
Leakage-free benchmark feature table in one call
Source:R/benchmark_features.R
extract_benchmark_features.RdChains the Elixhauser, prior-utilization and medication-class extractors and adds index-admission vital means,
lab means and latest in-stay values (lab_<name>, lab_<name>_last), CKD-EPI 2021 eGFR, anion gap and the
discharge disposition. Same function as omop_etl.extract_benchmark_features.
Usage
extract_benchmark_features(
con,
cohort_table = "cohort",
cohort_id = NULL,
include_demographics = TRUE,
include_sdoh = FALSE,
include_elixhauser = TRUE,
include_medications = TRUE,
include_vitals = TRUE,
include_labs = TRUE,
include_utilization = TRUE,
include_disposition = TRUE,
lookback_days = 365,
lab_lookback_days = 0,
medication_specs = NULL,
medication_window = NULL,
lab_loincs = NULL,
vital_loincs = NULL,
lab_concept_ids = NULL,
vital_concept_ids = NULL,
derive_labs = TRUE,
bounds = "default",
profile = NULL,
hematocrit_fallback = NULL,
elixhauser_lookback_days = "lookback_days",
elixhauser_code_table = NULL,
medication_set = NULL,
include_protocol_history = NULL,
ruca_crosswalk = NULL,
sdi_table = NULL,
sdi_cut_points = NULL,
disposition_map = NULL,
sdoh_fallback = "indicator",
address_table = "auto",
address_tie_break = "deterministic",
address_undated = "last",
impute = NULL,
impute_values = NULL,
bmi_fill = NULL,
bmi_lookback_days = 365,
unit_conversions = "default"
)Arguments
- con
DuckDB connection to an OMOP CDM.
- cohort_table
table/view with
subject_id(orperson_id),cohort_start_date,cohort_end_date; optionalvisit_occurrence_id,outcome_flag,discharged_to_concept_id,site/site_anon.- cohort_id
optional
cohort_definition_idfilter.- include_demographics, include_sdoh, include_elixhauser, include_medications, include_vitals, include_labs, include_utilization, include_disposition
feature groups.
include_sdohneedsruca_crosswalk,sdi_tableand frozensdi_cut_points.- lookback_days
history window for Elixhauser (back from discharge), utilization and medications.
- lab_lookback_days
days before admission included in the vital/lab window (default 0: the stay only).
- medication_specs
drug class specs (default
DEFAULT_MEDICATION_CONCEPTS, 8 classes)- medication_window
"pre_admission"(default; thelookback_daysbefore the admission),"pre_discharge"(thelookback_daysup to and including the discharge date, as the eDERRI protocol does),"inpatient"or"discharge". DefaultNULL:"pre_discharge"formedication_set = "ederri", else"pre_admission".- lab_loincs, vital_loincs
list(name = c(loinc, ...))(defaults:BENCHMARK_LAB_LOINCS,BENCHMARK_VITAL_LOINCS).- lab_concept_ids, vital_concept_ids
list(name = c(concept_id))for databases without the LOINC vocabulary.- derive_labs
add
lab_egfrand filllab_anion_gapwhere none was measured (mean and_last).- bounds
"default"(DEFAULT_BOUNDS), a named listlist(name = c(min, max))overriding those names (NAleaves a side open) orNULLfor no bounds. A single vital / lab measurement outside its bounds is dropped before the stay's mean and latest value are taken; WBC counts per uL are rescaled first (DEFAULT_RESCALE, off withNULL).- profile
NULL(generic definitions),"ederri"(the eDERRI protocol's: its ATC medication classes over[discharge - lookback_days, discharge], its Elixhauser ICD prefix lists over all history up to discharge, hemoglobin from hematocrit / 3 and its history columns) or"both"(the generic columns plus the protocol's Elixhauser flags and medication classes asederri_elix_*/ederri_med_*, and its history columns). Any single choice can be set with the arguments below; an explicit argument wins over the profile.- hematocrit_fallback
fill a missing hemoglobin with hematocrit / 3. Default:
TRUEforprofile = "ederri".- elixhauser_lookback_days
history window of the Elixhauser flags;
"lookback_days"(default) useslookback_days,NULLis all history (whatprofile = "ederri"uses).- elixhauser_code_table
"quan","ederri"or"both"(the protocol's flags asederri_elix_*); default fromprofile.- medication_set
"generic","ederri"or"both"(the protocol's classes asederri_med_*); default fromprofile.- include_protocol_history
add
extract_protocol_history_features()columns; defaultTRUEforprofile = "ederri"/"both".- ruca_crosswalk, sdi_table, sdi_cut_points
inputs of
derive_geography_features().- disposition_map
named character vector concept id -> category.
- sdoh_fallback
"indicator"(default): whenruca_crosswalk,sdi_tableorsdi_cut_pointsis missing,include_sdoh = TRUEgivessdi_quintile/ruca_category= NA plussdoh_missing = 1and a warning;"raise"keeps the error. No national cut points are bundled.- address_table
dated address history for
include_sdoh(columnsperson_id,zip5,address_start,address_end,preferred):"auto"(default) uses the one non-empty dated address table (resolve_address_table()), elseperson.location_idwhen it holds ZIPs, and stops otherwise; or a table name (for example a study's ownederri_address_history);NULLforperson.location_id.- address_undated
rank of an address with no start date (
undatedofderive_geography_features()).- address_tie_break
how
derive_geography_features()resolves addresses that tie on every rule key (tie_break).- impute
NULL,"median"or"mean": fill missing vital / lab values. Statistics come from this table unlessimpute_values(named numeric) is given; fit them on the training sites (attr(, "imputation_values")) and pass them to other tables.- impute_values
named numeric vector of frozen fill values.
- bmi_fill
how a stay with no in-stay BMI gets one (
vital_bmi):"derive"from the stay's mean height and weight,"derive_lookback"also the latest BMI recorded in thebmi_lookback_daysbefore admission, then one from the latest height and weight there,"none"leaves it missing. DefaultNULL:"derive_lookback"forprofile = "ederri"/"both", else"derive".attr(, "bmi_filled")counts the stays each step filled.- bmi_lookback_days
window before admission for
bmi_fill = "derive_lookback"(default 365).- unit_conversions
"default"(DEFAULT_UNIT_CONVERSIONS: glucose and BUN mmol/L, creatinine umol/L, albumin and hemoglobin g/L to mg/dL or g/dL, applied to each lab value before the bounds), a list in the same layout replacing the rules of the names it lists, orNULLfor none.attr(, "unit_converted")gives the share of each lab's kept values that were converted.