Skip to content

Commit 26c16ca

Browse files
Feature/bcss 21168 repo improvements (#134)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This PR has the following changes: Moving he functions in oracle_specific_dunctions.py into more concise files in the oracle_specific_functions_folder - This has been documented in Oracle.md wit ha table showcasing where each function is Organising the classes into more specific sub folders. - This is all tracked on confluence: https://nhsd-confluence.digital.nhs.uk/spaces/BCS/pages/1176510399/BCSS+Playwright+Classes+Folder+Structure Converting classes into Enum classes / python dataclasses where relevant Standardizing the capitalization of the criteria values ## Context <!-- Why is this change required? What problem does it solve? --> This was done to make the repository easier to navigate and use. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent cd518a5 commit 26c16ca

File tree

175 files changed

+3162
-2701
lines changed

Some content is hidden

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

175 files changed

+3162
-2701
lines changed

.gitleaksignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,4 @@ cae84544e2852202f5d0abb9ad18f9d83a0c6d80:subject_criteria_builder/criteria.json:
226226
60468a7d6f3ff3259616757be85d6f07e62d00b6:subject_criteria_builder/criteria.json:generic-api-key:4210
227227
145171b9e9d169acb136fc527708c997c9ad9f61:subject_criteria_builder/criteria.json:generic-api-key:4210
228228
2ccb5e91033934d4818c1efa2eb1696b5511ebc9:subject_criteria_builder/criteria.json:generic-api-key:4210
229+
145171b9e9d169acb136fc527708c997c9ad9f61:subject_criteria_builder/criteria.json:generic-api-key:4210

classes/address.py

Lines changed: 0 additions & 135 deletions
This file was deleted.

classes/address/address.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from dataclasses import dataclass
2+
3+
4+
@dataclass
5+
class Address:
6+
"""
7+
Represents a postal address with up to five address lines and a postcode.
8+
Provides methods to format the address as a string.
9+
"""
10+
11+
address_line1: str = ""
12+
address_line2: str = ""
13+
address_line3: str = ""
14+
address_line4: str = ""
15+
address_line5: str = ""
16+
post_code: str = ""
17+
18+
def set_address_line(self, line_number: int, address_line: str) -> None:
19+
"""
20+
Sets the specified address line (1-5) to the given value.
21+
22+
Args:
23+
line_number (int): The address line number (1-5).
24+
address_line (str): The value to set for the address line.
25+
26+
Raises:
27+
ValueError: If line_number is not between 1 and 5.
28+
"""
29+
if not 1 <= line_number <= 5:
30+
raise ValueError(
31+
f"Invalid line number {line_number}, must be between 1 and 5"
32+
)
33+
34+
setattr(self, f"address_line{line_number}", address_line)
35+
36+
def __str__(self) -> str:
37+
"""
38+
Returns the formatted address as a single string.
39+
"""
40+
address_parts = [
41+
self.address_line1,
42+
self.address_line2,
43+
self.address_line3,
44+
self.address_line4,
45+
self.address_line5,
46+
self.post_code,
47+
]
48+
return ", ".join([part for part in address_parts if part])
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from enum import Enum
2+
from typing import Optional
3+
4+
5+
class AppointmentSlotType(Enum):
6+
"""
7+
Enum representing appointment slot types, mapped to valid value IDs and descriptions.
8+
Provides utility methods for lookup by description (case-sensitive and insensitive) and by valid value ID.
9+
"""
10+
11+
COLONOSCOPY_ASSESSMENT = (209028, "Colonoscopy Assessment")
12+
BOWEL_SCOPE_AUTOMATIC = (200526, "FS Automatic")
13+
BOWEL_SCOPE_MANUAL = (200527, "FS Manual")
14+
POSITIVE_ASSESSMENT = (6016, "Positive Assessment")
15+
POST_INVESTIGATION = (6017, "Post-Investigation")
16+
SURVEILLANCE = (20061, "Surveillance")
17+
18+
def __init__(self, valid_value_id: int, description: str) -> None:
19+
self._valid_value_id = valid_value_id
20+
self._description = description
21+
22+
@property
23+
def valid_value_id(self) -> int:
24+
"""
25+
Returns the valid value ID for the appointment slot type.
26+
"""
27+
return self._valid_value_id
28+
29+
@property
30+
def description(self) -> str:
31+
"""
32+
Returns the description for the appointment slot type.
33+
"""
34+
return self._description
35+
36+
@classmethod
37+
def by_description(cls, description: str) -> Optional["AppointmentSlotType"]:
38+
"""
39+
Returns the enum member matching the given description (case-sensitive).
40+
"""
41+
for member in cls:
42+
if member.description == description:
43+
return member
44+
return None
45+
46+
@classmethod
47+
def by_description_case_insensitive(
48+
cls, description: str
49+
) -> Optional["AppointmentSlotType"]:
50+
"""
51+
Returns the enum member matching the given description (case-insensitive).
52+
"""
53+
desc_lower = description.lower()
54+
for member in cls:
55+
if member.description.lower() == desc_lower:
56+
return member
57+
return None
58+
59+
@classmethod
60+
def by_valid_value_id(cls, valid_value_id: int) -> Optional["AppointmentSlotType"]:
61+
"""
62+
Returns the enum member matching the given valid value ID.
63+
"""
64+
for member in cls:
65+
if member.valid_value_id == valid_value_id:
66+
return member
67+
return None
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from enum import Enum
2+
from typing import Optional
3+
4+
5+
class AppointmentStatusType(Enum):
6+
"""
7+
Enum representing appointment status types, mapped to valid value IDs and descriptions.
8+
"""
9+
10+
ATTENDED = (6121, "Attended")
11+
BOOKED = (6120, "Booked")
12+
CANCELLED = (6122, "Cancelled")
13+
DID_NOT_ATTEND = (6123, "Did Not Attend")
14+
15+
def __init__(self, valid_value_id: int, description: str) -> None:
16+
self._valid_value_id = valid_value_id
17+
self._description = description
18+
19+
@property
20+
def valid_value_id(self) -> int:
21+
"""
22+
Returns the valid value ID for the appointment status type.
23+
"""
24+
return self._valid_value_id
25+
26+
@property
27+
def description(self) -> str:
28+
"""
29+
Returns the description for the appointment status type.
30+
"""
31+
return self._description
32+
33+
@classmethod
34+
def by_description(cls, description: str) -> Optional["AppointmentStatusType"]:
35+
"""
36+
Returns the enum member matching the given description (case-sensitive).
37+
"""
38+
for member in cls:
39+
if member.description == description:
40+
return member
41+
return None
42+
43+
@classmethod
44+
def by_description_case_insensitive(
45+
cls, description: str
46+
) -> Optional["AppointmentStatusType"]:
47+
"""
48+
Returns the enum member matching the given description (case-insensitive).
49+
"""
50+
desc_lower = description.lower()
51+
for member in cls:
52+
if member.description.lower() == desc_lower:
53+
return member
54+
return None
55+
56+
@classmethod
57+
def by_valid_value_id(
58+
cls, valid_value_id: int
59+
) -> Optional["AppointmentStatusType"]:
60+
"""
61+
Returns the enum member matching the given valid value ID.
62+
"""
63+
for member in cls:
64+
if member.valid_value_id == valid_value_id:
65+
return member
66+
return None

classes/appointment_status_type.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)