Skip to content

Commit 65b9c42

Browse files
Initial commit - fixing broken methods and adding new classes / methods
1 parent 1e7f7bb commit 65b9c42

12 files changed

+1424
-221
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from enum import Enum
2+
from typing import Optional, Dict
3+
4+
5+
class DiagnosisDateReasonType(Enum):
6+
"""
7+
Enum representing diagnosis date reasons with valid value IDs and descriptions.
8+
"""
9+
10+
TWO_DNAS_OF_COLONOSCOPY_ASSESSMENT_APPT = (
11+
305521,
12+
"2 DNAs of colonoscopy assessment appt",
13+
)
14+
INCORRECT_INFORMATION_PREVIOUSLY_ENTERED = (
15+
305501,
16+
"Incorrect information previously entered",
17+
)
18+
OTHER = (305500, "Other")
19+
PATIENT_CHOICE = (305522, "Patient choice")
20+
PATIENT_COULD_NOT_BE_CONTACTED = (305505, "Patient could not be contacted")
21+
PATIENT_DECEASED = (305503, "Patient deceased")
22+
PATIENT_DECLINIED_ALL_APPOINTMENTS = (305520, "Patient declined all appointments")
23+
PATIENT_EMIGRATED = (305504, "Patient emigrated")
24+
REOPENED_OLD_EPISODE_DATE_UNKNOWN = (305502, "Reopened old episode, date unknown")
25+
SSPI_UPDATE_PATIENT_DECEASED = (305525, "SSPI update - patient deceased")
26+
SSPI_UPDATE_PATIENT_EMIGRATED = (305524, "SSPI update - patient emigrated")
27+
SYSTEM_CLOSURE_AFTER_NO_INPUT_OF_DIAGNOSIS_DATE = (
28+
305519,
29+
"System closure after no input of diagnosis date",
30+
)
31+
NULL = (None, "NULL")
32+
NOT_NULL = (None, "NOT NULL")
33+
34+
def __init__(self, valid_value_id: Optional[int], description: str):
35+
self._valid_value_id: Optional[int] = valid_value_id
36+
self._description: str = description
37+
38+
@property
39+
def valid_value_id(self) -> Optional[int]:
40+
"""Returns the valid value ID for the diagnosis date reason."""
41+
return self._valid_value_id
42+
43+
@property
44+
def description(self) -> str:
45+
"""Returns the description for the diagnosis date reason."""
46+
return self._description
47+
48+
@classmethod
49+
def _build_maps(cls) -> None:
50+
if not hasattr(cls, "_descriptions"):
51+
cls._descriptions: Dict[str, DiagnosisDateReasonType] = {}
52+
cls._lowercase_descriptions: Dict[str, DiagnosisDateReasonType] = {}
53+
cls._valid_value_ids: Dict[Optional[int], DiagnosisDateReasonType] = {}
54+
for item in cls:
55+
cls._descriptions[item.description] = item
56+
cls._lowercase_descriptions[item.description.lower()] = item
57+
cls._valid_value_ids[item.valid_value_id] = item
58+
59+
@classmethod
60+
def by_description(cls, description: str) -> Optional["DiagnosisDateReasonType"]:
61+
"""
62+
Returns the DiagnosisDateReasonType matching the given description.
63+
"""
64+
cls._build_maps()
65+
return cls._descriptions.get(description)
66+
67+
@classmethod
68+
def by_description_case_insensitive(
69+
cls, description: str
70+
) -> Optional["DiagnosisDateReasonType"]:
71+
"""
72+
Returns the DiagnosisDateReasonType matching the given description (case-insensitive).
73+
"""
74+
cls._build_maps()
75+
return cls._lowercase_descriptions.get(description.lower())
76+
77+
@classmethod
78+
def by_valid_value_id(
79+
cls, valid_value_id: Optional[int]
80+
) -> Optional["DiagnosisDateReasonType"]:
81+
"""
82+
Returns the DiagnosisDateReasonType matching the given valid value ID.
83+
"""
84+
cls._build_maps()
85+
return cls._valid_value_ids.get(valid_value_id)
86+
87+
def get_valid_value_id(self) -> Optional[int]:
88+
"""
89+
Returns the valid value ID for the diagnosis date reason.
90+
"""
91+
return self._valid_value_id
92+
93+
def get_description(self) -> str:
94+
"""
95+
Returns the description for the diagnosis date reason.
96+
"""
97+
return self._description
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
from enum import Enum
2+
from typing import Optional, Dict
3+
4+
5+
class EpisodeStatusReasonType(Enum):
6+
"""
7+
Enum representing episode status reasons with valid value IDs and descriptions.
8+
"""
9+
10+
BOWEL_SCOPE_DECOMMISSIONED = (307043, "Bowel scope decommissioned")
11+
CANCELLED_REGISTRATION = (11465, "Cancelled Registration")
12+
CEASE_REQUEST = (42, "Cease Request")
13+
CLINICAL_REASON = (11358, "Clinical Reason")
14+
CURRENTLY_INVOLVED_IN_A_SURVEILLANCE_PROGRAMME_OUTSIDE_BCSP = (
15+
200273,
16+
"Currently involved in a surveillance programme outside BCSP",
17+
)
18+
CURRENTLY_UNDER_CARE_FOR_CANCER = (200274, "Currently under care for cancer")
19+
DECEASED = (11356, "Deceased")
20+
DECLINE = (203050, "Decline")
21+
DISCHARGE_FROM_SURVEILLANCE_AGE = (20031, "Discharge from Surveillance - Age")
22+
DISCHARGE_FROM_SURVEILLANCE_CANNOT_CONTACT_PATIENT = (
23+
20034,
24+
"Discharge from Surveillance - Cannot Contact Patient",
25+
)
26+
DISCHARGE_FROM_SURVEILLANCE_CLINICAL_DECISION = (
27+
20035,
28+
"Discharge from Surveillance - Clinical Decision",
29+
)
30+
DISCHARGE_FROM_SURVEILLANCE_NATIONAL_GUIDELINES = (
31+
20032,
32+
"Discharge from Surveillance - National Guidelines",
33+
)
34+
DISCHARGE_FROM_SURVEILLANCE_PATIENT_CHOICE = (
35+
20033,
36+
"Discharge from Surveillance - Patient Choice",
37+
)
38+
DISCHARGE_FROM_SURVEILLANCE_PATIENT_DISSENT = (
39+
20038,
40+
"Discharge from Surveillance - Patient Dissent",
41+
)
42+
DISCHARGED = (11364, "Discharged")
43+
DISCHARGED_FROM_SCREENING_INTO_SYMPTOMATIC_CARE = (
44+
20423,
45+
"Discharged from Screening into Symptomatic care",
46+
)
47+
EPISODE_COMPLETE = (11360, "Episode Complete")
48+
INCORRECT_DATE_OF_BIRTH = (203180, "Incorrect Date of Birth")
49+
INDIVIDUAL_HAS_LEFT_THE_COUNTRY = (11357, "Individual has left the country")
50+
INFORMED_DISSENT = (11355, "Informed Dissent")
51+
NON_RESPONSE = (11359, "Non Response")
52+
NOT_SUITABLE = (203054, "Not suitable")
53+
OPT_OUT_OF_CURRENT_EPISODE = (200275, "Opt out of current episode")
54+
PATIENT_CHOICE = (20235, "Patient Choice")
55+
PATIENT_DISCHARGE_FROM_SURVEILLANCE = (20037, "Patient Discharge from Surveillance")
56+
PATIENT_COULD_NOT_BE_CONTACTED = (11467, "Patient could not be contacted")
57+
PATIENT_ELECTED_PRIVATE_TREATMENT = (11365, "Patient elected private treatment")
58+
PENDING_COMPLETION_OF_OUTSTANDING_EVENTS = (
59+
11363,
60+
"Pending Completion of Outstanding Events",
61+
)
62+
RETURNED_UNDELIVERED_MAIL = (15050, "Returned/Undelivered mail")
63+
RETURNED_UNDELIVERED_MAIL_LETTER_SENT = (
64+
203052,
65+
"Returned/undelivered mail letter sent",
66+
)
67+
SUBJECT_NOT_AVAILABLE_FOR_OFFERED_APPOINTMENT = (
68+
203051,
69+
"Subject not available for offered appointment",
70+
)
71+
SURVEILLANCE_POSTPONED = (20036, "Surveillance Postponed")
72+
SURVEILLANCE_SELECTION = (20174, "Surveillance Selection")
73+
UNCERTIFIED_DEATH = (11405, "Uncertified Death")
74+
UNCONFIRMED_CLINICAL_REASON = (11406, "Unconfirmed Clinical Reason")
75+
WAITING_FURTHER_ASSESSMENT = (20384, "Waiting Further Assessment")
76+
WAITING_FURTHER_INFORMATION = (11361, "Waiting Further Information")
77+
NULL = (None, "Null")
78+
79+
def __init__(self, valid_value_id: Optional[int], description: str):
80+
self._valid_value_id: Optional[int] = valid_value_id
81+
self._description: str = description
82+
83+
@property
84+
def valid_value_id(self) -> Optional[int]:
85+
"""Returns the valid value ID for the episode status reason."""
86+
return self._valid_value_id
87+
88+
@property
89+
def description(self) -> str:
90+
"""Returns the description for the episode status reason."""
91+
return self._description
92+
93+
@classmethod
94+
def _build_maps(cls) -> None:
95+
if not hasattr(cls, "_descriptions"):
96+
cls._descriptions: Dict[str, EpisodeStatusReasonType] = {}
97+
cls._lowercase_descriptions: Dict[str, EpisodeStatusReasonType] = {}
98+
cls._valid_value_ids: Dict[Optional[int], EpisodeStatusReasonType] = {}
99+
for item in cls:
100+
cls._descriptions[item.description] = item
101+
cls._lowercase_descriptions[item.description.lower()] = item
102+
cls._valid_value_ids[item.valid_value_id] = item
103+
104+
@classmethod
105+
def by_description(cls, description: str) -> Optional["EpisodeStatusReasonType"]:
106+
"""
107+
Returns the EpisodeStatusReasonType matching the given description.
108+
"""
109+
cls._build_maps()
110+
return cls._descriptions.get(description)
111+
112+
@classmethod
113+
def by_description_case_insensitive(
114+
cls, description: str
115+
) -> Optional["EpisodeStatusReasonType"]:
116+
"""
117+
Returns the EpisodeStatusReasonType matching the given description (case-insensitive).
118+
"""
119+
cls._build_maps()
120+
return cls._lowercase_descriptions.get(description.lower())
121+
122+
@classmethod
123+
def by_valid_value_id(
124+
cls, valid_value_id: Optional[int]
125+
) -> Optional["EpisodeStatusReasonType"]:
126+
"""
127+
Returns the EpisodeStatusReasonType matching the given valid value ID.
128+
"""
129+
cls._build_maps()
130+
return cls._valid_value_ids.get(valid_value_id)
131+
132+
def get_id(self) -> Optional[int]:
133+
"""
134+
Returns the valid value ID for the episode status reason.
135+
"""
136+
return self._valid_value_id
137+
138+
def get_description(self) -> str:
139+
"""
140+
Returns
141+
"""
142+
return self._description

