Skip to content

Commit

Permalink
Integrate PICDB into RICU (#5)
Browse files Browse the repository at this point in the history
* Add picdb.json.

* Some fewer rows.

* Add "easy" entries to concept dicts.

* Add 'sub_var': 'itemid'

* Add some 'defaults' values.

* Get rid of surgery vital signs.

* load_difftime and id_win_helper for picdb.

* Add picdb to startup datasets

* Update row counts: chartevents, labevents

---------

Co-authored-by: Manuel Burger <[email protected]>
  • Loading branch information
mlondschien and manuelburger authored Mar 6, 2024
1 parent 0be6b80 commit 8e5c060
Show file tree
Hide file tree
Showing 15 changed files with 1,404 additions and 48 deletions.
12 changes: 12 additions & 0 deletions R/data-load.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ load_difftime.sic_tbl <- function(x, rows, cols = colnames(x),
load_eiau(x, {{ rows }}, cols, id_hint, time_vars, sec_as_mins)
}

#' @rdname load_src
#' @export
# copy-pasted from mimic_tbl
load_difftime.picdb_tbl <- function(x, rows, cols = colnames(x),
id_hint = id_vars(x),
time_vars = ricu::time_vars(x), ...) {

warn_dots(...)

load_mihi(x, {{ rows }}, cols, id_hint, time_vars)
}

#' @rdname load_src
#' @export
load_difftime.character <- function(x, src, ...) {
Expand Down
29 changes: 29 additions & 0 deletions R/data-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,35 @@ id_win_helper.miiv_env <- function(x) {
order_rename(res, ids, sta, end)
}

#' @rdname data_utils
#' @export
# copy-pasted from mimic
id_win_helper.picdb_env <- function(x) {

merge_inter <- function(x, y) {
merge(x, y, by = intersect(colnames(x), colnames(y)))
}

get_id_tbl <- function(tbl, id, start, end, aux) {
as_src_tbl(x, tbl)[, c(id, start, end, aux)]
}

cfg <- sort(as_id_cfg(x), decreasing = TRUE)

ids <- field(cfg, "id")
sta <- field(cfg, "start")
end <- field(cfg, "end")

res <- Map(get_id_tbl, field(cfg, "table"), ids, sta,
end, c(as.list(ids[-1L]), list(NULL)))
res <- Reduce(merge_inter, res)

res <- res[, c(sta, end) := lapply(.SD, as_dt_min, get(sta[1L])),
.SDcols = c(sta, end)]

order_rename(res, ids, sta, end)
}

#' @export
id_win_helper.default <- function(x) stop_generic(x, .Generic)

Expand Down
2 changes: 1 addition & 1 deletion R/utils-file.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ auto_attach_srcs <- function() {
res <- sys_env("RICU_SRC_LOAD", unset = NA_character_)

if (is.na(res)) {
c("mimic", "mimic_demo", "eicu", "eicu_demo", "hirid", "aumc", "miiv", "sic")
c("mimic", "mimic_demo", "eicu", "eicu_demo", "hirid", "aumc", "miiv", "sic", "picdb")
} else {
strsplit(res, ",")[[1L]]
}
Expand Down
79 changes: 76 additions & 3 deletions inst/extdata/config/concept-dict/blood_gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
"table": "laboratory",
"sub_var": "LaboratoryID"
}
],
"picdb": [
{
"table": "labevents",
"ids": [
5211,
5249
],
"sub_var": "itemid"
}
]
}
},
Expand Down Expand Up @@ -144,7 +154,8 @@
"table": "laboratory",
"sub_var": "LaboratoryID"
}
]
],
"picdb": []
}
},
"fio2": {
Expand Down Expand Up @@ -246,7 +257,8 @@
"table": "data_float_h",
"sub_var": "DataID"
}
]
],
"picdb": []
}
},
"hbco": {
Expand Down Expand Up @@ -282,6 +294,15 @@
"sub_var": "variableid",
"class": "hrd_itm"
}
],
"picdb": [
{
"table": "labevents",
"ids": [
5219
],
"sub_var": "itemid"
}
]
}
},
Expand Down Expand Up @@ -356,6 +377,15 @@
"table": "laboratory",
"sub_var": "LaboratoryID"
}
],
"picdb": [
{
"table": "labevents",
"ids": [
5227
],
"sub_var": "itemid"
}
]
}
},
Expand Down Expand Up @@ -416,6 +446,15 @@
"table": "labevents",
"sub_var": "itemid"
}
],
"picdb": [
{
"table": "labevents",
"ids": [
5228
],
"sub_var": "itemid"
}
]
}
},
Expand Down Expand Up @@ -490,6 +529,16 @@
"table": "laboratory",
"sub_var": "LaboratoryID"
}
],
"picdb": [
{
"table": "labevents",
"ids": [
5235,
5236
],
"sub_var": "itemid"
}
]
}
},
Expand Down Expand Up @@ -559,6 +608,19 @@
"table": "laboratory",
"sub_var": "LaboratoryID"
}
],
"picdb": [
{
"table": "labevents",
"ids": [
5237,
5238,
5373,
5374,
5386
],
"sub_var": "itemid"
}
]
}
},
Expand Down Expand Up @@ -636,6 +698,16 @@
"table": "laboratory",
"sub_var": "LaboratoryID"
}
],
"picdb": [
{
"table": "labevents",
"ids": [
5239,
5244
],
"sub_var": "itemid"
}
]
}
},
Expand Down Expand Up @@ -683,7 +755,8 @@
"table": "labevents",
"sub_var": "itemid"
}
]
],
"picdb": []
}
}
}
Loading

0 comments on commit 8e5c060

Please sign in to comment.