Skip to content

Commit 95b1275

Browse files
Fixing and adding new methods / classes
1 parent 65b9c42 commit 95b1275

19 files changed

+1568
-74
lines changed

classes/asa_grade_type.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
if not hasattr(cls, "_descriptions"):
37+
cls._descriptions: Dict[str, ASAGradeType] = {}
38+
cls._lowercase_descriptions: Dict[str, ASAGradeType] = {}
39+
cls._valid_value_ids: Dict[Optional[int], ASAGradeType] = {}
40+
for item in cls:
41+
cls._descriptions[item.description] = item
42+
cls._lowercase_descriptions[item.description.lower()] = item
43+
cls._valid_value_ids[item.valid_value_id] = item
44+
45+
@classmethod
46+
def by_description(cls, description: str) -> Optional["ASAGradeType"]:
47+
"""
48+
Returns the ASAGradeType matching the given description.
49+
"""
50+
cls._build_maps()
51+
return cls._descriptions.get(description)
52+
53+
@classmethod
54+
def by_description_case_insensitive(
55+
cls, description: str
56+
) -> Optional["ASAGradeType"]:
57+
"""
58+
Returns the ASAGradeType matching the given description (case-insensitive).
59+
"""
60+
cls._build_maps()
61+
return cls._lowercase_descriptions.get(description.lower())
62+
63+
@classmethod
64+
def by_valid_value_id(
65+
cls, valid_value_id: Optional[int]
66+
) -> Optional["ASAGradeType"]:
67+
"""
68+
Returns the ASAGradeType matching the given valid value ID.
69+
"""
70+
cls._build_maps()
71+
return cls._valid_value_ids.get(valid_value_id)
72+
73+
def get_valid_value_id(self) -> Optional[int]:
74+
"""
75+
Returns the valid value ID for the ASA grade.
76+
"""
77+
return self._valid_value_id
78+
79+
def get_description(self) -> str:
80+
"""
81+
Returns the description for the ASA grade.
82+
"""
83+
return self._description