classes/episode_status_type.py

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 EpisodeStatusType(Enum):
6+
"""
7+
Enum representing episode status types with valid value IDs and descriptions.
8+
"""
9+
10+
Closed = (11353, "Closed")
11+
Open = (11352, "Open")
12+
Paused = (11354, "Paused")
13+
Pending = (11354, "Pending")
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 episode status."""
22+
return self._valid_value_id
23+
24+
@property
25+
def description(self) -> str:
26+
"""Returns the description for the episode status."""
27+
return self._description
28+
29+
@classmethod
30+
def _build_maps(cls) -> None:
31+
if not hasattr(cls, "_descriptions"):
32+
cls._descriptions: Dict[str, EpisodeStatusType] = {}
33+
cls._lowercase_descriptions: Dict[str, EpisodeStatusType] = {}
34+
cls._valid_value_ids: Dict[int, EpisodeStatusType] = {}
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(cls, description: str) -> Optional["EpisodeStatusType"]:
42+
"""
43+
Returns the EpisodeStatusType matching the given description.
44+
"""
45+
cls._build_maps()
46+
return cls._descriptions.get(description)
47+
48+
@classmethod
49+
def by_description_case_insensitive(
50+
cls, description: str
51+
) -> Optional["EpisodeStatusType"]:
52+
"""
53+
Returns the EpisodeStatusType matching the given description (case-insensitive).
54+
"""
55+
cls._build_maps()
56+
return cls._lowercase_descriptions.get(description.lower())
57+
58+
@classmethod
59+
def by_valid_value_id(cls, valid_value_id: int) -> Optional["EpisodeStatusType"]:
60+
"""
61+
Returns the EpisodeStatusType 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 episode status.
69+
"""
70+
return self._valid_value_id
71+
72+
def get_description(self) -> str:
73+
"""
74+
Returns the description for the
75+
"""
76+
return self._description

0 commit comments

Comments
 (0)