Skip to content

Commit 38a553b

Browse files
Adding docstrings to classes and removing temp file
1 parent 0950ba0 commit 38a553b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2576
-392
lines changed

classes/address_contact_type.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,61 @@
33

44

55
class AddressContactType(Enum):
6+
"""
7+
Enum representing the type of address contact for a subject.
8+
9+
Attributes:
10+
WORK: Represents a work address contact type.
11+
HOME: Represents a home address contact type.
12+
"""
13+
614
WORK = (13056, "WORK")
715
HOME = (13057, "HOME")
816

917
def __init__(self, valid_value_id: int, allowed_value: str):
18+
"""
19+
Initialize an AddressContactType enum member.
20+
21+
Args:
22+
valid_value_id (int): The unique identifier for the address contact type.
23+
allowed_value (str): The string representation of the address contact type.
24+
"""
1025
self._valid_value_id = valid_value_id
1126
self._allowed_value = allowed_value
1227

1328
@property
1429
def valid_value_id(self) -> int:
30+
"""
31+
Returns the unique identifier for the address contact type.
32+
33+
Returns:
34+
int: The valid value ID.
35+
"""
1536
return self._valid_value_id
1637

1738
@property
1839
def allowed_value(self) -> str:
40+
"""
41+
Returns the string representation of the address contact type.
42+
43+
Returns:
44+
str: The allowed value.
45+
"""
1946
return self._allowed_value
2047

