Skip to content

Commit 64de86f

Browse files
authored
Merge branch 'main' into feature/BCSS-22631-lynchregressiontests-scenario-4.1
2 parents 961ba39 + 83c7f70 commit 64de86f

File tree

4 files changed

+1769
-0
lines changed

4 files changed

+1769
-0
lines changed
Lines changed: 362 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,362 @@
1+
import logging
2+
import pytest
3+
from playwright.sync_api import Page
4+
from classes.repositories.general_repository import GeneralRepository
5+
from pages.base_page import BasePage
6+
from pages.logout.log_out_page import LogoutPage
7+
from pages.screening_subject_search.subject_screening_summary_page import (
8+
SubjectScreeningSummaryPage,
9+
)
10+
from utils import screening_subject_page_searcher
11+
from utils.appointments import AppointmentAttendance, book_appointments
12+
from utils.batch_processing import batch_processing
13+
from utils.lynch_utils import LynchUtils
14+
from utils.oracle.oracle import OracleDB
15+
from utils.subject_assertion import subject_assertion
16+
from utils.user_tools import UserTools
17+
18+
19+
@pytest.mark.usefixtures("setup_org_and_appointments")
20+
@pytest.mark.vpn_required
21+
@pytest.mark.regression
22+
@pytest.mark.lynch_regression_tests
23+
def test_lynch_scenario_3_1(page: Page) -> None:
24+
"""
25+
Scenario: 3.1 - DNA colonoscopy assessment twice - self referral
26+
27+
G4-G2-G3-A183-A25-J11-J27-A184-A26-A185-A37-A166-C203 over age range [SSCL5b(A166)]
28+
29+
This scenario tests where the patient is discharged from their Lynch episode because they DNA their colonoscopy assessment appointment twice.
30+
31+
Subject summary:
32+
33+
> Process Lynch diagnosis for a new over-age subject suitable for immediate self-referral
34+
> Run Lynch invitations > G4 (5.1)
35+
> Process G4 letter batch > G2 (5.1)
36+
> Run timed events > G3 (5.1)
37+
> Book appointment > A183 (1.11)
38+
> Process A183 letter batch > A25 (1.11)
39+
> Subject DNA > J11 (1.11)
40+
> Process J11 letter batch > J27 (1.11)
41+
> Book appointment > A184 (1.11)
42+
> Process A184 letter batch > A26 (1.11)
43+
> Subject DNA > A185 (1.11)
44+
> Process A185 letter batch > A37 (1.11)
45+
> Process A37 letter batch > A166 (1.11)
46+
> Check recall [SSCL5b(A166)]
47+
"""
48+
# Given I log in to BCSS "England" as user role "Hub Manager"
49+
user_role = UserTools.user_login(
50+
page, "Hub Manager State Registered at BCS01", return_role_type=True
51+
)
52+
if user_role is None:
53+
raise ValueError("User cannot be assigned to a UserRoleType")
54+
55+
# When I receive Lynch diagnosis "EPCAM" for a new subject in my hub aged "75" with diagnosis date "3 years ago" and last colonoscopy date "2 years ago"
56+
nhs_no = LynchUtils(page).insert_validated_lynch_patient_from_new_subject_with_age(
57+
age="75",
58+
gene="EPCAM",
59+
when_diagnosis_took_place="3 years ago",
60+
when_last_colonoscopy_took_place="2 years ago",
61+
user_role=user_role,
62+
)
63+
64+
# Then Comment: NHS number
65+
assert nhs_no is not None
66+
logging.info(f"[SUBJECT CREATION] Created Lynch subject with NHS number: {nhs_no}")
67+
68+
# When I self refer the subject
69+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
70+
SubjectScreeningSummaryPage(page).click_self_refer_button()
71+
72+
# Then my subject has been updated as follows:
73+
subject_assertion(
74+
nhs_no,
75+
{
76+
"Calculated FOBT due date": "Null",
77+
"Calculated lynch due date": "Today",
78+
"Calculated surveillance due date": "Null",
79+
"Lynch due date": "Today",
80+
"Lynch due date date of change": "Null",
81+
"Lynch due date reason": "Self-referral",
82+
"Previous screening status": "Lynch Surveillance",
83+
"Screening due date": "Null",
84+
"Screening due date date of change": "Null",
85+
"Screening due date reason": "Null",
86+
"Subject has lynch diagnosis": "Yes",
87+
"Subject lower FOBT age": "Default",
88+
"Subject lower lynch age": "25",
89+
"Screening status": "Lynch Self-referral",
90+
"Screening status date of change": "Today",
91+
"Screening status reason": "Self-referral",
92+
"Subject age": "75",
93+
"Surveillance due date": "Null",
94+
"Surveillance due date date of change": "Null",
95+
"Surveillance due date reason": "Null",
96+
},
97+
)
98+
99+
# When I set the Lynch invitation rate for all screening centres to 50
100+
LynchUtils(page).set_lynch_invitation_rate(rate=50)
101+
102+
# And I run the Lynch invitations process
103+
GeneralRepository().run_lynch_invitations()
104+
105+
# And my subject has been updated as follows:
106+
subject_assertion(
107+
nhs_no,
108+
{
109+
"latest episode type": "Lynch Surveillance",
110+
"latest episode sub-type": "Over Age",
111+
"latest event status": "G4 Selected for Lynch Surveillance (Self-referral)",
112+
"calculated fobt due date": "Null",
113+
"calculated lynch due date": "Today",
114+
"calculated surveillance due date": "Null",
115+
"lynch due date": "Today",
116+
"lynch due date date of change": "Null",
117+
"lynch due date reason": "Self-referral",
118+
"previous screening status": "Lynch Surveillance",
119+
"screening due date": "Null",
120+
"screening due date date of change": "Null",
121+
"screening due date reason": "Null",
122+
"subject has lynch diagnosis": "Yes",
123+
"subject lower fobt age": "Default",
124+
"subject lower lynch age": "25",
125+
"screening status": "Lynch Self-referral",
126+
"screening status date of change": "Today",
127+
"screening status reason": "Self-referral",
128+
"subject age": "75",
129+
"surveillance due date": "Null",
130+
"surveillance due date date of change": "Null",
131+
"surveillance due date reason": "Null",
132+
},
133+
)
134+
135+
# And there is a "G4" letter batch for my subject with the exact title "Lynch Surveillance Invitation (Self-referral)"
136+
# When I process the open "G4" letter batch for my subject
137+
batch_processing(
138+
page,
139+
"G4",
140+
"Lynch Surveillance Invitation (Self-referral)",
141+
)
142+
143+
# Then my subject has been updated as follows:
144+
subject_assertion(nhs_no, {"latest event status": "G2 Lynch Pre-invitation Sent"})
145+
146+
# When I run Timed Events for my subject
147+
OracleDB().exec_bcss_timed_events(nhs_number=nhs_no)
148+
149+
# Then my subject has been updated as follows:
150+
subject_assertion(
151+
nhs_no,
152+
{
153+
"latest event status": "G3 Lynch Surveillance Colonoscopy Assessment Appointment Required"
154+
},
155+
)
156+
157+
logging.info("Progress the episode through the required pathway")
158+
159+
# When I view the subject
160+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
161+
162+
# And I view the practitioner appointment booking screen
163+
SubjectScreeningSummaryPage(page).click_book_practitioner_clinic_button()
164+
165+
# And I select "BCS001" as the screening centre where the practitioner appointment will be held
166+
# And I set the practitioner appointment date to "today"
167+
# And I book the "earliest" available practitioner appointment on this date
168+
book_appointments(
169+
page,
170+
"BCS001 - Wolverhampton Bowel Cancer Screening Centre",
171+
"The Royal Hospital (Wolverhampton)",
172+
)
173+
174+
# Then my subject has been updated as follows:
175+
subject_assertion(
176+
nhs_no,
177+
{
178+
"latest event status": "A183 1st Colonoscopy Assessment Appointment Requested",
179+
},
180+
)
181+
182+
# And there is a "A183" letter batch for my subject with the exact title "Practitioner Clinic 1st Appointment (Lynch)"
183+
# When I process the open "A183" letter batch for my subject
184+
batch_processing(page, "A183", "Practitioner Clinic 1st Appointment (Lynch)")
185+
186+
# Then my subject has been updated as follows:
187+
subject_assertion(
188+
nhs_no,
189+
{
190+
"latest event status": "A25 1st Colonoscopy Assessment Appointment Booked, letter sent",
191+
},
192+
)
193+
194+
# When I switch users to BCSS "England" as user role "Screening Centre Manager"
195+
LogoutPage(page).log_out(close_page=False)
196+
BasePage(page).go_to_log_in_page()
197+
user_role = UserTools.user_login(page, "Screening Centre Manager at BCS001", True)
198+
if user_role is None:
199+
raise ValueError("User cannot be assigned to a UserRoleType")
200+
201+
# And I view the subject
202+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
203+
204+
# And I view the event history for the subject's latest episode
205+
# And I view the latest practitioner appointment in the subject's episode
206+
# And The subject DNAs the practitioner appointment
207+
AppointmentAttendance(page).mark_as_dna("Patient did not attend")
208+
209+
# Then my subject has been updated as follows:
210+
subject_assertion(
211+
nhs_no,
212+
{
213+
"latest event status": "J11 1st Colonoscopy Assessment Appointment Non-attendance (Patient)",
214+
},
215+
)
216+
217+
# And there is a "J11" letter batch for my subject with the exact title "Practitioner Clinic 1st Appointment Non Attendance (Patient) (Lynch)"
218+
# When I process the open "J11" letter batch for my subject
219+
batch_processing(
220+
page,
221+
"J11",
222+
"Practitioner Clinic 1st Appointment Non Attendance (Patient) (Lynch)",
223+
)
224+
225+
# Then my subject has been updated as follows:
226+
subject_assertion(
227+
nhs_no,
228+
{
229+
"latest event status": "J27 Appointment Non-attendance Letter Sent (Patient)",
230+
},
231+
)
232+
233+
# When I view the subject
234+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
235+
236+
# And I view the practitioner appointment booking screen
237+
SubjectScreeningSummaryPage(page).click_book_practitioner_clinic_button()
238+
239+
# And I select "BCS001" as the screening centre where the practitioner appointment will be held
240+
# And I set the practitioner appointment date to "today"
241+
# And I book the "earliest" available practitioner appointment on this date
242+
book_appointments(
243+
page,
244+
"BCS001 - Wolverhampton Bowel Cancer Screening Centre",
245+
"The Royal Hospital (Wolverhampton)",
246+
)
247+
248+
# Then my subject has been updated as follows:
249+
subject_assertion(
250+
nhs_no,
251+
{
252+
"latest event status": "A184 2nd Colonoscopy Assessment Appointment Requested",
253+
},
254+
)
255+
256+
# And there is a "A184" letter batch for my subject with the exact title "Practitioner Clinic 2nd Appointment (Lynch)"
257+
# When I process the open "A184" letter batch for my subject
258+
batch_processing(page, "A184", "Practitioner Clinic 2nd Appointment (Lynch)")
259+
260+
# Then my subject has been updated as follows:
261+
subject_assertion(
262+
nhs_no,
263+
{
264+
"latest event status": "A26 2nd Colonoscopy Assessment Appointment Booked, letter sent",
265+
},
266+
)
267+
268+
# And I view the subject
269+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
270+
271+
# And I view the event history for the subject's latest episode
272+
# And I view the latest practitioner appointment in the subject's episode
273+
# And The subject DNAs the practitioner appointment
274+
AppointmentAttendance(page).mark_as_dna("Patient did not attend")
275+
276+
# Then my subject has been updated as follows:
277+
subject_assertion(
278+
nhs_no,
279+
{
280+
"latest event status": "A185 2nd Colonoscopy Assessment Appointment Non-attendance (Patient)",
281+
},
282+
)
283+
284+
# And there is a "A185" letter batch for my subject with the exact title "Patient Discharge (Non Attendance of Practitioner Clinic) (Lynch)"
285+
# When I process the open "A185" letter batch for my subject
286+
batch_processing(
287+
page,
288+
"A185",
289+
"Patient Discharge (Non Attendance of Practitioner Clinic) (Lynch)",
290+
)
291+
292+
# Then my subject has been updated as follows:
293+
subject_assertion(
294+
nhs_no,
295+
{
296+
"latest event status": "A37 Patient Discharge Sent (Non-attendance at Colonoscopy Assessment Appointment)",
297+
},
298+
)
299+
300+
# When I switch users to BCSS "England" as user role "Hub Manager"
301+
LogoutPage(page).log_out(close_page=False)
302+
BasePage(page).go_to_log_in_page()
303+
user_role = UserTools.user_login(
304+
page, "Hub Manager State Registered at BCS01", True
305+
)
306+
if user_role is None:
307+
raise ValueError("User cannot be assigned to a UserRoleType")
308+
309+
# And there is a "A37" letter batch for my subject with the exact title "GP Discharge (Non Attendance of Practitioner Clinic) (Lynch)"
310+
# When I process the open "A37" letter batch for my subject
311+
batch_processing(
312+
page,
313+
"A37",
314+
"GP Discharge (Non Attendance of Practitioner Clinic) (Lynch)",
315+
)
316+
317+
logging.info("Check subject details against closure scenario SSCL5b(A166)")
318+
319+
# Then my subject has been updated as follows:
320+
subject_assertion(
321+
nhs_no,
322+
{
323+
"Calculated FOBT due date": "Null",
324+
"Calculated lynch due date": "2 years from latest A37 event",
325+
"Calculated surveillance due date": "Null",
326+
"Ceased confirmation date": "Today",
327+
"Ceased confirmation details": "Outside screening population at recall.",
328+
"Ceased confirmation user ID": "User's ID",
329+
"Clinical reason for cease": "Null",
330+
"Latest episode accumulated result": "Lynch non-participation",
331+
"Latest episode recall calculation method": "Date of last patient letter",
332+
"Latest episode recall episode type": "Lynch Surveillance",
333+
"Latest episode recall surveillance type": "Null",
334+
"Latest episode status": "Closed",
335+
"Latest episode status reason": "Non Response",
336+
"Latest event status": "A166 GP Discharge Sent (No show for Colonoscopy Assessment Appointment)",
337+
"Lynch due date": "Null",
338+
"Lynch due date date of change": "Today",
339+
"Lynch due date reason": "Ceased",
340+
"Lynch incident episode": "Null",
341+
"Screening due date": "Null",
342+
"Screening due date date of change": "Null",
343+
"Screening due date reason": "Null",
344+
"Screening status": "Ceased",
345+
"Screening status date of change": "Today",
346+
"Screening status reason": "Outside Screening Population",
347+
"Surveillance due date": "Null",
348+
"Surveillance due date date of change": "Null",
349+
"Surveillance due date reason": "Null",
350+
},
351+
user_role,
352+
)
353+
354+
# When I view the subject
355+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
356+
357+
# Then I "can" see a button with value of "Self-refer Lynch Surveillance"
358+
SubjectScreeningSummaryPage(page).button_with_value_present(
359+
"Self-refer Lynch Surveillance", True
360+
)
361+
362+
LogoutPage(page).log_out()

0 commit comments

Comments
 (0)