From 2ce4a35c78e6731eb72bc9db593b65538163480a Mon Sep 17 00:00:00 2001 From: Sunny Sun <38218185+sunnyosun@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:05:30 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Fix=20CI=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .pre-commit-config.yaml | 3 +- LICENSE | 201 +++ docs/index.md | 1 + docs/inspectdb.ipynb | 155 --- docs/notes.md | 7 + docs/notes/inspectdb.ipynb | 1216 +++++++++++++++++ docs/quickstart.ipynb | 2 - noxfile.py | 5 +- omop/__init__.py | 2 + omop/migrations/0001_initial.py | 47 +- ...pt_class_remove_concept_domain_and_more.py | 40 - omop/models.py | 80 +- tests/test_notebooks.py | 3 +- 14 files changed, 1478 insertions(+), 285 deletions(-) create mode 100644 LICENSE delete mode 100644 docs/inspectdb.ipynb create mode 100644 docs/notes.md create mode 100644 docs/notes/inspectdb.ipynb delete mode 100644 omop/migrations/0002_alter_concept_concept_class_remove_concept_domain_and_more.py diff --git a/.gitignore b/.gitignore index 545f162..cc55b43 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,4 @@ lamin_sphinx docs/conf.py _docs_tmp* testdb/ +OMOP_5.4/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d6962fa..ceaf80e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,5 +48,4 @@ repos: hooks: - id: mypy args: [--no-strict-optional, --ignore-missing-imports] - additional_dependencies: - ["types-pkg-resources", "types-requests", "types-attrs"] + additional_dependencies: ["types-requests", "types-attrs"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b09cd78 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/index.md b/docs/index.md index 8463317..0f708d1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,6 +8,7 @@ :hidden: guide +notes reference changelog ``` diff --git a/docs/inspectdb.ipynb b/docs/inspectdb.ipynb deleted file mode 100644 index 8518119..0000000 --- a/docs/inspectdb.ipynb +++ /dev/null @@ -1,155 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Inspectdb to generate django models\n", - "\n", - "Download sql statements files from: https://github.com/OHDSI/CommonDataModel/tree/main/ddl/5.4/postgresql" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from laminci.db import setup_local_test_postgres\n", - "import lamindb_setup as ln_setup\n", - "from django.db import connection" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "pgurl = setup_local_test_postgres()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ln_setup.init(storage=\"./default_storage\", name=\"lOMOPCDM_5.4\", db=pgurl)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for file in [\n", - " \"OMOPCDM_postgresql_5.4_ddl.sql\", \n", - " \"OMOPCDM_postgresql_5.4_indices.sql\", \n", - " \"OMOPCDM_postgresql_5.4_primary_keys.sql\", \n", - " \"OMOPCDM_postgresql_5.4_constraints.sql\"]:\n", - " print(\"Executing file:\", file)\n", - " with open(file, \"r\") as sql_file:\n", - " sql_statements = sql_file.read()\n", - "\n", - " statements = sql_statements.split(\";\")\n", - "\n", - " with connection.cursor() as cursor:\n", - " for statement in statements:\n", - " # Remove comments and trailing whitespace\n", - " statement = statement.strip().rstrip(\"--\")\n", - " if statement: # Skip empty lines and comments\n", - " try:\n", - " cursor.execute(statement)\n", - " except Exception as e:\n", - " print(\"Error executing statement:\", statement)\n", - " print(e)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ln_setup.django(\"inspectdb\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def remove_lnchema_classes(file_path):\n", - " \"\"\"\n", - " Removes entire classes starting with \"Lnschema\" from a Python file.\n", - "\n", - " Args:\n", - " file_path: Path to the Python file.\n", - "\n", - " Returns:\n", - " A string containing the modified code without \"Lnschema\" classes.\n", - " \"\"\"\n", - "\n", - " with open(file_path, \"r\") as f:\n", - " content = f.readlines()\n", - "\n", - " # Flag to track if inside a class definition\n", - " in_class = False\n", - " class_name = None\n", - " modified_lines = []\n", - "\n", - " for line in content:\n", - " if line.strip().startswith(\"class Lnschema\"):\n", - " # Start of a class with \"Lnschema\" prefix\n", - " in_class = True\n", - " class_name = line.split()[1] # Extract class name\n", - " elif line.strip() == \"}\" and in_class:\n", - " # End of the class with \"Lnschema\" prefix\n", - " in_class = False\n", - " class_name = None\n", - " elif not in_class:\n", - " # Lines outside a class or not starting with \"Lnschema\" class\n", - " modified_lines.append(line)\n", - " else:\n", - " # Skip lines inside a class with \"Lnschema\" prefix\n", - " pass\n", - "\n", - " return \"\".join(modified_lines)\n", - "\n", - "# Example usage\n", - "file_path = \"your_models.py\" # Replace with your actual file path\n", - "modified_code = remove_lnchema_classes(file_path)\n", - "\n", - "# Optionally, write the modified code to a new file\n", - "with open(\"modified_models.py\", \"w\") as f:\n", - " f.write(modified_code)\n", - "\n", - "print(\"Successfully removed entire 'Lnschema' classes!\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "py310", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/notes.md b/docs/notes.md new file mode 100644 index 0000000..460252e --- /dev/null +++ b/docs/notes.md @@ -0,0 +1,7 @@ +# Notes + +```{toctree} +:maxdepth: 1 + +notes/inspectdb +``` diff --git a/docs/notes/inspectdb.ipynb b/docs/notes/inspectdb.ipynb new file mode 100644 index 0000000..aec8b0b --- /dev/null +++ b/docs/notes/inspectdb.ipynb @@ -0,0 +1,1216 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Inspectdb to generate django models\n", + "\n", + "Download sql statements files from: https://github.com/OHDSI/CommonDataModel/tree/main/ddl/5.4/postgresql" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from laminci.db import setup_local_test_postgres\n", + "import lamindb_setup as ln_setup\n", + "from django.db import connection" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "57191f10f02c8c9c5208e2d650badc24c3874ecc32a7023db8806d2dcc7a8fa9\n", + "💡 Created Postgres test instance: 'postgresql://postgres:pwd@0.0.0.0:5432/pgtest'\n", + "It runs in docker container 'pgtest'\n" + ] + } + ], + "source": [ + "pgurl = setup_local_test_postgres()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ln_setup.init(storage=\"./default_storage\", name=\"lOMOPCDM_5.4\", db=pgurl)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Executing file: OMOPCDM_postgresql_5.4_indices.sql\n", + "Executing file: OMOPCDM_postgresql_5.4_primary_keys.sql\n", + "Executing file: OMOPCDM_postgresql_5.4_constraints.sql\n" + ] + } + ], + "source": [ + "for file in [\n", + " \"OMOPCDM_postgresql_5.4_ddl.sql\", \n", + " \"OMOPCDM_postgresql_5.4_indices.sql\", \n", + " \"OMOPCDM_postgresql_5.4_primary_keys.sql\", \n", + " \"OMOPCDM_postgresql_5.4_constraints.sql\"]:\n", + " print(\"Executing file:\", file)\n", + " with open(file, \"r\") as sql_file:\n", + " sql_statements = sql_file.read()\n", + "\n", + " statements = sql_statements.split(\";\")\n", + "\n", + " with connection.cursor() as cursor:\n", + " for statement in statements:\n", + " # Remove comments and trailing whitespace\n", + " statement = statement.strip().rstrip(\"--\")\n", + " if statement: # Skip empty lines and comments\n", + " try:\n", + " cursor.execute(statement)\n", + " except Exception as e:\n", + " print(\"Error executing statement:\", statement)\n", + " print(e)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "# This is an auto-generated Django model module.\n", + "# You'll have to do the following manually to clean this up:\n", + "# * Rearrange models' order\n", + "# * Make sure each model has one field with primary_key=True\n", + "# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior\n", + "# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table\n", + "# Feel free to rename the models, but don't rename db_table values or field names.\n", + "from django.db import models\n", + "\n", + "\n", + "class CareSite(models.Model):\n", + " care_site_id = models.IntegerField(primary_key=True)\n", + " care_site_name = models.CharField(max_length=255, blank=True, null=True)\n", + " place_of_service_concept = models.ForeignKey('Concept', models.DO_NOTHING, blank=True, null=True)\n", + " location = models.ForeignKey('Location', models.DO_NOTHING, blank=True, null=True)\n", + " care_site_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " place_of_service_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'care_site'\n", + "\n", + "\n", + "class CdmSource(models.Model):\n", + " cdm_source_name = models.CharField(max_length=255)\n", + " cdm_source_abbreviation = models.CharField(max_length=25)\n", + " cdm_holder = models.CharField(max_length=255)\n", + " source_description = models.TextField(blank=True, null=True)\n", + " source_documentation_reference = models.CharField(max_length=255, blank=True, null=True)\n", + " cdm_etl_reference = models.CharField(max_length=255, blank=True, null=True)\n", + " source_release_date = models.DateField()\n", + " cdm_release_date = models.DateField()\n", + " cdm_version = models.CharField(max_length=10, blank=True, null=True)\n", + " cdm_version_concept = models.ForeignKey('Concept', models.DO_NOTHING)\n", + " vocabulary_version = models.CharField(max_length=20)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'cdm_source'\n", + "\n", + "\n", + "class Cohort(models.Model):\n", + " cohort_definition_id = models.IntegerField()\n", + " subject_id = models.IntegerField()\n", + " cohort_start_date = models.DateField()\n", + " cohort_end_date = models.DateField()\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'cohort'\n", + "\n", + "\n", + "class CohortDefinition(models.Model):\n", + " cohort_definition_id = models.IntegerField()\n", + " cohort_definition_name = models.CharField(max_length=255)\n", + " cohort_definition_description = models.TextField(blank=True, null=True)\n", + " definition_type_concept = models.ForeignKey('Concept', models.DO_NOTHING)\n", + " cohort_definition_syntax = models.TextField(blank=True, null=True)\n", + " subject_concept = models.ForeignKey('Concept', models.DO_NOTHING, related_name='cohortdefinition_subject_concept_set')\n", + " cohort_initiation_date = models.DateField(blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'cohort_definition'\n", + "\n", + "\n", + "class Concept(models.Model):\n", + " concept_id = models.IntegerField(primary_key=True)\n", + " concept_name = models.CharField(max_length=255)\n", + " domain = models.ForeignKey('Domain', models.DO_NOTHING)\n", + " vocabulary = models.ForeignKey('Vocabulary', models.DO_NOTHING)\n", + " concept_class = models.ForeignKey('ConceptClass', models.DO_NOTHING)\n", + " standard_concept = models.CharField(max_length=1, blank=True, null=True)\n", + " concept_code = models.CharField(max_length=50)\n", + " valid_start_date = models.DateField()\n", + " valid_end_date = models.DateField()\n", + " invalid_reason = models.CharField(max_length=1, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'concept'\n", + "\n", + "\n", + "class ConceptAncestor(models.Model):\n", + " ancestor_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " descendant_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='conceptancestor_descendant_concept_set')\n", + " min_levels_of_separation = models.IntegerField()\n", + " max_levels_of_separation = models.IntegerField()\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'concept_ancestor'\n", + "\n", + "\n", + "class ConceptClass(models.Model):\n", + " concept_class_id = models.CharField(primary_key=True, max_length=20)\n", + " concept_class_name = models.CharField(max_length=255)\n", + " concept_class_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'concept_class'\n", + "\n", + "\n", + "class ConceptRelationship(models.Model):\n", + " concept_id_1 = models.ForeignKey(Concept, models.DO_NOTHING, db_column='concept_id_1')\n", + " concept_id_2 = models.ForeignKey(Concept, models.DO_NOTHING, db_column='concept_id_2', related_name='conceptrelationship_concept_id_2_set')\n", + " relationship = models.ForeignKey('Relationship', models.DO_NOTHING)\n", + " valid_start_date = models.DateField()\n", + " valid_end_date = models.DateField()\n", + " invalid_reason = models.CharField(max_length=1, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'concept_relationship'\n", + "\n", + "\n", + "class ConceptSynonym(models.Model):\n", + " concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " concept_synonym_name = models.CharField(max_length=1000)\n", + " language_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='conceptsynonym_language_concept_set')\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'concept_synonym'\n", + "\n", + "\n", + "class ConditionEra(models.Model):\n", + " condition_era_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " condition_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " condition_era_start_date = models.DateField()\n", + " condition_era_end_date = models.DateField()\n", + " condition_occurrence_count = models.IntegerField(blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'condition_era'\n", + "\n", + "\n", + "class ConditionOccurrence(models.Model):\n", + " condition_occurrence_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " condition_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " condition_start_date = models.DateField()\n", + " condition_start_datetime = models.DateTimeField(blank=True, null=True)\n", + " condition_end_date = models.DateField(blank=True, null=True)\n", + " condition_end_datetime = models.DateTimeField(blank=True, null=True)\n", + " condition_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='conditionoccurrence_condition_type_concept_set')\n", + " condition_status_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='conditionoccurrence_condition_status_concept_set', blank=True, null=True)\n", + " stop_reason = models.CharField(max_length=20, blank=True, null=True)\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail = models.ForeignKey('VisitDetail', models.DO_NOTHING, blank=True, null=True)\n", + " condition_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " condition_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='conditionoccurrence_condition_source_concept_set', blank=True, null=True)\n", + " condition_status_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'condition_occurrence'\n", + "\n", + "\n", + "class Cost(models.Model):\n", + " cost_id = models.IntegerField(primary_key=True)\n", + " cost_event_id = models.IntegerField()\n", + " cost_domain = models.ForeignKey('Domain', models.DO_NOTHING)\n", + " cost_type_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " currency_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='cost_currency_concept_set', blank=True, null=True)\n", + " total_charge = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " total_cost = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " total_paid = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_by_payer = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_by_patient = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_patient_copay = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_patient_coinsurance = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_patient_deductible = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_by_primary = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_ingredient_cost = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " paid_dispensing_fee = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " payer_plan_period_id = models.IntegerField(blank=True, null=True)\n", + " amount_allowed = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " revenue_code_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='cost_revenue_code_concept_set', blank=True, null=True)\n", + " revenue_code_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " drg_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='cost_drg_concept_set', blank=True, null=True)\n", + " drg_source_value = models.CharField(max_length=3, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'cost'\n", + "\n", + "\n", + "class Death(models.Model):\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " death_date = models.DateField()\n", + " death_datetime = models.DateTimeField(blank=True, null=True)\n", + " death_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, blank=True, null=True)\n", + " cause_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='death_cause_concept_set', blank=True, null=True)\n", + " cause_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " cause_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='death_cause_source_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'death'\n", + "\n", + "\n", + "class DeviceExposure(models.Model):\n", + " device_exposure_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " device_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " device_exposure_start_date = models.DateField()\n", + " device_exposure_start_datetime = models.DateTimeField(blank=True, null=True)\n", + " device_exposure_end_date = models.DateField(blank=True, null=True)\n", + " device_exposure_end_datetime = models.DateTimeField(blank=True, null=True)\n", + " device_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='deviceexposure_device_type_concept_set')\n", + " unique_device_id = models.CharField(max_length=255, blank=True, null=True)\n", + " production_id = models.CharField(max_length=255, blank=True, null=True)\n", + " quantity = models.IntegerField(blank=True, null=True)\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail = models.ForeignKey('VisitDetail', models.DO_NOTHING, blank=True, null=True)\n", + " device_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " device_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='deviceexposure_device_source_concept_set', blank=True, null=True)\n", + " unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='deviceexposure_unit_concept_set', blank=True, null=True)\n", + " unit_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " unit_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='deviceexposure_unit_source_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'device_exposure'\n", + "\n", + "\n", + "class DjangoMigrations(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " app = models.CharField(max_length=255)\n", + " name = models.CharField(max_length=255)\n", + " applied = models.DateTimeField()\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'django_migrations'\n", + "\n", + "\n", + "class Domain(models.Model):\n", + " domain_id = models.CharField(primary_key=True, max_length=20)\n", + " domain_name = models.CharField(max_length=255)\n", + " domain_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'domain'\n", + "\n", + "\n", + "class DoseEra(models.Model):\n", + " dose_era_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " drug_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='doseera_unit_concept_set')\n", + " dose_value = models.DecimalField(max_digits=65535, decimal_places=65535)\n", + " dose_era_start_date = models.DateField()\n", + " dose_era_end_date = models.DateField()\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'dose_era'\n", + "\n", + "\n", + "class DrugEra(models.Model):\n", + " drug_era_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " drug_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " drug_era_start_date = models.DateField()\n", + " drug_era_end_date = models.DateField()\n", + " drug_exposure_count = models.IntegerField(blank=True, null=True)\n", + " gap_days = models.IntegerField(blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'drug_era'\n", + "\n", + "\n", + "class DrugExposure(models.Model):\n", + " drug_exposure_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " drug_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " drug_exposure_start_date = models.DateField()\n", + " drug_exposure_start_datetime = models.DateTimeField(blank=True, null=True)\n", + " drug_exposure_end_date = models.DateField()\n", + " drug_exposure_end_datetime = models.DateTimeField(blank=True, null=True)\n", + " verbatim_end_date = models.DateField(blank=True, null=True)\n", + " drug_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='drugexposure_drug_type_concept_set')\n", + " stop_reason = models.CharField(max_length=20, blank=True, null=True)\n", + " refills = models.IntegerField(blank=True, null=True)\n", + " quantity = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " days_supply = models.IntegerField(blank=True, null=True)\n", + " sig = models.TextField(blank=True, null=True)\n", + " route_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='drugexposure_route_concept_set', blank=True, null=True)\n", + " lot_number = models.CharField(max_length=50, blank=True, null=True)\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail = models.ForeignKey('VisitDetail', models.DO_NOTHING, blank=True, null=True)\n", + " drug_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " drug_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='drugexposure_drug_source_concept_set', blank=True, null=True)\n", + " route_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " dose_unit_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'drug_exposure'\n", + "\n", + "\n", + "class DrugStrength(models.Model):\n", + " drug_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " ingredient_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='drugstrength_ingredient_concept_set')\n", + " amount_value = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " amount_unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='drugstrength_amount_unit_concept_set', blank=True, null=True)\n", + " numerator_value = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " numerator_unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='drugstrength_numerator_unit_concept_set', blank=True, null=True)\n", + " denominator_value = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " denominator_unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='drugstrength_denominator_unit_concept_set', blank=True, null=True)\n", + " box_size = models.IntegerField(blank=True, null=True)\n", + " valid_start_date = models.DateField()\n", + " valid_end_date = models.DateField()\n", + " invalid_reason = models.CharField(max_length=1, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'drug_strength'\n", + "\n", + "\n", + "class Episode(models.Model):\n", + " episode_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " episode_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " episode_start_date = models.DateField()\n", + " episode_start_datetime = models.DateTimeField(blank=True, null=True)\n", + " episode_end_date = models.DateField(blank=True, null=True)\n", + " episode_end_datetime = models.DateTimeField(blank=True, null=True)\n", + " episode_parent_id = models.IntegerField(blank=True, null=True)\n", + " episode_number = models.IntegerField(blank=True, null=True)\n", + " episode_object_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='episode_episode_object_concept_set')\n", + " episode_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='episode_episode_type_concept_set')\n", + " episode_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " episode_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='episode_episode_source_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'episode'\n", + "\n", + "\n", + "class EpisodeEvent(models.Model):\n", + " episode = models.ForeignKey(Episode, models.DO_NOTHING)\n", + " event_id = models.IntegerField()\n", + " episode_event_field_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'episode_event'\n", + "\n", + "\n", + "class FactRelationship(models.Model):\n", + " domain_concept_id_1 = models.ForeignKey(Concept, models.DO_NOTHING, db_column='domain_concept_id_1')\n", + " fact_id_1 = models.IntegerField()\n", + " domain_concept_id_2 = models.ForeignKey(Concept, models.DO_NOTHING, db_column='domain_concept_id_2', related_name='factrelationship_domain_concept_id_2_set')\n", + " fact_id_2 = models.IntegerField()\n", + " relationship_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='factrelationship_relationship_concept_set')\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'fact_relationship'\n", + "\n", + "\n", + "class LnschemaCoreArtifact(models.Model):\n", + " uid = models.CharField(unique=True, max_length=20)\n", + " key = models.CharField(max_length=255, blank=True, null=True)\n", + " suffix = models.CharField(max_length=30)\n", + " accessor = models.CharField(max_length=64, blank=True, null=True)\n", + " description = models.CharField(max_length=255, blank=True, null=True)\n", + " version = models.CharField(max_length=10, blank=True, null=True)\n", + " size = models.BigIntegerField(blank=True, null=True)\n", + " hash = models.CharField(max_length=86, blank=True, null=True)\n", + " hash_type = models.CharField(max_length=30, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + " run = models.ForeignKey('LnschemaCoreRun', models.DO_NOTHING, blank=True, null=True)\n", + " storage = models.ForeignKey('LnschemaCoreStorage', models.DO_NOTHING)\n", + " transform = models.ForeignKey('LnschemaCoreTransform', models.DO_NOTHING, blank=True, null=True)\n", + " visibility = models.SmallIntegerField()\n", + " key_is_virtual = models.BooleanField()\n", + " n_objects = models.BigIntegerField(blank=True, null=True)\n", + " n_observations = models.BigIntegerField(blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_artifact'\n", + "\n", + "\n", + "class LnschemaCoreArtifactInputOf(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " artifact = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING)\n", + " run = models.ForeignKey('LnschemaCoreRun', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_artifact_input_of'\n", + " unique_together = (('artifact', 'run'),)\n", + "\n", + "\n", + "class LnschemaCoreArtifactfeatureset(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " slot = models.CharField(max_length=40, blank=True, null=True)\n", + " feature_set = models.ForeignKey('LnschemaCoreFeatureset', models.DO_NOTHING)\n", + " artifact = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_artifactfeatureset'\n", + " unique_together = (('artifact', 'feature_set'),)\n", + "\n", + "\n", + "class LnschemaCoreArtifactulabel(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " feature = models.ForeignKey('LnschemaCoreFeature', models.DO_NOTHING, blank=True, null=True)\n", + " artifact = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING)\n", + " ulabel = models.ForeignKey('LnschemaCoreUlabel', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_artifactulabel'\n", + " unique_together = (('artifact', 'ulabel'),)\n", + "\n", + "\n", + "class LnschemaCoreCollection(models.Model):\n", + " uid = models.CharField(unique=True, max_length=20)\n", + " name = models.CharField(max_length=150)\n", + " description = models.TextField(blank=True, null=True)\n", + " version = models.CharField(max_length=10, blank=True, null=True)\n", + " hash = models.CharField(max_length=86, blank=True, null=True)\n", + " reference = models.CharField(max_length=255, blank=True, null=True)\n", + " reference_type = models.CharField(max_length=25, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + " artifact = models.OneToOneField(LnschemaCoreArtifact, models.DO_NOTHING, blank=True, null=True)\n", + " run = models.ForeignKey('LnschemaCoreRun', models.DO_NOTHING, blank=True, null=True)\n", + " transform = models.ForeignKey('LnschemaCoreTransform', models.DO_NOTHING, blank=True, null=True)\n", + " visibility = models.SmallIntegerField()\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_collection'\n", + "\n", + "\n", + "class LnschemaCoreCollectionInputOf(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " collection = models.ForeignKey(LnschemaCoreCollection, models.DO_NOTHING)\n", + " run = models.ForeignKey('LnschemaCoreRun', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_collection_input_of'\n", + " unique_together = (('collection', 'run'),)\n", + "\n", + "\n", + "class LnschemaCoreCollectionartifact(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " collection = models.ForeignKey(LnschemaCoreCollection, models.DO_NOTHING)\n", + " artifact = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_collectionartifact'\n", + " unique_together = (('collection', 'artifact'),)\n", + "\n", + "\n", + "class LnschemaCoreCollectionfeatureset(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " slot = models.CharField(max_length=50, blank=True, null=True)\n", + " collection = models.ForeignKey(LnschemaCoreCollection, models.DO_NOTHING)\n", + " feature_set = models.ForeignKey('LnschemaCoreFeatureset', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_collectionfeatureset'\n", + " unique_together = (('collection', 'feature_set'),)\n", + "\n", + "\n", + "class LnschemaCoreCollectionulabel(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " collection = models.ForeignKey(LnschemaCoreCollection, models.DO_NOTHING)\n", + " feature = models.ForeignKey('LnschemaCoreFeature', models.DO_NOTHING, blank=True, null=True)\n", + " ulabel = models.ForeignKey('LnschemaCoreUlabel', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_collectionulabel'\n", + " unique_together = (('collection', 'ulabel'),)\n", + "\n", + "\n", + "class LnschemaCoreFeature(models.Model):\n", + " uid = models.CharField(unique=True, max_length=12)\n", + " name = models.CharField(max_length=150)\n", + " type = models.CharField(max_length=64)\n", + " unit = models.CharField(max_length=30, blank=True, null=True)\n", + " description = models.TextField(blank=True, null=True)\n", + " registries = models.CharField(max_length=120, blank=True, null=True)\n", + " synonyms = models.TextField(blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_feature'\n", + "\n", + "\n", + "class LnschemaCoreFeatureFeatureSets(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " feature = models.ForeignKey(LnschemaCoreFeature, models.DO_NOTHING)\n", + " featureset = models.ForeignKey('LnschemaCoreFeatureset', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_feature_feature_sets'\n", + " unique_together = (('feature', 'featureset'),)\n", + "\n", + "\n", + "class LnschemaCoreFeatureset(models.Model):\n", + " uid = models.CharField(unique=True, max_length=20)\n", + " name = models.CharField(max_length=150, blank=True, null=True)\n", + " n = models.IntegerField()\n", + " type = models.CharField(max_length=64, blank=True, null=True)\n", + " registry = models.CharField(max_length=120)\n", + " hash = models.CharField(max_length=20, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_featureset'\n", + "\n", + "\n", + "class LnschemaCoreRun(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " uid = models.CharField(unique=True, max_length=20)\n", + " started_at = models.DateTimeField()\n", + " is_consecutive = models.BooleanField(blank=True, null=True)\n", + " reference = models.CharField(max_length=255, blank=True, null=True)\n", + " reference_type = models.CharField(max_length=25, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + " report = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING, blank=True, null=True)\n", + " transform = models.ForeignKey('LnschemaCoreTransform', models.DO_NOTHING)\n", + " environment = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING, related_name='lnschemacorerun_environment_set', blank=True, null=True)\n", + " finished_at = models.DateTimeField(blank=True, null=True)\n", + " json = models.JSONField(blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_run'\n", + "\n", + "\n", + "class LnschemaCoreRunReplicatedOutputArtifacts(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " run = models.ForeignKey(LnschemaCoreRun, models.DO_NOTHING)\n", + " artifact = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_run_replicated_output_artifacts'\n", + " unique_together = (('run', 'artifact'),)\n", + "\n", + "\n", + "class LnschemaCoreRunReplicatedOutputCollections(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " run = models.ForeignKey(LnschemaCoreRun, models.DO_NOTHING)\n", + " collection = models.ForeignKey(LnschemaCoreCollection, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_run_replicated_output_collections'\n", + " unique_together = (('run', 'collection'),)\n", + "\n", + "\n", + "class LnschemaCoreStorage(models.Model):\n", + " uid = models.CharField(unique=True, max_length=12)\n", + " root = models.CharField(unique=True, max_length=255)\n", + " type = models.CharField(max_length=30)\n", + " region = models.CharField(max_length=64, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + " description = models.CharField(max_length=255, blank=True, null=True)\n", + " instance_uid = models.CharField(max_length=12, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_storage'\n", + "\n", + "\n", + "class LnschemaCoreTransform(models.Model):\n", + " uid = models.CharField(unique=True, max_length=16)\n", + " name = models.CharField(max_length=150, blank=True, null=True)\n", + " key = models.CharField(max_length=120, blank=True, null=True)\n", + " version = models.CharField(max_length=10, blank=True, null=True)\n", + " type = models.CharField(max_length=20)\n", + " reference = models.CharField(max_length=255, blank=True, null=True)\n", + " reference_type = models.CharField(max_length=25, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + " latest_report = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING, blank=True, null=True)\n", + " source_code = models.ForeignKey(LnschemaCoreArtifact, models.DO_NOTHING, related_name='lnschemacoretransform_source_code_set', blank=True, null=True)\n", + " description = models.CharField(max_length=255, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_transform'\n", + "\n", + "\n", + "class LnschemaCoreTransformParents(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " from_transform = models.ForeignKey(LnschemaCoreTransform, models.DO_NOTHING)\n", + " to_transform = models.ForeignKey(LnschemaCoreTransform, models.DO_NOTHING, related_name='lnschemacoretransformparents_to_transform_set')\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_transform_parents'\n", + " unique_together = (('from_transform', 'to_transform'),)\n", + "\n", + "\n", + "class LnschemaCoreTransformUlabels(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " transform = models.ForeignKey(LnschemaCoreTransform, models.DO_NOTHING)\n", + " ulabel = models.ForeignKey('LnschemaCoreUlabel', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_transform_ulabels'\n", + " unique_together = (('transform', 'ulabel'),)\n", + "\n", + "\n", + "class LnschemaCoreUlabel(models.Model):\n", + " uid = models.CharField(unique=True, max_length=8)\n", + " name = models.CharField(unique=True, max_length=150)\n", + " description = models.TextField(blank=True, null=True)\n", + " reference = models.CharField(max_length=255, blank=True, null=True)\n", + " reference_type = models.CharField(max_length=25, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + " created_by = models.ForeignKey('LnschemaCoreUser', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_ulabel'\n", + "\n", + "\n", + "class LnschemaCoreUlabelParents(models.Model):\n", + " id = models.BigAutoField(primary_key=True)\n", + " from_ulabel = models.ForeignKey(LnschemaCoreUlabel, models.DO_NOTHING)\n", + " to_ulabel = models.ForeignKey(LnschemaCoreUlabel, models.DO_NOTHING, related_name='lnschemacoreulabelparents_to_ulabel_set')\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_ulabel_parents'\n", + " unique_together = (('from_ulabel', 'to_ulabel'),)\n", + "\n", + "\n", + "class LnschemaCoreUser(models.Model):\n", + " uid = models.CharField(unique=True, max_length=8)\n", + " handle = models.CharField(unique=True, max_length=30)\n", + " name = models.CharField(max_length=150, blank=True, null=True)\n", + " created_at = models.DateTimeField()\n", + " updated_at = models.DateTimeField()\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'lnschema_core_user'\n", + "\n", + "\n", + "class Location(models.Model):\n", + " location_id = models.IntegerField(primary_key=True)\n", + " address_1 = models.CharField(max_length=50, blank=True, null=True)\n", + " address_2 = models.CharField(max_length=50, blank=True, null=True)\n", + " city = models.CharField(max_length=50, blank=True, null=True)\n", + " state = models.CharField(max_length=2, blank=True, null=True)\n", + " zip = models.CharField(max_length=9, blank=True, null=True)\n", + " county = models.CharField(max_length=20, blank=True, null=True)\n", + " location_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " country_concept = models.ForeignKey(Concept, models.DO_NOTHING, blank=True, null=True)\n", + " country_source_value = models.CharField(max_length=80, blank=True, null=True)\n", + " latitude = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " longitude = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'location'\n", + "\n", + "\n", + "class Measurement(models.Model):\n", + " measurement_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " measurement_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " measurement_date = models.DateField()\n", + " measurement_datetime = models.DateTimeField(blank=True, null=True)\n", + " measurement_time = models.CharField(max_length=10, blank=True, null=True)\n", + " measurement_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='measurement_measurement_type_concept_set')\n", + " operator_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='measurement_operator_concept_set', blank=True, null=True)\n", + " value_as_number = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " value_as_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='measurement_value_as_concept_set', blank=True, null=True)\n", + " unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='measurement_unit_concept_set', blank=True, null=True)\n", + " range_low = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " range_high = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail = models.ForeignKey('VisitDetail', models.DO_NOTHING, blank=True, null=True)\n", + " measurement_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " measurement_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='measurement_measurement_source_concept_set', blank=True, null=True)\n", + " unit_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " unit_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='measurement_unit_source_concept_set', blank=True, null=True)\n", + " value_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " measurement_event_id = models.IntegerField(blank=True, null=True)\n", + " meas_event_field_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='measurement_meas_event_field_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'measurement'\n", + "\n", + "\n", + "class Metadata(models.Model):\n", + " metadata_id = models.IntegerField(primary_key=True)\n", + " metadata_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " metadata_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='metadata_metadata_type_concept_set')\n", + " name = models.CharField(max_length=250)\n", + " value_as_string = models.CharField(max_length=250, blank=True, null=True)\n", + " value_as_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='metadata_value_as_concept_set', blank=True, null=True)\n", + " value_as_number = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " metadata_date = models.DateField(blank=True, null=True)\n", + " metadata_datetime = models.DateTimeField(blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'metadata'\n", + "\n", + "\n", + "class Note(models.Model):\n", + " note_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " note_date = models.DateField()\n", + " note_datetime = models.DateTimeField(blank=True, null=True)\n", + " note_type_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " note_class_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='note_note_class_concept_set')\n", + " note_title = models.CharField(max_length=250, blank=True, null=True)\n", + " note_text = models.TextField()\n", + " encoding_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='note_encoding_concept_set')\n", + " language_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='note_language_concept_set')\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail = models.ForeignKey('VisitDetail', models.DO_NOTHING, blank=True, null=True)\n", + " note_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " note_event_id = models.IntegerField(blank=True, null=True)\n", + " note_event_field_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='note_note_event_field_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'note'\n", + "\n", + "\n", + "class NoteNlp(models.Model):\n", + " note_nlp_id = models.IntegerField(primary_key=True)\n", + " note_id = models.IntegerField()\n", + " section_concept = models.ForeignKey(Concept, models.DO_NOTHING, blank=True, null=True)\n", + " snippet = models.CharField(max_length=250, blank=True, null=True)\n", + " offset = models.CharField(max_length=50, blank=True, null=True)\n", + " lexical_variant = models.CharField(max_length=250)\n", + " note_nlp_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='notenlp_note_nlp_concept_set', blank=True, null=True)\n", + " note_nlp_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='notenlp_note_nlp_source_concept_set', blank=True, null=True)\n", + " nlp_system = models.CharField(max_length=250, blank=True, null=True)\n", + " nlp_date = models.DateField()\n", + " nlp_datetime = models.DateTimeField(blank=True, null=True)\n", + " term_exists = models.CharField(max_length=1, blank=True, null=True)\n", + " term_temporal = models.CharField(max_length=50, blank=True, null=True)\n", + " term_modifiers = models.CharField(max_length=2000, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'note_nlp'\n", + "\n", + "\n", + "class Observation(models.Model):\n", + " observation_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " observation_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " observation_date = models.DateField()\n", + " observation_datetime = models.DateTimeField(blank=True, null=True)\n", + " observation_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='observation_observation_type_concept_set')\n", + " value_as_number = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " value_as_string = models.CharField(max_length=60, blank=True, null=True)\n", + " value_as_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='observation_value_as_concept_set', blank=True, null=True)\n", + " qualifier_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='observation_qualifier_concept_set', blank=True, null=True)\n", + " unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='observation_unit_concept_set', blank=True, null=True)\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail = models.ForeignKey('VisitDetail', models.DO_NOTHING, blank=True, null=True)\n", + " observation_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " observation_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='observation_observation_source_concept_set', blank=True, null=True)\n", + " unit_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " qualifier_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " value_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " observation_event_id = models.IntegerField(blank=True, null=True)\n", + " obs_event_field_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='observation_obs_event_field_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'observation'\n", + "\n", + "\n", + "class ObservationPeriod(models.Model):\n", + " observation_period_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " observation_period_start_date = models.DateField()\n", + " observation_period_end_date = models.DateField()\n", + " period_type_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'observation_period'\n", + "\n", + "\n", + "class PayerPlanPeriod(models.Model):\n", + " payer_plan_period_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey('Person', models.DO_NOTHING)\n", + " payer_plan_period_start_date = models.DateField()\n", + " payer_plan_period_end_date = models.DateField()\n", + " payer_concept = models.ForeignKey(Concept, models.DO_NOTHING, blank=True, null=True)\n", + " payer_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " payer_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='payerplanperiod_payer_source_concept_set', blank=True, null=True)\n", + " plan_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='payerplanperiod_plan_concept_set', blank=True, null=True)\n", + " plan_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " plan_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='payerplanperiod_plan_source_concept_set', blank=True, null=True)\n", + " sponsor_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='payerplanperiod_sponsor_concept_set', blank=True, null=True)\n", + " sponsor_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " sponsor_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='payerplanperiod_sponsor_source_concept_set', blank=True, null=True)\n", + " family_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " stop_reason_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='payerplanperiod_stop_reason_concept_set', blank=True, null=True)\n", + " stop_reason_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " stop_reason_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='payerplanperiod_stop_reason_source_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'payer_plan_period'\n", + "\n", + "\n", + "class Person(models.Model):\n", + " person_id = models.IntegerField(primary_key=True)\n", + " gender_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " year_of_birth = models.IntegerField()\n", + " month_of_birth = models.IntegerField(blank=True, null=True)\n", + " day_of_birth = models.IntegerField(blank=True, null=True)\n", + " birth_datetime = models.DateTimeField(blank=True, null=True)\n", + " race_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='person_race_concept_set')\n", + " ethnicity_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='person_ethnicity_concept_set')\n", + " location = models.ForeignKey(Location, models.DO_NOTHING, blank=True, null=True)\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " care_site = models.ForeignKey(CareSite, models.DO_NOTHING, blank=True, null=True)\n", + " person_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " gender_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " gender_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='person_gender_source_concept_set', blank=True, null=True)\n", + " race_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " race_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='person_race_source_concept_set', blank=True, null=True)\n", + " ethnicity_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " ethnicity_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='person_ethnicity_source_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'person'\n", + "\n", + "\n", + "class ProcedureOccurrence(models.Model):\n", + " procedure_occurrence_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey(Person, models.DO_NOTHING)\n", + " procedure_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " procedure_date = models.DateField()\n", + " procedure_datetime = models.DateTimeField(blank=True, null=True)\n", + " procedure_end_date = models.DateField(blank=True, null=True)\n", + " procedure_end_datetime = models.DateTimeField(blank=True, null=True)\n", + " procedure_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='procedureoccurrence_procedure_type_concept_set')\n", + " modifier_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='procedureoccurrence_modifier_concept_set', blank=True, null=True)\n", + " quantity = models.IntegerField(blank=True, null=True)\n", + " provider = models.ForeignKey('Provider', models.DO_NOTHING, blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail = models.ForeignKey('VisitDetail', models.DO_NOTHING, blank=True, null=True)\n", + " procedure_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " procedure_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='procedureoccurrence_procedure_source_concept_set', blank=True, null=True)\n", + " modifier_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'procedure_occurrence'\n", + "\n", + "\n", + "class Provider(models.Model):\n", + " provider_id = models.IntegerField(primary_key=True)\n", + " provider_name = models.CharField(max_length=255, blank=True, null=True)\n", + " npi = models.CharField(max_length=20, blank=True, null=True)\n", + " dea = models.CharField(max_length=20, blank=True, null=True)\n", + " specialty_concept = models.ForeignKey(Concept, models.DO_NOTHING, blank=True, null=True)\n", + " care_site = models.ForeignKey(CareSite, models.DO_NOTHING, blank=True, null=True)\n", + " year_of_birth = models.IntegerField(blank=True, null=True)\n", + " gender_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='provider_gender_concept_set', blank=True, null=True)\n", + " provider_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " specialty_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " specialty_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='provider_specialty_source_concept_set', blank=True, null=True)\n", + " gender_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " gender_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='provider_gender_source_concept_set', blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'provider'\n", + "\n", + "\n", + "class Relationship(models.Model):\n", + " relationship_id = models.CharField(primary_key=True, max_length=20)\n", + " relationship_name = models.CharField(max_length=255)\n", + " is_hierarchical = models.CharField(max_length=1)\n", + " defines_ancestry = models.CharField(max_length=1)\n", + " reverse_relationship_id = models.CharField(max_length=20)\n", + " relationship_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'relationship'\n", + "\n", + "\n", + "class SourceToConceptMap(models.Model):\n", + " source_code = models.CharField(max_length=50)\n", + " source_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " source_vocabulary_id = models.CharField(max_length=20)\n", + " source_code_description = models.CharField(max_length=255, blank=True, null=True)\n", + " target_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='sourcetoconceptmap_target_concept_set')\n", + " target_vocabulary = models.ForeignKey('Vocabulary', models.DO_NOTHING)\n", + " valid_start_date = models.DateField()\n", + " valid_end_date = models.DateField()\n", + " invalid_reason = models.CharField(max_length=1, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'source_to_concept_map'\n", + "\n", + "\n", + "class Specimen(models.Model):\n", + " specimen_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey(Person, models.DO_NOTHING)\n", + " specimen_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " specimen_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='specimen_specimen_type_concept_set')\n", + " specimen_date = models.DateField()\n", + " specimen_datetime = models.DateTimeField(blank=True, null=True)\n", + " quantity = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, null=True)\n", + " unit_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='specimen_unit_concept_set', blank=True, null=True)\n", + " anatomic_site_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='specimen_anatomic_site_concept_set', blank=True, null=True)\n", + " disease_status_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='specimen_disease_status_concept_set', blank=True, null=True)\n", + " specimen_source_id = models.CharField(max_length=50, blank=True, null=True)\n", + " specimen_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " unit_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " anatomic_site_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " disease_status_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'specimen'\n", + "\n", + "\n", + "class VisitDetail(models.Model):\n", + " visit_detail_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey(Person, models.DO_NOTHING)\n", + " visit_detail_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " visit_detail_start_date = models.DateField()\n", + " visit_detail_start_datetime = models.DateTimeField(blank=True, null=True)\n", + " visit_detail_end_date = models.DateField()\n", + " visit_detail_end_datetime = models.DateTimeField(blank=True, null=True)\n", + " visit_detail_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitdetail_visit_detail_type_concept_set')\n", + " provider = models.ForeignKey(Provider, models.DO_NOTHING, blank=True, null=True)\n", + " care_site = models.ForeignKey(CareSite, models.DO_NOTHING, blank=True, null=True)\n", + " visit_detail_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " visit_detail_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitdetail_visit_detail_source_concept_set', blank=True, null=True)\n", + " admitted_from_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitdetail_admitted_from_concept_set', blank=True, null=True)\n", + " admitted_from_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " discharged_to_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " discharged_to_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitdetail_discharged_to_concept_set', blank=True, null=True)\n", + " preceding_visit_detail = models.ForeignKey('self', models.DO_NOTHING, blank=True, null=True)\n", + " parent_visit_detail = models.ForeignKey('self', models.DO_NOTHING, related_name='visitdetail_parent_visit_detail_set', blank=True, null=True)\n", + " visit_occurrence = models.ForeignKey('VisitOccurrence', models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'visit_detail'\n", + "\n", + "\n", + "class VisitOccurrence(models.Model):\n", + " visit_occurrence_id = models.IntegerField(primary_key=True)\n", + " person = models.ForeignKey(Person, models.DO_NOTHING)\n", + " visit_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + " visit_start_date = models.DateField()\n", + " visit_start_datetime = models.DateTimeField(blank=True, null=True)\n", + " visit_end_date = models.DateField()\n", + " visit_end_datetime = models.DateTimeField(blank=True, null=True)\n", + " visit_type_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitoccurrence_visit_type_concept_set')\n", + " provider = models.ForeignKey(Provider, models.DO_NOTHING, blank=True, null=True)\n", + " care_site = models.ForeignKey(CareSite, models.DO_NOTHING, blank=True, null=True)\n", + " visit_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " visit_source_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitoccurrence_visit_source_concept_set', blank=True, null=True)\n", + " admitted_from_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitoccurrence_admitted_from_concept_set', blank=True, null=True)\n", + " admitted_from_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " discharged_to_concept = models.ForeignKey(Concept, models.DO_NOTHING, related_name='visitoccurrence_discharged_to_concept_set', blank=True, null=True)\n", + " discharged_to_source_value = models.CharField(max_length=50, blank=True, null=True)\n", + " preceding_visit_occurrence = models.ForeignKey('self', models.DO_NOTHING, blank=True, null=True)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'visit_occurrence'\n", + "\n", + "\n", + "class Vocabulary(models.Model):\n", + " vocabulary_id = models.CharField(primary_key=True, max_length=20)\n", + " vocabulary_name = models.CharField(max_length=255)\n", + " vocabulary_reference = models.CharField(max_length=255, blank=True, null=True)\n", + " vocabulary_version = models.CharField(max_length=255, blank=True, null=True)\n", + " vocabulary_concept = models.ForeignKey(Concept, models.DO_NOTHING)\n", + "\n", + " class Meta:\n", + " managed = False\n", + " db_table = 'vocabulary'\n" + ] + } + ], + "source": [ + "ln_setup.django(\"inspectdb\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def remove_lnchema_classes(file_path):\n", + " \"\"\"\n", + " Removes entire classes starting with \"Lnschema\" from a Python file.\n", + "\n", + " Args:\n", + " file_path: Path to the Python file.\n", + "\n", + " Returns:\n", + " A string containing the modified code without \"Lnschema\" classes.\n", + " \"\"\"\n", + "\n", + " with open(file_path, \"r\") as f:\n", + " content = f.readlines()\n", + "\n", + " # Flag to track if inside a class definition\n", + " in_class = False\n", + " class_name = None\n", + " modified_lines = []\n", + "\n", + " for line in content:\n", + " if line.strip().startswith(\"class Lnschema\"):\n", + " # Start of a class with \"Lnschema\" prefix\n", + " in_class = True\n", + " class_name = line.split()[1] # Extract class name\n", + " elif line.strip() == \"}\" and in_class:\n", + " # End of the class with \"Lnschema\" prefix\n", + " in_class = False\n", + " class_name = None\n", + " elif not in_class:\n", + " # Lines outside a class or not starting with \"Lnschema\" class\n", + " modified_lines.append(line)\n", + " else:\n", + " # Skip lines inside a class with \"Lnschema\" prefix\n", + " pass\n", + "\n", + " return \"\".join(modified_lines)\n", + "\n", + "# Example usage\n", + "file_path = \"your_models.py\" # Replace with your actual file path\n", + "modified_code = remove_lnchema_classes(file_path)\n", + "\n", + "# Optionally, write the modified code to a new file\n", + "with open(\"modified_models.py\", \"w\") as f:\n", + " f.write(modified_code)\n", + "\n", + "print(\"Successfully removed entire 'Lnschema' classes!\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "py310", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.13" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/quickstart.ipynb b/docs/quickstart.ipynb index 34a2f24..c986f3d 100644 --- a/docs/quickstart.ipynb +++ b/docs/quickstart.ipynb @@ -11,8 +11,6 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This is, for now, only a stub.\n", - "\n", "We download some test data for the 32 tables from the address below and populate the Concept registry." ] }, diff --git a/noxfile.py b/noxfile.py index a7f97e8..6275ced 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,5 +1,5 @@ import nox -from laminci.nox import build_docs, run_pre_commit, run_pytest +from laminci.nox import build_docs, install_lamindb, run_pre_commit, run_pytest # we'd like to aggregate coverage information across sessions # and for this the code needs to be located in the same @@ -15,6 +15,7 @@ def lint(session: nox.Session) -> None: @nox.session() def build(session): - session.run(*"uv pip install --system -e .[dev]".split()) + install_lamindb(session, branch="main") + session.run(*"uv pip install --system .[dev]".split()) run_pytest(session) build_docs(session, strict=True) diff --git a/omop/__init__.py b/omop/__init__.py index c1d45b2..b4f5f22 100644 --- a/omop/__init__.py +++ b/omop/__init__.py @@ -63,6 +63,8 @@ def __getattr__(name): if _check_instance_setup(): + import lamindb + del __getattr__ # delete so that imports work out from .models import ( CareSite, diff --git a/omop/migrations/0001_initial.py b/omop/migrations/0001_initial.py index 4d5abe9..4290840 100644 --- a/omop/migrations/0001_initial.py +++ b/omop/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1 on 2024-05-07 16:38 +# Generated by Django 5.2 on 2024-09-16 12:22 import django.db.models.deletion from django.db import migrations, models @@ -37,6 +37,9 @@ class Migration(migrations.Migration): fields=[ ("concept_id", models.IntegerField(primary_key=True, serialize=False)), ("concept_name", models.CharField(max_length=255)), + ("domain_id", models.CharField(max_length=255)), + ("vocabulary_id", models.CharField(max_length=255)), + ("concept_class", models.CharField(max_length=255)), ( "standard_concept", models.CharField(blank=True, max_length=1, null=True), @@ -171,34 +174,6 @@ class Migration(migrations.Migration): "managed": True, }, ), - migrations.CreateModel( - name="ConceptClass", - fields=[ - ( - "concept_class_id", - models.CharField(max_length=20, primary_key=True, serialize=False), - ), - ("concept_class_name", models.CharField(max_length=255)), - ( - "concept_class_concept", - models.ForeignKey( - on_delete=django.db.models.deletion.DO_NOTHING, - to="omop.concept", - ), - ), - ], - options={ - "db_table": "concept_class", - "managed": True, - }, - ), - migrations.AddField( - model_name="concept", - name="concept_class", - field=models.ForeignKey( - on_delete=django.db.models.deletion.DO_NOTHING, to="omop.conceptclass" - ), - ), migrations.CreateModel( name="ConceptSynonym", fields=[ @@ -389,13 +364,6 @@ class Migration(migrations.Migration): "managed": True, }, ), - migrations.AddField( - model_name="concept", - name="domain", - field=models.ForeignKey( - on_delete=django.db.models.deletion.DO_NOTHING, to="omop.domain" - ), - ), migrations.CreateModel( name="DrugStrength", fields=[ @@ -2598,11 +2566,4 @@ class Migration(migrations.Migration): "managed": True, }, ), - migrations.AddField( - model_name="concept", - name="vocabulary", - field=models.ForeignKey( - on_delete=django.db.models.deletion.DO_NOTHING, to="omop.vocabulary" - ), - ), ] diff --git a/omop/migrations/0002_alter_concept_concept_class_remove_concept_domain_and_more.py b/omop/migrations/0002_alter_concept_concept_class_remove_concept_domain_and_more.py deleted file mode 100644 index df93d76..0000000 --- a/omop/migrations/0002_alter_concept_concept_class_remove_concept_domain_and_more.py +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-08 10:00 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("omop", "0001_initial"), - ] - - operations = [ - migrations.AlterField( - model_name="concept", - name="concept_class", - field=models.CharField(max_length=255), - ), - migrations.RemoveField( - model_name="concept", - name="domain", - ), - migrations.RemoveField( - model_name="concept", - name="vocabulary", - ), - migrations.AddField( - model_name="concept", - name="domain_id", - field=models.CharField(default="0", max_length=255), - preserve_default=False, - ), - migrations.AddField( - model_name="concept", - name="vocabulary_id", - field=models.CharField(default="0", max_length=255), - preserve_default=False, - ), - migrations.DeleteModel( - name="ConceptClass", - ), - ] diff --git a/omop/models.py b/omop/models.py index a77aa54..c0080ff 100644 --- a/omop/models.py +++ b/omop/models.py @@ -5,10 +5,10 @@ # * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior # Feel free to rename the models, but don't rename db_table values or field names. from django.db import models -from lnschema_core.models import Registry +from lnschema_core.models import Record -class CareSite(Registry): +class CareSite(Record): """The CARE_SITE table contains a list of uniquely identified institutional (physical or organizational) units where healthcare delivery is practiced (offices, wards, hospitals, clinics, etc.).""" care_site_id = models.IntegerField(primary_key=True) @@ -27,7 +27,7 @@ class Meta: db_table = "care_site" -class CdmSource(Registry): +class CdmSource(Record): """The CDM_SOURCE table contains detail about the source database and the process used to transform the data into the OMOP Common Data Model.""" cdm_source_name = models.CharField(max_length=255) @@ -49,7 +49,7 @@ class Meta: db_table = "cdm_source" -class Cohort(Registry): +class Cohort(Record): """The COHORT table contains records of subjects that satisfy a given set of criteria for a duration of time. The definition of the cohort is contained within the COHORT_DEFINITION table. @@ -67,7 +67,7 @@ class Meta: db_table = "cohort" -class CohortDefinition(Registry): +class CohortDefinition(Record): """The COHORT_DEFINITION table contains records defining a Cohort derived from the data through the associated description and syntax and upon instantiation (execution of the algorithm) placed into the COHORT table. Cohorts are a set of subjects that satisfy a given combination of inclusion criteria for a duration of time. The COHORT_DEFINITION table provides a standardized structure for maintaining the rules governing the inclusion of a subject into a cohort, and can store operational programming code to instantiate the cohort within the OMOP Common Data Model. @@ -90,7 +90,7 @@ class Meta: db_table = "cohort_definition" -class Concept(Registry): +class Concept(Record): """The Standardized Vocabularies contains records, or Concepts, that uniquely identify each fundamental unit of meaning used to express clinical information in all domain tables of the CDM. Concepts are derived from vocabularies, which represent clinical information across a domain (e.g. conditions, drugs, procedures) through the use of codes and associated descriptions. Some Concepts are designated Standard Concepts, meaning these Concepts can be used as normative expressions of a clinical entity within the OMOP Common Data Model and within standardized analytics. Each Standard Concept belongs to one domain, which defines the location where the Concept would be expected to occur within data tables of the CDM. @@ -114,7 +114,7 @@ class Meta: db_table = "concept" -class ConceptAncestor(Registry): +class ConceptAncestor(Record): """The CONCEPT_ANCESTOR table is designed to simplify observational analysis by providing the complete hierarchical relationships between Concepts. Only direct parent-child relationships between Concepts are stored in the CONCEPT_RELATIONSHIP table. To determine higher level ancestry connections, all individual direct relationships would have to be navigated at analysis time. The CONCEPT_ANCESTOR table includes records for all parent-child relationships, as well as grandparent-grandchild relationships and those of any other level of lineage. Using the CONCEPT_ANCESTOR table allows for querying for all descendants of a hierarchical concept. For example, drug ingredients and drug products are all descendants of a drug class ancestor. @@ -136,7 +136,7 @@ class Meta: db_table = "concept_ancestor" -# class ConceptClass(Registry): +# class ConceptClass(Record): # """The CONCEPT_CLASS table is a reference table, which includes a list of the classifications used to differentiate Concepts within a given Vocabulary. # This reference table is populated with a single record for each Concept Class. @@ -151,7 +151,7 @@ class Meta: # db_table = "concept_class" -class ConceptRelationship(Registry): +class ConceptRelationship(Record): """The CONCEPT_RELATIONSHIP table contains records that define direct relationships between any two Concepts and the nature or type of the relationship. Each type of a relationship is defined in the RELATIONSHIP table. @@ -176,7 +176,7 @@ class Meta: db_table = "concept_relationship" -class ConceptSynonym(Registry): +class ConceptSynonym(Record): """The CONCEPT_SYNONYM table is used to store alternate names and descriptions for Concepts.""" concept = models.ForeignKey(Concept, models.DO_NOTHING) @@ -190,7 +190,7 @@ class Meta: db_table = "concept_synonym" -class ConditionEra(Registry): +class ConditionEra(Record): """A Condition Era is defined as a span of time when the Person is assumed to have a given condition. Similar to Drug Eras, Condition Eras are chronological periods of Condition Occurrence. Combining individual Condition Occurrences into a single Condition Era serves two purposes: @@ -211,7 +211,7 @@ class Meta: db_table = "condition_era" -class ConditionOccurrence(Registry): +class ConditionOccurrence(Record): """This table contains records of Events of a Person suggesting the presence of a disease or medical condition stated as a diagnosis, a sign, or a symptom, which is either observed by a Provider or reported by the patient.""" condition_occurrence_id = models.IntegerField(primary_key=True) @@ -258,7 +258,7 @@ class Meta: db_table = "condition_occurrence" -class Cost(Registry): +class Cost(Record): """The COST table captures records containing the cost of any medical event recorded in one of the OMOP clinical event tables such as DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, VISIT_OCCURRENCE, VISIT_DETAIL, DEVICE_OCCURRENCE, OBSERVATION or MEASUREMENT.""" cost_id = models.IntegerField(primary_key=True) @@ -331,7 +331,7 @@ class Meta: db_table = "cost" -class Death(Registry): +class Death(Record): """The death domain contains the clinical event for how and when a Person dies. A person can have up to one record if the source system contains evidence about the Death, such as: Condition in an administrative claim, status of enrollment into a health plan, or explicit record in EHR data. @@ -364,7 +364,7 @@ class Meta: db_table = "death" -class DeviceExposure(Registry): +class DeviceExposure(Record): """The Device domain captures information about a person�s exposure to a foreign physical object or instrument which is used for diagnostic or therapeutic purposes through a mechanism beyond chemical action. Devices include implantable objects (e.g. pacemakers, stents, artificial joints), medical equipment and supplies (e.g. bandages, crutches, syringes), other instruments used in medical procedures (e.g. sutures, defibrillators) and material used in clinical care (e.g. adhesives, body material, dental material, surgical material). @@ -421,7 +421,7 @@ class Meta: db_table = "device_exposure" -class Domain(Registry): +class Domain(Record): """The DOMAIN table includes a list of OMOP-defined Domains the Concepts of the Standardized Vocabularies can belong to. A Domain defines the set of allowable Concepts for the standardized fields in the CDM tables.""" domain_id = models.CharField(primary_key=True, max_length=20) @@ -433,7 +433,7 @@ class Meta: db_table = "domain" -class DoseEra(Registry): +class DoseEra(Record): """A Dose Era is defined as a span of time when the Person is assumed to be exposed to a constant dose of a specific active ingredient.""" dose_era_id = models.IntegerField(primary_key=True) @@ -451,7 +451,7 @@ class Meta: db_table = "dose_era" -class DrugEra(Registry): +class DrugEra(Record): """A Drug Era is defined as a span of time when the Person is assumed to be exposed to a particular active ingredient. A Drug Era is not the same as a Drug Exposure: Exposures are individual records corresponding to the source when Drug was delivered to the Person, while successive periods of Drug Exposures are combined under certain rules to produce continuous Drug Eras. @@ -470,7 +470,7 @@ class Meta: db_table = "drug_era" -class DrugExposure(Registry): +class DrugExposure(Record): """This table captures records about the exposure to a Drug ingested or otherwise introduced into the body. A Drug is a biochemical substance formulated in such a way that when administered to a Person it will exert a certain biochemical effect on the metabolism. Drugs include prescription and over-the-counter medicines, vaccines, and large-molecule biologic therapies. Radiological devices ingested or applied locally do not count as Drugs. @@ -525,7 +525,7 @@ class Meta: db_table = "drug_exposure" -class DrugStrength(Registry): +class DrugStrength(Record): """The DRUG_STRENGTH table contains structured content about the amount or concentration and associated units of a specific ingredient contained within a particular drug product. This table is supplemental information to support standardized analysis of drug utilization. @@ -575,7 +575,7 @@ class Meta: db_table = "drug_strength" -class Episode(Registry): +class Episode(Record): """The EPISODE table aggregates lower-level clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) into a higher-level abstraction representing clinically and analytically relevant disease phases,outcomes and treatments. The EPISODE_EVENT table connects qualifying clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) to the appropriate EPISODE entry. For example cancers including their development over time, their treatment, and final resolution. @@ -610,7 +610,7 @@ class Meta: db_table = "episode" -class EpisodeEvent(Registry): +class EpisodeEvent(Record): """The EPISODE_EVENT table connects qualifying clinical events (such as CONDITION_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, MEASUREMENT) to the appropriate EPISODE entry. For example, linking the precise location of the metastasis (cancer modifier in MEASUREMENT) to the disease episode. @@ -625,7 +625,7 @@ class Meta: db_table = "episode_event" -class FactRelationship(Registry): +class FactRelationship(Record): """The FACT_RELATIONSHIP table contains records about the relationships between facts stored as records in any table of the CDM. Relationships can be defined between facts from the same domain, or different domains. Examples of Fact Relationships include: Person relationships (parent-child), care site relationships (hierarchical organizational structure of facilities within a health system), indication relationship (between drug exposures and associated conditions), usage relationships (of devices during the course of an associated procedure), or facts derived from one another (measurements derived from an associated specimen). @@ -653,7 +653,7 @@ class Meta: db_table = "fact_relationship" -class Location(Registry): +class Location(Record): """The LOCATION table represents a generic way to capture physical location or address information of Persons and Care Sites.""" location_id = models.IntegerField(primary_key=True) @@ -680,7 +680,7 @@ class Meta: db_table = "location" -class Measurement(Registry): +class Measurement(Record): """The MEASUREMENT table contains records of Measurements, i.e. structured values (numerical or categorical) obtained through systematic and standardized examination or testing of a Person or Person�s sample. The MEASUREMENT table contains both orders and results of such Measurements as laboratory tests, vital signs, quantitative findings from pathology reports, etc. Measurements are stored as attribute value pairs, with the attribute as the Measurement Concept and the value representing the result. The value can be a Concept (stored in VALUE_AS_CONCEPT), or a numerical value (VALUE_AS_NUMBER) with a Unit (UNIT_CONCEPT_ID). The Procedure for obtaining the sample is housed in the PROCEDURE_OCCURRENCE table, though it is unnecessary to create a PROCEDURE_OCCURRENCE record for each measurement if one does not exist in the source data. Measurements differ from Observations in that they require a standardized test or some other activity to generate a quantitative or qualitative result. If there is no result, it is assumed that the lab test was conducted but the result was not captured. @@ -765,7 +765,7 @@ class Meta: db_table = "measurement" -class Metadata(Registry): +class Metadata(Record): """The METADATA table contains metadata information about a dataset that has been transformed to the OMOP Common Data Model.""" metadata_id = models.IntegerField(primary_key=True) @@ -793,7 +793,7 @@ class Meta: db_table = "metadata" -class Note(Registry): +class Note(Record): """The NOTE table captures unstructured information that was recorded by a provider about a patient in free text (in ASCII, or preferably in UTF8 format) notes on a given date. The type of note_text is CLOB or varchar(MAX) depending on RDBMS. @@ -837,7 +837,7 @@ class Meta: db_table = "note" -class NoteNlp(Registry): +class NoteNlp(Record): """The NOTE_NLP table encodes all output of NLP on clinical notes. Each row represents a single extracted term from a note.""" note_nlp_id = models.IntegerField(primary_key=True) @@ -874,7 +874,7 @@ class Meta: db_table = "note_nlp" -class Observation(Registry): +class Observation(Record): """The OBSERVATION table captures clinical facts about a Person obtained in the context of examination, questioning or a procedure. Any data that cannot be represented by any other domains, such as social and lifestyle facts, medical history, family history, etc. are recorded here. @@ -947,7 +947,7 @@ class Meta: db_table = "observation" -class ObservationPeriod(Registry): +class ObservationPeriod(Record): """This table contains records which define spans of time during which two conditions are expected to hold: (i) Clinical Events that happened to the Person are recorded in the Event tables, and (ii) absense of records indicate such Events did not occur during this span of time.""" observation_period_id = models.IntegerField(primary_key=True) @@ -961,7 +961,7 @@ class Meta: db_table = "observation_period" -class PayerPlanPeriod(Registry): +class PayerPlanPeriod(Record): """The PAYER_PLAN_PERIOD table captures details of the period of time that a Person is continuously enrolled under a specific health Plan benefit structure from a given Payer. Each Person receiving healthcare is typically covered by a health benefit plan, which pays for (fully or partially), or directly provides, the care. These benefit plans are provided by payers, such as health insurances or state or government agencies. In each plan the details of the health benefits are defined for the Person or her family, and the health benefit Plan might change over time typically with increasing utilization (reaching certain cost thresholds such as deductibles), plan availability and purchasing choices of the Person. The unique combinations of Payer organizations, health benefit Plans and time periods in which they are valid for a Person are recorded in this table. @@ -1032,7 +1032,7 @@ class Meta: db_table = "payer_plan_period" -class Person(Registry): +class Person(Record): """This table serves as the central identity management for all Persons in the database. It contains records that uniquely identify each person or patient, and some demographic information. @@ -1084,7 +1084,7 @@ class Meta: db_table = "person" -class ProcedureOccurrence(Registry): +class ProcedureOccurrence(Record): """This table contains records of activities or processes ordered by, or carried out by, a healthcare provider on the patient with a diagnostic or therapeutic purpose.""" procedure_occurrence_id = models.IntegerField(primary_key=True) @@ -1129,7 +1129,7 @@ class Meta: db_table = "procedure_occurrence" -class Provider(Registry): +class Provider(Record): """The PROVIDER table contains a list of uniquely identified healthcare providers. These are individuals providing hands-on healthcare to patients, such as physicians, nurses, midwives, physical therapists etc. @@ -1174,7 +1174,7 @@ class Meta: db_table = "provider" -class Relationship(Registry): +class Relationship(Record): """The RELATIONSHIP table provides a reference list of all types of relationships that can be used to associate any two concepts in the CONCEPT_RELATIONSHP table.""" relationship_id = models.CharField(primary_key=True, max_length=20) @@ -1189,7 +1189,7 @@ class Meta: db_table = "relationship" -class SourceToConceptMap(Registry): +class SourceToConceptMap(Record): """The source to concept map table is a legacy data structure within the OMOP Common Data Model, recommended for use in ETL processes to maintain local source codes which are not available as Concepts in the Standardized Vocabularies, and to establish mappings for each source code into a Standard Concept as target_concept_ids that can be used to populate the Common Data Model tables. The SOURCE_TO_CONCEPT_MAP table is no longer populated with content within the Standardized Vocabularies published to the OMOP community. @@ -1212,7 +1212,7 @@ class Meta: db_table = "source_to_concept_map" -class Specimen(Registry): +class Specimen(Record): """The specimen domain contains the records identifying biological samples from a person.""" specimen_id = models.IntegerField(primary_key=True) @@ -1258,7 +1258,7 @@ class Meta: db_table = "specimen" -class VisitDetail(Registry): +class VisitDetail(Record): """The VISIT_DETAIL table is an optional table used to represents details of each record in the parent VISIT_OCCURRENCE table. A good example of this would be the movement between units in a hospital during an inpatient stay or claim lines associated with a one insurance claim. For every record in the VISIT_OCCURRENCE table there may be 0 or more records in the VISIT_DETAIL table with a 1:n relationship where n may be 0. The VISIT_DETAIL table is structurally very similar to VISIT_OCCURRENCE table and belongs to the visit domain. @@ -1319,7 +1319,7 @@ class Meta: db_table = "visit_detail" -class VisitOccurrence(Registry): +class VisitOccurrence(Record): """This table contains Events where Persons engage with the healthcare system for a duration of time. They are often also called �Encounters�. Visits are defined by a configuration of circumstances under which they occur, such as (i) whether the patient comes to a healthcare institution, the other way around, or the interaction is remote, (ii) whether and what kind of trained medical staff is delivering the service during the Visit, and (iii) whether the Visit is transient or for a longer period involving a stay in bed. @@ -1372,7 +1372,7 @@ class Meta: db_table = "visit_occurrence" -class Vocabulary(Registry): +class Vocabulary(Record): """The VOCABULARY table includes a list of the Vocabularies collected from various sources or created de novo by the OMOP community. This reference table is populated with a single record for each Vocabulary source and includes a descriptive name and other associated attributes for the Vocabulary.""" vocabulary_id = models.CharField(primary_key=True, max_length=20) diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py index 8ccfd84..02f1b32 100644 --- a/tests/test_notebooks.py +++ b/tests/test_notebooks.py @@ -6,4 +6,5 @@ def test_notebooks(): docs_folder = Path(__file__).parents[1] / "docs/" for check_folder in docs_folder.glob("./**"): - test.execute_notebooks(check_folder, write=True) + if check_folder.name != "notes": + test.execute_notebooks(check_folder, write=True)