Skip to contents

Chains 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 (or person_id), cohort_start_date, cohort_end_date; optional visit_occurrence_id, outcome_flag, discharged_to_concept_id, site / site_anon.

cohort_id

optional cohort_definition_id filter.

include_demographics, include_sdoh, include_elixhauser, include_medications, include_vitals, include_labs, include_utilization, include_disposition

feature groups. include_sdoh needs ruca_crosswalk, sdi_table and frozen sdi_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; the lookback_days before the admission), "pre_discharge" (the lookback_days up to and including the discharge date, as the eDERRI protocol does), "inpatient" or "discharge". Default NULL: "pre_discharge" for medication_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_egfr and fill lab_anion_gap where none was measured (mean and _last).

bounds

"default" (DEFAULT_BOUNDS), a named list list(name = c(min, max)) overriding those names (NA leaves a side open) or NULL for 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 with NULL).

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 as ederri_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: TRUE for profile = "ederri".

elixhauser_lookback_days

history window of the Elixhauser flags; "lookback_days" (default) uses lookback_days, NULL is all history (what profile = "ederri" uses).

elixhauser_code_table

"quan", "ederri" or "both" (the protocol's flags as ederri_elix_*); default from profile.

medication_set

"generic", "ederri" or "both" (the protocol's classes as ederri_med_*); default from profile.

include_protocol_history

add extract_protocol_history_features() columns; default TRUE for profile = "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): when ruca_crosswalk, sdi_table or sdi_cut_points is missing, include_sdoh = TRUE gives sdi_quintile / ruca_category = NA plus sdoh_missing = 1 and a warning; "raise" keeps the error. No national cut points are bundled.

address_table

dated address history for include_sdoh (columns person_id, zip5, address_start, address_end, preferred): "auto" (default) uses the one non-empty dated address table (resolve_address_table()), else person.location_id when it holds ZIPs, and stops otherwise; or a table name (for example a study's own ederri_address_history); NULL for person.location_id.

address_undated

rank of an address with no start date (undated of derive_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 unless impute_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 the bmi_lookback_days before admission, then one from the latest height and weight there, "none" leaves it missing. Default NULL: "derive_lookback" for profile = "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, or NULL for none. attr(, "unit_converted") gives the share of each lab's kept values that were converted.

Value

A data frame in cohort order; attr(, "feature_groups") lists the columns per group and attr(, "skipped") the features that could not be built.