Skip to content

Commit 69e988b

Browse files
Merge branch 'main' of github.com:NHSDigital/bcss-playwright into feature/BCSS-20521-c6-investigation-dataset-navigation-util
# Conflicts: # tests/smokescreen/test_compartment_6.py
2 parents 93f278b + ea3bc92 commit 69e988b

File tree

3 files changed

+84
-19
lines changed

3 files changed

+84
-19
lines changed

tests/smokescreen/bcss_smokescreen_tests.properties

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# ----------------------------------
4343
# compartment 6
4444
# ----------------------------------
45-
# c6_eng_org_id=23159
45+
c6_eng_org_id=23159
4646
# c6_eng_site_id=35317
4747
# c6_eng_practitioner_id=243
4848
# c6_eng_testing_clinician_id=805
@@ -90,8 +90,4 @@
9090
# ----------------------------------
9191
# compartment 6
9292
# ----------------------------------
93-
# c6_eng_number_of_normal_results_to_record=1
94-
# c6_eng_number_of_lnpcp_results_to_record=1
95-
# c6_eng_number_of_high_risk_findings_results_to_record=1
96-
# c6_eng_number_of_lnpcp_results_over_74_to_record=1
97-
# c6_eng_number_of_high_risk_findings_results_over_74_to_record=1
93+
c6_eng_number_of_subjects_to_record=5

