Skip to main content

omop-duck-db omop-duck-db website

CI R Coverage Python Coverage Codecov

Tools for building an OMOP Common Data Model (CDM) v5.4 database in DuckDB, loading the OHDSI Athena vocabulary, mapping PCORnet-format source data into the CDM, and running cohort, feature and quality workflows on it. Provided as an R package (omopduckdb) and a Python package (omop_etl, also importable as omop_duck_db) that share the same schema and concept-mapping SQL.

Scope. General-purpose mapping/ETL tooling and a small fabricated sample fixture. This repository does not ingest, store or process protected or identifiable data; real use happens against your own data infrastructure.

Install

# install.packages("remotes")
remotes::install_github("jkylearmstrong/omop-duck-db")
pip install omop-duck-db            # or: pip install 'omop-duck-db[ml]' for the ML dependencies

Working inside this repository with R? .Rprofile activates renv; run renv::restore(), or set RENV_CONFIG_AUTOLOADER = FALSE / use Rscript --no-init-file to use your system library.

Quick start

library(omopduckdb)

build_schema("omop_cdm.duckdb")                                    # empty CDM v5.4 schema
load_vocabulary("path/to/athena_download", "omop_cdm.duckdb")      # Athena vocabulary
etl_pcornet("path/to/pcornet_extract", "omop_cdm.duckdb")          # PCORnet -> CDM

con <- omop_connect("omop_cdm.duckdb")                             # also attaches a sibling central vocabulary
cohort <- define_study_cohort(con, visit_type = "inpatient", min_age = 18, table_name = "cohort")
from omop_etl import build_schema, etl_pcornet, load_vocabulary, omop_connect, define_study_cohort
import duckdb

con = duckdb.connect("omop_cdm.duckdb"); build_schema(con); con.close()
load_vocabulary("path/to/athena_download", "omop_cdm.duckdb")
etl_pcornet("path/to/pcornet_extract", "omop_cdm.duckdb")          # a second full run needs overwrite=True

con = omop_connect("omop_cdm.duckdb")
cohort = define_study_cohort(con, visit_type="inpatient", min_age=18, table_name="cohort")

Command-line equivalents: Rscript inst/scripts/etl_pcornet.R --source-dir ... and python -m omop_etl.build_omop_cdm --source-dir .... etl_pcornet() refuses to load into a database that already holds ETL output (it would duplicate every row); pass overwrite = TRUE to empty the CDM tables first.

Guides

The long-form documentation lives in vignettes (the website’s Articles menu).

Topic Guide
Build the database, refresh the vocabulary, central vocabulary, custom and Usagi mappings vignette("database_and_mapping")
Study cohorts, comorbidity, measurement sanitisation, features, Table 1, reconciliation vignette("study_cohorts_and_features")
Add your own person-level features vignette("study_features"), vignette("study_design_tools")
scikit-learn, omop-learn, OHDSI PLP / DeepPLP, tidymodels vignette("ml_bridge")
Risk scores, wide tables, phenotypes, consortium federation, calibration, decision curves vignette("clinical_tools_and_consortium")
Benchmark features, deep-learning datasets, DGX Spark, Oracle vignette("deep_learning_and_benchmarks")
Small-cell suppression, CONSORT counts, site summary packages vignette("disclosure_and_site_packages")
Reproducing the delivered manuscript, decisions that move the numbers vignette("reproducing_the_manuscript")
Tests, large files vignette("operations")
What is claimed, verified and planned vignette("status_and_roadmap")

Works with the OHDSI ecosystem

The package is built to sit beside the standard OMOP tools, not replace them. Status by tool (the evidence is in OHDSI_INTEGRATION.md; vignette("status_and_roadmap") says what is claimed versus verified):

