Skip to contents

Each table is truncated and reloaded inside its own transaction, with a row-count sanity check before commit – so a bad/partial download can only fail that one table (rolled back, left untouched), not half-clobber the rest of the vocabulary.

Usage

load_vocabulary(
  vocab_dir,
  db_path = "omop_cdm.duckdb",
  sanitize_cpt4 = TRUE,
  sanitize_all_null_names = FALSE,
  tables = NULL,
  drop_indexes = FALSE
)

Arguments

vocab_dir

Path to an extracted Athena vocabulary download (a directory of tab-delimited *.csv files).

db_path

Path to the DuckDB database file (schema must already exist, see build_schema()).

sanitize_cpt4

Automatically sanitize NULL concept_names for CPT4 concepts.

sanitize_all_null_names

Automatically sanitize any NULL concept_names.

tables

Optional character vector of vocabulary tables to (re)load, e.g. c("concept", "concept_relationship"). Default loads every table found.

drop_indexes

Drop user indexes on the target tables before the bulk load and recreate them afterwards.

Value

TRUE if every matched table loaded successfully, FALSE if any table failed and was rolled back.

Details

Supports CPT4 sanitization: Athena downloads without a UMLS license output CONCEPT_CPT4.csv (or CPT4 concept entries) with NULL concept_names, which violates the NOT NULL constraint on concept.concept_name. When sanitize_cpt4 = TRUE, CPT4 concept names are automatically sanitized to 'CPT4 ' || concept_code.