nci-cidc-api-modules 1.2.54__py3-none-any.whl → 1.2.55__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- boot.py +8 -0
- cidc_api/__init__.py +1 -1
- cidc_api/config/db.py +0 -2
- cidc_api/models/dataset.py +80 -0
- cidc_api/models/db/stage1/additional_treatment_orm.py +8 -1
- cidc_api/models/db/stage1/adverse_event_orm.py +8 -1
- cidc_api/models/db/stage1/baseline_clinical_assessment_orm.py +8 -1
- cidc_api/models/db/stage1/comorbidity_orm.py +8 -1
- cidc_api/models/db/stage1/consent_group_orm.py +6 -6
- cidc_api/models/db/stage1/demographic_orm.py +8 -1
- cidc_api/models/db/stage1/disease_orm.py +8 -1
- cidc_api/models/db/stage1/exposure_orm.py +8 -1
- cidc_api/models/db/stage1/gvhd_diagnosis_acute_orm.py +8 -3
- cidc_api/models/db/stage1/gvhd_diagnosis_chronic_orm.py +8 -3
- cidc_api/models/db/stage1/gvhd_organ_acute_orm.py +8 -1
- cidc_api/models/db/stage1/gvhd_organ_chronic_orm.py +8 -1
- cidc_api/models/db/stage1/medical_history_orm.py +8 -1
- cidc_api/models/db/stage1/other_malignancy_orm.py +8 -1
- cidc_api/models/db/stage1/participant_orm.py +4 -5
- cidc_api/models/db/stage1/prior_treatment_orm.py +8 -2
- cidc_api/models/db/stage1/radiotherapy_dose_orm.py +8 -1
- cidc_api/models/db/stage1/response_by_system_orm.py +8 -1
- cidc_api/models/db/stage1/response_orm.py +9 -2
- cidc_api/models/db/stage1/specimen_orm.py +9 -25
- cidc_api/models/db/stage1/stem_cell_transplant_orm.py +8 -1
- cidc_api/models/db/stage1/surgery_orm.py +8 -1
- cidc_api/models/db/stage1/therapy_agent_dose_orm.py +8 -1
- cidc_api/models/db/stage1/treatment_orm.py +8 -1
- cidc_api/models/db/stage1/trial_orm.py +1 -2
- cidc_api/models/db/stage2/additional_treatment_orm.py +8 -1
- cidc_api/models/db/stage2/administrative_person_orm.py +8 -1
- cidc_api/models/db/stage2/administrative_role_assignment_orm.py +1 -0
- cidc_api/models/db/stage2/adverse_event_orm.py +8 -1
- cidc_api/models/db/stage2/arm_orm.py +5 -4
- cidc_api/models/db/stage2/baseline_clinical_assessment_orm.py +8 -1
- cidc_api/models/db/stage2/cohort_orm.py +5 -4
- cidc_api/models/db/stage2/comorbidity_orm.py +8 -1
- cidc_api/models/db/stage2/consent_group_orm.py +5 -5
- cidc_api/models/db/stage2/contact_orm.py +10 -1
- cidc_api/models/db/stage2/demographic_orm.py +8 -1
- cidc_api/models/db/stage2/disease_orm.py +8 -1
- cidc_api/models/db/stage2/exposure_orm.py +8 -1
- cidc_api/models/db/stage2/file_orm.py +4 -4
- cidc_api/models/db/stage2/gvhd_diagnosis_acute_orm.py +8 -3
- cidc_api/models/db/stage2/gvhd_diagnosis_chronic_orm.py +8 -3
- cidc_api/models/db/stage2/gvhd_organ_acute_orm.py +8 -1
- cidc_api/models/db/stage2/gvhd_organ_chronic_orm.py +8 -1
- cidc_api/models/db/stage2/institution_orm.py +4 -4
- cidc_api/models/db/stage2/medical_history_orm.py +8 -1
- cidc_api/models/db/stage2/other_clinical_endpoint_orm.py +9 -1
- cidc_api/models/db/stage2/other_malignancy_orm.py +8 -1
- cidc_api/models/db/stage2/participant_orm.py +6 -6
- cidc_api/models/db/stage2/prior_treatment_orm.py +9 -3
- cidc_api/models/db/stage2/publication_orm.py +5 -4
- cidc_api/models/db/stage2/radiotherapy_dose_orm.py +9 -2
- cidc_api/models/db/stage2/response_by_system_orm.py +8 -1
- cidc_api/models/db/stage2/response_orm.py +9 -2
- cidc_api/models/db/stage2/shipment_orm.py +5 -5
- cidc_api/models/db/stage2/shipment_specimen_orm.py +8 -2
- cidc_api/models/db/stage2/specimen_orm.py +9 -75
- cidc_api/models/db/stage2/stem_cell_transplant_orm.py +8 -1
- cidc_api/models/db/stage2/surgery_orm.py +8 -1
- cidc_api/models/db/stage2/therapy_agent_dose_orm.py +8 -1
- cidc_api/models/db/stage2/treatment_orm.py +8 -1
- cidc_api/models/db/stage2/trial_orm.py +1 -2
- cidc_api/models/pydantic/stage1/trial.py +1 -1
- cidc_api/models/pydantic/stage2/adverse_event.py +52 -25
- cidc_api/models/pydantic/stage2/comorbidity.py +15 -8
- cidc_api/models/pydantic/stage2/demographic.py +45 -28
- cidc_api/models/pydantic/stage2/disease.py +100 -58
- cidc_api/models/pydantic/stage2/exposure.py +14 -8
- cidc_api/models/pydantic/stage2/medical_history.py +15 -8
- cidc_api/models/pydantic/stage2/other_malignancy.py +17 -11
- cidc_api/models/pydantic/stage2/participant.py +27 -15
- cidc_api/models/pydantic/stage2/prior_treatment.py +2 -0
- cidc_api/models/pydantic/stage2/radiotherapy_dose.py +27 -14
- cidc_api/models/pydantic/stage2/response.py +42 -23
- cidc_api/models/pydantic/stage2/response_by_system.py +138 -30
- cidc_api/models/pydantic/stage2/specimen.py +2 -185
- cidc_api/models/pydantic/stage2/surgery.py +15 -7
- cidc_api/models/pydantic/stage2/therapy_agent_dose.py +27 -14
- cidc_api/models/pydantic/stage2/treatment.py +30 -16
- cidc_api/telemetry.py +13 -13
- {nci_cidc_api_modules-1.2.54.dist-info → nci_cidc_api_modules-1.2.55.dist-info}/METADATA +1 -1
- nci_cidc_api_modules-1.2.55.dist-info/RECORD +163 -0
- cidc_api/models/data.py +0 -28
- nci_cidc_api_modules-1.2.54.dist-info/RECORD +0 -163
- {nci_cidc_api_modules-1.2.54.dist-info → nci_cidc_api_modules-1.2.55.dist-info}/WHEEL +0 -0
- {nci_cidc_api_modules-1.2.54.dist-info → nci_cidc_api_modules-1.2.55.dist-info}/licenses/LICENSE +0 -0
- {nci_cidc_api_modules-1.2.54.dist-info → nci_cidc_api_modules-1.2.55.dist-info}/top_level.txt +0 -0
boot.py
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
from os import mkdir, path
|
|
2
2
|
import shutil
|
|
3
|
+
from flask_migrate import upgrade
|
|
3
4
|
|
|
4
5
|
TEMPLATES_DIR = path.join("/tmp", "templates")
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
def apply_migrations():
|
|
9
|
+
from cidc_api.app import app
|
|
10
|
+
|
|
11
|
+
with app.app_context():
|
|
12
|
+
upgrade(app.config["MIGRATIONS_PATH"])
|
|
13
|
+
|
|
14
|
+
|
|
7
15
|
# set up the directories for holding generated templates
|
|
8
16
|
def set_up_templates_directories():
|
|
9
17
|
if path.exists(TEMPLATES_DIR):
|
cidc_api/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.2.
|
|
1
|
+
__version__ = "1.2.55"
|
cidc_api/config/db.py
CHANGED
|
@@ -35,8 +35,6 @@ def init_db(app: Flask):
|
|
|
35
35
|
"""Connect `app` to the database and run migrations"""
|
|
36
36
|
db.init_app(app)
|
|
37
37
|
Migrate(app, db, app.config["MIGRATIONS_PATH"])
|
|
38
|
-
with app.app_context():
|
|
39
|
-
upgrade(app.config["MIGRATIONS_PATH"])
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
def get_sqlalchemy_database_uri(testing: bool = False) -> str:
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from sqlalchemy import and_
|
|
5
|
+
from sqlalchemy.orm.session import Session
|
|
6
|
+
|
|
7
|
+
from cidc_api.models.pydantic.stage1 import all_models as stage1_all_models
|
|
8
|
+
from cidc_api.models.pydantic.stage2 import all_models as stage2_all_models
|
|
9
|
+
from cidc_api.models.db.stage1 import all_models as stage1_all_db_models
|
|
10
|
+
from cidc_api.models.db.stage2 import all_models as stage2_all_db_models
|
|
11
|
+
from cidc_api.models.db.stage1 import TrialORM as s1TrialORM
|
|
12
|
+
from cidc_api.models.db.stage2 import TrialORM as s2TrialORM
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
standard_data_categories = [
|
|
16
|
+
model.__data_category__ for model in stage1_all_models if hasattr(model, "__data_category__")
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Maps data categories like "treatment" to their associated pydantic model
|
|
21
|
+
data_category_to_model = {
|
|
22
|
+
"stage1": {model.__data_category__: model for model in stage1_all_models if hasattr(model, "__data_category__")},
|
|
23
|
+
"stage2": {model.__data_category__: model for model in stage2_all_models if hasattr(model, "__data_category__")},
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
data_category_to_db_model = {
|
|
28
|
+
"stage1": {model.__data_category__: model for model in stage1_all_db_models if hasattr(model, "__data_category__")},
|
|
29
|
+
"stage2": {model.__data_category__: model for model in stage2_all_db_models if hasattr(model, "__data_category__")},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Stages(StrEnum):
|
|
34
|
+
STAGE1 = "stage1"
|
|
35
|
+
STAGE2 = "stage2"
|
|
36
|
+
STAGE3 = "stage3"
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def members(cls):
|
|
40
|
+
return list(v.value for v in cls.__members__.values())
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def trial_exists(trial_id: str, version: str, stage: str, session: Session) -> bool:
|
|
44
|
+
if stage not in Stages:
|
|
45
|
+
raise ValueError(f"value for 'stage' must be in {Stages.members()}")
|
|
46
|
+
|
|
47
|
+
if stage == Stages.STAGE1:
|
|
48
|
+
TrialORM = s1TrialORM
|
|
49
|
+
elif stage == Stages.STAGE2:
|
|
50
|
+
TrialORM = s2TrialORM
|
|
51
|
+
elif stage == Stages.STAGE3:
|
|
52
|
+
pass # stub
|
|
53
|
+
|
|
54
|
+
trials = session.query(TrialORM).filter(and_(TrialORM.trial_id == trial_id, TrialORM.version == version)).all()
|
|
55
|
+
return len(trials) == 1
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# A class to hold the entire model representation of a trial's dataset
|
|
59
|
+
class Dataset(dict):
|
|
60
|
+
def __init__(self, *args, **kwargs):
|
|
61
|
+
for data_category in standard_data_categories:
|
|
62
|
+
self[data_category] = []
|
|
63
|
+
super().__init__(*args, **kwargs)
|
|
64
|
+
|
|
65
|
+
def load(self, trial_id: str, version: str, stage: str, session: Session):
|
|
66
|
+
if stage not in Stages:
|
|
67
|
+
raise ValueError(f"value for 'stage' must be in {Stages.members()}")
|
|
68
|
+
|
|
69
|
+
for data_category, _ in self.items():
|
|
70
|
+
db_model_cls = data_category_to_db_model[stage][data_category]
|
|
71
|
+
db_models = self.load_db_models(trial_id, version, db_model_cls, session)
|
|
72
|
+
self[data_category] = db_models
|
|
73
|
+
|
|
74
|
+
def load_db_models(self, trial_id: str, version: str, db_model_cls: Any, session: Session):
|
|
75
|
+
db_models = (
|
|
76
|
+
session.query(db_model_cls)
|
|
77
|
+
.filter(and_(db_model_cls.trial_id == trial_id, db_model_cls.version == version))
|
|
78
|
+
.all()
|
|
79
|
+
)
|
|
80
|
+
return db_models
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from pydantic import NonNegativeInt
|
|
3
3
|
|
|
4
|
-
from sqlalchemy import ForeignKey
|
|
4
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
5
5
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
6
|
|
|
7
7
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
8
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class AdditionalTreatmentORM(BaseORM):
|
|
11
12
|
__tablename__ = "additional_treatment"
|
|
12
13
|
__repr_attrs__ = ["additional_treatment_id", "participant_id"]
|
|
13
14
|
__data_category__ = "additional_treatment"
|
|
15
|
+
__table_args__ = (
|
|
16
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
trial_id: Mapped[str]
|
|
20
|
+
version: Mapped[str]
|
|
14
21
|
|
|
15
22
|
additional_treatment_id: Mapped[int] = mapped_column(primary_key=True)
|
|
16
23
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from pydantic import NonNegativeInt
|
|
3
|
-
from sqlalchemy import ForeignKey
|
|
3
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
4
4
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
5
5
|
|
|
6
6
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
7
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
7
8
|
from cidc_api.models.types import (
|
|
8
9
|
CTCAEEventTerm,
|
|
9
10
|
CTCAEEventCode,
|
|
@@ -22,6 +23,12 @@ class AdverseEventORM(BaseORM):
|
|
|
22
23
|
__tablename__ = "adverse_event"
|
|
23
24
|
__repr_attrs__ = ["adverse_event_id", "participant_id", "event_term"]
|
|
24
25
|
__data_category__ = "adverse_event"
|
|
26
|
+
__table_args__ = (
|
|
27
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
trial_id: Mapped[str]
|
|
31
|
+
version: Mapped[str]
|
|
25
32
|
|
|
26
33
|
adverse_event_id: Mapped[int] = mapped_column(primary_key=True)
|
|
27
34
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from sqlalchemy import ForeignKey
|
|
2
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
3
3
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
4
4
|
|
|
5
5
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
6
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
6
7
|
from cidc_api.models.types import ECOGScore, KarnofskyScore
|
|
7
8
|
|
|
8
9
|
|
|
@@ -10,6 +11,12 @@ class BaselineClinicalAssessmentORM(BaseORM):
|
|
|
10
11
|
__tablename__ = "baseline_clinical_assessment"
|
|
11
12
|
__repr_attrs__ = ["baseline_clinical_assessment_id", "participant_id"]
|
|
12
13
|
__data_category__ = "baseline_clinical_assessment"
|
|
14
|
+
__table_args__ = (
|
|
15
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
trial_id: Mapped[str]
|
|
19
|
+
version: Mapped[str]
|
|
13
20
|
|
|
14
21
|
baseline_clinical_assessment_id: Mapped[int] = mapped_column(primary_key=True)
|
|
15
22
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from sqlalchemy import ForeignKey
|
|
2
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
3
3
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
4
4
|
|
|
5
5
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
6
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
6
7
|
from cidc_api.models.types import ICD10CMCode, ICD10CMTerm
|
|
7
8
|
|
|
8
9
|
|
|
@@ -10,6 +11,12 @@ class ComorbidityORM(BaseORM):
|
|
|
10
11
|
__tablename__ = "comorbidity"
|
|
11
12
|
__repr_attrs__ = ["comorbidity_id", "comorbidity_term"]
|
|
12
13
|
__data_category__ = "comorbidity"
|
|
14
|
+
__table_args__ = (
|
|
15
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
trial_id: Mapped[str]
|
|
19
|
+
version: Mapped[str]
|
|
13
20
|
|
|
14
21
|
comorbidity_id: Mapped[int] = mapped_column(primary_key=True)
|
|
15
22
|
medical_history_id: Mapped[int] = mapped_column(
|
|
@@ -2,26 +2,26 @@ from __future__ import annotations
|
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
4
|
from pydantic import NonNegativeInt
|
|
5
|
-
from sqlalchemy import ForeignKeyConstraint
|
|
5
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
6
6
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
7
7
|
|
|
8
8
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
9
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class ConsentGroupORM(BaseORM):
|
|
12
13
|
__tablename__ = "consent_group"
|
|
13
14
|
__repr_attrs__ = ["consent_group_id", "consent_group_name"]
|
|
15
|
+
__data_category__ = "consent_group"
|
|
14
16
|
__table_args__ = (
|
|
15
|
-
ForeignKeyConstraint(
|
|
16
|
-
["trial_id", "version"], ["stage1.trial.trial_id", "stage1.trial.version"], ondelete="CASCADE"
|
|
17
|
-
),
|
|
17
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
18
18
|
)
|
|
19
|
-
__data_category__ = "consent_group"
|
|
20
19
|
|
|
21
|
-
consent_group_id: Mapped[int] = mapped_column(primary_key=True)
|
|
22
20
|
trial_id: Mapped[str]
|
|
23
21
|
version: Mapped[str]
|
|
24
22
|
|
|
23
|
+
consent_group_id: Mapped[int] = mapped_column(primary_key=True)
|
|
24
|
+
|
|
25
25
|
consent_group_short_name: Mapped[str]
|
|
26
26
|
consent_group_name: Mapped[str]
|
|
27
27
|
consent_group_number: Mapped[NonNegativeInt]
|
|
@@ -2,11 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
from pydantic import NonNegativeFloat, PositiveFloat, PositiveInt
|
|
3
3
|
from typing import List
|
|
4
4
|
|
|
5
|
-
from sqlalchemy import ForeignKey
|
|
5
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
6
6
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
7
7
|
from sqlalchemy.types import JSON
|
|
8
8
|
|
|
9
9
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
10
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
10
11
|
from cidc_api.models.types import (
|
|
11
12
|
Sex,
|
|
12
13
|
Race,
|
|
@@ -25,6 +26,12 @@ class DemographicORM(BaseORM):
|
|
|
25
26
|
__tablename__ = "demographic"
|
|
26
27
|
__repr_attrs__ = ["demographic_id", "participant_id", "age_at_enrollment", "sex"]
|
|
27
28
|
__data_category__ = "demographic"
|
|
29
|
+
__table_args__ = (
|
|
30
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
trial_id: Mapped[str]
|
|
34
|
+
version: Mapped[str]
|
|
28
35
|
|
|
29
36
|
demographic_id: Mapped[int] = mapped_column(primary_key=True)
|
|
30
37
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -2,11 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
4
|
from pydantic import NonPositiveInt
|
|
5
|
-
from sqlalchemy import ForeignKey
|
|
5
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
6
6
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
7
7
|
from sqlalchemy.types import JSON
|
|
8
8
|
|
|
9
9
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
10
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
10
11
|
from cidc_api.models.types import (
|
|
11
12
|
TumorGrade,
|
|
12
13
|
CancerStageSystem,
|
|
@@ -30,6 +31,12 @@ class DiseaseORM(BaseORM):
|
|
|
30
31
|
"participant_id",
|
|
31
32
|
]
|
|
32
33
|
__data_category__ = "disease"
|
|
34
|
+
__table_args__ = (
|
|
35
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
trial_id: Mapped[str]
|
|
39
|
+
version: Mapped[str]
|
|
33
40
|
|
|
34
41
|
disease_id: Mapped[int] = mapped_column(primary_key=True)
|
|
35
42
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
|
-
from sqlalchemy import ForeignKey
|
|
4
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
5
5
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
6
|
|
|
7
7
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
8
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
8
9
|
from cidc_api.models.types import YNU, ExposureType
|
|
9
10
|
|
|
10
11
|
|
|
@@ -12,6 +13,12 @@ class ExposureORM(BaseORM):
|
|
|
12
13
|
__tablename__ = "exposure"
|
|
13
14
|
__repr_attrs__ = ["exposure_id", "exposure_type", "carcinogen_exposure"]
|
|
14
15
|
__data_category__ = "exposure"
|
|
16
|
+
__table_args__ = (
|
|
17
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
trial_id: Mapped[str]
|
|
21
|
+
version: Mapped[str]
|
|
15
22
|
|
|
16
23
|
exposure_id: Mapped[int] = mapped_column(primary_key=True)
|
|
17
24
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
|
-
from sqlalchemy import ForeignKey, UniqueConstraint
|
|
4
|
+
from sqlalchemy import ForeignKey, UniqueConstraint, ForeignKeyConstraint
|
|
5
5
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
6
|
|
|
7
7
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
8
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
8
9
|
from cidc_api.models.types import (
|
|
9
10
|
GVHDDiagnosisAcuteAssessmentSystem,
|
|
10
11
|
GVHDDiagnosisAcuteAssessmentSystemVersion,
|
|
@@ -15,11 +16,15 @@ from cidc_api.models.types import (
|
|
|
15
16
|
|
|
16
17
|
class GVHDDiagnosisAcuteORM(BaseORM):
|
|
17
18
|
__tablename__ = "gvhd_diagnosis_acute"
|
|
19
|
+
__repr_attrs__ = ["gvhd_diagnosis_acute_id", "pre_or_post_enrollment"]
|
|
20
|
+
__data_category__ = "gvhd_diagnosis_acute"
|
|
18
21
|
__table_args__ = (
|
|
19
22
|
UniqueConstraint("participant_id", "pre_or_post_enrollment", name="unique_ix_gvhd_diagnosis_acute_pre_or_post"),
|
|
23
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
20
24
|
)
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
|
|
26
|
+
trial_id: Mapped[str]
|
|
27
|
+
version: Mapped[str]
|
|
23
28
|
|
|
24
29
|
gvhd_diagnosis_acute_id: Mapped[int] = mapped_column(primary_key=True)
|
|
25
30
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
|
-
from sqlalchemy import ForeignKey, UniqueConstraint
|
|
4
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint, UniqueConstraint
|
|
5
5
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
6
|
|
|
7
7
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
8
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
8
9
|
from cidc_api.models.types import (
|
|
9
10
|
GVHDDiagnosisChronicAssessmentSystem,
|
|
10
11
|
GVHDDiagnosisChronicAssessmentSystemVersion,
|
|
@@ -15,13 +16,17 @@ from cidc_api.models.types import (
|
|
|
15
16
|
|
|
16
17
|
class GVHDDiagnosisChronicORM(BaseORM):
|
|
17
18
|
__tablename__ = "gvhd_diagnosis_chronic"
|
|
19
|
+
__repr_attrs__ = ["gvhd_diagnosis_chronic_id", "pre_or_post_enrollment"]
|
|
20
|
+
__data_category__ = "gvhd_diagnosis_chronic"
|
|
18
21
|
__table_args__ = (
|
|
19
22
|
UniqueConstraint(
|
|
20
23
|
"participant_id", "pre_or_post_enrollment", name="unique_ix_gvhd_diagnosis_chronic_pre_or_post"
|
|
21
24
|
),
|
|
25
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
22
26
|
)
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
|
|
28
|
+
trial_id: Mapped[str]
|
|
29
|
+
version: Mapped[str]
|
|
25
30
|
|
|
26
31
|
gvhd_diagnosis_chronic_id: Mapped[int] = mapped_column(primary_key=True)
|
|
27
32
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from sqlalchemy import ForeignKey
|
|
2
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
3
3
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
4
4
|
|
|
5
5
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
6
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
6
7
|
from cidc_api.models.types import GVHDOrgan, GVHDOrganAcuteStage
|
|
7
8
|
|
|
8
9
|
|
|
@@ -10,6 +11,12 @@ class GVHDOrganAcuteORM(BaseORM):
|
|
|
10
11
|
__tablename__ = "gvhd_organ_acute"
|
|
11
12
|
__repr_attrs__ = ["gvhd_organ_acute_id", "organ"]
|
|
12
13
|
__data_category__ = "gvhd_organ_acute"
|
|
14
|
+
__table_args__ = (
|
|
15
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
trial_id: Mapped[str]
|
|
19
|
+
version: Mapped[str]
|
|
13
20
|
|
|
14
21
|
gvhd_organ_acute_id: Mapped[int] = mapped_column(primary_key=True)
|
|
15
22
|
gvhd_diagnosis_acute_id: Mapped[int] = mapped_column(
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from sqlalchemy import ForeignKey
|
|
2
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
3
3
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
4
4
|
|
|
5
5
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
6
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
6
7
|
from cidc_api.models.types import GVHDOrgan, GVHDOrganChronicScore
|
|
7
8
|
|
|
8
9
|
|
|
@@ -10,6 +11,12 @@ class GVHDOrganChronicORM(BaseORM):
|
|
|
10
11
|
__tablename__ = "gvhd_organ_chronic"
|
|
11
12
|
__repr_attrs__ = ["gvhd_organ_chronic_id", "organ"]
|
|
12
13
|
__data_category__ = "gvhd_organ_chronic"
|
|
14
|
+
__table_args__ = (
|
|
15
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
trial_id: Mapped[str]
|
|
19
|
+
version: Mapped[str]
|
|
13
20
|
|
|
14
21
|
gvhd_organ_chronic_id: Mapped[int] = mapped_column(primary_key=True)
|
|
15
22
|
gvhd_diagnosis_chronic_id: Mapped[int] = mapped_column(
|
|
@@ -2,10 +2,11 @@ from __future__ import annotations
|
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
4
|
from pydantic import NonNegativeInt, PositiveFloat
|
|
5
|
-
from sqlalchemy import ForeignKey
|
|
5
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
6
6
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
7
7
|
|
|
8
8
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
9
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
9
10
|
from cidc_api.models.types import TobaccoSmokingStatus
|
|
10
11
|
|
|
11
12
|
|
|
@@ -13,6 +14,12 @@ class MedicalHistoryORM(BaseORM):
|
|
|
13
14
|
__tablename__ = "medical_history"
|
|
14
15
|
__repr_attrs__ = ["medical_history_id"]
|
|
15
16
|
__data_category__ = "medical_history"
|
|
17
|
+
__table_args__ = (
|
|
18
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
trial_id: Mapped[str]
|
|
22
|
+
version: Mapped[str]
|
|
16
23
|
|
|
17
24
|
medical_history_id: Mapped[int] = mapped_column(primary_key=True)
|
|
18
25
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from pydantic import NonPositiveInt
|
|
3
|
-
from sqlalchemy import ForeignKey
|
|
3
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
4
4
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
5
5
|
|
|
6
6
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
7
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
7
8
|
from cidc_api.models.types import UberonAnatomicalTerm, ICDO3MorphologicalCode, ICDO3MorphologicalTerm, MalignancyStatus
|
|
8
9
|
|
|
9
10
|
|
|
@@ -11,6 +12,12 @@ class OtherMalignancyORM(BaseORM):
|
|
|
11
12
|
__tablename__ = "other_malignancy"
|
|
12
13
|
__repr_attrs__ = ["other_malignancy_id", "primary_disease_site"]
|
|
13
14
|
__data_category__ = "other_malignancy"
|
|
15
|
+
__table_args__ = (
|
|
16
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
trial_id: Mapped[str]
|
|
20
|
+
version: Mapped[str]
|
|
14
21
|
|
|
15
22
|
other_malignancy_id: Mapped[int] = mapped_column(primary_key=True)
|
|
16
23
|
medical_history_id: Mapped[int] = mapped_column(
|
|
@@ -5,23 +5,22 @@ from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
|
5
5
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
6
|
|
|
7
7
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
8
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
8
9
|
from cidc_api.models.types import OffStudyReason, YNU
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class ParticipantORM(BaseORM):
|
|
12
13
|
__tablename__ = "participant"
|
|
13
14
|
__repr_attrs__ = ["participant_id", "native_participant_id", "cimac_participant_id"]
|
|
15
|
+
__data_category__ = "participant"
|
|
14
16
|
__table_args__ = (
|
|
15
|
-
ForeignKeyConstraint(
|
|
16
|
-
["trial_id", "version"], ["stage1.trial.trial_id", "stage1.trial.version"], ondelete="CASCADE"
|
|
17
|
-
),
|
|
17
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
18
18
|
)
|
|
19
|
-
__data_category__ = "participant"
|
|
20
19
|
|
|
21
|
-
participant_id: Mapped[int] = mapped_column(primary_key=True)
|
|
22
20
|
trial_id: Mapped[str]
|
|
23
21
|
version: Mapped[str]
|
|
24
22
|
|
|
23
|
+
participant_id: Mapped[int] = mapped_column(primary_key=True)
|
|
25
24
|
native_participant_id: Mapped[str | None]
|
|
26
25
|
cimac_participant_id: Mapped[str | None]
|
|
27
26
|
consent_group_id: Mapped[int | None] = mapped_column(
|
|
@@ -2,11 +2,11 @@ from __future__ import annotations
|
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
4
|
from pydantic import NonPositiveInt, NegativeInt
|
|
5
|
-
from sqlalchemy import ForeignKey
|
|
5
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
6
6
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
7
|
-
from sqlalchemy.types import JSON
|
|
8
7
|
|
|
9
8
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
9
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
10
10
|
from cidc_api.models.types import ConditioningRegimenType, StemCellDonorType
|
|
11
11
|
|
|
12
12
|
|
|
@@ -14,6 +14,12 @@ class PriorTreatmentORM(BaseORM):
|
|
|
14
14
|
__tablename__ = "prior_treatment"
|
|
15
15
|
__repr_attrs__ = ["prior_treatment_id", "type"]
|
|
16
16
|
__data_category__ = "prior_treatment"
|
|
17
|
+
__table_args__ = (
|
|
18
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
trial_id: Mapped[str]
|
|
22
|
+
version: Mapped[str]
|
|
17
23
|
|
|
18
24
|
prior_treatment_id: Mapped[int] = mapped_column(primary_key=True)
|
|
19
25
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from pydantic import NonNegativeInt, NonNegativeFloat, PositiveFloat
|
|
3
3
|
|
|
4
|
-
from sqlalchemy import ForeignKey
|
|
4
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
5
5
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
6
|
|
|
7
7
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
8
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
8
9
|
from cidc_api.models.types import (
|
|
9
10
|
RadiotherapyProcedure,
|
|
10
11
|
UberonAnatomicalTerm,
|
|
@@ -19,6 +20,12 @@ class RadiotherapyDoseORM(BaseORM):
|
|
|
19
20
|
__tablename__ = "radiotherapy_dose"
|
|
20
21
|
__repr_attrs__ = ["radiotherapy_dose_id", "procedure"]
|
|
21
22
|
__data_category__ = "radiotherapy_dose"
|
|
23
|
+
__table_args__ = (
|
|
24
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
trial_id: Mapped[str]
|
|
28
|
+
version: Mapped[str]
|
|
22
29
|
|
|
23
30
|
radiotherapy_dose_id: Mapped[int] = mapped_column(primary_key=True)
|
|
24
31
|
treatment_id: Mapped[int] = mapped_column(ForeignKey("stage1.treatment.treatment_id", ondelete="CASCADE"))
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from pydantic import PositiveInt
|
|
3
|
-
from sqlalchemy import ForeignKey,
|
|
3
|
+
from sqlalchemy import String, ForeignKey, ForeignKeyConstraint
|
|
4
4
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
5
5
|
|
|
6
6
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
7
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
7
8
|
from cidc_api.models.types import ResponseSystem, ResponseSystemVersion, BestOverallResponse, YNUNA, YN
|
|
8
9
|
|
|
9
10
|
|
|
@@ -11,6 +12,12 @@ class ResponseBySystemORM(BaseORM):
|
|
|
11
12
|
__tablename__ = "response_by_system"
|
|
12
13
|
__repr_attrs__ = ["response_by_system_id", "participant_id"]
|
|
13
14
|
__data_category__ = "response_by_system"
|
|
15
|
+
__table_args__ = (
|
|
16
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
trial_id: Mapped[str]
|
|
20
|
+
version: Mapped[str]
|
|
14
21
|
|
|
15
22
|
response_by_system_id: Mapped[int] = mapped_column(primary_key=True)
|
|
16
23
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from pydantic import NonNegativeInt
|
|
3
3
|
|
|
4
|
-
from sqlalchemy import ForeignKey
|
|
4
|
+
from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|
5
5
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
6
|
|
|
7
7
|
from cidc_api.models.db.stage1.base_orm import BaseORM
|
|
8
|
-
from cidc_api.models.
|
|
8
|
+
from cidc_api.models.db.stage1.trial_orm import TrialORM
|
|
9
|
+
from cidc_api.models.types import SurvivalStatus, CauseOfDeath, YNUNA, YN
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class ResponseORM(BaseORM):
|
|
12
13
|
__tablename__ = "response"
|
|
13
14
|
__repr_attrs__ = ["response_id", "participant_id"]
|
|
14
15
|
__data_category__ = "response"
|
|
16
|
+
__table_args__ = (
|
|
17
|
+
ForeignKeyConstraint(["trial_id", "version"], [TrialORM.trial_id, TrialORM.version], ondelete="CASCADE"),
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
trial_id: Mapped[str]
|
|
21
|
+
version: Mapped[str]
|
|
15
22
|
|
|
16
23
|
response_id: Mapped[int] = mapped_column(primary_key=True)
|
|
17
24
|
participant_id: Mapped[int] = mapped_column(ForeignKey("stage1.participant.participant_id", ondelete="CASCADE"))
|