Skip to content

Commit 698e404

Browse files
Completing SurveillanceRegressionTests scenario 3
1 parent e079c41 commit 698e404

File tree

2 files changed

+213
-0
lines changed

2 files changed

+213
-0
lines changed

pages/screening_subject_search/advance_surveillance_episode_page.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def __init__(self, page: Page):
2424
self.book_surveillance_appointment_button = self.page.get_by_role(
2525
"button", name="Book Surveillance Appointment"
2626
)
27+
self.discharge_from_surveillance_patient_choice_button = self.page.get_by_role(
28+
"button",
29+
name="Discharge from Surveillance - Patient Choice",
30+
)
2731

2832
def click_discharge_from_surveillance_clinical_decision_button(self) -> None:
2933
"""Click on the 'Discharge from Surveillance - Clinical Decision' button."""
@@ -41,3 +45,9 @@ def click_book_surveillance_appointment_button(self) -> None:
4145
"""Click on the 'Book Surveillance Appointment' button."""
4246
self.safe_accept_dialog(self.book_surveillance_appointment_button)
4347
self.page.wait_for_timeout(500) # Timeout to allow subject to update on the DB.
48+
49+
def click_discharge_from_surveillance_patient_choice_button(
50+
self,
51+
) -> None:
52+
"""Click on the 'Discharge from Surveillance - Patient Choice' button."""
53+
self.click(self.discharge_from_surveillance_patient_choice_button)
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
import pytest
2+
from playwright.sync_api import Page
3+
from utils.user_tools import UserTools
4+
from utils.subject_assertion import subject_assertion
5+
import logging
6+
from utils.batch_processing import batch_processing
7+
from pages.logout.log_out_page import LogoutPage
8+
from utils.generate_health_check_forms_util import GenerateHealthCheckFormsUtil
9+
from utils import screening_subject_page_searcher
10+
from pages.screening_subject_search.subject_screening_summary_page import (
11+
SubjectScreeningSummaryPage,
12+
)
13+
from pages.screening_subject_search.advance_surveillance_episode_page import (
14+
AdvanceSurveillanceEpisodePage,
15+
)
16+
from pages.screening_subject_search.contact_with_patient_page import (
17+
ContactWithPatientPage,
18+
)
19+
from pages.screening_subject_search.discharge_from_surveillance_page import (
20+
DischargeFromSurveillancePage,
21+
)
22+
from utils.sspi_change_steps import SSPIChangeSteps
23+
24+
25+
@pytest.mark.vpn_required
26+
@pytest.mark.regression
27+
@pytest.mark.surveillance_regression_tests
28+
def test_scenario_3(page: Page, general_properties: dict) -> None:
29+
"""
30+
Scenario: 3: Discharge for patient decision, no diagnostic test
31+
32+
X500-X505-X512-X392-X386-X376-C203 [SSCL26b]
33+
34+
This scenario takes an in-age surveillance subject from invitation through to almost immediate episode closure on Discharge for patient choice. The scenario also checks that postpone is not possible once the episode is already in a “discharge” pathway.
35+
36+
This can occur right at the start of the episode (as in this scenario) or following referral for a subsequent diagnostic test where no previous diagnostic tests have achieved a result (this is covered in scenario 4).
37+
38+
Because we cannot know if we will be inviting a subject who has had previous FOBT episodes, or only a bowel scope episode, it is impossible to check if they will be set to Call or Recall; we can only check that they are not longer in Surveillance status.
39+
40+
Scenario summary:
41+
42+
> Run surveillance invitations for 1 subject > X500 (3.1)
43+
> SSPI update changes subject to in-age at recall
44+
> Process X500 letter batch > X505 (3.1)
45+
> Record patient contact – contacted, discharge patient choice > X512 > X392 (3.1)
46+
> Process X392 letter batch > X386 (3.4)
47+
> Process X386 letter batch > X376 > C203 (3.4)
48+
> Check recall [SSCL26b]
49+
"""
50+
# Given I log in to BCSS "England" as user role "Screening Centre Manager"
51+
user_role = UserTools.user_login(
52+
page, "Screening Centre Manager at BCS001", return_role_type=True
53+
)
54+
if user_role is None:
55+
raise ValueError("User cannot be assigned to a UserRoleType")
56+
57+
# When I run surveillance invitations for 1 subject
58+
org_id = general_properties["eng_screening_centre_id"]
59+
nhs_no = GenerateHealthCheckFormsUtil(page).invite_surveillance_subjects_early(
60+
org_id
61+
)
62+
logging.info(f"[SUBJECT RETRIEVAL] Subject's NHS Number: {nhs_no}")
63+
64+
# Then my subject has been updated as follows:
65+
subject_assertion(
66+
nhs_no,
67+
{
68+
"latest episode status": "Open",
69+
"latest episode type": "Surveillance",
70+
"latest event status": "X500 Selected For Surveillance",
71+
"responsible screening centre code": "User's screening centre",
72+
"subject has unprocessed SSPI updates": "No",
73+
"subject has user DOB updates": "No",
74+
},
75+
user_role,
76+
)
77+
78+
# When I receive an SSPI update to change their date of birth to "65" years old
79+
SSPIChangeSteps().sspi_update_to_change_dob_received(nhs_no, 65)
80+
81+
# Then my subject has been updated as follows:
82+
subject_assertion(nhs_no, {"subject age": "65"})
83+
84+
# And there is a "X500" letter batch for my subject with the exact title "Surveillance Selection"
85+
# When I process the open "X500" letter batch for my subject
86+
batch_processing(
87+
page,
88+
"X500",
89+
"Surveillance Selection",
90+
)
91+
92+
# Then my subject has been updated as follows:
93+
subject_assertion(nhs_no, {"latest event status": "X505 HealthCheck Form Printed"})
94+
95+
# When I view the subject
96+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
97+
98+
# And I select the advance episode option for "Record Contact with Patient"
99+
SubjectScreeningSummaryPage(page).click_advance_surveillance_episode_button()
100+
AdvanceSurveillanceEpisodePage(page).click_record_contact_with_patient_button()
101+
102+
# And I record contact with the subject with outcome "Discharge from surveillance - patient choice"
103+
ContactWithPatientPage(page).record_contact(
104+
"Discharge from surveillance - patient choice"
105+
)
106+
107+
# Then my subject has been updated as follows:
108+
subject_assertion(
109+
nhs_no,
110+
{
111+
"latest event status": "X512 Patient Contact Resulted in Discharge from Surveillance"
112+
},
113+
)
114+
115+
# When I view the subject
116+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
117+
118+
# And I select the advance episode option for "Discharge from Surveillance - Patient Choice"
119+
SubjectScreeningSummaryPage(page).click_advance_surveillance_episode_button()
120+
AdvanceSurveillanceEpisodePage(
121+
page
122+
).click_discharge_from_surveillance_patient_choice_button()
123+
124+
# And I complete the Discharge from Surveillance form
125+
DischargeFromSurveillancePage(page).complete_discharge_from_surveillance_form(False)
126+
127+
# Then my subject has been updated as follows:
128+
subject_assertion(
129+
nhs_no,
130+
{"latest event status": "X392 Discharge from Surveillance - Patient Choice"},
131+
)
132+
133+
# When I view the subject
134+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
135+
136+
# Then I "cannot" postpone the subject's surveillance episode
137+
SubjectScreeningSummaryPage(page).can_postpone_surveillance_episode(False)
138+
139+
# And there is a "X392" letter batch for my subject with the exact title "Discharge from surveillance - patient decision (letter to patient)"
140+
# When I process the open "X392" letter batch for my subject
141+
batch_processing(
142+
page,
143+
"X392",
144+
"Discharge from surveillance - patient decision (letter to patient)",
145+
)
146+
147+
# Then my subject has been updated as follows:
148+
subject_assertion(
149+
nhs_no,
150+
{
151+
"latest event status": "X386 Discharged from Surveillance - Patient Letter Printed"
152+
},
153+
)
154+
155+
# When I view the subject
156+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
157+
158+
# Then I "cannot" postpone the subject's surveillance episode
159+
SubjectScreeningSummaryPage(page).can_postpone_surveillance_episode(False)
160+
161+
# And there is a "X386" letter batch for my subject with the exact title "Discharge from surveillance - patient decision (letter to GP)"
162+
# When I process the open "X386" letter batch for my subject
163+
batch_processing(
164+
page,
165+
"X386",
166+
"Discharge from surveillance - patient decision (letter to GP)",
167+
)
168+
169+
# Then my subject has been updated as follows:
170+
subject_assertion(
171+
nhs_no,
172+
{
173+
"calculated fobt due date": "2 years from episode end",
174+
"calculated lynch due date": "Null",
175+
"calculated surveillance due date": "Null",
176+
"ceased confirmation date": "Null",
177+
"ceased confirmation details": "Null",
178+
"ceased confirmation user id": "Null",
179+
"clinical reason for cease": "Null",
180+
"latest episode accumulated result": "(Any) Surveillance non-participation",
181+
"latest episode recall calculation method": "Episode end date",
182+
"latest episode recall episode type": "FOBT Screening",
183+
"latest episode recall surveillance type": "Null",
184+
"latest episode status": "Closed",
185+
"latest episode status reason": "Discharge from Surveillance - Patient Choice",
186+
"latest event status": "X376 Discharged from Surveillance - GP Letter Printed",
187+
"lynch due date": "Null",
188+
"lynch due date date of change": "Unchanged",
189+
"lynch due date reason": "Unchanged",
190+
"screening due date": "Calculated FOBT due date",
191+
"screening due date reason": "Discharge from Surveillance - Patient Choice",
192+
"screening due date date of change": "Today",
193+
"screening status": "NOT: Surveillance",
194+
"screening status date of change": "Today",
195+
"screening status reason": "Patient Choice",
196+
"surveillance due date": "Null",
197+
"surveillance due date date of change": "Today",
198+
"surveillance due date reason": "Discharge from Surveillance - Patient Choice",
199+
},
200+
user_role,
201+
)
202+
203+
LogoutPage(page).log_out()

0 commit comments

Comments
 (0)