Skip to contents

Identifies top drug concepts and source values present in one strategy but missing in the other, applying small-cell count suppression (<11) so output aggregates can safely leave the institution.

Usage

explain_medication_disagreement(
  con,
  flags,
  medication_specs,
  cohort_table = "cohort",
  classes = NULL,
  site_col = "site",
  person_col = NULL,
  top_n = 10,
  min_cell_count = 11,
  mask_value = "<11",
  vocab_schema = NULL,
  vocab_db = NULL
)

Arguments

con

Active DuckDB DBI connection.

flags

Output of extract_medication_classes() with strategy = 'both'.

medication_specs

Medication class specifications list.

cohort_table

Cohort table name (default 'cohort').

classes

Classes to audit.

site_col

Site column name (default 'site').

person_col

Person identifier column name (default 'person_id' or auto-detected).

top_n

Maximum top disagreement patterns to return per site and class (default 10).

min_cell_count

Cell count threshold for privacy suppression (default 11).

mask_value

Suppression mask string (default '<11').

vocab_schema

Optional schema containing vocabulary tables.

vocab_db

Optional attached database containing vocabulary tables.

Value

A data frame with columns site, medication_class, disagreement_type, drug_source_value, drug_concept_id, concept_name, concept_class_id, patient_count, row_count, is_suppressed.