Skip to content

Commit 1be6e75

Browse files
Merge branch 'main' of github.com:NHSDigital/bcss-playwright into feature/BCSS-21321-fobtregressiontests-scenario-18
2 parents 7580477 + 23ba447 commit 1be6e75

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

classes/screening/has_gp_practice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def by_description(cls, description: str):
3333
Optional[HasGPPractice]: The matching enum member, or None if not found.
3434
"""
3535
for member in cls:
36-
if member.value == description:
36+
if member.value.lower() == description:
3737
return member
3838
return None
3939

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

0 commit comments

Comments
 (0)