Skip to contents

pcornet_id() maps a source id to a 63-bit key. A collision silently merges two source rows, so the number of distinct source ids must equal the number of distinct keys. check_key_collisions() verifies that for one source column; check_etl_keys() runs it on the ids the PCORnet ETL turns into surrogate keys. R port of omop_etl.key_checks.

Usage

check_key_collisions(
  con,
  source,
  id_column,
  key_expr = "pcornet_id({col})",
  on_collision = c("warn", "raise", "ignore")
)

check_etl_keys(
  con,
  source_dir,
  site_id = NULL,
  disambiguate_patids = FALSE,
  on_collision = c("warn", "raise", "ignore")
)

Arguments

con

A DuckDB DBI connection with the mapping macros loaded (see load_mapping_macros()).

source

A table, view or read_csv_auto(...)/read_parquet(...) relation expression.

id_column

Column holding the source id.

key_expr

Key expression with a {col} placeholder (default "pcornet_id({col})").

on_collision

"warn" (default), "raise" or "ignore".

source_dir

Directory of PCORnet source files.

site_id, disambiguate_patids

As in etl_pcornet(); PATID is checked only when both are set.

Value

check_key_collisions(): a list with source, id_column, distinct_ids, distinct_keys, lost, ok. check_etl_keys(): a list of such lists, each also holding table, cdm_table and cdm_rows.