Skip to content

Commit 64bc6e0

Browse files
committed
Surveillance scenario 1
1 parent bf5d2d8 commit 64bc6e0

File tree

4 files changed

+79
-62
lines changed

4 files changed

+79
-62
lines changed

pages/screening_practitioner_appointments/appointment_detail_page.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self, page: Page):
2020
self.reason_for_cancellation_dropdown = self.page.get_by_label(
2121
"Reason for Cancellation"
2222
)
23+
self.reschedule_radio_button = self.page.get_by_label("Reschedule")
2324

2425
def check_attendance_radio(self) -> None:
2526
"""Checks the attendance radio button."""
@@ -29,6 +30,10 @@ def check_attended_check_box(self) -> None:
2930
"""Checks the attended check box."""
3031
self.attended_check_box.check()
3132

33+
def click_reschedule_radio(self) -> None:
34+
"""Clicks the reschedule radio button"""
35+
self.click(self.reschedule_radio_button)
36+
3237
def click_calendar_button(self) -> None:
3338
"""Clicks the calendar button."""
3439
self.click(self.calendar_button)

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def click_close_button(self) -> None:
341341

342342
def click_view_events_link(self) -> None:
343343
"""Click on the 'View Events' link."""
344-
self.click(self.view_events_link)
344+
self.click(self.view_events_link.first)
345345