tests/smokescreen/test_compartment_6.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from utils.screening_subject_page_searcher import verify_subject_event_status_by_nhs_no
55
from utils.batch_processing import batch_processing
66
from pages.logout.log_out_page import LogoutPage
7+
from utils.oracle.oracle_specific_functions import (
8+
get_subjects_for_investigation_dataset_updates,
9+
)
10+
from utils.subject_demographics import SubjectDemographicUtil
711
from utils.investigation_dataset import (
812
InvestigationDatasetCompletion,
913
InvestigationDatasetResults,
@@ -15,13 +19,14 @@
1519
@pytest.mark.vpn_required
1620
@pytest.mark.smokescreen
1721
@pytest.mark.compartment6
18-
def test_compartment_6(page: Page) -> None:
22+
def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
1923
"""
2024
This is the main compartment 6 method
2125
This test fills out the investigation datasets for different subjects to get different outcomes for a diagnostic test
2226
based on the test results and the subject's age, then prints the diagnostic test result letters.
2327
If the subject is old enough and they get a high-risk or LNPCP result, then they are handed over
2428
into symptomatic care, and the relevant letters are printed.
29+
Here old refers to if a subject is over 75 at recall
2530
"""
2631

2732
# For the following tests 'old' refers to if a subject is over 75 at recall
@@ -30,51 +35,57 @@ def test_compartment_6(page: Page) -> None:
3035

3136
UserTools.user_login(page, "Screening Centre Manager at BCS001")
3237

33-
# This needs to be repeated for two subjects, one old and one not - High Risk Result
34-
# Older patient
38+
# Older patient - High Risk Result
3539
logging.info("High-risk result for an older subject")
36-
nhs_no = "9687319364"
40+
subjects_df = get_subjects_for_investigation_dataset_updates(
41+
smokescreen_properties["c6_eng_number_of_subjects_to_record"],
42+
smokescreen_properties["c6_eng_org_id"],
43+
)
44+
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
45+
SubjectDemographicUtil(page).update_subject_dob(nhs_no, False)
3746
InvestigationDatasetCompletion(page).complete_with_result(
3847
nhs_no, InvestigationDatasetResults.HIGH_RISK
3948
)
4049
AfterInvestigationDatasetComplete(page).progress_episode_based_on_result(
4150
InvestigationDatasetResults.HIGH_RISK, False
4251
)
4352

44-
# Younger patient
53+
# Younger patient - High Risk Result
4554
logging.info("High-risk result for a younger subject")
46-
nhs_no = "9462733759"
55+
nhs_no = subjects_df["subject_nhs_number"].iloc[1]
56+
SubjectDemographicUtil(page).update_subject_dob(nhs_no, True)
4757
InvestigationDatasetCompletion(page).complete_with_result(
4858
nhs_no, InvestigationDatasetResults.HIGH_RISK
4959
)
5060
AfterInvestigationDatasetComplete(page).progress_episode_based_on_result(
5161
InvestigationDatasetResults.HIGH_RISK, True
5262
)
5363

54-
# This needs to be repeated for two subjects, one old and one not - LNPCP Result
55-
# Older patient
64+
# Older patient - LNPCP Result
5665
logging.info("LNPCP result for an older subject")
57-
nhs_no = "9434999847"
66+
nhs_no = subjects_df["subject_nhs_number"].iloc[2]
67+
SubjectDemographicUtil(page).update_subject_dob(nhs_no, False)
5868
InvestigationDatasetCompletion(page).complete_with_result(
5969
nhs_no, InvestigationDatasetResults.LNPCP
6070
)
6171
AfterInvestigationDatasetComplete(page).progress_episode_based_on_result(
6272
InvestigationDatasetResults.LNPCP, False
6373
)
6474

65-
# Younger patient
75+
# Younger patient - LNPCP Result
6676
logging.info("LNPCP result for a younger subject")
67-
nhs_no = "9773554414"
77+
nhs_no = subjects_df["subject_nhs_number"].iloc[3]
78+
SubjectDemographicUtil(page).update_subject_dob(nhs_no, True)
6879
InvestigationDatasetCompletion(page).complete_with_result(
6980
nhs_no, InvestigationDatasetResults.LNPCP
7081
)
7182
AfterInvestigationDatasetComplete(page).progress_episode_based_on_result(
7283
InvestigationDatasetResults.LNPCP, True
7384
)
7485

75-
# This needs to be repeated for 1 subject, age does not matter - Normal Result
86+
# Any patient - Normal Result
7687
logging.info("Normal result for any age subject")
77-
nhs_no_normal = "9039985766"
88+
nhs_no_normal = subjects_df["subject_nhs_number"].iloc[4]
7889
InvestigationDatasetCompletion(page).complete_with_result(
7990
nhs_no_normal, InvestigationDatasetResults.NORMAL
8091
)

utils/oracle/oracle_specific_functions.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class SqlQueryValues(IntEnum):
1212
OPEN_EPISODE_STATUS_ID = 11352
1313
A8_EVENT_STATUS = 11132
1414
POSITIVE_APPOINTMENT_BOOKED = 11119
15+
POST_INVESTIGATION_APPOINTMENT_NOT_REQUIRED = 160182
1516

1617

1718
def get_kit_id_from_db(
@@ -364,3 +365,60 @@ def get_subjects_with_booked_appointments(subjects_to_retrieve: int) -> pd.DataF
364365
subjects_df = OracleDB().execute_query(query, params)
365366

366367
return subjects_df
368+
369+
370+
def get_subjects_for_investigation_dataset_updates(
371+
number_of_subjects: int, hub_id: str
372+
) -> pd.DataFrame:
373+
"""
374+
This is used to get subjects for compartment 6
375+
It finds subjects with latest envent status of A323 - Post-investigation Appointment
376+
377+
Args:
378+
number_of_subjects (int): The number of subjects to retrieve
379+
hub_id (str): hub id to use
380+
381+
Returns:
382+
subjects_df (pd.DataFrame): A pandas DataFrame containing the result of the query
383+
"""
384+
385+
query = """SELECT distinct(ss.subject_nhs_number)
386+
from
387+
(
388+
select count(*), eset.screening_subject_id
389+
from ep_subject_episode_t eset
390+
inner join screening_subject_t sst on (eset.screening_subject_id = sst.screening_subject_id)
391+
inner join external_tests_t ext on (eset.subject_epis_id = ext.subject_epis_id)
392+
inner join ds_colonoscopy_t dct on (ext.ext_test_id = dct.ext_test_id)
393+
where dct.dataset_completed_date is null
394+
and dct.deleted_flag ='N'
395+
and ext.void = 'N'
396+
group by eset.screening_subject_id
397+
having
398+
count(*)= 1 ) sst
399+
inner join ep_subject_episode_t eset on ( sst.screening_subject_id = eset.screening_subject_id )
400+
inner join screening_subject_t ss on (eset.screening_subject_id = ss.screening_subject_id)
401+
inner join sd_contact_t c ON ss.subject_nhs_number = c.nhs_number
402+
inner join EXTERNAL_TESTS_T ext on (eset.subject_epis_id = ext.subject_epis_id)
403+
inner join DS_COLONOSCOPY_T dct on (ext.ext_test_id = dct.ext_test_id)
404+
inner join sd_contact_t sd on (ss.subject_nhs_number = sd.nhs_number)
405+
inner join sd_address_t sda on (sd.contact_id = sda.address_id)
406+
inner join org on (sd.gp_practice_id = org.org_id)
407+
where eset.latest_event_status_id = :latest_event_status_id -- A323 - Post-investigation Appointment NOT Required
408+
and ext.void = 'N'
409+
and dct.dataset_new_flag = 'Y'
410+
and dct.deleted_flag = 'N'
411+
and sd.GP_PRACTICE_ID is not null
412+
and eset.start_hub_id = :start_hub_id
413+
fetch first :subjects_to_retrieve rows only
414+
"""
415+
416+
params = {
417+
"latest_event_status_id": SqlQueryValues.POST_INVESTIGATION_APPOINTMENT_NOT_REQUIRED,
418+
"start_hub_id": hub_id,
419+
"subjects_to_retrieve": number_of_subjects,
420+
}
421+
422+
subjects_df = OracleDB().execute_query(query, params)
423+
424+
return subjects_df

0 commit comments

Comments
 (0)