omop-duck-db exists to run OMOP studies on DuckDB databases. OHDSI already has tools for most of what a study needs, so the rule for this package is:
- Study logic goes in standard OHDSI artifacts (Circe/ATLAS cohort definitions, concept sets, OHDSI SQL, HADES settings objects), so it is portable to ATLAS and to sites that do not run this package.
- The package supplies what the OHDSI tools do not: PCORnet-to-OMOP ETL, DuckDB/Arrow/lakehouse plumbing, vocabulary loading, a Java-free Circe compiler, bridges that make a DuckDB CDM usable by HADES, and checks that the data are fit for the study.
- Where the package re-implements an OHDSI tool, it says so, covers only a subset, and is checked against the tool.
This page audits the package against that rule, and records what was checked against the real tools. The checks ran with CohortGenerator, CirceR, FeatureExtraction, Achilles 1.7.2, DataQualityDashboard, PhenotypeLibrary, CohortDiagnostics and PatientLevelPrediction (DatabaseConnector 8.0.0, duckdb 2.0.0). On 2026-11-13 CohortMethod 6.0.3, CohortConstructor 0.6.3 (with CDMConnector 2.8.1), DeepPatientLevelPrediction 2.4.0 and omop-learn (commit a33440a) were added to that list; see the rows below, and the end of this page for the tools that have not been checked (ATLAS 3, Data2Evidence, Phenelope, GIS).
Studies use the validated OHDSI tools; the package adds
features to them, not replacements. A feature that OMOP has no
definition for (RUCA, SDI, a site score) is written to the CDM with
write_custom_covariates() and read with FeatureExtraction
like any other covariate; an alternative definition of an existing
feature gets its own concept id and is compared with the standard one
(compare_feature_tables()) before a study picks one.
| Area | omop-duck-db | OHDSI tool | Relationship | Recommendation |
|---|---|---|---|---|
| PCORnet to OMOP ETL, vocabulary load, observation periods |
etl_pcornet, omop_etl.build_omop_cdm,
load_vocabulary
|
Athena vocabularies (downloaded); no HADES ETL | Package-only | Keep. This is the package’s core job. Keep concept choices (visit, discharge) checked against Athena. |
| DuckDB as a HADES backend |
hades_preflight, readonly_*,
plp_database_details, integer64 helpers |
DatabaseConnector, CohortGenerator, PatientLevelPrediction | Complementary | Keep. Tested with CohortGenerator on DuckDB. |
| Cohort definitions |
inst/cohorts/*.circe.json,
inst/cohorts/*.sql, cohort_definition_set(),
compile_circe_to_duckdb()
|
ATLAS/Circe, CirceR, CohortGenerator | Same job (portable form) | Prefer Circe. New study logic is written as Circe JSON (see below). The native compiler evaluates a subset of Circe and refuses the rest with an error naming the construct (it accepts 521 of the 707 PhenotypeLibrary definitions); use CirceR + CohortGenerator for the others. |
| Study cohort engine |
define_study_cohort,
build_readmission_cohort,
build_end_of_life_cohort
|
CohortGenerator + Circe (cohort), PLP (outcome windows) | Overlaps for entry/exclusion; adds one-stay-per-patient sampling, verified follow-up, attrition |
Keep as a convenience for replication studies,
document that Circe is the interoperable route, and keep new exclusions
in Circe
(metformin_only_prediabetes_pcos_*.circe.json). |
| Phenotype DSL | phenotype_dsl |
Circe, PhenotypeLibrary | Same job | Prefer Circe / PhenotypeLibrary for anything meant to be shared; keep the DSL for quick exploration. |
| Metformin-only prediabetes/PCOS |
find_metformin_only_prediabetes_pcos and the Circe
files |
Circe cohort | Same job | Circe is the definition; the function stays as a check that also reads source values, which Circe cannot. |
| Diabetes phenotype |
diabetes_phenotype.circe.json,
require_diabetes
|
PhenotypeLibrary (T1DM/T2DM phenotypes), Circe | Same job | Prefer the Circe file; consider PhenotypeLibrary definitions for a published phenotype. |
| Concept sets, descendants |
concept_optimizer, get_concept_*,
resolve_concept_set
|
Circe concept sets, ConceptSetDiagnostics | Overlaps | Wrap: express sets as Circe concept sets; keep helpers for DuckDB-side use. |
| Covariates / features |
extract_patient_features, comorbidity
(Elixhauser, Charlson), utilization, velocity,
labs, extract_sparse_concept_matrix
|
FeatureExtraction (demographics, condition/drug groups, Charlson, DCSI, CHADS2, visit counts, measurement values) | Overlaps for Charlson, demographics, counts; Elixhauser is not in FeatureExtraction as far as known (not checked here) |
Keep Elixhauser and the velocity set (no
equivalent). Visit counts match FeatureExtraction exactly.
Charlson does not match FeatureExtraction’s Romano
adaptation (see below). The package does not pick one: a study adds its
own definition with write_custom_features() beside
FeatureExtraction’s and compares them. |
| Area-level and custom covariates (RUCA, SDI, …) |
derive_geography_features,
person_address_history,
write_custom_covariates,
custom_covariate_settings
|
None | Package-only |
Keep, and integrate: derived values are stored as
measurement rows with local concept ids and
FeatureExtraction / PLP read them as covariates (tested). RUCA and SDI
are examples of the general mechanism. |
| Model training, calibration, evaluation |
ml, evaluate, scoring,
model_bundle, feature_contract,
categorical_encoding
|
PatientLevelPrediction, DeepPatientLevelPrediction | Overlaps | Prefer PLP for development and validation. Keep bundles, contracts and fixed-level encoding for scoring outside HADES (for example an XGBoost model at a site). |
| Data quality |
dqd, dqd_catalog (Python and R),
run_dqd_full (JSON in DQD shape) |
DataQualityDashboard | Same job, subset | Use the official DQD where it is installed; keep the in-DuckDB catalog as a fast gate. State the check subset when reporting (now includes the concept FK, domain, class and standard/valid checks, the fixed-bound and physiologic value checks and the person / era / source-concept completeness gaps; not the per-concept checks). |
| Data characterization |
run_achilles (about 25 of about 170 analyses) |
Achilles | Same job, subset |
Use Achilles for published characterization; keep
the subset for quick checks on a DuckDB file.
min_cell_count removes cells where Achilles masks
them. |
| Cohort diagnostics, attrition |
cohort_diagnostics, cohort_flow,
compute_attrition
|
CohortDiagnostics | Overlaps | Wrap or defer to CohortDiagnostics when the study is shared; keep attrition for CONSORT tables. |
| Table 1 |
table1, profiles |
FeatureExtraction createTable1, CohortDiagnostics |
Overlaps | Keep (study-specific layout); do not claim equivalence. |
| Effect estimation |
propensity, survival,
federated_survival, federated_learning
|
CohortMethod, SelfControlledCaseSeries, Strategus | Overlaps | Prefer HADES for estimates that will be published; the federated functions are research tools, not a replacement for Strategus. |
| Negative controls, empirical calibration | negative_controls |
EmpiricalCalibration, Strategus modules | Overlaps | Prefer EmpiricalCalibration for published results. |
| Cohort SQL on other engines |
cohort_sql (sqlglot), Oracle/T-SQL translation |
SqlRender | Overlaps |
Prefer SqlRender for OHDSI SQL; the sqlglot path is
for engines SqlRender handles badly; both are tested only where noted in
NEWS.md. |
| BigQuery, lakehouse, Arrow sync |
bigquery_sync, load_from_bigquery,
lakehouse
|
None | Package-only | Keep. Unit-tested only against fakes. |
| Reconciliation with a legacy pipeline |
reconciliation (compare_feature_tables,
cohort_overlap) |
None | Package-only | Keep. |
What to change next
-
Cohorts: add every new inclusion/exclusion rule as
Circe JSON first (done for the metformin-only exclusion and the diabetes
phenotype, and now the index-stay cohort).
inst/cohorts/target_cohort.circe.jsonis the index-stay cohort as Circe JSON and agrees with CirceR + CohortGenerator; it cannot express discharge disposition or a death-in-window follow-up (documented), so its SQL stays authoritative. Run a new definition through CirceR + CohortGenerator as well as the native compiler before relying on the native one. - Run the official tools in CI where HADES is installed (the R tests above skip cleanly otherwise).
-
Charlson: not a package decision. Downstream writes
its own definition with
write_custom_features()and compares it with FeatureExtraction’s on real mapped data. -
DQD: the per-concept checks of the official list
(
plausibleGender,plausibleUnitConceptIds, …) are still not run; say so in every report. The checks that are run were compared with DataQualityDashboard 2.9.1 on a planted fixture: violated rows and denominators agree for every check both tools produce on the same table and field (pinned as golden values intests/test_dqd_catalog.pyandtests/testthat/test-dqd-catalog.R). - Keep the claim honest: every function that overlaps an OHDSI tool says in its help page what it covers and what it does not.
Checked against the official tools
| Tool | What was compared | Result |
|---|---|---|
| CirceR + CohortGenerator | The six inst/cohorts/*.circe.json files, rendered by
CirceR and run on DuckDB, against the native compiler and
find_metformin_only_prediabetes_pcos()
|
Same people in every cohort
(tests/testthat/test-circe-definitions.R). The check found
that the first version of diabetes_phenotype.circe.json was
not valid Circe (age was written as a
DemographicCriteria criterion instead of
DemographicCriteriaList); fixed, and the native compiler
now reads DemographicCriteriaList. |
| FeatureExtraction, visit counts |
extract_prior_utilization against
useVisitConceptCountLongTerm (365 days before, admission
day excluded) |
Identical counts (test-ohdsi-parity.R). |
| FeatureExtraction, measurement values | RUCA and SDI written by write_geography_measurements()
read back as covariates |
Works once unit_concept_id is 0: FeatureExtraction
joins on the unit and silently skips rows where it is NULL
(test-geography.R). |
| FeatureExtraction, Charlson |
extract_charlson_index against
useCharlsonIndex (“Romano adaptation”) on the repo’s
comorbidity fixture, ICD codes mapped to standard concepts through the
vocabulary |
Not equivalent. 135 of 180 persons get the same index. Many of the 45 differences are the fixture’s own probes (code normalization such as lower case and spaces, which FeatureExtraction cannot see, window-edge cases, Elixhauser probes) and 33 of 103 codes had no standard mapping, so this is not a clean estimate; but the two use different category definitions and different data (source codes vs standard concepts), so do not mix them in one model or table. A clean comparison needs real mapped data. |
| Achilles 1.7.2 | 14 analyses (0-5, 101, 103, 105, 108, 111-113, 200-202) on a small fixture | Counts identical. Two real differences, now fixed: the package used
the population standard deviation and interpolated percentiles; Achilles
uses the sample standard deviation (NULL for one value) and the discrete
percentile (tests/test_achilles.py holds the official
values). Cosmetic: analysis 0 stores the Achilles version in
stratum_2; analysis 108 writes 12.0 on DuckDB.
Achilles itself needs a workaround on this stack: with duckdb 2.0.0 and
DatabaseConnector 8.0.0 achilles() fails with “Column
ANALYSIS_ID does not exist in target table” (upper-case column names in
insertTable). |
| DataQualityDashboard | Table and field checks on a planted-defect fixture | Agrees on person foreign keys, start-before-end and after-birth.
Differences, now fixed: primary-key violations counted only the surplus
copies (DQD counts every row of a duplicated key); after-birth ignored
end dates and datetime fields. The catalog
(run_dqd_catalog()) now also generates the concept
foreign-key, domain, class and standard/valid-concept checks.
plausibleFutureDate and visitPersonMatch are
not DQD checks; they are labelled
check_origin = "omop-duck-db" in the output. |
| PhenotypeLibrary + CirceR + CohortGenerator | All 707 library definitions classified by the native compiler; 160 sampled definitions run on a synthetic CDM (2,000 people, 30,000 events per domain, concepts and descendants from Athena) through both engines | The native compiler accepts 521 of the 707 definitions and refuses
the rest with an error naming the construct. On a sample of 160 accepted
ones, 160 return the same people and 158 the same start
dates (the two others use CustomEra, which the
compiler warns it does not apply). Constructs added after the first runs
(First, AdditionalCriteria, Unit
and source-concept attributes, AT_LEAST /
AT_MOST groups, nested groups, DateAdjustment,
Age and correlated criteria on an entry event) were each
checked against CirceR on a purpose-built CDM
(scripts/ohdsi_parity_constructs.R, pinned in
tests/test_circe_constructs.py): First is the
earliest event of the concept set before the window and before the other
attributes, and AdditionalCriteria is applied after the
primary limit like an inclusion rule. Inclusion-rule age was compared
with CirceR across operators and birthdays: it is the difference of
calendar years, which the compiler already used. Still refused:
EndWindow, criteria nested inside a criterion of an
inclusion rule, ValueAsConcept,
OccurrenceStartDate, includeMapped,
distinct-count occurrences, DrugEra /
ConditionEra / ObservationPeriod criteria. The
first runs found real defects, all fixed: inclusion rules applied before
the primary limit (231 vs 361 people), Observation entry
events falling back to every visit (0 vs 1,887 people), ignored
AdditionalCriteria and unevaluated criterion attributes, an
unknown operator read as =, no era collapse or end
strategy. QualifiedLimit is not applied by CirceR (only
ExpressionLimit); the compiler follows CirceR. Repeat with
scripts/ohdsi_parity_phenotypelibrary.R. |
| CohortDiagnostics |
executeDiagnostics() on the diabetes phenotype and an
inpatient-visit outcome cohort |
Cohort entries and subjects identical to CohortGenerator and to
execute_circe_cohort()
(scripts/ohdsi_parity_plp_cohortdiagnostics.R). |
| CohortMethod 6.0.3 |
getDbCohortMethodData() through
cm_database_details(), createStudyPopulation()
(risk window 1-365) and fitOutcomeModel(logistic) on a
synthetic 3,000-person CDM with a known effect
(scripts/ohdsi_parity_cohortmethod.R,
tests/testthat/test-ohdsi-parity-scripts.R) |
Per-arm subjects and outcomes equal direct counts; the logistic odds ratio equals the 2x2 odds ratio (2.138367 vs 2.138369; Cyclops stops at its convergence tolerance). Propensity-score and stratified analyses were not compared. |
| CohortConstructor 0.6.3 (CDMConnector 2.8.1) |
conceptCohort() and
demographicsCohort(18+) on a synthetic CDM read through
CDMConnector::cdmFromCon()
(scripts/ohdsi_parity_cohortconstructor.R) |
The concept cohort has the same subjects and the same distinct
subject/start pairs as execute_circe_cohort() on the
equivalent Circe definition; the 18+ cohort equals a direct SQL count at
completed-years age. Other CohortConstructor verbs
(requireX, exitAt, stratification) were not
compared. |
| omop-learn (commit a33440a, 2023-06-17) |
DuckDBBackend with the real
OMOPDatasetBackend, Feature,
Cohort, OMOPDataset and torch collate classes
(OMOP_LEARN_SRC=<clone>/src pytest tests/test_omop_learn_backend.py) |
tests/test_omop_learn_backend.py and
tests/test_ml_features.py pass (31 tests), including the 3
that need the real classes (they skip without the clone); the set-based
lateral strategy equals omop-learn’s per-person reference
loop. Its transformer models were not trained. |
| DeepPatientLevelPrediction 2.4.0 |
as_plp_data() ->
createStudyPopulation() -> runPlp() with
setMultiLayerPerceptron() on a synthetic 4,000-person CDM
with a known signal (scripts/ohdsi_parity_deepplp.R; Python
torch 2.14 CPU through reticulate) |
The study population’s outcomes equal the labels, covariate ids are
concept_id * 1000 + analysis_id, and the MLP trains and
scores the held-out set (test AUROC 0.685 where the outcome depends on 5
of 30 conditions). Found and fixed:
as_plp_data() set the CovariateData class from
this package’s namespace, which left an object whose $ did
not dispatch under current Andromeda / FeatureExtraction.
Limitation: when about 2% of patients had no covariate,
DeepPLP stopped with an out-of-bounds index; whether native
FeatureExtraction data does the same was not checked. Only the
non-temporal MLP was run, not the temporal transformer. On Windows
import torch before duckdb / HADES in the R session (WinError 1114
otherwise). |
| PatientLevelPrediction |
getPlpData() through
plp_database_details() with demographics and a custom
covariate; createStudyPopulation() (risk window 1-365
days); runPlp() with LASSO |
The custom covariate is extracted; the study population and its
outcome count equal a direct SQL count; runPlp finishes on
the DuckDB-backed data (AUC 0.5 on random data, as it should be). |
Index-stay cohort (target_cohort.circe.json) |
CirceR + CohortGenerator, the native compilers (Python and R) and
target_cohort.sql on one small CDM with the awkward cases
(scripts/ohdsi_parity_target_cohort.R) |
The official engine and both native compilers return the same people
and index dates. The SQL differs in two cases Circe cannot express:
discharge disposition without a death record, and a death inside the
follow-up window when the observation period ends at death. Circe
applies PrimaryCriteriaLimit before the inclusion rules, so
the stay-level rules are correlated criteria of the entry event. |
Not checked
These tools are not covered by any check in this repository. Nothing here should be read as “works with”.
| Tool | Why it has not been checked |
|---|---|
| ATLAS 3 (OHDSI/Atlas3) | A Vue 3 front end for WebAPI. scripts/atlas/ exercises
the WebAPI import/render path that ATLAS 2 uses (verified on WebAPI
2.14), which ATLAS 3 shares; the ATLAS 3 UI itself was never run. WebAPI
2.14 / 2.15 cannot generate cohorts on a DuckDB source, so any ATLAS
route is for definitions, not execution. |
| Data2Evidence (OHDSI/Data2Evidence) | A multi-service platform (beta). Nothing in this repo was run inside it. |
| Phenelope (OHDSI/Phenelope) |
createConceptSet() needs an ellmer LLM
client with API access plus an Athena vocabulary. A stubbed LLM would
only test plumbing, so no row was added. |
| OHDSI GIS / Gaia (gaiaDb, gaiaCore) | gaiaDb is PostgreSQL/PostGIS and gaiaCore talks to it through DatabaseConnector. The package’s own RUCA / SDI geography features are independent of it; no Gaia exposure was loaded into a DuckDB CDM. |