346346
def assert_view_letter_links_for_event(
347347
self, event_name: str, expected_count: int

tests/regression/regression_tests/surveillance_regression_tests/test_surveillance_scenario_1.py

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@
3535
AppointmentAttendance,
3636
book_post_investigation_appointment,
3737
)
38+
from utils.calendar_picker import CalendarPicker
3839
from utils.generate_health_check_forms_util import GenerateHealthCheckFormsUtil
3940
from utils.sspi_change_steps import SSPIChangeSteps
4041
from utils.user_tools import UserTools
4142
from utils.subject_assertion import subject_assertion
4243
import logging
4344
from utils.batch_processing import batch_processing
4445
from pages.logout.log_out_page import LogoutPage
45-
from datetime import datetime
46+
from datetime import datetime, timedelta
4647
from classes.repositories.subject_repository import SubjectRepository
4748
from utils.oracle.oracle_specific_functions.organisation_parameters import (
4849
set_org_parameter_value,
@@ -92,58 +93,59 @@ def test_scenario_1(page: Page, general_properties: dict) -> None:
9293
> Process X382 letter batch > X79 > C203 (3.4)
9394
> Check recall [SSCL25a]
9495
95-
#"""
96+
"""
9697
# Given I log in to BCSS "England" as user role "Screening Centre Manager at BCS001"
9798
user_role = UserTools.user_login(
9899
page, "Screening Centre Manager at BCS001", return_role_type=True
99100
)
100-
# if user_role is None:
101-
# raise ValueError("User cannot be assigned to a UserRoleType")
102-
103-
# # When I run surveillance invitations for 1 subject
104-
105-
# nhs_no = GenerateHealthCheckFormsUtil(page).invite_surveillance_subjects_early(general_properties["eng_screening_centre_id"])
106-
# # Then my subject has been updated as follows:
107-
108-
# criteria = {
109-
# "latest episode status": "Open",
110-
# "latest episode type": "Surveillance",
111-
# "latest event status": "X500 Selected For Surveillance",
112-
# "responsible screening centre code": "User's screening centre",
113-
# "subject has unprocessed sspi updates": "No",
114-
# "subject has user dob updates": "No",
115-
# }
116-
117-
# subject_assertion(nhs_no, criteria,user_role)
118-
# # And there is a "X500" letter batch for my subject with the exact title "Surveillance Selection"
119-
# SubjectRepository().there_is_letter_batch_for_subject(
120-
# nhs_no, "X500", "Surveillance Selection"
121-
# )
122-
# # Then Comment: NHS number logging.info(f"Surveillance Scenario NHS Number: {nhs_number}")
101+
if user_role is None:
102+
raise ValueError("User cannot be assigned to a UserRoleType")
103+
104+
# When I run surveillance invitations for 1 subject
105+
106+
nhs_no = GenerateHealthCheckFormsUtil(page).invite_surveillance_subjects_early(
107+
general_properties["eng_screening_centre_id"]
108+
)
109+
# Then my subject has been updated as follows:
110+
111+
criteria = {
112+
"latest episode status": "Open",
113+
"latest episode type": "Surveillance",
114+
"latest event status": "X500 Selected For Surveillance",
115+
"responsible screening centre code": "User's screening centre",
116+
"subject has unprocessed sspi updates": "No",
117+
"subject has user dob updates": "No",
118+
}
119+
120+
subject_assertion(nhs_no, criteria, user_role)
121+
# And there is a "X500" letter batch for my subject with the exact title "Surveillance Selection"
122+
SubjectRepository().there_is_letter_batch_for_subject(
123+
nhs_no, "X500", "Surveillance Selection"
124+
)
125+
# Then Comment: NHS number logging.info(f"Surveillance Scenario NHS Number: {nhs_number}")
123126
# When I set the value of parameter 82 to "Y" for my organisation with immediate effect
124-
# org_id = general_properties["eng_screening_centre_id"]
125-
# set_org_parameter_value(82, "Y", org_id)
126-
# # When I receive an SSPI update to change their date of birth to "72" years old
127-
# SSPIChangeSteps().sspi_update_to_change_dob_received(nhs_no, 72)
128-
# # Then my subject has been updated as follows:
129-
# subject_assertion(nhs_no, {"subject age": "72"})
130-
# # When I process the open "X500" letter batch for my subject
131-
# batch_processing(
132-
# page,
133-
# batch_type="X500",
134-
# batch_description="Surveillance Selection",
135-
# )
136-
# # Then my subject has been updated as follows:
137-
# subject_assertion(
138-
# nhs_no,
139-
# {
140-
# "latest event status": "X505 HealthCheck Form Printed",
141-
# },
142-
# )
143-
# UserTools.user_login(
144-
# page, "Screening Centre Manager at BCS001", return_role_type=True
145-
# )
146-
nhs_no = "9712072282"
127+
org_id = general_properties["eng_screening_centre_id"]
128+
set_org_parameter_value(82, "Y", org_id)
129+
# When I receive an SSPI update to change their date of birth to "72" years old
130+
SSPIChangeSteps().sspi_update_to_change_dob_received(nhs_no, 72)
131+
# Then my subject has been updated as follows:
132+
subject_assertion(nhs_no, {"subject age": "72"})
133+
# When I process the open "X500" letter batch for my subject
134+
batch_processing(
135+
page,
136+
batch_type="X500",
137+
batch_description="Surveillance Selection",
138+
)
139+
# Then my subject has been updated as follows:
140+
subject_assertion(
141+
nhs_no,
142+
{
143+
"latest event status": "X505 HealthCheck Form Printed",
144+
},
145+
)
146+
UserTools.user_login(
147+
page, "Screening Centre Manager at BCS001", return_role_type=True
148+
)
147149
# When I view the subject
148150
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
149151
# And I select the advance episode option for "Record Contact with Patient"
@@ -217,12 +219,7 @@ def test_scenario_1(page: Page, general_properties: dict) -> None:
217219
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
218220

219221
# And I view the event history for the subject's latest episode
220-
SubjectScreeningSummaryPage(page).expand_episodes_list()
221-
SubjectScreeningSummaryPage(page).click_first_surveillance_epsiode_link()
222-
223222
# And I view the latest practitioner appointment in the subject's episode
224-
EpisodeEventsAndNotesPage(page).click_most_recent_view_appointment_link()
225-
226223
# And the subject DNAs the practitioner appointment
227224
AppointmentAttendance(page).mark_as_dna("Patient did not attend")
228225

@@ -326,7 +323,9 @@ def test_scenario_1(page: Page, general_properties: dict) -> None:
326323
# Then I "cannot" postpone the subject's surveillance episode
327324
SubjectScreeningSummaryPage(page).can_postpone_surveillance_episode(False)
328325
# When I process the open "X390" letter batch for my subject
329-
batch_processing(page, "X390", "Discharge from Surveillance - Clinical Decision")
326+
batch_processing(
327+
page, "X390", "Discharge from surveillance - Clinical (letter to GP)"
328+
)
330329

331330
# Then my subject has been updated as follows:
332331
criteria = {
@@ -416,9 +415,15 @@ def test_scenario_1(page: Page, general_properties: dict) -> None:
416415
# And I choose to book a practitioner clinic for my subject
417416
SubjectScreeningSummaryPage(page=page).click_book_practitioner_clinic_button()
418417

419-
# And I set the practitioner appointment date to "tomorrow"--recheck this, we dont have anything for tomorrow
418+
# And I set the practitioner appointment date to "tomorrow"
420419
# And I book the earliest available post investigation appointment on this date
421-
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)")
420+
421+
tomorrow = datetime.today() + timedelta(days=1)
422+
book_post_investigation_appointment(
423+
page,
424+
"The Royal Hospital (Wolverhampton)",
425+
appointment_date=tomorrow,
426+
)
422427

423428
# Then my subject has been updated as follows:
424429
subject_assertion(
@@ -441,7 +446,11 @@ def test_scenario_1(page: Page, general_properties: dict) -> None:
441446
EpisodeEventsAndNotesPage(page).click_most_recent_view_appointment_link()
442447

443448
# And the Screening Centre reschedules the surveillance practitioner appointment to "today"-recheck this
444-
AppointmentDetailPage(page).mark_appointment_as_attended(datetime.today())
449+
AppointmentDetailPage(page).click_reschedule_radio()
450+
AppointmentDetailPage(page).click_calendar_button()
451+
CalendarPicker(page).v2_calendar_picker(datetime.today())
452+
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)")
453+
445454
# Then my subject has been updated as follows:
446455
subject_assertion(
447456
nhs_no,

utils/appointments.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from typing import Optional
23
from playwright.sync_api import Page
34
from pages.base_page import BasePage
45
from pages.logout.log_out_page import LogoutPage
@@ -133,19 +134,21 @@ def book_appointments(page: Page, screening_centre: str, site: str) -> None:
133134

134135

135136
def book_post_investigation_appointment(
136-
page: Page,
137-
site: str,
137+
page: Page, site: str, appointment_date: Optional[datetime] = None
138138
) -> None:
139139
"""
140140
Book a post-investigation appointment for a subject.
141-
Sets the appointment date to today and the start time to '08:00'.
141+
If appointment_date is not provided, sets the appointment date to today and the start time to '08:00'.
142142
If a dialog about overlapping appointments is triggered, increases the start time by 15 minutes and retries.
143143
If all times for a practitioner are exhausted, tries the next practitioner.
144144
Loops until a successful booking or all practitioners are exhausted.
145145
Args:
146146
page (Page): The Playwright page object.
147147
site (str): The name of the site.
148+
appointment_date (datetime, optional): The appointment date. Defaults to today.
148149
"""
150+
if appointment_date is None:
151+
appointment_date = datetime.today()
149152
book_appointments_page = BookAppointmentPage(page)
150153
book_appointments_page.select_site_dropdown_option(
151154
[
@@ -166,7 +169,7 @@ def book_post_investigation_appointment(
166169
book_appointments_page.select_screening_practitioner_dropdown_option(
167170
screening_practitioner_index
168171
)
169-
book_appointments_page.enter_appointment_date(datetime.today())
172+
book_appointments_page.enter_appointment_date(appointment_date)
170173

171174
hour, minute = map(int, appointment_start_time.split(":"))
172175

0 commit comments

Comments
 (0)