Skip to content

Commit 7641177

Browse files
Merge branch 'main' into feature/BCSS-20615-regression-test-subject-episodes-diagnosis-date
Signed-off-by: vidhya-chandra1 <[email protected]>
2 parents 6c41841 + 83e54a7 commit 7641177

29 files changed

+3727
-294
lines changed

classes/asa_grade_type.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
from enum import Enum
2+
from typing import Optional, Dict
3+
4+
5+
class ASAGradeType(Enum):
6+
"""
7+
Enum representing ASA grades for colonoscopy assessment scenarios,
8+
with valid value IDs and descriptions.
9+
"""
10+
11+
IFIT = (17009, "I - Fit")
12+
II_RELEVANT_DISEASE = (17010, "II - Relevant disease")
13+
III_RESTRICTIVE_DISEASE = (17011, "III - Restrictive disease")
14+
IV_LIFE_THREATENING_DISEASE = (17012, "IV - Life threatening disease")
15+
V_MORIBUND = (17013, "V - Moribund")
16+
NOT_APPLICABLE = (17014, "Not Applicable")
17+
NOT_KNOWN = (17015, "Not Known")
18+
NULL = (None, "")
19+
20+
def __init__(self, valid_value_id: Optional[int], description: str):
21+
self._valid_value_id: Optional[int] = valid_value_id
22+
self._description: str = description
23+
24+
@property
25+
def valid_value_id(self) -> Optional[int]:
26+
"""Returns the valid value ID for the ASA grade."""
27+
return self._valid_value_id
28+
29+
@property
30+
def description(self) -> str:
31+
"""Returns the description for the ASA grade."""
32+
return self._description
33+
34+
@classmethod
35+
def _build_maps(cls) -> None:
36+
"""
37+
Initializes internal lookup maps for ASAGradeType enum members.
38+
39+
It ensures these maps are built only once per class, using `hasattr` to prevent
40+
redundant reinitialization.
41+
"""
42+
if not hasattr(cls, "_descriptions"):
43+
cls._descriptions: Dict[str, ASAGradeType] = {}
44+
cls._lowercase_descriptions: Dict[str, ASAGradeType] = {}
45+
cls._valid_value_ids: Dict[Optional[int], ASAGradeType] = {}
46+
for item in cls:
47+
cls._descriptions[item.description] = item
48+
cls._lowercase_descriptions[item.description.lower()] = item
49+
cls._valid_value_ids[item.valid_value_id] = item
50+
51+
@classmethod
52+
def by_description(cls, description: str) -> Optional["ASAGradeType"]:
53+
"""
54+
Returns the ASAGradeType matching the given description.
55+
"""
56+
cls._build_maps()
57+
return cls._descriptions.get(description)
58+
59+
@classmethod
60+
def by_description_case_insensitive(
61+
cls, description: str
62+
) -> Optional["ASAGradeType"]:
63+
"""
64+
Returns the ASAGradeType matching the given description (case-insensitive).
65+
"""
66+
cls._build_maps()
67+
return cls._lowercase_descriptions.get(description.lower())
68+
69+
@classmethod
70+
def by_valid_value_id(
71+
cls, valid_value_id: Optional[int]
72+
) -> Optional["ASAGradeType"]:
73+
"""
74+
Returns the ASAGradeType matching the given valid value ID.
75+
"""
76+
cls._build_maps()
77+
return cls._valid_value_ids.get(valid_value_id)
78+
79+
def get_valid_value_id(self) -> Optional[int]:
80+
"""
81+
Returns the valid value ID for the ASA grade.
82+
"""
83+
return self._valid_value_id
84+
85+
def get_description(self) -> str:
86+
"""
87+
Returns the description for the ASA grade.
88+
"""
89+
return self._description

