Skip to contents

Extract Harmonized Inpatient Lab Panels with Outlier Sanitization

Usage

extract_standard_labs(
  con,
  cohort_table = "cohort",
  cohort_id = NULL,
  panel = "core_14",
  aggregation = "last_before_discharge",
  window = "stay",
  winsorize = TRUE,
  format = "df"
)

Arguments

con

Active DuckDB connection (DBI::dbConnect).

cohort_table

Name of cohort table (default "cohort").

cohort_id

Optional cohort definition ID filter.

panel

Standard lab panel to extract (default "core_14").

aggregation

Aggregation strategy ("last_before_discharge", "first_on_admission", "mean", "median", "min", "max").

window

Windowing scope ("stay", "lookback", "all").

winsorize

Logical TRUE to clamp to physiologic bounds, numeric vector c(low_q, high_q) for percentile winsorization, or FALSE for raw values.

format

Output format ("df", "arrow").

Value

A data.frame or arrow::Table of harmonized laboratory values.