Status Tools
Compared against the official tool (DuckDB, DatabaseConnector 8.0.0) CirceR + CohortGenerator (cohort definitions), FeatureExtraction (visit counts, custom covariates), PatientLevelPrediction (getPlpData, study population, runPlp), DeepPatientLevelPrediction (an MLP trained on as_plp_data() output), CohortMethod (study population and an unadjusted odds ratio), CohortConstructor (concept and demographic cohorts), DataQualityDashboard, Achilles, PhenotypeLibrary, CohortDiagnostics, via HADES DatabaseConnector; omop-learn (DuckDBBackend against the real classes)
Works, partly checked ATLAS 2.x: scripts/atlas/ imports the shipped Circe JSON and has WebAPI render SQL (verified on WebAPI 2.14; not a generation check). FeatureExtraction’s Charlson index is not equivalent to the package’s.
Not covered by any check ATLAS 3 (UI never run), Data2Evidence, Phenelope (needs an LLM), OHDSI GIS / Gaia (PostgreSQL/PostGIS). Reasons in OHDSI_INTEGRATION.md.

Where the package overlaps an OHDSI tool (cohort engine, DQD catalog, Achilles subset, Table 1) it covers a subset and says so; prefer the official tool for anything you publish.

Repository layout

  • inst/extdata/5.4/duckdb/*.sql – CDM v5.4 DDL; the schema source of truth for both languages.
  • inst/sql/*.sql – DuckDB macros shared by both ETLs (ID hashing, date parsing, ancestry). Concept resolution itself is written out in each loader.
  • R/ – the R package. python/omop_etl/ – the Python package, closely mirroring it (some features are language-specific; see NOTES.md). python/omop_duck_db/ re-exports omop_etl.
  • inst/scripts/ – command-line wrappers; inst/cohorts/ – shipped Circe cohort definitions; inst/examples/, scripts/ – worked examples and repository helper scripts; vignettes/ – the guides above.

Things to know before you rely on results

  • Age. define_study_cohort() computes age in completed years. The old calendar-year method is still available as age_method = "year_difference", but it is deprecated: it admits people younger than min_age.
  • Disclosure. Aggregate helpers suppress counts from 1 to min_cell_count - 1 (default 11) and blank what could be recovered from them by subtraction. Only the duplicate/overlap helpers and the site-summary export were audited; treat other helpers’ output as pre-suppression. Details: vignette("disclosure_and_site_packages").
  • Vocabulary. Athena downloads omit CPT4 concept names (AMA licence); until the licensed tool is run, CPT4 procedures map to concept 0. A few source fields (e.g. admission source) are not mapped yet.
  • Not run live. The BigQuery sync, Oracle cohort-SQL translation and Oracle transfers are unit-tested only; the DGX Spark GPU path is untested on the device. R behaviour on production-size data is less field-tested than Python’s.

See NEWS.md for changes and NOTES.md for architecture notes and the R/Python parity table.

Metadata

Release files for omop-duck-db 0.21.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omop-duck-db 0.21.0
File Size Uploaded Provenance Actions
omop_duck_db-0.21.0.tar.gz 14.2 MB With provenance Details for omop_duck_db-0.21.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for omop-duck-db 0.21.0
File Interpreter ABI Platform Actions
omop_duck_db-0.21.0-py3-none-any.whl Python 3 none any Details for omop_duck_db-0.21.0-py3-none-any.whl

Total release size: 14.9 MB

Release files / omop_duck_db-0.21.0.tar.gz

Download URL omop_duck_db-0.21.0.tar.gz
Size 14.2 MB
Tags Source
SHA-256 checksum
How to use checksums
e15e7ecff3f2a3ebbb41cdacf071cde526431ebd50af5ba76459733268209f8a
BLAKE2b-256 checksum
How to use checksums
0f86d79fad59e78f82395623fee3247c21f6c912c72e3a94518b628ffe09a8dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / omop_duck_db-0.21.0-py3-none-any.whl

Download URL omop_duck_db-0.21.0-py3-none-any.whl
Size 741.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cb7d565a6352a237db6ffd5f55a8397381a75932f0fa8754f055c94e02700b9
BLAKE2b-256 checksum
How to use checksums
4fa122ad99e3ed0527592193a20a9ab731305e0c20654980cd3c0cb6fddbdfed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for omop-duck-db 0.21.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for omop_duck_db-0.21.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.21.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page