
Index-stay laboratory values per cohort row, separating acute labs from routine ones
Source:R/features.R
extract_inpatient_labs.RdLabs named in acute_lab_subset (lactate, troponin, blood gases, ...) are only meaningful during the stay, so
they are always drawn from [cohort_start_date, cohort_end_date]. The remaining labs (HbA1c, creatinine, ...)
use routine_window so a value measured shortly before admission is not lost. Both blocks use the same
selection_rule and are returned side by side, one row per (subject_id, cohort_start_date).
Mirror of omop_etl.features.extract_inpatient_labs in Python.
Usage
extract_inpatient_labs(
con,
cohort_table = "cohort",
cohort_id = NULL,
lab_specs = NULL,
selection_rule = "last_in_stay",
acute_lab_subset = NULL,
routine_window = "lookback",
routine_lookback_days = 365,
outlier_bounds = NULL,
format = "df"
)Arguments
- con, cohort_table, cohort_id
As in
extract_measurements()(the cohort needssubject_id,cohort_start_dateandcohort_end_date).- lab_specs
Named list
lab_name -> LOINC codes or concept ids. Default: CORE_14_LAB_PANEL plus ACUTE_LAB_PANEL.- selection_rule
"last_in_stay"(closest to discharge),"first_in_stay","mean","median","min","max"or"worst"(direction per lab in WORST_LAB_DIRECTION).- acute_lab_subset
Names in
lab_specstreated as acute (stay window only).NULL(default): the ACUTE_LAB_PANEL names present inlab_specs. An explicit vector must be a subset oflab_specs.- routine_window
Window for the non-acute labs:
"stay","lookback"(theroutine_lookback_daysbefore admission, excluding the stay) or"all"(everything up to discharge).- routine_lookback_days
Days for the
"lookback"window.- outlier_bounds
Named list
lab_name -> c(low, high);NULLuses the physiologic bounds used byextract_standard_labs(). Passlist()to disable. Readings outside the bounds are dropped before selection.- format
"df"or"arrow".