Skip to contents

Evaluates 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.

Value

A medication_transitions object.

Details

Also populates summary trajectory flags:

  • med_initiated_inpatient: 1 if ANY evaluated drug class was newly initiated.

  • med_discontinued_at_discharge: 1 if ANY evaluated drug class was discontinued.

  • med_continued_across_stay: 1 if ANY evaluated drug class was continued across stay.