Mirrors python/omop_etl/build_omop_cdm.py table-for-table. Both read the
same PCORnet-format source directory, share the same schema and concept-resolution
logic, and generate 100% deterministic surrogate keys and OHDSI v5.4 tables.
Usage
etl_pcornet(
source_dir,
db_path = "omop_cdm.duckdb",
central_vocab = NULL,
site_id = NULL,
site_anon = NULL,
site_name = NULL,
disambiguate_patids = FALSE,
auto_resources = FALSE,
memory_limit = NULL,
threads = NULL,
temp_dir = NULL,
source_format = NULL,
strict_source = FALSE,
key_check = c("warn", "raise", "ignore"),
key_check_callback = NULL,
date_audit_callback = NULL,
use_enrollment = "auto",
enrollment_type_concept_id = 0L,
data_cutoff = "auto",
mode = c("full", "append"),
since = NULL
)Arguments
- source_dir
Directory containing PCORnet-format CSVs (
demographic.csv,encounter.csv,diagnosis.csv,procedures.csv,lab_result_cm.csv,prescribing.csv,provider.csv, optionallyvital.csv,facility.csv, and optionallydeath.csv), matched case-insensitively. Any table whose source file isn't found is skipped.- db_path
Path to the DuckDB database file (schema + vocabulary must already exist).
- central_vocab
Optional path to an existing central vocabulary DuckDB database to attach in read-only mode with zero-copy views.
- site_id
Optional numeric site identifier (e.g. 1 to 5).
- site_anon
Optional publication pseudonym (e.g. "Site A").
- site_name
Optional institutional name or internal descriptor (e.g. "Hospital System A").
- disambiguate_patids
Logical. If
TRUE, formatsperson_source_valueassrc.PATID || '-' || site_idand derives surrogate keys viapcornet_id(src.PATID || '-' || site_id).- auto_resources
Logical. If
TRUE, size DuckDB to the host withconfigure_resources()(75% of available RAM, best spill volume, cores - 1) before loading;memory_limit,threadsandtemp_dirstill win over the detected values.- memory_limit
Optional DuckDB
memory_limit, e.g."16GB".- threads
Optional DuckDB worker thread count.
- temp_dir
Optional DuckDB disk-spill directory.
- source_format
"csv","parquet"orNULL(either); restricts which source files are read when checking the source contract (seecheck_source()). Only used whenstrict_source = TRUE.- strict_source
Logical. If
TRUE, runcheck_source()first and stop with asource_contract_errorwhen a required source table or column is missing.- key_check
"warn"(default),"raise"or"ignore": at the end of the build, compare distinct source ids with distinct surrogate keys viacheck_etl_keys()and report any encounters/patients that would be merged.- key_check_callback
Optional function called with the list returned by
check_etl_keys().- date_audit_callback
Optional function called with the list of per-source-table date-fallback and undated-drop counts.
- use_enrollment
"auto"(default),TRUEorFALSE. Buildobservation_periodfrom the PCORnet ENROLLMENT file when the source has one (load_enrollment_spans()); people without an enrolment record keep the event-span period.TRUEfails if no usable ENROLLMENT file exists.- enrollment_type_concept_id
period_type_concept_idfor enrolment-derived periods (default 0).- data_cutoff
"auto"(default), an ISO date orNULL(today): capsobservation_periodends."auto"uses the latest event dated before today, so events filled with the build date do not set period ends.- mode
"full"(default) or"append": add only newly arrived rows to an existing database. Patients, providers and encounters already present are skipped (matched on source values), events dated beforesinceare skipped, surrogate keys continue from the current maximum, care sites / locations are left alone, andobservation_periodand the eras are rebuilt. Encounters are selected by admit date. Mirror of Pythonetl_pcornet(mode = "append").- since
With
mode = "append": ISO date; only events on/after it are loaded.
