Skip to content

Commit d1c3574

Browse files
committed
Working on scenario 19
1 parent 5a7af62 commit d1c3574

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

tests/regression/regression_tests/fobt_regression_tests/test_scenario_17.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
from pages.organisations.organisations_page import OrganisationSwitchPage
8181

8282

83-
@pytest.mark.wip
8483
@pytest.mark.usefixtures("setup_org_and_appointments")
8584
@pytest.mark.vpn_required
8685
@pytest.mark.regression
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
from datetime import datetime
2+
import pytest
3+
import logging
4+
from playwright.sync_api import Page
5+
from classes.repositories.episode_repository import EpisodeRepository
6+
from classes.subject.subject import Subject
7+
from classes.user.user import User
8+
from pages.logout.log_out_page import LogoutPage
9+
from utils.fit_kit import FitKitGeneration, FitKitLogged
10+
from utils.oracle.subject_selection_query_builder import SubjectSelectionQueryBuilder
11+
from utils.subject_assertion import subject_assertion
12+
from utils.user_tools import UserTools
13+
14+
15+
@pytest.mark.usefixtures("setup_org_and_appointments")
16+
@pytest.mark.vpn_required
17+
@pytest.mark.regression
18+
@pytest.mark.fobt_regression_tests
19+
def test_scenario_17(page: Page) -> None:
20+
"""
21+
Scenario: 19: Late response receive a kit
22+
23+
This scenario tests that a new "late response" episode will be created for a subject who returns a kit following a non-response episode that started more than 6 months ago - provided they are registered with an active GP practice.
24+
25+
"""
26+
# Given I log in to BCSS "England" as user role "Hub Manager"
27+
user_role = UserTools.user_login(
28+
page, "Hub Manager at BCS01", return_role_type=True
29+
)
30+
if user_role is None:
31+
raise ValueError("This user cannot be assigned to a UserRoleType")
32+
33+
# And there is a subject who meets the following criteria:
34+
criteria = {
35+
"latest event status": "S44 GP Discharge for Non-response Sent (Initial Test)",
36+
"latest episode kit class": "FIT",
37+
"latest episode started": "More than 6 months ago",
38+
"latest episode status": "Closed",
39+
"latest episode type": "FOBT",
40+
"latest episode sub-type": "Routine",
41+
"has gp practice": "Yes - active",
42+
"subject has unprocessed sspi updates": "No",
43+
"subject has user dob updates": "No",
44+
"subject age": "Between 60 and 72",
45+
"subject has unlogged kits": "Yes",
46+
"subject hub code": "User's hub",
47+
}
48+
49+
user = User().from_user_role_type(user_role)
50+
51+
query, bind_vars = SubjectSelectionQueryBuilder().build_subject_selection_query(
52+
criteria=criteria,
53+
user=user,
54+
subject=Subject(),
55+
subjects_to_retrieve=1,
56+
)
57+
58+
nhs_no_df = OracleDB().execute_query(query=query, parameters=bind_vars)
59+
nhs_no = nhs_no_df["subject_nhs_number"].iloc[0]
60+
61+
# Then Comment: NHS number
62+
logging.info(f"[SUBJECT RETRIEVAL] Retrieved subject's NHS number: {nhs_no}")
63+
64+
# When I log my subject's latest unlogged FIT kit
65+
fit_kit = FitKitGeneration().get_fit_kit_for_subject_sql(nhs_no, False, False)
66+
FitKitLogged().log_fit_kits(
67+
page=page,
68+
sample_date=datetime.now(),
69+
fit_kit=fit_kit,
70+
)
71+
72+
# Then my subject has been updated as follows:
73+
criteria = {
74+
"latest episode includes event code": "E59 Initiate Opt-in/Self-referral",
75+
"latest episode started": "Today",
76+
"latest episode status": "Open",
77+
"latest episode type": "FOBT",
78+
"latest episode sub-type": "Late Responder",
79+
"latest episode includes event status": "S195 Receipt of Self-referral kit",
80+
"latest event status": "S43 Kit Returned and Logged (Initial Test)",
81+
"screening due date": "Today",
82+
"screening due date date of change": "Today",
83+
"screening due date reason": "Late Response",
84+
"screening status": "Self-referral",
85+
"screening status date of change": "Today",
86+
"screening status reason": "Late Response",
87+
}
88+
subject_assertion(nhs_no, criteria)
89+
90+
# Finally I log out of BCSS
91+
LogoutPage(page).log_out()

0 commit comments

Comments
 (0)