dzdomop 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dzdomop-0.3.1/PKG-INFO +78 -0
- dzdomop-0.3.1/README.md +50 -0
- dzdomop-0.3.1/dzdomop.egg-info/PKG-INFO +78 -0
- dzdomop-0.3.1/dzdomop.egg-info/SOURCES.txt +21 -0
- dzdomop-0.3.1/dzdomop.egg-info/dependency_links.txt +1 -0
- dzdomop-0.3.1/dzdomop.egg-info/requires.txt +14 -0
- dzdomop-0.3.1/dzdomop.egg-info/top_level.txt +1 -0
- dzdomop-0.3.1/examples/postgresql_create_omop_schema_and_load_vocab.py +23 -0
- dzdomop-0.3.1/examples/sqlite_create_omop_schema_and_load_vocab.py +25 -0
- dzdomop-0.3.1/examples/sqlite_insert_person.py +27 -0
- dzdomop-0.3.1/examples/sqlite_insert_person_sqlmodel_wip.py +29 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_3_dataclasses.py +1836 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_3_declarative.py +1836 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_3_sqlmodels.py +1819 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_3_tables.py +850 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_4_dataclasses.py +1971 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_4_declarative.py +1971 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_4_sqlmodels.py +1952 -0
- dzdomop-0.3.1/omopmodel/OMOP_5_4_tables.py +917 -0
- dzdomop-0.3.1/omopmodel/__init__.py +1 -0
- dzdomop-0.3.1/omopmodel/vocabularies_loader.py +703 -0
- dzdomop-0.3.1/pyproject.toml +32 -0
- dzdomop-0.3.1/setup.cfg +4 -0
dzdomop-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: dzdomop
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A Python ORM/data classes representation of the OMOP Common Data Model in different flavors powered by sqlacodegen
|
|
5
|
+
Author-email: Tim Bleimehl <bleimehl@helmholtz-munich.de>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models
|
|
8
|
+
Project-URL: Issues, https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models/issues
|
|
9
|
+
Keywords: DZD,OMOP
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: sqlmodel
|
|
17
|
+
Requires-Dist: sqlalchemy
|
|
18
|
+
Requires-Dist: tqdm
|
|
19
|
+
Requires-Dist: pg8000
|
|
20
|
+
Provides-Extra: test
|
|
21
|
+
Requires-Dist: pytest; extra == "test"
|
|
22
|
+
Requires-Dist: deepdiff; extra == "test"
|
|
23
|
+
Provides-Extra: docs
|
|
24
|
+
Requires-Dist: mkdocs; extra == "docs"
|
|
25
|
+
Requires-Dist: mkdocstrings[python]; extra == "docs"
|
|
26
|
+
Requires-Dist: mkdocs-autorefs; extra == "docs"
|
|
27
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
28
|
+
|
|
29
|
+
# DZD - OMOP CDM Python ORM/Data Classes Representation
|
|
30
|
+
A Python ORM/data classes representation of the [Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM)](https://www.ohdsi.org/data-standardization/) in different flavors powered by [sqlacodegen](https://github.com/agronholm/sqlacodegen)
|
|
31
|
+
|
|
32
|
+
Author/Maintainer: Tim Bleimehl
|
|
33
|
+
|
|
34
|
+
For more background how this sausage is made have a look at the github repo at https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models
|
|
35
|
+
|
|
36
|
+
This Readme is a "work in process". Come back later for a more complete manual.
|
|
37
|
+
|
|
38
|
+
# Install
|
|
39
|
+
|
|
40
|
+
Just install the python module from pypi.org
|
|
41
|
+
|
|
42
|
+
`python -m pip install --upgrade dzdomop`
|
|
43
|
+
|
|
44
|
+
# How to use
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
This tiny script demostrates how this module can help you to
|
|
49
|
+
* Create a local dev database with the complete omop datamodel
|
|
50
|
+
* insert some data based on our classes with some basic guardrails like type validation, typo prevention, ...
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from sqlalchemy import create_engine
|
|
54
|
+
from sqlalchemy.orm import Session
|
|
55
|
+
from omopmodel import OMOP_5_3_declarative as omop
|
|
56
|
+
|
|
57
|
+
# Create a local SQLite database with all OMOP CDM tables+properties
|
|
58
|
+
engine = create_engine("sqlite:///cdm_source.db", echo=True)
|
|
59
|
+
omop.Base.metadata.create_all(engine)
|
|
60
|
+
|
|
61
|
+
# Create a some basic OMOP objects
|
|
62
|
+
care_site = omop.CareSite(care_site_id=5678, care_site_name="St. Local")
|
|
63
|
+
person = omop.Person(
|
|
64
|
+
person_id=1234,
|
|
65
|
+
year_of_birth=1985,
|
|
66
|
+
care_site=care_site,
|
|
67
|
+
gender_concept_id=1,
|
|
68
|
+
race_concept_id=1,
|
|
69
|
+
ethnicity_concept_id=1,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Write the Object to the database
|
|
73
|
+
with Session(engine) as session:
|
|
74
|
+
session.add(care_site)
|
|
75
|
+
session.add(person)
|
|
76
|
+
session.commit()
|
|
77
|
+
```
|
|
78
|
+
|
dzdomop-0.3.1/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# DZD - OMOP CDM Python ORM/Data Classes Representation
|
|
2
|
+
A Python ORM/data classes representation of the [Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM)](https://www.ohdsi.org/data-standardization/) in different flavors powered by [sqlacodegen](https://github.com/agronholm/sqlacodegen)
|
|
3
|
+
|
|
4
|
+
Author/Maintainer: Tim Bleimehl
|
|
5
|
+
|
|
6
|
+
For more background how this sausage is made have a look at the github repo at https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models
|
|
7
|
+
|
|
8
|
+
This Readme is a "work in process". Come back later for a more complete manual.
|
|
9
|
+
|
|
10
|
+
# Install
|
|
11
|
+
|
|
12
|
+
Just install the python module from pypi.org
|
|
13
|
+
|
|
14
|
+
`python -m pip install --upgrade dzdomop`
|
|
15
|
+
|
|
16
|
+
# How to use
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
This tiny script demostrates how this module can help you to
|
|
21
|
+
* Create a local dev database with the complete omop datamodel
|
|
22
|
+
* insert some data based on our classes with some basic guardrails like type validation, typo prevention, ...
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from sqlalchemy import create_engine
|
|
26
|
+
from sqlalchemy.orm import Session
|
|
27
|
+
from omopmodel import OMOP_5_3_declarative as omop
|
|
28
|
+
|
|
29
|
+
# Create a local SQLite database with all OMOP CDM tables+properties
|
|
30
|
+
engine = create_engine("sqlite:///cdm_source.db", echo=True)
|
|
31
|
+
omop.Base.metadata.create_all(engine)
|
|
32
|
+
|
|
33
|
+
# Create a some basic OMOP objects
|
|
34
|
+
care_site = omop.CareSite(care_site_id=5678, care_site_name="St. Local")
|
|
35
|
+
person = omop.Person(
|
|
36
|
+
person_id=1234,
|
|
37
|
+
year_of_birth=1985,
|
|
38
|
+
care_site=care_site,
|
|
39
|
+
gender_concept_id=1,
|
|
40
|
+
race_concept_id=1,
|
|
41
|
+
ethnicity_concept_id=1,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Write the Object to the database
|
|
45
|
+
with Session(engine) as session:
|
|
46
|
+
session.add(care_site)
|
|
47
|
+
session.add(person)
|
|
48
|
+
session.commit()
|
|
49
|
+
```
|
|
50
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: dzdomop
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A Python ORM/data classes representation of the OMOP Common Data Model in different flavors powered by sqlacodegen
|
|
5
|
+
Author-email: Tim Bleimehl <bleimehl@helmholtz-munich.de>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models
|
|
8
|
+
Project-URL: Issues, https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models/issues
|
|
9
|
+
Keywords: DZD,OMOP
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: sqlmodel
|
|
17
|
+
Requires-Dist: sqlalchemy
|
|
18
|
+
Requires-Dist: tqdm
|
|
19
|
+
Requires-Dist: pg8000
|
|
20
|
+
Provides-Extra: test
|
|
21
|
+
Requires-Dist: pytest; extra == "test"
|
|
22
|
+
Requires-Dist: deepdiff; extra == "test"
|
|
23
|
+
Provides-Extra: docs
|
|
24
|
+
Requires-Dist: mkdocs; extra == "docs"
|
|
25
|
+
Requires-Dist: mkdocstrings[python]; extra == "docs"
|
|
26
|
+
Requires-Dist: mkdocs-autorefs; extra == "docs"
|
|
27
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
28
|
+
|
|
29
|
+
# DZD - OMOP CDM Python ORM/Data Classes Representation
|
|
30
|
+
A Python ORM/data classes representation of the [Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM)](https://www.ohdsi.org/data-standardization/) in different flavors powered by [sqlacodegen](https://github.com/agronholm/sqlacodegen)
|
|
31
|
+
|
|
32
|
+
Author/Maintainer: Tim Bleimehl
|
|
33
|
+
|
|
34
|
+
For more background how this sausage is made have a look at the github repo at https://github.com/DZD-eV-Diabetes-Research/dzd-omop-cdm-python-models
|
|
35
|
+
|
|
36
|
+
This Readme is a "work in process". Come back later for a more complete manual.
|
|
37
|
+
|
|
38
|
+
# Install
|
|
39
|
+
|
|
40
|
+
Just install the python module from pypi.org
|
|
41
|
+
|
|
42
|
+
`python -m pip install --upgrade dzdomop`
|
|
43
|
+
|
|
44
|
+
# How to use
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
This tiny script demostrates how this module can help you to
|
|
49
|
+
* Create a local dev database with the complete omop datamodel
|
|
50
|
+
* insert some data based on our classes with some basic guardrails like type validation, typo prevention, ...
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from sqlalchemy import create_engine
|
|
54
|
+
from sqlalchemy.orm import Session
|
|
55
|
+
from omopmodel import OMOP_5_3_declarative as omop
|
|
56
|
+
|
|
57
|
+
# Create a local SQLite database with all OMOP CDM tables+properties
|
|
58
|
+
engine = create_engine("sqlite:///cdm_source.db", echo=True)
|
|
59
|
+
omop.Base.metadata.create_all(engine)
|
|
60
|
+
|
|
61
|
+
# Create a some basic OMOP objects
|
|
62
|
+
care_site = omop.CareSite(care_site_id=5678, care_site_name="St. Local")
|
|
63
|
+
person = omop.Person(
|
|
64
|
+
person_id=1234,
|
|
65
|
+
year_of_birth=1985,
|
|
66
|
+
care_site=care_site,
|
|
67
|
+
gender_concept_id=1,
|
|
68
|
+
race_concept_id=1,
|
|
69
|
+
ethnicity_concept_id=1,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Write the Object to the database
|
|
73
|
+
with Session(engine) as session:
|
|
74
|
+
session.add(care_site)
|
|
75
|
+
session.add(person)
|
|
76
|
+
session.commit()
|
|
77
|
+
```
|
|
78
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
dzdomop.egg-info/PKG-INFO
|
|
4
|
+
dzdomop.egg-info/SOURCES.txt
|
|
5
|
+
dzdomop.egg-info/dependency_links.txt
|
|
6
|
+
dzdomop.egg-info/requires.txt
|
|
7
|
+
dzdomop.egg-info/top_level.txt
|
|
8
|
+
examples/postgresql_create_omop_schema_and_load_vocab.py
|
|
9
|
+
examples/sqlite_create_omop_schema_and_load_vocab.py
|
|
10
|
+
examples/sqlite_insert_person.py
|
|
11
|
+
examples/sqlite_insert_person_sqlmodel_wip.py
|
|
12
|
+
omopmodel/OMOP_5_3_dataclasses.py
|
|
13
|
+
omopmodel/OMOP_5_3_declarative.py
|
|
14
|
+
omopmodel/OMOP_5_3_sqlmodels.py
|
|
15
|
+
omopmodel/OMOP_5_3_tables.py
|
|
16
|
+
omopmodel/OMOP_5_4_dataclasses.py
|
|
17
|
+
omopmodel/OMOP_5_4_declarative.py
|
|
18
|
+
omopmodel/OMOP_5_4_sqlmodels.py
|
|
19
|
+
omopmodel/OMOP_5_4_tables.py
|
|
20
|
+
omopmodel/__init__.py
|
|
21
|
+
omopmodel/vocabularies_loader.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
omopmodel
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from sqlalchemy import create_engine
|
|
2
|
+
from omopmodel import OMOP_5_4_declarative as omop54
|
|
3
|
+
from omopmodel import VocabulariesLoader
|
|
4
|
+
|
|
5
|
+
# Define the connection to our running postgresql database
|
|
6
|
+
engine = create_engine("postgresql+pg8000://ps:ps@localhost/ps")
|
|
7
|
+
|
|
8
|
+
# Define the directory where our athena vocabularies csv files are stored.
|
|
9
|
+
authena_export_directory = "/home/me/Downloads/AthenaUnzipped"
|
|
10
|
+
|
|
11
|
+
# Create the OMOP Schema on our database
|
|
12
|
+
omop54.Base.metadata.create_all(engine)
|
|
13
|
+
|
|
14
|
+
# Initialize the vocabulary loader.
|
|
15
|
+
v = VocabulariesLoader(
|
|
16
|
+
authena_export_directory,
|
|
17
|
+
database_engine=engine,
|
|
18
|
+
omop_module=omop54, # <- This is optional. default is OMOP CDM V5.4
|
|
19
|
+
)
|
|
20
|
+
# Load the vocaablary from the CSV files into the database.
|
|
21
|
+
# This will take some time, you will see some progress bars.
|
|
22
|
+
# Take your time make a coffe
|
|
23
|
+
v.load_all()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from sqlalchemy import create_engine
|
|
2
|
+
from omopmodel import OMOP_5_4_declarative as omop54
|
|
3
|
+
from omopmodel import VocabulariesLoader
|
|
4
|
+
|
|
5
|
+
# Define the connection to our sqlite database.
|
|
6
|
+
# if it does not exists, it will created on the fly
|
|
7
|
+
engine = create_engine("sqlite:///cdm_source.db", echo=False)
|
|
8
|
+
|
|
9
|
+
# Define the directory where our athena vocabularies csv files are stored.
|
|
10
|
+
authena_export_directory = "/home/tim/Downloads/tmp/athenalars"
|
|
11
|
+
|
|
12
|
+
# Create the OMOP Schema on our database
|
|
13
|
+
omop54.Base.metadata.create_all(engine)
|
|
14
|
+
|
|
15
|
+
# Initialize the vocabulary loader.
|
|
16
|
+
v = VocabulariesLoader(
|
|
17
|
+
authena_export_directory,
|
|
18
|
+
database_engine=engine,
|
|
19
|
+
omop_module=omop54, # <- This is optional. default is OMOP CDM V5.4
|
|
20
|
+
)
|
|
21
|
+
# Load the vocabulary from the CSV files into the database.
|
|
22
|
+
# HINT: If you are using a sqlite database this can take unbearably long
|
|
23
|
+
# sqlite is for testing and tinkering but will have a hard time storing larger vocabulary exports
|
|
24
|
+
# Use postgresql instead
|
|
25
|
+
v.load_all()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from sqlalchemy import create_engine
|
|
2
|
+
from sqlalchemy.orm import Session
|
|
3
|
+
from omopmodel import OMOP_5_3_declarative as omop53
|
|
4
|
+
|
|
5
|
+
# Create a SQLite database and deploy the omop schema (tables,constraints, indices and primary keys)
|
|
6
|
+
|
|
7
|
+
engine = create_engine("sqlite:///cdm_source.db", echo=False)
|
|
8
|
+
|
|
9
|
+
# Create the schema if not done
|
|
10
|
+
omop53.Base.metadata.create_all(engine)
|
|
11
|
+
|
|
12
|
+
# Define a caresite and a person. Connect these two
|
|
13
|
+
care_site = omop53.CareSite(care_site_id=5678, care_site_name="St. Local")
|
|
14
|
+
person = omop53.Person(
|
|
15
|
+
person_id=1234,
|
|
16
|
+
year_of_birth=1985,
|
|
17
|
+
care_site=care_site,
|
|
18
|
+
gender_concept_id=0,
|
|
19
|
+
race_concept_id=0,
|
|
20
|
+
ethnicity_concept_id=0,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Open a session and write these object/rows to the database
|
|
24
|
+
with Session(engine) as session:
|
|
25
|
+
session.add(care_site)
|
|
26
|
+
session.add(person)
|
|
27
|
+
session.commit()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from sqlmodel import SQLModel, Session, create_engine
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from omopmodel import OMOP_5_4_sqlmodels as omop54
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Create a SQLite database and deploy the omop schema (tables,constraints, indices and primary keys)
|
|
8
|
+
|
|
9
|
+
engine = create_engine("sqlite:///cdm_source.db", echo=False)
|
|
10
|
+
|
|
11
|
+
# Create the schema if not done
|
|
12
|
+
SQLModel.metadata.create_all(engine)
|
|
13
|
+
|
|
14
|
+
# Define a caresite and a person. Connect these two
|
|
15
|
+
care_site = omop54.CareSite(care_site_id=5678, care_site_name="St. Local")
|
|
16
|
+
person = omop54.Person(
|
|
17
|
+
person_id=1234,
|
|
18
|
+
year_of_birth=1985,
|
|
19
|
+
care_site=care_site,
|
|
20
|
+
gender_concept_id=0,
|
|
21
|
+
race_concept_id=0,
|
|
22
|
+
ethnicity_concept_id=0,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Open a session and write these object/rows to the database
|
|
26
|
+
with Session(engine) as session:
|
|
27
|
+
session.add(care_site)
|
|
28
|
+
session.add(person)
|
|
29
|
+
session.commit()
|