Metadata-Version: 2.5
Name: dzdomop
Version: 0.5.0rc1
Summary: A Python ORM/data classes representation of the OMOP Common Data Model in different flavors powered by sqlacodegen
Project-URL: Source, https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models
Project-URL: Issues, https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models/issues
Author-email: Tim Bleimehl <bleimehl@helmholtz-munich.de>
License-Expression: MIT
License-File: LICENSE
Keywords: DZD,OMOP
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: sqlalchemy<2.2,>=2.0.14
Provides-Extra: pg8000
Requires-Dist: pg8000>=1.30; extra == 'pg8000'
Provides-Extra: postgres
Requires-Dist: psycopg[binary]>=3.1; extra == 'postgres'
Provides-Extra: progress
Requires-Dist: tqdm>=4.60; extra == 'progress'
Provides-Extra: sqlmodel
Requires-Dist: sqlmodel>=0.0.22; extra == 'sqlmodel'
Description-Content-Type: text/markdown

# dzdomop: the OMOP CDM as Python classes

The [OMOP Common Data Model](https://ohdsi.github.io/CommonDataModel/) (CDM) 5.3, 5.4 and 5.5 as
ready-made [SQLAlchemy](https://www.sqlalchemy.org/) and [SQLModel](https://sqlmodel.tiangolo.com/)
classes, plus a loader for the standardized vocabularies you export from
[Athena](https://athena.ohdsi.org).

- Create a complete OMOP schema with one call
- Write and query OMOP data with typed Python classes; the OMOP docs show up in your editor
- Load an Athena export (folder, zip file or download link) into PostgreSQL or SQLite

Status: beta, your feedback is welcome.

## Install

```bash
pip install dzdomop
```

| Extra | Installs | Needed for |
| ----- | -------- | ---------- |
| `sqlmodel` | sqlmodel | the `OMOP_5_x_sqlmodels` modules |
| `postgres` | psycopg 3 | PostgreSQL (psycopg2 and pg8000 work too) |
| `pg8000` | pg8000 | PostgreSQL with `postgresql+pg8000://` |
| `progress` | tqdm | progress bars of the vocabulary loader |

## Quickstart

```python
from sqlalchemy import create_engine, select
from sqlalchemy.orm import Session
from omopmodel import OMOP_5_4_declarative as omop

engine = create_engine("sqlite:///omop.db")
omop.metadata.create_all(engine)  # every OMOP CDM 5.4 table

with Session(engine) as session:
    care_site = omop.CareSite(care_site_id=1, care_site_name="St. Local")
    person = omop.Person(
        person_id=1,
        year_of_birth=1985,
        care_site=care_site,
        gender_concept_id=0,
        race_concept_id=0,
        ethnicity_concept_id=0,
    )
    session.add(person)
    session.commit()
    print(session.scalars(select(omop.Person)).one().care_site.care_site_name)
```

Load a vocabulary export from Athena (the zip file, the unzipped folder or the download link):

<!-- docs-test: run -->
```bash
dzdomop load-vocab athena-export.zip --url sqlite:///omop.db --cdm-version 5.4 --create-tables
```

## Documentation

- [User guide](https://dzd-ev-diabetes-research.github.io/dzd-omop-cdm-python-models/): flavors,
  relationships, validation, vocabularies, PostgreSQL, FAQ
- [Upgrading from 0.4](https://dzd-ev-diabetes-research.github.io/dzd-omop-cdm-python-models/upgrading/)
- [Changelog](https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models/blob/main/CHANGELOG.md)
- [Source code and issues](https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models)

Maintainer: Tim Bleimehl · License: MIT
