diff --git a/R/callback-circ-fail.R b/R/callback-circ-fail.R new file mode 100644 index 00000000..25cc6c76 --- /dev/null +++ b/R/callback-circ-fail.R @@ -0,0 +1,183 @@ +# ============================================================================== +# +# Callback for circulatory failure +# Implementation by `prockenschaub` +# from: https://github.com/prockenschaub/icuDG-preprocessing/blob/main/R/callback-circ-fail.R +# +# ============================================================================== + +circ_fail <- function (..., lact_thresh = 2, map_thresh = 65, + fill_for = hours(3L), cond_win = mins(45L), + cond_dur = mins(30L), keep_components = FALSE, + interval = NULL, by_ref = FALSE) { + cnc <- c("map", "cf_treat", "lact") + res <- ricu:::collect_dots(cnc, interval, ...) + assert_that(lact_thresh >= 0, map_thresh >= 0, + ricu:::is_interval(fill_for), ricu:::is_interval(cond_win), + ricu:::is_interval(cond_dur), is.flag(keep_components), + units(cond_win) == units(cond_dur), cond_dur < cond_win) + + map <- res[["map"]] + cf_treat <- res[["cf_treat"]] + lact <- res[["lact"]] + + if (!by_ref) { + map <- copy(map) + cf_treat <- copy(cf_treat) + lact <- copy(lact) + } + + id <- id_vars(map) + step_size <- interval(map) + + assert_that(units(step_size) == units(cond_win)) + + p <- as.numeric(cond_dur) / as.numeric(cond_win) + steps <- as.integer(cond_win / as.numeric(step_size)) + + # Interpolate lactate values + map_times <- map[, .SD, .SDcols = meta_vars(map)] + map_limits <- ricu::collapse(map_times, as_win_tbl = FALSE) + grid_times <- fill_gaps(map_times, map_limits) + lact <- interpolate_lactate(lact, grid_times, lact_thresh, fill_for) + + # Combine MAP, vasopress/inotrope meds, and lactate to define cf + res <- merge_lst(list(map, cf_treat, lact)) + + .rmean <- function(x) frollmean(x, steps, align = "center") + .thresh <- function(x, op, val) fifelse(!is.na(x), op(x, val), FALSE) + + res[, miss := pmax(.rmean(is.na(map)), .rmean(is.na(lact))) == 1, by = c(id)] + res[, low_map := .rmean(.thresh(map, `<`, map_thresh)), by = c(id)] + res[, treated := .rmean(!is.na(cf_treat)), by = c(id)] + res[, high_lact := .rmean(.thresh(lact, `>`, lact_thresh)), by = c(id)] + res[, circ_fail := fcase( + miss, NA, + (low_map <= p | treated <= p) & high_lact <= p, FALSE, + (low_map > p | treated > p) & high_lact > p, TRUE, + default = NA + )] + + cols_rm <- c("miss", "low_map", "treated", "high_lact") + if (!keep_components) { + cols_rm <- c(cols_rm, "map", "cf_treat", "lact") + } + res <- rm_cols(res, cols_rm, skip_absent = TRUE, by_ref = TRUE) + + res +} + +approx <- function(x, y = NULL, xout, ...) { + if (length(x) == 1) { + return(list(x = x, y = y)) + } + stats::approx(x, y, xout, ...) +} + +# TODO: bring in line with ricu::replace_na +replace_na <- function(x, val, type = "const", max_n = Inf, ...) { + seq_num <- rleid(is.na(x)) + imp_cnt <- sapply(split(x, seq_num), function(x) seq_along(x)) + + if (type == "nocb") { + imp_cnt <- Map(rev, imp_cnt) + } + + imp_cnt <- Reduce(c, imp_cnt) + + if (identical(type, "const")) { + repl <- data.table::nafill(x, type, val, ...) + } + else { + repl <- data.table::nafill(x, type, ...) + } + + fifelse(imp_cnt <= max_n, repl, x) +} + +interpolate_lactate <- function(df, grid_times, thresh, fill_win = hours(3L)) { + id <- id_vars(df) + ind <- index_var(df) + val <- data_var(df) + + step_size <- interval(df) + fill_win <- ricu:::re_time(fill_win, step_size) + + df[, abn := .SD[[val]] >= thresh] # TODO: generalise to allow for < thresh + df[, tdiff := c(diff(.SD[[ind]]), NA_real_), by = c(id)] + + # Linearly interpolate everything + rep_to_interpol_grid <- function(x, d) { + rep(x, times = fifelse(is.na(d), 1., as.numeric(d) / as.numeric(step_size))) + } + + int_lin_cond <- expr(abn == shift(abn, type = "lead") | tdiff < 2 * fill_win) + df[, int_lin := eval(int_lin_cond), by = c(id)] + + df <- df[, c( + # Expand all existing columns to match length of interpolation + lapply(.SD, rep_to_interpol_grid, d = tdiff), + # Linearly interpolate every observation (for speed, ffill/bfill later) + approx(.SD[[ind]], .SD[[val]], xout = seq(as.numeric(.SD[[ind]][1]), as.numeric(.SD[[ind]][.N]), by = as.numeric(step_size))) + ), + by = c(id) + ] + + df[x == get(ind), int_lin := TRUE] + df[int_lin == FALSE , y := NA_real_] + + # Replace linear with forward/backward fill if consecutive values crossed + # thresh and are more than `fill_win` apart + max_n <- as.numeric(fill_win) / as.numeric(step_size) + df[, y := fifelse(!int_lin, replace_na(y, type = "locf", max_n = max_n), y), by = c(id)] + df[, y := fifelse(!int_lin, replace_na(y, type = "nocb", max_n = max_n), y), by = c(id)] + + # Clean up table + df[, c(ind) := as.difftime(x, units = attr(step_size, "units"))] + df[, c(val) := y] + df <- df[, .SD, .SDcols = c(id, ind, val, "abn")] + + # Forward/backward fill the first and last observation over grid + df <- merge(df, grid_times, all = TRUE) + df[, abn_int := replace_na(as.integer(abn), type = "nocb"), by = c(id)] + df[, c(val) := fcase( + !is.na(abn), .SD[[val]], # If not first, do nothing + abn_int == 0, replace_na(.SD[[val]], type = "nocb"), # If first val normal, infinite bfill + abn_int == 1, replace_na(.SD[[val]], type = "nocb", max_n = max_n), # If first val abnormal, bfill `max_n` steps + rep(TRUE, .N), .SD[[val]] + ), + by = c(id) + ] + df[, abn_int := replace_na(as.integer(abn), type = "locf"), by = c(id)] + df[, c(val) := fcase( + !is.na(abn), .SD[[val]], # If not last, do nothing + abn_int == 0, replace_na(.SD[[val]], type = "locf"), # If last val normal, infinite ffill + abn_int == 1, replace_na(.SD[[val]], type = "locf", max_n = max_n), # If last val abnormal, ffill `max_n` steps + rep(TRUE, .N), .SD[[val]] + ), + by = c(id) + ] + + df[, .SD, .SDcols = c(id, ind, val)] +} + +cf_treat <- function(..., interval = NULL) { + + cnc <- c("epi_dur", "norepi_dur", "dopa_dur", "dobu_dur", "adh_dur", "phn_dur", + "levo_dur", "milrin_dur", "teophyllin_dur") + res <- ricu:::collect_dots(cnc, interval, ..., merge_dat = TRUE) + unt <- ricu::time_unit(res) + + res <- res[, c(cnc) := lapply(.SD, as.difftime, units = unt), .SDcols = cnc] + res <- res[, c("cf_treat", cnc) := list(pmax( + get("dopa_dur"), get("norepi_dur"), get("dobu_dur"), get("epi_dur"), + get("adh_dur"), get("phn_dur"), get("levo_dur"), get("milrin_dur"), get("teophyllin_dur"), + na.rm = TRUE), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) + ] + + res <- expand(res, index_var(res), "cf_treat") + res <- unique(res) + res <- res[, c("cf_treat") := TRUE] + + res +} diff --git a/R/callback-cncpt.R b/R/callback-cncpt.R index cd919e0f..d640ce01 100644 --- a/R/callback-cncpt.R +++ b/R/callback-cncpt.R @@ -615,6 +615,30 @@ bmi <- function(..., interval = NULL) { res } +#' @rdname callback_cncpt +#' @export +o2sat_lab_first <- function(..., interval = NULL) { + + # Pulse Oxymetry: `spo2` + # Arterial Blood Gas: `sao2` + cnc <- c("sao2", "spo2") + res <- collect_dots(cnc, interval, ..., merge_dat = TRUE) + + # default to sao2 (arterial blood gas) + res <- res[, o2sat := sao2] + + # if sao2 is missing, use spo2 (pulse oxymetry) + res <- res[is.na(sao2), o2sat := spo2] + + # Filter out values below 50 and above 100 + res <- filter_bounds(res, "o2sat", 50, 100) + + # remove sao2 and spo2 columns + res <- rm_cols(res, cnc, by_ref = TRUE) + + res +} + #' @rdname callback_cncpt #' @export norepi_equiv <- function(..., interval = NULL) { diff --git a/R/callback-icu-mortality.R b/R/callback-icu-mortality.R new file mode 100644 index 00000000..0b6fc7b2 --- /dev/null +++ b/R/callback-icu-mortality.R @@ -0,0 +1,63 @@ +# ============================================================================== +# +# Refined ICU mortality callbacks +# +# based on YAIB: https://github.com/rvandewater/YAIB-cohorts/tree/main/ricu-extensions/callbacks +# ============================================================================== + +aumc_death_icu <- function (x, val_var, death_date, ...) { + # Identify ICU mortality in AUMCdb via the discharge destination field. Use + # discharge time from the ICU as death time, as date of death sometimes only + # contain the date part and no time (i.e., 00:00:00). + # + # See discussions here: + # https://github.com/AmsterdamUMC/AmsterdamUMCdb/issues/56 + # https://github.com/AmsterdamUMC/AmsterdamUMCdb/issues/61 + idx <- index_var(x) + x[, `:=`(c(val_var), ricu:::is_true(get(val_var) == "Overleden"))] + x[get(death_date) - get(idx) > hours(24L), `:=`(c(val_var), FALSE)] + x +} + +hirid_death_icu <- function (x, val_var, sub_var, env, ...) { + dis <- "discharge_status" + idx <- index_var(x) + idc <- id_vars(x) + res <- dt_gforce(x, "last", by = idc, vars = idx) + tmp <- load_id(env[["general"]], cols = dis) + res <- merge(res, tmp[ricu:::is_true(get(dis) == "dead"), ]) + res <- res[, `:=`(c(val_var, dis), list(TRUE, NULL))] + res +} + +mi_death_icu <- function(x, transfers, icu_wards, ...) { + # Look for all hospital deaths in which the last careunit was an ICU. + # See discussion here: https://github.com/MIT-LCP/mimic-code/issues/874 + id <- id_vars(transfers) + lead <- function(x) data.table:::shift(x, type = "lead") + + transfers[, is_last := ricu:::is_true(lead(eventtype) == "discharge")] + last_ward <- transfers[, .(ward = ward[is_last]), by = c(id)] + last_ward[, "is_icu" := .(ricu:::is_true(ward %in% icu_wards))] + + dat <- data_var(x) + x[(last_ward[is_icu == FALSE]), c(dat) := 0L] + x[, c(dat) := ricu:::is_true(get(dat) == 1L)] + x +} + +mimic_death_icu <- function(x, env, ...){ + icu_wards <- sort(unique(env[["icustays"]]$first_careunit)) + transfers <- load_ts(env[["transfers"]], id_var = "hadm_id", index_var = "intime", interval = mins(1L)) + transfers <- change_id(transfers, "icustay", as_src_cfg(env), id_type = TRUE) + rename_cols(transfers, "ward", "curr_careunit", by_ref = TRUE) + mi_death_icu(x, transfers, icu_wards, ...) +} + +miiv_death_icu <- function(x, env, ...){ + icu_wards <- sort(unique(env[["icustays"]]$first_careunit)) + transfers <- load_ts(env[["transfers"]], index_var = "intime") + rename_cols(transfers, "ward", "careunit", by_ref = TRUE) + mi_death_icu(x, transfers, icu_wards, ...) +} + diff --git a/R/callback-kdigo.R b/R/callback-kdigo.R new file mode 100644 index 00000000..644b4ea8 --- /dev/null +++ b/R/callback-kdigo.R @@ -0,0 +1,140 @@ +# ============================================================================== +# +# KDIGO Callbacks +# +# based on YAIB: https://github.com/rvandewater/YAIB-cohorts/tree/main/ricu-extensions/callbacks +# ============================================================================== +kdigo_crea <- function(..., keep_components = FALSE, interval = NULL) { + cnc <- c("crea") + crea <- ricu:::collect_dots(cnc, interval, ...) + + id <- id_vars(crea) + ind <- index_var(crea) + + min_over_period <- function(dur = hours(1L)) { + cdur <- as.character(dur) + summ <- slide( + crea, + list(crea = min(get("crea"), na.rm = TRUE)), + dur, + left_closed = FALSE + ) + rename_cols(summ, paste0("crea_", cdur, "hr"), "crea") + } + + res <- lapply(hours(2 * 24, 7 * 24), min_over_period) + res <- merge_lst(c(list(crea), res)) + res[, kdigo_crea := data.table::fcase( + crea >= 3 * crea_168hr , 3L, + crea >= 4 & + (crea - crea_48hr >= 0.3 | + crea >= 1.5 * crea_168hr) , 3L, + crea >= 2 * crea_168hr , 2L, + crea >= crea_48hr + 0.3 , 1L, + crea >= 1.5 * crea_168hr , 1L, + default = 0L + )] + + cols_rm <- c("crea_48hr", "crea_168hr") + if (!keep_components) { + cols_rm <- c(cols_rm, "crea") + } + res <- rm_cols(res, cols_rm, skip_absent = TRUE, by_ref = TRUE) + res +} + + +urine_rate <- function(x, max_gap = hours(24L), interval = NULL, id_type = "icustay") { + # TODO: Does not currently work as a rec_cncpt. For example, currently keep_components = TRUE would lead to + # a situation in which `urine` and not `urine_rate` is passed back. This is likely because `fun_itm`, + # which is currently expects a table with a single column. If multiple are present, it chooses the first, + # which in this case is `urine`. Unhelpfully, this is then renamed to `urine_rate`, hiding this + # behaviour. + # Solution: remove keep_components for now and use only as `fun_itm` + id <- id_var(x) + ind <- index_var(x) + + res <- rename_cols(x, "urine", old = data_var(x)) + + res[, tm := get(ind) - data.table::shift(get(ind)) + 1L, by = c(id)] + res[, tm := ifelse(is.na(tm) | tm > max_gap, 1, tm)] + res[, val_var := urine / tm] + + cols_rm <- c("tm", "urine") + res <- rm_cols(res, cols_rm, skip_absent = TRUE, by_ref = TRUE) + res +} + + +kdigo_urine <- function(..., keep_components = FALSE, interval = NULL) { + cnc <- c("urine_rate", "weight") + res <- ricu:::collect_dots(cnc, interval, ...) + urine_rate <- res[["urine_rate"]] + weight <- res[["weight"]] + + id <- id_vars(urine_rate) + ind <- index_var(urine_rate) + + rate_over_period <- function(dur = hours(1L)) { + name <- paste0("urine_rate_", as.character(dur), "hr") + summ <- slide(urine_rate, list(urine_h = sum(get("urine_rate"), na.rm = TRUE)), dur, left_closed = FALSE) + summ[weight, urine_h := urine_h / ifelse(is.na(weight), 75, weight), on = c(id)] + summ <- rename_cols(summ, name, "urine_h") + summ[, .SD, .SDcols = c(id, ind, name)] + } + + res <- lapply(hours(6L, 12L, 24L), rate_over_period) + res <- merge_lst(c(list(urine_rate, weight), res)) + res[, kdigo_urine := data.table::fcase( # TODO: make work with intervals other than + get(ind) >= hours(24L) & urine_rate_24hr < 0.3, 3L, + get(ind) >= hours(12L) & urine_rate_12hr == 0 , 3L, + get(ind) >= hours(12L) & urine_rate_12hr < 0.5, 2L, + get(ind) >= hours(6L) & urine_rate_6hr < 0.5, 1L, + default = 0L + )] + + cols_rm <- c( + "urine_rate_6hr", "urine_rate_12hr", "urine_rate_24hr" + ) + if (!keep_components) { + cols_rm <- c(cols_rm, "urine_rate", "weight") + } + res <- rm_cols(res, cols_rm, skip_absent = TRUE, by_ref = TRUE) + res +} + + +kdigo <- function(..., keep_components = FALSE, interval = NULL) { + cnc <- c("kdigo_crea", "kdigo_urine") + res <- ricu:::collect_dots(cnc, interval, ...) + kdigo_crea <- res[["kdigo_crea"]] + kdigo_urine <- res[["kdigo_urine"]] + + idc <- id_vars(kdigo_crea) + indc <- index_var(kdigo_crea) + idu <- id_vars(kdigo_urine) + indu <- index_var(kdigo_urine) + + res <- merge(kdigo_crea, kdigo_urine, by.x = c(idc, indc), by.y = c(idu, indu), all = TRUE) + res[, kdigo := pmax(kdigo_crea, kdigo_urine, na.rm = TRUE)] + + if (!keep_components) { + cols_rm <- c("kdigo_crea", "kdigo_urine") + res <- rm_cols(res, cols_rm, skip_absent = TRUE, by_ref = TRUE) + } + res +} + + +aki <- function(..., threshold = 1L, interval = NULL, keep_components = FALSE) { + + cnc <- c("kdigo") + res <- ricu:::collect_dots(cnc, interval, ...) + res[, aki := kdigo >= threshold] + + if (!keep_components) { + res <- rm_cols(res, "kdigo", skip_absent = TRUE, by_ref = TRUE) + } + + res[aki == TRUE] +} diff --git a/R/callback-sep3.R b/R/callback-sep3.R index b49aba12..2effb004 100644 --- a/R/callback-sep3.R +++ b/R/callback-sep3.R @@ -432,3 +432,131 @@ si_or <- function(abx, samp, abx_win, samp_win, keep) { res } + + +# ============================================================================== +# Alternative sepsis3 implementations +# based on: https://github.com/rvandewater/YAIB-cohorts/tree/main/ricu-extensions/callbacks +# ============================================================================== +cummax_difftime <- function(x){ + # TODO: change to allow other intervals than hours + as.difftime(cummax(as.numeric(x)), units = "hours") +} +lead <- function(x) { + data.table::shift(x, type="lead") +} + +abx_cont <- function(..., abx_win = hours(72L), abx_max_gap = hours(24L), keep_components = FALSE, interval = NULL) { + cnc <- c("abx_duration", "death_icu") + res <- ricu:::collect_dots(cnc, interval, ...) + abx <- res[["abx_duration"]] + death_icu <- res[["death_icu"]] + + aid <- id_vars(abx) + aind <- index_var(abx) + adur <- dur_var(abx) + did <- id_vars(death_icu) + dind <- index_var(death_icu) + + abx <- as_ts_tbl(abx) + abx <- abx[, .(dur_var = max(get(adur))), by = c(aid, aind)] + death_icu <- death_icu[death_icu == TRUE] + abx_death <- merge(abx, death_icu, by.x = aid, by.y = did, all.x = TRUE) + + res <- slide( + # Only look at antibiotic records that are recorded before the time of death + abx_death[is.na(get(dind)) | get(aind) <= get(dind)], + .( + # Calculate the maximum gap between two administrations for the next `abx_win` hours + # as follows: + # + # 1. get the administration time of the next antibiotic: + # lead(get(aind)) + # 2. this isn't defined for the last (.N-th) time within the window, so remove that + # lead(get(aind))[-.N]: + # 3. replace the last time with either + # a) the time of death: + # get(dind) + # b) the first antibiotic time in the window (=current antibiotic we are looking at) + # plus the window lenght + # get(aind)[1] + abx_win + # whichever is earlier + # 4. subtract from it the latest time that any previous antibiotic was stopped + # cummax_difftime(get(aind) + dur_var) + # this is the gap + # 5. take the maximum gap calculated this way for this window + # 6. repeat for all possible windows + max_gap = max( + c(lead(get(aind))[-.N], min(c(get(dind), get(aind)[1] + abx_win), na.rm = TRUE)) - + cummax_difftime(get(aind) + dur_var) + ) + ), + before = hours(0L), # we always start from the current antibiotic and look `abx_win` in the future + after = abx_win + ) + + res <- res[max_gap <= abx_max_gap] + res[, c("abx_cont", "max_gap") := .(TRUE, NULL)] + res +} + + +susp_inf_abx_cont <- function(..., abx_count_win = hours(24L), abx_min_count = 1L, + positive_cultures = FALSE, si_mode = c("and", "or", "abx", "samp"), + abx_win = hours(24L), samp_win = hours(72L), + by_ref = TRUE, keep_components = FALSE, interval = NULL) +{ + cnc <- c("abx_cont", "samp") + res <- ricu:::collect_dots(cnc, interval, ...) + abx_cont <- res[["abx_cont"]] + samp <- res[['samp']] + + # make `abx_cont` look like abx to pass on to the original ricu::susp_inf + rename_cols(abx_cont, "abx", "abx_cont", by_ref = TRUE) + + # pass the rest of the calculations to ricu::susp_inf + res <- ricu::susp_inf( + abx = abx_cont, + samp = samp, + abx_count_win = abx_count_win, + abx_min_count = abx_min_count, + positive_cultures = positive_cultures, + si_mode = si_mode, + abx_win = abx_win, + samp_win = samp_win, + by_ref = by_ref, + keep_components = keep_components, + interval = interval + ) + rename_cols(res, "susp_inf_abx_cont", "susp_inf", by_ref = TRUE) + res +} + + +sep3_abx_cont <- function (..., si_window = c("first", "last", "any"), delta_fun = delta_cummin, + sofa_thresh = 2L, si_lwr = hours(48L), si_upr = hours(24L), + keep_components = FALSE, interval = NULL) +{ + cnc <- c("sofa", "susp_inf_abx_cont") + res <- ricu:::collect_dots(cnc, interval, ...) + sofa <- res[["sofa"]] + susp <- res[["susp_inf_abx_cont"]] + + # make `susp_inf_abx_cont` look like susp_inf to pass on to the original ricu::sep3 + rename_cols(susp, "susp_inf", "susp_inf_abx_cont", by_ref = TRUE) + + # pass the rest of the calculations to ricu::susp_inf + res <- ricu::sep3( + sofa = sofa, + susp_inf = susp, + si_window = si_window, + delta_fun = delta_fun, + sofa_thresh = sofa_thresh, + si_lwr = si_lwr, + si_upr = si_upr, + keep_components = keep_components, + interval = interval + ) + rename_cols(res, "sep3_alt", "sep3", by_ref = TRUE) + res +} diff --git a/inst/extdata/config/concept-dict/chemistry.json b/inst/extdata/config/concept-dict/chemistry.json index 12e92d91..d0560498 100644 --- a/inst/extdata/config/concept-dict/chemistry.json +++ b/inst/extdata/config/concept-dict/chemistry.json @@ -43,7 +43,7 @@ ], "miiv": [ { - "ids": 50862, + "ids": [50862, 53085], "table": "labevents", "sub_var": "itemid" } @@ -127,7 +127,7 @@ ], "miiv": [ { - "ids": 50863, + "ids": [50863, 53086], "table": "labevents", "sub_var": "itemid" } @@ -454,7 +454,7 @@ ], "miiv": [ { - "ids": 50885, + "ids": [50885, 53089], "table": "labevents", "sub_var": "itemid" } @@ -506,7 +506,7 @@ "ids": 6812, "table": "numericitems", "sub_var": "itemid", - "callback": "convert_unit(binary_op(`*`, 0.058467), 'mg/dL')" + "callback": "convert_unit(binary_op(`*`, 1.), 'mg/dL')" } ], "eicu": [ @@ -825,7 +825,8 @@ { "ids": 6824, "table": "numericitems", - "sub_var": "itemid" + "sub_var": "itemid", + "callback": "convert_unit(binary_op(`*`, 0.2), 'ng/mL')" } ], "eicu": [ diff --git a/inst/extdata/config/concept-dict/circulatory.json b/inst/extdata/config/concept-dict/circulatory.json new file mode 100644 index 00000000..9d37f4fb --- /dev/null +++ b/inst/extdata/config/concept-dict/circulatory.json @@ -0,0 +1,19 @@ +{ + "mech_circ": { + "description": "mechanical circulatory support", + "class": "lgl_cncpt", + "target": "id_tbl", + "category": "circulatory", + "sources": { + "mimic": [ + { + "ids": ["3752", "3760", "3765", "3766", "3768"], + "table": "procedures_icd", + "sub_var": "icd9_code", + "val_var": "seq_num", + "callback": "transform_fun(set_val(TRUE))" + } + ] + } + } +} \ No newline at end of file diff --git a/inst/extdata/config/concept-dict/demographics.json b/inst/extdata/config/concept-dict/demographics.json index f4723d6d..811a2bb1 100644 --- a/inst/extdata/config/concept-dict/demographics.json +++ b/inst/extdata/config/concept-dict/demographics.json @@ -419,5 +419,86 @@ } ] } - } + }, + "ethnic": { + "target": "id_tbl", + "levels": ["asian", "black", "white", "other"], + "class": "fct_cncpt", + "description": "ethnicity", + "category": "demographics", + "sources": { + "eicu": [ + { + "table": "patient", + "val_var": "ethnicity", + "callback": "apply_map(c(`African American` = 'black', Asian = 'asian', Caucasian = 'white', Hispanic = 'other', `Native American` = 'other', `Other/Unknown` = 'other'))", + "class": "col_itm" + } + ], + "eicu_demo": [ + { + "table": "patient", + "val_var": "ethnicity", + "callback": "apply_map(c(`African American` = 'black', Asian = 'asian', Caucasian = 'white', Hispanic = 'other', `Native American` = 'other', `Other/Unknown` = 'other'))", + "class": "col_itm" + } + ], + "miiv": [ + { + "table": "admissions", + "val_var": "race", + "callback": "apply_map(c(`AMERICAN INDIAN/ALASKA NATIVE` = 'other', ASIAN = 'asian', `ASIAN - ASIAN INDIAN` = 'asian', `ASIAN - CHINESE` = 'asian', `ASIAN - KOREAN` = 'asian', `ASIAN - SOUTH EAST ASIAN` = 'asian', `BLACK/AFRICAN` = 'black', `BLACK/AFRICAN AMERICAN` = 'black', `BLACK/CAPE VERDEAN` = 'black', `BLACK/CARIBBEAN ISLAND` = 'black', `HISPANIC OR LATINO` = 'other', `HISPANIC/LATINO - CENTRAL AMERICAN` = 'other', `HISPANIC/LATINO - COLUMBIAN` = 'other', `HISPANIC/LATINO - CUBAN` = 'other', `HISPANIC/LATINO - DOMINICAN` = 'other', `HISPANIC/LATINO - GUATEMALAN` = 'other', `HISPANIC/LATINO - HONDURAN` = 'other', `HISPANIC/LATINO - MEXICAN` = 'other', `HISPANIC/LATINO - PUERTO RICAN` = 'other', `HISPANIC/LATINO - SALVADORAN` = 'other', `MULTIPLE RACE/ETHNICITY NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER` = 'other', `OTHER` = 'other', `PATIENT DECLINED TO ANSWER` = NA, `PORTUGUESE` = 'white', `SOUTH AMERICAN` = 'other', `UNABLE TO OBTAIN` = NA, `UNKNOWN` = NA, `WHITE` = 'white', `WHITE - BRAZILIAN` = 'white', `WHITE - EASTERN EUROPEAN` = 'white', `WHITE - OTHER EUROPEAN` = 'white', `WHITE - RUSSIAN` = 'white'))", + "class": "col_itm" + } + ], + "mimic": [ + { + "table": "admissions", + "val_var": "ethnicity", + "callback": "apply_map(c(`AMERICAN INDIAN/ALASKA NATIVE` = 'other', `AMERICAN INDIAN/ALASKA NATIVE FEDERALLY RECOGNIZED TRIBE` = 'other', ASIAN = 'asian', `ASIAN - ASIAN INDIAN` = 'asian', `ASIAN - CAMBODIAN` = 'asian', `ASIAN - CHINESE` = 'asian', `ASIAN - FILIPINO` = 'asian', `ASIAN - JAPANESE` = 'asian', `ASIAN - KOREAN` = 'asian', `ASIAN - OTHER` = 'asian', `ASIAN - THAI` = 'asian', `ASIAN - VIETNAMESE` = 'asian',`BLACK/AFRICAN` = 'black', `BLACK/AFRICAN AMERICAN` = 'black', `BLACK/CAPE VERDEAN` = 'black', `BLACK/HAITIAN` = 'black', `CARIBBEAN ISLAND` = 'black', `HISPANIC OR LATINO` = 'other', `HISPANIC/LATINO - CENTRAL AMERICAN (OTHER)` = 'other', `HISPANIC/LATINO - COLOMBIAN` = 'other', `HISPANIC/LATINO - CUBAN` = 'other', `HISPANIC/LATINO - DOMINICAN` = 'other', `HISPANIC/LATINO - GUATEMALAN` = 'other', `HISPANIC/LATINO - HONDURAN` = 'other', `HISPANIC/LATINO - MEXICAN` = 'other', `HISPANIC/LATINO - PUERTO RICAN` = 'other', `HISPANIC/LATINO - SALVADORAN` = 'other', `MIDDLE EASTERN` = 'other', `MULTI RACE ETHNICITY` = 'other', `NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER` = 'other', `OTHER` = 'other', `PATIENT DECLINED TO ANSWER` = NA, `PORTUGUESE` = 'white', `SOUTH AMERICAN` = 'other', `UNABLE TO OBTAIN` = NA, `UNKNOWN/NOT SPECIFIED` = NA, `WHITE` = 'white', `WHITE - BRAZILIAN` = 'white', `WHITE - EASTERN EUROPEAN` = 'white', `WHITE - OTHER EUROPEAN` = 'white', `WHITE - RUSSIAN` = 'white'))", + "class": "col_itm" + } + ], + "mimic_demo": [ + { + "table": "admissions", + "val_var": "ethnicity", + "callback": "apply_map(c(`AMERICAN INDIAN/ALASKA NATIVE` = 'other', `AMERICAN INDIAN/ALASKA NATIVE FEDERALLY RECOGNIZED TRIBE` = 'other', ASIAN = 'asian', `ASIAN - ASIAN INDIAN` = 'asian', `ASIAN - CAMBODIAN` = 'asian', `ASIAN - CHINESE` = 'asian', `ASIAN - FILIPINO` = 'asian', `ASIAN - JAPANESE` = 'asian', `ASIAN - KOREAN` = 'asian', `ASIAN - OTHER` = 'asian', `ASIAN - THAI` = 'asian', `ASIAN - VIETNAMESE` = 'asian',`BLACK/AFRICAN` = 'black', `BLACK/AFRICAN AMERICAN` = 'black', `BLACK/CAPE VERDEAN` = 'black', `BLACK/HAITIAN` = 'black', `CARIBBEAN ISLAND` = 'black', `HISPANIC OR LATINO` = 'other', `HISPANIC/LATINO - CENTRAL AMERICAN (OTHER)` = 'other', `HISPANIC/LATINO - COLOMBIAN` = 'other', `HISPANIC/LATINO - CUBAN` = 'other', `HISPANIC/LATINO - DOMINICAN` = 'other', `HISPANIC/LATINO - GUATEMALAN` = 'other', `HISPANIC/LATINO - HONDURAN` = 'other', `HISPANIC/LATINO - MEXICAN` = 'other', `HISPANIC/LATINO - PUERTO RICAN` = 'other', `HISPANIC/LATINO - SALVADORAN` = 'other', `MIDDLE EASTERN` = 'other', `MULTI RACE ETHNICITY` = 'other', `NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER` = 'other', `OTHER` = 'other', `PATIENT DECLINED TO ANSWER` = NA, `PORTUGUESE` = 'white', `SOUTH AMERICAN` = 'other', `UNABLE TO OBTAIN` = NA, `UNKNOWN/NOT SPECIFIED` = NA, `WHITE` = 'white', `WHITE - BRAZILIAN` = 'white', `WHITE - EASTERN EUROPEAN` = 'white', `WHITE - OTHER EUROPEAN` = 'white', `WHITE - RUSSIAN` = 'white'))", + "class": "col_itm" + } + ], + "picdb": [ + { + "table": "admissions", + "val_var": "ethnicity", + "callback": "apply_map(c(`Hui ethnic` = 'asian', `Buyei ethnic` = 'asian', `Han ethnic` = 'asian', `Yi ethnic` = 'asian', `Miao ethnic` = 'asian', `Others` = 'other', `Tujia ethnic` = 'asian'))", + "class": "col_itm" + } + ] + } + }, + "insurance": { + "target": "id_tbl", + "levels": ["Government", "Medicaid", "Medicare", "Private", "Self Pay"], + "class": "fct_cncpt", + "description": "insurance", + "category": "demographics", + "sources": { + "mimic": [{ + "table": "admissions", + "val_var": "insurance", + "class": "col_itm" + }], + "mimic_demo": [{ + "table": "admissions", + "val_var": "insurance", + "class": "col_itm" + }], + "miiv": [{ + "table": "admissions", + "val_var": "insurance", + "class": "col_itm" + }] + } + } } \ No newline at end of file diff --git a/inst/extdata/config/concept-dict/hematology.json b/inst/extdata/config/concept-dict/hematology.json index 735e071b..73193b6c 100644 --- a/inst/extdata/config/concept-dict/hematology.json +++ b/inst/extdata/config/concept-dict/hematology.json @@ -825,9 +825,9 @@ "ids": 24000170, "table": "observations", "sub_var": "variableid", - "callback": "convert_unit(binary_op(`*`, 0.16114), '%')", + "callback": "convert_unit(binary_op(`*`, 0.1), '%')", "class": "hrd_itm" - } + } ], "miiv": [ { @@ -990,8 +990,9 @@ "ids": 24000550, "table": "observations", "sub_var": "variableid", - "class": "hrd_itm" - } + "class": "hrd_itm", + "callback": "blood_cell_ratio" + } ], "miiv": [ { diff --git a/inst/extdata/config/concept-dict/medications.json b/inst/extdata/config/concept-dict/medications.json index 770deb8f..98f0b821 100644 --- a/inst/extdata/config/concept-dict/medications.json +++ b/inst/extdata/config/concept-dict/medications.json @@ -417,6 +417,102 @@ "picdb": [] } }, + "abx_cont": { + "description": "continuous antibiotic administration", + "concepts": ["abx_duration", "death_icu"], + "category": "medications", + "callback": "abx_cont", + "class": "rec_cncpt" + }, + "abx_duration": { + "description": "duration of administered antibiotics", + "category": "medications", + "target": "win_tbl", + "class": "lgl_cncpt", + "sources": { + "aumc": [ + { + "ids": [2, 13, 19, 24, 28, 29, 57, 59, 82, 103, 240, 247, 333, 1133, 1199, 1300, 1371, 1795, 2284, 2834, 3237, 3741, 5576, 6834, 6847, 6871, 6919, 6948, 6953, 6958, 7044, 7064, 7185, 7187, 7208, 7227, 7235, 8064, 8394, 8942, 9029, 9030, 9052, 9070, 9117, 9128, 9133, 9142, 9151, 9152, 12262, 12389, 12398, 12956, 12997, 13057, 13094, 13102, 15591, 18860, 19137, 19773, 20563, 23166, 24241, 25776, 27617, 29321], + "table": "drugitems", + "sub_var": "itemid", + "dur_var": "stop", + "callback": "transform_fun(set_val(TRUE))" + } + ], + "eicu": [ + { + "regex": "bactrim|cipro|flagyl|metronidazole|zithromax|zosyn|(((amika|cleo|ofloxa)|(azithro|clinda|tobra|vanco)my)c|(ampi|oxa|peni|pipera)cill|cefazol|levaqu|rifamp)in", + "table": "infusiondrug", + "sub_var": "drugname", + "target": "ts_tbl", + "callback": "combine_callbacks(transform_fun(set_val(TRUE)), ricu:::ts_to_win_tbl(mins(1L)))", + "class": "rgx_itm" + }, + { + "regex": "cipro|flagyl|maxipime|metronidazole|tazobactam|zosyn|cef(azolin|epime)|(((azithro|clinda|vanco)my|ofloxa|vanco)c|levaqu|piperacill|roceph)in", + "table": "medication", + "sub_var": "drugname", + "dur_var": "drugstopoffset", + "class": "rgx_itm", + "callback": "transform_fun(set_val(TRUE))" + } + ], + "eicu_demo": [ + { + "regex": "bactrim|cipro|flagyl|metronidazole|zithromax|zosyn|(((amika|cleo|ofloxa)|(azithro|clinda|tobra|vanco)my)c|(ampi|oxa|peni|pipera)cill|cefazol|levaqu|rifamp)in", + "table": "infusiondrug", + "sub_var": "drugname", + "target": "ts_tbl", + "callback": "combine_callbacks(transform_fun(set_val(TRUE)), ricu:::ts_to_win_tbl(mins(1L)))", + "class": "rgx_itm" + }, + { + "regex": "cipro|flagyl|maxipime|metronidazole|tazobactam|zosyn|cef(azolin|epime)|(((azithro|clinda|vanco)my|ofloxa|vanco)c|levaqu|piperacill|roceph)in", + "table": "medication", + "sub_var": "drugname", + "dur_var": "drugstopoffset", + "class": "rgx_itm", + "callback": "transform_fun(set_val(TRUE))" + } + ], + "hirid": [ + { + "ids": [163, 176, 181, 186, 189, 300, 326, 331, 351, 405, 1000234, 1000272, 1000273, 1000274, 1000284, 1000299, 1000300, 1000302, 1000304, 1000305, 1000306, 1000315, 1000317, 1000318, 1000320, 1000321, 1000322, 1000335, 1000348, 1000352, 1000363, 1000365, 1000390, 1000407, 1000408, 1000424, 1000425, 1000426, 1000437, 1000483, 1000507, 1000508, 1000518, 1000519, 1000549, 1000601, 1000648, 1000666, 1000670, 1000671, 1000760, 1000781, 1000791, 1000797, 1000812, 1000825, 1000829, 1000830, 1000837, 1000838, 1000854, 1000855, 1000893, 1000894, 1001005, 1001068, 1001075, 1001079, 1001084, 1001086, 1001095, 1001096, 1001097, 1001098, 1001168, 1001169, 1001170, 1001171, 1001173, 1001193, 1001198], + "table": "pharma", + "sub_var": "pharmaid", + "target": "ts_tbl", + "callback": "combine_callbacks(transform_fun(set_val(TRUE)), ricu:::ts_to_win_tbl(mins(1L)))" + } + ], + "miiv": [ + { + "ids": [225798, 225837, 225838, 225840, 225842, 225843, 225844, 225845, 225847, 225848, 225850, 225851, 225853, 225855, 225857, 225859, 225860, 225862, 225863, 225865, 225866, 225868, 225869, 225871, 225873, 225875, 225876, 225877, 225879, 225881, 225882, 225883, 225884, 225885, 225886, 225888, 225889, 225890, 225892, 225893, 225895, 225896, 225897, 225898, 225899, 225900, 225902, 225903, 225905, 227691, 228003], + "table": "inputevents", + "sub_var": "itemid", + "dur_var": "endtime", + "callback": "transform_fun(set_val(TRUE))" + } + ], + "mimic": [ + { + "ids": [225798, 225837, 225838, 225840, 225842, 225843, 225844, 225845, 225847, 225848, 225850, 225851, 225853, 225855, 225857, 225859, 225860, 225862, 225863, 225865, 225866, 225868, 225869, 225871, 225873, 225875, 225876, 225877, 225879, 225881, 225882, 225883, 225884, 225885, 225886, 225888, 225889, 225890, 225892, 225893, 225895, 225896, 225897, 225898, 225899, 225900, 225902, 225903, 225905, 227691, 228003], + "table": "inputevents_mv", + "sub_var": "itemid", + "dur_var": "endtime", + "callback": "transform_fun(set_val(TRUE))" + } + ], + "mimic_demo": [ + { + "ids": [225798, 225837, 225838, 225840, 225842, 225843, 225844, 225845, 225847, 225848, 225850, 225851, 225853, 225855, 225857, 225859, 225860, 225862, 225863, 225865, 225866, 225868, 225869, 225871, 225873, 225875, 225876, 225877, 225879, 225881, 225882, 225883, 225884, 225885, 225886, 225888, 225889, 225890, 225892, 225893, 225895, 225896, 225897, 225898, 225899, 225900, 225902, 225903, 225905, 227691, 228003], + "table": "inputevents_mv", + "sub_var": "itemid", + "dur_var": "endtime", + "callback": "transform_fun(set_val(TRUE))" + } + ] + } + }, "adh_rate": { "unit": [ "units/min", @@ -510,6 +606,22 @@ "picdb": [] } }, + "adh_dur": { + "description": "vasopressin duration", + "category": "medications", + "aggregate": "max", + "sources": { + "hirid": [ + { + "ids": [112, 113], + "table": "pharma", + "sub_var": "pharmaid", + "grp_var": "infusionid", + "callback": "hirid_duration" + } + ] + } + }, "cort": { "class": "lgl_cncpt", "description": "corticosteroids", @@ -1745,6 +1857,61 @@ "picdb": [] } }, + "phn_dur": { + "description": "phenylephrine duration", + "category": "medications", + "aggregate": "max", + "sources": { + } + }, + "levo_dur": { + "description": "levosimendan duration", + "category": "medications", + "aggregate": "max", + "sources": { + "hirid": [ + { + "ids": 1000606, + "table": "pharma", + "sub_var": "pharmaid", + "grp_var": "infusionid", + "callback": "hirid_duration" + } + ] + } + }, + "milrin_dur": { + "description": "milrinone duration", + "category": "medications", + "aggregate": "max", + "sources": { + "hirid": [ + { + "ids": 1000441, + "table": "pharma", + "sub_var": "pharmaid", + "grp_var": "infusionid", + "callback": "hirid_duration" + } + ] + } + }, + "teophyllin_dur": { + "description": "theophyllin duration", + "category": "medications", + "aggregate": "max", + "sources": { + "hirid": [ + { + "ids": [1000706, 1000707, 1000698, 1000267], + "table": "pharma", + "sub_var": "pharmaid", + "grp_var": "infusionid", + "callback": "hirid_duration" + } + ] + } + }, "phn_rate": { "unit": "mcg/kg/min", "description": "phenylephrine rate", @@ -1786,7 +1953,7 @@ "table": "inputevents_cv", "sub_var": "itemid", "grp_var": "linkorderid", - "callback": "combine_callbacks(\n mimic_kg_rate, mimic_rate_cv)\n " + "callback": "combine_callbacks(mimic_kg_rate, mimic_rate_cv)" }, { "ids": 30128, @@ -1809,7 +1976,7 @@ "table": "inputevents_cv", "sub_var": "itemid", "grp_var": "linkorderid", - "callback": "combine_callbacks(\n mimic_kg_rate, mimic_rate_cv)\n " + "callback": "combine_callbacks(mimic_kg_rate, mimic_rate_cv)" }, { "ids": 30128, @@ -1841,5 +2008,13 @@ "category": "medications", "callback": "vaso_ind", "class": "rec_cncpt" + }, + "cf_treat": { + "description": "treatment for circulatory failure (vasopressors/inotropes)", + "category": "medications", + "concepts": ["epi_dur", "norepi_dur", "dopa_dur", "dobu_dur", "adh_dur", + "phn_dur", "levo_dur", "milrin_dur", "teophyllin_dur"], + "callback": "cf_treat", + "class": "rec_cncpt" } } \ No newline at end of file diff --git a/inst/extdata/config/concept-dict/misc.json b/inst/extdata/config/concept-dict/misc.json new file mode 100644 index 00000000..2cbc07f1 --- /dev/null +++ b/inst/extdata/config/concept-dict/misc.json @@ -0,0 +1,125 @@ +{ + "hospital_id": { + "description": "source hospital identifier", + "min": 1, + "max": 1000, + "target": "id_tbl", + "sources": { + "eicu": [ + { + "table": "patient", + "class": "col_itm", + "val_var": "hospitalid" + } + ], + "eicu_demo": [ + { + "table": "patient", + "class": "col_itm", + "val_var": "hospitalid" + } + ], + "hirid": [ + { + "table": "general", + "class": "col_itm", + "val_var": "sex", + "callback": "transform_fun(set_val(1))" + } + ], + "mimic": [ + { + "table": "icustays", + "class": "col_itm", + "val_var": "hadm_id", + "callback": "transform_fun(set_val(1))" + } + ], + "mimic_demo": [ + { + "table": "icustays", + "class": "col_itm", + "val_var": "hadm_id", + "callback": "transform_fun(set_val(1))" + } + ], + "miiv": [ + { + "table": "icustays", + "class": "col_itm", + "val_var": "hadm_id", + "callback": "transform_fun(set_val(1))" + } + ] + } + }, + "patient_id": { + "description": "Patient Identifier", + "target": "id_tbl", + "sources": { + "aumc": [ + { + "table": "admissions", + "val_var": "patientid", + "class": "col_itm" + } + ], + "mimic_demo": [ + { + "table": "admissions", + "val_var": "subject_id", + "class": "col_itm" + } + ], + "mimic": [ + { + "table": "admissions", + "val_var": "subject_id", + "class": "col_itm" + } + ], + "miiv": [ + { + "table": "admissions", + "val_var": "subject_id", + "class": "col_itm" + } + ], + "hirid": [ + { + "table": "general", + "val_var": "patientid", + "class": "col_itm" + } + ], + "eicu_demo": [ + { + "table": "patient", + "val_var": "patientunitstayid", + "class": "col_itm" + } + ], + "eicu": [ + { + "table": "patient", + "val_var": "patientunitstayid", + "class": "col_itm" + } + ], + "picdb": [ + { + "table": "icustays", + "val_var": "subject_id", + "class": "col_itm" + } + ], + "sic": [ + { + "table": "cases", + "val_var": "patientid", + "class": "col_itm" + } + ] + } + } +} \ No newline at end of file diff --git a/inst/extdata/config/concept-dict/outcome.json b/inst/extdata/config/concept-dict/outcome.json index 95009c78..6316741b 100644 --- a/inst/extdata/config/concept-dict/outcome.json +++ b/inst/extdata/config/concept-dict/outcome.json @@ -92,6 +92,146 @@ ] } }, + "death_hosp": { + "class": "lgl_cncpt", + "description": "ICU mortality", + "category": "outcome", + "sources": { + "eicu": [ + { + "table": "patient", + "index_var": "hospitaldischargeoffset", + "val_var": "hospitaldischargestatus", + "callback": "transform_fun(comp_na(`==`, 'Expired'))", + "class": "col_itm" + } + ], + "eicu_demo": [ + { + "table": "patient", + "index_var": "hospitaldischargeoffset", + "val_var": "hospitaldischargestatus", + "callback": "transform_fun(comp_na(`==`, 'Expired'))", + "class": "col_itm" + } + ], + "miiv": [ + { + "table": "admissions", + "index_var": "deathtime", + "val_var": "hospital_expire_flag", + "callback": "transform_fun(comp_na(`==`, 1L))", + "class": "col_itm" + } + ], + "mimic": [ + { + "table": "admissions", + "index_var": "deathtime", + "val_var": "hospital_expire_flag", + "callback": "transform_fun(comp_na(`==`, 1L))", + "class": "col_itm" + } + ], + "mimic_demo": [ + { + "table": "admissions", + "index_var": "deathtime", + "val_var": "hospital_expire_flag", + "callback": "transform_fun(comp_na(`==`, 1L))", + "class": "col_itm" + } + ] + } + }, + "death_icu": { + "class": "lgl_cncpt", + "description": "ICU mortality", + "category": "outcome", + "sources": { + "aumc": [ + { + "table": "admissions", + "index_var": "dischargedat", + "val_var": "destination", + "death_date": "dateofdeath", + "callback": "aumc_death_icu", + "class": "col_itm" + } + ], + "eicu": [ + { + "table": "patient", + "index_var": "unitdischargeoffset", + "val_var": "unitdischargestatus", + "callback": "transform_fun(comp_na(`==`, 'Expired'))", + "class": "col_itm" + } + ], + "eicu_demo": [ + { + "table": "patient", + "index_var": "unitdischargeoffset", + "val_var": "unitdischargestatus", + "callback": "transform_fun(comp_na(`==`, 'Expired'))", + "class": "col_itm" + } + ], + "hirid": [ + { + "ids": [110, 200], + "table": "observations", + "sub_var": "variableid", + "callback": "hirid_death_icu", + "class": "hrd_itm" + } + ], + "miiv": [ + { + "table": "admissions", + "index_var": "deathtime", + "val_var": "hospital_expire_flag", + "callback": "miiv_death_icu", + "class": "col_itm" + } + ], + "mimic": [ + { + "table": "admissions", + "index_var": "deathtime", + "val_var": "hospital_expire_flag", + "callback": "mimic_death_icu", + "class": "col_itm" + } + ], + "mimic_demo": [ + { + "table": "admissions", + "index_var": "deathtime", + "val_var": "hospital_expire_flag", + "callback": "mimic_death_icu", + "class": "col_itm" + } + ], + "sic": [ + { + "table": "cases", + "index_var": "offsetofdeath", + "adm_time": "offsetafterfirstadmission", + "val_var": "timeofstay", + "callback": "sic_death", + "class": "col_itm" + } + ] + } + }, + "circ_fail": { + "description": "circulatory failure", + "concepts": ["map", "cf_treat", "lact"], + "category": "outcome", + "callback": "circ_fail", + "class": "rec_cncpt" + }, "dopa60": { "concepts": [ "dopa_rate", @@ -416,5 +556,55 @@ ], "callback": "susp_inf", "class": "rec_cncpt" - } + }, + "sep3_abx_cont": { + "concepts": ["sofa", "susp_inf_abx_cont"], + "description": "sepsis-3 criterion (alt. def.: continuous abx only)", + "category": "outcome", + "callback": "sep3_abx_cont", + "class": "rec_cncpt" + }, + "susp_inf_abx_cont": { + "concepts": ["abx_cont", "samp"], + "description": "suspected infection (alt. def.: continuous abx only)", + "category": "outcome", + "aggregate": [ + [ + "sum" + ], + [ + false + ] + ], + "callback": "susp_inf_abx_cont", + "class": "rec_cncpt" + }, + "aki": { + "description": "acute kidney injury (KDIGO 1/2/3)", + "concepts": "kdigo", + "category": "outcome", + "callback": "aki", + "class": "rec_cncpt" + }, + "kdigo": { + "description": "kidney disease improving global outcome staging", + "concepts": ["kdigo_crea", "kdigo_urine"], + "category": "outcome", + "callback": "kdigo", + "class": "rec_cncpt" + }, + "kdigo_crea": { + "description": "kidney disease improving global outcome creatinine component", + "concepts": "crea", + "category": "outcome", + "callback": "kdigo_crea", + "class": "rec_cncpt" + }, + "kdigo_urine": { + "description": "kidney disease improving global outcome urine output component", + "concepts": ["urine_rate", "weight"], + "category": "outcome", + "callback": "kdigo_urine", + "class": "rec_cncpt" + } } \ No newline at end of file diff --git a/inst/extdata/config/concept-dict/output.json b/inst/extdata/config/concept-dict/output.json index 73953d48..12439354 100644 --- a/inst/extdata/config/concept-dict/output.json +++ b/inst/extdata/config/concept-dict/output.json @@ -2,7 +2,7 @@ "urine": { "unit": "mL", "min": 0, - "max": 2000, + "max": 7000, "aggregate": "sum", "description": "urine output", "omopid": 4264378, @@ -10,7 +10,7 @@ "sources": { "aumc": [ { - "ids": 8794, + "ids": [8794, 8796, 8798, 8800, 8803], "table": "numericitems", "sub_var": "itemid" } @@ -164,6 +164,66 @@ ] } }, + "urine_rate": { + "unit": "mL/h", + "min": 0, + "max": 3000, + "aggregate": "max", + "description": "urine rate per hour", + "category": "output", + "sources": { + "aumc": [ + { + "class": "fun_itm", + "callback": "combine_callbacks(fwd_concept('urine'), urine_rate)" + } + ], + "eicu": [ + { + "class": "fun_itm", + "callback": "combine_callbacks(fwd_concept('urine'), urine_rate)" + } + ], + "eicu_demo": [ + { + "class": "fun_itm", + "callback": "combine_callbacks(fwd_concept('urine'), urine_rate)" + } + ], + "hirid": [ + { + "ids": 10020000, + "table": "observations", + "sub_var": "variableid", + "class": "hrd_itm" + } + ], + "miiv": [ + { + "class": "fun_itm", + "callback": "combine_callbacks(fwd_concept('urine'), urine_rate)" + } + ], + "mimic": [ + { + "class": "fun_itm", + "callback": "combine_callbacks(fwd_concept('urine'), urine_rate)" + } + ], + "mimic_demo": [ + { + "class": "fun_itm", + "callback": "combine_callbacks(fwd_concept('urine'), urine_rate)" + } + ], + "sic": [ + { + "class": "fun_itm", + "callback": "combine_callbacks(fwd_concept('urine'), urine_rate)" + } + ] + } + }, "urine24": { "concepts": "urine", "description": "urine output per 24h", diff --git a/inst/extdata/config/concept-dict/respiratory.json b/inst/extdata/config/concept-dict/respiratory.json index 5e64f8fe..7efc8189 100644 --- a/inst/extdata/config/concept-dict/respiratory.json +++ b/inst/extdata/config/concept-dict/respiratory.json @@ -119,15 +119,11 @@ "picdb": [] } }, - "o2sat": { - "unit": [ - "%", - "% Sat." - ], + "spo2": { + "unit": ["%", "% Sat."], "min": 50, "max": 100, - "description": "oxygen saturation", - "omopid": 40483579, + "description": "oxygen saturation (pulse oximetry)", "category": "respiratory", "sources": { "aumc": [ @@ -138,46 +134,29 @@ ], "table": "numericitems", "sub_var": "itemid" - }, - { - "ids": 12311, - "table": "numericitems", - "sub_var": "itemid", - "callback": "transform_fun(binary_op(`*`, 100))" } ], "eicu": [ { - "table": "vitalperiodic", - "val_var": "sao2", - "unit_val": "%", - "class": "col_itm" - }, - { - "ids": "O2 Sat (%)", - "table": "lab", - "sub_var": "labname" + "table": "vitalperiodic", + "val_var": "sao2", + "unit_val": "%", + "class": "col_itm" } ], "eicu_demo": [ { - "table": "vitalperiodic", - "val_var": "sao2", - "unit_val": "%", - "class": "col_itm" - }, - { - "ids": "O2 Sat (%)", - "table": "lab", - "sub_var": "labname" + "table": "vitalperiodic", + "val_var": "sao2", + "unit_val": "%", + "class": "col_itm" } ], "hirid": [ { "ids": [ 4000, - 8280, - 20000800 + 8280 ], "table": "observations", "sub_var": "variableid", @@ -187,9 +166,7 @@ "miiv": [ { "ids": [ - 220277, - 226253, - 50817 + 220277 ], "table": "chartevents", "sub_var": "itemid" @@ -197,26 +174,16 @@ ], "mimic": [ { - "ids": [ - 646, - 220277, - 226253, - 50817 - ], - "table": "chartevents", - "sub_var": "itemid" + "ids": [646, 220277], + "table": "chartevents", + "sub_var": "itemid" } ], "mimic_demo": [ { - "ids": [ - 646, - 220277, - 226253, - 50817 - ], - "table": "chartevents", - "sub_var": "itemid" + "ids": [646, 220277], + "table": "chartevents", + "sub_var": "itemid" } ], "sic": [ @@ -235,16 +202,107 @@ "1006" ], "sub_var": "itemid" - }, - { - "table": "labevents", - "ids": [ - 5252 - ], - "sub_var": "itemid" } ] } + }, + "sao2": { + "unit": ["%", "% Sat."], + "min": 50, + "max": 100, + "description": "oxygen saturation (arterial blood)", + "category": "respiratory", + "sources": { + "aumc": [ + { + "ids": 12311, + "table": "numericitems", + "sub_var": "itemid", + "callback": "transform_fun(binary_op(`*`, 100))" + } + ], + "eicu": [ + { + "ids": "O2 Sat (%)", + "table": "lab", + "sub_var": "labname" + } + ], + "eicu_demo": [ + { + "ids": "O2 Sat (%)", + "table": "lab", + "sub_var": "labname" + } + ], + "hirid": [ + { + "ids": [ + 20000800 + ], + "table": "observations", + "sub_var": "variableid", + "class": "hrd_itm" + } + ], + "miiv": [ + { + "ids": [ + 50817 + ], + "table": "chartevents", + "sub_var": "itemid" + } + ], + "mimic": [ + { + "ids": [834, 220227], + "table": "chartevents", + "sub_var": "itemid" + } + ], + "mimic_demo": [ + { + "ids": [834, 220227], + "table": "chartevents", + "sub_var": "itemid" + } + ], + "sic": [ + { + "ids": 673, + "table": "laboratory", + "sub_var": "laboratoryid", + "class": "sic_itm" + } + ], + "picdb": [ + { + "table": "labevents", + "ids": [ + 5252 + ], + "sub_var": "itemid" + } + ] + } + }, + "o2sat": { + "concepts": [ + "sao2", + "spo2" + ], + "unit": [ + "%", + "% Sat." + ], + "min": 50, + "max": 100, + "description": "oxygen saturation (pulse oximetry and arterial blood)", + "omopid": 40483579, + "category": "respiratory", + "callback": "o2sat_lab_first", + "class": "rec_cncpt" }, "pafi": { "concepts": [ @@ -274,10 +332,7 @@ "sources": { "aumc": [ { - "ids": [ - 8874, - 12266 - ], + "ids": [8873, 8874, 12266], "table": "numericitems", "sub_var": "itemid" } @@ -287,6 +342,11 @@ "table": "vitalperiodic", "val_var": "respiration", "class": "col_itm" + }, + { + "table": "nursecharting", + "ids": "Respiratory Rate", + "sub_var": "nursingchartcelltypevalname" } ], "eicu_demo": [ diff --git a/inst/extdata/config/concept-dict/vitals.json b/inst/extdata/config/concept-dict/vitals.json index 75967e5e..75190235 100644 --- a/inst/extdata/config/concept-dict/vitals.json +++ b/inst/extdata/config/concept-dict/vitals.json @@ -12,7 +12,7 @@ "sources": { "aumc": [ { - "ids": 6643, + "ids": [6643, 6680, 8842], "table": "numericitems", "sub_var": "itemid" } @@ -22,6 +22,11 @@ "table": "vitalperiodic", "val_var": "systemicdiastolic", "class": "col_itm" + }, + { + "table": "vitalaperiodic", + "val_var": "noninvasivediastolic", + "class": "col_itm" } ], "eicu_demo": [ @@ -29,6 +34,11 @@ "table": "vitalperiodic", "val_var": "systemicdiastolic", "class": "col_itm" + }, + { + "table": "vitalaperiodic", + "val_var": "noninvasivediastolic", + "class": "col_itm" } ], "hirid": [ @@ -275,7 +285,7 @@ "sources": { "aumc": [ { - "ids": 6642, + "ids": [6642, 6679, 8843], "table": "numericitems", "sub_var": "itemid" } @@ -385,7 +395,7 @@ "sources": { "aumc": [ { - "ids": 6641, + "ids": [6641, 6678, 8841], "table": "numericitems", "sub_var": "itemid" } @@ -395,6 +405,11 @@ "table": "vitalperiodic", "val_var": "systemicsystolic", "class": "col_itm" + }, + { + "table": "vitalaperiodic", + "val_var": "noninvasivesystolic", + "class": "col_itm" } ], "eicu_demo": [ @@ -402,6 +417,11 @@ "table": "vitalperiodic", "val_var": "systemicsystolic", "class": "col_itm" + }, + { + "table": "vitalaperiodic", + "val_var": "noninvasivesystolic", + "class": "col_itm" } ], "hirid": [ @@ -484,11 +504,7 @@ "sources": { "aumc": [ { - "ids": [ - 8658, - 13952, - 16110 - ], + "ids": [8658, 8659, 8662, 11889, 13058, 13059, 13060, 13061, 13062, 13063, 13952, 16110], "table": "numericitems", "sub_var": "itemid" } @@ -497,14 +513,38 @@ { "table": "vitalperiodic", "val_var": "temperature", + "unit_val": "C", "class": "col_itm" + }, + { + "table": "nursecharting", + "ids": "Temperature (C)", + "sub_var": "nursingchartcelltypevalname" + }, + { + "table": "nursecharting", + "ids": "Temperature (F)", + "sub_var": "nursingchartcelltypevalname", + "callback": "combine_callbacks(transform_fun(as.numeric), transform_fun(fahr_to_cels))" } ], "eicu_demo": [ { "table": "vitalperiodic", "val_var": "temperature", + "unit_val": "C", "class": "col_itm" + }, + { + "table": "nursecharting", + "ids": "Temperature (C)", + "sub_var": "nursingchartcelltypevalname" + }, + { + "table": "nursecharting", + "ids": "Temperature (F)", + "sub_var": "nursingchartcelltypevalname", + "callback": "combine_callbacks(transform_fun(as.numeric), transform_fun(fahr_to_cels))" } ], "hirid": [