classes/cancer_treatment_intent.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from enum import Enum
2+
from typing import Optional, Dict
3+
4+
5+
class CancerTreatmentIntent(Enum):
6+
"""
7+
Enum representing types of cancer treatment intent with associated valid value IDs and descriptions.
8+
Provides utility methods to retrieve enum instances by description or ID.
9+
"""
10+
11+
CURATIVE = (17370, "Curative")
12+
PALLIATIVE = (17371, "Palliative")
13+
UNCERTAIN = (17372, "Uncertain")
14+
NOT_KNOWN = (17373, "Not Known")
15+
16+
def __init__(self, valid_value_id: int, description: str):
17+
self._valid_value_id = valid_value_id
18+
self._description = description
19+
20+
@property
21+
def valid_value_id(self) -> int:
22+
"""Returns the valid value ID for the treatment given."""
23+
return self._valid_value_id
24+
25+
@property
26+
def description(self) -> str:
27+
"""Returns the description for the treatment given."""
28+
return self._description
29+
30+
@classmethod
31+
def _build_maps(cls) -> None:
32+
"""
33+
Initializes internal lookup maps for CanterTreatmentIntent enum members.
34+
35+
It ensures these maps are built only once per class, using `hasattr` to prevent
36+
redundant reinitialization.
37+
"""
38+
if not hasattr(cls, "_descriptions"):
39+
cls._descriptions: Dict[str, CancerTreatmentIntent] = {}
40+
cls._lowercase_descriptions: Dict[str, CancerTreatmentIntent] = {}
41+
cls._valid_value_ids: Dict[int, CancerTreatmentIntent] = {}
42+
for item in cls:
43+
cls._descriptions[item.description] = item
44+
cls._lowercase_descriptions[item.description.lower()] = item
45+
cls._valid_value_ids[item.valid_value_id] = item
46+
47+
@classmethod
48+
def by_description(cls, description: str) -> Optional["CancerTreatmentIntent"]:
49+
"""
50+
Returns the CancerTreatmentIntent matching the given description.
51+
"""
52+
cls._build_maps()
53+
return cls._descriptions.get(description)
54+
55+
@classmethod
56+
def by_description_case_insensitive(
57+
cls, description: str
58+
) -> Optional["CancerTreatmentIntent"]:
59+
"""
60+
Returns the CancerTreatmentIntent matching the given description (case-insensitive).
61+
"""
62+
cls._build_maps()
63+
return cls._lowercase_descriptions.get(description.lower())
64+
65+
@classmethod
66+
def by_valid_value_id(
67+
cls, valid_value_id: int
68+
) -> Optional["CancerTreatmentIntent"]:
69+
"""
70+
Returns the CancerTreatmentIntent matching the given valid value ID.
71+
"""
72+
cls._build_maps()
73+
return cls._valid_value_ids.get(valid_value_id)
74+
75+
def get_id(self) -> int:
76+
"""Returns the valid value ID for the CancerTreatmentIntent given."""
77+
return self._valid_value_id
78+
79+
def get_description(self) -> str:
80+
"""Returns the description for the CancerTreatmentIntent given."""
81+
return self._description

classes/diagnosis_date_reason_type.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
from enum import Enum
22
from typing import Optional, Dict
33

