Skip to contents

Groups continuous or near-continuous periods of drug exposure within a specified persistence gap using vectorized DuckDB island-and-gap window functions.

Usage

compute_drug_eras(
  con,
  concept_set = NULL,
  persistence_window_days = 30,
  drug_exposure_table = "drug_exposure",
  output_table = NULL
)

Arguments

con

Active DuckDB connection.

concept_set

Optional vector of drug_concept_ids (or ingredient IDs) to restrict to.

persistence_window_days

Maximum allowable gap in days between exposures to stay in the same era (default 30).

drug_exposure_table

Name of drug exposure table in DuckDB (default 'drug_exposure').

output_table

Optional table name to materialize the computed eras into.

Value

A data frame with columns: drug_era_id, person_id, drug_concept_id, drug_era_start_date, drug_era_end_date, drug_exposure_count, era_days, gap_days.