Skip to content

Commit 434f238

Browse files
committed
Began work on C5 codegen
1 parent 16c3438 commit 434f238

File tree

1 file changed

+230
-0
lines changed

1 file changed

+230
-0
lines changed
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
import logging
2+
from math import exp
3+
import pytest
4+
from playwright.sync_api import Page, expect
5+
from pages.logout.log_out_page import Logout
6+
from pages.base_page import BasePage
7+
from pages.screening_practitioner_appointments.screening_practitioner_appointments import (
8+
ScreeningPractitionerAppointmentsPage,
9+
)
10+
from pages.screening_practitioner_appointments.set_availability_page import (
11+
SetAvailabilityPage,
12+
)
13+
from pages.screening_practitioner_appointments.practitioner_availability_page import (
14+
PractitionerAvailabilityPage,
15+
)
16+
from pages.screening_practitioner_appointments.colonoscopy_assessment_appointments_page import (
17+
ColonoscopyAssessmentAppointments,
18+
)
19+
from pages.screening_practitioner_appointments.book_appointment_page import (
20+
BookAppointmentPage,
21+
)
22+
from pages.screening_subject_search.subject_screening_summary import (
23+
SubjectScreeningSummary,
24+
)
25+
from pages.screening_subject_search.episode_events_and_notes_page import (
26+
EpisodeEventsAndNotesPage,
27+
)
28+
from utils.user_tools import UserTools
29+
from utils.load_properties_file import PropertiesFile
30+
from utils.calendar_picker import CalendarPicker
31+
from utils.batch_processing import batch_processing
32+
from datetime import datetime
33+
from sqlalchemy.orm import Session
34+
35+
36+
@pytest.fixture
37+
def smokescreen_properties() -> dict:
38+
return PropertiesFile().get_smokescreen_properties()
39+
40+
41+
# --------------
42+
# DATA SETUP
43+
# --------------
44+
45+
# The data setup steps below have been translated directly from the selenium tests and need to be refactored
46+
47+
48+
# Get required test data from the DB
49+
def find_test_data(session: Session, region):
50+
all_data_found = True
51+
error_message = ""
52+
53+
required_number_of_kits = get_properties().get_c5_number_of_appointments_to_attend(
54+
region
55+
)
56+
if required_number_of_kits == 0:
57+
print("application properties specifies Zero appointments")
58+
else:
59+
print("Finding recent appointments")
60+
appointments = (
61+
session.query(Appointment)
62+
.filter(
63+
Appointment.org_id
64+
== get_properties().get_appointments_test_org_id(region),
65+
Appointment.kit_type == KitType.Any,
66+
)
67+
.order_by(Appointment.date_created.desc())
68+
.limit(required_number_of_kits)
69+
.all()
70+
)
71+
72+
if not appointments or len(appointments) < required_number_of_kits:
73+
all_data_found = False
74+
error_message = f"{required_number_of_kits} appointments could not be found that had an abnormal result ({region}). Instead found {len(appointments)}"
75+
print(
76+
f"{required_number_of_kits} appointments could not be found that had an abnormal result ({region})"
77+
)
78+
else:
79+
print(f"{len(appointments)} appointments found with abnormal results")
80+
81+
print(
82+
f"Appointments found: {', '.join([str(appointment.screening_subject.name_and_nhs_number) for appointment in appointments])}"
83+
)
84+
85+
return all_data_found, error_message, appointments
86+
87+
88+
# Find subjects requiring screening outcomes
89+
def test_find_subjects_requiring_screening_outcomes(setup_browser, region, page: Page):
90+
browser, _ = setup_browser
91+
# Assume testData is initialized somewhere in your test setup.
92+
93+
# Use SQLAlchemy session to fetch data
94+
session = get_session(region) # Replace with actual session setup
95+
all_data_found, error_message, appointments = find_test_data(session, region)
96+
97+
assert all_data_found, error_message
98+
99+
logging.trace("exit: findSubjectsRequiringScreeningOutcomes(region={})", region)
100+
101+
# --------------
102+
# TEST STEPS
103+
# --------------
104+
@pytest.mark.vpn_required
105+
@pytest.mark.smokescreen
106+
@pytest.mark.compartment5
107+
def test_compartment_5(page: Page, smokescreen_properties: dict) -> None:
108+
"""This is the main compartment 5 method"""
109+
110+
# --------------
111+
# Attendance of Screening
112+
# Practitioner Clinic Appointment
113+
# --------------
114+
115+
# Log in as a Screening Centre user
116+
UserTools.user_login(page, "Screening Centre Manager at BCS001")
117+
BasePage(page).go_to_screening_practitioner_appointments_page()
118+
119+
# From the Main Menu, choose the 'Screening Practitioner Appointments' and then 'View Appointments' option
120+
ScreeningPractitionerAppointmentsPage(page).go_to_view_appointments_page()
121+
122+
# Select the Appointment Type, Site, and Screening Practitioner
123+
ScreeningPractitionerAppointmentsPage(page).select_appointment_type(
124+
"Any Practitioner Appointment"
125+
)
126+
ScreeningPractitionerAppointmentsPage(page).select_site_dropdown_option(
127+
"BCS001 - Wolverhampton Bowel Cancer Screening Centre"
128+
)
129+
ScreeningPractitionerAppointmentsPage(page).select_practitioner_dropdown_option(
130+
"Astonish, Ethanol"
131+
)
132+
# Select the required date of the appointment
133+
# TODO: Add logic to select the date of the appointmentonce the C4 calendar picker is implemented
134+
135+
# Click 'View appointments on this day' button
136+
ScreeningPractitionerAppointmentsPage(
137+
page
138+
).click_view_appointments_on_this_day_button()
139+
# 'View Appointments' screen displayed
140+
BasePage.bowel_cancer_screening_page_title_contains_text(
141+
"Screening Practitioner Day View"
142+
)
143+
144+
# Select the first positive (abnormal ) patient
145+
page.get_by_role("link", name="SCALDING COD").click()
146+
147+
148+
# Select Attendance radio button, tick Attended checkbox,
149+
# set Attended Date to yesterday's (system) date and then press Save
150+
# Appointment attendance details saved Status set to J10
151+
152+
# Repeat for the 2nd and 3rd Abnormal patients
153+
# Appointment attendance details saved Status set to J10
154+
155+
# --------------
156+
# Invite for colonoscopy
157+
# --------------
158+
# Navigate to the 'Subject Screening Summary' screen for the 1st Abnormal patient
159+
# ''Subject Screening Summary' screen of the 1st Abnormal patient is displayed
160+
161+
# Click on 'Datasets' link
162+
# 'There should be a '1 dataset' for Colonoscopy Assessment
163+
164+
# Click on 'Show Dataset' next to the Colonoscopy Assessment
165+
# Populate Colonoscopy Assessment Details fields
166+
# ASA Grade - I - Fit
167+
# Fit for Colonoscopy (SSP) - Yes
168+
# Click 'Yes' for Dataset Complete?
169+
# Click Save Dataset button
170+
# Click Back
171+
# Data set marked as **Completed**. The subject event status stays at J10.
172+
173+
# On the Subject Screening Summary click on the 'Advance FOBT Screening Episode' button and then click on the 'Suitable for Endoscopic Test' button
174+
# Click OK after message
175+
# Pop up message states
176+
# This will change the status to:
177+
# A99 - Suitable for Endoscopic Test.
178+
# No other pop up message should be displayed
179+
180+
# Enter a 'First Offered Appointment Date' (enter a date after the attended appt)
181+
182+
# Select 'Colonoscopy' from the 'Type of Test' from the drop down list
183+
184+
# Click the 'Invite for Diagnostic Test >>' button
185+
# Pop-up box displayed informing user that the patient will be set to A59 - Invited for Diagnostic Test
186+
187+
# Click 'OK'
188+
# Pop-box removed from screen
189+
# 'Advance Screening Episode' redisplayed
190+
# Status set to A59 - Invited for Diagnostic Test
191+
192+
# Click 'Attend Diagnostic Test' button
193+
194+
# Select Colonoscopy from drop down list. Enter the actual appointment date as today's date and select 'Save'
195+
# Status set to A259 - Attended Diagnostic Test
196+
197+
# Repeat for the 2nd & 3rd Abnormal patients
198+
# Status set to A259 - Attended Diagnostic Test
199+
200+
# --------------
201+
# Advance the screening episode
202+
# --------------
203+
204+
# Click on 'Advance FOBT Screening Episode' button for the 1st Abnormal patient
205+
206+
# Click 'Other Post-investigation Contact Required' button
207+
# Confirmation pop-up box displayed
208+
209+
# Click 'OK'
210+
# Status set to A361 - Other Post-investigation Contact Required'Advance FOBT Screening Episode' screen re-displayed
211+
212+
# Select 'Record other post-investigation contact' button
213+
# 'Contact with Patient' screen displayed
214+
215+
# Complete 'Contact Direction',
216+
# 'Contact made between patient and',
217+
# 'Date of Patient Contact',
218+
# 'Start Time', 'End Time',
219+
# 'Discussion Record' and
220+
# select 'Outcome' - 'Post-investigation Appointment Not Required'
221+
# and click 'Save'
222+
# ''Contact with Patient' screen re-displayed readonly
223+
224+
# Click 'Back' button
225+
# ''Subject Screening Summary' screen displayed
226+
# Status set to A323 - Post-investigation Appointment NOT Required
227+
228+
# Repeat for the 2nd & 3rd Abnormal patients
229+
# ''Subject Screening Summary' screen displayed
230+
# Status set to A323 - Post-investigation Appointment NOT Required

0 commit comments

Comments
 (0)