
Extract medication trajectory flags across care transitions
Source:R/medication_classes.R
extract_medication_transitions.RdEvaluates drug exposure across three canonical transitions (pre_admission, inpatient, discharge)
to classify trajectory flags:
{cls}_initiated_inpatient: 1 if unexposed pre-admission and exposed during inpatient or discharge.{cls}_discontinued_at_discharge: 1 if exposed pre-admission/inpatient and not active at discharge.{cls}_continued_across_stay: 1 if exposed both pre-admission and at discharge.
Usage
extract_medication_transitions(
con,
cohort_table = "cohort",
medication_specs = NULL,
strategy = "standard",
crosswalk = NULL,
lookback_days = 365,
person_id_col = NULL,
index_date_col = NULL,
end_date_col = NULL
)Arguments
- con
Active DuckDB connection.
- cohort_table
Cohort table name.
- medication_specs
Drug-class specs mapping (defaults to DEFAULT_MEDICATION_CONCEPTS).
- strategy
Extraction strategy (
"standard","source", or"both").- crosswalk
Optional source-value crosswalk.
- lookback_days
Pre-admission lookback window in days (default 365).
- person_id_col, index_date_col, end_date_col
Column name overrides.