Skip to content

Commit 757e73e

Browse files
committed
wip
1 parent e830df8 commit 757e73e

File tree

1 file changed

+294
-0
lines changed

1 file changed

+294
-0
lines changed
Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
import pytest
2+
import logging
3+
from datetime import datetime
4+
from playwright.sync_api import Page
5+
from utils.oracle.subject_creation_util import CreateSubjectSteps
6+
from utils.sspi_change_steps import SSPIChangeSteps
7+
from utils.user_tools import UserTools
8+
from utils.subject_assertion import subject_assertion
9+
from utils.call_and_recall_utils import CallAndRecallUtils
10+
from utils import screening_subject_page_searcher
11+
from utils.batch_processing import batch_processing
12+
from utils.fit_kit import FitKitLogged, FitKitGeneration
13+
from pages.screening_subject_search.subject_screening_summary_page import (
14+
SubjectScreeningSummaryPage,
15+
)
16+
17+
# from pages.screening_subject_search.close_fobt_screening_episode_page import (
18+
# CloseFobtScreeningEpisodePage,
19+
# )
20+
from utils.appointments import book_appointments
21+
from pages.logout.log_out_page import LogoutPage
22+
from pages.base_page import BasePage
23+
from pages.screening_subject_search.episode_events_and_notes_page import (
24+
EpisodeEventsAndNotesPage,
25+
)
26+
from pages.screening_practitioner_appointments.appointment_detail_page import (
27+
AppointmentDetailPage,
28+
ReasonForCancellationOptions,
29+
)
30+
from pages.screening_subject_search.advance_fobt_screening_episode_page import (
31+
AdvanceFOBTScreeningEpisodePage,
32+
)
33+
from pages.screening_subject_search.record_diagnosis_date_page import (
34+
RecordDiagnosisDatePage,
35+
)
36+
37+
38+
@pytest.mark.wip
39+
@pytest.mark.usefixtures("setup_org_and_appointments")
40+
@pytest.mark.vpn_required
41+
@pytest.mark.regression
42+
@pytest.mark.fobt_regression_tests
43+
def test_scenario_5(page: Page) -> None:
44+
"""
45+
Scenario: 5: DNA colonoscopy assessment twice
46+
47+
S1-S9-S10-S43-A8-A183-A25-J11-J27-A184-A26-A185-A37-A166-P202-(A50)-(A167)-A166-C203 [SSCL4a(A166)]
48+
49+
This scenario tests where the patient is discharged from their FOBT episode because they DNA their colonoscopy assessment appointment twice. It also tests the diagnosis date and kit result letter spur events.
50+
51+
Scenario summary:
52+
53+
> Create a new subject in the FOBT age range > Inactive
54+
> Run the FOBT failsafe trawl > Call
55+
> Run the database transition to invite them for FOBT screening > S1(1.1)
56+
> Process S1 letter batch > S9 (1.1)
57+
> Run timed events > creates S9 letter (1.1)
58+
> Process S9 letter batch > S10 (1.1)
59+
> Log kit > S43 (1.2)
60+
> Read kit with ABNORMAL result > A8 (1.3)
61+
> Invite for colonoscopy assessment > A183 (1.11)
62+
> Process A183 appointment letter > A25 (1.11)
63+
> Patient DNA appointment > J11 (1.11)
64+
> Process J11 letter batch > J27 (1.11)
65+
> Rebook colonoscopy assessment > A184 (1.11)
66+
> Process A184 letter > A26 (1.11)
67+
> Patient DNA appointment > A185 (1.11)
68+
> Process A185 letter batch > A37 (1.11)
69+
> Process A37 letter batch > A166 (1.11) > P202
70+
> Record diagnosis date (A50)
71+
> Process A183 result letter (A167) > A166 (1.11) > C203 (1.13)
72+
> Check recall [SSCL4a(A166)]
73+
"""
74+
75+
summary_page = SubjectScreeningSummaryPage(page)
76+
logging.info(
77+
"[TEST START] Regression - Scenario: 5: DNA colonoscopy assessment twice"
78+
)
79+
80+
# Given I log in to BCSS "England" as user role "Hub Manager"
81+
user_role = UserTools.user_login(
82+
page, "Hub Manager at BCS01", return_role_type=True
83+
)
84+
if user_role is None:
85+
raise ValueError("User cannot be assigned to a UserRoleType")
86+
87+
# And I create a subject that meets the following criteria:
88+
requirements = {
89+
"age (y/d)": "64/12",
90+
"active gp practice in hub/sc": "BCS01/BCS001",
91+
}
92+
nhs_no = CreateSubjectSteps().create_custom_subject(requirements)
93+
if nhs_no is None:
94+
pytest.fail("Failed to create subject: NHS number not returned.")
95+
96+
# Then Comment: NHS number
97+
logging.info(f"[SUBJECT CREATED] NHS number: {nhs_no}")
98+
99+
# And my subject has been updated as follows:
100+
subject_assertion(
101+
nhs_no,
102+
{
103+
"subject age": "64",
104+
"subject has episodes": "No",
105+
"screening status": "Inactive",
106+
},
107+
)
108+
# Assert subject details in the UI
109+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
110+
summary_page.assert_subject_age(64)
111+
summary_page.assert_screening_status("Inactive")
112+
113+
# When I run the FOBT failsafe trawl for my subject
114+
CallAndRecallUtils().run_failsafe(nhs_no)
115+
116+
# Then my subject has been updated as follows:
117+
subject_assertion(
118+
nhs_no,
119+
{
120+
"subject has episodes": "No",
121+
"Screening Due Date": "Last Birthday",
122+
"Screening due date date of change": "Today",
123+
"Screening Due Date Reason": "Failsafe Trawl",
124+
"screening status": "Call",
125+
"Screening Status Date of Change": "Today",
126+
"Screening Status Reason": "Failsafe Trawl",
127+
},
128+
)
129+
130+
# When I invite my subject for FOBT screening
131+
CallAndRecallUtils().invite_subject_for_fobt_screening(nhs_no, user_role)
132+
133+
# Then my subject has been updated as follows:
134+
subject_assertion(
135+
nhs_no,
136+
{
137+
"latest event status": "S1 Selected for Screening",
138+
"latest episode kit class": "FIT",
139+
"latest episode type": "FOBT",
140+
},
141+
)
142+
143+
# Then there is a "S1" letter batch for my subject with the exact title "Pre-invitation (FIT)"
144+
# When I process the open "S1" letter batch for my subject
145+
# When I run Timed Events for my subject
146+
# Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
147+
# Then my subject has been updated as follows:
148+
# batch_processing( TODO: Check these values
149+
# page,
150+
# "S1",
151+
# "Pre-invitation (FIT)",
152+
# "S9 - Invitation & Test Kit (FIT)",
153+
# True,
154+
# )
155+
156+
157+
# When I process the open "S9" letter batch for my subject
158+
# And I pause for 5 seconds to let the process complete
159+
# Then my subject has been updated as follows:
160+
161+
# Latest event status S10 Invitation & Test Kit Sent
162+
163+
# When I log my subject's latest unlogged FIT kit
164+
# And I pause for "6" seconds to let the process complete
165+
# Then my subject has been updated as follows:
166+
167+
# Latest event status S43 Kit Returned and Logged (Initial Test)
168+
169+
# When I read my subject's latest logged FIT kit as "ABNORMAL"
170+
# Then my subject has been updated as follows:
171+
172+
# Latest event status A8 Abnormal
173+
174+
# When I view the subject
175+
# And I choose to book a practitioner clinic for my subject
176+
# And I select "BCS001" as the screening centre where the practitioner appointment will be held
177+
# And I set the practitioner appointment date to "today"
178+
# And I book the "earliest" available practitioner appointment on this date
179+
# And I pause for 5 seconds to let the process complete
180+
# Then my subject has been updated as follows:
181+
182+
# Latest event status A183 1st Colonoscopy Assessment Appointment Requested
183+
# And there is a "A183" letter batch for my subject with the exact title "Practitioner Clinic 1st Appointment"
184+
# And there is a "A183" letter batch for my subject with the exact title "GP Result (Abnormal)"
185+
186+
# When I process the open "A183 - Practitioner Clinic 1st Appointment" letter batch for my subject
187+
# And I pause for 5 seconds to let the process complete
188+
# Then my subject has been updated as follows:
189+
190+
# Latest event status A25 1st Colonoscopy Assessment Appointment Booked, letter sent
191+
192+
# When I switch users to BCSS "England" as user role "Screening Centre Manager"
193+
# And I view the subject
194+
# And I view the event history for the subject's latest episode
195+
# And I view the latest practitioner appointment in the subject's episode
196+
# And The subject DNAs the practitioner appointment
197+
# And I pause for 5 seconds to let the process complete
198+
# Then my subject has been updated as follows:
199+
200+
# Latest event status J11 1st Colonoscopy Assessment Appointment Non-attendance (Patient)
201+
# And there is a "J11" letter batch for my subject with the exact title "Practitioner Clinic 1st Appointment Non Attendance (Patient)"
202+
203+
# When I process the open "J11" letter batch for my subject
204+
# And I pause for 5 seconds to let the process complete
205+
# Then my subject has been updated as follows:
206+
207+
# Latest event status J27 Appointment Non-attendance Letter Sent (Patient)
208+
209+
# When I view the subject
210+
# And I choose to book a practitioner clinic for my subject
211+
# And I select "BCS001" as the screening centre where the practitioner appointment will be held
212+
# And I set the practitioner appointment date to "today"
213+
# And I book the "earliest" available practitioner appointment on this date
214+
# And I pause for 5 seconds to let the process complete
215+
# Then my subject has been updated as follows:
216+
217+
# Latest event status A184 2nd Colonoscopy Assessment Appointment Requested
218+
# And there is a "A184" letter batch for my subject with the exact title "Practitioner Clinic 2nd Appointment"
219+
220+
# When I process the open "A184 - Practitioner Clinic 2nd Appointment" letter batch for my subject
221+
# And I pause for 5 seconds to let the process complete
222+
# Then my subject has been updated as follows:
223+
224+
# Latest event status A26 2nd Colonoscopy Assessment Appointment Booked, letter sent
225+
226+
# When I view the subject
227+
# And I view the event history for the subject's latest episode
228+
# And I view the latest practitioner appointment in the subject's episode
229+
# And The subject DNAs the practitioner appointment
230+
# And I pause for 5 seconds to let the process complete
231+
# Then my subject has been updated as follows:
232+
233+
# Latest event status A185 2nd Colonoscopy Assessment Appointment Non-attendance (Patient)
234+
# And there is a "A185" letter batch for my subject with the exact title "Patient Discharge (Non Attendance of Practitioner Clinic)"
235+
236+
# When I process the open "A185" letter batch for my subject
237+
# And I pause for 5 seconds to let the process complete
238+
# Then my subject has been updated as follows:
239+
240+
# Latest event status A37 Patient Discharge Sent (Non-attendance at Colonoscopy Assessment Appointment)
241+
# And there is a "A37" letter batch for my subject with the exact title "GP Discharge (Non Attendance of Practitioner Clinic)"
242+
243+
# When I switch users to BCSS "England" as user role "Hub Manager"
244+
# And I process the open "A37" letter batch for my subject
245+
# And I pause for 5 seconds to let the process complete
246+
# Then my subject has been updated as follows:
247+
248+
# Latest event status P202 Waiting Completion of Outstanding Events
249+
250+
# When I view the subject
251+
# And I view the advance episode options
252+
# And I select the advance episode option for "Record Diagnosis Date"
253+
# And I enter a Diagnosis Date of "today"
254+
# And I save Diagnosis Date Information
255+
# And I pause for 5 seconds to let the process complete
256+
# Then my subject has been updated as follows:
257+
258+
# Latest episode diagnosis date reason Null
259+
# Latest episode has diagnosis date Yes
260+
# Latest episode includes event status A50 Diagnosis date recorded
261+
# Latest event status P202 Waiting Completion of Outstanding Events
262+
263+
# When I process the open "A183 - GP Result (Abnormal)" letter batch for my subject
264+
# And I pause for 5 seconds to let the process complete
265+
# Then my subject has been updated as follows:
266+
267+
# Calculated FOBT due date 2 years from latest A37 event
268+
# Calculated lynch due date Unchanged
269+
# Calculated surveillance due date Unchanged
270+
# Ceased confirmation date Null
271+
# Ceased confirmation details Null
272+
# Ceased confirmation user ID Null
273+
# Clinical reason for cease Null
274+
# Latest episode accumulated result Definitive abnormal FOBT outcome
275+
# Latest episode includes event status A167 GP Abnormal FOBT Result Sent
276+
# Latest episode recall calculation method Date of last patient letter
277+
# Latest episode recall episode type FOBT Screening
278+
# Latest episode recall surveillance type Null
279+
# Latest episode status Closed
280+
# Latest episode status reason Non Response
281+
# Latest event status A166 GP Discharge Sent (No show for Colonoscopy Assessment Appointment)
282+
# Lynch due date Null
283+
# Lynch due date date of change Unchanged
284+
# Lynch due date reason Unchanged
285+
# Screening due date Calculated FOBT due date
286+
# Screening due date date of change Today
287+
# Screening due date reason Recall
288+
# Screening status Recall
289+
# Screening status date of change
290+
# Not checking as status may or may not have changed
291+
# Screening status reason Recall
292+
# Surveillance due date Null
293+
# Surveillance due date date of change Unchanged
294+
# Surveillance due date reason Unchanged

0 commit comments

Comments
 (0)