Skip to contents

Gives every patient of a reference list the first step that keeps them out of a cohort, by walking a Circe definition step by step (entry event, correlated criteria, observation window, each inclusion rule) with the native compiler.

Usage

explain_cohort_gaps(
  con,
  reference,
  definition = NULL,
  cohort = NULL,
  id_col = "person_source_value",
  id_type = "person_source_value",
  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 (or person_id); optional when definition is given.

id_col

Name of the identifier column in reference.

id_type

"person_source_value" or "person_id".

group_col

Optional column of reference kept in the person rows.

cdm_schema

Schema of the CDM tables.

min_cell

Suppress counts from 1 to min_cell - 1 (see suppress_small_cells()).

include_person_rows

Return one row per reference patient with its reason.

Value

A list with gaps (reason, detail, n, pct, suppressed), n_reference and persons (or NULL).

Details

Reasons, in the order they are checked: in_cohort; not_in_cdm (the identifier maps to no person); no_observation_period; no_entry_event (no event of the entry criteria, including their concept sets, age and values); failed_entry_correlated_criteria; entry_outside_observation_window; failed_inclusion_rule (one row per rule, named in detail); in_definition_not_in_cohort (the definition keeps them but the cohort table does not); not_in_cohort_no_definition_given. The report is counts by reason; patient-level rows are returned only with include_person_rows = TRUE and stay on the machine that ran the function.