|
| 1 | +import pytest |
| 2 | +from playwright.sync_api import Page |
| 3 | +from classes.repositories.subject_repository import SubjectRepository |
| 4 | +from conftest import general_properties |
| 5 | +from pages.base_page import BasePage |
| 6 | +from pages.surveillance import produce_healthcheck_forms |
| 7 | +from pages.surveillance.produce_healthcheck_forms import ProduceHealthCheckPage |
| 8 | +from pages.surveillance.surveillance_page import SurveillancePage |
| 9 | +from utils import screening_subject_page_searcher |
| 10 | +from utils.generate_healthcheck_forms import generate_healthcheck_forms |
| 11 | +from utils.sspi_change_steps import SSPIChangeSteps |
| 12 | +from utils.user_tools import UserTools |
| 13 | +from utils.oracle.subject_creation_util import CreateSubjectSteps |
| 14 | +from utils.subject_assertion import subject_assertion |
| 15 | +from utils.call_and_recall_utils import CallAndRecallUtils |
| 16 | +import logging |
| 17 | +from utils.batch_processing import batch_processing |
| 18 | +from utils.fit_kit import FitKitGeneration, FitKitLogged |
| 19 | +from pages.logout.log_out_page import LogoutPage |
| 20 | +from datetime import datetime |
| 21 | +from pages.surveillance.produce_healthcheck_forms import ProduceHealthCheckPage |
| 22 | +from classes.repositories.subject_repository import SubjectRepository |
| 23 | +from utils.oracle.oracle_specific_functions.organisation_parameters import ( |
| 24 | + set_org_parameter_value, |
| 25 | + check_parameter, |
| 26 | +) |
| 27 | + |
| 28 | +@pytest.mark.wip |
| 29 | +@pytest.mark.vpn_required |
| 30 | +@pytest.mark.regression |
| 31 | +@pytest.mark.survelliance_regression_tests |
| 32 | +def test_scenario_1(page: Page, general_properties: dict) -> None: |
| 33 | + """ |
| 34 | + Scenario: 1: Discharge for clinical decision (GP letter required) |
| 35 | +
|
| 36 | + X500-X505-X600-X610-X615-X641-X600-X610-X615-X650-X390-X379-C203 [SSCL28b] X900-X600-X610-X2-X610-X615-X650-X382-X79-C203 [SSCL25a] |
| 37 | +
|
| 38 | + This scenario takes both an in-age and an over-age surveillance subject from invitation through to episode closure on X379 - discharge for clinical reason, GP letter required. The scenario includes both DNA and reschedule of the SSP appointment. It also includes a reopen, and checks that the episode could be postponed at most points during this pathway. |
| 39 | +
|
| 40 | + Because we cannot know if we will be inviting a subject who has had previous FOBT episodes, or only a bowel scope episode, it is impossible to check if they will be set to Call or Recall; we can only check that they are not longer in Surveillance status. |
| 41 | +
|
| 42 | + Note: parameter 82 controls whether or not a GP letter is required when a patient is discharged from Surveillance as a result of a clinical decision. It actually defaults to Y, but it's set at SC level in the scenario to be sure it holds the correct value. As a parameter can't be set with immediate effect through the screens, the scenario uses a direct database update to do this. |
| 43 | +
|
| 44 | +
|
| 45 | + Scenario summary: |
| 46 | + >Run surveillance invitations for 1 subject > X500 (3.1) |
| 47 | + > SSPI update changes subject to in-age |
| 48 | + > Process X500 letter batch > X505 (3.1) |
| 49 | + > Record patient contact – contacted, SSP appointment > X600 (3.1) |
| 50 | + > Book SSP appointment from report > X610 (3.3) |
| 51 | + > Process X610 letter batch > X615 (3.3) |
| 52 | + > Patient DNA SSP appointment > X641 (3.3) |
| 53 | + > Choose to book SSP appointment > X600 (3.3) |
| 54 | + > Book SSP appointment > X610 (3.3) |
| 55 | + > Process X610 letter batch > X615 (3.3) |
| 56 | + > Attend SSP appointment > X650 (3.3) |
| 57 | + > Record discharge, clinical decision, GP letter required > X390 (3.4) |
| 58 | + > Process X390 letter batch > X379 > C203 (3.4) |
| 59 | + > Check recall [SSCL28b] |
| 60 | + > Reopen episode for correction > X900 (3.1) |
| 61 | + > Record patient contact – contacted, SSP appointment > X600 (3.1) |
| 62 | + > Book SSP appointment from subject summary > X610 (3.3) |
| 63 | + > Reschedule SSP appointment > X2 > X610 (3.3) |
| 64 | + > Process X610 letter batch > X615 (3.3) |
| 65 | + > Attend SSP appointment > X650 (3.3) |
| 66 | + > SSPI update changes subject to over-age |
| 67 | + > Record discharge, clinical decision, GP letter required > X382 (3.4) |
| 68 | + > Process X382 letter batch > X79 > C203 (3.4) |
| 69 | + > Check recall [SSCL25a] |
| 70 | +
|
| 71 | + """ |
| 72 | + # Given I log in to BCSS "England" as user role "Screening Centre Manager at BCS001" |
| 73 | + user_role = UserTools.user_login( |
| 74 | + page, "Screening Centre Manager at BCS001", return_role_type=True |
| 75 | + ) |
| 76 | + if user_role is None: |
| 77 | + raise ValueError("User cannot be assigned to a UserRoleType") |
| 78 | + |
| 79 | + # When I run surveillance invitations for 1 subject |
| 80 | + |
| 81 | + nhs_no = generate_healthcheck_forms(page, general_properties) |
| 82 | + # Then my subject has been updated as follows: |
| 83 | + |
| 84 | + criteria = { |
| 85 | + "latest episode status": "Open", |
| 86 | + "latest episode type": "Surveillance", |
| 87 | + "latest event status": "X500 Selected For Surveillance", |
| 88 | + "responsible screening centre code": "User's screening centre", |
| 89 | + "subject has unprocessed sspi updates": "No", |
| 90 | + "subject has user dob updates": "No", |
| 91 | + } |
| 92 | + |
| 93 | + subject_assertion(nhs_no, criteria,user_role) |
| 94 | + # And there is a "X500" letter batch for my subject with the exact title "Surveillance Selection" |
| 95 | + SubjectRepository().there_is_letter_batch_for_subject( |
| 96 | + nhs_no, "X500", "Surveillance Selection" |
| 97 | + ) |
| 98 | + # Then Comment: NHS number logging.info(f"Surveillance Scenario NHS Number: {nhs_number}") |
| 99 | + # When I set the value of parameter 82 to "Y" for my organisation with immediate effect |
| 100 | + org_id = general_properties["eng_screening_centre_id"] |
| 101 | + set_org_parameter_value(82, "Y", org_id) |
| 102 | + # When I receive an SSPI update to change their date of birth to "72" years old |
| 103 | + SSPIChangeSteps().sspi_update_to_change_dob_received(nhs_no, 72) |
| 104 | + # Then my subject has been updated as follows: |
| 105 | + subject_assertion(nhs_no, {"subject age": "72"}) |
| 106 | + # When I process the open "X500" letter batch for my subject |
| 107 | + batch_processing( |
| 108 | + page, |
| 109 | + batch_type="X500", |
| 110 | + batch_description="Surveillance Selection", |
| 111 | + latest_event_status="X505 HealthCheck Form Printed", |
| 112 | + ) |
| 113 | + # Then my subject has been updated as follows: |
| 114 | + subject_assertion( |
| 115 | + nhs_no, |
| 116 | + { |
| 117 | + "latest event status": "X505 HealthCheck Form Printed", |
| 118 | + }, |
| 119 | + ) |
| 120 | + # When I view the subject |
| 121 | + screening_subject_page_searcher.navigate_to_subject_summary_page( |
| 122 | + page=page, nhs_no=nhs_no |
| 123 | + ) |
| 124 | + # And I select the advance episode option for "Record Contact with Patient" |
| 125 | + # SurveillancePage(page).select_advance_episode_option("Record Contact with Patient") |
| 126 | + |
0 commit comments