classes/cancer_treatment_intent.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
if not hasattr(cls, "_descriptions"):
33+
cls._descriptions: Dict[str, CancerTreatmentIntent] = {}
34+
cls._lowercase_descriptions: Dict[str, CancerTreatmentIntent] = {}
35+
cls._valid_value_ids: Dict[int, CancerTreatmentIntent] = {}
36+
for item in cls:
37+
cls._descriptions[item.description] = item
38+
cls._lowercase_descriptions[item.description.lower()] = item
39+
cls._valid_value_ids[item.valid_value_id] = item
40+
41+
@classmethod
42+
def by_description(cls, description: str) -> Optional["CancerTreatmentIntent"]:
43+
"""
44+
Returns the CancerTreatmentIntent matching the given description.
45+
"""
46+
cls._build_maps()
47+
return cls._descriptions.get(description)
48+
49+
@classmethod
50+
def by_description_case_insensitive(
51+
cls, description: str
52+
) -> Optional["CancerTreatmentIntent"]:
53+
"""
54+
Returns the CancerTreatmentIntent matching the given description (case-insensitive).
55+
"""
56+
cls._build_maps()
57+
return cls._lowercase_descriptions.get(description.lower())
58+
59+
@classmethod
60+
def by_valid_value_id(
61+
cls, valid_value_id: int
62+
) -> Optional["CancerTreatmentIntent"]:
63+
"""
64+
Returns the CancerTreatmentIntent matching the given valid value ID.
65+
"""
66+
cls._build_maps()
67+
return cls._valid_value_ids.get(valid_value_id)
68+
69+
def get_id(self) -> int:
70+
"""Returns the valid value ID for the CancerTreatmentIntent given."""
71+
return self._valid_value_id
72+
73+
def get_description(self) -> str:
74+
"""Returns the description for the CancerTreatmentIntent given."""
75+
return self._description
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
if not hasattr(cls, "_descriptions"):
30+
cls._descriptions: Dict[str, DiagnosticTestReferralType] = {}
31+
cls._lowercase_descriptions: Dict[str, DiagnosticTestReferralType] = {}
32+
cls._valid_value_ids: Dict[int, DiagnosticTestReferralType] = {}
33+
for item in cls:
34+
cls._descriptions[item.description] = item
35+
cls._lowercase_descriptions[item.description.lower()] = item
36+
cls._valid_value_ids[item.valid_value_id] = item
37+
38+
@classmethod
39+
def by_description(cls, description: str) -> Optional["DiagnosticTestReferralType"]:
40+
"""
41+
Returns the DiagnosticTestReferralType matching the given description.
42+
"""
43+
cls._build_maps()
44+
return cls._descriptions.get(description)
45+
46+
@classmethod
47+
def by_description_case_insensitive(
48+
cls, description: str
49+
) -> Optional["DiagnosticTestReferralType"]:
50+
"""
51+
Returns the DiagnosticTestReferralType matching the given description (case-insensitive).
52+
"""
53+
cls._build_maps()
54+
return cls._lowercase_descriptions.get(description.lower())
55+
56+
@classmethod
57+
def by_valid_value_id(
58+
cls, valid_value_id: int
59+
) -> Optional["DiagnosticTestReferralType"]:
60+
"""
61+
Returns the DiagnosticTestReferralType matching the given valid value ID.
62+
"""
63+
cls._build_maps()
64+
return cls._valid_value_ids.get(valid_value_id)
65+
66+
def get_id(self) -> int:
67+
"""
68+
Returns the valid value ID for the diagnostic test referral type.
69+
"""
70+
return self._valid_value_id
71+
72+
def get_description(self) -> str:
73+
"""
74+
Returns the description for the diagnostic test referral type.
75+
"""
76+
return self._description
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
from enum import Enum
2+
from typing import Optional, Dict
3+
4+
5+
class FinalPretreatmentMCategoryType(Enum):
6+
"""
7+
Enum representing final pretreatment M categories for cancer audit datasets,
8+
with valid value IDs and descriptions.
9+
"""
10+
11+
CM1 = (17248, "Metastases (cM1)")
12+
CM0 = (17247, "No Metastases (cM0)")
13+
NOT_REPORTED = (202140, "Not Reported")
14+
15+
def __init__(self, valid_value_id: int, description: str):
16+
self._valid_value_id: int = valid_value_id
17+
self._description: str = description
18+
19+
@property
20+
def valid_value_id(self) -> int:
21+
"""Returns the valid value ID for the M category."""
22+
return self._valid_value_id
23+
24+
@property
25+
def description(self) -> str:
26+
"""Returns the description for the M category."""
27+
return self._description
28+
29+
@classmethod
30+
def _build_maps(cls) -> None:
31+
if not hasattr(cls, "_descriptions"):
32+
cls._descriptions: Dict[str, FinalPretreatmentMCategoryType] = {}
33+
cls._lowercase_descriptions: Dict[str, FinalPretreatmentMCategoryType] = {}
34+
cls._valid_value_ids: Dict[int, FinalPretreatmentMCategoryType] = {}
35+
for item in cls:
36+
cls._descriptions[item.description] = item
37+
cls._lowercase_descriptions[item.description.lower()] = item
38+
cls._valid_value_ids[item.valid_value_id] = item
39+
40+
@classmethod
41+
def by_description(
42+
cls, description: str
43+
) -> Optional["FinalPretreatmentMCategoryType"]:
44+
"""
45+
Returns the FinalPretreatmentMCategoryType matching the given description.
46+
"""
47+
cls._build_maps()
48+
return cls._descriptions.get(description)
49+
50+
@classmethod
51+
def by_description_case_insensitive(
52+
cls, description: str
53+
) -> Optional["FinalPretreatmentMCategoryType"]:
54+
"""
55+
Returns the FinalPretreatmentMCategoryType matching the given description (case-insensitive).
56+
"""
57+
cls._build_maps()
58+
return cls._lowercase_descriptions.get(description.lower())
59+
60+
@classmethod
61+
def by_valid_value_id(
62+
cls, valid_value_id: int
63+
) -> Optional["FinalPretreatmentMCategoryType"]:
64+
"""
65+
Returns the FinalPretreatmentMCategoryType matching the given valid value ID.
66+
"""
67+
cls._build_maps()
68+
return cls._valid_value_ids.get(valid_value_id)
69+
70+
def get_id(self) -> int:
71+
"""Returns the valid value ID for the M category."""
72+
return self._valid_value_id
73+
74+
def get_description(self) -> str:
75+
"""Returns the description for the M category."""
76+
return self._description
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from enum import Enum
2+
from typing import Optional, Dict
3+
4+
5+
class FinalPretreatmentNCategoryType(Enum):
6+
"""
7+
Enum representing final pretreatment N categories for cancer audit datasets,
8+
with valid value IDs and descriptions.
9+
"""
10+
11+
CNX = (202201, "Regional lymph nodes cannot be assessed (cNX)")
12+
CN0 = (17256, "No regional lymph node metastasis (cN0)")
13+
CN1 = (17257, "Metastasis in 1 to 3 regional lymph nodes (cN1)")
14+
CN2 = (17258, "Metastasis in 4 or more regional lymph nodes (cN2)")
15+
NOT_REPORTED = (202140, "Not Reported")
16+
17+
def __init__(self, valid_value_id: int, description: str):
18+
self._valid_value_id: int = valid_value_id
19+
self._description: str = description
20+
21+
@property
22+
def valid_value_id(self) -> int:
23+
"""Returns the valid value ID for the N category."""
24+
return self._valid_value_id
25+
26+
@property
27+
def description(self) -> str:
28+
"""Returns the description for the N category."""
29+
return self._description
30+
31+
@classmethod
32+
def _build_maps(cls) -> None:
33+
if not hasattr(cls, "_descriptions"):
34+
cls._descriptions: Dict[str, FinalPretreatmentNCategoryType] = {}
35+
cls._lowercase_descriptions: Dict[str, FinalPretreatmentNCategoryType] = {}
36+
cls._valid_value_ids: Dict[int, FinalPretreatmentNCategoryType] = {}
37+
for item in cls:
38+
cls._descriptions[item.description] = item
39+
cls._lowercase_descriptions[item.description.lower()] = item
40+
cls._valid_value_ids[item.valid_value_id] = item
41+
42+
@classmethod
43+
def by_description(
44+
cls, description: str
45+
) -> Optional["FinalPretreatmentNCategoryType"]:
46+
"""
47+
Returns the FinalPretreatmentNCategoryType 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["FinalPretreatmentNCategoryType"]:
56+
"""
57+
Returns the FinalPretreatmentNCategoryType 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["FinalPretreatmentNCategoryType"]:
66+
"""
67+
Returns the FinalPretreatmentNCategoryType 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+
"""Returns the valid value ID for the N category."""
74+
return self._valid_value_id
75+
76+
def get_description(self) -> str:
77+
"""Returns the description for the N category."""
78+
return self._description

0 commit comments

Comments
 (0)