-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
7,350 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Ruff | ||
on: [push, pull_request] | ||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: chartboost/ruff-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This workflow will install Python dependencies, run tests with a range of Python versions | ||
|
||
name: tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [ | ||
'3.8', | ||
'3.9', | ||
'3.10', | ||
'3.11', | ||
'3.12', | ||
] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
- name: Install package and dependencies | ||
run: poetry install | ||
- name: Test with pytest | ||
run: poetry run pytest -vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.3.2 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter. | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# OMOP-CDM | ||
|
||
Python SQLAlchemy table definitions of the [OHDSI OMOP CDM](https://ohdsi.github.io/CommonDataModel/). | ||
|
||
## Installation | ||
|
||
Install from PyPI: | ||
```shell | ||
pip install omop-cdm | ||
``` | ||
|
||
## Usage | ||
TODO: | ||
See [User documentation](docs/index.md) | ||
|
||
## Development | ||
|
||
### Setup steps | ||
|
||
Make sure the following tooling is installed: | ||
- [Poetry](https://python-poetry.org/docs/#installation) | ||
- [pre-commit](https://pre-commit.com/#install) | ||
|
||
Install the project and dependencies via `poetry install`. | ||
|
||
Then set up the git hook scripts via `pre-commit install`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import nox # type: ignore | ||
|
||
nox.options.sessions = [ | ||
"tests", | ||
"lint", | ||
] | ||
|
||
python = [ | ||
"3.8", | ||
"3.9", | ||
"3.10", | ||
"3.11", | ||
"3.12", | ||
] | ||
|
||
|
||
@nox.session(python=python) | ||
def tests(session): | ||
session.run("poetry", "install", external=True) | ||
session.run("pytest") | ||
|
||
|
||
@nox.session(python="3.12") | ||
def lint(session): | ||
session.run("poetry", "install", external=True) | ||
session.run("ruff", "check") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[tool.poetry] | ||
name = "omop-cdm" | ||
version = "0.1.0" | ||
description = "SQLAlchemy ORM of the OHDSI OMOP CDM" | ||
authors = [ | ||
"Spayralbe <[email protected]>", | ||
] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
sqlalchemy = "^2.0.0" | ||
|
||
|
||
[tool.poetry.group.test.dependencies] | ||
testcontainers-postgres = "^0.0.1rc1" | ||
pytest = "^8.1.1" | ||
nox = "^2024.3.2" | ||
ruff = "^0.3.2" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
|
||
[tool.pytest.ini_options] | ||
addopts = "--import-mode=importlib" | ||
pythonpath = [ | ||
".", | ||
] | ||
|
||
# Ignore import violations in all `__init__.py` files | ||
[tool.ruff.lint.per-file-ignores] | ||
"__init__.py" = ["E402", "F401"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from omop_cdm.constants import NAMING_CONVENTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Module containing the placeholder schema names as used in the ORM.""" | ||
|
||
# These are the placeholder schema names as used in the ORM table | ||
# definitions and as keys in the schema_translate_map. | ||
# Actual schema names will be different at runtime, as determined by the | ||
# provided parameters in the config.yml file. | ||
VOCAB_SCHEMA = "vocabulary_schema" | ||
CDM_SCHEMA = "cdm_schema" | ||
|
||
# Some often used foreign keys are added as variables for convenience. | ||
FK_CONCEPT_ID = f"{VOCAB_SCHEMA}.concept.concept_id" | ||
FK_VOCABULARY_ID = f"{VOCAB_SCHEMA}.vocabulary.vocabulary_id" | ||
FK_DOMAIN_ID = f"{VOCAB_SCHEMA}.domain.domain_id" | ||
FK_CONCEPT_CLASS_ID = f"{VOCAB_SCHEMA}.concept_class.concept_class_id" | ||
FK_PERSON_ID = f"{CDM_SCHEMA}.person.person_id" | ||
FK_VISIT_OCCURRENCE_ID = f"{CDM_SCHEMA}.visit_occurrence.visit_occurrence_id" | ||
FK_VISIT_DETAIL_ID = f"{CDM_SCHEMA}.visit_detail.visit_detail_id" | ||
FK_PROVIDER_ID = f"{CDM_SCHEMA}.provider.provider_id" | ||
FK_CARE_SITE_ID = f"{CDM_SCHEMA}.care_site.care_site_id" | ||
FK_LOCATION_ID = f"{CDM_SCHEMA}.location.location_id" | ||
|
||
# This object should be used to set the naming_convention parameter of | ||
# the SQLAlchemy MetaData object. Using it makes sure that the naming of | ||
# constraints and indexes is deterministic and not left up to the DBMS. | ||
# It's also needed when dropping these, as SQLAlchemy requires that | ||
# they have a name for them to be dropped. See: | ||
# https://docs.sqlalchemy.org/en/20/core/constraints.html#configuring-constraint-naming-conventions | ||
NAMING_CONVENTION = { | ||
"ix": "ix_%(table_name)s_%(column_0_N_name)s", | ||
"uq": "uq_%(table_name)s_%(column_0_name)s", | ||
"ck": "ck_%(table_name)s_%(constraint_name)s", | ||
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", | ||
"pk": "pk_%(table_name)s", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
OMOP CDM Version 5.3.1. | ||
Generated from OMOP CDM release 5.3.1 using sqlacodegen 3.0.0rc5. | ||
DDL from https://github.com/OHDSI/CommonDataModel/tree/v5.3.1. | ||
Deviations from standard model | ||
Removed | ||
attribute_definition | ||
cohort_attribute | ||
Added | ||
stem_table | ||
source_to_concept_map_version | ||
Updated | ||
source_to_concept_map | ||
source_code from VARCHAR(50) --> VARCHAR(1000) | ||
If using a separate vocab schema, STCM is created in the CDM schema | ||
""" |
Oops, something went wrong.