4+
45
class DiagnosisDateReasonType(Enum):
6+
"""
7+
Enum representing diagnosis date reasons with valid value IDs and descriptions.
8+
"""
9+
510
TWO_DNAS_OF_COLONOSCOPY_ASSESSMENT_APPT = (
611
305521,
712
"2 DNAs of colonoscopy assessment appt",
@@ -14,7 +19,7 @@ class DiagnosisDateReasonType(Enum):
1419
PATIENT_CHOICE = (305522, "Patient choice")
1520
PATIENT_COULD_NOT_BE_CONTACTED = (305505, "Patient could not be contacted")
1621
PATIENT_DECEASED = (305503, "Patient deceased")
17-
PATIENT_DECLINIED_ALL_APPOINTMENTS = (305520, "Patient declined all appointments")
22+
PATIENT_DECLINED_ALL_APPOINTMENTS = (305520, "Patient declined all appointments")
1823
PATIENT_EMIGRATED = (305504, "Patient emigrated")
1924
REOPENED_OLD_EPISODE_DATE_UNKNOWN = (305502, "Reopened old episode, date unknown")
2025
SSPI_UPDATE_PATIENT_DECEASED = (305525, "SSPI update - patient deceased")
@@ -27,21 +32,27 @@ class DiagnosisDateReasonType(Enum):
2732
NOT_NULL = (None, "NOT NULL")
2833

2934
def __init__(self, valid_value_id: Optional[int], description: str):
30-
self._valid_value_id = valid_value_id
31-
self._description = description
35+
self._valid_value_id: Optional[int] = valid_value_id
36+
self._description: str = description
3237

3338
@property
3439
def valid_value_id(self) -> Optional[int]:
35-
"""Returns the valid value ID for the reason for diagnosis date."""
40+
"""Returns the valid value ID for the diagnosis date reason."""
3641
return self._valid_value_id
3742

3843
@property
3944
def description(self) -> str:
40-
"""Returns the description for the reason for diagnosis date."""
45+
"""Returns the description for the diagnosis date reason."""
4146
return self._description
4247

4348
@classmethod
44-
def _build_maps(cls):
49+
def _build_maps(cls) -> None:
50+
"""
51+
Initializes internal lookup maps for DiagnosisDateReasonType enum members.
52+
53+
It ensures these maps are built only once per class, using `hasattr` to prevent
54+
redundant reinitialization.
55+
"""
4556
if not hasattr(cls, "_descriptions"):
4657
cls._descriptions: Dict[str, DiagnosisDateReasonType] = {}
4758
cls._lowercase_descriptions: Dict[str, DiagnosisDateReasonType] = {}
@@ -53,30 +64,40 @@ def _build_maps(cls):
5364

5465
@classmethod
5566
def by_description(cls, description: str) -> Optional["DiagnosisDateReasonType"]:
56-
"""Returns the DiagnosisDateReasonType matching the given description."""
67+
"""
68+
Returns the DiagnosisDateReasonType matching the given description.
69+
"""
5770
cls._build_maps()
5871
return cls._descriptions.get(description)
5972

6073
@classmethod
6174
def by_description_case_insensitive(
6275
cls, description: str
6376
) -> Optional["DiagnosisDateReasonType"]:
64-
"""Returns the DiagnosisDateReasonType matching the given description. (case-insensitive)."""
77+
"""
78+
Returns the DiagnosisDateReasonType matching the given description (case-insensitive).
79+
"""
6580
cls._build_maps()
6681
return cls._lowercase_descriptions.get(description.lower())
6782

6883
@classmethod
6984
def by_valid_value_id(
7085
cls, valid_value_id: Optional[int]
7186
) -> Optional["DiagnosisDateReasonType"]:
72-
"""Returns the DiagnosisDateReasonType matching the given valid value ID."""
87+
"""
88+
Returns the DiagnosisDateReasonType matching the given valid value ID.
89+
"""
7390
cls._build_maps()
7491
return cls._valid_value_ids.get(valid_value_id)
7592

7693
def get_valid_value_id(self) -> Optional[int]:
77-
"""Returns the valid value ID for the reason for diagnosis date reason."""
94+
"""
95+
Returns the valid value ID for the diagnosis date reason.
96+
"""
7897
return self._valid_value_id
7998

8099
def get_description(self) -> str:
81-
"""Returns the description for the reason for diagnosis date reason"""
82-
return self._description
100+
"""
101+
Returns the description for the diagnosis date reason.
102+
"""
103+
return self._description
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from enum import Enum
2+
from typing import Optional, Dict
3+
4+
5+
class DiagnosticTestReferralType(Enum):
6+
"""
7+
Enum representing diagnostic test referral types with valid value IDs and descriptions.
8+
"""
9+
10+
ENDOSCOPIC = (20356, "Endoscopic")
11+
RADIOLOGICAL = (20357, "Radiological")
12+
13+
def __init__(self, valid_value_id: int, description: str):
14+
self._valid_value_id: int = valid_value_id
15+
self._description: str = description
16+
17+
@property
18+
def valid_value_id(self) -> int:
19+
"""Returns the valid value ID for the diagnostic test referral type."""
20+
return self._valid_value_id
21+
22+
@property
23+
def description(self) -> str:
24+
"""Returns the description for the diagnostic test referral type."""
25+
return self._description
26+
27+
@classmethod
28+
def _build_maps(cls) -> None:
29+
"""
30+
Initializes internal lookup maps for DiagnosticTestReferralType enum members.
31+
32+
It ensures these maps are built only once per class, using `hasattr` to prevent
33+
redundant reinitialization.
34+
"""
35+
if not hasattr(cls, "_descriptions"):
36+
cls._descriptions: Dict[str, DiagnosticTestReferralType] = {}
37+
cls._lowercase_descriptions: Dict[str, DiagnosticTestReferralType] = {}
38+
cls._valid_value_ids: Dict[int, DiagnosticTestReferralType] = {}
39+
for item in cls:
40+
cls._descriptions[item.description] = item
41+
cls._lowercase_descriptions[item.description.lower()] = item
42+
cls._valid_value_ids[item.valid_value_id] = item
43+
44+
@classmethod
45+
def by_description(cls, description: str) -> Optional["DiagnosticTestReferralType"]:
46+
"""
47+
Returns the DiagnosticTestReferralType matching the given description.
48+
"""
49+
cls._build_maps()
50+
return cls._descriptions.get(description)
51+
52+
@classmethod
53+
def by_description_case_insensitive(
54+
cls, description: str
55+
) -> Optional["DiagnosticTestReferralType"]:
56+
"""
57+
Returns the DiagnosticTestReferralType matching the given description (case-insensitive).
58+
"""
59+
cls._build_maps()
60+
return cls._lowercase_descriptions.get(description.lower())
61+
62+
@classmethod
63+
def by_valid_value_id(
64+
cls, valid_value_id: int
65+
) -> Optional["DiagnosticTestReferralType"]:
66+
"""
67+
Returns the DiagnosticTestReferralType matching the given valid value ID.
68+
"""
69+
cls._build_maps()
70+
return cls._valid_value_ids.get(valid_value_id)
71+
72+
def get_id(self) -> int:
73+
"""
74+
Returns the valid value ID for the diagnostic test referral type.
75+
"""
76+
return self._valid_value_id
77+
78+
def get_description(self) -> str:
79+
"""
80+
Returns the description for the diagnostic test referral type.
81+
"""
82+
return self._description

0 commit comments

Comments
 (0)