Skip to content

Commit b2c0cde

Browse files
Addressing PR comments
1 parent f37dff5 commit b2c0cde

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

classes/pi_subject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def from_subject(subject: "Subject") -> "PISubject":
8787
if gender is not None:
8888
gender_code = gender.redefined_value
8989
else:
90-
gender_code = 0 # If None setting to "Not known gender"
90+
gender_code = 0 # If None, set to "Not known gender"
9191
return PISubject(
9292
screening_subject_id=subject.screening_subject_id,
9393
nhs_number=subject.nhs_number,

classes/subject.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,13 @@ def from_dataframe_row(row: pd.Series) -> "Subject":
13071307
return Subject(**field_map)
13081308

13091309
def populate_subject_object_from_nhs_no(self, nhs_no: str) -> "Subject":
1310+
"""
1311+
Populates a Subject object from the NHS number.
1312+
Args:
1313+
nhs_no (str): The NHS number to populate the subject from.
1314+
Returns:
1315+
Subject: A populated Subject object from the database
1316+
"""
13101317
from utils.oracle.subject_selection_query_builder import (
13111318
SubjectSelectionQueryBuilder,
13121319
)

pages/screening_practitioner_appointments/appointment_detail_page.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def select_reason_for_cancellation_option(self, option: str) -> None:
8282
Selects the reason for cancellation from the dropdown.
8383
Args:
8484
option: The reason for cancellation to select.
85+
The options are in the ReasonForCancellationOptions class
8586
"""
8687
self.reason_for_cancellation_dropwdown.select_option(value=option)
8788

utils/appointments.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,35 @@ def book_appointments(page: Page, screening_centre: str, site: str) -> None:
8585
page (Page): The Playwright page object.
8686
screening_centre (str): The name of the screening centre.
8787
site (str): The name of the site.
88+
Raises:
89+
RuntimeError: If the appointment booking confirmation is not displayed.
8890
"""
89-
BookAppointmentPage(page).select_screening_centre_dropdown_option(screening_centre)
90-
BookAppointmentPage(page).select_site_dropdown_option(
91+
book_appointments_page = BookAppointmentPage(page)
92+
book_appointments_page.select_screening_centre_dropdown_option(screening_centre)
93+
book_appointments_page.select_site_dropdown_option(
9194
[
9295
f"{site} (? km)",
9396
f"{site} (? km) (attended)",
9497
]
9598
)
9699

97100
# And I book the "earliest" available practitioner appointment on this date
98-
current_month_displayed = BookAppointmentPage(page).get_current_month_displayed()
101+
current_month_displayed = book_appointments_page.get_current_month_displayed()
99102
CalendarPicker(page).book_first_eligible_appointment(
100103
current_month_displayed,
101-
BookAppointmentPage(page).appointment_cell_locators,
104+
book_appointments_page.appointment_cell_locators,
102105
[
103-
BookAppointmentPage(page).available_background_colour,
104-
BookAppointmentPage(page).some_available_background_colour,
106+
book_appointments_page.available_background_colour,
107+
book_appointments_page.some_available_background_colour,
105108
],
106109
)
107110
page.wait_for_timeout(500) # Wait for the appointments to load
108-
BookAppointmentPage(page).appointments_table.click_first_input_in_column(
111+
book_appointments_page.appointments_table.click_first_input_in_column(
109112
"Appt/Slot Time"
110113
)
111-
BasePage(page).safe_accept_dialog(BookAppointmentPage(page).save_button)
114+
BasePage(page).safe_accept_dialog(book_appointments_page.save_button)
112115
try:
113-
BookAppointmentPage(page).appointment_booked_confirmation_is_displayed(
116+
book_appointments_page.appointment_booked_confirmation_is_displayed(
114117
"Appointment booked"
115118
)
116119
logging.info("[BOOK APPOINTMENTS] Appointment successfully booked")

utils/date_time_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ def parse_datetime(
213213
@staticmethod
214214
def calculate_birth_date_for_age(age: int) -> date:
215215
"""
216-
Calculates the birth date for a given age.
216+
Calculates a birth date corresponding to a given age as of today's date.
217+
218+
This method subtracts the specified age from the current year to estimate the birth date.
219+
If the resulting date would fall on February 29 in a non-leap year, it adjusts to February 28
220+
to ensure a valid date.
217221
Args:
218222
age (int): The age to calculate the birth date for.
219223
Returns:

utils/sspi_change_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def sspi_update_to_change_dob_received(
3131

3232
logging.debug("exit: sspi_update_to_change_dob_received()")
3333

34-
def handle_update(self, subject, birth_date: Optional[date]) -> None:
34+
def handle_update(self, subject: Subject, birth_date: Optional[date]) -> None:
3535
"""
3636
Performs the SSPI update to make the changes in the database.
3737
Args:

0 commit comments

Comments
 (0)