From 01ee1440a596a8542001b14623bc88dbbdf61d01 Mon Sep 17 00:00:00 2001 From: Spayralbe Date: Thu, 14 Mar 2024 14:33:45 +0100 Subject: [PATCH] First version --- .github/PULL_REQUEST_TEMPLATE.md | 4 + .github/workflows/lint.yml | 15 + .github/workflows/python-package.yml | 32 + .pre-commit-config.yaml | 19 + CHANGELOG.md | 4 + README.md | 22 + noxfile.py | 47 + poetry.lock | 1037 ++++++++++++++++ pyproject.toml | 35 + ruff.toml | 24 + src/omop_cdm/__init__.py | 1 + src/omop_cdm/constants.py | 33 + src/omop_cdm/dynamic/cdm531/__init__.py | 29 + src/omop_cdm/dynamic/cdm531/clinical_data.py | 902 ++++++++++++++ .../dynamic/cdm531/derived_elements.py | 76 ++ .../dynamic/cdm531/health_economics.py | 123 ++ .../dynamic/cdm531/health_system_data.py | 81 ++ src/omop_cdm/dynamic/cdm531/metadata.py | 38 + src/omop_cdm/dynamic/cdm531/vocabularies.py | 262 ++++ src/omop_cdm/dynamic/cdm54/__init__.py | 29 + src/omop_cdm/dynamic/cdm54/clinical_data.py | 949 +++++++++++++++ .../dynamic/cdm54/derived_elements.py | 137 +++ .../dynamic/cdm54/health_economics.py | 122 ++ .../dynamic/cdm54/health_system_data.py | 91 ++ src/omop_cdm/dynamic/cdm54/metadata.py | 59 + .../dynamic/cdm54/vocabularies/__init__.py | 1 + .../cdm54/vocabularies/vocabularies.py | 266 ++++ src/omop_cdm/dynamic/cdm600/__init__.py | 24 + src/omop_cdm/dynamic/cdm600/clinical_data.py | 965 +++++++++++++++ .../dynamic/cdm600/derived_elements.py | 76 ++ .../dynamic/cdm600/health_economics.py | 143 +++ .../dynamic/cdm600/health_system_data.py | 112 ++ src/omop_cdm/dynamic/cdm600/metadata.py | 38 + src/omop_cdm/dynamic/cdm600/vocabularies.py | 280 +++++ src/omop_cdm/dynamic/legacy/__init__.py | 1 + src/omop_cdm/dynamic/legacy/legacy.py | 96 ++ src/omop_cdm/dynamic/ruff.toml | 10 + src/omop_cdm/regular/cdm531/__init__.py | 100 ++ src/omop_cdm/regular/cdm531/tables.py | 980 +++++++++++++++ src/omop_cdm/regular/cdm54/__init__.py | 103 ++ src/omop_cdm/regular/cdm54/tables.py | 1070 ++++++++++++++++ src/omop_cdm/regular/cdm600/__init__.py | 94 ++ src/omop_cdm/regular/cdm600/tables.py | 1082 +++++++++++++++++ src/omop_cdm/regular/ruff.toml | 5 + tests/conftest.py | 40 + tests/omop_cdm/dynamic/cdm531/test_cdm531.py | 26 + tests/omop_cdm/dynamic/cdm54/test_cdm54.py | 26 + .../dynamic/cdm54_custom/test_cdm54_custom.py | 64 + .../dynamic/cdm54_plus_legacy/test_legacy.py | 28 + tests/omop_cdm/dynamic/cdm600/test_cdm600.py | 26 + .../cdm_definitions/cdm531/__init__.py | 1 + .../dynamic/cdm_definitions/cdm531/tables.py | 208 ++++ .../dynamic/cdm_definitions/cdm54/__init__.py | 1 + .../dynamic/cdm_definitions/cdm54/tables.py | 218 ++++ .../cdm_definitions/cdm54_custom/__init__.py | 3 + .../cdm_definitions/cdm54_custom/tables.py | 237 ++++ .../cdm54_plus_legacy/__init__.py | 3 + .../cdm54_plus_legacy/tables.py | 240 ++++ .../cdm_definitions/cdm600/__init__.py | 1 + .../dynamic/cdm_definitions/cdm600/tables.py | 213 ++++ tests/omop_cdm/regular/cdm531/test_cdm531.py | 27 + tests/omop_cdm/regular/cdm54/test_cdm54.py | 27 + .../test_cdm54_extra_tables.py | 27 + tests/omop_cdm/regular/cdm600/test_cdm600.py | 27 + .../cdm_definitions/cdm54_custom/__init__.py | 3 + .../cdm_definitions/cdm54_custom/tables.py | 29 + tests/omop_cdm/table_sets.py | 113 ++ 67 files changed, 11205 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/python-package.yml create mode 100644 .pre-commit-config.yaml create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 noxfile.py create mode 100644 poetry.lock create mode 100644 pyproject.toml create mode 100644 ruff.toml create mode 100644 src/omop_cdm/__init__.py create mode 100644 src/omop_cdm/constants.py create mode 100644 src/omop_cdm/dynamic/cdm531/__init__.py create mode 100644 src/omop_cdm/dynamic/cdm531/clinical_data.py create mode 100644 src/omop_cdm/dynamic/cdm531/derived_elements.py create mode 100644 src/omop_cdm/dynamic/cdm531/health_economics.py create mode 100644 src/omop_cdm/dynamic/cdm531/health_system_data.py create mode 100644 src/omop_cdm/dynamic/cdm531/metadata.py create mode 100644 src/omop_cdm/dynamic/cdm531/vocabularies.py create mode 100644 src/omop_cdm/dynamic/cdm54/__init__.py create mode 100644 src/omop_cdm/dynamic/cdm54/clinical_data.py create mode 100644 src/omop_cdm/dynamic/cdm54/derived_elements.py create mode 100644 src/omop_cdm/dynamic/cdm54/health_economics.py create mode 100644 src/omop_cdm/dynamic/cdm54/health_system_data.py create mode 100644 src/omop_cdm/dynamic/cdm54/metadata.py create mode 100644 src/omop_cdm/dynamic/cdm54/vocabularies/__init__.py create mode 100644 src/omop_cdm/dynamic/cdm54/vocabularies/vocabularies.py create mode 100644 src/omop_cdm/dynamic/cdm600/__init__.py create mode 100644 src/omop_cdm/dynamic/cdm600/clinical_data.py create mode 100644 src/omop_cdm/dynamic/cdm600/derived_elements.py create mode 100644 src/omop_cdm/dynamic/cdm600/health_economics.py create mode 100644 src/omop_cdm/dynamic/cdm600/health_system_data.py create mode 100644 src/omop_cdm/dynamic/cdm600/metadata.py create mode 100644 src/omop_cdm/dynamic/cdm600/vocabularies.py create mode 100644 src/omop_cdm/dynamic/legacy/__init__.py create mode 100644 src/omop_cdm/dynamic/legacy/legacy.py create mode 100644 src/omop_cdm/dynamic/ruff.toml create mode 100644 src/omop_cdm/regular/cdm531/__init__.py create mode 100644 src/omop_cdm/regular/cdm531/tables.py create mode 100644 src/omop_cdm/regular/cdm54/__init__.py create mode 100644 src/omop_cdm/regular/cdm54/tables.py create mode 100644 src/omop_cdm/regular/cdm600/__init__.py create mode 100644 src/omop_cdm/regular/cdm600/tables.py create mode 100644 src/omop_cdm/regular/ruff.toml create mode 100644 tests/conftest.py create mode 100644 tests/omop_cdm/dynamic/cdm531/test_cdm531.py create mode 100644 tests/omop_cdm/dynamic/cdm54/test_cdm54.py create mode 100644 tests/omop_cdm/dynamic/cdm54_custom/test_cdm54_custom.py create mode 100644 tests/omop_cdm/dynamic/cdm54_plus_legacy/test_legacy.py create mode 100644 tests/omop_cdm/dynamic/cdm600/test_cdm600.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm531/__init__.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm531/tables.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm54/__init__.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm54/tables.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/__init__.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/tables.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/__init__.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/tables.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm600/__init__.py create mode 100644 tests/omop_cdm/dynamic/cdm_definitions/cdm600/tables.py create mode 100644 tests/omop_cdm/regular/cdm531/test_cdm531.py create mode 100644 tests/omop_cdm/regular/cdm54/test_cdm54.py create mode 100644 tests/omop_cdm/regular/cdm54_extra_tables/test_cdm54_extra_tables.py create mode 100644 tests/omop_cdm/regular/cdm600/test_cdm600.py create mode 100644 tests/omop_cdm/regular/cdm_definitions/cdm54_custom/__init__.py create mode 100644 tests/omop_cdm/regular/cdm_definitions/cdm54_custom/tables.py create mode 100644 tests/omop_cdm/table_sets.py diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..1577e64 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,4 @@ + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..29a9ad9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,15 @@ +name: Ruff +on: [push, pull_request] +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + - name: Install Poetry + uses: snok/install-poetry@v1 + - name: Install nox + run: pip install nox + - name: Run ruff linter via nox session + run: nox -s lint diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..a402ee0 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a0d0bb4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2196a9a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog + +## v0.1.0 +First release. diff --git a/README.md b/README.md new file mode 100644 index 0000000..21fc271 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# 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 [Poetry](https://python-poetry.org/docs/#installation) is installed. +- Install the project and dependencies via `poetry install`. +- Set up the pre-commit hook scripts via `poetry run pre-commit install`. diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..2138fee --- /dev/null +++ b/noxfile.py @@ -0,0 +1,47 @@ +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: nox.Session): + """Run test suite.""" + session.run("poetry", "install", external=True) + session.run("pytest", "--cov=src") + session.notify("coverage") + + +@nox.session +def coverage(session: nox.Session): + """Generate pytest code coverage report.""" + session.run("coverage", "report", "--show-missing") + + +@nox.session(reuse_venv=True, name="format") +def format_all(session: nox.Session): + """Format codebase with ruff.""" + session.run("poetry", "install", "--only", "dev", external=True) + session.run("ruff", "format") + # format imports according to isort via ruff check + session.run("ruff", "check", "--select", "I", "--fix") + + +@nox.session(reuse_venv=True) +def lint(session: nox.Session): + """Run ruff linter.""" + session.run("poetry", "install", "--only", "dev", external=True) + # Run the ruff linter + session.run("ruff", "check") + # Check if any code requires formatting via ruff format + session.run("ruff", "format", "--diff") diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..3e17deb --- /dev/null +++ b/poetry.lock @@ -0,0 +1,1037 @@ +# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. + +[[package]] +name = "argcomplete" +version = "3.2.3" +description = "Bash tab completion for argparse" +optional = false +python-versions = ">=3.8" +files = [ + {file = "argcomplete-3.2.3-py3-none-any.whl", hash = "sha256:c12355e0494c76a2a7b73e3a59b09024ca0ba1e279fb9ed6c1b82d5b74b6a70c"}, + {file = "argcomplete-3.2.3.tar.gz", hash = "sha256:bf7900329262e481be5a15f56f19736b376df6f82ed27576fa893652c5de6c23"}, +] + +[package.extras] +test = ["coverage", "mypy", "pexpect", "ruff", "wheel"] + +[[package]] +name = "certifi" +version = "2024.2.2" +description = "Python package for providing Mozilla's CA Bundle." +optional = false +python-versions = ">=3.6" +files = [ + {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, + {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, +] + +[[package]] +name = "cfgv" +version = "3.4.0" +description = "Validate configuration and produce human readable error messages." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, +] + +[[package]] +name = "charset-normalizer" +version = "3.3.2" +description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +optional = false +python-versions = ">=3.7.0" +files = [ + {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-win32.whl", hash = "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-win32.whl", hash = "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-win32.whl", hash = "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-win32.whl", hash = "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl", hash = "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-win32.whl", hash = "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-win32.whl", hash = "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"}, + {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, +] + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "colorlog" +version = "6.8.2" +description = "Add colours to the output of Python's logging module." +optional = false +python-versions = ">=3.6" +files = [ + {file = "colorlog-6.8.2-py3-none-any.whl", hash = "sha256:4dcbb62368e2800cb3c5abd348da7e53f6c362dda502ec27c560b2e58a66bd33"}, + {file = "colorlog-6.8.2.tar.gz", hash = "sha256:3e3e079a41feb5a1b64f978b5ea4f46040a94f11f0e8bbb8261e3dbbeca64d44"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} + +[package.extras] +development = ["black", "flake8", "mypy", "pytest", "types-colorama"] + +[[package]] +name = "coverage" +version = "7.4.4" +description = "Code coverage measurement for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "coverage-7.4.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0be5efd5127542ef31f165de269f77560d6cdef525fffa446de6f7e9186cfb2"}, + {file = "coverage-7.4.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ccd341521be3d1b3daeb41960ae94a5e87abe2f46f17224ba5d6f2b8398016cf"}, + {file = "coverage-7.4.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:09fa497a8ab37784fbb20ab699c246053ac294d13fc7eb40ec007a5043ec91f8"}, + {file = "coverage-7.4.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b1a93009cb80730c9bca5d6d4665494b725b6e8e157c1cb7f2db5b4b122ea562"}, + {file = "coverage-7.4.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:690db6517f09336559dc0b5f55342df62370a48f5469fabf502db2c6d1cffcd2"}, + {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:09c3255458533cb76ef55da8cc49ffab9e33f083739c8bd4f58e79fecfe288f7"}, + {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:8ce1415194b4a6bd0cdcc3a1dfbf58b63f910dcb7330fe15bdff542c56949f87"}, + {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b91cbc4b195444e7e258ba27ac33769c41b94967919f10037e6355e998af255c"}, + {file = "coverage-7.4.4-cp310-cp310-win32.whl", hash = "sha256:598825b51b81c808cb6f078dcb972f96af96b078faa47af7dfcdf282835baa8d"}, + {file = "coverage-7.4.4-cp310-cp310-win_amd64.whl", hash = "sha256:09ef9199ed6653989ebbcaacc9b62b514bb63ea2f90256e71fea3ed74bd8ff6f"}, + {file = "coverage-7.4.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0f9f50e7ef2a71e2fae92774c99170eb8304e3fdf9c8c3c7ae9bab3e7229c5cf"}, + {file = "coverage-7.4.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:623512f8ba53c422fcfb2ce68362c97945095b864cda94a92edbaf5994201083"}, + {file = "coverage-7.4.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0513b9508b93da4e1716744ef6ebc507aff016ba115ffe8ecff744d1322a7b63"}, + {file = "coverage-7.4.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40209e141059b9370a2657c9b15607815359ab3ef9918f0196b6fccce8d3230f"}, + {file = "coverage-7.4.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8a2b2b78c78293782fd3767d53e6474582f62443d0504b1554370bde86cc8227"}, + {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:73bfb9c09951125d06ee473bed216e2c3742f530fc5acc1383883125de76d9cd"}, + {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:1f384c3cc76aeedce208643697fb3e8437604b512255de6d18dae3f27655a384"}, + {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:54eb8d1bf7cacfbf2a3186019bcf01d11c666bd495ed18717162f7eb1e9dd00b"}, + {file = "coverage-7.4.4-cp311-cp311-win32.whl", hash = "sha256:cac99918c7bba15302a2d81f0312c08054a3359eaa1929c7e4b26ebe41e9b286"}, + {file = "coverage-7.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:b14706df8b2de49869ae03a5ccbc211f4041750cd4a66f698df89d44f4bd30ec"}, + {file = "coverage-7.4.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:201bef2eea65e0e9c56343115ba3814e896afe6d36ffd37bab783261db430f76"}, + {file = "coverage-7.4.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:41c9c5f3de16b903b610d09650e5e27adbfa7f500302718c9ffd1c12cf9d6818"}, + {file = "coverage-7.4.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d898fe162d26929b5960e4e138651f7427048e72c853607f2b200909794ed978"}, + {file = "coverage-7.4.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ea79bb50e805cd6ac058dfa3b5c8f6c040cb87fe83de10845857f5535d1db70"}, + {file = "coverage-7.4.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce4b94265ca988c3f8e479e741693d143026632672e3ff924f25fab50518dd51"}, + {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:00838a35b882694afda09f85e469c96367daa3f3f2b097d846a7216993d37f4c"}, + {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:fdfafb32984684eb03c2d83e1e51f64f0906b11e64482df3c5db936ce3839d48"}, + {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:69eb372f7e2ece89f14751fbcbe470295d73ed41ecd37ca36ed2eb47512a6ab9"}, + {file = "coverage-7.4.4-cp312-cp312-win32.whl", hash = "sha256:137eb07173141545e07403cca94ab625cc1cc6bc4c1e97b6e3846270e7e1fea0"}, + {file = "coverage-7.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:d71eec7d83298f1af3326ce0ff1d0ea83c7cb98f72b577097f9083b20bdaf05e"}, + {file = "coverage-7.4.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d5ae728ff3b5401cc320d792866987e7e7e880e6ebd24433b70a33b643bb0384"}, + {file = "coverage-7.4.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:cc4f1358cb0c78edef3ed237ef2c86056206bb8d9140e73b6b89fbcfcbdd40e1"}, + {file = "coverage-7.4.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8130a2aa2acb8788e0b56938786c33c7c98562697bf9f4c7d6e8e5e3a0501e4a"}, + {file = "coverage-7.4.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cf271892d13e43bc2b51e6908ec9a6a5094a4df1d8af0bfc360088ee6c684409"}, + {file = "coverage-7.4.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a4cdc86d54b5da0df6d3d3a2f0b710949286094c3a6700c21e9015932b81447e"}, + {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ae71e7ddb7a413dd60052e90528f2f65270aad4b509563af6d03d53e979feafd"}, + {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:38dd60d7bf242c4ed5b38e094baf6401faa114fc09e9e6632374388a404f98e7"}, + {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa5b1c1bfc28384f1f53b69a023d789f72b2e0ab1b3787aae16992a7ca21056c"}, + {file = "coverage-7.4.4-cp38-cp38-win32.whl", hash = "sha256:dfa8fe35a0bb90382837b238fff375de15f0dcdb9ae68ff85f7a63649c98527e"}, + {file = "coverage-7.4.4-cp38-cp38-win_amd64.whl", hash = "sha256:b2991665420a803495e0b90a79233c1433d6ed77ef282e8e152a324bbbc5e0c8"}, + {file = "coverage-7.4.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3b799445b9f7ee8bf299cfaed6f5b226c0037b74886a4e11515e569b36fe310d"}, + {file = "coverage-7.4.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b4d33f418f46362995f1e9d4f3a35a1b6322cb959c31d88ae56b0298e1c22357"}, + {file = "coverage-7.4.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aadacf9a2f407a4688d700e4ebab33a7e2e408f2ca04dbf4aef17585389eff3e"}, + {file = "coverage-7.4.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c95949560050d04d46b919301826525597f07b33beba6187d04fa64d47ac82e"}, + {file = "coverage-7.4.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ff7687ca3d7028d8a5f0ebae95a6e4827c5616b31a4ee1192bdfde697db110d4"}, + {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5fc1de20b2d4a061b3df27ab9b7c7111e9a710f10dc2b84d33a4ab25065994ec"}, + {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:c74880fc64d4958159fbd537a091d2a585448a8f8508bf248d72112723974cbd"}, + {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:742a76a12aa45b44d236815d282b03cfb1de3b4323f3e4ec933acfae08e54ade"}, + {file = "coverage-7.4.4-cp39-cp39-win32.whl", hash = "sha256:d89d7b2974cae412400e88f35d86af72208e1ede1a541954af5d944a8ba46c57"}, + {file = "coverage-7.4.4-cp39-cp39-win_amd64.whl", hash = "sha256:9ca28a302acb19b6af89e90f33ee3e1906961f94b54ea37de6737b7ca9d8827c"}, + {file = "coverage-7.4.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:b2c5edc4ac10a7ef6605a966c58929ec6c1bd0917fb8c15cb3363f65aa40e677"}, + {file = "coverage-7.4.4.tar.gz", hash = "sha256:c901df83d097649e257e803be22592aedfd5182f07b3cc87d640bbb9afd50f49"}, +] + +[package.dependencies] +tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} + +[package.extras] +toml = ["tomli"] + +[[package]] +name = "deprecation" +version = "2.1.0" +description = "A library to handle automated deprecations" +optional = false +python-versions = "*" +files = [ + {file = "deprecation-2.1.0-py2.py3-none-any.whl", hash = "sha256:a10811591210e1fb0e768a8c25517cabeabcba6f0bf96564f8ff45189f90b14a"}, + {file = "deprecation-2.1.0.tar.gz", hash = "sha256:72b3bde64e5d778694b0cf68178aed03d15e15477116add3fb773e581f9518ff"}, +] + +[package.dependencies] +packaging = "*" + +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + +[[package]] +name = "docker" +version = "7.0.0" +description = "A Python library for the Docker Engine API." +optional = false +python-versions = ">=3.8" +files = [ + {file = "docker-7.0.0-py3-none-any.whl", hash = "sha256:12ba681f2777a0ad28ffbcc846a69c31b4dfd9752b47eb425a274ee269c5e14b"}, + {file = "docker-7.0.0.tar.gz", hash = "sha256:323736fb92cd9418fc5e7133bc953e11a9da04f4483f828b527db553f1e7e5a3"}, +] + +[package.dependencies] +packaging = ">=14.0" +pywin32 = {version = ">=304", markers = "sys_platform == \"win32\""} +requests = ">=2.26.0" +urllib3 = ">=1.26.0" + +[package.extras] +ssh = ["paramiko (>=2.4.3)"] +websockets = ["websocket-client (>=1.3.0)"] + +[[package]] +name = "exceptiongroup" +version = "1.2.0" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, + {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "filelock" +version = "3.13.1" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.8" +files = [ + {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, + {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] + +[[package]] +name = "greenlet" +version = "3.0.3" +description = "Lightweight in-process concurrent programming" +optional = false +python-versions = ">=3.7" +files = [ + {file = "greenlet-3.0.3-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:9da2bd29ed9e4f15955dd1595ad7bc9320308a3b766ef7f837e23ad4b4aac31a"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d353cadd6083fdb056bb46ed07e4340b0869c305c8ca54ef9da3421acbdf6881"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dca1e2f3ca00b84a396bc1bce13dd21f680f035314d2379c4160c98153b2059b"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3ed7fb269f15dc662787f4119ec300ad0702fa1b19d2135a37c2c4de6fadfd4a"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd4f49ae60e10adbc94b45c0b5e6a179acc1736cf7a90160b404076ee283cf83"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:73a411ef564e0e097dbe7e866bb2dda0f027e072b04da387282b02c308807405"}, + {file = "greenlet-3.0.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7f362975f2d179f9e26928c5b517524e89dd48530a0202570d55ad6ca5d8a56f"}, + {file = "greenlet-3.0.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:649dde7de1a5eceb258f9cb00bdf50e978c9db1b996964cd80703614c86495eb"}, + {file = "greenlet-3.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:68834da854554926fbedd38c76e60c4a2e3198c6fbed520b106a8986445caaf9"}, + {file = "greenlet-3.0.3-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:b1b5667cced97081bf57b8fa1d6bfca67814b0afd38208d52538316e9422fc61"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:52f59dd9c96ad2fc0d5724107444f76eb20aaccb675bf825df6435acb7703559"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:afaff6cf5200befd5cec055b07d1c0a5a06c040fe5ad148abcd11ba6ab9b114e"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fe754d231288e1e64323cfad462fcee8f0288654c10bdf4f603a39ed923bef33"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2797aa5aedac23af156bbb5a6aa2cd3427ada2972c828244eb7d1b9255846379"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b7f009caad047246ed379e1c4dbcb8b020f0a390667ea74d2387be2998f58a22"}, + {file = "greenlet-3.0.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:c5e1536de2aad7bf62e27baf79225d0d64360d4168cf2e6becb91baf1ed074f3"}, + {file = "greenlet-3.0.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:894393ce10ceac937e56ec00bb71c4c2f8209ad516e96033e4b3b1de270e200d"}, + {file = "greenlet-3.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:1ea188d4f49089fc6fb283845ab18a2518d279c7cd9da1065d7a84e991748728"}, + {file = "greenlet-3.0.3-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:70fb482fdf2c707765ab5f0b6655e9cfcf3780d8d87355a063547b41177599be"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4d1ac74f5c0c0524e4a24335350edad7e5f03b9532da7ea4d3c54d527784f2e"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:149e94a2dd82d19838fe4b2259f1b6b9957d5ba1b25640d2380bea9c5df37676"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:15d79dd26056573940fcb8c7413d84118086f2ec1a8acdfa854631084393efcc"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:881b7db1ebff4ba09aaaeae6aa491daeb226c8150fc20e836ad00041bcb11230"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fcd2469d6a2cf298f198f0487e0a5b1a47a42ca0fa4dfd1b6862c999f018ebbf"}, + {file = "greenlet-3.0.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:1f672519db1796ca0d8753f9e78ec02355e862d0998193038c7073045899f305"}, + {file = "greenlet-3.0.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:2516a9957eed41dd8f1ec0c604f1cdc86758b587d964668b5b196a9db5bfcde6"}, + {file = "greenlet-3.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:bba5387a6975598857d86de9eac14210a49d554a77eb8261cc68b7d082f78ce2"}, + {file = "greenlet-3.0.3-cp37-cp37m-macosx_11_0_universal2.whl", hash = "sha256:5b51e85cb5ceda94e79d019ed36b35386e8c37d22f07d6a751cb659b180d5274"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:daf3cb43b7cf2ba96d614252ce1684c1bccee6b2183a01328c98d36fcd7d5cb0"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99bf650dc5d69546e076f413a87481ee1d2d09aaaaaca058c9251b6d8c14783f"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2dd6e660effd852586b6a8478a1d244b8dc90ab5b1321751d2ea15deb49ed414"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3391d1e16e2a5a1507d83e4a8b100f4ee626e8eca43cf2cadb543de69827c4c"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1f145462f1fa6e4a4ae3c0f782e580ce44d57c8f2c7aae1b6fa88c0b2efdb41"}, + {file = "greenlet-3.0.3-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1a7191e42732df52cb5f39d3527217e7ab73cae2cb3694d241e18f53d84ea9a7"}, + {file = "greenlet-3.0.3-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:0448abc479fab28b00cb472d278828b3ccca164531daab4e970a0458786055d6"}, + {file = "greenlet-3.0.3-cp37-cp37m-win32.whl", hash = "sha256:b542be2440edc2d48547b5923c408cbe0fc94afb9f18741faa6ae970dbcb9b6d"}, + {file = "greenlet-3.0.3-cp37-cp37m-win_amd64.whl", hash = "sha256:01bc7ea167cf943b4c802068e178bbf70ae2e8c080467070d01bfa02f337ee67"}, + {file = "greenlet-3.0.3-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:1996cb9306c8595335bb157d133daf5cf9f693ef413e7673cb07e3e5871379ca"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ddc0f794e6ad661e321caa8d2f0a55ce01213c74722587256fb6566049a8b04"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c9db1c18f0eaad2f804728c67d6c610778456e3e1cc4ab4bbd5eeb8e6053c6fc"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7170375bcc99f1a2fbd9c306f5be8764eaf3ac6b5cb968862cad4c7057756506"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b66c9c1e7ccabad3a7d037b2bcb740122a7b17a53734b7d72a344ce39882a1b"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:098d86f528c855ead3479afe84b49242e174ed262456c342d70fc7f972bc13c4"}, + {file = "greenlet-3.0.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:81bb9c6d52e8321f09c3d165b2a78c680506d9af285bfccbad9fb7ad5a5da3e5"}, + {file = "greenlet-3.0.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:fd096eb7ffef17c456cfa587523c5f92321ae02427ff955bebe9e3c63bc9f0da"}, + {file = "greenlet-3.0.3-cp38-cp38-win32.whl", hash = "sha256:d46677c85c5ba00a9cb6f7a00b2bfa6f812192d2c9f7d9c4f6a55b60216712f3"}, + {file = "greenlet-3.0.3-cp38-cp38-win_amd64.whl", hash = "sha256:419b386f84949bf0e7c73e6032e3457b82a787c1ab4a0e43732898a761cc9dbf"}, + {file = "greenlet-3.0.3-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:da70d4d51c8b306bb7a031d5cff6cc25ad253affe89b70352af5f1cb68e74b53"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:086152f8fbc5955df88382e8a75984e2bb1c892ad2e3c80a2508954e52295257"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d73a9fe764d77f87f8ec26a0c85144d6a951a6c438dfe50487df5595c6373eac"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b7dcbe92cc99f08c8dd11f930de4d99ef756c3591a5377d1d9cd7dd5e896da71"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1551a8195c0d4a68fac7a4325efac0d541b48def35feb49d803674ac32582f61"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:64d7675ad83578e3fc149b617a444fab8efdafc9385471f868eb5ff83e446b8b"}, + {file = "greenlet-3.0.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b37eef18ea55f2ffd8f00ff8fe7c8d3818abd3e25fb73fae2ca3b672e333a7a6"}, + {file = "greenlet-3.0.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:77457465d89b8263bca14759d7c1684df840b6811b2499838cc5b040a8b5b113"}, + {file = "greenlet-3.0.3-cp39-cp39-win32.whl", hash = "sha256:57e8974f23e47dac22b83436bdcf23080ade568ce77df33159e019d161ce1d1e"}, + {file = "greenlet-3.0.3-cp39-cp39-win_amd64.whl", hash = "sha256:c5ee858cfe08f34712f548c3c363e807e7186f03ad7a5039ebadb29e8c6be067"}, + {file = "greenlet-3.0.3.tar.gz", hash = "sha256:43374442353259554ce33599da8b692d5aa96f8976d567d4badf263371fbe491"}, +] + +[package.extras] +docs = ["Sphinx", "furo"] +test = ["objgraph", "psutil"] + +[[package]] +name = "identify" +version = "2.5.35" +description = "File identification library for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "identify-2.5.35-py2.py3-none-any.whl", hash = "sha256:c4de0081837b211594f8e877a6b4fad7ca32bbfc1a9307fdd61c28bfe923f13e"}, + {file = "identify-2.5.35.tar.gz", hash = "sha256:10a7ca245cfcd756a554a7288159f72ff105ad233c7c4b9c6f0f4d108f5f6791"}, +] + +[package.extras] +license = ["ukkonen"] + +[[package]] +name = "idna" +version = "3.6" +description = "Internationalized Domain Names in Applications (IDNA)" +optional = false +python-versions = ">=3.5" +files = [ + {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, + {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, +] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "nodeenv" +version = "1.8.0" +description = "Node.js virtual environment builder" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, + {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, +] + +[package.dependencies] +setuptools = "*" + +[[package]] +name = "nox" +version = "2024.3.2" +description = "Flexible test automation." +optional = false +python-versions = ">=3.7" +files = [ + {file = "nox-2024.3.2-py3-none-any.whl", hash = "sha256:e53514173ac0b98dd47585096a55572fe504fecede58ced708979184d05440be"}, + {file = "nox-2024.3.2.tar.gz", hash = "sha256:f521ae08a15adbf5e11f16cb34e8d0e6ea521e0b92868f684e91677deb974553"}, +] + +[package.dependencies] +argcomplete = ">=1.9.4,<4.0" +colorlog = ">=2.6.1,<7.0.0" +packaging = ">=20.9" +virtualenv = ">=20.14.1" + +[package.extras] +tox-to-nox = ["jinja2", "tox"] +uv = ["uv"] + +[[package]] +name = "packaging" +version = "24.0" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, + {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, +] + +[[package]] +name = "platformdirs" +version = "4.2.0" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.8" +files = [ + {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, + {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] + +[[package]] +name = "pluggy" +version = "1.4.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, + {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, +] + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "pre-commit" +version = "3.5.0" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +optional = false +python-versions = ">=3.8" +files = [ + {file = "pre_commit-3.5.0-py2.py3-none-any.whl", hash = "sha256:841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660"}, + {file = "pre_commit-3.5.0.tar.gz", hash = "sha256:5804465c675b659b0862f07907f96295d490822a450c4c40e747d0b1c6ebcb32"}, +] + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + +[[package]] +name = "psycopg2-binary" +version = "2.9.9" +description = "psycopg2 - Python-PostgreSQL Database Adapter" +optional = false +python-versions = ">=3.7" +files = [ + {file = "psycopg2-binary-2.9.9.tar.gz", hash = "sha256:7f01846810177d829c7692f1f5ada8096762d9172af1b1a28d4ab5b77c923c1c"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c2470da5418b76232f02a2fcd2229537bb2d5a7096674ce61859c3229f2eb202"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c6af2a6d4b7ee9615cbb162b0738f6e1fd1f5c3eda7e5da17861eacf4c717ea7"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:75723c3c0fbbf34350b46a3199eb50638ab22a0228f93fb472ef4d9becc2382b"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:83791a65b51ad6ee6cf0845634859d69a038ea9b03d7b26e703f94c7e93dbcf9"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0ef4854e82c09e84cc63084a9e4ccd6d9b154f1dbdd283efb92ecd0b5e2b8c84"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed1184ab8f113e8d660ce49a56390ca181f2981066acc27cf637d5c1e10ce46e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d2997c458c690ec2bc6b0b7ecbafd02b029b7b4283078d3b32a852a7ce3ddd98"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:b58b4710c7f4161b5e9dcbe73bb7c62d65670a87df7bcce9e1faaad43e715245"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:0c009475ee389757e6e34611d75f6e4f05f0cf5ebb76c6037508318e1a1e0d7e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8dbf6d1bc73f1d04ec1734bae3b4fb0ee3cb2a493d35ede9badbeb901fb40f6f"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win32.whl", hash = "sha256:3f78fd71c4f43a13d342be74ebbc0666fe1f555b8837eb113cb7416856c79682"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:876801744b0dee379e4e3c38b76fc89f88834bb15bf92ee07d94acd06ec890a0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ee825e70b1a209475622f7f7b776785bd68f34af6e7a46e2e42f27b659b5bc26"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1ea665f8ce695bcc37a90ee52de7a7980be5161375d42a0b6c6abedbf0d81f0f"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:143072318f793f53819048fdfe30c321890af0c3ec7cb1dfc9cc87aa88241de2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c332c8d69fb64979ebf76613c66b985414927a40f8defa16cf1bc028b7b0a7b0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f7fc5a5acafb7d6ccca13bfa8c90f8c51f13d8fb87d95656d3950f0158d3ce53"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:977646e05232579d2e7b9c59e21dbe5261f403a88417f6a6512e70d3f8a046be"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b6356793b84728d9d50ead16ab43c187673831e9d4019013f1402c41b1db9b27"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bc7bb56d04601d443f24094e9e31ae6deec9ccb23581f75343feebaf30423359"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:77853062a2c45be16fd6b8d6de2a99278ee1d985a7bd8b103e97e41c034006d2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:78151aa3ec21dccd5cdef6c74c3e73386dcdfaf19bced944169697d7ac7482fc"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win32.whl", hash = "sha256:dc4926288b2a3e9fd7b50dc6a1909a13bbdadfc67d93f3374d984e56f885579d"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:b76bedd166805480ab069612119ea636f5ab8f8771e640ae103e05a4aae3e417"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:8532fd6e6e2dc57bcb3bc90b079c60de896d2128c5d9d6f24a63875a95a088cf"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b0605eaed3eb239e87df0d5e3c6489daae3f7388d455d0c0b4df899519c6a38d"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f8544b092a29a6ddd72f3556a9fcf249ec412e10ad28be6a0c0d948924f2212"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2d423c8d8a3c82d08fe8af900ad5b613ce3632a1249fd6a223941d0735fce493"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2e5afae772c00980525f6d6ecf7cbca55676296b580c0e6abb407f15f3706996"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e6f98446430fdf41bd36d4faa6cb409f5140c1c2cf58ce0bbdaf16af7d3f119"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c77e3d1862452565875eb31bdb45ac62502feabbd53429fdc39a1cc341d681ba"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:cb16c65dcb648d0a43a2521f2f0a2300f40639f6f8c1ecbc662141e4e3e1ee07"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:911dda9c487075abd54e644ccdf5e5c16773470a6a5d3826fda76699410066fb"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:57fede879f08d23c85140a360c6a77709113efd1c993923c59fde17aa27599fe"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win32.whl", hash = "sha256:64cf30263844fa208851ebb13b0732ce674d8ec6a0c86a4e160495d299ba3c93"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:81ff62668af011f9a48787564ab7eded4e9fb17a4a6a74af5ffa6a457400d2ab"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2293b001e319ab0d869d660a704942c9e2cce19745262a8aba2115ef41a0a42a"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:03ef7df18daf2c4c07e2695e8cfd5ee7f748a1d54d802330985a78d2a5a6dca9"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a602ea5aff39bb9fac6308e9c9d82b9a35c2bf288e184a816002c9fae930b77"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8359bf4791968c5a78c56103702000105501adb557f3cf772b2c207284273984"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:275ff571376626195ab95a746e6a04c7df8ea34638b99fc11160de91f2fef503"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:f9b5571d33660d5009a8b3c25dc1db560206e2d2f89d3df1cb32d72c0d117d52"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:420f9bbf47a02616e8554e825208cb947969451978dceb77f95ad09c37791dae"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:4154ad09dac630a0f13f37b583eae260c6aa885d67dfbccb5b02c33f31a6d420"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:a148c5d507bb9b4f2030a2025c545fccb0e1ef317393eaba42e7eabd28eb6041"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win32.whl", hash = "sha256:68fc1f1ba168724771e38bee37d940d2865cb0f562380a1fb1ffb428b75cb692"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win_amd64.whl", hash = "sha256:281309265596e388ef483250db3640e5f414168c5a67e9c665cafce9492eda2f"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:60989127da422b74a04345096c10d416c2b41bd7bf2a380eb541059e4e999980"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:246b123cc54bb5361588acc54218c8c9fb73068bf227a4a531d8ed56fa3ca7d6"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:34eccd14566f8fe14b2b95bb13b11572f7c7d5c36da61caf414d23b91fcc5d94"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18d0ef97766055fec15b5de2c06dd8e7654705ce3e5e5eed3b6651a1d2a9a152"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d3f82c171b4ccd83bbaf35aa05e44e690113bd4f3b7b6cc54d2219b132f3ae55"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ead20f7913a9c1e894aebe47cccf9dc834e1618b7aa96155d2091a626e59c972"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ca49a8119c6cbd77375ae303b0cfd8c11f011abbbd64601167ecca18a87e7cdd"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:323ba25b92454adb36fa425dc5cf6f8f19f78948cbad2e7bc6cdf7b0d7982e59"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:1236ed0952fbd919c100bc839eaa4a39ebc397ed1c08a97fc45fee2a595aa1b3"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:729177eaf0aefca0994ce4cffe96ad3c75e377c7b6f4efa59ebf003b6d398716"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win32.whl", hash = "sha256:804d99b24ad523a1fe18cc707bf741670332f7c7412e9d49cb5eab67e886b9b5"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win_amd64.whl", hash = "sha256:a6cdcc3ede532f4a4b96000b6362099591ab4a3e913d70bcbac2b56c872446f7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:72dffbd8b4194858d0941062a9766f8297e8868e1dd07a7b36212aaa90f49472"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:30dcc86377618a4c8f3b72418df92e77be4254d8f89f14b8e8f57d6d43603c0f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:31a34c508c003a4347d389a9e6fcc2307cc2150eb516462a7a17512130de109e"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:15208be1c50b99203fe88d15695f22a5bed95ab3f84354c494bcb1d08557df67"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1873aade94b74715be2246321c8650cabf5a0d098a95bab81145ffffa4c13876"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a58c98a7e9c021f357348867f537017057c2ed7f77337fd914d0bedb35dace7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4686818798f9194d03c9129a4d9a702d9e113a89cb03bffe08c6cf799e053291"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:ebdc36bea43063116f0486869652cb2ed7032dbc59fbcb4445c4862b5c1ecf7f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:ca08decd2697fdea0aea364b370b1249d47336aec935f87b8bbfd7da5b2ee9c1"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ac05fb791acf5e1a3e39402641827780fe44d27e72567a000412c648a85ba860"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win32.whl", hash = "sha256:9dba73be7305b399924709b91682299794887cbbd88e38226ed9f6712eabee90"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win_amd64.whl", hash = "sha256:f7ae5d65ccfbebdfa761585228eb4d0df3a8b15cfb53bd953e713e09fbb12957"}, +] + +[[package]] +name = "pytest" +version = "8.1.1" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest-8.1.1-py3-none-any.whl", hash = "sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7"}, + {file = "pytest-8.1.1.tar.gz", hash = "sha256:ac978141a75948948817d360297b7aae0fcb9d6ff6bc9ec6d514b85d5a65c044"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=1.4,<2.0" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "pytest-cov" +version = "4.1.0" +description = "Pytest plugin for measuring coverage." +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, + {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, +] + +[package.dependencies] +coverage = {version = ">=5.2.1", extras = ["toml"]} +pytest = ">=4.6" + +[package.extras] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] + +[[package]] +name = "pywin32" +version = "306" +description = "Python for Window Extensions" +optional = false +python-versions = "*" +files = [ + {file = "pywin32-306-cp310-cp310-win32.whl", hash = "sha256:06d3420a5155ba65f0b72f2699b5bacf3109f36acbe8923765c22938a69dfc8d"}, + {file = "pywin32-306-cp310-cp310-win_amd64.whl", hash = "sha256:84f4471dbca1887ea3803d8848a1616429ac94a4a8d05f4bc9c5dcfd42ca99c8"}, + {file = "pywin32-306-cp311-cp311-win32.whl", hash = "sha256:e65028133d15b64d2ed8f06dd9fbc268352478d4f9289e69c190ecd6818b6407"}, + {file = "pywin32-306-cp311-cp311-win_amd64.whl", hash = "sha256:a7639f51c184c0272e93f244eb24dafca9b1855707d94c192d4a0b4c01e1100e"}, + {file = "pywin32-306-cp311-cp311-win_arm64.whl", hash = "sha256:70dba0c913d19f942a2db25217d9a1b726c278f483a919f1abfed79c9cf64d3a"}, + {file = "pywin32-306-cp312-cp312-win32.whl", hash = "sha256:383229d515657f4e3ed1343da8be101000562bf514591ff383ae940cad65458b"}, + {file = "pywin32-306-cp312-cp312-win_amd64.whl", hash = "sha256:37257794c1ad39ee9be652da0462dc2e394c8159dfd913a8a4e8eb6fd346da0e"}, + {file = "pywin32-306-cp312-cp312-win_arm64.whl", hash = "sha256:5821ec52f6d321aa59e2db7e0a35b997de60c201943557d108af9d4ae1ec7040"}, + {file = "pywin32-306-cp37-cp37m-win32.whl", hash = "sha256:1c73ea9a0d2283d889001998059f5eaaba3b6238f767c9cf2833b13e6a685f65"}, + {file = "pywin32-306-cp37-cp37m-win_amd64.whl", hash = "sha256:72c5f621542d7bdd4fdb716227be0dd3f8565c11b280be6315b06ace35487d36"}, + {file = "pywin32-306-cp38-cp38-win32.whl", hash = "sha256:e4c092e2589b5cf0d365849e73e02c391c1349958c5ac3e9d5ccb9a28e017b3a"}, + {file = "pywin32-306-cp38-cp38-win_amd64.whl", hash = "sha256:e8ac1ae3601bee6ca9f7cb4b5363bf1c0badb935ef243c4733ff9a393b1690c0"}, + {file = "pywin32-306-cp39-cp39-win32.whl", hash = "sha256:e25fd5b485b55ac9c057f67d94bc203f3f6595078d1fb3b458c9c28b7153a802"}, + {file = "pywin32-306-cp39-cp39-win_amd64.whl", hash = "sha256:39b61c15272833b5c329a2989999dcae836b1eed650252ab1b7bfbe1d59f30f4"}, +] + +[[package]] +name = "pyyaml" +version = "6.0.1" +description = "YAML parser and emitter for Python" +optional = false +python-versions = ">=3.6" +files = [ + {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, + {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, + {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, + {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, + {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, + {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, + {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, + {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, + {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, + {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, + {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, + {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, + {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, + {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, +] + +[[package]] +name = "requests" +version = "2.31.0" +description = "Python HTTP for Humans." +optional = false +python-versions = ">=3.7" +files = [ + {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, + {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, +] + +[package.dependencies] +certifi = ">=2017.4.17" +charset-normalizer = ">=2,<4" +idna = ">=2.5,<4" +urllib3 = ">=1.21.1,<3" + +[package.extras] +socks = ["PySocks (>=1.5.6,!=1.5.7)"] +use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] + +[[package]] +name = "ruff" +version = "0.3.3" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:973a0e388b7bc2e9148c7f9be8b8c6ae7471b9be37e1cc732f8f44a6f6d7720d"}, + {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfa60d23269d6e2031129b053fdb4e5a7b0637fc6c9c0586737b962b2f834493"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1eca7ff7a47043cf6ce5c7f45f603b09121a7cc047447744b029d1b719278eb5"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7d3f6762217c1da954de24b4a1a70515630d29f71e268ec5000afe81377642d"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b24c19e8598916d9c6f5a5437671f55ee93c212a2c4c569605dc3842b6820386"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5a6cbf216b69c7090f0fe4669501a27326c34e119068c1494f35aaf4cc683778"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:352e95ead6964974b234e16ba8a66dad102ec7bf8ac064a23f95371d8b198aab"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d6ab88c81c4040a817aa432484e838aaddf8bfd7ca70e4e615482757acb64f8"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79bca3a03a759cc773fca69e0bdeac8abd1c13c31b798d5bb3c9da4a03144a9f"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2700a804d5336bcffe063fd789ca2c7b02b552d2e323a336700abb8ae9e6a3f8"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:fd66469f1a18fdb9d32e22b79f486223052ddf057dc56dea0caaf1a47bdfaf4e"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:45817af234605525cdf6317005923bf532514e1ea3d9270acf61ca2440691376"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:0da458989ce0159555ef224d5b7c24d3d2e4bf4c300b85467b08c3261c6bc6a8"}, + {file = "ruff-0.3.3-py3-none-win32.whl", hash = "sha256:f2831ec6a580a97f1ea82ea1eda0401c3cdf512cf2045fa3c85e8ef109e87de0"}, + {file = "ruff-0.3.3-py3-none-win_amd64.whl", hash = "sha256:be90bcae57c24d9f9d023b12d627e958eb55f595428bafcb7fec0791ad25ddfc"}, + {file = "ruff-0.3.3-py3-none-win_arm64.whl", hash = "sha256:0171aab5fecdc54383993389710a3d1227f2da124d76a2784a7098e818f92d61"}, + {file = "ruff-0.3.3.tar.gz", hash = "sha256:38671be06f57a2f8aba957d9f701ea889aa5736be806f18c0cd03d6ff0cbca8d"}, +] + +[[package]] +name = "setuptools" +version = "69.2.0" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "setuptools-69.2.0-py3-none-any.whl", hash = "sha256:c21c49fb1042386df081cb5d86759792ab89efca84cf114889191cd09aacc80c"}, + {file = "setuptools-69.2.0.tar.gz", hash = "sha256:0ff4183f8f42cd8fa3acea16c45205521a4ef28f73c6391d8a25e92893134f2e"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + +[[package]] +name = "sqlalchemy" +version = "2.0.28" +description = "Database Abstraction Library" +optional = false +python-versions = ">=3.7" +files = [ + {file = "SQLAlchemy-2.0.28-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0b148ab0438f72ad21cb004ce3bdaafd28465c4276af66df3b9ecd2037bf252"}, + {file = "SQLAlchemy-2.0.28-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:bbda76961eb8f27e6ad3c84d1dc56d5bc61ba8f02bd20fcf3450bd421c2fcc9c"}, + {file = "SQLAlchemy-2.0.28-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:feea693c452d85ea0015ebe3bb9cd15b6f49acc1a31c28b3c50f4db0f8fb1e71"}, + {file = "SQLAlchemy-2.0.28-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5da98815f82dce0cb31fd1e873a0cb30934971d15b74e0d78cf21f9e1b05953f"}, + {file = "SQLAlchemy-2.0.28-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4a5adf383c73f2d49ad15ff363a8748319ff84c371eed59ffd0127355d6ea1da"}, + {file = "SQLAlchemy-2.0.28-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:56856b871146bfead25fbcaed098269d90b744eea5cb32a952df00d542cdd368"}, + {file = "SQLAlchemy-2.0.28-cp310-cp310-win32.whl", hash = "sha256:943aa74a11f5806ab68278284a4ddd282d3fb348a0e96db9b42cb81bf731acdc"}, + {file = "SQLAlchemy-2.0.28-cp310-cp310-win_amd64.whl", hash = "sha256:c6c4da4843e0dabde41b8f2e8147438330924114f541949e6318358a56d1875a"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:46a3d4e7a472bfff2d28db838669fc437964e8af8df8ee1e4548e92710929adc"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:0d3dd67b5d69794cfe82862c002512683b3db038b99002171f624712fa71aeaa"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c61e2e41656a673b777e2f0cbbe545323dbe0d32312f590b1bc09da1de6c2a02"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0315d9125a38026227f559488fe7f7cee1bd2fbc19f9fd637739dc50bb6380b2"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:af8ce2d31679006e7b747d30a89cd3ac1ec304c3d4c20973f0f4ad58e2d1c4c9"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:81ba314a08c7ab701e621b7ad079c0c933c58cdef88593c59b90b996e8b58fa5"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-win32.whl", hash = "sha256:1ee8bd6d68578e517943f5ebff3afbd93fc65f7ef8f23becab9fa8fb315afb1d"}, + {file = "SQLAlchemy-2.0.28-cp311-cp311-win_amd64.whl", hash = "sha256:ad7acbe95bac70e4e687a4dc9ae3f7a2f467aa6597049eeb6d4a662ecd990bb6"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d3499008ddec83127ab286c6f6ec82a34f39c9817f020f75eca96155f9765097"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9b66fcd38659cab5d29e8de5409cdf91e9986817703e1078b2fdaad731ea66f5"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bea30da1e76cb1acc5b72e204a920a3a7678d9d52f688f087dc08e54e2754c67"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:124202b4e0edea7f08a4db8c81cc7859012f90a0d14ba2bf07c099aff6e96462"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:e23b88c69497a6322b5796c0781400692eca1ae5532821b39ce81a48c395aae9"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4b6303bfd78fb3221847723104d152e5972c22367ff66edf09120fcde5ddc2e2"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-win32.whl", hash = "sha256:a921002be69ac3ab2cf0c3017c4e6a3377f800f1fca7f254c13b5f1a2f10022c"}, + {file = "SQLAlchemy-2.0.28-cp312-cp312-win_amd64.whl", hash = "sha256:b4a2cf92995635b64876dc141af0ef089c6eea7e05898d8d8865e71a326c0385"}, + {file = "SQLAlchemy-2.0.28-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e91b5e341f8c7f1e5020db8e5602f3ed045a29f8e27f7f565e0bdee3338f2c7"}, + {file = "SQLAlchemy-2.0.28-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:45c7b78dfc7278329f27be02c44abc0d69fe235495bb8e16ec7ef1b1a17952db"}, + {file = "SQLAlchemy-2.0.28-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3eba73ef2c30695cb7eabcdb33bb3d0b878595737479e152468f3ba97a9c22a4"}, + {file = "SQLAlchemy-2.0.28-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:5df5d1dafb8eee89384fb7a1f79128118bc0ba50ce0db27a40750f6f91aa99d5"}, + {file = "SQLAlchemy-2.0.28-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:2858bbab1681ee5406650202950dc8f00e83b06a198741b7c656e63818633526"}, + {file = "SQLAlchemy-2.0.28-cp37-cp37m-win32.whl", hash = "sha256:9461802f2e965de5cff80c5a13bc945abea7edaa1d29360b485c3d2b56cdb075"}, + {file = "SQLAlchemy-2.0.28-cp37-cp37m-win_amd64.whl", hash = "sha256:a6bec1c010a6d65b3ed88c863d56b9ea5eeefdf62b5e39cafd08c65f5ce5198b"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:843a882cadebecc655a68bd9a5b8aa39b3c52f4a9a5572a3036fb1bb2ccdc197"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:dbb990612c36163c6072723523d2be7c3eb1517bbdd63fe50449f56afafd1133"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd7e4baf9161d076b9a7e432fce06217b9bd90cfb8f1d543d6e8c4595627edb9"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0a5354cb4de9b64bccb6ea33162cb83e03dbefa0d892db88a672f5aad638a75"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:fffcc8edc508801ed2e6a4e7b0d150a62196fd28b4e16ab9f65192e8186102b6"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aca7b6d99a4541b2ebab4494f6c8c2f947e0df4ac859ced575238e1d6ca5716b"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-win32.whl", hash = "sha256:8c7f10720fc34d14abad5b647bc8202202f4948498927d9f1b4df0fb1cf391b7"}, + {file = "SQLAlchemy-2.0.28-cp38-cp38-win_amd64.whl", hash = "sha256:243feb6882b06a2af68ecf4bec8813d99452a1b62ba2be917ce6283852cf701b"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:fc4974d3684f28b61b9a90fcb4c41fb340fd4b6a50c04365704a4da5a9603b05"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:87724e7ed2a936fdda2c05dbd99d395c91ea3c96f029a033a4a20e008dd876bf"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:68722e6a550f5de2e3cfe9da6afb9a7dd15ef7032afa5651b0f0c6b3adb8815d"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:328529f7c7f90adcd65aed06a161851f83f475c2f664a898af574893f55d9e53"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:df40c16a7e8be7413b885c9bf900d402918cc848be08a59b022478804ea076b8"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:426f2fa71331a64f5132369ede5171c52fd1df1bd9727ce621f38b5b24f48750"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-win32.whl", hash = "sha256:33157920b233bc542ce497a81a2e1452e685a11834c5763933b440fedd1d8e2d"}, + {file = "SQLAlchemy-2.0.28-cp39-cp39-win_amd64.whl", hash = "sha256:2f60843068e432311c886c5f03c4664acaef507cf716f6c60d5fde7265be9d7b"}, + {file = "SQLAlchemy-2.0.28-py3-none-any.whl", hash = "sha256:78bb7e8da0183a8301352d569900d9d3594c48ac21dc1c2ec6b3121ed8b6c986"}, + {file = "SQLAlchemy-2.0.28.tar.gz", hash = "sha256:dd53b6c4e6d960600fd6532b79ee28e2da489322fcf6648738134587faf767b6"}, +] + +[package.dependencies] +greenlet = {version = "!=0.4.17", markers = "platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\""} +typing-extensions = ">=4.6.0" + +[package.extras] +aiomysql = ["aiomysql (>=0.2.0)", "greenlet (!=0.4.17)"] +aioodbc = ["aioodbc", "greenlet (!=0.4.17)"] +aiosqlite = ["aiosqlite", "greenlet (!=0.4.17)", "typing_extensions (!=3.10.0.1)"] +asyncio = ["greenlet (!=0.4.17)"] +asyncmy = ["asyncmy (>=0.2.3,!=0.2.4,!=0.2.6)", "greenlet (!=0.4.17)"] +mariadb-connector = ["mariadb (>=1.0.1,!=1.1.2,!=1.1.5)"] +mssql = ["pyodbc"] +mssql-pymssql = ["pymssql"] +mssql-pyodbc = ["pyodbc"] +mypy = ["mypy (>=0.910)"] +mysql = ["mysqlclient (>=1.4.0)"] +mysql-connector = ["mysql-connector-python"] +oracle = ["cx_oracle (>=8)"] +oracle-oracledb = ["oracledb (>=1.0.1)"] +postgresql = ["psycopg2 (>=2.7)"] +postgresql-asyncpg = ["asyncpg", "greenlet (!=0.4.17)"] +postgresql-pg8000 = ["pg8000 (>=1.29.1)"] +postgresql-psycopg = ["psycopg (>=3.0.7)"] +postgresql-psycopg2binary = ["psycopg2-binary"] +postgresql-psycopg2cffi = ["psycopg2cffi"] +postgresql-psycopgbinary = ["psycopg[binary] (>=3.0.7)"] +pymysql = ["pymysql"] +sqlcipher = ["sqlcipher3_binary"] + +[[package]] +name = "testcontainers" +version = "3.7.1" +description = "Library provides lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container" +optional = false +python-versions = ">=3.7" +files = [ + {file = "testcontainers-3.7.1-py2.py3-none-any.whl", hash = "sha256:7f48cef4bf0ccd78f1a4534d4b701a003a3bace851f24eae58a32f9e3f0aeba0"}, +] + +[package.dependencies] +deprecation = "*" +docker = ">=4.0.0" +wrapt = "*" + +[package.extras] +arangodb = ["python-arango"] +azurite = ["azure-storage-blob"] +clickhouse = ["clickhouse-driver"] +docker-compose = ["docker-compose"] +google-cloud-pubsub = ["google-cloud-pubsub (<2)"] +kafka = ["kafka-python"] +keycloak = ["python-keycloak"] +mongo = ["pymongo"] +mssqlserver = ["pymssql"] +mysql = ["pymysql", "sqlalchemy"] +neo4j = ["neo4j"] +oracle = ["cx-Oracle", "sqlalchemy"] +postgresql = ["psycopg2-binary", "sqlalchemy"] +rabbitmq = ["pika"] +redis = ["redis"] +selenium = ["selenium"] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + +[[package]] +name = "typing-extensions" +version = "4.10.0" +description = "Backported and Experimental Type Hints for Python 3.8+" +optional = false +python-versions = ">=3.8" +files = [ + {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, + {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, +] + +[[package]] +name = "urllib3" +version = "2.2.1" +description = "HTTP library with thread-safe connection pooling, file post, and more." +optional = false +python-versions = ">=3.8" +files = [ + {file = "urllib3-2.2.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, + {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, +] + +[package.extras] +brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +h2 = ["h2 (>=4,<5)"] +socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] +zstd = ["zstandard (>=0.18.0)"] + +[[package]] +name = "virtualenv" +version = "20.25.1" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, + {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<5" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + +[[package]] +name = "wrapt" +version = "1.16.0" +description = "Module for decorators, wrappers and monkey patching." +optional = false +python-versions = ">=3.6" +files = [ + {file = "wrapt-1.16.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ffa565331890b90056c01db69c0fe634a776f8019c143a5ae265f9c6bc4bd6d4"}, + {file = "wrapt-1.16.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e4fdb9275308292e880dcbeb12546df7f3e0f96c6b41197e0cf37d2826359020"}, + {file = "wrapt-1.16.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb2dee3874a500de01c93d5c71415fcaef1d858370d405824783e7a8ef5db440"}, + {file = "wrapt-1.16.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2a88e6010048489cda82b1326889ec075a8c856c2e6a256072b28eaee3ccf487"}, + {file = "wrapt-1.16.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ac83a914ebaf589b69f7d0a1277602ff494e21f4c2f743313414378f8f50a4cf"}, + {file = "wrapt-1.16.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:73aa7d98215d39b8455f103de64391cb79dfcad601701a3aa0dddacf74911d72"}, + {file = "wrapt-1.16.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:807cc8543a477ab7422f1120a217054f958a66ef7314f76dd9e77d3f02cdccd0"}, + {file = "wrapt-1.16.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bf5703fdeb350e36885f2875d853ce13172ae281c56e509f4e6eca049bdfb136"}, + {file = "wrapt-1.16.0-cp310-cp310-win32.whl", hash = "sha256:f6b2d0c6703c988d334f297aa5df18c45e97b0af3679bb75059e0e0bd8b1069d"}, + {file = "wrapt-1.16.0-cp310-cp310-win_amd64.whl", hash = "sha256:decbfa2f618fa8ed81c95ee18a387ff973143c656ef800c9f24fb7e9c16054e2"}, + {file = "wrapt-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1a5db485fe2de4403f13fafdc231b0dbae5eca4359232d2efc79025527375b09"}, + {file = "wrapt-1.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:75ea7d0ee2a15733684badb16de6794894ed9c55aa5e9903260922f0482e687d"}, + {file = "wrapt-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a452f9ca3e3267cd4d0fcf2edd0d035b1934ac2bd7e0e57ac91ad6b95c0c6389"}, + {file = "wrapt-1.16.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:43aa59eadec7890d9958748db829df269f0368521ba6dc68cc172d5d03ed8060"}, + {file = "wrapt-1.16.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72554a23c78a8e7aa02abbd699d129eead8b147a23c56e08d08dfc29cfdddca1"}, + {file = "wrapt-1.16.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:d2efee35b4b0a347e0d99d28e884dfd82797852d62fcd7ebdeee26f3ceb72cf3"}, + {file = "wrapt-1.16.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:6dcfcffe73710be01d90cae08c3e548d90932d37b39ef83969ae135d36ef3956"}, + {file = "wrapt-1.16.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:eb6e651000a19c96f452c85132811d25e9264d836951022d6e81df2fff38337d"}, + {file = "wrapt-1.16.0-cp311-cp311-win32.whl", hash = "sha256:66027d667efe95cc4fa945af59f92c5a02c6f5bb6012bff9e60542c74c75c362"}, + {file = "wrapt-1.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:aefbc4cb0a54f91af643660a0a150ce2c090d3652cf4052a5397fb2de549cd89"}, + {file = "wrapt-1.16.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:5eb404d89131ec9b4f748fa5cfb5346802e5ee8836f57d516576e61f304f3b7b"}, + {file = "wrapt-1.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9090c9e676d5236a6948330e83cb89969f433b1943a558968f659ead07cb3b36"}, + {file = "wrapt-1.16.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94265b00870aa407bd0cbcfd536f17ecde43b94fb8d228560a1e9d3041462d73"}, + {file = "wrapt-1.16.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f2058f813d4f2b5e3a9eb2eb3faf8f1d99b81c3e51aeda4b168406443e8ba809"}, + {file = "wrapt-1.16.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:98b5e1f498a8ca1858a1cdbffb023bfd954da4e3fa2c0cb5853d40014557248b"}, + {file = "wrapt-1.16.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:14d7dc606219cdd7405133c713f2c218d4252f2a469003f8c46bb92d5d095d81"}, + {file = "wrapt-1.16.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:49aac49dc4782cb04f58986e81ea0b4768e4ff197b57324dcbd7699c5dfb40b9"}, + {file = "wrapt-1.16.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:418abb18146475c310d7a6dc71143d6f7adec5b004ac9ce08dc7a34e2babdc5c"}, + {file = "wrapt-1.16.0-cp312-cp312-win32.whl", hash = "sha256:685f568fa5e627e93f3b52fda002c7ed2fa1800b50ce51f6ed1d572d8ab3e7fc"}, + {file = "wrapt-1.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:dcdba5c86e368442528f7060039eda390cc4091bfd1dca41e8046af7c910dda8"}, + {file = "wrapt-1.16.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:d462f28826f4657968ae51d2181a074dfe03c200d6131690b7d65d55b0f360f8"}, + {file = "wrapt-1.16.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a33a747400b94b6d6b8a165e4480264a64a78c8a4c734b62136062e9a248dd39"}, + {file = "wrapt-1.16.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3646eefa23daeba62643a58aac816945cadc0afaf21800a1421eeba5f6cfb9c"}, + {file = "wrapt-1.16.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ebf019be5c09d400cf7b024aa52b1f3aeebeff51550d007e92c3c1c4afc2a40"}, + {file = "wrapt-1.16.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:0d2691979e93d06a95a26257adb7bfd0c93818e89b1406f5a28f36e0d8c1e1fc"}, + {file = "wrapt-1.16.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:1acd723ee2a8826f3d53910255643e33673e1d11db84ce5880675954183ec47e"}, + {file = "wrapt-1.16.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:bc57efac2da352a51cc4658878a68d2b1b67dbe9d33c36cb826ca449d80a8465"}, + {file = "wrapt-1.16.0-cp36-cp36m-win32.whl", hash = "sha256:da4813f751142436b075ed7aa012a8778aa43a99f7b36afe9b742d3ed8bdc95e"}, + {file = "wrapt-1.16.0-cp36-cp36m-win_amd64.whl", hash = "sha256:6f6eac2360f2d543cc875a0e5efd413b6cbd483cb3ad7ebf888884a6e0d2e966"}, + {file = "wrapt-1.16.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a0ea261ce52b5952bf669684a251a66df239ec6d441ccb59ec7afa882265d593"}, + {file = "wrapt-1.16.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7bd2d7ff69a2cac767fbf7a2b206add2e9a210e57947dd7ce03e25d03d2de292"}, + {file = "wrapt-1.16.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9159485323798c8dc530a224bd3ffcf76659319ccc7bbd52e01e73bd0241a0c5"}, + {file = "wrapt-1.16.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a86373cf37cd7764f2201b76496aba58a52e76dedfaa698ef9e9688bfd9e41cf"}, + {file = "wrapt-1.16.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:73870c364c11f03ed072dda68ff7aea6d2a3a5c3fe250d917a429c7432e15228"}, + {file = "wrapt-1.16.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:b935ae30c6e7400022b50f8d359c03ed233d45b725cfdd299462f41ee5ffba6f"}, + {file = "wrapt-1.16.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:db98ad84a55eb09b3c32a96c576476777e87c520a34e2519d3e59c44710c002c"}, + {file = "wrapt-1.16.0-cp37-cp37m-win32.whl", hash = "sha256:9153ed35fc5e4fa3b2fe97bddaa7cbec0ed22412b85bcdaf54aeba92ea37428c"}, + {file = "wrapt-1.16.0-cp37-cp37m-win_amd64.whl", hash = "sha256:66dfbaa7cfa3eb707bbfcd46dab2bc6207b005cbc9caa2199bcbc81d95071a00"}, + {file = "wrapt-1.16.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1dd50a2696ff89f57bd8847647a1c363b687d3d796dc30d4dd4a9d1689a706f0"}, + {file = "wrapt-1.16.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:44a2754372e32ab315734c6c73b24351d06e77ffff6ae27d2ecf14cf3d229202"}, + {file = "wrapt-1.16.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e9723528b9f787dc59168369e42ae1c3b0d3fadb2f1a71de14531d321ee05b0"}, + {file = "wrapt-1.16.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dbed418ba5c3dce92619656802cc5355cb679e58d0d89b50f116e4a9d5a9603e"}, + {file = "wrapt-1.16.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:941988b89b4fd6b41c3f0bfb20e92bd23746579736b7343283297c4c8cbae68f"}, + {file = "wrapt-1.16.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:6a42cd0cfa8ffc1915aef79cb4284f6383d8a3e9dcca70c445dcfdd639d51267"}, + {file = "wrapt-1.16.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:1ca9b6085e4f866bd584fb135a041bfc32cab916e69f714a7d1d397f8c4891ca"}, + {file = "wrapt-1.16.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d5e49454f19ef621089e204f862388d29e6e8d8b162efce05208913dde5b9ad6"}, + {file = "wrapt-1.16.0-cp38-cp38-win32.whl", hash = "sha256:c31f72b1b6624c9d863fc095da460802f43a7c6868c5dda140f51da24fd47d7b"}, + {file = "wrapt-1.16.0-cp38-cp38-win_amd64.whl", hash = "sha256:490b0ee15c1a55be9c1bd8609b8cecd60e325f0575fc98f50058eae366e01f41"}, + {file = "wrapt-1.16.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9b201ae332c3637a42f02d1045e1d0cccfdc41f1f2f801dafbaa7e9b4797bfc2"}, + {file = "wrapt-1.16.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:2076fad65c6736184e77d7d4729b63a6d1ae0b70da4868adeec40989858eb3fb"}, + {file = "wrapt-1.16.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c5cd603b575ebceca7da5a3a251e69561bec509e0b46e4993e1cac402b7247b8"}, + {file = "wrapt-1.16.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b47cfad9e9bbbed2339081f4e346c93ecd7ab504299403320bf85f7f85c7d46c"}, + {file = "wrapt-1.16.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f8212564d49c50eb4565e502814f694e240c55551a5f1bc841d4fcaabb0a9b8a"}, + {file = "wrapt-1.16.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5f15814a33e42b04e3de432e573aa557f9f0f56458745c2074952f564c50e664"}, + {file = "wrapt-1.16.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:db2e408d983b0e61e238cf579c09ef7020560441906ca990fe8412153e3b291f"}, + {file = "wrapt-1.16.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:edfad1d29c73f9b863ebe7082ae9321374ccb10879eeabc84ba3b69f2579d537"}, + {file = "wrapt-1.16.0-cp39-cp39-win32.whl", hash = "sha256:ed867c42c268f876097248e05b6117a65bcd1e63b779e916fe2e33cd6fd0d3c3"}, + {file = "wrapt-1.16.0-cp39-cp39-win_amd64.whl", hash = "sha256:eb1b046be06b0fce7249f1d025cd359b4b80fc1c3e24ad9eca33e0dcdb2e4a35"}, + {file = "wrapt-1.16.0-py3-none-any.whl", hash = "sha256:6906c4100a8fcbf2fa735f6059214bb13b97f75b1a61777fcf6432121ef12ef1"}, + {file = "wrapt-1.16.0.tar.gz", hash = "sha256:5f370f952971e7d17c7d1ead40e49f32345a7f7a5373571ef44d800d06b1899d"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.8" +content-hash = "0fd319dc714d5c0dc52352fcd9bb6a94ddd5b5e05da3c0a68aba71cea10f8481" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b720675 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,35 @@ +[tool.poetry] +name = "omop-cdm" +version = "0.1.0" +description = "SQLAlchemy ORM of the OHDSI OMOP CDM" +authors = [ + "Spayralbe ", +] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.8" +sqlalchemy = "^2.0.0" + + +[tool.poetry.group.dev.dependencies] +nox = "^2024.3.2" +ruff = "^0.3.2" +pre-commit = "^3.5.0" + +[tool.poetry.group.test.dependencies] +pytest = "^8.1.1" +pytest-cov = "^4.1.0" +testcontainers = {version = ">=3.7.1", extras = ["postgres"]} +psycopg2-binary = "^2.9.9" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + + +[tool.pytest.ini_options] +addopts = "--import-mode=importlib" +pythonpath = [ + ".", +] diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..046ca58 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,24 @@ +src = ["src", "."] + +[lint] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", +] + +[lint.isort] +known-first-party = ["omop_cdm"] + +# Ignore import violations in all `__init__.py` files +[lint.per-file-ignores] +"__init__.py" = ["E402", "F401"] diff --git a/src/omop_cdm/__init__.py b/src/omop_cdm/__init__.py new file mode 100644 index 0000000..e1ec222 --- /dev/null +++ b/src/omop_cdm/__init__.py @@ -0,0 +1 @@ +from omop_cdm.constants import NAMING_CONVENTION diff --git a/src/omop_cdm/constants.py b/src/omop_cdm/constants.py new file mode 100644 index 0000000..b856f3e --- /dev/null +++ b/src/omop_cdm/constants.py @@ -0,0 +1,33 @@ +"""Module containing the placeholder schema names as used in the ORM.""" + +# These are the placeholder schema names as used in the ORM table +# definitions. They will be replaced with actual schema names at runtime +# by providing a schema_translate_map to your SQLAlchemy engine. +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", +} diff --git a/src/omop_cdm/dynamic/cdm531/__init__.py b/src/omop_cdm/dynamic/cdm531/__init__.py new file mode 100644 index 0000000..82fc8b9 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm531/__init__.py @@ -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 + +""" diff --git a/src/omop_cdm/dynamic/cdm531/clinical_data.py b/src/omop_cdm/dynamic/cdm531/clinical_data.py new file mode 100644 index 0000000..87b684e --- /dev/null +++ b/src/omop_cdm/dynamic/cdm531/clinical_data.py @@ -0,0 +1,902 @@ +"""OMOP CDM 5.3.1 clinical tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import Date, DateTime, ForeignKey, Integer, Numeric, String, Text +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CARE_SITE_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_LOCATION_ID, + FK_PERSON_ID, + FK_PROVIDER_ID, + FK_VISIT_DETAIL_ID, + FK_VISIT_OCCURRENCE_ID, +) + + +class BaseConditionOccurrenceCdm531: + __tablename__ = "condition_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + condition_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + condition_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + condition_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + condition_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + condition_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + condition_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + condition_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + @declared_attr + def condition_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_concept_id") + + @declared_attr + def condition_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_source_concept_id") + + @declared_attr + def condition_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_status_concept_id") + + @declared_attr + def condition_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ConditionOccurrence.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="ConditionOccurrence.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="ConditionOccurrence.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="ConditionOccurrence.visit_occurrence_id") + + +class BaseDeathCdm531: + __tablename__ = "death" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), primary_key=True, index=True, sort_order=100) + death_date: Mapped[datetime.date] = mapped_column(Date, sort_order=200) + death_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=300) + death_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + cause_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + cause_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + cause_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + + @declared_attr + def cause_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Death.cause_concept_id") + + @declared_attr + def cause_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Death.cause_source_concept_id") + + @declared_attr + def death_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Death.death_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Death.person_id") + + +class BaseDeviceExposureCdm531: + __tablename__ = "device_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + device_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + device_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + device_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + device_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + device_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + device_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + device_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + device_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + device_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + + @declared_attr + def device_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_concept_id") + + @declared_attr + def device_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_source_concept_id") + + @declared_attr + def device_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DeviceExposure.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="DeviceExposure.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="DeviceExposure.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="DeviceExposure.visit_occurrence_id") + + +class BaseDrugExposureCdm531: + __tablename__ = "drug_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + drug_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + drug_exposure_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + drug_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + drug_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1300) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=1400) + route_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1700) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1800 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1900) + drug_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drug_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2300) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_concept_id") + + @declared_attr + def drug_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_source_concept_id") + + @declared_attr + def drug_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DrugExposure.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="DrugExposure.provider_id") + + @declared_attr + def route_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.route_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="DrugExposure.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="DrugExposure.visit_occurrence_id") + + +class BaseFactRelationshipCdm531: + __tablename__ = "fact_relationship" + __table_args__ = {"schema": CDM_SCHEMA} + + domain_concept_id_1: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + fact_id_1: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + domain_concept_id_2: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=300 + ) + fact_id_2: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=400) + relationship_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + + @declared_attr + def domain_concept_1(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_1") + + @declared_attr + def domain_concept_2(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_2") + + @declared_attr + def relationship_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.relationship_concept_id") + + +class BaseMeasurementCdm531: + __tablename__ = "measurement" + __table_args__ = {"schema": CDM_SCHEMA} + + measurement_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + measurement_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + measurement_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + measurement_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + measurement_time: Mapped[Optional[str]] = mapped_column(String(10), sort_order=600) + measurement_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1400) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1500 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1600) + measurement_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + measurement_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + + @declared_attr + def measurement_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_concept_id") + + @declared_attr + def measurement_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_source_concept_id") + + @declared_attr + def measurement_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_type_concept_id") + + @declared_attr + def operator_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.operator_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Measurement.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Measurement.provider_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.unit_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Measurement.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Measurement.visit_occurrence_id") + + +class BaseNoteCdm531: + __tablename__ = "note" + __table_args__ = {"schema": CDM_SCHEMA} + + note_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + note_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + note_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=400) + note_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=500) + note_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + note_title: Mapped[Optional[str]] = mapped_column(String(250), sort_order=700) + note_text: Mapped[str] = mapped_column(Text, sort_order=800) + encoding_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + note_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + + @declared_attr + def encoding_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.encoding_concept_id") + + @declared_attr + def language_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.language_concept_id") + + @declared_attr + def note_class_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.note_class_concept_id") + + @declared_attr + def note_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.note_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Note.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Note.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Note.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Note.visit_occurrence_id") + + +class BaseNoteNlpCdm531: + __tablename__ = "note_nlp" + __table_args__ = {"schema": CDM_SCHEMA} + + note_nlp_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + note_id: Mapped[int] = mapped_column(ForeignKey(f"{CDM_SCHEMA}.note.note_id"), index=True, sort_order=200) + section_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + snippet: Mapped[Optional[str]] = mapped_column(String(250), sort_order=400) + offset: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + lexical_variant: Mapped[str] = mapped_column(String(250), sort_order=600) + note_nlp_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + note_nlp_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + nlp_system: Mapped[Optional[str]] = mapped_column(String(250), sort_order=900) + nlp_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + nlp_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1100) + term_exists: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + term_temporal: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + term_modifiers: Mapped[Optional[str]] = mapped_column(String(2000), sort_order=1400) + + @declared_attr + def note(cls) -> Mapped["Note"]: + return relationship("Note", foreign_keys="NoteNlp.note_id") + + @declared_attr + def note_nlp_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.note_nlp_concept_id") + + @declared_attr + def note_nlp_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.note_nlp_source_concept_id") + + @declared_attr + def section_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.section_concept_id") + + +class BaseObservationCdm531: + __tablename__ = "observation" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + observation_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + observation_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + observation_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=800) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1300 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1400) + observation_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + observation_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + + @declared_attr + def observation_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_concept_id") + + @declared_attr + def observation_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_source_concept_id") + + @declared_attr + def observation_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Observation.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Observation.provider_id") + + @declared_attr + def qualifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.qualifier_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.unit_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Observation.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Observation.visit_occurrence_id") + + +class BaseObservationPeriodCdm531: + __tablename__ = "observation_period" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_period_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + observation_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + period_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + @declared_attr + def period_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ObservationPeriod.period_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ObservationPeriod.person_id") + + +class BasePersonCdm531: + __tablename__ = "person" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=200) + year_of_birth: Mapped[int] = mapped_column(Integer, sort_order=300) + month_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=400) + day_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + birth_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + race_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + ethnicity_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=900) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1000) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1100) + person_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + race_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + race_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + ethnicity_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + ethnicity_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="Person.care_site_id") + + @declared_attr + def ethnicity_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.ethnicity_concept_id") + + @declared_attr + def ethnicity_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.ethnicity_source_concept_id") + + @declared_attr + def gender_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.gender_concept_id") + + @declared_attr + def gender_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.gender_source_concept_id") + + @declared_attr + def location(cls) -> Mapped["Location"]: + return relationship("Location", foreign_keys="Person.location_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Person.provider_id") + + @declared_attr + def race_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.race_concept_id") + + @declared_attr + def race_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.race_source_concept_id") + + +class BaseProcedureOccurrenceCdm531: + __tablename__ = "procedure_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + procedure_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + procedure_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + procedure_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + procedure_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + procedure_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + modifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1000 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1100) + procedure_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + procedure_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + + @declared_attr + def modifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.modifier_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ProcedureOccurrence.person_id") + + @declared_attr + def procedure_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_concept_id") + + @declared_attr + def procedure_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_source_concept_id") + + @declared_attr + def procedure_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_type_concept_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="ProcedureOccurrence.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="ProcedureOccurrence.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="ProcedureOccurrence.visit_occurrence_id") + + +class BaseSpecimenCdm531: + __tablename__ = "specimen" + __table_args__ = {"schema": CDM_SCHEMA} + + specimen_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + specimen_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + specimen_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + specimen_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + specimen_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + anatomic_site_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + disease_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + specimen_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + + @declared_attr + def anatomic_site_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.anatomic_site_concept_id") + + @declared_attr + def disease_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.disease_status_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Specimen.person_id") + + @declared_attr + def specimen_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.specimen_concept_id") + + @declared_attr + def specimen_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.specimen_type_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.unit_concept_id") + + +class BaseVisitDetailCdm531: + __tablename__ = "visit_detail" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_detail_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_detail_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_detail_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_detail_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_detail_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_detail_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_detail_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_detail_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_detail_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitting_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + admitting_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + discharge_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + preceding_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1700) + visit_detail_parent_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1800) + visit_occurrence_id: Mapped[int] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1900) + + @declared_attr + def admitting_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.admitting_source_concept_id") + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="VisitDetail.care_site_id") + + @declared_attr + def discharge_to_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.discharge_to_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="VisitDetail.person_id") + + @declared_attr + def preceding_visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="VisitDetail.preceding_visit_detail_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="VisitDetail.provider_id") + + @declared_attr + def visit_detail_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_concept_id") + + @declared_attr + def visit_detail_parent(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="VisitDetail.visit_detail_parent_id") + + @declared_attr + def visit_detail_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_source_concept_id") + + @declared_attr + def visit_detail_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_type_concept_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="VisitDetail.visit_occurrence_id") + + +class BaseVisitOccurrenceCdm531: + __tablename__ = "visit_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitting_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitting_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharge_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + preceding_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1700 + ) + + @declared_attr + def admitting_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.admitting_source_concept_id") + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="VisitOccurrence.care_site_id") + + @declared_attr + def discharge_to_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.discharge_to_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="VisitOccurrence.person_id") + + @declared_attr + def preceding_visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="VisitOccurrence.preceding_visit_occurrence_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="VisitOccurrence.provider_id") + + @declared_attr + def visit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_concept_id") + + @declared_attr + def visit_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_source_concept_id") + + @declared_attr + def visit_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_type_concept_id") + + +class BaseStemTableCdm531: + __tablename__ = "stem_table" + __table_args__ = {"schema": CDM_SCHEMA} + + id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + domain_id: Mapped[Optional[str]] = mapped_column(ForeignKey(FK_DOMAIN_ID), sort_order=200) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=300) + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=400) + start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=500) + start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=800) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=900) + type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=1400) + value_as_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1500) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1700) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1900) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=2000 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=2100) + source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2300) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2400) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2500) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=2600) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=2700) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=2800) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=2900) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=3000) + route_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3100) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3200) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3300) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3400) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3500) + condition_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3600) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3700) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3800) + modifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3900) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4000) + anatomic_site_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4100) + disease_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4200) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4500) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4600) + + @declared_attr + def anatomic_site_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.anatomic_site_concept_id") + + @declared_attr + def concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.concept_id") + + @declared_attr + def condition_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.condition_status_concept_id") + + @declared_attr + def disease_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.disease_status_concept_id") + + @declared_attr + def domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="StemTable.domain_id") + + @declared_attr + def modifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.modifier_concept_id") + + @declared_attr + def operator_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.operator_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="StemTable.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="StemTable.provider_id") + + @declared_attr + def qualifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.qualifier_concept_id") + + @declared_attr + def route_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.route_concept_id") + + @declared_attr + def source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.source_concept_id") + + @declared_attr + def type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.type_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.unit_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="StemTable.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="StemTable.visit_occurrence_id") diff --git a/src/omop_cdm/dynamic/cdm531/derived_elements.py b/src/omop_cdm/dynamic/cdm531/derived_elements.py new file mode 100644 index 0000000..66666a9 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm531/derived_elements.py @@ -0,0 +1,76 @@ +"""OMOP CDM 5.3.1 derived elements tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import DateTime, ForeignKey, Integer, Numeric +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID, FK_PERSON_ID + + +class BaseConditionEraCdm531: + __tablename__ = "condition_era" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + condition_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_occurrence_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + + @declared_attr + def condition_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionEra.condition_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ConditionEra.person_id") + + +class BaseDoseEraCdm531: + __tablename__ = "dose_era" + __table_args__ = {"schema": CDM_SCHEMA} + + dose_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + unit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + dose_value: Mapped[decimal.Decimal] = mapped_column(Numeric, sort_order=500) + dose_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + dose_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DoseEra.drug_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DoseEra.person_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DoseEra.unit_concept_id") + + +class BaseDrugEraCdm531: + __tablename__ = "drug_era" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + drug_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + gap_days: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugEra.drug_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DrugEra.person_id") diff --git a/src/omop_cdm/dynamic/cdm531/health_economics.py b/src/omop_cdm/dynamic/cdm531/health_economics.py new file mode 100644 index 0000000..b09f176 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm531/health_economics.py @@ -0,0 +1,123 @@ +"""OMOP CDM 5.3.1 health economics tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import Date, ForeignKey, Integer, Numeric, String +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID, FK_DOMAIN_ID, FK_PERSON_ID + + +class BasePayerPlanPeriodCdm531: + __tablename__ = "payer_plan_period" + __table_args__ = {"schema": CDM_SCHEMA} + + payer_plan_period_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + payer_plan_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + payer_plan_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + payer_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + payer_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + payer_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + plan_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + plan_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + plan_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + sponsor_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + sponsor_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + sponsor_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + family_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + stop_reason_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + stop_reason_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + stop_reason_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + + @declared_attr + def payer_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.payer_concept_id") + + @declared_attr + def payer_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.payer_source_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="PayerPlanPeriod.person_id") + + @declared_attr + def plan_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.plan_concept_id") + + @declared_attr + def plan_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.plan_source_concept_id") + + @declared_attr + def sponsor_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_concept_id") + + @declared_attr + def sponsor_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_source_concept_id") + + @declared_attr + def stop_reason_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.stop_reason_concept_id") + + @declared_attr + def stop_reason_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.stop_reason_source_concept_id") + + +class BaseCostCdm531: + __tablename__ = "cost" + __table_args__ = {"schema": CDM_SCHEMA} + + cost_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + cost_event_id: Mapped[int] = mapped_column(Integer, sort_order=200) + cost_domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), sort_order=300) + cost_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + currency_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + total_charge: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=600) + total_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + total_paid: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=800) + paid_by_payer: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + paid_by_patient: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1000) + paid_patient_copay: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + paid_patient_coinsurance: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + paid_patient_deductible: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + paid_by_primary: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1400) + paid_ingredient_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1500) + paid_dispensing_fee: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1600) + payer_plan_period_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(f"{CDM_SCHEMA}.payer_plan_period.payer_plan_period_id"), sort_order=1700 + ) + amount_allowed: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1800) + revenue_code_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + revenue_code_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drg_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + drg_source_value: Mapped[Optional[str]] = mapped_column(String(3), sort_order=2200) + + @declared_attr + def cost_domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="Cost.cost_domain_id") + + @declared_attr + def cost_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.cost_type_concept_id") + + @declared_attr + def currency_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.currency_concept_id") + + @declared_attr + def drg_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.drg_concept_id") + + @declared_attr + def payer_plan_period(cls) -> Mapped["PayerPlanPeriod"]: + return relationship("PayerPlanPeriod", foreign_keys="Cost.payer_plan_period_id") + + @declared_attr + def revenue_code_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.revenue_code_concept_id") diff --git a/src/omop_cdm/dynamic/cdm531/health_system_data.py b/src/omop_cdm/dynamic/cdm531/health_system_data.py new file mode 100644 index 0000000..d86b084 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm531/health_system_data.py @@ -0,0 +1,81 @@ +"""OMOP CDM 5.3.1 health system data tables.""" + +from typing import Optional + +from sqlalchemy import ForeignKey, Integer, String +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CARE_SITE_ID, FK_CONCEPT_ID, FK_LOCATION_ID + + +class BaseCareSiteCdm531: + __tablename__ = "care_site" + __table_args__ = {"schema": CDM_SCHEMA} + + care_site_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + care_site_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + place_of_service_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=400) + care_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + place_of_service_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + + @declared_attr + def location(cls) -> Mapped["Location"]: + return relationship("Location") + + @declared_attr + def place_of_service_concept(cls) -> Mapped["Concept"]: + return relationship("Concept") + + +class BaseLocationCdm531: + __tablename__ = "location" + __table_args__ = {"schema": CDM_SCHEMA} + + location_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + address_1: Mapped[Optional[str]] = mapped_column(String(50), sort_order=200) + address_2: Mapped[Optional[str]] = mapped_column(String(50), sort_order=300) + city: Mapped[Optional[str]] = mapped_column(String(50), sort_order=400) + state: Mapped[Optional[str]] = mapped_column(String(2), sort_order=500) + zip: Mapped[Optional[str]] = mapped_column(String(9), sort_order=600) + county: Mapped[Optional[str]] = mapped_column(String(20), sort_order=700) + location_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=800) + + +class BaseProviderCdm531: + __tablename__ = "provider" + __table_args__ = {"schema": CDM_SCHEMA} + + provider_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + provider_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + npi: Mapped[Optional[str]] = mapped_column(String(20), sort_order=300) + dea: Mapped[Optional[str]] = mapped_column(String(20), sort_order=400) + specialty_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=600) + year_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + gender_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + specialty_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1000) + specialty_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="Provider.care_site_id") + + @declared_attr + def gender_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.gender_concept_id") + + @declared_attr + def gender_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.gender_source_concept_id") + + @declared_attr + def specialty_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.specialty_concept_id") + + @declared_attr + def specialty_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.specialty_source_concept_id") diff --git a/src/omop_cdm/dynamic/cdm531/metadata.py b/src/omop_cdm/dynamic/cdm531/metadata.py new file mode 100644 index 0000000..ec2587e --- /dev/null +++ b/src/omop_cdm/dynamic/cdm531/metadata.py @@ -0,0 +1,38 @@ +"""OMOP CDM metadata tables.""" + +import datetime +from typing import Optional + +from sqlalchemy import Date, DateTime, Integer, String, Text +from sqlalchemy.orm import Mapped, mapped_column + +from omop_cdm.constants import CDM_SCHEMA + + +class BaseCdmSourceCdm531: + __tablename__ = "cdm_source" + __table_args__ = {"schema": CDM_SCHEMA} + + cdm_source_name: Mapped[str] = mapped_column(String(255), primary_key=True, sort_order=100) + cdm_source_abbreviation: Mapped[Optional[str]] = mapped_column(String(25), sort_order=200) + cdm_holder: Mapped[Optional[str]] = mapped_column(String(255), sort_order=300) + source_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + source_documentation_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=500) + cdm_etl_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=600) + source_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + cdm_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + cdm_version: Mapped[Optional[str]] = mapped_column(String(10), sort_order=900) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + + +class BaseMetadataCdm531: + __tablename__ = "metadata" + __table_args__ = {"schema": CDM_SCHEMA} + + metadata_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + metadata_type_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + name: Mapped[str] = mapped_column(String(250), primary_key=True, sort_order=300) + value_as_string: Mapped[Optional[str]] = mapped_column(String, sort_order=400) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + metadata_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + metadata_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) diff --git a/src/omop_cdm/dynamic/cdm531/vocabularies.py b/src/omop_cdm/dynamic/cdm531/vocabularies.py new file mode 100644 index 0000000..6b07404 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm531/vocabularies.py @@ -0,0 +1,262 @@ +"""OMOP CDM v5.3.1 vocabulary tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import Date, DateTime, ForeignKey, Integer, Numeric, String +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CONCEPT_CLASS_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_VOCABULARY_ID, + VOCAB_SCHEMA, +) + + +class BaseConceptCdm531: + __tablename__ = "concept" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + concept_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), index=True, sort_order=300) + vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=400) + concept_class_id: Mapped[str] = mapped_column(ForeignKey(FK_CONCEPT_CLASS_ID), index=True, sort_order=500) + standard_concept: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + concept_code: Mapped[str] = mapped_column(String(50), index=True, sort_order=700) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1000) + + @declared_attr + def concept_class(cls) -> Mapped["ConceptClass"]: + return relationship("ConceptClass", foreign_keys="Concept.concept_class_id") + + @declared_attr + def domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="Concept.domain_id") + + @declared_attr + def vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="Concept.vocabulary_id") + + +class BaseConceptAncestorCdm531: + __tablename__ = "concept_ancestor" + __table_args__ = {"schema": VOCAB_SCHEMA} + + ancestor_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + descendant_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + min_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=300) + max_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=400) + + @declared_attr + def ancestor_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptAncestor.ancestor_concept_id") + + @declared_attr + def descendant_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptAncestor.descendant_concept_id") + + +class BaseConceptClassCdm531: + __tablename__ = "concept_class" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_class_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + concept_class_name: Mapped[str] = mapped_column(String(255), sort_order=200) + concept_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + @declared_attr + def concept_class_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptClass.concept_class_concept_id") + + +class BaseConceptRelationshipCdm531: + __tablename__ = "concept_relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200) + relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), primary_key=True, index=True, sort_order=300 + ) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + + @declared_attr + def concept_1(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptRelationship.concept_id_1") + + @declared_attr + def concept_2(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptRelationship.concept_id_2") + + @declared_attr + def relationship(cls) -> Mapped["Relationship"]: + return relationship("Relationship", foreign_keys="ConceptRelationship.relationship_id") + + +class BaseConceptSynonymCdm531: + __tablename__ = "concept_synonym" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_synonym_name: Mapped[str] = mapped_column(String(1000), primary_key=True, sort_order=200) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300) + + @declared_attr + def concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptSynonym.concept_id") + + @declared_attr + def language_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptSynonym.language_concept_id") + + +class BaseDomainCdm531: + __tablename__ = "domain" + __table_args__ = {"schema": VOCAB_SCHEMA} + + domain_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + domain_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + @declared_attr + def domain_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Domain.domain_concept_id") + + +class BaseDrugStrengthCdm531: + __tablename__ = "drug_strength" + __table_args__ = {"schema": VOCAB_SCHEMA} + + drug_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + ingredient_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + amount_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=300) + amount_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + numerator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=500) + numerator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + denominator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + denominator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + box_size: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1100) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + + @declared_attr + def amount_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.amount_unit_concept_id") + + @declared_attr + def denominator_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.denominator_unit_concept_id") + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.drug_concept_id") + + @declared_attr + def ingredient_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.ingredient_concept_id") + + @declared_attr + def numerator_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.numerator_unit_concept_id") + + +class BaseRelationshipCdm531: + __tablename__ = "relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + relationship_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + relationship_name: Mapped[str] = mapped_column(String(255), sort_order=200) + is_hierarchical: Mapped[str] = mapped_column(String(1), sort_order=300) + defines_ancestry: Mapped[str] = mapped_column(String(1), sort_order=400) + reverse_relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), sort_order=500 + ) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + + @declared_attr + def relationship_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Relationship.relationship_concept_id") + + @declared_attr + def reverse_relationship(cls) -> Mapped["Relationship"]: + return relationship("Relationship", foreign_keys="Relationship.reverse_relationship_id") + + +class BaseVocabularyCdm531: + __tablename__ = "vocabulary" + __table_args__ = {"schema": VOCAB_SCHEMA} + + vocabulary_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + vocabulary_name: Mapped[str] = mapped_column(String(255), sort_order=200) + vocabulary_reference: Mapped[str] = mapped_column(String(255), sort_order=300) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + vocabulary_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + @declared_attr + def vocabulary_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Vocabulary.vocabulary_concept_id") + + +class BaseSourceToConceptMapCdm531: + __tablename__ = "source_to_concept_map" + __table_args__ = {"schema": CDM_SCHEMA} + + source_code: Mapped[str] = mapped_column(String(1000), primary_key=True, index=True, sort_order=100) + source_concept_id: Mapped[int] = mapped_column(Integer, sort_order=200) + source_vocabulary_id: Mapped[str] = mapped_column( + ForeignKey(FK_VOCABULARY_ID), primary_key=True, index=True, sort_order=300 + ) + source_code_description: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + target_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + target_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=600) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=800) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=900) + + @declared_attr + def source_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMap.source_vocabulary_id") + + @declared_attr + def target_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SourceToConceptMap.target_concept_id") + + @declared_attr + def target_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMap.target_vocabulary_id") + + +class BaseSourceToConceptMapVersionCdm531: + __tablename__ = "source_to_concept_map_version" + __table_args__ = {"schema": CDM_SCHEMA} + + source_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), primary_key=True, sort_order=100) + stcm_version: Mapped[str] = mapped_column(String(255), sort_order=200) + last_upload_date: Mapped[datetime.datetime] = mapped_column( + DateTime, default=datetime.datetime.utcnow, sort_order=300 + ) + + @declared_attr + def source_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMapVersion.source_vocabulary_id") diff --git a/src/omop_cdm/dynamic/cdm54/__init__.py b/src/omop_cdm/dynamic/cdm54/__init__.py new file mode 100644 index 0000000..ef6a6ed --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/__init__.py @@ -0,0 +1,29 @@ +""" +OMOP CDM Version 5.4. + +Generated from OMOP CDM release 5.4 using sqlacodegen 3.0.0rc5. +DDL from https://github.com/OHDSI/CommonDataModel/tree/v5.4 + + + +Deviations from standard model + +Removed + +cohort +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 + +""" diff --git a/src/omop_cdm/dynamic/cdm54/clinical_data.py b/src/omop_cdm/dynamic/cdm54/clinical_data.py new file mode 100644 index 0000000..04cbeb1 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/clinical_data.py @@ -0,0 +1,949 @@ +"""OMOP CDM 5.4 clinical tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import BigInteger, Date, DateTime, ForeignKey, Integer, Numeric, String, Text +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CARE_SITE_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_LOCATION_ID, + FK_PERSON_ID, + FK_PROVIDER_ID, + FK_VISIT_DETAIL_ID, + FK_VISIT_OCCURRENCE_ID, +) + + +class BaseConditionOccurrenceCdm54: + __tablename__ = "condition_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + condition_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + condition_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + condition_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + condition_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + condition_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + condition_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + condition_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + @declared_attr + def condition_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_concept_id") + + @declared_attr + def condition_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_source_concept_id") + + @declared_attr + def condition_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_status_concept_id") + + @declared_attr + def condition_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ConditionOccurrence.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="ConditionOccurrence.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="ConditionOccurrence.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="ConditionOccurrence.visit_occurrence_id") + + +class BaseDeathCdm54: + __tablename__ = "death" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), primary_key=True, index=True, sort_order=100) + death_date: Mapped[datetime.date] = mapped_column(Date, sort_order=200) + death_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=300) + death_type_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + cause_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + cause_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + cause_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + + @declared_attr + def cause_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Death.cause_concept_id") + + @declared_attr + def cause_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Death.cause_source_concept_id") + + @declared_attr + def death_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Death.death_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Death.person_id") + + +class BaseFactRelationshipCdm54: + __tablename__ = "fact_relationship" + __table_args__ = {"schema": CDM_SCHEMA} + + domain_concept_id_1: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + fact_id_1: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + domain_concept_id_2: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=300 + ) + fact_id_2: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=400) + relationship_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + + @declared_attr + def domain_concept_1(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_1") + + @declared_attr + def domain_concept_2(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_2") + + @declared_attr + def relationship_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.relationship_concept_id") + + +class BaseNoteNlpCdm54: + __tablename__ = "note_nlp" + __table_args__ = {"schema": CDM_SCHEMA} + + note_nlp_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + note_id: Mapped[int] = mapped_column(Integer, index=True, sort_order=200) + section_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + snippet: Mapped[Optional[str]] = mapped_column(String(250), sort_order=400) + offset: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + lexical_variant: Mapped[str] = mapped_column(String(250), sort_order=600) + note_nlp_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + note_nlp_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + nlp_system: Mapped[Optional[str]] = mapped_column(String(250), sort_order=900) + nlp_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + nlp_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1100) + term_exists: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + term_temporal: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + term_modifiers: Mapped[Optional[str]] = mapped_column(String(2000), sort_order=1400) + + @declared_attr + def note_nlp_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.note_nlp_concept_id") + + @declared_attr + def note_nlp_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.note_nlp_source_concept_id") + + @declared_attr + def section_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.section_concept_id") + + +class BasePersonCdm54: + __tablename__ = "person" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=200) + year_of_birth: Mapped[int] = mapped_column(Integer, sort_order=300) + month_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=400) + day_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + birth_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + race_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + ethnicity_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=900) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1000) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1100) + person_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + race_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + race_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + ethnicity_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + ethnicity_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="Person.care_site_id") + + @declared_attr + def ethnicity_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.ethnicity_concept_id") + + @declared_attr + def ethnicity_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.ethnicity_source_concept_id") + + @declared_attr + def gender_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.gender_concept_id") + + @declared_attr + def gender_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.gender_source_concept_id") + + @declared_attr + def location(cls) -> Mapped["Location"]: + return relationship("Location", foreign_keys="Person.location_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Person.provider_id") + + @declared_attr + def race_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.race_concept_id") + + @declared_attr + def race_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.race_source_concept_id") + + +class BaseObservationPeriodCdm54: + __tablename__ = "observation_period" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_period_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + observation_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + period_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + @declared_attr + def period_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ObservationPeriod.period_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ObservationPeriod.person_id") + + +class BaseSpecimenCdm54: + __tablename__ = "specimen" + __table_args__ = {"schema": CDM_SCHEMA} + + specimen_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + specimen_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + specimen_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + specimen_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + specimen_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + anatomic_site_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + disease_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + specimen_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + + @declared_attr + def anatomic_site_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.anatomic_site_concept_id") + + @declared_attr + def disease_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.disease_status_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Specimen.person_id") + + @declared_attr + def specimen_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.specimen_concept_id") + + @declared_attr + def specimen_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.specimen_type_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.unit_concept_id") + + +class BaseVisitOccurrenceCdm54: + __tablename__ = "visit_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharged_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + discharged_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + preceding_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1700 + ) + + @declared_attr + def admitted_from_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.admitted_from_concept_id") + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="VisitOccurrence.care_site_id") + + @declared_attr + def discharged_to_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.discharged_to_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="VisitOccurrence.person_id") + + @declared_attr + def preceding_visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="VisitOccurrence.preceding_visit_occurrence_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="VisitOccurrence.provider_id") + + @declared_attr + def visit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_concept_id") + + @declared_attr + def visit_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_source_concept_id") + + @declared_attr + def visit_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_type_concept_id") + + +class BaseVisitDetailCdm54: + __tablename__ = "visit_detail" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_detail_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_detail_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_detail_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_detail_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_detail_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_detail_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_detail_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_detail_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_detail_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharged_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + discharged_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + preceding_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1700) + parent_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1800) + visit_occurrence_id: Mapped[int] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1900) + + @declared_attr + def admitted_from_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.admitted_from_concept_id") + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="VisitDetail.care_site_id") + + @declared_attr + def discharged_to_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.discharged_to_concept_id") + + @declared_attr + def parent_visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="VisitDetail.parent_visit_detail_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="VisitDetail.person_id") + + @declared_attr + def preceding_visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="VisitDetail.preceding_visit_detail_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="VisitDetail.provider_id") + + @declared_attr + def visit_detail_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_concept_id") + + @declared_attr + def visit_detail_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_source_concept_id") + + @declared_attr + def visit_detail_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_type_concept_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="VisitDetail.visit_occurrence_id") + + +class BaseDeviceExposureCdm54: + __tablename__ = "device_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + device_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + device_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + device_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + device_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + device_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + device_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + device_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(255), sort_order=900) + production_id: Mapped[Optional[str]] = mapped_column(String(255), sort_order=1000) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1300 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1400) + device_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + device_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + unit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + + @declared_attr + def device_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_concept_id") + + @declared_attr + def device_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_source_concept_id") + + @declared_attr + def device_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DeviceExposure.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="DeviceExposure.provider_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.unit_concept_id") + + @declared_attr + def unit_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.unit_source_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="DeviceExposure.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="DeviceExposure.visit_occurrence_id") + + +class BaseDrugExposureCdm54: + __tablename__ = "drug_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + drug_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + drug_exposure_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + drug_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + drug_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1300) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=1400) + route_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1700) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1800 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1900) + drug_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drug_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2300) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_concept_id") + + @declared_attr + def drug_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_source_concept_id") + + @declared_attr + def drug_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DrugExposure.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="DrugExposure.provider_id") + + @declared_attr + def route_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.route_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="DrugExposure.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="DrugExposure.visit_occurrence_id") + + +class BaseMeasurementCdm54: + __tablename__ = "measurement" + __table_args__ = {"schema": CDM_SCHEMA} + + measurement_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + measurement_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + measurement_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + measurement_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + measurement_time: Mapped[Optional[str]] = mapped_column(String(10), sort_order=600) + measurement_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1400) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1500 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1600) + measurement_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + measurement_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + unit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2000) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2100) + measurement_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=2200) + meas_event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2300) + + @declared_attr + def meas_event_field_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.meas_event_field_concept_id") + + @declared_attr + def measurement_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_concept_id") + + @declared_attr + def measurement_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_source_concept_id") + + @declared_attr + def measurement_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_type_concept_id") + + @declared_attr + def operator_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.operator_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Measurement.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Measurement.provider_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.unit_concept_id") + + @declared_attr + def unit_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.unit_source_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Measurement.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Measurement.visit_occurrence_id") + + +class BaseNoteCdm54: + __tablename__ = "note" + __table_args__ = {"schema": CDM_SCHEMA} + + note_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + note_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + note_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=400) + note_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=500) + note_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + note_title: Mapped[Optional[str]] = mapped_column(String(250), sort_order=700) + note_text: Mapped[str] = mapped_column(Text, sort_order=800) + encoding_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + note_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + note_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=1500) + note_event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + + @declared_attr + def encoding_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.encoding_concept_id") + + @declared_attr + def language_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.language_concept_id") + + @declared_attr + def note_class_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.note_class_concept_id") + + @declared_attr + def note_event_field_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.note_event_field_concept_id") + + @declared_attr + def note_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.note_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Note.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Note.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Note.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Note.visit_occurrence_id") + + +class BaseObservationCdm54: + __tablename__ = "observation" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + observation_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + observation_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + observation_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=800) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1300 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1400) + observation_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + observation_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + observation_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=2000) + obs_event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + + @declared_attr + def obs_event_field_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.obs_event_field_concept_id") + + @declared_attr + def observation_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_concept_id") + + @declared_attr + def observation_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_source_concept_id") + + @declared_attr + def observation_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Observation.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Observation.provider_id") + + @declared_attr + def qualifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.qualifier_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.unit_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Observation.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Observation.visit_occurrence_id") + + +class BaseProcedureOccurrenceCdm54: + __tablename__ = "procedure_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + procedure_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + procedure_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + procedure_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + procedure_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + procedure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + procedure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + procedure_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + modifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + procedure_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + procedure_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + @declared_attr + def modifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.modifier_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ProcedureOccurrence.person_id") + + @declared_attr + def procedure_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_concept_id") + + @declared_attr + def procedure_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_source_concept_id") + + @declared_attr + def procedure_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_type_concept_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="ProcedureOccurrence.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="ProcedureOccurrence.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="ProcedureOccurrence.visit_occurrence_id") + + +class BaseStemTableCdm54: + __tablename__ = "stem_table" + __table_args__ = {"schema": CDM_SCHEMA} + + id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + domain_id: Mapped[Optional[str]] = mapped_column(ForeignKey(FK_DOMAIN_ID), sort_order=200) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=300) + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=400) + start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=500) + start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=800) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=900) + type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=1400) + value_as_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1500) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1700) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1900) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=2000 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=2100) + source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2300) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2400) + unit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2500) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2600) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=2700) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=2800) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=2900) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=3000) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=3100) + route_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3200) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3300) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3400) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3500) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3600) + condition_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3700) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3800) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3900) + modifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4000) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4100) + production_id: Mapped[Optional[str]] = mapped_column(String(255), sort_order=4200) + anatomic_site_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4300) + disease_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4400) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4500) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4600) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4700) + event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=4800) + event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4900) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=5000) + + @declared_attr + def anatomic_site_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.anatomic_site_concept_id") + + @declared_attr + def concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.concept_id") + + @declared_attr + def condition_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.condition_status_concept_id") + + @declared_attr + def disease_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.disease_status_concept_id") + + @declared_attr + def domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="StemTable.domain_id") + + @declared_attr + def event_field_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.event_field_concept_id") + + @declared_attr + def modifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.modifier_concept_id") + + @declared_attr + def operator_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.operator_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="StemTable.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="StemTable.provider_id") + + @declared_attr + def qualifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.qualifier_concept_id") + + @declared_attr + def route_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.route_concept_id") + + @declared_attr + def source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.source_concept_id") + + @declared_attr + def type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.type_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.unit_concept_id") + + @declared_attr + def unit_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.unit_source_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="StemTable.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="StemTable.visit_occurrence_id") diff --git a/src/omop_cdm/dynamic/cdm54/derived_elements.py b/src/omop_cdm/dynamic/cdm54/derived_elements.py new file mode 100644 index 0000000..f5c272e --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/derived_elements.py @@ -0,0 +1,137 @@ +"""OMOP CDM 5.4 derived elements tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import BigInteger, Date, DateTime, ForeignKey, Integer, Numeric, String +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID, FK_PERSON_ID + + +class BaseConditionEraCdm54: + __tablename__ = "condition_era" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + condition_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_occurrence_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + + @declared_attr + def condition_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionEra.condition_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ConditionEra.person_id") + + +class BaseDoseEraCdm54: + __tablename__ = "dose_era" + __table_args__ = {"schema": CDM_SCHEMA} + + dose_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + unit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + dose_value: Mapped[decimal.Decimal] = mapped_column(Numeric, sort_order=500) + dose_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + dose_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DoseEra.drug_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DoseEra.person_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DoseEra.unit_concept_id") + + +class BaseDrugEraCdm54: + __tablename__ = "drug_era" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + drug_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + gap_days: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugEra.drug_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DrugEra.person_id") + + +class BaseEpisodeCdm54: + __tablename__ = "episode" + __table_args__ = {"schema": CDM_SCHEMA} + + episode_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), sort_order=200) + episode_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + episode_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + episode_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + episode_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + episode_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + episode_parent_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=800) + episode_number: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + episode_object_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + episode_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + episode_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + episode_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + @declared_attr + def episode_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Episode.episode_concept_id") + + @declared_attr + def episode_object_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Episode.episode_object_concept_id") + + @declared_attr + def episode_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Episode.episode_source_concept_id") + + @declared_attr + def episode_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Episode.episode_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Episode.person_id") + + +class BaseEpisodeEventCdm54: + __tablename__ = "episode_event" + __table_args__ = {"schema": CDM_SCHEMA} + + episode_id: Mapped[int] = mapped_column( + ForeignKey(f"{CDM_SCHEMA}.episode.episode_id"), primary_key=True, sort_order=100 + ) + event_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=200) + episode_event_field_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300 + ) + + @declared_attr + def episode_event_field_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="EpisodeEvent.episode_event_field_concept_id") + + @declared_attr + def episode(cls) -> Mapped["Episode"]: + return relationship("Episode", foreign_keys="EpisodeEvent.episode_id") diff --git a/src/omop_cdm/dynamic/cdm54/health_economics.py b/src/omop_cdm/dynamic/cdm54/health_economics.py new file mode 100644 index 0000000..b54b970 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/health_economics.py @@ -0,0 +1,122 @@ +"""OMOP CDM 5.4 health economics tables.""" + +import decimal +from datetime import datetime +from typing import Optional + +from sqlalchemy import Date, ForeignKey, Integer, Numeric, String +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID, FK_DOMAIN_ID, FK_PERSON_ID + + +class BasePayerPlanPeriodCdm54: + __tablename__ = "payer_plan_period" + __table_args__ = {"schema": CDM_SCHEMA} + + payer_plan_period_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + payer_plan_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + payer_plan_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + payer_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + payer_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + payer_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + plan_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + plan_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + plan_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + sponsor_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + sponsor_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + sponsor_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + family_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + stop_reason_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + stop_reason_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + stop_reason_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + + @declared_attr + def payer_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.payer_concept_id") + + @declared_attr + def payer_plan_period(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="PayerPlanPeriod.payer_plan_period_id") + + @declared_attr + def payer_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.payer_source_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="PayerPlanPeriod.person_id") + + @declared_attr + def plan_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.plan_concept_id") + + @declared_attr + def plan_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.plan_source_concept_id") + + @declared_attr + def sponsor_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_concept_id") + + @declared_attr + def sponsor_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_source_concept_id") + + @declared_attr + def stop_reason_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.stop_reason_concept_id") + + @declared_attr + def stop_reason_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.stop_reason_source_concept_id") + + +class BaseCostCdm54: + __tablename__ = "cost" + __table_args__ = {"schema": CDM_SCHEMA} + + cost_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + cost_event_id: Mapped[int] = mapped_column(Integer, index=True, sort_order=200) + cost_domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), sort_order=300) + cost_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + currency_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + total_charge: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=600) + total_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + total_paid: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=800) + paid_by_payer: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + paid_by_patient: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1000) + paid_patient_copay: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + paid_patient_coinsurance: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + paid_patient_deductible: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + paid_by_primary: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1400) + paid_ingredient_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1500) + paid_dispensing_fee: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1600) + payer_plan_period_id: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1700) + amount_allowed: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1800) + revenue_code_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + revenue_code_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drg_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + drg_source_value: Mapped[Optional[str]] = mapped_column(String(3), sort_order=2200) + + @declared_attr + def cost_domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="Cost.cost_domain_id") + + @declared_attr + def cost_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.cost_type_concept_id") + + @declared_attr + def currency_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.currency_concept_id") + + @declared_attr + def drg_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.drg_concept_id") + + @declared_attr + def revenue_code_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.revenue_code_concept_id") diff --git a/src/omop_cdm/dynamic/cdm54/health_system_data.py b/src/omop_cdm/dynamic/cdm54/health_system_data.py new file mode 100644 index 0000000..09d1f83 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/health_system_data.py @@ -0,0 +1,91 @@ +"""OMOP CDM 5.4 health system data tables.""" + +import decimal +from typing import Optional + +from sqlalchemy import ForeignKey, Integer, Numeric, String +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CARE_SITE_ID, FK_CONCEPT_ID, FK_LOCATION_ID + + +class BaseCareSiteCdm54: + __tablename__ = "care_site" + __table_args__ = {"schema": CDM_SCHEMA} + + care_site_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + care_site_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + place_of_service_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=400) + care_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + place_of_service_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + + @declared_attr + def location(cls) -> Mapped["Location"]: + return relationship("Location", foreign_keys="CareSite.location_id") + + @declared_attr + def place_of_service_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="CareSite.place_of_service_concept_id") + + +class BaseLocationCdm54: + __tablename__ = "location" + __table_args__ = {"schema": CDM_SCHEMA} + + location_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + address_1: Mapped[Optional[str]] = mapped_column(String(50), sort_order=200) + address_2: Mapped[Optional[str]] = mapped_column(String(50), sort_order=300) + city: Mapped[Optional[str]] = mapped_column(String(50), sort_order=400) + state: Mapped[Optional[str]] = mapped_column(String(2), sort_order=500) + zip: Mapped[Optional[str]] = mapped_column(String(9), sort_order=600) + county: Mapped[Optional[str]] = mapped_column(String(20), sort_order=700) + location_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=800) + country_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + country_source_value: Mapped[Optional[str]] = mapped_column(String(80), sort_order=1000) + latitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + longitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + + @declared_attr + def country_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Location.country_concept_id") + + +class BaseProviderCdm54: + __tablename__ = "provider" + __table_args__ = {"schema": CDM_SCHEMA} + + provider_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + provider_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + npi: Mapped[Optional[str]] = mapped_column(String(20), sort_order=300) + dea: Mapped[Optional[str]] = mapped_column(String(20), sort_order=400) + specialty_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=600) + year_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + gender_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + specialty_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1000) + specialty_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="Provider.care_site_id") + + @declared_attr + def gender_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.gender_concept_id") + + @declared_attr + def gender_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.gender_source_concept_id") + + @declared_attr + def specialty_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.specialty_concept_id") + + @declared_attr + def specialty_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.specialty_source_concept_id") diff --git a/src/omop_cdm/dynamic/cdm54/metadata.py b/src/omop_cdm/dynamic/cdm54/metadata.py new file mode 100644 index 0000000..868b990 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/metadata.py @@ -0,0 +1,59 @@ +"""OMOP CDM metadata tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import Date, DateTime, ForeignKey, Integer, Numeric, String, Text +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID + + +class BaseCdmSourceCdm54: + __tablename__ = "cdm_source" + __table_args__ = {"schema": CDM_SCHEMA} + + cdm_source_name: Mapped[str] = mapped_column(String(255), primary_key=True, sort_order=100) + cdm_source_abbreviation: Mapped[str] = mapped_column(String(25), sort_order=200) + cdm_holder: Mapped[str] = mapped_column(String(255), sort_order=300) + source_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + source_documentation_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=500) + cdm_etl_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=600) + source_release_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + cdm_release_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + cdm_version: Mapped[Optional[str]] = mapped_column(String(10), sort_order=900) + cdm_version_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + vocabulary_version: Mapped[str] = mapped_column(String(20), sort_order=1100) + + @declared_attr + def cdm_version_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="CdmSource.cdm_version_concept_id") + + +class BaseMetadataCdm54: + __tablename__ = "metadata" + __table_args__ = {"schema": CDM_SCHEMA} + + metadata_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + metadata_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=200) + metadata_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + name: Mapped[str] = mapped_column(String(250), sort_order=400) + value_as_string: Mapped[Optional[str]] = mapped_column(String(250), sort_order=500) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + metadata_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + metadata_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=900) + + @declared_attr + def metadata_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Metadata.metadata_concept_id") + + @declared_attr + def metadata_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Metadata.metadata_type_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Metadata.value_as_concept_id") diff --git a/src/omop_cdm/dynamic/cdm54/vocabularies/__init__.py b/src/omop_cdm/dynamic/cdm54/vocabularies/__init__.py new file mode 100644 index 0000000..5a4221e --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/vocabularies/__init__.py @@ -0,0 +1 @@ +"""CDM vocabulary tables package.""" diff --git a/src/omop_cdm/dynamic/cdm54/vocabularies/vocabularies.py b/src/omop_cdm/dynamic/cdm54/vocabularies/vocabularies.py new file mode 100644 index 0000000..e656621 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm54/vocabularies/vocabularies.py @@ -0,0 +1,266 @@ +"""OMOP CDM v5.4 vocabulary tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import Date, DateTime, ForeignKey, Integer, Numeric, String +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CONCEPT_CLASS_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_VOCABULARY_ID, + VOCAB_SCHEMA, +) + + +class BaseConceptCdm54: + __tablename__ = "concept" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + concept_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), index=True, sort_order=300) + vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=400) + concept_class_id: Mapped[str] = mapped_column(ForeignKey(FK_CONCEPT_CLASS_ID), index=True, sort_order=500) + standard_concept: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + concept_code: Mapped[str] = mapped_column(String(50), index=True, sort_order=700) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1000) + + @declared_attr + def concept_class(cls) -> Mapped["ConceptClass"]: + return relationship("ConceptClass", foreign_keys="Concept.concept_class_id") + + @declared_attr + def domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="Concept.domain_id") + + @declared_attr + def vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="Concept.vocabulary_id") + + +class BaseConceptClassCdm54: + __tablename__ = "concept_class" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_class_id: Mapped[str] = mapped_column(String(20), primary_key=True, index=True, sort_order=100) + concept_class_name: Mapped[str] = mapped_column(String(255), sort_order=200) + concept_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + @declared_attr + def concept_class_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptClass.concept_class_concept_id") + + +class BaseDomainCdm54: + __tablename__ = "domain" + __table_args__ = {"schema": VOCAB_SCHEMA} + + domain_id: Mapped[str] = mapped_column(String(20), primary_key=True, index=True, sort_order=100) + domain_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + @declared_attr + def domain_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Domain.domain_concept_id") + + +class BaseVocabularyCdm54: + __tablename__ = "vocabulary" + __table_args__ = {"schema": VOCAB_SCHEMA} + + vocabulary_id: Mapped[str] = mapped_column(String(20), primary_key=True, index=True, sort_order=100) + vocabulary_name: Mapped[str] = mapped_column(String(255), sort_order=200) + vocabulary_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=300) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + vocabulary_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + @declared_attr + def vocabulary_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Vocabulary.vocabulary_concept_id") + + +class BaseConceptAncestorCdm54: + __tablename__ = "concept_ancestor" + __table_args__ = {"schema": VOCAB_SCHEMA} + + ancestor_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + descendant_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + min_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=300) + max_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=400) + + @declared_attr + def ancestor_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptAncestor.ancestor_concept_id") + + @declared_attr + def descendant_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptAncestor.descendant_concept_id") + + +class BaseConceptSynonymCdm54: + __tablename__ = "concept_synonym" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_synonym_name: Mapped[str] = mapped_column(String(1000), primary_key=True, sort_order=200) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300) + + @declared_attr + def concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptSynonym.concept_id") + + @declared_attr + def language_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptSynonym.language_concept_id") + + +class BaseDrugStrengthCdm54: + __tablename__ = "drug_strength" + __table_args__ = {"schema": VOCAB_SCHEMA} + + drug_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + ingredient_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + amount_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=300) + amount_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + numerator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=500) + numerator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + denominator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + denominator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + box_size: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1100) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + + @declared_attr + def amount_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.amount_unit_concept_id") + + @declared_attr + def denominator_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.denominator_unit_concept_id") + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.drug_concept_id") + + @declared_attr + def ingredient_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.ingredient_concept_id") + + @declared_attr + def numerator_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.numerator_unit_concept_id") + + +class BaseRelationshipCdm54: + __tablename__ = "relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + relationship_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + relationship_name: Mapped[str] = mapped_column(String(255), sort_order=200) + is_hierarchical: Mapped[str] = mapped_column(String(1), sort_order=300) + defines_ancestry: Mapped[str] = mapped_column(String(1), sort_order=400) + reverse_relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), sort_order=500 + ) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + + @declared_attr + def relationship_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Relationship.relationship_concept_id") + + @declared_attr + def reverse_relationship(cls) -> Mapped["Relationship"]: + return relationship("Relationship", foreign_keys="Relationship.reverse_relationship_id") + + +class BaseConceptRelationshipCdm54: + __tablename__ = "concept_relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200) + relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), primary_key=True, index=True, sort_order=300 + ) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + + @declared_attr + def concept_1(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptRelationship.concept_id_1") + + @declared_attr + def concept_2(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptRelationship.concept_id_2") + + @declared_attr + def relationship(cls) -> Mapped["Relationship"]: + return relationship("Relationship", foreign_keys="ConceptRelationship.relationship_id") + + +class BaseSourceToConceptMapCdm54: + __tablename__ = "source_to_concept_map" + __table_args__ = {"schema": CDM_SCHEMA} + + source_code: Mapped[str] = mapped_column(String(1000), primary_key=True, index=True, sort_order=100) + source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=200) + source_vocabulary_id: Mapped[str] = mapped_column( + ForeignKey(FK_VOCABULARY_ID), primary_key=True, index=True, sort_order=300 + ) + source_code_description: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + target_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + target_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=600) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=800) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=900) + + @declared_attr + def source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SourceToConceptMap.source_concept_id") + + @declared_attr + def source_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMap.source_vocabulary_id") + + @declared_attr + def target_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SourceToConceptMap.target_concept_id") + + @declared_attr + def target_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMap.target_vocabulary_id") + + +class BaseSourceToConceptMapVersionCdm54: + __tablename__ = "source_to_concept_map_version" + __table_args__ = {"schema": CDM_SCHEMA} + + source_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), primary_key=True, sort_order=100) + stcm_version: Mapped[str] = mapped_column(String(255), sort_order=200) + last_upload_date: Mapped[datetime.datetime] = mapped_column( + DateTime, default=datetime.datetime.utcnow, sort_order=300 + ) + + @declared_attr + def source_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMapVersion.source_vocabulary_id") diff --git a/src/omop_cdm/dynamic/cdm600/__init__.py b/src/omop_cdm/dynamic/cdm600/__init__.py new file mode 100644 index 0000000..6186a9a --- /dev/null +++ b/src/omop_cdm/dynamic/cdm600/__init__.py @@ -0,0 +1,24 @@ +""" +OMOP CDM Version 6.0.0. + +Generated with python using sqlacodegen 3.0.0rc5, model from +https://github.com/OHDSI/CommonDataModel/tree/Dev/PostgreSQL, +commit 30d851a. + + + +Deviations from standard model + +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 + +""" diff --git a/src/omop_cdm/dynamic/cdm600/clinical_data.py b/src/omop_cdm/dynamic/cdm600/clinical_data.py new file mode 100644 index 0000000..4b5ebd7 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm600/clinical_data.py @@ -0,0 +1,965 @@ +"""OMOP CDM 6.0.0 clinical tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import BigInteger, Date, DateTime, ForeignKey, Integer, Numeric, String, Text +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CARE_SITE_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_LOCATION_ID, + FK_PERSON_ID, + FK_PROVIDER_ID, + FK_VISIT_DETAIL_ID, + FK_VISIT_OCCURRENCE_ID, +) + + +class BaseFactRelationshipCdm600: + __tablename__ = "fact_relationship" + __table_args__ = {"schema": CDM_SCHEMA} + + fact_relationship_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + domain_concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=200) + fact_id_1: Mapped[int] = mapped_column(Integer, sort_order=300) + domain_concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=400) + fact_id_2: Mapped[int] = mapped_column(Integer, sort_order=500) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=600) + + @declared_attr + def domain_concept_1(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_1") + + @declared_attr + def domain_concept_2(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_2") + + @declared_attr + def relationship_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="FactRelationship.relationship_concept_id") + + +class BasePersonCdm600: + __tablename__ = "person" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=200) + year_of_birth: Mapped[int] = mapped_column(Integer, sort_order=300) + month_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=400) + day_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + birth_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + death_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + race_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + ethnicity_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1200) + person_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + gender_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + race_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + race_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + ethnicity_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + ethnicity_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="Person.care_site_id") + + @declared_attr + def ethnicity_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.ethnicity_concept_id") + + @declared_attr + def ethnicity_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.ethnicity_source_concept_id") + + @declared_attr + def gender_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.gender_concept_id") + + @declared_attr + def gender_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.gender_source_concept_id") + + @declared_attr + def location(cls) -> Mapped["Location"]: + return relationship("Location", foreign_keys="Person.location_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Person.provider_id") + + @declared_attr + def race_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.race_concept_id") + + @declared_attr + def race_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Person.race_source_concept_id") + + +class BaseObservationPeriodCdm600: + __tablename__ = "observation_period" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_period_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + observation_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + period_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + @declared_attr + def period_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ObservationPeriod.period_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ObservationPeriod.person_id") + + +class BaseSpecimenCdm600: + __tablename__ = "specimen" + __table_args__ = {"schema": CDM_SCHEMA} + + specimen_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + specimen_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + specimen_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + specimen_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=500) + specimen_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + anatomic_site_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + disease_status_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + specimen_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + + @declared_attr + def anatomic_site_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.anatomic_site_concept_id") + + @declared_attr + def disease_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.disease_status_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Specimen.person_id") + + @declared_attr + def specimen_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.specimen_concept_id") + + @declared_attr + def specimen_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.specimen_type_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Specimen.unit_concept_id") + + +class BaseVisitOccurrenceCdm600: + __tablename__ = "visit_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_occurrence_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + visit_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + visit_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + visit_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + visit_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + discharge_to_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + preceding_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1700 + ) + + @declared_attr + def admitted_from_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.admitted_from_concept_id") + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="VisitOccurrence.care_site_id") + + @declared_attr + def discharge_to_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.discharge_to_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="VisitOccurrence.person_id") + + @declared_attr + def preceding_visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="VisitOccurrence.preceding_visit_occurrence_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="VisitOccurrence.provider_id") + + @declared_attr + def visit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_concept_id") + + @declared_attr + def visit_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_source_concept_id") + + @declared_attr + def visit_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitOccurrence.visit_type_concept_id") + + +class BaseVisitDetailCdm600: + __tablename__ = "visit_detail" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_detail_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_detail_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_detail_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + visit_detail_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + visit_detail_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + visit_detail_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + visit_detail_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + discharge_to_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + admitted_from_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + visit_detail_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + visit_detail_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + preceding_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1700) + visit_detail_parent_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1800) + visit_occurrence_id: Mapped[int] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1900) + + @declared_attr + def admitted_from_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.admitted_from_concept_id") + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="VisitDetail.care_site_id") + + @declared_attr + def discharge_to_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.discharge_to_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="VisitDetail.person_id") + + @declared_attr + def preceding_visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="VisitDetail.preceding_visit_detail_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="VisitDetail.provider_id") + + @declared_attr + def visit_detail_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_concept_id") + + @declared_attr + def visit_detail_parent(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="VisitDetail.visit_detail_parent_id") + + @declared_attr + def visit_detail_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_source_concept_id") + + @declared_attr + def visit_detail_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="VisitDetail.visit_detail_type_concept_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="VisitDetail.visit_occurrence_id") + + +class BaseConditionOccurrenceCdm600: + __tablename__ = "condition_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_occurrence_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + condition_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + condition_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + condition_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=900) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1000) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1100 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1200) + condition_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + condition_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + condition_status_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + + @declared_attr + def condition_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_concept_id") + + @declared_attr + def condition_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_source_concept_id") + + @declared_attr + def condition_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_status_concept_id") + + @declared_attr + def condition_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionOccurrence.condition_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ConditionOccurrence.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="ConditionOccurrence.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="ConditionOccurrence.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="ConditionOccurrence.visit_occurrence_id") + + +class BaseDeviceExposureCdm600: + __tablename__ = "device_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + device_exposure_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + device_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + device_exposure_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + device_exposure_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + device_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + device_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + device_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + device_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1400) + device_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + + @declared_attr + def device_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_concept_id") + + @declared_attr + def device_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_source_concept_id") + + @declared_attr + def device_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DeviceExposure.device_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DeviceExposure.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="DeviceExposure.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="DeviceExposure.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="DeviceExposure.visit_occurrence_id") + + +class BaseDrugExposureCdm600: + __tablename__ = "drug_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_exposure_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_exposure_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + drug_exposure_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + drug_exposure_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + drug_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1300) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=1400) + route_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1700) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1800 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1900) + drug_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drug_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2300) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_concept_id") + + @declared_attr + def drug_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_source_concept_id") + + @declared_attr + def drug_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.drug_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DrugExposure.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="DrugExposure.provider_id") + + @declared_attr + def route_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugExposure.route_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="DrugExposure.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="DrugExposure.visit_occurrence_id") + + +class BaseMeasurementCdm600: + __tablename__ = "measurement" + __table_args__ = {"schema": CDM_SCHEMA} + + measurement_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + measurement_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + measurement_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + measurement_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + measurement_time: Mapped[Optional[str]] = mapped_column(String(10), sort_order=600) + measurement_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1400) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1500 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1600) + measurement_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + measurement_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + + @declared_attr + def measurement_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_concept_id") + + @declared_attr + def measurement_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_source_concept_id") + + @declared_attr + def measurement_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.measurement_type_concept_id") + + @declared_attr + def operator_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.operator_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Measurement.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Measurement.provider_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.unit_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Measurement.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Measurement.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Measurement.visit_occurrence_id") + + +class BaseNoteCdm600: + __tablename__ = "note" + __table_args__ = {"schema": CDM_SCHEMA} + + note_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + note_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=300) + note_event_field_concept_id: Mapped[int] = mapped_column(Integer, sort_order=400) + note_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=500) + note_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + note_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + note_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + note_title: Mapped[Optional[str]] = mapped_column(String(250), sort_order=900) + note_text: Mapped[str] = mapped_column(Text, sort_order=1000) + encoding_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1300) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1400 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1500) + note_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + @declared_attr + def encoding_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.encoding_concept_id") + + @declared_attr + def language_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.language_concept_id") + + @declared_attr + def note_class_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.note_class_concept_id") + + @declared_attr + def note_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Note.note_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Note.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Note.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Note.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Note.visit_occurrence_id") + + +class BaseObservationCdm600: + __tablename__ = "observation" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + observation_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + observation_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + observation_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=800) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + value_as_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1000) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1300) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1400 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1500) + observation_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + observation_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + observation_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=2000) + obs_event_field_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + + @declared_attr + def obs_event_field_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.obs_event_field_concept_id") + + @declared_attr + def observation_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_concept_id") + + @declared_attr + def observation_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_source_concept_id") + + @declared_attr + def observation_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.observation_type_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Observation.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="Observation.provider_id") + + @declared_attr + def qualifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.qualifier_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.unit_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Observation.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="Observation.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="Observation.visit_occurrence_id") + + +class BaseProcedureOccurrenceCdm600: + __tablename__ = "procedure_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + procedure_occurrence_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + procedure_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + procedure_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + procedure_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + procedure_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + modifier_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1000 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1100) + procedure_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + procedure_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + + @declared_attr + def modifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.modifier_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ProcedureOccurrence.person_id") + + @declared_attr + def procedure_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_concept_id") + + @declared_attr + def procedure_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_source_concept_id") + + @declared_attr + def procedure_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ProcedureOccurrence.procedure_type_concept_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="ProcedureOccurrence.provider_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="ProcedureOccurrence.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="ProcedureOccurrence.visit_occurrence_id") + + +class BaseSurveyConductCdm600: + __tablename__ = "survey_conduct" + __table_args__ = {"schema": CDM_SCHEMA} + + survey_conduct_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + survey_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + survey_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + survey_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + survey_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + survey_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=800) + assisted_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + respondent_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + timing_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + collection_method_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + assisted_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + respondent_type_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1400) + timing_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1500) + collection_method_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1600) + survey_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1700) + survey_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + survey_source_identifier: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1900) + validated_survey_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2000) + validated_survey_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=2100) + survey_version_number: Mapped[Optional[str]] = mapped_column(String(20), sort_order=2200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=2300) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=2400) + response_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=2500 + ) + + @declared_attr + def assisted_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SurveyConduct.assisted_concept_id") + + @declared_attr + def collection_method_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SurveyConduct.collection_method_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="SurveyConduct.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="SurveyConduct.provider_id") + + @declared_attr + def respondent_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SurveyConduct.respondent_type_concept_id") + + @declared_attr + def response_visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="SurveyConduct.response_visit_occurrence_id") + + @declared_attr + def survey_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SurveyConduct.survey_concept_id") + + @declared_attr + def survey_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SurveyConduct.survey_source_concept_id") + + @declared_attr + def timing_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SurveyConduct.timing_concept_id") + + @declared_attr + def validated_survey_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SurveyConduct.validated_survey_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="SurveyConduct.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="SurveyConduct.visit_occurrence_id") + + +class BaseNoteNlpCdm600: + __tablename__ = "note_nlp" + __table_args__ = {"schema": CDM_SCHEMA} + + note_nlp_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + note_id: Mapped[int] = mapped_column(ForeignKey(f"{CDM_SCHEMA}.note.note_id"), index=True, sort_order=200) + section_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + snippet: Mapped[Optional[str]] = mapped_column(String(250), sort_order=400) + offset: Mapped[Optional[str]] = mapped_column(String(250), sort_order=500) + lexical_variant: Mapped[str] = mapped_column(String(250), sort_order=600) + note_nlp_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + nlp_system: Mapped[Optional[str]] = mapped_column(String(250), sort_order=800) + nlp_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + nlp_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1000) + term_exists: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1100) + term_temporal: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + term_modifiers: Mapped[Optional[str]] = mapped_column(String(2000), sort_order=1300) + note_nlp_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + + @declared_attr + def note(cls) -> Mapped["Note"]: + return relationship("Note", foreign_keys="NoteNlp.note_id") + + @declared_attr + def note_nlp_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.note_nlp_concept_id") + + @declared_attr + def note_nlp_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.note_nlp_source_concept_id") + + @declared_attr + def section_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="NoteNlp.section_concept_id") + + +class BaseStemTableCdm600: + __tablename__ = "stem_table" + __table_args__ = {"schema": CDM_SCHEMA} + + id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + domain_id: Mapped[Optional[str]] = mapped_column(ForeignKey(FK_DOMAIN_ID), sort_order=200) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=300) + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=400) + start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=500) + start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=800) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=900) + type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=1400) + value_as_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1500) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1700) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1900) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=2000 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=2100) + source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2300) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2400) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2500) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=2600) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=2700) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=2800) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=2900) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=3000) + route_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3100) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3200) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3300) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3400) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3500) + condition_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3600) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3700) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=3800) + modifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=3900) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4000) + anatomic_site_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4100) + disease_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4200) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4500) + event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=4600) + event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=4700) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=4800) + + @declared_attr + def anatomic_site_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.anatomic_site_concept_id") + + @declared_attr + def concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.concept_id") + + @declared_attr + def condition_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.condition_status_concept_id") + + @declared_attr + def disease_status_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.disease_status_concept_id") + + @declared_attr + def domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="StemTable.domain_id") + + @declared_attr + def event_field_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.event_field_concept_id") + + @declared_attr + def modifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.modifier_concept_id") + + @declared_attr + def operator_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.operator_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="StemTable.person_id") + + @declared_attr + def provider(cls) -> Mapped["Provider"]: + return relationship("Provider", foreign_keys="StemTable.provider_id") + + @declared_attr + def qualifier_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.qualifier_concept_id") + + @declared_attr + def route_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.route_concept_id") + + @declared_attr + def source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.source_concept_id") + + @declared_attr + def type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.type_concept_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.unit_concept_id") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="StemTable.value_as_concept_id") + + @declared_attr + def visit_detail(cls) -> Mapped["VisitDetail"]: + return relationship("VisitDetail", foreign_keys="StemTable.visit_detail_id") + + @declared_attr + def visit_occurrence(cls) -> Mapped["VisitOccurrence"]: + return relationship("VisitOccurrence", foreign_keys="StemTable.visit_occurrence_id") diff --git a/src/omop_cdm/dynamic/cdm600/derived_elements.py b/src/omop_cdm/dynamic/cdm600/derived_elements.py new file mode 100644 index 0000000..3557030 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm600/derived_elements.py @@ -0,0 +1,76 @@ +"""OMOP CDM 6.0.0 derived elements tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import BigInteger, DateTime, ForeignKey, Integer, Numeric +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID, FK_PERSON_ID + + +class BaseConditionEraCdm600: + __tablename__ = "condition_era" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_era_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_era_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + condition_era_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_occurrence_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + + @declared_attr + def condition_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConditionEra.condition_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="ConditionEra.person_id") + + +class BaseDoseEraCdm600: + __tablename__ = "dose_era" + __table_args__ = {"schema": CDM_SCHEMA} + + dose_era_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + unit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + dose_value: Mapped[decimal.Decimal] = mapped_column(Numeric, sort_order=500) + dose_era_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + dose_era_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DoseEra.drug_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DoseEra.person_id") + + @declared_attr + def unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DoseEra.unit_concept_id") + + +class BaseDrugEraCdm600: + __tablename__ = "drug_era" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_era_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_era_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + drug_era_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + gap_days: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugEra.drug_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="DrugEra.person_id") diff --git a/src/omop_cdm/dynamic/cdm600/health_economics.py b/src/omop_cdm/dynamic/cdm600/health_economics.py new file mode 100644 index 0000000..0404640 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm600/health_economics.py @@ -0,0 +1,143 @@ +"""OMOP CDM 6.0.0 health economics tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import BigInteger, Date, ForeignKey, Integer, Numeric, String +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID, FK_PERSON_ID + + +class BaseCostCdm600: + __tablename__ = "cost" + __table_args__ = {"schema": CDM_SCHEMA} + + cost_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + cost_event_id: Mapped[int] = mapped_column(BigInteger, sort_order=300) + cost_event_field_concept_id: Mapped[int] = mapped_column(Integer, sort_order=400) + cost_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + cost_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + currency_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=800) + incurred_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + billed_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=1000) + paid_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=1100) + revenue_code_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + drg_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + cost_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + cost_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + revenue_code_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + drg_source_value: Mapped[Optional[str]] = mapped_column(String(3), sort_order=1700) + payer_plan_period_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(f"{CDM_SCHEMA}.payer_plan_period.payer_plan_period_id"), sort_order=1800 + ) + + @declared_attr + def cost_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.cost_concept_id") + + @declared_attr + def cost_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.cost_source_concept_id") + + @declared_attr + def cost_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.cost_type_concept_id") + + @declared_attr + def currency_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.currency_concept_id") + + @declared_attr + def drg_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.drg_concept_id") + + @declared_attr + def payer_plan_period(cls) -> Mapped["PayerPlanPeriod"]: + return relationship("PayerPlanPeriod", foreign_keys="Cost.payer_plan_period_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="Cost.person_id") + + @declared_attr + def revenue_code_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Cost.revenue_code_concept_id") + + +class BasePayerPlanPeriodCdm600: + __tablename__ = "payer_plan_period" + __table_args__ = {"schema": CDM_SCHEMA} + + payer_plan_period_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + contract_person_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PERSON_ID), sort_order=300) + payer_plan_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + payer_plan_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + payer_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + plan_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + contract_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + sponsor_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + payer_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + payer_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + plan_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + plan_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + contract_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + contract_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + sponsor_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + sponsor_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + family_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + stop_reason_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + stop_reason_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + + @declared_attr + def contract_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.contract_concept_id") + + @declared_attr + def contract_person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="PayerPlanPeriod.contract_person_id") + + @declared_attr + def contract_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.contract_source_concept_id") + + @declared_attr + def payer_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.payer_concept_id") + + @declared_attr + def payer_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.payer_source_concept_id") + + @declared_attr + def person(cls) -> Mapped["Person"]: + return relationship("Person", foreign_keys="PayerPlanPeriod.person_id") + + @declared_attr + def plan_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.plan_concept_id") + + @declared_attr + def plan_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.plan_source_concept_id") + + @declared_attr + def sponsor_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_concept_id") + + @declared_attr + def sponsor_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_source_concept_id") + + @declared_attr + def stop_reason_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.stop_reason_concept_id") + + @declared_attr + def stop_reason_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="PayerPlanPeriod.stop_reason_source_concept_id") diff --git a/src/omop_cdm/dynamic/cdm600/health_system_data.py b/src/omop_cdm/dynamic/cdm600/health_system_data.py new file mode 100644 index 0000000..8d8cf42 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm600/health_system_data.py @@ -0,0 +1,112 @@ +"""OMOP CDM 6.0.0 health system tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import BigInteger, Date, ForeignKey, Integer, Numeric, String +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CARE_SITE_ID, FK_CONCEPT_ID, FK_LOCATION_ID + + +class BaseCareSiteCdm600: + __tablename__ = "care_site" + __table_args__ = {"schema": CDM_SCHEMA} + + care_site_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + care_site_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + place_of_service_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=400) + care_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + place_of_service_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + + @declared_attr + def location(cls) -> Mapped["Location"]: + return relationship("Location", foreign_keys="CareSite.location_id") + + @declared_attr + def place_of_service_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="CareSite.place_of_service_concept_id") + + +class BaseLocationCdm600: + __tablename__ = "location" + __table_args__ = {"schema": CDM_SCHEMA} + + location_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + address_1: Mapped[Optional[str]] = mapped_column(String(50), sort_order=200) + address_2: Mapped[Optional[str]] = mapped_column(String(50), sort_order=300) + city: Mapped[Optional[str]] = mapped_column(String(50), sort_order=400) + state: Mapped[Optional[str]] = mapped_column(String(2), sort_order=500) + zip: Mapped[Optional[str]] = mapped_column(String(9), sort_order=600) + county: Mapped[Optional[str]] = mapped_column(String(20), sort_order=700) + country: Mapped[Optional[str]] = mapped_column(String(100), sort_order=800) + location_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + latitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1000) + longitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + region_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + + @declared_attr + def region_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Location.region_concept_id") + + +class BaseLocationHistoryCdm600: + __tablename__ = "location_history" + __table_args__ = {"schema": CDM_SCHEMA} + + location_history_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + location_id: Mapped[int] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=200) + relationship_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + domain_id: Mapped[str] = mapped_column(String(50), sort_order=400) + entity_id: Mapped[int] = mapped_column(BigInteger, sort_order=500) + start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + + @declared_attr + def location(cls) -> Mapped["Location"]: + return relationship("Location", foreign_keys="LocationHistory.location_id") + + @declared_attr + def relationship_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="LocationHistory.relationship_type_concept_id") + + +class BaseProviderCdm600: + __tablename__ = "provider" + __table_args__ = {"schema": CDM_SCHEMA} + + provider_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + provider_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + npi: Mapped[Optional[str]] = mapped_column(String(20), sort_order=300) + dea: Mapped[Optional[str]] = mapped_column(String(20), sort_order=400) + specialty_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=600) + year_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + specialty_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1000) + specialty_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + @declared_attr + def care_site(cls) -> Mapped["CareSite"]: + return relationship("CareSite", foreign_keys="Provider.care_site_id") + + @declared_attr + def gender_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.gender_concept_id") + + @declared_attr + def gender_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.gender_source_concept_id") + + @declared_attr + def specialty_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.specialty_concept_id") + + @declared_attr + def specialty_source_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Provider.specialty_source_concept_id") diff --git a/src/omop_cdm/dynamic/cdm600/metadata.py b/src/omop_cdm/dynamic/cdm600/metadata.py new file mode 100644 index 0000000..3fd9ad6 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm600/metadata.py @@ -0,0 +1,38 @@ +"""OMOP CDM metadata tables.""" + +import datetime +from typing import Optional + +from sqlalchemy import Date, DateTime, Integer, String, Text +from sqlalchemy.orm import Mapped, mapped_column + +from omop_cdm.constants import CDM_SCHEMA + + +class BaseCdmSourceCdm600: + __tablename__ = "cdm_source" + __table_args__ = {"schema": CDM_SCHEMA} + + cdm_source_name: Mapped[str] = mapped_column(String(255), primary_key=True, sort_order=100) + cdm_source_abbreviation: Mapped[Optional[str]] = mapped_column(String(25), sort_order=200) + cdm_holder: Mapped[Optional[str]] = mapped_column(String(255), sort_order=300) + source_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + source_documentation_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=500) + cdm_etl_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=600) + source_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + cdm_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + cdm_version: Mapped[Optional[str]] = mapped_column(String(10), sort_order=900) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + + +class BaseMetadataCdm600: + __tablename__ = "metadata" + __table_args__ = {"schema": CDM_SCHEMA} + + metadata_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + metadata_type_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + name: Mapped[str] = mapped_column(String(250), primary_key=True, sort_order=300) + value_as_string: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + metadata_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + metadata_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) diff --git a/src/omop_cdm/dynamic/cdm600/vocabularies.py b/src/omop_cdm/dynamic/cdm600/vocabularies.py new file mode 100644 index 0000000..3b6bf48 --- /dev/null +++ b/src/omop_cdm/dynamic/cdm600/vocabularies.py @@ -0,0 +1,280 @@ +""" +OMOP CDM vocabulary tables. + +CDM 6.0.0 check constraints are included. +""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import CheckConstraint, Date, DateTime, ForeignKey, Integer, Numeric, String +from sqlalchemy.ext.declarative import declared_attr +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CONCEPT_CLASS_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_VOCABULARY_ID, + VOCAB_SCHEMA, +) + + +class BaseConceptCdm600: + __tablename__ = "concept" + __table_args__ = ( + CheckConstraint("(COALESCE(invalid_reason,'D') in ('D','U'))", name="chk_c_invalid_reason"), + CheckConstraint("(COALESCE(standard_concept,'C') in ('C','S'))", name="chk_c_standard_concept"), + CheckConstraint("(concept_code <> '')", name="chk_c_concept_code"), + CheckConstraint("(concept_name <> '')", name="chk_c_concept_name"), + {"schema": VOCAB_SCHEMA}, + ) + + concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + concept_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), index=True, sort_order=300) + vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=400) + concept_class_id: Mapped[str] = mapped_column(ForeignKey(FK_CONCEPT_CLASS_ID), index=True, sort_order=500) + standard_concept: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + concept_code: Mapped[str] = mapped_column(String(50), index=True, sort_order=700) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1000) + + @declared_attr + def concept_class(cls) -> Mapped["ConceptClass"]: + return relationship("ConceptClass", foreign_keys="Concept.concept_class_id") + + @declared_attr + def domain(cls) -> Mapped["Domain"]: + return relationship("Domain", foreign_keys="Concept.domain_id") + + @declared_attr + def vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="Concept.vocabulary_id") + + +class BaseConceptAncestorCdm600: + __tablename__ = "concept_ancestor" + __table_args__ = {"schema": VOCAB_SCHEMA} + + ancestor_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + descendant_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + min_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=300) + max_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=400) + + @declared_attr + def ancestor_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptAncestor.ancestor_concept_id") + + @declared_attr + def descendant_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptAncestor.descendant_concept_id") + + +class BaseConceptClassCdm600: + __tablename__ = "concept_class" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_class_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + concept_class_name: Mapped[str] = mapped_column(String(255), sort_order=200) + concept_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + @declared_attr + def concept_class_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptClass.concept_class_concept_id") + + +class BaseConceptRelationshipCdm600: + __tablename__ = "concept_relationship" + __table_args__ = ( + CheckConstraint("(COALESCE(invalid_reason,'D')='D')", name="chk_cr_invalid_reason"), + {"schema": VOCAB_SCHEMA}, + ) + + concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200) + relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), primary_key=True, index=True, sort_order=300 + ) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + + @declared_attr + def concept_1(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptRelationship.concept_id_1") + + @declared_attr + def concept_2(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptRelationship.concept_id_2") + + @declared_attr + def relationship(cls) -> Mapped["Relationship"]: + return relationship("Relationship", foreign_keys="ConceptRelationship.relationship_id") + + +class BaseConceptSynonymCdm600: + __tablename__ = "concept_synonym" + __table_args__ = ( + # UniqueConstraint uq_concept_synonym is not added, because + # there is already a PK on the same columns + CheckConstraint("(concept_synonym_name <> '')", name="chk_csyn_concept_synonym_name"), + {"schema": VOCAB_SCHEMA}, + ) + + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_synonym_name: Mapped[str] = mapped_column(String(1000), primary_key=True, sort_order=200) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300) + + @declared_attr + def concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptSynonym.concept_id") + + @declared_attr + def language_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="ConceptSynonym.language_concept_id") + + +class BaseDomainCdm600: + __tablename__ = "domain" + __table_args__ = {"schema": VOCAB_SCHEMA} + + domain_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + domain_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + @declared_attr + def domain_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Domain.domain_concept_id") + + +class BaseDrugStrengthCdm600: + __tablename__ = "drug_strength" + __table_args__ = {"schema": VOCAB_SCHEMA} + + drug_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + ingredient_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + amount_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=300) + amount_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + numerator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=500) + numerator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + denominator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + denominator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + box_size: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1100) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + + @declared_attr + def amount_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.amount_unit_concept_id") + + @declared_attr + def denominator_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.denominator_unit_concept_id") + + @declared_attr + def drug_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.drug_concept_id") + + @declared_attr + def ingredient_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.ingredient_concept_id") + + @declared_attr + def numerator_unit_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="DrugStrength.numerator_unit_concept_id") + + +class BaseRelationshipCdm600: + __tablename__ = "relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + relationship_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + relationship_name: Mapped[str] = mapped_column(String(255), sort_order=200) + is_hierarchical: Mapped[str] = mapped_column(String(1), sort_order=300) + defines_ancestry: Mapped[str] = mapped_column(String(1), sort_order=400) + reverse_relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), sort_order=500 + ) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + + @declared_attr + def relationship_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Relationship.relationship_concept_id") + + @declared_attr + def reverse_relationship(cls) -> Mapped["Relationship"]: + return relationship("Relationship", foreign_keys="Relationship.reverse_relationship_id") + + +class BaseVocabularyCdm600: + __tablename__ = "vocabulary" + __table_args__ = {"schema": VOCAB_SCHEMA} + + vocabulary_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + vocabulary_name: Mapped[str] = mapped_column(String(255), sort_order=200) + vocabulary_reference: Mapped[str] = mapped_column(String(255), sort_order=300) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + vocabulary_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + @declared_attr + def vocabulary_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="Vocabulary.vocabulary_concept_id") + + +class BaseSourceToConceptMapCdm600: + __tablename__ = "source_to_concept_map" + __table_args__ = {"schema": CDM_SCHEMA} + + source_code: Mapped[str] = mapped_column(String(1000), primary_key=True, index=True, sort_order=100) + source_concept_id: Mapped[int] = mapped_column(Integer, sort_order=200) + source_vocabulary_id: Mapped[str] = mapped_column( + ForeignKey(FK_VOCABULARY_ID), primary_key=True, index=True, sort_order=300 + ) + source_code_description: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + target_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + target_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=600) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=800) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=900) + + @declared_attr + def source_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMap.source_vocabulary_id") + + @declared_attr + def target_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="SourceToConceptMap.target_concept_id") + + @declared_attr + def target_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMap.target_vocabulary_id") + + +class BaseSourceToConceptMapVersionCdm600: + __tablename__ = "source_to_concept_map_version" + __table_args__ = {"schema": CDM_SCHEMA} + + source_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), primary_key=True, sort_order=100) + stcm_version: Mapped[str] = mapped_column(String(255), sort_order=200) + last_upload_date: Mapped[datetime.datetime] = mapped_column( + DateTime, default=datetime.datetime.utcnow, sort_order=300 + ) + + @declared_attr + def source_vocabulary(cls) -> Mapped["Vocabulary"]: + return relationship("Vocabulary", foreign_keys="SourceToConceptMapVersion.source_vocabulary_id") diff --git a/src/omop_cdm/dynamic/legacy/__init__.py b/src/omop_cdm/dynamic/legacy/__init__.py new file mode 100644 index 0000000..08cbb71 --- /dev/null +++ b/src/omop_cdm/dynamic/legacy/__init__.py @@ -0,0 +1 @@ +"""Legacy CDM tables package.""" diff --git a/src/omop_cdm/dynamic/legacy/legacy.py b/src/omop_cdm/dynamic/legacy/legacy.py new file mode 100644 index 0000000..4f62e30 --- /dev/null +++ b/src/omop_cdm/dynamic/legacy/legacy.py @@ -0,0 +1,96 @@ +"""OMOP CDM legacy tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import Date, ForeignKey, Integer, Numeric, String, Text +from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship + +from omop_cdm.constants import CDM_SCHEMA, FK_CONCEPT_ID + +FK_COHORT_DEFINITION_ID = f"{CDM_SCHEMA}.cohort_definition.cohort_definition_id" + + +class BaseCohort: + __tablename__ = "cohort" + __table_args__ = {"schema": CDM_SCHEMA} + + cohort_definition_id: Mapped[int] = mapped_column( + ForeignKey(FK_COHORT_DEFINITION_ID), primary_key=True, index=True, sort_order=100 + ) + subject_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=200) + cohort_start_date: Mapped[Date] = mapped_column(Date, primary_key=True, sort_order=300) + cohort_end_date: Mapped[Date] = mapped_column(Date, primary_key=True, sort_order=400) + + @declared_attr + def cohort_definition(cls) -> Mapped["CohortDefinition"]: + return relationship("CohortDefinition") + + +class BaseCohortDefinition: + __tablename__ = "cohort_definition" + __table_args__ = {"schema": CDM_SCHEMA} + + cohort_definition_id: Mapped[Integer] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + cohort_definition_name: Mapped[str] = mapped_column(String(255), sort_order=200) + cohort_definition_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=300) + definition_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + cohort_definition_syntax: Mapped[Optional[str]] = mapped_column(Text, sort_order=500) + subject_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + cohort_initiation_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + + @declared_attr + def definition_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="CohortDefinition.definition_type_concept_id") + + @declared_attr + def subject_concept(cls) -> Mapped["Concept"]: + return relationship("Concept", foreign_keys="CohortDefinition.subject_concept_id") + + +class BaseCohortAttribute: + __tablename__ = "cohort_attribute" + __table_args__ = {"schema": CDM_SCHEMA} + + cohort_definition_id: Mapped[int] = mapped_column( + ForeignKey(FK_COHORT_DEFINITION_ID), primary_key=True, index=True, sort_order=100 + ) + subject_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + cohort_start_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=300) + cohort_end_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=400) + attribute_definition_id: Mapped[int] = mapped_column( + ForeignKey(f"{CDM_SCHEMA}.attribute_definition.attribute_definition_id"), + primary_key=True, + index=True, + sort_order=500, + ) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=600) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + + @declared_attr + def cohort_definition(cls) -> Mapped["CohortDefinition"]: + return relationship("CohortDefinition") + + @declared_attr + def attribute_definition(cls) -> Mapped["AttributeDefinition"]: + return relationship("AttributeDefinition") + + @declared_attr + def value_as_concept(cls) -> Mapped["Concept"]: + return relationship("Concept") + + +class BaseAttributeDefinition: + __tablename__ = "attribute_definition" + __table_args__ = {"schema": CDM_SCHEMA} + + attribute_definition_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + attribute_name: Mapped[str] = mapped_column(String(255), sort_order=200) + attribute_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=300) + attribute_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + attribute_syntax: Mapped[Optional[str]] = mapped_column(Text, sort_order=500) + + @declared_attr + def attribute_type_concept(cls) -> Mapped["Concept"]: + return relationship("Concept") diff --git a/src/omop_cdm/dynamic/ruff.toml b/src/omop_cdm/dynamic/ruff.toml new file mode 100644 index 0000000..abd25ec --- /dev/null +++ b/src/omop_cdm/dynamic/ruff.toml @@ -0,0 +1,10 @@ +# Extend the `ruff.toml` file in the root directory... +extend = "../../../ruff.toml" + +# Allow a longer line length for easier to navigate table definitions +line-length = 119 + +[lint] +ignore = [ + "F821", # Allow unresolved return types for relationships +] diff --git a/src/omop_cdm/regular/cdm531/__init__.py b/src/omop_cdm/regular/cdm531/__init__.py new file mode 100644 index 0000000..e2e99ed --- /dev/null +++ b/src/omop_cdm/regular/cdm531/__init__.py @@ -0,0 +1,100 @@ +""" +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 + +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 + +""" + +from omop_cdm.regular.cdm531.tables import ( + BaseCdm531, + CareSite, + CdmSource, + Concept, + ConceptAncestor, + ConceptClass, + ConceptRelationship, + ConceptSynonym, + ConditionEra, + ConditionOccurrence, + Cost, + Death, + DeviceExposure, + Domain, + DoseEra, + DrugEra, + DrugExposure, + DrugStrength, + FactRelationship, + Location, + Measurement, + Metadata, + Note, + NoteNlp, + Observation, + ObservationPeriod, + PayerPlanPeriod, + Person, + ProcedureOccurrence, + Provider, + Relationship, + SourceToConceptMap, + Specimen, + VisitDetail, + VisitOccurrence, + Vocabulary, +) + +__all__ = [ + "BaseCdm531", + "Person", + "Death", + "Note", + "Measurement", + "NoteNlp", + "Observation", + "Specimen", + "VisitDetail", + "ConditionOccurrence", + "DeviceExposure", + "DrugExposure", + "FactRelationship", + "ObservationPeriod", + "ProcedureOccurrence", + "VisitOccurrence", + "CareSite", + "Location", + "Provider", + "Cost", + "PayerPlanPeriod", + "DoseEra", + "DrugEra", + "ConditionEra", + "Metadata", + "CdmSource", + "Vocabulary", + "SourceToConceptMap", + "Concept", + "ConceptAncestor", + "ConceptClass", + "ConceptRelationship", + "ConceptSynonym", + "Domain", + "DrugStrength", + "Relationship", +] diff --git a/src/omop_cdm/regular/cdm531/tables.py b/src/omop_cdm/regular/cdm531/tables.py new file mode 100644 index 0000000..3fef7e2 --- /dev/null +++ b/src/omop_cdm/regular/cdm531/tables.py @@ -0,0 +1,980 @@ +"""OMOP CDM 5.3.1 tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import Date, DateTime, ForeignKey, Integer, MetaData, Numeric, String, Text +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship + +from omop_cdm import NAMING_CONVENTION +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CARE_SITE_ID, + FK_CONCEPT_CLASS_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_LOCATION_ID, + FK_PERSON_ID, + FK_PROVIDER_ID, + FK_VISIT_DETAIL_ID, + FK_VISIT_OCCURRENCE_ID, + FK_VOCABULARY_ID, + VOCAB_SCHEMA, +) + + +class BaseCdm531(DeclarativeBase): + pass + + +BaseCdm531.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class ConditionOccurrence(BaseCdm531): + __tablename__ = "condition_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + condition_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + condition_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + condition_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + condition_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + condition_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + condition_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + condition_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + condition_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_concept_id" + ) + condition_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_source_concept_id" + ) + condition_status_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_status_concept_id" + ) + condition_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ConditionOccurrence.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="ConditionOccurrence.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="ConditionOccurrence.visit_detail_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="ConditionOccurrence.visit_occurrence_id" + ) + + +class Death(BaseCdm531): + __tablename__ = "death" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), primary_key=True, index=True, sort_order=100) + death_date: Mapped[datetime.date] = mapped_column(Date, sort_order=200) + death_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=300) + death_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + cause_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + cause_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + cause_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + + cause_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Death.cause_concept_id") + cause_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Death.cause_source_concept_id") + death_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Death.death_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Death.person_id") + + +class DeviceExposure(BaseCdm531): + __tablename__ = "device_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + device_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + device_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + device_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + device_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + device_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + device_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + device_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + device_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + device_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + + device_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DeviceExposure.device_concept_id") + device_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DeviceExposure.device_source_concept_id" + ) + device_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DeviceExposure.device_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="DeviceExposure.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="DeviceExposure.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="DeviceExposure.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="DeviceExposure.visit_occurrence_id" + ) + + +class DrugExposure(BaseCdm531): + __tablename__ = "drug_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + drug_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + drug_exposure_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + drug_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + drug_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1300) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=1400) + route_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1700) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1800 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1900) + drug_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drug_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2300) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.drug_concept_id") + drug_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugExposure.drug_source_concept_id" + ) + drug_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.drug_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DrugExposure.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="DrugExposure.provider_id") + route_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.route_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="DrugExposure.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="DrugExposure.visit_occurrence_id" + ) + + +class FactRelationship(BaseCdm531): + __tablename__ = "fact_relationship" + __table_args__ = {"schema": CDM_SCHEMA} + + domain_concept_id_1: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + fact_id_1: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + domain_concept_id_2: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=300 + ) + fact_id_2: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=400) + relationship_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + + domain_concept_1: Mapped["Concept"] = relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_1") + domain_concept_2: Mapped["Concept"] = relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_2") + relationship_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="FactRelationship.relationship_concept_id" + ) + + +class Measurement(BaseCdm531): + __tablename__ = "measurement" + __table_args__ = {"schema": CDM_SCHEMA} + + measurement_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + measurement_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + measurement_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + measurement_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + measurement_time: Mapped[Optional[str]] = mapped_column(String(10), sort_order=600) + measurement_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1400) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1500 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1600) + measurement_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + measurement_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + + measurement_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.measurement_concept_id") + measurement_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Measurement.measurement_source_concept_id" + ) + measurement_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Measurement.measurement_type_concept_id" + ) + operator_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.operator_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Measurement.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Measurement.provider_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.unit_concept_id") + value_as_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.value_as_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Measurement.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Measurement.visit_occurrence_id" + ) + + +class Note(BaseCdm531): + __tablename__ = "note" + __table_args__ = {"schema": CDM_SCHEMA} + + note_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + note_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + note_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=400) + note_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=500) + note_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + note_title: Mapped[Optional[str]] = mapped_column(String(250), sort_order=700) + note_text: Mapped[str] = mapped_column(Text, sort_order=800) + encoding_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + note_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + + encoding_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.encoding_concept_id") + language_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.language_concept_id") + note_class_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.note_class_concept_id") + note_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.note_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Note.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Note.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Note.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Note.visit_occurrence_id" + ) + + +class NoteNlp(BaseCdm531): + __tablename__ = "note_nlp" + __table_args__ = {"schema": CDM_SCHEMA} + + note_nlp_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + note_id: Mapped[int] = mapped_column(ForeignKey(f"{CDM_SCHEMA}.note.note_id"), index=True, sort_order=200) + section_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + snippet: Mapped[Optional[str]] = mapped_column(String(250), sort_order=400) + offset: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + lexical_variant: Mapped[str] = mapped_column(String(250), sort_order=600) + note_nlp_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + note_nlp_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + nlp_system: Mapped[Optional[str]] = mapped_column(String(250), sort_order=900) + nlp_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + nlp_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1100) + term_exists: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + term_temporal: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + term_modifiers: Mapped[Optional[str]] = mapped_column(String(2000), sort_order=1400) + + note: Mapped["Note"] = relationship("Note", foreign_keys="NoteNlp.note_id") + note_nlp_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="NoteNlp.note_nlp_concept_id") + note_nlp_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="NoteNlp.note_nlp_source_concept_id" + ) + section_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="NoteNlp.section_concept_id") + + +class Observation(BaseCdm531): + __tablename__ = "observation" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + observation_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + observation_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + observation_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=800) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1300 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1400) + observation_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + observation_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + + observation_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.observation_concept_id") + observation_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.observation_source_concept_id" + ) + observation_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.observation_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="Observation.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Observation.provider_id") + qualifier_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.qualifier_concept_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.unit_concept_id") + value_as_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.value_as_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Observation.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Observation.visit_occurrence_id" + ) + + +class ObservationPeriod(BaseCdm531): + __tablename__ = "observation_period" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_period_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + observation_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + period_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + period_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ObservationPeriod.period_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ObservationPeriod.person_id") + + +class Person(BaseCdm531): + __tablename__ = "person" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=200) + year_of_birth: Mapped[int] = mapped_column(Integer, sort_order=300) + month_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=400) + day_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + birth_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + race_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + ethnicity_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=900) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1000) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1100) + person_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + race_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + race_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + ethnicity_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + ethnicity_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="Person.care_site_id") + ethnicity_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.ethnicity_concept_id") + ethnicity_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Person.ethnicity_source_concept_id" + ) + gender_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.gender_concept_id") + gender_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.gender_source_concept_id") + location: Mapped["Location"] = relationship("Location", foreign_keys="Person.location_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Person.provider_id") + race_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.race_concept_id") + race_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.race_source_concept_id") + + +class ProcedureOccurrence(BaseCdm531): + __tablename__ = "procedure_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + procedure_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + procedure_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + procedure_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + procedure_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + procedure_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + modifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1000 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1100) + procedure_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + procedure_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + + modifier_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.modifier_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ProcedureOccurrence.person_id") + procedure_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_concept_id" + ) + procedure_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_source_concept_id" + ) + procedure_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_type_concept_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="ProcedureOccurrence.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="ProcedureOccurrence.visit_detail_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="ProcedureOccurrence.visit_occurrence_id" + ) + + +class Specimen(BaseCdm531): + __tablename__ = "specimen" + __table_args__ = {"schema": CDM_SCHEMA} + + specimen_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + specimen_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + specimen_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + specimen_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + specimen_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + anatomic_site_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + disease_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + specimen_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + + anatomic_site_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.anatomic_site_concept_id" + ) + disease_status_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.disease_status_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="Specimen.person_id") + specimen_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Specimen.specimen_concept_id") + specimen_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.specimen_type_concept_id" + ) + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Specimen.unit_concept_id") + + +class VisitDetail(BaseCdm531): + __tablename__ = "visit_detail" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_detail_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_detail_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_detail_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_detail_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_detail_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_detail_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_detail_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_detail_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_detail_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitting_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + admitting_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + discharge_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + preceding_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1700) + visit_detail_parent_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1800) + visit_occurrence_id: Mapped[int] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1900) + + admitting_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.admitting_source_concept_id" + ) + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="VisitDetail.care_site_id") + discharge_to_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.discharge_to_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="VisitDetail.person_id") + preceding_visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="VisitDetail.preceding_visit_detail_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="VisitDetail.provider_id") + visit_detail_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_concept_id" + ) + visit_detail_parent: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="VisitDetail.visit_detail_parent_id" + ) + visit_detail_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_source_concept_id" + ) + visit_detail_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_type_concept_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="VisitDetail.visit_occurrence_id" + ) + + +class VisitOccurrence(BaseCdm531): + __tablename__ = "visit_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitting_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitting_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharge_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + preceding_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1700 + ) + + admitting_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.admitting_source_concept_id" + ) + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="VisitOccurrence.care_site_id") + discharge_to_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.discharge_to_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="VisitOccurrence.person_id") + preceding_visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="VisitOccurrence.preceding_visit_occurrence_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="VisitOccurrence.provider_id") + visit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="VisitOccurrence.visit_concept_id") + visit_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.visit_source_concept_id" + ) + visit_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.visit_type_concept_id" + ) + + +class ConditionEra(BaseCdm531): + __tablename__ = "condition_era" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + condition_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_occurrence_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + + condition_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConditionEra.condition_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="ConditionEra.person_id") + + +class DoseEra(BaseCdm531): + __tablename__ = "dose_era" + __table_args__ = {"schema": CDM_SCHEMA} + + dose_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + unit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + dose_value: Mapped[decimal.Decimal] = mapped_column(Numeric, sort_order=500) + dose_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + dose_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DoseEra.drug_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DoseEra.person_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DoseEra.unit_concept_id") + + +class DrugEra(BaseCdm531): + __tablename__ = "drug_era" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + drug_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + gap_days: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugEra.drug_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DrugEra.person_id") + + +class PayerPlanPeriod(BaseCdm531): + __tablename__ = "payer_plan_period" + __table_args__ = {"schema": CDM_SCHEMA} + + payer_plan_period_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + payer_plan_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + payer_plan_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + payer_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + payer_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + payer_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + plan_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + plan_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + plan_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + sponsor_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + sponsor_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + sponsor_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + family_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + stop_reason_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + stop_reason_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + stop_reason_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + + payer_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.payer_concept_id") + payer_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.payer_source_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="PayerPlanPeriod.person_id") + plan_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.plan_concept_id") + plan_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.plan_source_concept_id" + ) + sponsor_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_concept_id") + sponsor_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.sponsor_source_concept_id" + ) + stop_reason_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.stop_reason_concept_id" + ) + stop_reason_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.stop_reason_source_concept_id" + ) + + +class Cost(BaseCdm531): + __tablename__ = "cost" + __table_args__ = {"schema": CDM_SCHEMA} + + cost_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + cost_event_id: Mapped[int] = mapped_column(Integer, sort_order=200) + cost_domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), sort_order=300) + cost_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + currency_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + total_charge: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=600) + total_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + total_paid: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=800) + paid_by_payer: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + paid_by_patient: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1000) + paid_patient_copay: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + paid_patient_coinsurance: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + paid_patient_deductible: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + paid_by_primary: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1400) + paid_ingredient_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1500) + paid_dispensing_fee: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1600) + payer_plan_period_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(f"{CDM_SCHEMA}.payer_plan_period.payer_plan_period_id"), sort_order=1700 + ) + amount_allowed: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1800) + revenue_code_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + revenue_code_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drg_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + drg_source_value: Mapped[Optional[str]] = mapped_column(String(3), sort_order=2200) + + cost_domain: Mapped["Domain"] = relationship("Domain", foreign_keys="Cost.cost_domain_id") + cost_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.cost_type_concept_id") + currency_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.currency_concept_id") + drg_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.drg_concept_id") + payer_plan_period: Mapped["PayerPlanPeriod"] = relationship( + "PayerPlanPeriod", foreign_keys="Cost.payer_plan_period_id" + ) + revenue_code_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.revenue_code_concept_id") + + +class CareSite(BaseCdm531): + __tablename__ = "care_site" + __table_args__ = {"schema": CDM_SCHEMA} + + care_site_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + care_site_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + place_of_service_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=400) + care_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + place_of_service_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + + location: Mapped["Location"] = relationship("Location") + place_of_service_concept: Mapped["Concept"] = relationship("Concept") + + +class Location(BaseCdm531): + __tablename__ = "location" + __table_args__ = {"schema": CDM_SCHEMA} + + location_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + address_1: Mapped[Optional[str]] = mapped_column(String(50), sort_order=200) + address_2: Mapped[Optional[str]] = mapped_column(String(50), sort_order=300) + city: Mapped[Optional[str]] = mapped_column(String(50), sort_order=400) + state: Mapped[Optional[str]] = mapped_column(String(2), sort_order=500) + zip: Mapped[Optional[str]] = mapped_column(String(9), sort_order=600) + county: Mapped[Optional[str]] = mapped_column(String(20), sort_order=700) + location_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=800) + + +class Provider(BaseCdm531): + __tablename__ = "provider" + __table_args__ = {"schema": CDM_SCHEMA} + + provider_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + provider_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + npi: Mapped[Optional[str]] = mapped_column(String(20), sort_order=300) + dea: Mapped[Optional[str]] = mapped_column(String(20), sort_order=400) + specialty_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=600) + year_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + gender_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + specialty_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1000) + specialty_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="Provider.care_site_id") + gender_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Provider.gender_concept_id") + gender_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Provider.gender_source_concept_id" + ) + specialty_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Provider.specialty_concept_id") + specialty_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Provider.specialty_source_concept_id" + ) + + +class CdmSource(BaseCdm531): + __tablename__ = "cdm_source" + __table_args__ = {"schema": CDM_SCHEMA} + + cdm_source_name: Mapped[str] = mapped_column(String(255), primary_key=True, sort_order=100) + cdm_source_abbreviation: Mapped[Optional[str]] = mapped_column(String(25), sort_order=200) + cdm_holder: Mapped[Optional[str]] = mapped_column(String(255), sort_order=300) + source_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + source_documentation_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=500) + cdm_etl_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=600) + source_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + cdm_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + cdm_version: Mapped[Optional[str]] = mapped_column(String(10), sort_order=900) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + + +class Metadata(BaseCdm531): + __tablename__ = "metadata" + __table_args__ = {"schema": CDM_SCHEMA} + + metadata_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + metadata_type_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + name: Mapped[str] = mapped_column(String(250), primary_key=True, sort_order=300) + value_as_string: Mapped[Optional[str]] = mapped_column(String, sort_order=400) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + metadata_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + metadata_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + + +class Concept(BaseCdm531): + __tablename__ = "concept" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + concept_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), index=True, sort_order=300) + vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=400) + concept_class_id: Mapped[str] = mapped_column(ForeignKey(FK_CONCEPT_CLASS_ID), index=True, sort_order=500) + standard_concept: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + concept_code: Mapped[str] = mapped_column(String(50), index=True, sort_order=700) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1000) + + concept_class: Mapped["ConceptClass"] = relationship("ConceptClass", foreign_keys="Concept.concept_class_id") + domain: Mapped["Domain"] = relationship("Domain", foreign_keys="Concept.domain_id") + vocabulary: Mapped["Vocabulary"] = relationship("Vocabulary", foreign_keys="Concept.vocabulary_id") + + +class ConceptAncestor(BaseCdm531): + __tablename__ = "concept_ancestor" + __table_args__ = {"schema": VOCAB_SCHEMA} + + ancestor_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + descendant_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + min_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=300) + max_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=400) + + ancestor_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptAncestor.ancestor_concept_id") + descendant_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConceptAncestor.descendant_concept_id" + ) + + +class ConceptClass(BaseCdm531): + __tablename__ = "concept_class" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_class_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + concept_class_name: Mapped[str] = mapped_column(String(255), sort_order=200) + concept_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + concept_class_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConceptClass.concept_class_concept_id" + ) + + +class ConceptRelationship(BaseCdm531): + __tablename__ = "concept_relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200) + relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), primary_key=True, index=True, sort_order=300 + ) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + + concept_1: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptRelationship.concept_id_1") + concept_2: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptRelationship.concept_id_2") + relationship: Mapped["Relationship"] = relationship( + "Relationship", foreign_keys="ConceptRelationship.relationship_id" + ) + + +class ConceptSynonym(BaseCdm531): + __tablename__ = "concept_synonym" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_synonym_name: Mapped[str] = mapped_column(String(1000), primary_key=True, sort_order=200) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300) + + concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptSynonym.concept_id") + language_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptSynonym.language_concept_id") + + +class Domain(BaseCdm531): + __tablename__ = "domain" + __table_args__ = {"schema": VOCAB_SCHEMA} + + domain_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + domain_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + domain_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Domain.domain_concept_id") + + +class DrugStrength(BaseCdm531): + __tablename__ = "drug_strength" + __table_args__ = {"schema": VOCAB_SCHEMA} + + drug_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + ingredient_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + amount_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=300) + amount_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + numerator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=500) + numerator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + denominator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + denominator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + box_size: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1100) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + + amount_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.amount_unit_concept_id" + ) + denominator_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.denominator_unit_concept_id" + ) + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugStrength.drug_concept_id") + ingredient_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugStrength.ingredient_concept_id") + numerator_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.numerator_unit_concept_id" + ) + + +class Relationship(BaseCdm531): + __tablename__ = "relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + relationship_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + relationship_name: Mapped[str] = mapped_column(String(255), sort_order=200) + is_hierarchical: Mapped[str] = mapped_column(String(1), sort_order=300) + defines_ancestry: Mapped[str] = mapped_column(String(1), sort_order=400) + reverse_relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), sort_order=500 + ) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + + relationship_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Relationship.relationship_concept_id" + ) + reverse_relationship: Mapped["Relationship"] = relationship( + "Relationship", foreign_keys="Relationship.reverse_relationship_id" + ) + + +class Vocabulary(BaseCdm531): + __tablename__ = "vocabulary" + __table_args__ = {"schema": VOCAB_SCHEMA} + + vocabulary_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + vocabulary_name: Mapped[str] = mapped_column(String(255), sort_order=200) + vocabulary_reference: Mapped[str] = mapped_column(String(255), sort_order=300) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + vocabulary_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + vocabulary_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Vocabulary.vocabulary_concept_id") + + +class SourceToConceptMap(BaseCdm531): + __tablename__ = "source_to_concept_map" + __table_args__ = {"schema": CDM_SCHEMA} + + source_code: Mapped[str] = mapped_column(String(1000), primary_key=True, index=True, sort_order=100) + source_concept_id: Mapped[int] = mapped_column(Integer, sort_order=200) + source_vocabulary_id: Mapped[str] = mapped_column( + ForeignKey(FK_VOCABULARY_ID), primary_key=True, index=True, sort_order=300 + ) + source_code_description: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + target_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + target_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=600) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=800) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=900) + + source_vocabulary: Mapped["Vocabulary"] = relationship( + "Vocabulary", foreign_keys="SourceToConceptMap.source_vocabulary_id" + ) + target_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="SourceToConceptMap.target_concept_id") + target_vocabulary: Mapped["Vocabulary"] = relationship( + "Vocabulary", foreign_keys="SourceToConceptMap.target_vocabulary_id" + ) diff --git a/src/omop_cdm/regular/cdm54/__init__.py b/src/omop_cdm/regular/cdm54/__init__.py new file mode 100644 index 0000000..da8b94f --- /dev/null +++ b/src/omop_cdm/regular/cdm54/__init__.py @@ -0,0 +1,103 @@ +""" +OMOP CDM Version 5.4. + +Generated from OMOP CDM release 5.4 using sqlacodegen 3.0.0rc5. +DDL from https://github.com/OHDSI/CommonDataModel/tree/v5.4 + + +Deviations from standard model + +Removed + +cohort +cohort_attribute + +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 + +""" + +from omop_cdm.regular.cdm54.tables import ( + BaseCdm54, + CareSite, + CdmSource, + Concept, + ConceptAncestor, + ConceptClass, + ConceptRelationship, + ConceptSynonym, + ConditionEra, + ConditionOccurrence, + Cost, + Death, + DeviceExposure, + Domain, + DoseEra, + DrugEra, + DrugExposure, + DrugStrength, + Episode, + EpisodeEvent, + FactRelationship, + Location, + Measurement, + Metadata, + Note, + NoteNlp, + Observation, + ObservationPeriod, + PayerPlanPeriod, + Person, + ProcedureOccurrence, + Provider, + Relationship, + SourceToConceptMap, + Specimen, + VisitDetail, + VisitOccurrence, + Vocabulary, +) + +__all__ = [ + "BaseCdm54", + "Person", + "Death", + "Note", + "Measurement", + "NoteNlp", + "Observation", + "Specimen", + "VisitDetail", + "ConditionOccurrence", + "DeviceExposure", + "DrugExposure", + "FactRelationship", + "ObservationPeriod", + "ProcedureOccurrence", + "VisitOccurrence", + "CareSite", + "Location", + "Provider", + "Cost", + "PayerPlanPeriod", + "DoseEra", + "DrugEra", + "ConditionEra", + "Episode", + "EpisodeEvent", + "Metadata", + "CdmSource", + "Vocabulary", + "SourceToConceptMap", + "Concept", + "ConceptAncestor", + "ConceptClass", + "ConceptRelationship", + "ConceptSynonym", + "Domain", + "DrugStrength", + "Relationship", +] diff --git a/src/omop_cdm/regular/cdm54/tables.py b/src/omop_cdm/regular/cdm54/tables.py new file mode 100644 index 0000000..e0c6fdd --- /dev/null +++ b/src/omop_cdm/regular/cdm54/tables.py @@ -0,0 +1,1070 @@ +"""OMOP CDM v5.4 tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import BigInteger, Date, DateTime, ForeignKey, Integer, MetaData, Numeric, String, Text +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship + +from omop_cdm import NAMING_CONVENTION +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CARE_SITE_ID, + FK_CONCEPT_CLASS_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_LOCATION_ID, + FK_PERSON_ID, + FK_PROVIDER_ID, + FK_VISIT_DETAIL_ID, + FK_VISIT_OCCURRENCE_ID, + FK_VOCABULARY_ID, + VOCAB_SCHEMA, +) + + +class BaseCdm54(DeclarativeBase): + pass + + +BaseCdm54.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class Concept(BaseCdm54): + __tablename__ = "concept" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + concept_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), index=True, sort_order=300) + vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=400) + concept_class_id: Mapped[str] = mapped_column(ForeignKey(FK_CONCEPT_CLASS_ID), index=True, sort_order=500) + standard_concept: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + concept_code: Mapped[str] = mapped_column(String(50), index=True, sort_order=700) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1000) + + concept_class: Mapped["ConceptClass"] = relationship("ConceptClass", foreign_keys="Concept.concept_class_id") + domain: Mapped["Domain"] = relationship("Domain", foreign_keys="Concept.domain_id") + vocabulary: Mapped["Vocabulary"] = relationship("Vocabulary", foreign_keys="Concept.vocabulary_id") + + +class ConceptClass(BaseCdm54): + __tablename__ = "concept_class" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_class_id: Mapped[str] = mapped_column(String(20), primary_key=True, index=True, sort_order=100) + concept_class_name: Mapped[str] = mapped_column(String(255), sort_order=200) + concept_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + concept_class_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConceptClass.concept_class_concept_id" + ) + + +class Domain(BaseCdm54): + __tablename__ = "domain" + __table_args__ = {"schema": VOCAB_SCHEMA} + + domain_id: Mapped[str] = mapped_column(String(20), primary_key=True, index=True, sort_order=100) + domain_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + domain_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Domain.domain_concept_id") + + +class Vocabulary(BaseCdm54): + __tablename__ = "vocabulary" + __table_args__ = {"schema": VOCAB_SCHEMA} + + vocabulary_id: Mapped[str] = mapped_column(String(20), primary_key=True, index=True, sort_order=100) + vocabulary_name: Mapped[str] = mapped_column(String(255), sort_order=200) + vocabulary_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=300) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + vocabulary_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + vocabulary_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Vocabulary.vocabulary_concept_id") + + +class ConceptAncestor(BaseCdm54): + __tablename__ = "concept_ancestor" + __table_args__ = {"schema": VOCAB_SCHEMA} + + ancestor_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + descendant_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + min_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=300) + max_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=400) + + ancestor_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptAncestor.ancestor_concept_id") + descendant_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConceptAncestor.descendant_concept_id" + ) + + +class ConceptSynonym(BaseCdm54): + __tablename__ = "concept_synonym" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_synonym_name: Mapped[str] = mapped_column(String(1000), primary_key=True, sort_order=200) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300) + + concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptSynonym.concept_id") + language_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptSynonym.language_concept_id") + + +class DrugStrength(BaseCdm54): + __tablename__ = "drug_strength" + __table_args__ = {"schema": VOCAB_SCHEMA} + + drug_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + ingredient_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + amount_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=300) + amount_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + numerator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=500) + numerator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + denominator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + denominator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + box_size: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1100) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + + amount_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.amount_unit_concept_id" + ) + denominator_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.denominator_unit_concept_id" + ) + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugStrength.drug_concept_id") + ingredient_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugStrength.ingredient_concept_id") + numerator_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.numerator_unit_concept_id" + ) + + +class Relationship(BaseCdm54): + __tablename__ = "relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + relationship_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + relationship_name: Mapped[str] = mapped_column(String(255), sort_order=200) + is_hierarchical: Mapped[str] = mapped_column(String(1), sort_order=300) + defines_ancestry: Mapped[str] = mapped_column(String(1), sort_order=400) + reverse_relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), sort_order=500 + ) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + + relationship_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Relationship.relationship_concept_id" + ) + reverse_relationship: Mapped["Relationship"] = relationship( + "Relationship", foreign_keys="Relationship.reverse_relationship_id" + ) + + +class ConceptRelationship(BaseCdm54): + __tablename__ = "concept_relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200) + relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), primary_key=True, index=True, sort_order=300 + ) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + + concept_1: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptRelationship.concept_id_1") + concept_2: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptRelationship.concept_id_2") + relationship: Mapped["Relationship"] = relationship( + "Relationship", foreign_keys="ConceptRelationship.relationship_id" + ) + + +class SourceToConceptMap(BaseCdm54): + __tablename__ = "source_to_concept_map" + __table_args__ = {"schema": CDM_SCHEMA} + + source_code: Mapped[str] = mapped_column(String(1000), primary_key=True, index=True, sort_order=100) + source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=200) + source_vocabulary_id: Mapped[str] = mapped_column( + ForeignKey(FK_VOCABULARY_ID), primary_key=True, index=True, sort_order=300 + ) + source_code_description: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + target_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + target_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=600) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=800) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=900) + + source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="SourceToConceptMap.source_concept_id") + source_vocabulary: Mapped["Vocabulary"] = relationship( + "Vocabulary", foreign_keys="SourceToConceptMap.source_vocabulary_id" + ) + target_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="SourceToConceptMap.target_concept_id") + target_vocabulary: Mapped["Vocabulary"] = relationship( + "Vocabulary", foreign_keys="SourceToConceptMap.target_vocabulary_id" + ) + + +class ConditionOccurrence(BaseCdm54): + __tablename__ = "condition_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + condition_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + condition_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + condition_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + condition_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + condition_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + condition_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + condition_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + condition_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_concept_id" + ) + condition_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_source_concept_id" + ) + condition_status_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_status_concept_id" + ) + condition_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ConditionOccurrence.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="ConditionOccurrence.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="ConditionOccurrence.visit_detail_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="ConditionOccurrence.visit_occurrence_id" + ) + + +class Death(BaseCdm54): + __tablename__ = "death" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), primary_key=True, index=True, sort_order=100) + death_date: Mapped[datetime.date] = mapped_column(Date, sort_order=200) + death_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=300) + death_type_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + cause_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + cause_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + cause_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + + cause_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Death.cause_concept_id") + cause_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Death.cause_source_concept_id") + death_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Death.death_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Death.person_id") + + +class FactRelationship(BaseCdm54): + __tablename__ = "fact_relationship" + __table_args__ = {"schema": CDM_SCHEMA} + + domain_concept_id_1: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + fact_id_1: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + domain_concept_id_2: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=300 + ) + fact_id_2: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=400) + relationship_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + + domain_concept_1: Mapped["Concept"] = relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_1") + domain_concept_2: Mapped["Concept"] = relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_2") + relationship_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="FactRelationship.relationship_concept_id" + ) + + +class NoteNlp(BaseCdm54): + __tablename__ = "note_nlp" + __table_args__ = {"schema": CDM_SCHEMA} + + note_nlp_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + note_id: Mapped[int] = mapped_column(Integer, index=True, sort_order=200) + section_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + snippet: Mapped[Optional[str]] = mapped_column(String(250), sort_order=400) + offset: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + lexical_variant: Mapped[str] = mapped_column(String(250), sort_order=600) + note_nlp_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + note_nlp_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + nlp_system: Mapped[Optional[str]] = mapped_column(String(250), sort_order=900) + nlp_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + nlp_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1100) + term_exists: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + term_temporal: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + term_modifiers: Mapped[Optional[str]] = mapped_column(String(2000), sort_order=1400) + + note_nlp_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="NoteNlp.note_nlp_concept_id") + note_nlp_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="NoteNlp.note_nlp_source_concept_id" + ) + section_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="NoteNlp.section_concept_id") + + +class Person(BaseCdm54): + __tablename__ = "person" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=200) + year_of_birth: Mapped[int] = mapped_column(Integer, sort_order=300) + month_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=400) + day_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + birth_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + race_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + ethnicity_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=900) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1000) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1100) + person_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + race_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + race_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + ethnicity_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + ethnicity_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="Person.care_site_id") + ethnicity_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.ethnicity_concept_id") + ethnicity_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Person.ethnicity_source_concept_id" + ) + gender_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.gender_concept_id") + gender_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.gender_source_concept_id") + location: Mapped["Location"] = relationship("Location", foreign_keys="Person.location_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Person.provider_id") + race_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.race_concept_id") + race_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.race_source_concept_id") + + +class ObservationPeriod(BaseCdm54): + __tablename__ = "observation_period" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_period_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + observation_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + period_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + period_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ObservationPeriod.period_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ObservationPeriod.person_id") + + +class Specimen(BaseCdm54): + __tablename__ = "specimen" + __table_args__ = {"schema": CDM_SCHEMA} + + specimen_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + specimen_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + specimen_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + specimen_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + specimen_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + anatomic_site_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + disease_status_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + specimen_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + + anatomic_site_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.anatomic_site_concept_id" + ) + disease_status_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.disease_status_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="Specimen.person_id") + specimen_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Specimen.specimen_concept_id") + specimen_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.specimen_type_concept_id" + ) + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Specimen.unit_concept_id") + + +class VisitOccurrence(BaseCdm54): + __tablename__ = "visit_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharged_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + discharged_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + preceding_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1700 + ) + + admitted_from_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.admitted_from_concept_id" + ) + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="VisitOccurrence.care_site_id") + discharged_to_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.discharged_to_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="VisitOccurrence.person_id") + preceding_visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="VisitOccurrence.preceding_visit_occurrence_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="VisitOccurrence.provider_id") + visit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="VisitOccurrence.visit_concept_id") + visit_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.visit_source_concept_id" + ) + visit_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.visit_type_concept_id" + ) + + +class VisitDetail(BaseCdm54): + __tablename__ = "visit_detail" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_detail_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_detail_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_detail_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + visit_detail_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + visit_detail_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + visit_detail_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + visit_detail_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_detail_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_detail_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharged_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + discharged_to_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + preceding_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1700) + parent_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1800) + visit_occurrence_id: Mapped[int] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1900) + + admitted_from_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.admitted_from_concept_id" + ) + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="VisitDetail.care_site_id") + discharged_to_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.discharged_to_concept_id" + ) + parent_visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="VisitDetail.parent_visit_detail_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="VisitDetail.person_id") + preceding_visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="VisitDetail.preceding_visit_detail_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="VisitDetail.provider_id") + visit_detail_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_concept_id" + ) + visit_detail_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_source_concept_id" + ) + visit_detail_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_type_concept_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="VisitDetail.visit_occurrence_id" + ) + + +class DeviceExposure(BaseCdm54): + __tablename__ = "device_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + device_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + device_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + device_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + device_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + device_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + device_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + device_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(255), sort_order=900) + production_id: Mapped[Optional[str]] = mapped_column(String(255), sort_order=1000) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1300 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1400) + device_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + device_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + unit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + + device_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DeviceExposure.device_concept_id") + device_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DeviceExposure.device_source_concept_id" + ) + device_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DeviceExposure.device_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="DeviceExposure.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="DeviceExposure.provider_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DeviceExposure.unit_concept_id") + unit_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DeviceExposure.unit_source_concept_id" + ) + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="DeviceExposure.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="DeviceExposure.visit_occurrence_id" + ) + + +class DrugExposure(BaseCdm54): + __tablename__ = "drug_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_exposure_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_exposure_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + drug_exposure_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + drug_exposure_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + drug_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + drug_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1300) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=1400) + route_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1700) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1800 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1900) + drug_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drug_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2300) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.drug_concept_id") + drug_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugExposure.drug_source_concept_id" + ) + drug_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.drug_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DrugExposure.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="DrugExposure.provider_id") + route_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.route_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="DrugExposure.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="DrugExposure.visit_occurrence_id" + ) + + +class Measurement(BaseCdm54): + __tablename__ = "measurement" + __table_args__ = {"schema": CDM_SCHEMA} + + measurement_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + measurement_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + measurement_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + measurement_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + measurement_time: Mapped[Optional[str]] = mapped_column(String(10), sort_order=600) + measurement_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1400) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1500 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1600) + measurement_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + measurement_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + unit_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2000) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2100) + measurement_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=2200) + meas_event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2300) + + meas_event_field_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Measurement.meas_event_field_concept_id" + ) + measurement_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.measurement_concept_id") + measurement_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Measurement.measurement_source_concept_id" + ) + measurement_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Measurement.measurement_type_concept_id" + ) + operator_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.operator_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Measurement.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Measurement.provider_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.unit_concept_id") + unit_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.unit_source_concept_id") + value_as_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.value_as_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Measurement.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Measurement.visit_occurrence_id" + ) + + +class Note(BaseCdm54): + __tablename__ = "note" + __table_args__ = {"schema": CDM_SCHEMA} + + note_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + note_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + note_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=400) + note_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=500) + note_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + note_title: Mapped[Optional[str]] = mapped_column(String(250), sort_order=700) + note_text: Mapped[str] = mapped_column(Text, sort_order=800) + encoding_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + note_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + note_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=1500) + note_event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + + encoding_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.encoding_concept_id") + language_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.language_concept_id") + note_class_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.note_class_concept_id") + note_event_field_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Note.note_event_field_concept_id" + ) + note_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.note_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Note.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Note.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Note.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Note.visit_occurrence_id" + ) + + +class Observation(BaseCdm54): + __tablename__ = "observation" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + observation_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + observation_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + observation_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=800) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1300 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1400) + observation_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + observation_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + observation_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=2000) + obs_event_field_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + + obs_event_field_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.obs_event_field_concept_id" + ) + observation_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.observation_concept_id") + observation_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.observation_source_concept_id" + ) + observation_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.observation_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="Observation.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Observation.provider_id") + qualifier_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.qualifier_concept_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.unit_concept_id") + value_as_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.value_as_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Observation.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Observation.visit_occurrence_id" + ) + + +class ProcedureOccurrence(BaseCdm54): + __tablename__ = "procedure_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + procedure_occurrence_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + procedure_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + procedure_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + procedure_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + procedure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + procedure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + procedure_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + modifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + procedure_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + procedure_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + modifier_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.modifier_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ProcedureOccurrence.person_id") + procedure_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_concept_id" + ) + procedure_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_source_concept_id" + ) + procedure_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_type_concept_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="ProcedureOccurrence.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="ProcedureOccurrence.visit_detail_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="ProcedureOccurrence.visit_occurrence_id" + ) + + +class ConditionEra(BaseCdm54): + __tablename__ = "condition_era" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + condition_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_occurrence_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + + condition_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConditionEra.condition_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="ConditionEra.person_id") + + +class DoseEra(BaseCdm54): + __tablename__ = "dose_era" + __table_args__ = {"schema": CDM_SCHEMA} + + dose_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + unit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + dose_value: Mapped[decimal.Decimal] = mapped_column(Numeric, sort_order=500) + dose_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + dose_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DoseEra.drug_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DoseEra.person_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DoseEra.unit_concept_id") + + +class DrugEra(BaseCdm54): + __tablename__ = "drug_era" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_era_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_era_start_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + drug_era_end_date: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + gap_days: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugEra.drug_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DrugEra.person_id") + + +class Episode(BaseCdm54): + __tablename__ = "episode" + __table_args__ = {"schema": CDM_SCHEMA} + + episode_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), sort_order=200) + episode_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + episode_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + episode_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + episode_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + episode_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + episode_parent_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=800) + episode_number: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + episode_object_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + episode_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + episode_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + episode_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + episode_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Episode.episode_concept_id") + episode_object_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Episode.episode_object_concept_id" + ) + episode_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Episode.episode_source_concept_id" + ) + episode_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Episode.episode_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Episode.person_id") + + +class EpisodeEvent(BaseCdm54): + __tablename__ = "episode_event" + __table_args__ = {"schema": CDM_SCHEMA} + + episode_id: Mapped[int] = mapped_column( + ForeignKey(f"{CDM_SCHEMA}.episode.episode_id"), primary_key=True, sort_order=100 + ) + event_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=200) + episode_event_field_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300 + ) + + episode_event_field_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="EpisodeEvent.episode_event_field_concept_id" + ) + episode: Mapped["Episode"] = relationship("Episode", foreign_keys="EpisodeEvent.episode_id") + + +class PayerPlanPeriod(BaseCdm54): + __tablename__ = "payer_plan_period" + __table_args__ = {"schema": CDM_SCHEMA} + + payer_plan_period_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + payer_plan_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + payer_plan_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + payer_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + payer_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + payer_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + plan_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + plan_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + plan_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + sponsor_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + sponsor_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + sponsor_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + family_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + stop_reason_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + stop_reason_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + stop_reason_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + + payer_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.payer_concept_id") + payer_plan_period: Mapped["Person"] = relationship("Person", foreign_keys="PayerPlanPeriod.payer_plan_period_id") + payer_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.payer_source_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="PayerPlanPeriod.person_id") + plan_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.plan_concept_id") + plan_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.plan_source_concept_id" + ) + sponsor_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_concept_id") + sponsor_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.sponsor_source_concept_id" + ) + stop_reason_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.stop_reason_concept_id" + ) + stop_reason_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.stop_reason_source_concept_id" + ) + + +class Cost(BaseCdm54): + __tablename__ = "cost" + __table_args__ = {"schema": CDM_SCHEMA} + + cost_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + cost_event_id: Mapped[int] = mapped_column(Integer, index=True, sort_order=200) + cost_domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), sort_order=300) + cost_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + currency_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + total_charge: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=600) + total_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + total_paid: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=800) + paid_by_payer: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + paid_by_patient: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1000) + paid_patient_copay: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + paid_patient_coinsurance: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + paid_patient_deductible: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + paid_by_primary: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1400) + paid_ingredient_cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1500) + paid_dispensing_fee: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1600) + payer_plan_period_id: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1700) + amount_allowed: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1800) + revenue_code_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + revenue_code_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drg_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + drg_source_value: Mapped[Optional[str]] = mapped_column(String(3), sort_order=2200) + + cost_domain: Mapped["Domain"] = relationship("Domain", foreign_keys="Cost.cost_domain_id") + cost_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.cost_type_concept_id") + currency_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.currency_concept_id") + drg_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.drg_concept_id") + revenue_code_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.revenue_code_concept_id") + + +class CareSite(BaseCdm54): + __tablename__ = "care_site" + __table_args__ = {"schema": CDM_SCHEMA} + + care_site_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + care_site_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + place_of_service_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=400) + care_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + place_of_service_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + + location: Mapped["Location"] = relationship("Location", foreign_keys="CareSite.location_id") + place_of_service_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="CareSite.place_of_service_concept_id" + ) + + +class Location(BaseCdm54): + __tablename__ = "location" + __table_args__ = {"schema": CDM_SCHEMA} + + location_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + address_1: Mapped[Optional[str]] = mapped_column(String(50), sort_order=200) + address_2: Mapped[Optional[str]] = mapped_column(String(50), sort_order=300) + city: Mapped[Optional[str]] = mapped_column(String(50), sort_order=400) + state: Mapped[Optional[str]] = mapped_column(String(2), sort_order=500) + zip: Mapped[Optional[str]] = mapped_column(String(9), sort_order=600) + county: Mapped[Optional[str]] = mapped_column(String(20), sort_order=700) + location_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=800) + country_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + country_source_value: Mapped[Optional[str]] = mapped_column(String(80), sort_order=1000) + latitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + longitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + + country_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Location.country_concept_id") + + +class Provider(BaseCdm54): + __tablename__ = "provider" + __table_args__ = {"schema": CDM_SCHEMA} + + provider_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + provider_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + npi: Mapped[Optional[str]] = mapped_column(String(20), sort_order=300) + dea: Mapped[Optional[str]] = mapped_column(String(20), sort_order=400) + specialty_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=600) + year_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + gender_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + specialty_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1000) + specialty_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="Provider.care_site_id") + gender_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Provider.gender_concept_id") + gender_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Provider.gender_source_concept_id" + ) + specialty_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Provider.specialty_concept_id") + specialty_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Provider.specialty_source_concept_id" + ) + + +class CdmSource(BaseCdm54): + __tablename__ = "cdm_source" + __table_args__ = {"schema": CDM_SCHEMA} + + cdm_source_name: Mapped[str] = mapped_column(String(255), primary_key=True, sort_order=100) + cdm_source_abbreviation: Mapped[str] = mapped_column(String(25), sort_order=200) + cdm_holder: Mapped[str] = mapped_column(String(255), sort_order=300) + source_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + source_documentation_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=500) + cdm_etl_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=600) + source_release_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + cdm_release_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + cdm_version: Mapped[Optional[str]] = mapped_column(String(10), sort_order=900) + cdm_version_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + vocabulary_version: Mapped[str] = mapped_column(String(20), sort_order=1100) + + cdm_version_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="CdmSource.cdm_version_concept_id") + + +class Metadata(BaseCdm54): + __tablename__ = "metadata" + __table_args__ = {"schema": CDM_SCHEMA} + + metadata_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + metadata_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=200) + metadata_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + name: Mapped[str] = mapped_column(String(250), sort_order=400) + value_as_string: Mapped[Optional[str]] = mapped_column(String(250), sort_order=500) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + metadata_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + metadata_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=900) + + metadata_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Metadata.metadata_concept_id") + metadata_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Metadata.metadata_type_concept_id" + ) + value_as_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Metadata.value_as_concept_id") diff --git a/src/omop_cdm/regular/cdm600/__init__.py b/src/omop_cdm/regular/cdm600/__init__.py new file mode 100644 index 0000000..407035d --- /dev/null +++ b/src/omop_cdm/regular/cdm600/__init__.py @@ -0,0 +1,94 @@ +""" +OMOP CDM Version 6.0.0. + +Generated with python using sqlacodegen 3.0.0rc5, model from +https://github.com/OHDSI/CommonDataModel/tree/Dev/PostgreSQL, +commit 30d851a. + + + +Deviations from standard model + +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 + +""" + +from omop_cdm.regular.cdm600.tables import ( + BaseCdm600, + CareSite, + CdmSource, + Concept, + ConceptAncestor, + ConceptClass, + ConceptRelationship, + ConceptSynonym, + ConditionEra, + ConditionOccurrence, + Cost, + DeviceExposure, + Domain, + DoseEra, + DrugEra, + DrugExposure, + DrugStrength, + FactRelationship, + Location, + Measurement, + Metadata, + Note, + NoteNlp, + Observation, + ObservationPeriod, + PayerPlanPeriod, + Person, + ProcedureOccurrence, + Provider, + Relationship, + SourceToConceptMap, + Specimen, + VisitDetail, + VisitOccurrence, + Vocabulary, +) + +__all__ = [ + "BaseCdm600", + "Person", + "Note", + "Measurement", + "NoteNlp", + "Observation", + "Specimen", + "VisitDetail", + "ConditionOccurrence", + "DeviceExposure", + "DrugExposure", + "FactRelationship", + "ObservationPeriod", + "ProcedureOccurrence", + "VisitOccurrence", + "CareSite", + "Location", + "Provider", + "Cost", + "PayerPlanPeriod", + "DoseEra", + "DrugEra", + "ConditionEra", + "Metadata", + "CdmSource", + "Vocabulary", + "SourceToConceptMap", + "Concept", + "ConceptAncestor", + "ConceptClass", + "ConceptRelationship", + "ConceptSynonym", + "Domain", + "DrugStrength", + "Relationship", +] diff --git a/src/omop_cdm/regular/cdm600/tables.py b/src/omop_cdm/regular/cdm600/tables.py new file mode 100644 index 0000000..e6448b0 --- /dev/null +++ b/src/omop_cdm/regular/cdm600/tables.py @@ -0,0 +1,1082 @@ +"""OMOP CDM 6.0.0 tables.""" + +import datetime +import decimal +from typing import Optional + +from sqlalchemy import ( + BigInteger, + CheckConstraint, + Date, + DateTime, + ForeignKey, + Integer, + MetaData, + Numeric, + String, + Text, +) +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship + +from omop_cdm import NAMING_CONVENTION +from omop_cdm.constants import ( + CDM_SCHEMA, + FK_CARE_SITE_ID, + FK_CONCEPT_CLASS_ID, + FK_CONCEPT_ID, + FK_DOMAIN_ID, + FK_LOCATION_ID, + FK_PERSON_ID, + FK_PROVIDER_ID, + FK_VISIT_DETAIL_ID, + FK_VISIT_OCCURRENCE_ID, + FK_VOCABULARY_ID, + VOCAB_SCHEMA, +) + + +class BaseCdm600(DeclarativeBase): + pass + + +BaseCdm600.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class FactRelationship(BaseCdm600): + __tablename__ = "fact_relationship" + __table_args__ = {"schema": CDM_SCHEMA} + + fact_relationship_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + domain_concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=200) + fact_id_1: Mapped[int] = mapped_column(Integer, sort_order=300) + domain_concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=400) + fact_id_2: Mapped[int] = mapped_column(Integer, sort_order=500) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=600) + + domain_concept_1: Mapped["Concept"] = relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_1") + domain_concept_2: Mapped["Concept"] = relationship("Concept", foreign_keys="FactRelationship.domain_concept_id_2") + relationship_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="FactRelationship.relationship_concept_id" + ) + + +class Person(BaseCdm600): + __tablename__ = "person" + __table_args__ = {"schema": CDM_SCHEMA} + + person_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=200) + year_of_birth: Mapped[int] = mapped_column(Integer, sort_order=300) + month_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=400) + day_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + birth_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=600) + death_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + race_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + ethnicity_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1200) + person_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + gender_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + race_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + race_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + ethnicity_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + ethnicity_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1900) + + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="Person.care_site_id") + ethnicity_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.ethnicity_concept_id") + ethnicity_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Person.ethnicity_source_concept_id" + ) + gender_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.gender_concept_id") + gender_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.gender_source_concept_id") + location: Mapped["Location"] = relationship("Location", foreign_keys="Person.location_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Person.provider_id") + race_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.race_concept_id") + race_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Person.race_source_concept_id") + + +class ObservationPeriod(BaseCdm600): + __tablename__ = "observation_period" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_period_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=300) + observation_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + period_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + period_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ObservationPeriod.period_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ObservationPeriod.person_id") + + +class Specimen(BaseCdm600): + __tablename__ = "specimen" + __table_args__ = {"schema": CDM_SCHEMA} + + specimen_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + specimen_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + specimen_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + specimen_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=500) + specimen_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + anatomic_site_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + disease_status_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + specimen_source_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + specimen_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + anatomic_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + disease_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + + anatomic_site_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.anatomic_site_concept_id" + ) + disease_status_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.disease_status_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="Specimen.person_id") + specimen_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Specimen.specimen_concept_id") + specimen_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Specimen.specimen_type_concept_id" + ) + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Specimen.unit_concept_id") + + +class VisitOccurrence(BaseCdm600): + __tablename__ = "visit_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_occurrence_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + visit_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + visit_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + visit_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + visit_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + visit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + visit_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + discharge_to_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + preceding_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1700 + ) + + admitted_from_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.admitted_from_concept_id" + ) + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="VisitOccurrence.care_site_id") + discharge_to_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.discharge_to_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="VisitOccurrence.person_id") + preceding_visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="VisitOccurrence.preceding_visit_occurrence_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="VisitOccurrence.provider_id") + visit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="VisitOccurrence.visit_concept_id") + visit_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.visit_source_concept_id" + ) + visit_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitOccurrence.visit_type_concept_id" + ) + + +class VisitDetail(BaseCdm600): + __tablename__ = "visit_detail" + __table_args__ = {"schema": CDM_SCHEMA} + + visit_detail_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + visit_detail_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + visit_detail_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + visit_detail_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + visit_detail_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + visit_detail_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + visit_detail_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=1000) + discharge_to_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + admitted_from_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + admitted_from_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + visit_detail_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + visit_detail_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + discharge_to_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + preceding_visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1700) + visit_detail_parent_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1800) + visit_occurrence_id: Mapped[int] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=1900) + + admitted_from_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.admitted_from_concept_id" + ) + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="VisitDetail.care_site_id") + discharge_to_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.discharge_to_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="VisitDetail.person_id") + preceding_visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="VisitDetail.preceding_visit_detail_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="VisitDetail.provider_id") + visit_detail_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_concept_id" + ) + visit_detail_parent: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="VisitDetail.visit_detail_parent_id" + ) + visit_detail_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_source_concept_id" + ) + visit_detail_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="VisitDetail.visit_detail_type_concept_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="VisitDetail.visit_occurrence_id" + ) + + +class ConditionOccurrence(BaseCdm600): + __tablename__ = "condition_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_occurrence_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + condition_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + condition_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + condition_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=900) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1000) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1100 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1200) + condition_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + condition_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + condition_status_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + condition_status_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + + condition_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_concept_id" + ) + condition_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_source_concept_id" + ) + condition_status_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_status_concept_id" + ) + condition_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConditionOccurrence.condition_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ConditionOccurrence.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="ConditionOccurrence.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="ConditionOccurrence.visit_detail_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="ConditionOccurrence.visit_occurrence_id" + ) + + +class DeviceExposure(BaseCdm600): + __tablename__ = "device_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + device_exposure_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + device_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + device_exposure_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + device_exposure_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + device_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + device_exposure_end_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + device_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + unique_device_id: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1000) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1100) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1200 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1300) + device_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1400) + device_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + + device_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DeviceExposure.device_concept_id") + device_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DeviceExposure.device_source_concept_id" + ) + device_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DeviceExposure.device_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="DeviceExposure.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="DeviceExposure.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="DeviceExposure.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="DeviceExposure.visit_occurrence_id" + ) + + +class DrugExposure(BaseCdm600): + __tablename__ = "drug_exposure" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_exposure_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_exposure_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + drug_exposure_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + drug_exposure_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + verbatim_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + drug_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + refills: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1100) + quantity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + days_supply: Mapped[Optional[int]] = mapped_column(Integer, sort_order=1300) + sig: Mapped[Optional[str]] = mapped_column(Text, sort_order=1400) + route_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + lot_number: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1700) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1800 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1900) + drug_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + drug_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + route_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2200) + dose_unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2300) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.drug_concept_id") + drug_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugExposure.drug_source_concept_id" + ) + drug_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.drug_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DrugExposure.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="DrugExposure.provider_id") + route_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugExposure.route_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="DrugExposure.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="DrugExposure.visit_occurrence_id" + ) + + +class Measurement(BaseCdm600): + __tablename__ = "measurement" + __table_args__ = {"schema": CDM_SCHEMA} + + measurement_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + measurement_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + measurement_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + measurement_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + measurement_time: Mapped[Optional[str]] = mapped_column(String(10), sort_order=600) + measurement_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + operator_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=900) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + range_low: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1200) + range_high: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1300) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1400) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1500 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1600) + measurement_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + measurement_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + value_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + + measurement_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.measurement_concept_id") + measurement_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Measurement.measurement_source_concept_id" + ) + measurement_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Measurement.measurement_type_concept_id" + ) + operator_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.operator_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Measurement.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Measurement.provider_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.unit_concept_id") + value_as_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Measurement.value_as_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Measurement.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Measurement.visit_occurrence_id" + ) + + +class Note(BaseCdm600): + __tablename__ = "note" + __table_args__ = {"schema": CDM_SCHEMA} + + note_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + note_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=300) + note_event_field_concept_id: Mapped[int] = mapped_column(Integer, sort_order=400) + note_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=500) + note_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + note_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + note_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + note_title: Mapped[Optional[str]] = mapped_column(String(250), sort_order=900) + note_text: Mapped[str] = mapped_column(Text, sort_order=1000) + encoding_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1300) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1400 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1500) + note_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + + encoding_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.encoding_concept_id") + language_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.language_concept_id") + note_class_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.note_class_concept_id") + note_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Note.note_type_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="Note.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Note.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Note.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Note.visit_occurrence_id" + ) + + +class Observation(BaseCdm600): + __tablename__ = "observation" + __table_args__ = {"schema": CDM_SCHEMA} + + observation_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + observation_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + observation_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + observation_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + observation_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + value_as_number: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + value_as_string: Mapped[Optional[str]] = mapped_column(String(60), sort_order=800) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + value_as_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1000) + qualifier_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=1300) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1400 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1500) + observation_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + observation_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1700) + unit_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1800) + qualifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + observation_event_id: Mapped[Optional[int]] = mapped_column(BigInteger, sort_order=2000) + obs_event_field_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + + obs_event_field_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.obs_event_field_concept_id" + ) + observation_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.observation_concept_id") + observation_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.observation_source_concept_id" + ) + observation_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Observation.observation_type_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="Observation.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="Observation.provider_id") + qualifier_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.qualifier_concept_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.unit_concept_id") + value_as_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Observation.value_as_concept_id") + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="Observation.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="Observation.visit_occurrence_id" + ) + + +class ProcedureOccurrence(BaseCdm600): + __tablename__ = "procedure_occurrence" + __table_args__ = {"schema": CDM_SCHEMA} + + procedure_occurrence_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + procedure_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + procedure_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + procedure_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + procedure_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + modifier_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + quantity: Mapped[Optional[int]] = mapped_column(Integer, sort_order=800) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=900) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), index=True, sort_order=1000 + ) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=1100) + procedure_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + procedure_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + modifier_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + + modifier_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.modifier_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="ProcedureOccurrence.person_id") + procedure_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_concept_id" + ) + procedure_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_source_concept_id" + ) + procedure_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ProcedureOccurrence.procedure_type_concept_id" + ) + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="ProcedureOccurrence.provider_id") + visit_detail: Mapped["VisitDetail"] = relationship( + "VisitDetail", foreign_keys="ProcedureOccurrence.visit_detail_id" + ) + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="ProcedureOccurrence.visit_occurrence_id" + ) + + +class SurveyConduct(BaseCdm600): + __tablename__ = "survey_conduct" + __table_args__ = {"schema": CDM_SCHEMA} + + survey_conduct_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + survey_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + survey_start_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=400) + survey_start_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=500) + survey_end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + survey_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + provider_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PROVIDER_ID), sort_order=800) + assisted_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + respondent_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + timing_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + collection_method_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + assisted_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + respondent_type_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1400) + timing_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1500) + collection_method_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1600) + survey_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1700) + survey_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + survey_source_identifier: Mapped[Optional[str]] = mapped_column(String(100), sort_order=1900) + validated_survey_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2000) + validated_survey_source_value: Mapped[Optional[str]] = mapped_column(String(100), sort_order=2100) + survey_version_number: Mapped[Optional[str]] = mapped_column(String(20), sort_order=2200) + visit_occurrence_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=2300) + visit_detail_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_VISIT_DETAIL_ID), sort_order=2400) + response_visit_occurrence_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(FK_VISIT_OCCURRENCE_ID), sort_order=2500 + ) + + assisted_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="SurveyConduct.assisted_concept_id") + collection_method_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="SurveyConduct.collection_method_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="SurveyConduct.person_id") + provider: Mapped["Provider"] = relationship("Provider", foreign_keys="SurveyConduct.provider_id") + respondent_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="SurveyConduct.respondent_type_concept_id" + ) + response_visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="SurveyConduct.response_visit_occurrence_id" + ) + survey_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="SurveyConduct.survey_concept_id") + survey_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="SurveyConduct.survey_source_concept_id" + ) + timing_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="SurveyConduct.timing_concept_id") + validated_survey_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="SurveyConduct.validated_survey_concept_id" + ) + visit_detail: Mapped["VisitDetail"] = relationship("VisitDetail", foreign_keys="SurveyConduct.visit_detail_id") + visit_occurrence: Mapped["VisitOccurrence"] = relationship( + "VisitOccurrence", foreign_keys="SurveyConduct.visit_occurrence_id" + ) + + +class NoteNlp(BaseCdm600): + __tablename__ = "note_nlp" + __table_args__ = {"schema": CDM_SCHEMA} + + note_nlp_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + note_id: Mapped[int] = mapped_column(ForeignKey(f"{CDM_SCHEMA}.note.note_id"), index=True, sort_order=200) + section_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + snippet: Mapped[Optional[str]] = mapped_column(String(250), sort_order=400) + offset: Mapped[Optional[str]] = mapped_column(String(250), sort_order=500) + lexical_variant: Mapped[str] = mapped_column(String(250), sort_order=600) + note_nlp_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=700) + nlp_system: Mapped[Optional[str]] = mapped_column(String(250), sort_order=800) + nlp_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + nlp_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=1000) + term_exists: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1100) + term_temporal: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + term_modifiers: Mapped[Optional[str]] = mapped_column(String(2000), sort_order=1300) + note_nlp_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + + note: Mapped["Note"] = relationship("Note", foreign_keys="NoteNlp.note_id") + note_nlp_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="NoteNlp.note_nlp_concept_id") + note_nlp_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="NoteNlp.note_nlp_source_concept_id" + ) + section_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="NoteNlp.section_concept_id") + + +class ConditionEra(BaseCdm600): + __tablename__ = "condition_era" + __table_args__ = {"schema": CDM_SCHEMA} + + condition_era_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + condition_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + condition_era_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + condition_era_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + condition_occurrence_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + + condition_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConditionEra.condition_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="ConditionEra.person_id") + + +class DoseEra(BaseCdm600): + __tablename__ = "dose_era" + __table_args__ = {"schema": CDM_SCHEMA} + + dose_era_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + unit_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + dose_value: Mapped[decimal.Decimal] = mapped_column(Numeric, sort_order=500) + dose_era_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=600) + dose_era_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=700) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DoseEra.drug_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DoseEra.person_id") + unit_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DoseEra.unit_concept_id") + + +class DrugEra(BaseCdm600): + __tablename__ = "drug_era" + __table_args__ = {"schema": CDM_SCHEMA} + + drug_era_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + drug_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), index=True, sort_order=300) + drug_era_start_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=400) + drug_era_end_datetime: Mapped[datetime.datetime] = mapped_column(DateTime, sort_order=500) + drug_exposure_count: Mapped[Optional[int]] = mapped_column(Integer, sort_order=600) + gap_days: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugEra.drug_concept_id") + person: Mapped["Person"] = relationship("Person", foreign_keys="DrugEra.person_id") + + +class Cost(BaseCdm600): + __tablename__ = "cost" + __table_args__ = {"schema": CDM_SCHEMA} + + cost_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + cost_event_id: Mapped[int] = mapped_column(BigInteger, sort_order=300) + cost_event_field_concept_id: Mapped[int] = mapped_column(Integer, sort_order=400) + cost_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + cost_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + currency_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + cost: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=800) + incurred_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + billed_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=1000) + paid_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=1100) + revenue_code_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + drg_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + cost_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1400) + cost_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1500) + revenue_code_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1600) + drg_source_value: Mapped[Optional[str]] = mapped_column(String(3), sort_order=1700) + payer_plan_period_id: Mapped[Optional[int]] = mapped_column( + ForeignKey(f"{CDM_SCHEMA}.payer_plan_period.payer_plan_period_id"), sort_order=1800 + ) + + cost_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.cost_concept_id") + cost_source_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.cost_source_concept_id") + cost_type_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.cost_type_concept_id") + currency_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.currency_concept_id") + drg_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.drg_concept_id") + payer_plan_period: Mapped["PayerPlanPeriod"] = relationship( + "PayerPlanPeriod", foreign_keys="Cost.payer_plan_period_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="Cost.person_id") + revenue_code_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Cost.revenue_code_concept_id") + + +class PayerPlanPeriod(BaseCdm600): + __tablename__ = "payer_plan_period" + __table_args__ = {"schema": CDM_SCHEMA} + + payer_plan_period_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID), index=True, sort_order=200) + contract_person_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_PERSON_ID), sort_order=300) + payer_plan_period_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + payer_plan_period_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + payer_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + plan_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=700) + contract_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + sponsor_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=900) + stop_reason_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1000) + payer_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1100) + payer_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + plan_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1300) + plan_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1400) + contract_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1500) + contract_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1600) + sponsor_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1700) + sponsor_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1800) + family_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1900) + stop_reason_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=2000) + stop_reason_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=2100) + + contract_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.contract_concept_id") + contract_person: Mapped["Person"] = relationship("Person", foreign_keys="PayerPlanPeriod.contract_person_id") + contract_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.contract_source_concept_id" + ) + payer_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.payer_concept_id") + payer_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.payer_source_concept_id" + ) + person: Mapped["Person"] = relationship("Person", foreign_keys="PayerPlanPeriod.person_id") + plan_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.plan_concept_id") + plan_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.plan_source_concept_id" + ) + sponsor_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="PayerPlanPeriod.sponsor_concept_id") + sponsor_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.sponsor_source_concept_id" + ) + stop_reason_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.stop_reason_concept_id" + ) + stop_reason_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="PayerPlanPeriod.stop_reason_source_concept_id" + ) + + +class CareSite(BaseCdm600): + __tablename__ = "care_site" + __table_args__ = {"schema": CDM_SCHEMA} + + care_site_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + care_site_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + place_of_service_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + location_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=400) + care_site_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=500) + place_of_service_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=600) + + location: Mapped["Location"] = relationship("Location", foreign_keys="CareSite.location_id") + place_of_service_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="CareSite.place_of_service_concept_id" + ) + + +class Location(BaseCdm600): + __tablename__ = "location" + __table_args__ = {"schema": CDM_SCHEMA} + + location_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + address_1: Mapped[Optional[str]] = mapped_column(String(50), sort_order=200) + address_2: Mapped[Optional[str]] = mapped_column(String(50), sort_order=300) + city: Mapped[Optional[str]] = mapped_column(String(50), sort_order=400) + state: Mapped[Optional[str]] = mapped_column(String(2), sort_order=500) + zip: Mapped[Optional[str]] = mapped_column(String(9), sort_order=600) + county: Mapped[Optional[str]] = mapped_column(String(20), sort_order=700) + country: Mapped[Optional[str]] = mapped_column(String(100), sort_order=800) + location_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + latitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1000) + longitude: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=1100) + region_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1200) + + region_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Location.region_concept_id") + + +class LocationHistory(BaseCdm600): + __tablename__ = "location_history" + __table_args__ = {"schema": CDM_SCHEMA} + + location_history_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + location_id: Mapped[int] = mapped_column(ForeignKey(FK_LOCATION_ID), sort_order=200) + relationship_type_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + domain_id: Mapped[str] = mapped_column(String(50), sort_order=400) + entity_id: Mapped[int] = mapped_column(BigInteger, sort_order=500) + start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=600) + end_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + + location: Mapped["Location"] = relationship("Location", foreign_keys="LocationHistory.location_id") + relationship_type_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="LocationHistory.relationship_type_concept_id" + ) + + +class Provider(BaseCdm600): + __tablename__ = "provider" + __table_args__ = {"schema": CDM_SCHEMA} + + provider_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, sort_order=100) + provider_name: Mapped[Optional[str]] = mapped_column(String(255), sort_order=200) + npi: Mapped[Optional[str]] = mapped_column(String(20), sort_order=300) + dea: Mapped[Optional[str]] = mapped_column(String(20), sort_order=400) + specialty_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + care_site_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CARE_SITE_ID), sort_order=600) + year_of_birth: Mapped[Optional[int]] = mapped_column(Integer, sort_order=700) + gender_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + provider_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=900) + specialty_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1000) + specialty_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1100) + gender_source_value: Mapped[Optional[str]] = mapped_column(String(50), sort_order=1200) + gender_source_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=1300) + + care_site: Mapped["CareSite"] = relationship("CareSite", foreign_keys="Provider.care_site_id") + gender_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Provider.gender_concept_id") + gender_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Provider.gender_source_concept_id" + ) + specialty_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Provider.specialty_concept_id") + specialty_source_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Provider.specialty_source_concept_id" + ) + + +class CdmSource(BaseCdm600): + __tablename__ = "cdm_source" + __table_args__ = {"schema": CDM_SCHEMA} + + cdm_source_name: Mapped[str] = mapped_column(String(255), primary_key=True, sort_order=100) + cdm_source_abbreviation: Mapped[Optional[str]] = mapped_column(String(25), sort_order=200) + cdm_holder: Mapped[Optional[str]] = mapped_column(String(255), sort_order=300) + source_description: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + source_documentation_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=500) + cdm_etl_reference: Mapped[Optional[str]] = mapped_column(String(255), sort_order=600) + source_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=700) + cdm_release_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=800) + cdm_version: Mapped[Optional[str]] = mapped_column(String(10), sort_order=900) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(20), sort_order=1000) + + +class Metadata(BaseCdm600): + __tablename__ = "metadata" + __table_args__ = {"schema": CDM_SCHEMA} + + metadata_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True, sort_order=100) + metadata_type_concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=200) + name: Mapped[str] = mapped_column(String(250), primary_key=True, sort_order=300) + value_as_string: Mapped[Optional[str]] = mapped_column(Text, sort_order=400) + value_as_concept_id: Mapped[Optional[int]] = mapped_column(Integer, sort_order=500) + metadata_date: Mapped[Optional[datetime.date]] = mapped_column(Date, sort_order=600) + metadata_datetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, sort_order=700) + + +class Concept(BaseCdm600): + __tablename__ = "concept" + __table_args__ = ( + CheckConstraint("(COALESCE(invalid_reason,'D') in ('D','U'))", name="chk_c_invalid_reason"), + CheckConstraint("(COALESCE(standard_concept,'C') in ('C','S'))", name="chk_c_standard_concept"), + CheckConstraint("(concept_code <> '')", name="chk_c_concept_code"), + CheckConstraint("(concept_name <> '')", name="chk_c_concept_name"), + {"schema": VOCAB_SCHEMA}, + ) + + concept_id: Mapped[int] = mapped_column(Integer, primary_key=True, sort_order=100) + concept_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_id: Mapped[str] = mapped_column(ForeignKey(FK_DOMAIN_ID), index=True, sort_order=300) + vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=400) + concept_class_id: Mapped[str] = mapped_column(ForeignKey(FK_CONCEPT_CLASS_ID), index=True, sort_order=500) + standard_concept: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + concept_code: Mapped[str] = mapped_column(String(50), index=True, sort_order=700) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=800) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=900) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1000) + + concept_class: Mapped["ConceptClass"] = relationship("ConceptClass", foreign_keys="Concept.concept_class_id") + domain: Mapped["Domain"] = relationship("Domain", foreign_keys="Concept.domain_id") + vocabulary: Mapped["Vocabulary"] = relationship("Vocabulary", foreign_keys="Concept.vocabulary_id") + + +class ConceptAncestor(BaseCdm600): + __tablename__ = "concept_ancestor" + __table_args__ = {"schema": VOCAB_SCHEMA} + + ancestor_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + descendant_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + min_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=300) + max_levels_of_separation: Mapped[int] = mapped_column(Integer, sort_order=400) + + ancestor_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptAncestor.ancestor_concept_id") + descendant_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConceptAncestor.descendant_concept_id" + ) + + +class ConceptClass(BaseCdm600): + __tablename__ = "concept_class" + __table_args__ = {"schema": VOCAB_SCHEMA} + + concept_class_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + concept_class_name: Mapped[str] = mapped_column(String(255), sort_order=200) + concept_class_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + concept_class_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="ConceptClass.concept_class_concept_id" + ) + + +class ConceptRelationship(BaseCdm600): + __tablename__ = "concept_relationship" + __table_args__ = ( + CheckConstraint("(COALESCE(invalid_reason,'D')='D')", name="chk_cr_invalid_reason"), + {"schema": VOCAB_SCHEMA}, + ) + + concept_id_1: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_id_2: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200) + relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), primary_key=True, index=True, sort_order=300 + ) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=400) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=500) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=600) + + concept_1: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptRelationship.concept_id_1") + concept_2: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptRelationship.concept_id_2") + relationship: Mapped["Relationship"] = relationship( + "Relationship", foreign_keys="ConceptRelationship.relationship_id" + ) + + +class ConceptSynonym(BaseCdm600): + __tablename__ = "concept_synonym" + __table_args__ = ( + # UniqueConstraint uq_concept_synonym is not added, because + # there is already a PK on the same columns + CheckConstraint("(concept_synonym_name <> '')", name="chk_csyn_concept_synonym_name"), + {"schema": VOCAB_SCHEMA}, + ) + + concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100) + concept_synonym_name: Mapped[str] = mapped_column(String(1000), primary_key=True, sort_order=200) + language_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), primary_key=True, sort_order=300) + + concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptSynonym.concept_id") + language_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="ConceptSynonym.language_concept_id") + + +class Domain(BaseCdm600): + __tablename__ = "domain" + __table_args__ = {"schema": VOCAB_SCHEMA} + + domain_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + domain_name: Mapped[str] = mapped_column(String(255), sort_order=200) + domain_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=300) + + domain_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Domain.domain_concept_id") + + +class DrugStrength(BaseCdm600): + __tablename__ = "drug_strength" + __table_args__ = {"schema": VOCAB_SCHEMA} + + drug_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=100 + ) + ingredient_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=200 + ) + amount_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=300) + amount_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=400) + numerator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=500) + numerator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + denominator_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric, sort_order=700) + denominator_unit_concept_id: Mapped[Optional[int]] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=800) + box_size: Mapped[Optional[int]] = mapped_column(Integer, sort_order=900) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1000) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, sort_order=1100) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=1200) + + amount_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.amount_unit_concept_id" + ) + denominator_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.denominator_unit_concept_id" + ) + drug_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugStrength.drug_concept_id") + ingredient_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="DrugStrength.ingredient_concept_id") + numerator_unit_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="DrugStrength.numerator_unit_concept_id" + ) + + +class Relationship(BaseCdm600): + __tablename__ = "relationship" + __table_args__ = {"schema": VOCAB_SCHEMA} + + relationship_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + relationship_name: Mapped[str] = mapped_column(String(255), sort_order=200) + is_hierarchical: Mapped[str] = mapped_column(String(1), sort_order=300) + defines_ancestry: Mapped[str] = mapped_column(String(1), sort_order=400) + reverse_relationship_id: Mapped[str] = mapped_column( + ForeignKey(f"{VOCAB_SCHEMA}.relationship.relationship_id"), sort_order=500 + ) + relationship_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=600) + + relationship_concept: Mapped["Concept"] = relationship( + "Concept", foreign_keys="Relationship.relationship_concept_id" + ) + reverse_relationship: Mapped["Relationship"] = relationship( + "Relationship", foreign_keys="Relationship.reverse_relationship_id" + ) + + +class Vocabulary(BaseCdm600): + __tablename__ = "vocabulary" + __table_args__ = {"schema": VOCAB_SCHEMA} + + vocabulary_id: Mapped[str] = mapped_column(String(20), primary_key=True, sort_order=100) + vocabulary_name: Mapped[str] = mapped_column(String(255), sort_order=200) + vocabulary_reference: Mapped[str] = mapped_column(String(255), sort_order=300) + vocabulary_version: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + vocabulary_concept_id: Mapped[int] = mapped_column(ForeignKey(FK_CONCEPT_ID), sort_order=500) + + vocabulary_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="Vocabulary.vocabulary_concept_id") + + +class SourceToConceptMap(BaseCdm600): + __tablename__ = "source_to_concept_map" + __table_args__ = {"schema": CDM_SCHEMA} + + source_code: Mapped[str] = mapped_column(String(1000), primary_key=True, index=True, sort_order=100) + source_concept_id: Mapped[int] = mapped_column(Integer, sort_order=200) + source_vocabulary_id: Mapped[str] = mapped_column( + ForeignKey(FK_VOCABULARY_ID), primary_key=True, index=True, sort_order=300 + ) + source_code_description: Mapped[Optional[str]] = mapped_column(String(255), sort_order=400) + target_concept_id: Mapped[int] = mapped_column( + ForeignKey(FK_CONCEPT_ID), primary_key=True, index=True, sort_order=500 + ) + target_vocabulary_id: Mapped[str] = mapped_column(ForeignKey(FK_VOCABULARY_ID), index=True, sort_order=600) + valid_start_date: Mapped[datetime.date] = mapped_column(Date, sort_order=700) + valid_end_date: Mapped[datetime.date] = mapped_column(Date, primary_key=True, sort_order=800) + invalid_reason: Mapped[Optional[str]] = mapped_column(String(1), sort_order=900) + + source_vocabulary: Mapped["Vocabulary"] = relationship( + "Vocabulary", foreign_keys="SourceToConceptMap.source_vocabulary_id" + ) + target_concept: Mapped["Concept"] = relationship("Concept", foreign_keys="SourceToConceptMap.target_concept_id") + target_vocabulary: Mapped["Vocabulary"] = relationship( + "Vocabulary", foreign_keys="SourceToConceptMap.target_vocabulary_id" + ) diff --git a/src/omop_cdm/regular/ruff.toml b/src/omop_cdm/regular/ruff.toml new file mode 100644 index 0000000..ce39771 --- /dev/null +++ b/src/omop_cdm/regular/ruff.toml @@ -0,0 +1,5 @@ +# Extend the `ruff.toml` file in the root directory... +extend = "../../../ruff.toml" + +# Allow a longer line length for easier to navigate table definitions +line-length = 119 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..9daa873 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,40 @@ +from contextlib import contextmanager +from typing import Set + +from pytest import fixture +from sqlalchemy import Connection, Engine, MetaData, create_engine +from sqlalchemy.sql.ddl import CreateSchema, DropSchema +from testcontainers.postgres import PostgresContainer + +POSTGRES_IMAGE = "postgres:16-alpine" + + +@fixture(scope="session") +def pg_db_engine() -> Engine: + with PostgresContainer(POSTGRES_IMAGE) as postgres: + engine = create_engine(postgres.get_connection_url()) + yield engine + + +def create_schemas(schemas: Set[str], conn: Connection) -> None: + for schema in schemas: + conn.execute(CreateSchema(schema, if_not_exists=True)) + + +def drop_schemas(schemas: Set[str], conn: Connection) -> None: + for schema in schemas: + conn.execute(DropSchema(schema, cascade=True, if_exists=True)) + + +@contextmanager +def temp_schemas(engine: Engine, schemas: Set[str]): + with engine.begin() as conn: + create_schemas(schemas, conn) + yield + with engine.begin() as conn: + drop_schemas(schemas, conn) + + +def create_all_tables(engine: Engine, metadata: MetaData) -> None: + with engine.begin() as conn: + metadata.create_all(bind=conn) diff --git a/tests/omop_cdm/dynamic/cdm531/test_cdm531.py b/tests/omop_cdm/dynamic/cdm531/test_cdm531.py new file mode 100644 index 0000000..d81ab81 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm531/test_cdm531.py @@ -0,0 +1,26 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.dynamic.cdm_definitions import cdm531 +from tests.omop_cdm.table_sets import CDM531_NON_VOCAB, CUSTOM, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab531", + CDM_SCHEMA: "cdm531", +} + + +@fixture(scope="session") +def cdm531_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm531(cdm531_engine: Engine): + with temp_schemas(engine=cdm531_engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables(engine=cdm531_engine, metadata=cdm531.Base.metadata) + vocab_tables = inspect(cdm531_engine).get_table_names(SCHEMA_MAP[VOCAB_SCHEMA]) + cdm_tables = inspect(cdm531_engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(vocab_tables) == VOCAB + assert set(cdm_tables) == CDM531_NON_VOCAB | CUSTOM diff --git a/tests/omop_cdm/dynamic/cdm54/test_cdm54.py b/tests/omop_cdm/dynamic/cdm54/test_cdm54.py new file mode 100644 index 0000000..36b5a32 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm54/test_cdm54.py @@ -0,0 +1,26 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.dynamic.cdm_definitions import cdm54 +from tests.omop_cdm.table_sets import CDM54_NON_VOCAB, CUSTOM, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab54", + CDM_SCHEMA: "cdm54", +} + + +@fixture(scope="session") +def cdm54_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm54(cdm54_engine: Engine): + with temp_schemas(engine=cdm54_engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables(engine=cdm54_engine, metadata=cdm54.Base.metadata) + vocab_tables = inspect(cdm54_engine).get_table_names(SCHEMA_MAP[VOCAB_SCHEMA]) + cdm_tables = inspect(cdm54_engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(vocab_tables) == VOCAB + assert set(cdm_tables) == CDM54_NON_VOCAB | CUSTOM diff --git a/tests/omop_cdm/dynamic/cdm54_custom/test_cdm54_custom.py b/tests/omop_cdm/dynamic/cdm54_custom/test_cdm54_custom.py new file mode 100644 index 0000000..1f10f49 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm54_custom/test_cdm54_custom.py @@ -0,0 +1,64 @@ +import pytest +from pytest import fixture +from sqlalchemy import BIGINT, Engine, inspect + +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.dynamic.cdm_definitions import cdm54_custom +from tests.omop_cdm.table_sets import CDM54_NON_VOCAB, CUSTOM + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab54_custom", + CDM_SCHEMA: "cdm54_custom", +} + + +@fixture(scope="session") +def cdm54_custom_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +@fixture(scope="module") +def create_custom_cdm_tables(cdm54_custom_engine: Engine): + with temp_schemas(engine=cdm54_custom_engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables( + engine=cdm54_custom_engine, metadata=cdm54_custom.Base.metadata + ) + yield + + +@pytest.mark.usefixtures("create_custom_cdm_tables") +def test_custom_table_is_created(cdm54_custom_engine: Engine): + cdm_tables = inspect(cdm54_custom_engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(cdm_tables) == CDM54_NON_VOCAB | CUSTOM | {"cloudspine"} + + +@pytest.mark.usefixtures("create_custom_cdm_tables") +def test_column_can_be_redefined(cdm54_custom_engine: Engine): + """person.person_id data type should be bigint.""" + person_columns = inspect(cdm54_custom_engine).get_columns( + table_name="person", schema=SCHEMA_MAP[CDM_SCHEMA] + ) + person_id = person_columns[0] + assert person_id["name"] == "person_id" + assert isinstance(person_id["type"], BIGINT) + + +@pytest.mark.usefixtures("create_custom_cdm_tables") +def test_custom_columns_can_be_added(cdm54_custom_engine: Engine): + """Custom columns are added in the expected position.""" + death_columns = inspect(cdm54_custom_engine).get_columns( + table_name="death", schema=SCHEMA_MAP[CDM_SCHEMA] + ) + death_columns = [c["name"] for c in death_columns] + assert death_columns == [ + "person_id", + "new_field_1", + "death_date", + "death_datetime", + "death_type_concept_id", + "cause_concept_id", + "cause_source_value", + "cause_source_concept_id", + "new_field_2", + ] diff --git a/tests/omop_cdm/dynamic/cdm54_plus_legacy/test_legacy.py b/tests/omop_cdm/dynamic/cdm54_plus_legacy/test_legacy.py new file mode 100644 index 0000000..c906dd2 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm54_plus_legacy/test_legacy.py @@ -0,0 +1,28 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.dynamic.cdm_definitions import cdm54_plus_legacy +from tests.omop_cdm.table_sets import CDM54_NON_VOCAB, CUSTOM, LEGACY, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "cdm54_legacy", + CDM_SCHEMA: "cdm54_legacy", +} + + +@fixture(scope="session") +def cdm54_legacy_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm54_plus_legacy(cdm54_legacy_engine: Engine): + with temp_schemas(engine=cdm54_legacy_engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables( + engine=cdm54_legacy_engine, metadata=cdm54_plus_legacy.Base.metadata + ) + cdm_tables = inspect(cdm54_legacy_engine).get_table_names( + SCHEMA_MAP[CDM_SCHEMA] + ) + assert set(cdm_tables) == VOCAB | CDM54_NON_VOCAB | LEGACY | CUSTOM diff --git a/tests/omop_cdm/dynamic/cdm600/test_cdm600.py b/tests/omop_cdm/dynamic/cdm600/test_cdm600.py new file mode 100644 index 0000000..f0022f4 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm600/test_cdm600.py @@ -0,0 +1,26 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.dynamic.cdm_definitions import cdm600 +from tests.omop_cdm.table_sets import CDM600_NON_VOCAB, CUSTOM, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab600", + CDM_SCHEMA: "cdm600", +} + + +@fixture(scope="session") +def cdm600_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm600(cdm600_engine: Engine): + with temp_schemas(engine=cdm600_engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables(engine=cdm600_engine, metadata=cdm600.Base.metadata) + vocab_tables = inspect(cdm600_engine).get_table_names(SCHEMA_MAP[VOCAB_SCHEMA]) + cdm_tables = inspect(cdm600_engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(vocab_tables) == VOCAB + assert set(cdm_tables) == CDM600_NON_VOCAB | CUSTOM diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm531/__init__.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm531/__init__.py new file mode 100644 index 0000000..5f09675 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm531/__init__.py @@ -0,0 +1 @@ +from .tables import * # noqa: F403 diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm531/tables.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm531/tables.py new file mode 100644 index 0000000..a07f773 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm531/tables.py @@ -0,0 +1,208 @@ +from sqlalchemy import MetaData +from sqlalchemy.orm import DeclarativeBase + +from src.omop_cdm.constants import NAMING_CONVENTION +from src.omop_cdm.dynamic.cdm531.clinical_data import ( + BaseConditionOccurrenceCdm531, + BaseDeathCdm531, + BaseDeviceExposureCdm531, + BaseDrugExposureCdm531, + BaseFactRelationshipCdm531, + BaseMeasurementCdm531, + BaseNoteCdm531, + BaseNoteNlpCdm531, + BaseObservationCdm531, + BaseObservationPeriodCdm531, + BasePersonCdm531, + BaseProcedureOccurrenceCdm531, + BaseSpecimenCdm531, + BaseStemTableCdm531, + BaseVisitDetailCdm531, + BaseVisitOccurrenceCdm531, +) +from src.omop_cdm.dynamic.cdm531.derived_elements import ( + BaseConditionEraCdm531, + BaseDoseEraCdm531, + BaseDrugEraCdm531, +) +from src.omop_cdm.dynamic.cdm531.health_economics import ( + BaseCostCdm531, + BasePayerPlanPeriodCdm531, +) +from src.omop_cdm.dynamic.cdm531.health_system_data import ( + BaseCareSiteCdm531, + BaseLocationCdm531, + BaseProviderCdm531, +) +from src.omop_cdm.dynamic.cdm531.metadata import ( + BaseCdmSourceCdm531, + BaseMetadataCdm531, +) +from src.omop_cdm.dynamic.cdm531.vocabularies import ( + BaseConceptAncestorCdm531, + BaseConceptCdm531, + BaseConceptClassCdm531, + BaseConceptRelationshipCdm531, + BaseConceptSynonymCdm531, + BaseDomainCdm531, + BaseDrugStrengthCdm531, + BaseRelationshipCdm531, + BaseSourceToConceptMapCdm531, + BaseSourceToConceptMapVersionCdm531, + BaseVocabularyCdm531, +) + + +class Base(DeclarativeBase): + pass + + +Base.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class Person(BasePersonCdm531, Base): + pass + + +class Death(BaseDeathCdm531, Base): + pass + + +class Note(BaseNoteCdm531, Base): + pass + + +class Measurement(BaseMeasurementCdm531, Base): + pass + + +class NoteNlp(BaseNoteNlpCdm531, Base): + pass + + +class Observation(BaseObservationCdm531, Base): + pass + + +class Specimen(BaseSpecimenCdm531, Base): + pass + + +class StemTable(BaseStemTableCdm531, Base): + pass + + +class VisitDetail(BaseVisitDetailCdm531, Base): + pass + + +class ConditionOccurrence(BaseConditionOccurrenceCdm531, Base): + pass + + +class DeviceExposure(BaseDeviceExposureCdm531, Base): + pass + + +class DrugExposure(BaseDrugExposureCdm531, Base): + pass + + +class FactRelationship(BaseFactRelationshipCdm531, Base): + pass + + +class ObservationPeriod(BaseObservationPeriodCdm531, Base): + pass + + +class ProcedureOccurrence(BaseProcedureOccurrenceCdm531, Base): + pass + + +class VisitOccurrence(BaseVisitOccurrenceCdm531, Base): + pass + + +class Location(BaseLocationCdm531, Base): + pass + + +class CareSite(BaseCareSiteCdm531, Base): + pass + + +class Provider(BaseProviderCdm531, Base): + pass + + +class Cost(BaseCostCdm531, Base): + pass + + +class PayerPlanPeriod(BasePayerPlanPeriodCdm531, Base): + pass + + +class DoseEra(BaseDoseEraCdm531, Base): + pass + + +class DrugEra(BaseDrugEraCdm531, Base): + pass + + +class ConditionEra(BaseConditionEraCdm531, Base): + pass + + +class CdmSource(BaseCdmSourceCdm531, Base): + pass + + +class Metadata(BaseMetadataCdm531, Base): + pass + + +class Concept(BaseConceptCdm531, Base): + pass + + +class ConceptAncestor(BaseConceptAncestorCdm531, Base): + pass + + +class ConceptClass(BaseConceptClassCdm531, Base): + pass + + +class ConceptRelationship(BaseConceptRelationshipCdm531, Base): + pass + + +class ConceptSynonym(BaseConceptSynonymCdm531, Base): + pass + + +class DrugStrength(BaseDrugStrengthCdm531, Base): + pass + + +class Relationship(BaseRelationshipCdm531, Base): + pass + + +class SourceToConceptMap(BaseSourceToConceptMapCdm531, Base): + pass + + +class SourceToConceptMapVersion(BaseSourceToConceptMapVersionCdm531, Base): + pass + + +class Vocabulary(BaseVocabularyCdm531, Base): + pass + + +class Domain(BaseDomainCdm531, Base): + pass diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm54/__init__.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm54/__init__.py new file mode 100644 index 0000000..5f09675 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm54/__init__.py @@ -0,0 +1 @@ +from .tables import * # noqa: F403 diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm54/tables.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm54/tables.py new file mode 100644 index 0000000..e182bc6 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm54/tables.py @@ -0,0 +1,218 @@ +from sqlalchemy import MetaData +from sqlalchemy.orm import DeclarativeBase + +from src.omop_cdm.constants import NAMING_CONVENTION +from src.omop_cdm.dynamic.cdm54.clinical_data import ( + BaseConditionOccurrenceCdm54, + BaseDeathCdm54, + BaseDeviceExposureCdm54, + BaseDrugExposureCdm54, + BaseFactRelationshipCdm54, + BaseMeasurementCdm54, + BaseNoteCdm54, + BaseNoteNlpCdm54, + BaseObservationCdm54, + BaseObservationPeriodCdm54, + BasePersonCdm54, + BaseProcedureOccurrenceCdm54, + BaseSpecimenCdm54, + BaseStemTableCdm54, + BaseVisitDetailCdm54, + BaseVisitOccurrenceCdm54, +) +from src.omop_cdm.dynamic.cdm54.derived_elements import ( + BaseConditionEraCdm54, + BaseDoseEraCdm54, + BaseDrugEraCdm54, + BaseEpisodeCdm54, + BaseEpisodeEventCdm54, +) +from src.omop_cdm.dynamic.cdm54.health_economics import ( + BaseCostCdm54, + BasePayerPlanPeriodCdm54, +) +from src.omop_cdm.dynamic.cdm54.health_system_data import ( + BaseCareSiteCdm54, + BaseLocationCdm54, + BaseProviderCdm54, +) +from src.omop_cdm.dynamic.cdm54.metadata import ( + BaseCdmSourceCdm54, + BaseMetadataCdm54, +) +from src.omop_cdm.dynamic.cdm54.vocabularies.vocabularies import ( + BaseConceptAncestorCdm54, + BaseConceptCdm54, + BaseConceptClassCdm54, + BaseConceptRelationshipCdm54, + BaseConceptSynonymCdm54, + BaseDomainCdm54, + BaseDrugStrengthCdm54, + BaseRelationshipCdm54, + BaseSourceToConceptMapCdm54, + BaseSourceToConceptMapVersionCdm54, + BaseVocabularyCdm54, +) + + +class Base(DeclarativeBase): + pass + + +Base.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class Person(BasePersonCdm54, Base): + pass + + +class Death(BaseDeathCdm54, Base): + pass + + +class Note(BaseNoteCdm54, Base): + pass + + +class Measurement(BaseMeasurementCdm54, Base): + pass + + +class NoteNlp(BaseNoteNlpCdm54, Base): + pass + + +class Observation(BaseObservationCdm54, Base): + pass + + +class Specimen(BaseSpecimenCdm54, Base): + pass + + +class StemTable(BaseStemTableCdm54, Base): + pass + + +class VisitDetail(BaseVisitDetailCdm54, Base): + pass + + +class ConditionOccurrence(BaseConditionOccurrenceCdm54, Base): + pass + + +class DeviceExposure(BaseDeviceExposureCdm54, Base): + pass + + +class DrugExposure(BaseDrugExposureCdm54, Base): + pass + + +class FactRelationship(BaseFactRelationshipCdm54, Base): + pass + + +class ObservationPeriod(BaseObservationPeriodCdm54, Base): + pass + + +class ProcedureOccurrence(BaseProcedureOccurrenceCdm54, Base): + pass + + +class VisitOccurrence(BaseVisitOccurrenceCdm54, Base): + pass + + +class Location(BaseLocationCdm54, Base): + pass + + +class CareSite(BaseCareSiteCdm54, Base): + pass + + +class Provider(BaseProviderCdm54, Base): + pass + + +class Cost(BaseCostCdm54, Base): + pass + + +class PayerPlanPeriod(BasePayerPlanPeriodCdm54, Base): + pass + + +class DoseEra(BaseDoseEraCdm54, Base): + pass + + +class DrugEra(BaseDrugEraCdm54, Base): + pass + + +class ConditionEra(BaseConditionEraCdm54, Base): + pass + + +class Episode(BaseEpisodeCdm54, Base): + pass + + +class EpisodeEvent(BaseEpisodeEventCdm54, Base): + pass + + +class CdmSource(BaseCdmSourceCdm54, Base): + pass + + +class Metadata(BaseMetadataCdm54, Base): + pass + + +class Concept(BaseConceptCdm54, Base): + pass + + +class ConceptAncestor(BaseConceptAncestorCdm54, Base): + pass + + +class ConceptClass(BaseConceptClassCdm54, Base): + pass + + +class ConceptRelationship(BaseConceptRelationshipCdm54, Base): + pass + + +class ConceptSynonym(BaseConceptSynonymCdm54, Base): + pass + + +class DrugStrength(BaseDrugStrengthCdm54, Base): + pass + + +class Relationship(BaseRelationshipCdm54, Base): + pass + + +class SourceToConceptMap(BaseSourceToConceptMapCdm54, Base): + pass + + +class SourceToConceptMapVersion(BaseSourceToConceptMapVersionCdm54, Base): + pass + + +class Vocabulary(BaseVocabularyCdm54, Base): + pass + + +class Domain(BaseDomainCdm54, Base): + pass diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/__init__.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/__init__.py new file mode 100644 index 0000000..6b1d961 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/__init__.py @@ -0,0 +1,3 @@ +"""CDM 5.4 with customizations.""" + +from .tables import * # noqa: F403 diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/tables.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/tables.py new file mode 100644 index 0000000..23763e1 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_custom/tables.py @@ -0,0 +1,237 @@ +from typing import Optional + +from sqlalchemy import BigInteger, ForeignKey, MetaData, Text +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship + +from src.omop_cdm.constants import CDM_SCHEMA, FK_PERSON_ID, NAMING_CONVENTION +from src.omop_cdm.dynamic.cdm54.clinical_data import ( + BaseConditionOccurrenceCdm54, + BaseDeathCdm54, + BaseDeviceExposureCdm54, + BaseDrugExposureCdm54, + BaseFactRelationshipCdm54, + BaseMeasurementCdm54, + BaseNoteCdm54, + BaseNoteNlpCdm54, + BaseObservationCdm54, + BaseObservationPeriodCdm54, + BasePersonCdm54, + BaseProcedureOccurrenceCdm54, + BaseSpecimenCdm54, + BaseStemTableCdm54, + BaseVisitDetailCdm54, + BaseVisitOccurrenceCdm54, +) +from src.omop_cdm.dynamic.cdm54.derived_elements import ( + BaseConditionEraCdm54, + BaseDoseEraCdm54, + BaseDrugEraCdm54, + BaseEpisodeCdm54, + BaseEpisodeEventCdm54, +) +from src.omop_cdm.dynamic.cdm54.health_economics import ( + BaseCostCdm54, + BasePayerPlanPeriodCdm54, +) +from src.omop_cdm.dynamic.cdm54.health_system_data import ( + BaseCareSiteCdm54, + BaseLocationCdm54, + BaseProviderCdm54, +) +from src.omop_cdm.dynamic.cdm54.metadata import ( + BaseCdmSourceCdm54, + BaseMetadataCdm54, +) +from src.omop_cdm.dynamic.cdm54.vocabularies.vocabularies import ( + BaseConceptAncestorCdm54, + BaseConceptCdm54, + BaseConceptClassCdm54, + BaseConceptRelationshipCdm54, + BaseConceptSynonymCdm54, + BaseDomainCdm54, + BaseDrugStrengthCdm54, + BaseRelationshipCdm54, + BaseSourceToConceptMapCdm54, + BaseSourceToConceptMapVersionCdm54, + BaseVocabularyCdm54, +) + + +class Base(DeclarativeBase): + pass + + +Base.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class Person(BasePersonCdm54, Base): + # Change data type of person_id to BigInt; keep column position + person_id: Mapped[int] = mapped_column( + BigInteger, primary_key=True, index=True, sort_order=100 + ) + + +class Death(BaseDeathCdm54, Base): + # Insert custom field at 2nd column position + new_field_1: Mapped[Optional[str]] = mapped_column(Text, sort_order=150) + # Insert custom field as the last column of the table + new_field_2: Mapped[Optional[str]] = mapped_column(Text, sort_order=10_000) + + +# Custom table +class Cloudspine(Base): + __tablename__ = "cloudspine" + __table_args__ = {"schema": CDM_SCHEMA} + + cloud_id: Mapped[int] = mapped_column(BigInteger, primary_key=True) + person_id: Mapped[int] = mapped_column(ForeignKey(FK_PERSON_ID)) + + person: Mapped[Person] = relationship(Person) + + +class Note(BaseNoteCdm54, Base): + pass + + +class Measurement(BaseMeasurementCdm54, Base): + pass + + +class NoteNlp(BaseNoteNlpCdm54, Base): + pass + + +class Observation(BaseObservationCdm54, Base): + pass + + +class Specimen(BaseSpecimenCdm54, Base): + pass + + +class StemTable(BaseStemTableCdm54, Base): + pass + + +class VisitDetail(BaseVisitDetailCdm54, Base): + pass + + +class ConditionOccurrence(BaseConditionOccurrenceCdm54, Base): + pass + + +class DeviceExposure(BaseDeviceExposureCdm54, Base): + pass + + +class DrugExposure(BaseDrugExposureCdm54, Base): + pass + + +class FactRelationship(BaseFactRelationshipCdm54, Base): + pass + + +class ObservationPeriod(BaseObservationPeriodCdm54, Base): + pass + + +class ProcedureOccurrence(BaseProcedureOccurrenceCdm54, Base): + pass + + +class VisitOccurrence(BaseVisitOccurrenceCdm54, Base): + pass + + +class Location(BaseLocationCdm54, Base): + pass + + +class CareSite(BaseCareSiteCdm54, Base): + pass + + +class Provider(BaseProviderCdm54, Base): + pass + + +class Cost(BaseCostCdm54, Base): + pass + + +class PayerPlanPeriod(BasePayerPlanPeriodCdm54, Base): + pass + + +class DoseEra(BaseDoseEraCdm54, Base): + pass + + +class DrugEra(BaseDrugEraCdm54, Base): + pass + + +class ConditionEra(BaseConditionEraCdm54, Base): + pass + + +class Episode(BaseEpisodeCdm54, Base): + pass + + +class EpisodeEvent(BaseEpisodeEventCdm54, Base): + pass + + +class CdmSource(BaseCdmSourceCdm54, Base): + pass + + +class Metadata(BaseMetadataCdm54, Base): + pass + + +class Concept(BaseConceptCdm54, Base): + pass + + +class ConceptAncestor(BaseConceptAncestorCdm54, Base): + pass + + +class ConceptClass(BaseConceptClassCdm54, Base): + pass + + +class ConceptRelationship(BaseConceptRelationshipCdm54, Base): + pass + + +class ConceptSynonym(BaseConceptSynonymCdm54, Base): + pass + + +class DrugStrength(BaseDrugStrengthCdm54, Base): + pass + + +class Relationship(BaseRelationshipCdm54, Base): + pass + + +class SourceToConceptMap(BaseSourceToConceptMapCdm54, Base): + pass + + +class SourceToConceptMapVersion(BaseSourceToConceptMapVersionCdm54, Base): + pass + + +class Vocabulary(BaseVocabularyCdm54, Base): + pass + + +class Domain(BaseDomainCdm54, Base): + pass diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/__init__.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/__init__.py new file mode 100644 index 0000000..887b866 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/__init__.py @@ -0,0 +1,3 @@ +"""CDM 5.4 plus the legacy tables.""" + +from .tables import * # noqa: F403 diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/tables.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/tables.py new file mode 100644 index 0000000..e4b0f73 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm54_plus_legacy/tables.py @@ -0,0 +1,240 @@ +from sqlalchemy import MetaData +from sqlalchemy.orm import DeclarativeBase + +from src.omop_cdm.constants import NAMING_CONVENTION +from src.omop_cdm.dynamic.cdm54.clinical_data import ( + BaseConditionOccurrenceCdm54, + BaseDeathCdm54, + BaseDeviceExposureCdm54, + BaseDrugExposureCdm54, + BaseFactRelationshipCdm54, + BaseMeasurementCdm54, + BaseNoteCdm54, + BaseNoteNlpCdm54, + BaseObservationCdm54, + BaseObservationPeriodCdm54, + BasePersonCdm54, + BaseProcedureOccurrenceCdm54, + BaseSpecimenCdm54, + BaseStemTableCdm54, + BaseVisitDetailCdm54, + BaseVisitOccurrenceCdm54, +) +from src.omop_cdm.dynamic.cdm54.derived_elements import ( + BaseConditionEraCdm54, + BaseDoseEraCdm54, + BaseDrugEraCdm54, + BaseEpisodeCdm54, + BaseEpisodeEventCdm54, +) +from src.omop_cdm.dynamic.cdm54.health_economics import ( + BaseCostCdm54, + BasePayerPlanPeriodCdm54, +) +from src.omop_cdm.dynamic.cdm54.health_system_data import ( + BaseCareSiteCdm54, + BaseLocationCdm54, + BaseProviderCdm54, +) +from src.omop_cdm.dynamic.cdm54.metadata import ( + BaseCdmSourceCdm54, + BaseMetadataCdm54, +) +from src.omop_cdm.dynamic.cdm54.vocabularies.vocabularies import ( + BaseConceptAncestorCdm54, + BaseConceptCdm54, + BaseConceptClassCdm54, + BaseConceptRelationshipCdm54, + BaseConceptSynonymCdm54, + BaseDomainCdm54, + BaseDrugStrengthCdm54, + BaseRelationshipCdm54, + BaseSourceToConceptMapCdm54, + BaseSourceToConceptMapVersionCdm54, + BaseVocabularyCdm54, +) +from src.omop_cdm.dynamic.legacy.legacy import ( + BaseAttributeDefinition, + BaseCohort, + BaseCohortAttribute, + BaseCohortDefinition, +) + + +class Base(DeclarativeBase): + pass + + +Base.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class Person(BasePersonCdm54, Base): + pass + + +class Death(BaseDeathCdm54, Base): + pass + + +class Note(BaseNoteCdm54, Base): + pass + + +class Measurement(BaseMeasurementCdm54, Base): + pass + + +class NoteNlp(BaseNoteNlpCdm54, Base): + pass + + +class Observation(BaseObservationCdm54, Base): + pass + + +class Specimen(BaseSpecimenCdm54, Base): + pass + + +class StemTable(BaseStemTableCdm54, Base): + pass + + +class VisitDetail(BaseVisitDetailCdm54, Base): + pass + + +class ConditionOccurrence(BaseConditionOccurrenceCdm54, Base): + pass + + +class DeviceExposure(BaseDeviceExposureCdm54, Base): + pass + + +class DrugExposure(BaseDrugExposureCdm54, Base): + pass + + +class FactRelationship(BaseFactRelationshipCdm54, Base): + pass + + +class ObservationPeriod(BaseObservationPeriodCdm54, Base): + pass + + +class ProcedureOccurrence(BaseProcedureOccurrenceCdm54, Base): + pass + + +class VisitOccurrence(BaseVisitOccurrenceCdm54, Base): + pass + + +class Location(BaseLocationCdm54, Base): + pass + + +class CareSite(BaseCareSiteCdm54, Base): + pass + + +class Provider(BaseProviderCdm54, Base): + pass + + +class Cost(BaseCostCdm54, Base): + pass + + +class PayerPlanPeriod(BasePayerPlanPeriodCdm54, Base): + pass + + +class DoseEra(BaseDoseEraCdm54, Base): + pass + + +class DrugEra(BaseDrugEraCdm54, Base): + pass + + +class ConditionEra(BaseConditionEraCdm54, Base): + pass + + +class Episode(BaseEpisodeCdm54, Base): + pass + + +class EpisodeEvent(BaseEpisodeEventCdm54, Base): + pass + + +class CdmSource(BaseCdmSourceCdm54, Base): + pass + + +class Metadata(BaseMetadataCdm54, Base): + pass + + +class Concept(BaseConceptCdm54, Base): + pass + + +class ConceptAncestor(BaseConceptAncestorCdm54, Base): + pass + + +class ConceptClass(BaseConceptClassCdm54, Base): + pass + + +class ConceptRelationship(BaseConceptRelationshipCdm54, Base): + pass + + +class ConceptSynonym(BaseConceptSynonymCdm54, Base): + pass + + +class DrugStrength(BaseDrugStrengthCdm54, Base): + pass + + +class Relationship(BaseRelationshipCdm54, Base): + pass + + +class SourceToConceptMap(BaseSourceToConceptMapCdm54, Base): + pass + + +class SourceToConceptMapVersion(BaseSourceToConceptMapVersionCdm54, Base): + pass + + +class Vocabulary(BaseVocabularyCdm54, Base): + pass + + +class Domain(BaseDomainCdm54, Base): + pass + + +class Cohort(BaseCohort, Base): + pass + + +class CohortAttribute(BaseCohortAttribute, Base): + pass + + +class CohortDefinition(BaseCohortDefinition, Base): + pass + + +class AttributeDefinition(BaseAttributeDefinition, Base): + pass diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm600/__init__.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm600/__init__.py new file mode 100644 index 0000000..5f09675 --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm600/__init__.py @@ -0,0 +1 @@ +from .tables import * # noqa: F403 diff --git a/tests/omop_cdm/dynamic/cdm_definitions/cdm600/tables.py b/tests/omop_cdm/dynamic/cdm_definitions/cdm600/tables.py new file mode 100644 index 0000000..30263cb --- /dev/null +++ b/tests/omop_cdm/dynamic/cdm_definitions/cdm600/tables.py @@ -0,0 +1,213 @@ +from sqlalchemy import MetaData +from sqlalchemy.orm import DeclarativeBase + +from src.omop_cdm.constants import NAMING_CONVENTION +from src.omop_cdm.dynamic.cdm600.clinical_data import ( + BaseConditionOccurrenceCdm600, + BaseDeviceExposureCdm600, + BaseDrugExposureCdm600, + BaseFactRelationshipCdm600, + BaseMeasurementCdm600, + BaseNoteCdm600, + BaseNoteNlpCdm600, + BaseObservationCdm600, + BaseObservationPeriodCdm600, + BasePersonCdm600, + BaseProcedureOccurrenceCdm600, + BaseSpecimenCdm600, + BaseStemTableCdm600, + BaseSurveyConductCdm600, + BaseVisitDetailCdm600, + BaseVisitOccurrenceCdm600, +) +from src.omop_cdm.dynamic.cdm600.derived_elements import ( + BaseConditionEraCdm600, + BaseDoseEraCdm600, + BaseDrugEraCdm600, +) +from src.omop_cdm.dynamic.cdm600.health_economics import ( + BaseCostCdm600, + BasePayerPlanPeriodCdm600, +) +from src.omop_cdm.dynamic.cdm600.health_system_data import ( + BaseCareSiteCdm600, + BaseLocationCdm600, + BaseLocationHistoryCdm600, + BaseProviderCdm600, +) +from src.omop_cdm.dynamic.cdm600.metadata import ( + BaseCdmSourceCdm600, + BaseMetadataCdm600, +) +from src.omop_cdm.dynamic.cdm600.vocabularies import ( + BaseConceptAncestorCdm600, + BaseConceptCdm600, + BaseConceptClassCdm600, + BaseConceptRelationshipCdm600, + BaseConceptSynonymCdm600, + BaseDomainCdm600, + BaseDrugStrengthCdm600, + BaseRelationshipCdm600, + BaseSourceToConceptMapCdm600, + BaseSourceToConceptMapVersionCdm600, + BaseVocabularyCdm600, +) + + +class Base(DeclarativeBase): + pass + + +Base.metadata = MetaData(naming_convention=NAMING_CONVENTION) + + +class Person(BasePersonCdm600, Base): + pass + + +class Note(BaseNoteCdm600, Base): + pass + + +class Measurement(BaseMeasurementCdm600, Base): + pass + + +class NoteNlp(BaseNoteNlpCdm600, Base): + pass + + +class Observation(BaseObservationCdm600, Base): + pass + + +class Specimen(BaseSpecimenCdm600, Base): + pass + + +class StemTable(BaseStemTableCdm600, Base): + pass + + +class VisitDetail(BaseVisitDetailCdm600, Base): + pass + + +class ConditionOccurrence(BaseConditionOccurrenceCdm600, Base): + pass + + +class DeviceExposure(BaseDeviceExposureCdm600, Base): + pass + + +class DrugExposure(BaseDrugExposureCdm600, Base): + pass + + +class FactRelationship(BaseFactRelationshipCdm600, Base): + pass + + +class ObservationPeriod(BaseObservationPeriodCdm600, Base): + pass + + +class ProcedureOccurrence(BaseProcedureOccurrenceCdm600, Base): + pass + + +class SurveyConduct(BaseSurveyConductCdm600, Base): + pass + + +class VisitOccurrence(BaseVisitOccurrenceCdm600, Base): + pass + + +class Cost(BaseCostCdm600, Base): + pass + + +class PayerPlanPeriod(BasePayerPlanPeriodCdm600, Base): + pass + + +class CdmSource(BaseCdmSourceCdm600, Base): + pass + + +class Metadata(BaseMetadataCdm600, Base): + pass + + +class DoseEra(BaseDoseEraCdm600, Base): + pass + + +class DrugEra(BaseDrugEraCdm600, Base): + pass + + +class ConditionEra(BaseConditionEraCdm600, Base): + pass + + +class Location(BaseLocationCdm600, Base): + pass + + +class CareSite(BaseCareSiteCdm600, Base): + pass + + +class Provider(BaseProviderCdm600, Base): + pass + + +class LocationHistory(BaseLocationHistoryCdm600, Base): + pass + + +class Concept(BaseConceptCdm600, Base): + pass + + +class ConceptAncestor(BaseConceptAncestorCdm600, Base): + pass + + +class ConceptClass(BaseConceptClassCdm600, Base): + pass + + +class ConceptRelationship(BaseConceptRelationshipCdm600, Base): + pass + + +class ConceptSynonym(BaseConceptSynonymCdm600, Base): + pass + + +class DrugStrength(BaseDrugStrengthCdm600, Base): + pass + + +class Relationship(BaseRelationshipCdm600, Base): + pass + + +class SourceToConceptMap(BaseSourceToConceptMapCdm600, Base): + pass + + +class SourceToConceptMapVersion(BaseSourceToConceptMapVersionCdm600, Base): + pass + + +class Vocabulary(BaseVocabularyCdm600, Base): + pass + + +class Domain(BaseDomainCdm600, Base): + pass diff --git a/tests/omop_cdm/regular/cdm531/test_cdm531.py b/tests/omop_cdm/regular/cdm531/test_cdm531.py new file mode 100644 index 0000000..2597a08 --- /dev/null +++ b/tests/omop_cdm/regular/cdm531/test_cdm531.py @@ -0,0 +1,27 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +import src.omop_cdm.regular.cdm531 as cdm531 +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.table_sets import CDM531_NON_VOCAB, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab531", + CDM_SCHEMA: "cdm531", +} + + +@fixture(scope="session") +def cdm531_regular_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm531_regular(cdm531_regular_engine: Engine): + engine = cdm531_regular_engine + with temp_schemas(engine=engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables(engine=engine, metadata=cdm531.BaseCdm531.metadata) + vocab_tables = inspect(engine).get_table_names(SCHEMA_MAP[VOCAB_SCHEMA]) + cdm_tables = inspect(engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(vocab_tables) == VOCAB + assert set(cdm_tables) == CDM531_NON_VOCAB diff --git a/tests/omop_cdm/regular/cdm54/test_cdm54.py b/tests/omop_cdm/regular/cdm54/test_cdm54.py new file mode 100644 index 0000000..e1f5358 --- /dev/null +++ b/tests/omop_cdm/regular/cdm54/test_cdm54.py @@ -0,0 +1,27 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +import src.omop_cdm.regular.cdm54 as cdm54 +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.table_sets import CDM54_NON_VOCAB, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab54", + CDM_SCHEMA: "cdm54", +} + + +@fixture(scope="session") +def cdm54_regular_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm54_regular(cdm54_regular_engine: Engine): + engine = cdm54_regular_engine + with temp_schemas(engine=engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables(engine=engine, metadata=cdm54.BaseCdm54.metadata) + vocab_tables = inspect(engine).get_table_names(SCHEMA_MAP[VOCAB_SCHEMA]) + cdm_tables = inspect(engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(vocab_tables) == VOCAB + assert set(cdm_tables) == CDM54_NON_VOCAB diff --git a/tests/omop_cdm/regular/cdm54_extra_tables/test_cdm54_extra_tables.py b/tests/omop_cdm/regular/cdm54_extra_tables/test_cdm54_extra_tables.py new file mode 100644 index 0000000..9703afb --- /dev/null +++ b/tests/omop_cdm/regular/cdm54_extra_tables/test_cdm54_extra_tables.py @@ -0,0 +1,27 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.regular.cdm_definitions.cdm54_custom import BaseCdm54Extended +from tests.omop_cdm.table_sets import CDM54_NON_VOCAB, CUSTOM, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab54_custom", + CDM_SCHEMA: "cdm54_custom", +} + + +@fixture(scope="session") +def cdm54_extra_tables_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm54_extra_tables(cdm54_extra_tables_engine: Engine): + engine = cdm54_extra_tables_engine + with temp_schemas(engine=engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables(engine=engine, metadata=BaseCdm54Extended.metadata) + vocab_tables = inspect(engine).get_table_names(SCHEMA_MAP[VOCAB_SCHEMA]) + cdm_tables = inspect(engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(vocab_tables) == VOCAB + assert set(cdm_tables) == CDM54_NON_VOCAB | CUSTOM diff --git a/tests/omop_cdm/regular/cdm600/test_cdm600.py b/tests/omop_cdm/regular/cdm600/test_cdm600.py new file mode 100644 index 0000000..f700036 --- /dev/null +++ b/tests/omop_cdm/regular/cdm600/test_cdm600.py @@ -0,0 +1,27 @@ +from pytest import fixture +from sqlalchemy import Engine, inspect + +import src.omop_cdm.regular.cdm600 as cdm600 +from src.omop_cdm.constants import CDM_SCHEMA, VOCAB_SCHEMA +from tests.conftest import create_all_tables, temp_schemas +from tests.omop_cdm.table_sets import CDM600_NON_VOCAB, VOCAB + +SCHEMA_MAP = { + VOCAB_SCHEMA: "vocab600", + CDM_SCHEMA: "cdm600", +} + + +@fixture(scope="session") +def cdm600_regular_engine(pg_db_engine: Engine) -> Engine: + yield pg_db_engine.execution_options(schema_translate_map=SCHEMA_MAP) + + +def test_create_tables_cdm600_regular(cdm600_regular_engine: Engine): + engine = cdm600_regular_engine + with temp_schemas(engine=engine, schemas=set(SCHEMA_MAP.values())): + create_all_tables(engine=engine, metadata=cdm600.BaseCdm600.metadata) + vocab_tables = inspect(engine).get_table_names(SCHEMA_MAP[VOCAB_SCHEMA]) + cdm_tables = inspect(engine).get_table_names(SCHEMA_MAP[CDM_SCHEMA]) + assert set(vocab_tables) == VOCAB + assert set(cdm_tables) == CDM600_NON_VOCAB diff --git a/tests/omop_cdm/regular/cdm_definitions/cdm54_custom/__init__.py b/tests/omop_cdm/regular/cdm_definitions/cdm54_custom/__init__.py new file mode 100644 index 0000000..8d71672 --- /dev/null +++ b/tests/omop_cdm/regular/cdm_definitions/cdm54_custom/__init__.py @@ -0,0 +1,3 @@ +"""CDM 5.4 with extra tables.""" + +from .tables import * # noqa: F403 diff --git a/tests/omop_cdm/regular/cdm_definitions/cdm54_custom/tables.py b/tests/omop_cdm/regular/cdm_definitions/cdm54_custom/tables.py new file mode 100644 index 0000000..0f98ee3 --- /dev/null +++ b/tests/omop_cdm/regular/cdm_definitions/cdm54_custom/tables.py @@ -0,0 +1,29 @@ +from copy import deepcopy + +from sqlalchemy.orm import DeclarativeBase + +from src.omop_cdm.dynamic.cdm54.clinical_data import BaseStemTableCdm54 +from src.omop_cdm.dynamic.cdm54.vocabularies.vocabularies import ( + BaseSourceToConceptMapVersionCdm54, +) +from src.omop_cdm.regular.cdm54 import BaseCdm54 + + +# Workaround to avoid affecting the global scope via DeclarativeBase. +# Without it, the new tables added below would also affect the metadata +# property of BaseCdm54, meaning the extra tables would always be +# created instead of only for the relevant unit test. +class BaseCdm54Extended(DeclarativeBase): + pass + + +metadata = deepcopy(BaseCdm54.metadata) +BaseCdm54Extended.metadata = metadata + + +class SourceToConceptMapVersion(BaseSourceToConceptMapVersionCdm54, BaseCdm54Extended): + pass + + +class StemTable(BaseStemTableCdm54, BaseCdm54Extended): + pass diff --git a/tests/omop_cdm/table_sets.py b/tests/omop_cdm/table_sets.py new file mode 100644 index 0000000..d331ada --- /dev/null +++ b/tests/omop_cdm/table_sets.py @@ -0,0 +1,113 @@ +VOCAB = { + "concept", + "concept_ancestor", + "concept_class", + "concept_relationship", + "concept_synonym", + "domain", + "drug_strength", + "relationship", + "vocabulary", +} + +CDM531_NON_VOCAB = { + "care_site", + "cdm_source", + "condition_era", + "condition_occurrence", + "cost", + "death", + "device_exposure", + "dose_era", + "drug_era", + "drug_exposure", + "fact_relationship", + "location", + "measurement", + "metadata", + "note", + "note_nlp", + "observation", + "observation_period", + "payer_plan_period", + "person", + "procedure_occurrence", + "provider", + "specimen", + "visit_detail", + "visit_occurrence", + "source_to_concept_map", +} + +CDM54_NON_VOCAB = { + "care_site", + "cdm_source", + "condition_era", + "condition_occurrence", + "cost", + "death", + "device_exposure", + "dose_era", + "drug_era", + "drug_exposure", + "episode", + "episode_event", + "fact_relationship", + "location", + "measurement", + "metadata", + "note", + "note_nlp", + "observation", + "observation_period", + "payer_plan_period", + "person", + "procedure_occurrence", + "provider", + "specimen", + "visit_detail", + "visit_occurrence", + "source_to_concept_map", +} + +CDM600_NON_VOCAB = { + "care_site", + "cdm_source", + "condition_era", + "condition_occurrence", + "cost", + "device_exposure", + "dose_era", + "drug_era", + "drug_exposure", + "fact_relationship", + "location", + "location_history", + "measurement", + "metadata", + "note", + "note_nlp", + "observation", + "observation_period", + "payer_plan_period", + "person", + "procedure_occurrence", + "provider", + "specimen", + "survey_conduct", + "visit_detail", + "visit_occurrence", + "source_to_concept_map", +} + +LEGACY = { + "cohort", + "cohort_definition", + "cohort_attribute", + "attribute_definition", +} + +CUSTOM = { + "source_to_concept_map_version", + "stem_table", +}