Skip to main content

omop-duck-db omop-duck-db website

CI R Coverage Python Coverage Codecov Docker image

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
pip install 'omop-duck-db[postgres-embedded]'   # optional: PostgreSQL inside Python, see testing/postgres-in-python.md

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.

Docker image

Every version tag publishes an image to GitHub Container Registry (not Docker Hub); the build runs both test suites. The badge above shows the latest build and links to the package page.

docker pull ghcr.io/jkylearmstrong/omop-duck-db:latest

Guides

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

Topic Guide
Build and operate
  Build the database, refresh the vocabulary, central vocabulary, custom and Usagi mappings, run the tests, sync large files vignette("database_and_mapping")
  Keep site databases in a PostgreSQL that runs inside Python (no install, no admin rights) and check the DuckDB <-> PostgreSQL round trip testing/postgres-in-python.md
Cohorts and features
  Study cohorts, comorbidity, measurement sanitisation, features, Table 1, reconciliation, the shipped eDERRI cohort definitions vignette("study_cohorts_and_features")
  Add your own person-level features (R and Python), and fit them once for use across sites vignette("study_features")
  Circe evaluation, cohort reconciliation, bundles, feature ablation and the DQD catalog for a downstream study vignette("study_design_tools")
Clinical tools and multi-site work
  Risk scores, wide tables, phenotypes, consortium federation, calibration, decision curves vignette("clinical_tools_and_consortium")
  Small-cell suppression, CONSORT counts, site summary packages vignette("disclosure_and_site_packages")
Machine learning and OHDSI
  scikit-learn, omop-learn, OHDSI PLP / DeepPLP, tidymodels vignette("ml_bridge")
  Benchmark features, deep-learning datasets, DGX Spark, Oracle vignette("deep_learning_and_benchmarks")
  What was checked against the official OHDSI tools, and what was not vignette("ohdsi_integration")
Cloud and demos
  Run the diabetes cohort on public BigQuery data (CMS SynPUF); the runnable BigQuery-to-DuckDB check is inst/examples/bigquery_duckdb_roundtrip.qmd vignette("bigquery_synthetic_demo")
Reproducibility and status
  Reproducing the delivered manuscript, decisions that move the numbers vignette("reproducing_the_manuscript")
  What is claimed, verified and planned; architecture notes and the R/Python parity table 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 vignette("ohdsi_integration"); 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 vignette("ohdsi_integration").

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 vignette("status_and_roadmap")). 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 and Oracle cohort-SQL translation are unit-tested only. Oracle transfers (to_sql / verify_transfer) and the DGX Spark image (gpu-check, dgx-smoke) have each been run on one real system; testing/tested-environments.md says what those runs show and what they do not. R behaviour on production-size data is less field-tested than Python’s.

See NEWS.md for changes and vignette("status_and_roadmap") for architecture notes and the R/Python parity table.

Metadata

Release files for omop-duck-db 0.31.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.31.0
File Size Uploaded Provenance Actions
omop_duck_db-0.31.0.tar.gz 14.4 MB With provenance Details for omop_duck_db-0.31.0.tar.gz

Built distribution (wheel)

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

Total release size: 15.3 MB

Release files / omop_duck_db-0.31.0.tar.gz

Download URL omop_duck_db-0.31.0.tar.gz
Size 14.4 MB
Tags Source
SHA-256 checksum
How to use checksums
845230c91941a0c3672eb36f46acc31351432cd32600f43dc2d7674ca5c5d26b
BLAKE2b-256 checksum
How to use checksums
a2b6e1f234db100d92bf6129f6ec5bbad70fe8aa452564627e7a91eebe989bd0
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 17, 2026.

Transparency log

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

Download URL omop_duck_db-0.31.0-py3-none-any.whl
Size 861.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e197e203416126b04ff619b9357503a646a7518b74068dbde3999c3cbea7c99
BLAKE2b-256 checksum
How to use checksums
7482e97e1e85e2e4a65b6adf6c37e3871ac0004d989bdd702c968547efe266eb
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 17, 2026.

Transparency log

Security for omop-duck-db 0.31.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.31.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 17, 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.31.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