Skip to content

Commit

Permalink
Add variables to PICDS (#8)
Browse files Browse the repository at this point in the history
* Add picdb ca and cai.

* Add sbp and dbp.

* Add tco2

* Add 1002 - 'pulse' to HR.

* fio2

* Add ph.

* po2

* Add sex.

* age.

* death

* height: get rid of biopsy variable.

* weight: get rid of labevents entry

* alb

* alt

* ast

* bili and bilidir.

* ck

* ckmb and cl

* fix conversion ckmb

* Add conversion to crea.

* glu add conversion.

* mg

* na

* phos

* tnt

* Fix outcome json.

* samp

* Add working `picdb_sampling`

* Fix unit conversion on `alb`

---------

Co-authored-by: Manuel Burger <[email protected]>
  • Loading branch information
mlondschien and manuelburger authored Mar 22, 2024
1 parent 1980f37 commit 7824352
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 46 deletions.
19 changes: 19 additions & 0 deletions R/callback-itm.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ mimic_sampling <- function(x, val_var, aux_time, ...) {
set(x, j = val_var, value = !is.na(x[[val_var]]))
}

picdb_sampling <- function(x, val_var, aux_time, ...) {
x <- combine_date_time(x, aux_time, hours(12L))

# These identifiers indicate that the culture showed no growth
# of the respective organism
no_growth_identifiers <- c('MIC1008', 'MIC2123', 'MIC2287', 'MIC2291', 'MIC2293',
'MIC2370', 'MIC2408', 'MIC2421', 'MIC575',
'MIC585', 'MIC593', 'MIC629', 'MIC631',
'MIC635', 'MIC637', 'MIC645', 'MIC648',
'MIC874', 'MIC941', 'MIC979'
)

# Assign:
# - 0 if NA or in no_growth_identifiers
# - 1 otherwise, indicating growth
bool_value <- !is.na(x[[val_var]]) & !(x[[val_var]] %in% no_growth_identifiers)
set(x, j = val_var, value = bool_value)
}

#' Item callback utilities
#'
#' For concept loading, item callback functions are used in order to handle
Expand Down
33 changes: 25 additions & 8 deletions inst/extdata/config/concept-dict/blood_gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"ids": 5215,
"table": "labevents",
"sub_var": "itemid"
}
]
}
},
"fio2": {
Expand Down Expand Up @@ -258,7 +264,14 @@
"sub_var": "DataID"
}
],
"picdb": []
"picdb": [
{
"ids": 5222,
"table": "labevents",
"sub_var": "itemid"
}

]
}
},
"hbco": {
Expand Down Expand Up @@ -614,10 +627,7 @@
"table": "labevents",
"ids": [
5237,
5238,
5373,
5374,
5386
5238
],
"sub_var": "itemid"
}
Expand Down Expand Up @@ -704,7 +714,8 @@
"table": "labevents",
"ids": [
5239,
5244
5244,
5242
],
"sub_var": "itemid"
}
Expand Down Expand Up @@ -756,7 +767,13 @@
"sub_var": "itemid"
}
],
"picdb": []
"picdb": [
{
"ids": 5256,
"table": "labevents",
"sub_var": "itemid"
}
]
}
}
}
123 changes: 106 additions & 17 deletions inst/extdata/config/concept-dict/chemistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@
{
"table": "labevents",
"ids": [
5024
5024,
6465
],
"sub_var": "itemid"
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 0.1), 'g/dL')"
}
]
}
Expand Down Expand Up @@ -231,7 +233,13 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"ids": [5026, 5195],
"table": "labevents",
"sub_var": "itemid"
}
]
}
},
"ast": {
Expand Down Expand Up @@ -304,7 +312,15 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"table": "labevents",
"ids": [
5031
],
"sub_var": "itemid"
}
]
}
},
"bicar": {
Expand Down Expand Up @@ -459,7 +475,16 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"table": "labevents",
"ids": [
5075
],
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 0.058467), 'mg/dL')"
}
]
}
},
"bili_dir": {
Expand Down Expand Up @@ -529,7 +554,16 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"table": "labevents",
"ids": [
5042
],
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 0.058467), 'mg/dL')"
}
]
}
},
"bun": {
Expand Down Expand Up @@ -603,7 +637,16 @@
"callback": "transform_fun(binary_op(`*`, 2.14))"
}
],
"picdb": []
"picdb": [
{
"table": "labevents",
"ids": [
5224
],
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 2.8), 'mg/dL')"
}
]
}
},
"ca": {
Expand Down Expand Up @@ -679,7 +722,14 @@
"callback": "transform_fun(binary_op(`*`, 4.008))"
}
],
"picdb": []
"picdb": [
{
"ids": 5034,
"table": "labevents",
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 4), 'mg/dL', 'mmol/L')"
}
]
}
},
"ck": {
Expand Down Expand Up @@ -752,7 +802,15 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"table": "labevents",
"ids": [
5038
],
"sub_var": "itemid"
}
]
}
},
"ckmb": {
Expand Down Expand Up @@ -819,7 +877,16 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"table": "labevents",
"ids": [
5039
],
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 0.1893), 'ng/mL', 'U/L')"
}
]
}
},
"cl": {
Expand Down Expand Up @@ -896,7 +963,15 @@
"sub_var": "LaboratoryID"
}
],
"picdb": []
"picdb": [
{
"table": "labevents",
"ids": [
5218
],
"sub_var": "itemid"
}
]
}
},
"crea": {
Expand Down Expand Up @@ -978,7 +1053,8 @@
5041,
6954
],
"sub_var": "itemid"
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 0.011312), 'mg/dL')"
}
]
}
Expand Down Expand Up @@ -1164,7 +1240,8 @@
5047,
5223
],
"sub_var": "itemid"
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 18.016), 'mg/dL')"
}
]
}
Expand Down Expand Up @@ -1340,7 +1417,8 @@
"ids": [
5059
],
"sub_var": "itemid"
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 2.431), 'mg/dL')"
}
]
}
Expand Down Expand Up @@ -1431,7 +1509,7 @@
{
"table": "labevents",
"ids": [
5062
5230
],
"sub_var": "itemid"
}
Expand Down Expand Up @@ -1515,7 +1593,8 @@
"ids": [
5072
],
"sub_var": "itemid"
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`*`, 3.097521), 'mg/dL')"
}
]
}
Expand Down Expand Up @@ -1592,7 +1671,17 @@
"ids": [
6525
],
"sub_var": "itemid"
"sub_var": "itemid",
"callback": "convert_unit(binary_op(`/`, 1000), 'ng/mL', 'pg/m')"
},
{
"table": "labevents",
"ids": [
6525
],
"sub_var": "itemid",
"val_var": "value",
"callback": "apply_map(c(`<0.003` = 0.003))"
}
]
}
Expand Down
36 changes: 18 additions & 18 deletions inst/extdata/config/concept-dict/demographics.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@
"class": "col_itm"
}
],
"picdb": []
"picdb": [
{
"table": "patients",
"val_var": "dob",
"callback": "transform_fun(mimic_age)",
"class": "col_itm"
}
]
}
},
"bmi": {
Expand Down Expand Up @@ -236,14 +243,7 @@
{
"table": "chartevents",
"ids": [
"1013"
],
"sub_var": "itemid"
},
{
"table": "labevents",
"ids": [
6322
1013
],
"sub_var": "itemid"
}
Expand Down Expand Up @@ -323,7 +323,14 @@
"class": "col_itm"
}
],
"picdb": []
"picdb": [
{
"table": "patients",
"val_var": "gender",
"class": "col_itm",
"callback": "apply_map(c(M = 'Male', F = 'Female'))"
}
]
}
},
"weight": {
Expand Down Expand Up @@ -406,14 +413,7 @@
{
"table": "chartevents",
"ids": [
"1014"
],
"sub_var": "itemid"
},
{
"table": "labevents",
"ids": [
6323
1014
],
"sub_var": "itemid"
}
Expand Down
Loading

0 comments on commit 7824352

Please sign in to comment.