
Compare a reference patient list with a cohort built here and explain the patients we miss
Source:R/cohort_reconcile.R
reconcile_cohort.RdReturns the patient-level overlap (counts: n_reference, n_mapped_to_cdm, n_cohort, both, reference_only, cohort_only,
jaccard), the reasons for the missing patients (gaps, see explain_cohort_gaps()), and, when index_date_col names a date in the
reference, how many matched patients have the same index date and how far apart the others are (dates; the nearest
cohort_start_date is used when the cohort has several). Counts only unless include_person_rows = TRUE.
Usage
reconcile_cohort(
con,
reference,
definition = NULL,
cohort = NULL,
id_col = "person_source_value",
id_type = "person_source_value",
index_date_col = NULL,
group_col = NULL,
cdm_schema = "main",
min_cell = 0,
include_person_rows = FALSE
)Arguments
- con
A DBI connection to an OMOP DuckDB.
- reference
A data frame, CSV / parquet path or table name with one identifier column.
- definition
A Circe definition (list, JSON text or path) the native compiler can evaluate.
- cohort
A table name or data frame with
subject_id(orperson_id); optional whendefinitionis given.- id_col
Name of the identifier column in
reference.- id_type
"person_source_value"or"person_id".- index_date_col
Optional name of a date column in
reference.- group_col
Optional column of
referencekept in the person rows.- cdm_schema
Schema of the CDM tables.
- min_cell
Suppress counts from 1 to
min_cell - 1(seesuppress_small_cells()).- include_person_rows
Return one row per reference patient with its reason.
Examples
if (FALSE) { # \dontrun{
# a legacy extraction's patient list (one identifier per row, optionally its index date) against a Circe definition
con <- DBI::dbConnect(duckdb::duckdb(), "cdm.duckdb", read_only = TRUE)
out <- reconcile_cohort(con, "legacy_patients.csv", definition = file.path(cohort_definitions_dir(), "target_cohort.circe.json"),
id_col = "patient_id", index_date_col = "admit_date", min_cell = 11)
out$counts # both, reference_only, cohort_only, jaccard
out$gaps # why the reference patients we miss are missing, as counts by step
out$dates # how many matched patients share the index date
} # }