2148
@classmethod
2249
def by_valid_value_id(
2350
cls, address_contact_type_id: int
2451
) -> Optional["AddressContactType"]:
52+
"""
53+
Returns the AddressContactType enum member matching the given valid value ID.
54+
55+
Args:
56+
address_contact_type_id (int): The valid value ID to search for.
57+
58+
Returns:
59+
Optional[AddressContactType]: The matching enum member, or None if not found.
60+
"""
2561
return next(
2662
(item for item in cls if item.valid_value_id == address_contact_type_id),
2763
None,

classes/address_type.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,59 @@
33

44

55
class AddressType(Enum):
6+
"""
7+
Enum representing the type of address for a subject.
8+
9+
Attributes:
10+
MAIN_REGISTERED_ADDRESS: Represents the main registered address (code "H").
11+
TEMPORARY_ADDRESS: Represents a temporary address (code "T").
12+
"""
13+
614
MAIN_REGISTERED_ADDRESS = (13042, "H")
715
TEMPORARY_ADDRESS = (13043, "T")
816

917
def __init__(self, valid_value_id: int, allowed_value: str):
18+
"""
19+
Initialize an AddressType enum member.
20+
21+
Args:
22+
valid_value_id (int): The unique identifier for the address type.
23+
allowed_value (str): The string representation of the address type.
24+
"""
1025
self._valid_value_id = valid_value_id
1126
self._allowed_value = allowed_value
1227

1328
@property
1429
def valid_value_id(self) -> int:
30+
"""
31+
Returns the unique identifier for the address type.
32+
33+
Returns:
34+
int: The valid value ID.
35+
"""
1536
return self._valid_value_id
1637

1738
@property
1839
def allowed_value(self) -> str:
40+
"""
41+
Returns the string representation of the address type.
42+
43+
Returns:
44+
str: The allowed value.
45+
"""
1946
return self._allowed_value
2047

2148
@classmethod
2249
def by_valid_value_id(cls, address_type_id: int) -> Optional["AddressType"]:
50+
"""
51+
Returns the AddressType enum member matching the given valid value ID.
52+
53+
Args:
54+
address_type_id (int): The valid value ID to search for.
55+
56+
Returns:
57+
Optional[AddressType]: The matching enum member, or None if not found.
58+
"""
2359
return next(
2460
(item for item in cls if item.valid_value_id == address_type_id), None
2561
)

classes/appointment_status_type.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
class AppointmentStatusType:
22
"""
3-
Maps descriptive appointment statuses to internal IDs.
4-
Extend with real values as needed.
3+
Utility class for mapping descriptive appointment statuses to internal IDs.
4+
5+
This class provides a mapping between human-readable appointment status descriptions
6+
(such as "booked", "attended", "cancelled", "dna") and their corresponding internal
7+
integer IDs used in the system.
8+
9+
Methods:
10+
get_id(description: str) -> int:
11+
Returns the internal ID for a given appointment status description.
12+
Raises ValueError if the description is not recognized.
513
"""
614

715
_mapping = {
@@ -13,6 +21,18 @@ class AppointmentStatusType:
1321

1422
@classmethod
1523
def get_id(cls, description: str) -> int:
24+
"""
25+
Returns the internal ID for a given appointment status description.
26+
27+
Args:
28+
description (str): The appointment status description (e.g., "booked").
29+
30+
Returns:
31+
int: The internal ID corresponding to the description.
32+
33+
Raises:
34+
ValueError: If the description is not recognized.
35+
"""
1636
key = description.strip().lower()
1737
if key not in cls._mapping:
1838
raise ValueError(f"Unknown appointment status: {description}")

classes/appointments_slot_type.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
class AppointmentSlotType:
22
"""
3-
Maps symbolic appointment slot types to their internal IDs.
4-
Extend as needed.
3+
Utility class for mapping symbolic appointment slot types to their internal IDs.
4+
5+
This class provides a mapping between human-readable appointment slot type descriptions
6+
(such as "clinic", "phone", "video") and their corresponding internal integer IDs used in the system.
7+
8+
Methods:
9+
get_id(description: str) -> int:
10+
Returns the internal ID for a given appointment slot type description.
11+
Raises ValueError if the description is not recognized.
512
"""
613

714
_mapping = {
@@ -13,6 +20,18 @@ class AppointmentSlotType:
1320

1421
@classmethod
1522
def get_id(cls, description: str) -> int:
23+
"""
24+
Returns the internal ID for a given appointment slot type description.
25+
26+
Args:
27+
description (str): The appointment slot type description (e.g., "clinic").
28+
29+
Returns:
30+
int: The internal ID corresponding to the description.
31+
32+
Raises:
33+
ValueError: If the description is not recognized.
34+
"""
1635
key = description.strip().lower()
1736
if key not in cls._mapping:
1837
raise ValueError(f"Unknown appointment slot type: {description}")

classes/bowel_scope_dd_reason_for_change_type.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33

44

55
class BowelScopeDDReasonForChangeType(Enum):
6+
"""
7+
Enum representing reasons for change to Bowel Scope Due Date.
8+
9+
Attributes:
10+
Ceased: Ceased
11+
DateOfBirthAmendment: Date of birth amendment
12+
EligibleToBeInvitedForFsScreening: Eligible to be invited for FS Screening
13+
FsScreeningEpisodeOpened: FS Screening episode opened
14+
MultipleDateOfBirthChanges: Multiple Date of Birth Changes
15+
NoLongerEligibleToBeInvitedForFsScreening: No longer eligible to be invited for FS Screening
16+
ReopenedFsEpisode: Reopened FS Episode
17+
SeekingFurtherData: Seeking further data
18+
"""
19+
620
Ceased = (200669, "Ceased")
721
DateOfBirthAmendment = (205266, "Date of birth amendment")
822
EligibleToBeInvitedForFsScreening = (
@@ -19,33 +33,79 @@ class BowelScopeDDReasonForChangeType(Enum):
1933
SeekingFurtherData = (200670, "Seeking further data")
2034

2135
def __init__(self, valid_value_id: int, description: str):
36+
"""
37+
Initialize a BowelScopeDDReasonForChangeType enum member.
38+
39+
Args:
40+
valid_value_id (int): The unique identifier for the reason.
41+
description (str): The string description of the reason.
42+
"""
2243
self._valid_value_id: int = valid_value_id
2344
self._description: str = description
2445

2546
@property
2647
def valid_value_id(self) -> int:
48+
"""
49+
Returns the unique identifier for the reason.
50+
51+
Returns:
52+
int: The valid value ID.
53+
"""
2754
return self._valid_value_id
2855

2956
@property
3057
def description(self) -> str:
58+
"""
59+
Returns the string description of the reason.
60+
61+
Returns:
62+
str: The description.
63+
"""
3164
return self._description
3265

3366
@classmethod
3467
def _descriptions(cls) -> Dict[str, "BowelScopeDDReasonForChangeType"]:
68+
"""
69+
Returns a mapping from description to enum member.
70+
71+
Returns:
72+
Dict[str, BowelScopeDDReasonForChangeType]: Mapping from description to enum member.
73+
"""
3574
return {item.description: item for item in cls}
3675

3776
@classmethod
3877
def _lowercase_descriptions(cls) -> Dict[str, "BowelScopeDDReasonForChangeType"]:
78+
"""
79+
Returns a mapping from lowercase description to enum member.
80+
81+
Returns:
82+
Dict[str, BowelScopeDDReasonForChangeType]: Mapping from lowercase description to enum member.
83+
"""
3984
return {item.description.lower(): item for item in cls}
4085

4186
@classmethod
4287
def _valid_value_ids(cls) -> Dict[int, "BowelScopeDDReasonForChangeType"]:
88+
"""
89+
Returns a mapping from valid value ID to enum member.
90+
91+
Returns:
92+
Dict[int, BowelScopeDDReasonForChangeType]: Mapping from valid value ID to enum member.
93+
"""
4394
return {item.valid_value_id: item for item in cls}
4495

4596
@classmethod
4697
def by_description(
4798
cls, description: Optional[str]
4899
) -> Optional["BowelScopeDDReasonForChangeType"]:
100+
"""
101+
Returns the enum member matching the given description (case-insensitive).
102+
103+
Args:
104+
description (Optional[str]): The description to search for.
105+
106+
Returns:
107+
Optional[BowelScopeDDReasonForChangeType]: The matching enum member, or None if not found.
108+
"""
49109
if description is None:
50110
return None
51111
return cls._lowercase_descriptions().get(description.lower())
@@ -54,4 +114,13 @@ def by_description(
54114
def by_valid_value_id(
55115
cls, valid_value_id: int
56116
) -> Optional["BowelScopeDDReasonForChangeType"]:
117+
"""
118+
Returns the enum member matching the given valid value ID.
119+
120+
Args:
121+
valid_value_id (int): The valid value ID to search for.
122+
123+
Returns:
124+
Optional[BowelScopeDDReasonForChangeType]: The matching enum member, or None if not found.
125+
"""
57126
return cls._valid_value_ids().get(valid_value_id)

classes/ceased_confirmation_details.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,38 @@
33

44

55
class CeasedConfirmationDetails(Enum):
6+
"""
7+
Enum representing ceased confirmation details for a subject.
8+
9+
Members:
10+
NULL: Represents a null ceased confirmation detail.
11+
NOT_NULL: Represents a non-null ceased confirmation detail.
12+
"""
13+
614
NULL = "null"
715
NOT_NULL = "not null"
816

917
@classmethod
1018
def by_description(cls, description: str) -> Optional["CeasedConfirmationDetails"]:
19+
"""
20+
Returns the enum member matching the given description.
21+
22+
Args:
23+
description (str): The description to search for.
24+
25+
Returns:
26+
Optional[CeasedConfirmationDetails]: The matching enum member, or None if not found.
27+
"""
1128
for item in cls:
1229
if item.value == description:
1330
return item
1431
return None
1532

1633
def get_description(self) -> str:
34+
"""
35+
Returns the string description of the ceased confirmation detail.
36+
37+
Returns:
38+
str: The description value.
39+
"""
1740
return self.value

classes/ceased_confirmation_user_id.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,42 @@
33

44

55
class CeasedConfirmationUserId(Enum):
6+
"""
7+
Enum representing possible user IDs for ceased confirmation actions.
8+
9+
Members:
10+
AUTOMATED_PROCESS_ID: Represents an automated process user ID.
11+
NULL: Represents a null user ID.
12+
NOT_NULL: Represents a non-null user ID.
13+
USER_ID: Represents a specific user's ID.
14+
"""
15+
616
AUTOMATED_PROCESS_ID = "automated process id"
717
NULL = "null"
818
NOT_NULL = "not null"
919
USER_ID = "user's id"
1020

1121
@classmethod
1222
def by_description(cls, description: str) -> Optional["CeasedConfirmationUserId"]:
23+
"""
24+
Returns the enum member matching the given description.
25+
26+
Args:
27+
description (str): The description to search for.
28+
29+
Returns:
30+
Optional[CeasedConfirmationUserId]: The matching enum member, or None if not found.
31+
"""
1332
for item in cls:
1433
if item.value == description:
1534
return item
1635
return None
1736

1837
def get_description(self) -> str:
38+
"""
39+
Returns the string description of the ceased confirmation user ID.
40+
41+
Returns:
42+
str: The description value.
43+
"""
1944
return self.value

0 commit comments

Comments
 (0)