Skip to contents

Builds a cohort-level Table 1 from a DuckDB OMOP database. Labs use the last value in the stay by default; bounds (user bounds, then profile, then DEFAULT_PHYSIOLOGIC_BOUNDS) are applied BEFORE aggregation and bounds = FALSE disables bounding. Units are harmonized first (harmonize_measurement_units()). The cohort table needs subject_id, cohort_start_date, cohort_end_date. Mirror of Python Table1Generator.

Usage

table1_generator(
  db_path = NULL,
  con = NULL,
  read_only = TRUE,
  bounds = NULL,
  population = "adult",
  harmonize_units = TRUE
)

Arguments

db_path

Path to a DuckDB file (opened read-only), or give con.

con

An existing DuckDB DBI connection.

read_only

Open db_path read-only (default).

bounds

NULL (defaults), a named list of overrides, or FALSE.

population

"adult", "pediatric", or "neonatal" (default "adult").

harmonize_units

Run the unit preflight first (default TRUE).

Value

A list of functions: add_domain_profile, add_custom_lab, add_custom_medication, add_custom_condition, extract, generate, state (the current configuration), close. Mutators return the generator invisibly so calls can be chained.

Details

t1 <- table1_generator(con = con)
t1$add_domain_profile("heart_failure")
t1$add_custom_lab("troponin_t", c("6598-7", "42757-5"), bounds = c(0, 50))
out <- t1$generate("inpatient_hf_cohort", stratify_by = "readmitted_30d")