endoreg-db 0.6.2__py3-none-any.whl → 0.6.4__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.
Potentially problematic release.
This version of endoreg-db might be problematic. Click here for more details.
- endoreg_db/data/__init__.py +14 -0
- endoreg_db/data/disease_classification/chronic_kidney_disease.yaml +2 -2
- endoreg_db/data/disease_classification_choice/chronic_kidney_disease.yaml +6 -6
- endoreg_db/data/distribution/numeric/data.yaml +1 -1
- endoreg_db/data/examination/examinations/data.yaml +22 -21
- endoreg_db/data/examination/type/data.yaml +12 -0
- endoreg_db/data/examination_indication/endoscopy.yaml +417 -1
- endoreg_db/data/examination_indication_classification/endoscopy.yaml +157 -5
- endoreg_db/data/finding/data.yaml +18 -11
- endoreg_db/data/finding_intervention/endoscopy.yaml +26 -121
- endoreg_db/data/finding_intervention/endoscopy_colonoscopy.yaml +163 -0
- endoreg_db/data/finding_intervention/endoscopy_egd.yaml +128 -0
- endoreg_db/data/finding_intervention/endoscopy_ercp.yaml +32 -0
- endoreg_db/data/finding_intervention/endoscopy_eus_lower.yaml +9 -0
- endoreg_db/data/finding_intervention/endoscopy_eus_upper.yaml +36 -0
- endoreg_db/data/information_source/endoscopy_guidelines.yaml +7 -0
- endoreg_db/data/medication_indication/anticoagulation.yaml +4 -4
- endoreg_db/data/pdf_type/data.yaml +9 -16
- endoreg_db/data/requirement/colonoscopy_indications.yaml +56 -0
- endoreg_db/data/requirement/disease_cardiovascular.yaml +79 -0
- endoreg_db/data/requirement/disease_classification_choice_cardiovascular.yaml +38 -0
- endoreg_db/data/requirement/disease_hepatology.yaml +12 -0
- endoreg_db/data/requirement/disease_misc.yaml +12 -0
- endoreg_db/data/requirement/disease_renal.yaml +80 -0
- endoreg_db/data/requirement/event_cardiology.yaml +251 -0
- endoreg_db/data/requirement/lab_value.yaml +120 -0
- endoreg_db/data/requirement_operator/lab_operators.yaml +128 -0
- endoreg_db/data/requirement_operator/model_operators.yaml +90 -0
- endoreg_db/data/requirement_set/endoscopy_bleeding_risk.yaml +12 -0
- endoreg_db/data/requirement_set_type/data.yaml +20 -0
- endoreg_db/data/requirement_type/requirement_types.yaml +83 -0
- endoreg_db/data/risk/bleeding.yaml +26 -0
- endoreg_db/data/risk/thrombosis.yaml +37 -0
- endoreg_db/data/risk_type/data.yaml +27 -0
- endoreg_db/data/unit/time.yaml +36 -1
- endoreg_db/management/commands/load_base_db_data.py +14 -1
- endoreg_db/management/commands/load_center_data.py +46 -21
- endoreg_db/management/commands/load_examination_indication_data.py +49 -27
- endoreg_db/management/commands/load_requirement_data.py +156 -0
- endoreg_db/management/commands/load_risk_data.py +56 -0
- endoreg_db/mermaid/Overall_flow_patient_finding_intervention.md +10 -0
- endoreg_db/mermaid/anonymized_image_annotation.md +20 -0
- endoreg_db/mermaid/binary_classification_annotation.md +50 -0
- endoreg_db/mermaid/classification.md +8 -0
- endoreg_db/mermaid/examination.md +8 -0
- endoreg_db/mermaid/findings.md +7 -0
- endoreg_db/mermaid/image_classification.md +28 -0
- endoreg_db/mermaid/interventions.md +8 -0
- endoreg_db/mermaid/morphology.md +8 -0
- endoreg_db/mermaid/patient_creation.md +14 -0
- endoreg_db/mermaid/video_segmentation_annotation.md +17 -0
- endoreg_db/migrations/0009_requirementoperator_requirementsettype_and_more.py +154 -0
- endoreg_db/models/__init__.py +20 -0
- endoreg_db/models/ai_model/ai_model.py +0 -13
- endoreg_db/models/ai_model/model_meta.py +2 -12
- endoreg_db/models/data_file/base_classes/abstract_frame.py +0 -2
- endoreg_db/models/data_file/base_classes/abstract_pdf.py +0 -9
- endoreg_db/models/data_file/base_classes/abstract_video.py +7 -8
- endoreg_db/models/data_file/base_classes/utils.py +0 -22
- endoreg_db/models/data_file/frame.py +1 -1
- endoreg_db/models/data_file/import_classes/raw_pdf.py +5 -11
- endoreg_db/models/data_file/import_classes/raw_video.py +6 -4
- endoreg_db/models/data_file/video/video.py +3 -3
- endoreg_db/models/disease.py +88 -19
- endoreg_db/models/event.py +108 -21
- endoreg_db/models/examination/examination_indication.py +108 -29
- endoreg_db/models/examination/examination_type.py +20 -6
- endoreg_db/models/information_source.py +37 -1
- endoreg_db/models/laboratory/lab_value.py +83 -32
- endoreg_db/models/requirement/__init__.py +11 -0
- endoreg_db/models/requirement/requirement.py +325 -0
- endoreg_db/models/requirement/requirement_evaluation/__init__.py +134 -0
- endoreg_db/models/requirement/requirement_evaluation/requirement_type_parser.py +102 -0
- endoreg_db/models/requirement/requirement_operator.py +58 -0
- endoreg_db/models/requirement/requirement_set.py +127 -0
- endoreg_db/models/risk/__init__.py +7 -0
- endoreg_db/models/risk/risk.py +72 -0
- endoreg_db/models/risk/risk_type.py +55 -0
- endoreg_db/serializers/raw_pdf_anony_text_validation.py +137 -0
- endoreg_db/serializers/raw_pdf_meta_validation.py +223 -0
- endoreg_db/serializers/raw_video_meta_validation.py +163 -1
- endoreg_db/serializers/video_segmentation.py +208 -126
- endoreg_db/urls.py +127 -14
- endoreg_db/utils/__init__.py +43 -0
- endoreg_db/utils/dataloader.py +38 -19
- endoreg_db/utils/hashs.py +1 -0
- endoreg_db/utils/paths.py +86 -0
- endoreg_db/views/raw_pdf_anony_text_validation_views.py +95 -0
- endoreg_db/views/raw_pdf_meta_validation_views.py +111 -0
- endoreg_db/views/raw_video_meta_validation_views.py +128 -18
- endoreg_db/views/video_segmentation_views.py +28 -11
- endoreg_db/views/views.py +107 -0
- {endoreg_db-0.6.2.dist-info → endoreg_db-0.6.4.dist-info}/METADATA +1 -1
- {endoreg_db-0.6.2.dist-info → endoreg_db-0.6.4.dist-info}/RECORD +96 -46
- endoreg_db/management/commands/load_name_data.py +0 -37
- {endoreg_db-0.6.2.dist-info → endoreg_db-0.6.4.dist-info}/WHEEL +0 -0
- {endoreg_db-0.6.2.dist-info → endoreg_db-0.6.4.dist-info}/licenses/LICENSE +0 -0
endoreg_db/models/disease.py
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
from django.db import models
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
class DiseaseManager(models.Manager):
|
|
5
6
|
def get_by_natural_key(self, name):
|
|
7
|
+
"""
|
|
8
|
+
Retrieve a model instance by its natural key.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
name: The natural key value used to match the model's 'name' field.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
The model instance corresponding to the provided natural key.
|
|
15
|
+
"""
|
|
6
16
|
return self.get(name=name)
|
|
7
17
|
|
|
18
|
+
|
|
8
19
|
class Disease(models.Model):
|
|
9
20
|
name = models.CharField(max_length=255, unique=True)
|
|
10
21
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
@@ -15,65 +26,123 @@ class Disease(models.Model):
|
|
|
15
26
|
objects = DiseaseManager()
|
|
16
27
|
|
|
17
28
|
def natural_key(self):
|
|
29
|
+
"""
|
|
30
|
+
Return the natural key for this model instance.
|
|
31
|
+
|
|
32
|
+
The natural key is defined as a tuple containing the instance's name.
|
|
33
|
+
"""
|
|
18
34
|
return (self.name,)
|
|
19
35
|
|
|
20
36
|
def __str__(self):
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
"""
|
|
38
|
+
Return the string representation of the instance using its name attribute.
|
|
39
|
+
"""
|
|
40
|
+
return str(self.name)
|
|
41
|
+
|
|
42
|
+
def get_classifications(self) -> List["DiseaseClassification"]:
|
|
43
|
+
"""
|
|
44
|
+
Retrieves all classifications associated with this disease.
|
|
25
45
|
|
|
46
|
+
Returns:
|
|
47
|
+
List[DiseaseClassification]: A list of related disease classification objects.
|
|
48
|
+
"""
|
|
49
|
+
classifications: List[DiseaseClassification] = [
|
|
50
|
+
_ for _ in self.disease_classifications.all()
|
|
51
|
+
]
|
|
52
|
+
return classifications
|
|
26
53
|
|
|
27
54
|
|
|
28
|
-
|
|
29
|
-
def get_classifications(self)->List['DiseaseClassification']:
|
|
30
|
-
classifications: List[DiseaseClassification] = [_ for _ in self.disease_classifications.all()]
|
|
31
|
-
return classifications
|
|
32
|
-
|
|
33
55
|
class DiseaseClassificationManager(models.Manager):
|
|
34
56
|
def get_by_natural_key(self, name):
|
|
57
|
+
"""
|
|
58
|
+
Retrieves a model instance using its natural key.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
name: A unique identifier representing the natural key of the instance.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
The model instance corresponding to the given natural key.
|
|
65
|
+
"""
|
|
35
66
|
return self.get(name=name)
|
|
36
67
|
|
|
68
|
+
|
|
37
69
|
class DiseaseClassification(models.Model):
|
|
38
70
|
name = models.CharField(max_length=255, unique=True)
|
|
39
71
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
40
72
|
name_en = models.CharField(max_length=255, blank=True, null=True)
|
|
41
73
|
|
|
42
74
|
disease = models.ForeignKey(
|
|
43
|
-
Disease, on_delete=models.CASCADE,
|
|
44
|
-
related_name='disease_classifications'
|
|
75
|
+
Disease, on_delete=models.CASCADE, related_name="disease_classifications"
|
|
45
76
|
)
|
|
46
77
|
|
|
47
78
|
objects = DiseaseClassificationManager()
|
|
48
79
|
|
|
49
80
|
def natural_key(self):
|
|
81
|
+
"""
|
|
82
|
+
Return the natural key for the instance.
|
|
83
|
+
|
|
84
|
+
Returns a single-element tuple containing the object's name, which is used as a
|
|
85
|
+
unique identifier for natural key-based lookups.
|
|
86
|
+
"""
|
|
50
87
|
return (self.name,)
|
|
51
88
|
|
|
52
89
|
def __str__(self):
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
90
|
+
"""
|
|
91
|
+
Return the string representation of the model instance.
|
|
92
|
+
|
|
93
|
+
This method converts the instance's name attribute to a string, ensuring a clear
|
|
94
|
+
and consistent display across Django interfaces.
|
|
95
|
+
"""
|
|
96
|
+
return str(self.name)
|
|
97
|
+
|
|
98
|
+
def get_choices(self) -> List["DiseaseClassificationChoice"]:
|
|
99
|
+
"""
|
|
100
|
+
Retrieves all choices associated with this disease classification.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
List[DiseaseClassificationChoice]: A list of related disease classification choices.
|
|
104
|
+
"""
|
|
105
|
+
choices: List[DiseaseClassificationChoice] = [
|
|
106
|
+
_ for _ in self.disease_classification_choices.all()
|
|
107
|
+
]
|
|
57
108
|
return choices
|
|
58
|
-
|
|
109
|
+
|
|
110
|
+
|
|
59
111
|
class DiseaseClassificationChoiceManager(models.Manager):
|
|
60
112
|
def get_by_natural_key(self, name):
|
|
113
|
+
"""Retrieve an object by its natural key.
|
|
114
|
+
|
|
115
|
+
Queries for and returns the instance whose 'name' attribute matches the provided key.
|
|
116
|
+
"""
|
|
61
117
|
return self.get(name=name)
|
|
62
118
|
|
|
119
|
+
|
|
63
120
|
class DiseaseClassificationChoice(models.Model):
|
|
64
121
|
name = models.CharField(max_length=255, unique=True)
|
|
65
122
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
66
123
|
name_en = models.CharField(max_length=255, blank=True, null=True)
|
|
67
124
|
|
|
68
125
|
disease_classification = models.ForeignKey(
|
|
69
|
-
DiseaseClassification,
|
|
70
|
-
|
|
126
|
+
DiseaseClassification,
|
|
127
|
+
on_delete=models.CASCADE,
|
|
128
|
+
related_name="disease_classification_choices",
|
|
71
129
|
)
|
|
72
130
|
|
|
73
131
|
objects = DiseaseClassificationChoiceManager()
|
|
74
132
|
|
|
75
133
|
def natural_key(self):
|
|
134
|
+
"""
|
|
135
|
+
Return a tuple representing the natural key for the instance.
|
|
136
|
+
|
|
137
|
+
The tuple contains the unique name of the model instance, which is used to
|
|
138
|
+
identify it naturally.
|
|
139
|
+
"""
|
|
76
140
|
return (self.name,)
|
|
77
141
|
|
|
78
142
|
def __str__(self):
|
|
79
|
-
|
|
143
|
+
"""
|
|
144
|
+
Return the string representation of the object's name.
|
|
145
|
+
|
|
146
|
+
This method converts the model's 'name' attribute to a string for a human-readable display.
|
|
147
|
+
"""
|
|
148
|
+
return str(self.name)
|
endoreg_db/models/event.py
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
from django.db import models
|
|
2
2
|
from typing import List
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
class EventManager(models.Manager):
|
|
6
|
+
"""
|
|
7
|
+
Manager for Event with custom query methods.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
def get_by_natural_key(self, name: str) -> "Event":
|
|
11
|
+
"""
|
|
12
|
+
Retrieves an Event instance using its natural key.
|
|
13
|
+
|
|
14
|
+
This method returns the event whose name matches the provided natural key.
|
|
15
|
+
It is primarily used to support Django's natural key serialization during
|
|
16
|
+
data import/export and deserialization processes.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
name: The unique event name serving as the natural key.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
The Event object corresponding to the given name.
|
|
23
|
+
"""
|
|
24
|
+
return self.get(name=name)
|
|
25
|
+
|
|
26
|
+
|
|
4
27
|
class Event(models.Model):
|
|
5
28
|
"""
|
|
6
29
|
A class representing an event.
|
|
@@ -11,63 +34,127 @@ class Event(models.Model):
|
|
|
11
34
|
name_en (str): The English name of the event.
|
|
12
35
|
description (str): A description of the event.
|
|
13
36
|
"""
|
|
37
|
+
|
|
14
38
|
name = models.CharField(max_length=100, unique=True)
|
|
15
39
|
name_de = models.CharField(max_length=100, blank=True, null=True)
|
|
16
40
|
name_en = models.CharField(max_length=100, blank=True, null=True)
|
|
17
41
|
description = models.TextField(blank=True, null=True)
|
|
18
42
|
event_classification = models.ForeignKey(
|
|
19
|
-
|
|
20
|
-
|
|
43
|
+
"EventClassification",
|
|
44
|
+
on_delete=models.CASCADE,
|
|
45
|
+
related_name="events",
|
|
46
|
+
null=True,
|
|
47
|
+
blank=True,
|
|
21
48
|
)
|
|
49
|
+
objects = EventManager()
|
|
22
50
|
|
|
23
51
|
def natural_key(self):
|
|
52
|
+
"""
|
|
53
|
+
Return the natural key for this instance.
|
|
54
|
+
|
|
55
|
+
The natural key is defined as a tuple containing the instance's unique name.
|
|
56
|
+
"""
|
|
24
57
|
return (self.name,)
|
|
25
58
|
|
|
26
59
|
def __str__(self):
|
|
27
|
-
|
|
28
|
-
|
|
60
|
+
"""
|
|
61
|
+
Return a string representation of the instance's name.
|
|
62
|
+
|
|
63
|
+
This method converts the 'name' attribute to a string, providing a human-readable
|
|
64
|
+
representation of the model instance.
|
|
65
|
+
"""
|
|
66
|
+
return str(self.name)
|
|
67
|
+
|
|
29
68
|
|
|
30
69
|
class EventClassificationManager(models.Manager):
|
|
31
70
|
def get_by_natural_key(self, name):
|
|
71
|
+
"""
|
|
72
|
+
Retrieves an Event instance using its natural key.
|
|
73
|
+
|
|
74
|
+
This method returns the Event whose "name" attribute matches the provided natural key.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
name (str): The natural key representing the Event's name.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Event: The Event instance with the specified name.
|
|
81
|
+
"""
|
|
32
82
|
return self.get(name=name)
|
|
33
|
-
|
|
83
|
+
|
|
84
|
+
|
|
34
85
|
class EventClassification(models.Model):
|
|
35
86
|
name = models.CharField(max_length=255, unique=True)
|
|
36
87
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
37
88
|
name_en = models.CharField(max_length=255, blank=True, null=True)
|
|
38
|
-
|
|
89
|
+
|
|
39
90
|
objects = EventClassificationManager()
|
|
40
|
-
|
|
91
|
+
|
|
41
92
|
def natural_key(self):
|
|
93
|
+
"""
|
|
94
|
+
Return a tuple containing the natural key of the instance.
|
|
95
|
+
|
|
96
|
+
The tuple consists solely of the object's name attribute, serving as its unique identifier for natural key lookups.
|
|
97
|
+
"""
|
|
42
98
|
return (self.name,)
|
|
43
|
-
|
|
99
|
+
|
|
44
100
|
def __str__(self):
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
101
|
+
"""
|
|
102
|
+
Return the object's name as a string.
|
|
103
|
+
"""
|
|
104
|
+
return str(self.name)
|
|
105
|
+
|
|
106
|
+
def get_choices(self) -> List["EventClassificationChoice"]:
|
|
107
|
+
"""
|
|
108
|
+
Retrieves the event classification choices.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
List[EventClassificationChoice]: The list of choices associated with this classification.
|
|
112
|
+
"""
|
|
113
|
+
choices: List[EventClassificationChoice] = [
|
|
114
|
+
_ for _ in self.event_classification_choices.all()
|
|
115
|
+
]
|
|
49
116
|
return choices
|
|
50
|
-
|
|
117
|
+
|
|
118
|
+
|
|
51
119
|
class EventClassificationChoiceManager(models.Manager):
|
|
52
120
|
def get_by_natural_key(self, name):
|
|
121
|
+
"""
|
|
122
|
+
Retrieves a model instance using its natural key.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
name: The value of the natural key corresponding to the instance's name field.
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
The model instance with a name matching the provided natural key.
|
|
129
|
+
"""
|
|
53
130
|
return self.get(name=name)
|
|
54
|
-
|
|
131
|
+
|
|
132
|
+
|
|
55
133
|
class EventClassificationChoice(models.Model):
|
|
56
134
|
name = models.CharField(max_length=255, unique=True)
|
|
57
135
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
58
136
|
name_en = models.CharField(max_length=255, blank=True, null=True)
|
|
59
137
|
subcategories = models.JSONField(default=dict)
|
|
60
138
|
numerical_descriptors = models.JSONField(default=dict)
|
|
61
|
-
|
|
139
|
+
|
|
62
140
|
event_classification = models.ForeignKey(
|
|
63
|
-
EventClassification,
|
|
64
|
-
|
|
141
|
+
EventClassification,
|
|
142
|
+
on_delete=models.CASCADE,
|
|
143
|
+
related_name="event_classification_choices",
|
|
65
144
|
)
|
|
66
|
-
|
|
145
|
+
|
|
67
146
|
objects = EventClassificationChoiceManager()
|
|
68
|
-
|
|
147
|
+
|
|
69
148
|
def natural_key(self):
|
|
149
|
+
"""
|
|
150
|
+
Returns the natural key for the model instance.
|
|
151
|
+
|
|
152
|
+
The natural key is defined as a tuple containing the instance's name, uniquely identifying it.
|
|
153
|
+
"""
|
|
70
154
|
return (self.name,)
|
|
71
|
-
|
|
155
|
+
|
|
72
156
|
def __str__(self):
|
|
73
|
-
|
|
157
|
+
"""
|
|
158
|
+
Return the string representation of the instance's name.
|
|
159
|
+
"""
|
|
160
|
+
return str(self.name)
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
from django.db import models
|
|
2
|
-
from typing import List
|
|
2
|
+
from typing import List, TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from endoreg_db.models import Examination, Requirement, FindingIntervention
|
|
6
|
+
|
|
3
7
|
|
|
4
8
|
class ExaminationIndicationManager(models.Manager):
|
|
5
9
|
"""
|
|
6
10
|
Manager for ExaminationIndication with custom query methods.
|
|
7
11
|
"""
|
|
12
|
+
|
|
8
13
|
def get_by_natural_key(self, name: str) -> "ExaminationIndication":
|
|
14
|
+
"""
|
|
15
|
+
Retrieves an ExaminationIndication instance by its natural key.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
name: The unique name identifying the examination indication.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
The ExaminationIndication instance corresponding to the specified name.
|
|
22
|
+
"""
|
|
9
23
|
return self.get(name=name)
|
|
10
|
-
|
|
24
|
+
|
|
25
|
+
|
|
11
26
|
class ExaminationIndication(models.Model):
|
|
12
27
|
"""
|
|
13
28
|
Represents an indication for an examination.
|
|
@@ -18,22 +33,40 @@ class ExaminationIndication(models.Model):
|
|
|
18
33
|
name_en (str): The English name of the indication.
|
|
19
34
|
classification (ForeignKey): The classification associated with the indication.
|
|
20
35
|
examination (ForeignKey): The examination associated with the indication.
|
|
36
|
+
expected_interventions (ManyToManyField): Expected interventions for this indication.
|
|
21
37
|
"""
|
|
38
|
+
|
|
22
39
|
name = models.CharField(max_length=255, unique=True)
|
|
23
40
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
24
41
|
name_en = models.CharField(max_length=255, blank=True, null=True)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
description = models.TextField(blank=True, null=True)
|
|
43
|
+
|
|
44
|
+
classifications = models.ManyToManyField(
|
|
45
|
+
"ExaminationIndicationClassification",
|
|
46
|
+
related_name="indications",
|
|
47
|
+
blank=True,
|
|
29
48
|
)
|
|
49
|
+
|
|
30
50
|
examination = models.ForeignKey(
|
|
31
|
-
|
|
32
|
-
|
|
51
|
+
"Examination",
|
|
52
|
+
on_delete=models.CASCADE,
|
|
53
|
+
related_name="indications",
|
|
33
54
|
)
|
|
34
|
-
|
|
55
|
+
|
|
56
|
+
expected_interventions = models.ManyToManyField(
|
|
57
|
+
"FindingIntervention",
|
|
58
|
+
related_name="indications",
|
|
59
|
+
blank=True,
|
|
60
|
+
)
|
|
61
|
+
|
|
35
62
|
objects = ExaminationIndicationManager()
|
|
36
|
-
|
|
63
|
+
|
|
64
|
+
if TYPE_CHECKING:
|
|
65
|
+
classifications: "models.ManyToManyField[ExaminationIndicationClassification]"
|
|
66
|
+
examination: "Examination"
|
|
67
|
+
related_requirements: "models.QuerySet[Requirement]"
|
|
68
|
+
expected_interventions: "models.ManyToManyField[FindingIntervention]"
|
|
69
|
+
|
|
37
70
|
def natural_key(self) -> tuple:
|
|
38
71
|
"""
|
|
39
72
|
Returns the natural key for the indication.
|
|
@@ -50,18 +83,24 @@ class ExaminationIndication(models.Model):
|
|
|
50
83
|
Returns:
|
|
51
84
|
str: The name of the indication.
|
|
52
85
|
"""
|
|
53
|
-
return self.name
|
|
86
|
+
return str(self.name)
|
|
54
87
|
|
|
55
|
-
def get_choices(self) -> List[
|
|
88
|
+
def get_choices(self) -> List["ExaminationIndicationClassificationChoice"]:
|
|
56
89
|
"""
|
|
57
|
-
Retrieves all choices
|
|
58
|
-
|
|
90
|
+
Retrieves all classification choices for the indication.
|
|
91
|
+
|
|
92
|
+
Aggregates and returns the choices from each classification associated with the indication.
|
|
93
|
+
|
|
59
94
|
Returns:
|
|
60
|
-
|
|
95
|
+
List[ExaminationIndicationClassificationChoice]: A list of classification choices.
|
|
61
96
|
"""
|
|
62
|
-
|
|
97
|
+
classifications = self.classifications.all()
|
|
98
|
+
choices = []
|
|
99
|
+
for classification in classifications:
|
|
100
|
+
choices.extend(classification.choices.all())
|
|
101
|
+
return choices
|
|
63
102
|
|
|
64
|
-
def get_examination(self) ->
|
|
103
|
+
def get_examination(self) -> "Examination":
|
|
65
104
|
"""
|
|
66
105
|
Retrieves the associated examination.
|
|
67
106
|
|
|
@@ -70,13 +109,25 @@ class ExaminationIndication(models.Model):
|
|
|
70
109
|
"""
|
|
71
110
|
return self.examination
|
|
72
111
|
|
|
112
|
+
|
|
73
113
|
class ExaminationIndicationClassificationManager(models.Manager):
|
|
74
114
|
"""
|
|
75
115
|
Manager for ExaminationIndicationClassification with custom query methods.
|
|
76
116
|
"""
|
|
117
|
+
|
|
77
118
|
def get_by_natural_key(self, name: str) -> "ExaminationIndicationClassification":
|
|
119
|
+
"""
|
|
120
|
+
Retrieves an ExaminationIndicationClassification by its natural key.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
name: The unique name identifying the classification.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
The ExaminationIndicationClassification instance corresponding to the given name.
|
|
127
|
+
"""
|
|
78
128
|
return self.get(name=name)
|
|
79
129
|
|
|
130
|
+
|
|
80
131
|
class ExaminationIndicationClassification(models.Model):
|
|
81
132
|
"""
|
|
82
133
|
Represents a classification for examination indications.
|
|
@@ -86,13 +137,25 @@ class ExaminationIndicationClassification(models.Model):
|
|
|
86
137
|
name_de (str): The German name of the classification.
|
|
87
138
|
name_en (str): The English name of the classification.
|
|
88
139
|
"""
|
|
140
|
+
|
|
89
141
|
name = models.CharField(max_length=255, unique=True)
|
|
90
142
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
91
143
|
name_en = models.CharField(max_length=255, blank=True, null=True)
|
|
92
|
-
|
|
93
|
-
|
|
144
|
+
description = models.TextField(blank=True, null=True)
|
|
145
|
+
examination = models.ForeignKey(
|
|
146
|
+
"Examination",
|
|
147
|
+
on_delete=models.CASCADE,
|
|
148
|
+
related_name="indication_classifications",
|
|
149
|
+
blank=True,
|
|
150
|
+
null=True,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
if TYPE_CHECKING:
|
|
154
|
+
examination: "Examination"
|
|
155
|
+
choices: "models.QuerySet[ExaminationIndicationClassificationChoice]"
|
|
156
|
+
|
|
94
157
|
objects = ExaminationIndicationClassificationManager()
|
|
95
|
-
|
|
158
|
+
|
|
96
159
|
def natural_key(self) -> tuple:
|
|
97
160
|
"""
|
|
98
161
|
Returns the natural key for the classification.
|
|
@@ -109,24 +172,38 @@ class ExaminationIndicationClassification(models.Model):
|
|
|
109
172
|
Returns:
|
|
110
173
|
str: The name of the classification.
|
|
111
174
|
"""
|
|
112
|
-
return self.name
|
|
175
|
+
return str(self.name)
|
|
113
176
|
|
|
114
|
-
def get_choices(self) -> List[
|
|
177
|
+
def get_choices(self) -> List["ExaminationIndicationClassificationChoice"]:
|
|
115
178
|
"""
|
|
116
|
-
Retrieves all choices associated with this classification.
|
|
117
|
-
|
|
179
|
+
Retrieves all classification choices associated with this classification.
|
|
180
|
+
|
|
118
181
|
Returns:
|
|
119
|
-
|
|
182
|
+
List[ExaminationIndicationClassificationChoice]: A list of classification choice instances.
|
|
120
183
|
"""
|
|
121
184
|
return list(self.choices.all())
|
|
122
185
|
|
|
186
|
+
|
|
123
187
|
class ExaminationIndicationClassificationChoiceManager(models.Manager):
|
|
124
188
|
"""
|
|
125
189
|
Manager for ExaminationIndicationClassificationChoice with custom query methods.
|
|
126
190
|
"""
|
|
127
|
-
|
|
191
|
+
|
|
192
|
+
def get_by_natural_key(
|
|
193
|
+
self, name: str
|
|
194
|
+
) -> "ExaminationIndicationClassificationChoice":
|
|
195
|
+
"""
|
|
196
|
+
Retrieves an ExaminationIndicationClassificationChoice instance by its natural key.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
name: The unique name serving as the natural key for the classification choice.
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
An ExaminationIndicationClassificationChoice instance corresponding to the given name.
|
|
203
|
+
"""
|
|
128
204
|
return self.get(name=name)
|
|
129
205
|
|
|
206
|
+
|
|
130
207
|
class ExaminationIndicationClassificationChoice(models.Model):
|
|
131
208
|
"""
|
|
132
209
|
Represents a choice within an examination indication classification.
|
|
@@ -139,14 +216,16 @@ class ExaminationIndicationClassificationChoice(models.Model):
|
|
|
139
216
|
numerical_descriptors (JSONField): Numerical descriptors for the choice.
|
|
140
217
|
classification (ForeignKey): The classification to which this choice belongs.
|
|
141
218
|
"""
|
|
219
|
+
|
|
142
220
|
name = models.CharField(max_length=255, unique=True)
|
|
143
221
|
name_de = models.CharField(max_length=255, blank=True, null=True)
|
|
144
222
|
name_en = models.CharField(max_length=255, blank=True, null=True)
|
|
145
223
|
subcategories = models.JSONField(default=dict)
|
|
146
224
|
numerical_descriptors = models.JSONField(default=dict)
|
|
147
225
|
classification = models.ForeignKey(
|
|
148
|
-
ExaminationIndicationClassification,
|
|
149
|
-
|
|
226
|
+
ExaminationIndicationClassification,
|
|
227
|
+
on_delete=models.CASCADE,
|
|
228
|
+
related_name="choices",
|
|
150
229
|
)
|
|
151
230
|
|
|
152
231
|
objects = ExaminationIndicationClassificationChoiceManager()
|
|
@@ -167,4 +246,4 @@ class ExaminationIndicationClassificationChoice(models.Model):
|
|
|
167
246
|
Returns:
|
|
168
247
|
str: The name of the classification choice.
|
|
169
248
|
"""
|
|
170
|
-
return self.name
|
|
249
|
+
return str(self.name)
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
from django.db import models
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
class ExaminationTypeManager(models.Manager):
|
|
4
5
|
"""
|
|
5
6
|
Manager for ExaminationType with custom query methods.
|
|
6
7
|
"""
|
|
8
|
+
|
|
7
9
|
def get_by_natural_key(self, name: str) -> "ExaminationType":
|
|
10
|
+
"""
|
|
11
|
+
Retrieves an ExaminationType instance using its natural key.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
name: The natural identifier for the ExaminationType, typically the unique name.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
The ExaminationType instance that matches the given name.
|
|
18
|
+
"""
|
|
8
19
|
return self.get(name=name)
|
|
9
|
-
|
|
20
|
+
|
|
21
|
+
|
|
10
22
|
class ExaminationType(models.Model):
|
|
11
23
|
"""
|
|
12
24
|
Represents a type of examination.
|
|
@@ -16,6 +28,7 @@ class ExaminationType(models.Model):
|
|
|
16
28
|
name_de (str): The German name of the examination type.
|
|
17
29
|
name_en (str): The English name of the examination type.
|
|
18
30
|
"""
|
|
31
|
+
|
|
19
32
|
objects = ExaminationTypeManager()
|
|
20
33
|
name = models.CharField(max_length=100, unique=True)
|
|
21
34
|
name_de = models.CharField(max_length=100, blank=True, null=True)
|
|
@@ -23,12 +36,13 @@ class ExaminationType(models.Model):
|
|
|
23
36
|
|
|
24
37
|
def __str__(self) -> str:
|
|
25
38
|
"""
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
str: The name of the examination type.
|
|
39
|
+
Return the string representation of the examination type.
|
|
40
|
+
|
|
41
|
+
If an English name is provided, it is returned; otherwise, the default name is used.
|
|
30
42
|
"""
|
|
31
|
-
|
|
43
|
+
name = self.name_en or self.name
|
|
44
|
+
name = str(name)
|
|
45
|
+
return name
|
|
32
46
|
|
|
33
47
|
def natural_key(self) -> tuple:
|
|
34
48
|
"""
|
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
from django.db import models
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
def get_prediction_information_source():
|
|
5
|
+
"""
|
|
6
|
+
Retrieve the prediction information source.
|
|
7
|
+
|
|
8
|
+
This function queries the InformationSource model for an entry with the name
|
|
9
|
+
"prediction" using Django's ORM and asserts that the retrieved object is valid.
|
|
10
|
+
It returns the matching InformationSource instance.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
InformationSource: The InformationSource object with name "prediction".
|
|
14
|
+
|
|
15
|
+
Raises:
|
|
16
|
+
AssertionError: If no prediction information source is found.
|
|
17
|
+
"""
|
|
4
18
|
_source = InformationSource.objects.get(name="prediction")
|
|
5
19
|
|
|
6
20
|
# make sure to return only one object
|
|
7
21
|
assert _source, "No prediction information source found"
|
|
8
22
|
return _source
|
|
9
23
|
|
|
24
|
+
|
|
10
25
|
class InformationSourceManager(models.Manager):
|
|
11
26
|
def get_by_natural_key(self, name):
|
|
27
|
+
"""
|
|
28
|
+
Retrieves a model instance using its natural key.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
name: The natural key value corresponding to the model's 'name' field.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
The model instance that matches the provided natural key.
|
|
35
|
+
"""
|
|
12
36
|
return self.get(name=name)
|
|
13
37
|
|
|
38
|
+
|
|
14
39
|
class InformationSource(models.Model):
|
|
15
40
|
objects = InformationSourceManager()
|
|
16
41
|
|
|
@@ -23,7 +48,18 @@ class InformationSource(models.Model):
|
|
|
23
48
|
date = models.DateField(blank=True, null=True)
|
|
24
49
|
|
|
25
50
|
def natural_key(self):
|
|
51
|
+
"""
|
|
52
|
+
Returns the natural key tuple for the information source.
|
|
53
|
+
|
|
54
|
+
The tuple contains the object's name, which uniquely identifies it for
|
|
55
|
+
serialization and natural key lookup.
|
|
56
|
+
"""
|
|
26
57
|
return (self.name,)
|
|
27
58
|
|
|
28
59
|
def __str__(self):
|
|
29
|
-
|
|
60
|
+
"""
|
|
61
|
+
Return the string representation of the InformationSource instance.
|
|
62
|
+
|
|
63
|
+
This method returns the instance's name attribute converted explicitly to a string.
|
|
64
|
+
"""
|
|
65
|
+
return str(self.name)
|