|
| 1 | +import pytest |
| 2 | +import logging |
| 3 | +import pandas as pd |
| 4 | +from playwright.sync_api import Page |
| 5 | +from pages.base_page import BasePage |
| 6 | +from utils.oracle.oracle_specific_functions import SubjectSelector |
| 7 | +from classes.subject import Subject |
| 8 | +from utils.oracle.oracle import OracleDB |
| 9 | +from pages.base_page import BasePage |
| 10 | +from utils import screening_subject_page_searcher |
| 11 | + |
| 12 | +# from utils.subject.subject_assertions import SubjectAssertions |
| 13 | +# from utils.subject.subject_cease_utils import SubjectCeaseUtils |
| 14 | + |
| 15 | +# Feature: Manually cease a subject |
| 16 | + |
| 17 | + |
| 18 | +# These scenarios just check that manually ceasing a subject (either immediately or via a disclaimer letter) from different statuses correctly sets their screening status and status reason. |
| 19 | +# Screening due date reason is always set to "Ceased" during a manual cease, even if the SDD is not changing. |
| 20 | +@pytest.mark.wip |
| 21 | +@pytest.mark.manual_cease |
| 22 | +@pytest.mark.regression |
| 23 | +def test_manual_cease_from_inactive_subject_for_informed_dissent(page: Page) -> None: |
| 24 | + """ |
| 25 | + Scenario: Subject is at status Inactive, cease for Informed Dissent |
| 26 | +
|
| 27 | + Given I log in to BCSS "England" as user role "Hub Manager" |
| 28 | + And there is a subject who meets the following criteria: |
| 29 | + | Screening status | Inactive | |
| 30 | + When I view the subject |
| 31 | + And I manually cease the subject with reason "Informed Dissent" |
| 32 | + And I pause for "5" seconds to let the process complete |
| 33 | + Then my subject has been updated as follows: |
| 34 | + | Screening Status | Ceased | |
| 35 | + | Screening Status Reason | Informed Dissent | |
| 36 | + | Screening Status Date of Change | Today | |
| 37 | + | Screening Due Date Reason | Ceased | |
| 38 | + | Screening Due Date | Null (unchanged) | |
| 39 | + | Ceased Confirmation Details | AUTO TESTING: confirm not-immediate manual cease | |
| 40 | + | Ceased Confirmation User ID | User's ID | |
| 41 | + | Lynch / Surveillance Due Dates | Unchanged or Null | |
| 42 | + | Clinical Reason for Cease | Null | |
| 43 | + """ |
| 44 | + logging.info("[TEST START] Manual cease from Inactive subject for Informed Dissent") |
| 45 | + |
| 46 | + # Retrieve NHS number for subject matching scenario criteria |
| 47 | + nhs_number = SubjectSelector.get_subject_for_manual_cease( |
| 48 | + {"screening status": "Inactive"} |
| 49 | + ) |
| 50 | + logging.info(f"[SUBJECT SELECTOR] Retrieved NHS number: {nhs_number}") |
| 51 | + # TODO: Does a stored procedure need to be run? Subject is not being updated as specified in docstring |
| 52 | + # Create Oracle subject object and run timed events (optional but consistent with existing pattern) |
| 53 | + subject = Subject() |
| 54 | + nhs_df = pd.DataFrame({"subject_nhs_number": [nhs_number]}) |
| 55 | + OracleDB().exec_bcss_timed_events(nhs_df) |
| 56 | + logging.info("[TIMED EVENTS] Executed for subject") |
| 57 | + |
| 58 | + # # Navigate to subject profile in UI |
| 59 | + # base_page = BasePage(page) |
| 60 | + # base_page.click_main_menu_link() |
| 61 | + # base_page.go_to_screening_subject_search_page() |
| 62 | + # screening_subject_page_searcher.search_subject_by_nhs_number(page, nhs_number) |
| 63 | + # logging.info("[SUBJECT VIEW] Subject loaded in UI") |
| 64 | + |
| 65 | + # # Manually cease subject with specified reason |
| 66 | + # SubjectCeaseUtils.trigger_manual_cease(page, reason="Informed Dissent") |
| 67 | + # logging.info("[CEASE ACTION] Manual cease triggered") |
| 68 | + |
| 69 | + # # Wait for updates to process |
| 70 | + # page.wait_for_timeout(5000) |
| 71 | + |
| 72 | + # # Perform field assertions |
| 73 | + # SubjectAssertions.assert_field("Screening Status", "Ceased") |
| 74 | + # SubjectAssertions.assert_field("Screening Status Reason", "Informed Dissent") |
| 75 | + # SubjectAssertions.assert_field_is_today("Screening Status Date of Change") |
| 76 | + # SubjectAssertions.assert_field("Screening Due Date Reason", "Ceased") |
| 77 | + # SubjectAssertions.assert_field_null("Screening Due Date") |
| 78 | + # SubjectAssertions.assert_field( |
| 79 | + # "Ceased Confirmation Details", |
| 80 | + # "AUTO TESTING: confirm not-immediate manual cease", |
| 81 | + # ) |
| 82 | + # SubjectAssertions.assert_field_matches_user_id("Ceased Confirmation User ID") |
| 83 | + # SubjectAssertions.assert_field_null("Clinical Reason for Cease") |
| 84 | + # SubjectAssertions.assert_field_unchanged("Calculated FOBT Due Date") |
| 85 | + # SubjectAssertions.assert_field_null("Calculated Lynch Due Date") |
| 86 | + # SubjectAssertions.assert_field_unchanged("Calculated Surveillance Due Date") |
| 87 | + |
| 88 | + # logging.info("[ASSERTIONS COMPLETE] Manual cease scenario validated successfully") |
| 89 | + |
| 90 | + |
| 91 | +# Scenario: Subject is at status Call, cease for Informed Dissent, verbal only |
| 92 | + |
| 93 | +# Given I log in to BCSS "England" as user role "Hub Manager" |
| 94 | +# And there is a subject who meets the following criteria: |
| 95 | +# | Screening status | Call | |
| 96 | +# | Subject has episodes | No | |
| 97 | + |
| 98 | +# When Comment: NHS number |
| 99 | + |
| 100 | +# When I view the subject |
| 101 | +# And I manually cease the subject with reason "Informed Dissent (verbal only)" |
| 102 | +# And I pause for "5" seconds to let the process complete |
| 103 | +# Then my subject has been updated as follows: |
| 104 | +# | Calculated FOBT due date | Unchanged | |
| 105 | +# | Calculated lynch due date | Null | |
| 106 | +# | Calculated surveillance due date | Unchanged | |
| 107 | +# | Ceased confirmation date | Today | |
| 108 | +# | Ceased confirmation details | AUTO TESTING: confirm immediate manual cease | |
| 109 | +# | Ceased confirmation user ID | User's ID | |
| 110 | +# | Clinical reason for cease | Null | |
| 111 | +# | Lynch due date | Null | |
| 112 | +# | Lynch due date reason | Unchanged | |
| 113 | +# | Lynch due date date of change | Unchanged | |
| 114 | +# | Screening due date | Null | |
| 115 | +# | Screening due date date of change | Today | |
| 116 | +# | Screening due date reason | Ceased | |
| 117 | +# | Screening status | Ceased | |
| 118 | +# | Screening status reason | Informed Dissent (verbal only) | |
| 119 | +# | Screening status date of change | Today | |
| 120 | +# | Surveillance due date | Null | |
| 121 | +# | Surveillance due date reason | Unchanged | |
| 122 | +# | Surveillance due date date of change | Unchanged | |
| 123 | + |
| 124 | + |
| 125 | +# Scenario: Subject is at status Recall, cease for No Colon, subject request |
| 126 | + |
| 127 | +# Look for subject's with a not-null due date so the check for the SDD change is not tripped up by dodgy test data. |
| 128 | + |
| 129 | +# Given I log in to BCSS "England" as user role "Hub Manager" |
| 130 | +# And there is a subject who meets the following criteria: |
| 131 | +# | Screening status | Recall | |
| 132 | +# | Screening due date | Not null | |
| 133 | +# | Latest episode status | Closed | |
| 134 | + |
| 135 | +# When Comment: NHS number |
| 136 | + |
| 137 | +# When I view the subject |
| 138 | +# And I manually cease the subject with reason "No Colon (subject request)" |
| 139 | +# And I pause for "5" seconds to let the process complete |
| 140 | +# Then my subject has been updated as follows: |
| 141 | +# | Calculated FOBT due date | Unchanged | |
| 142 | +# | Calculated lynch due date | Null | |
| 143 | +# | Calculated surveillance due date | Unchanged | |
| 144 | +# | Ceased confirmation date | Today | |
| 145 | +# | Ceased confirmation details | AUTO TESTING: confirm not-immediate manual cease | |
| 146 | +# | Ceased confirmation user ID | User's ID | |
| 147 | +# | Clinical reason for cease | Null | |
| 148 | +# | Lynch due date | Null | |
| 149 | +# | Lynch due date reason | Unchanged | |
| 150 | +# | Lynch due date date of change | Unchanged | |
| 151 | +# | Screening due date | Null | |
| 152 | +# | Screening due date date of change | Today | |
| 153 | +# | Screening due date reason | Ceased | |
| 154 | +# | Screening status | Ceased | |
| 155 | +# | Screening status reason | No Colon (subject request) | |
| 156 | +# | Screening status date of change | Today | |
| 157 | +# | Surveillance due date | Null | |
| 158 | +# | Surveillance due date reason | Unchanged | |
| 159 | +# | Surveillance due date date of change | Unchanged | |
| 160 | + |
| 161 | + |
| 162 | +# Scenario: Subject is at status Surveillance, cease for No Colon, programme assessed |
| 163 | + |
| 164 | +# Given I log in to BCSS "England" as user role "Hub Manager" |
| 165 | +# And there is a subject who meets the following criteria: |
| 166 | +# | Screening status | Surveillance | |
| 167 | +# | Latest episode status | Closed | |
| 168 | + |
| 169 | +# When Comment: NHS number |
| 170 | + |
| 171 | +# When I view the subject |
| 172 | +# And I manually cease the subject with reason "No Colon (programme assessed)" |
| 173 | +# And I pause for "5" seconds to let the process complete |
| 174 | +# Then my subject has been updated as follows: |
| 175 | +# | Calculated FOBT due date | Unchanged | |
| 176 | +# | Calculated lynch due date | Null | |
| 177 | +# | Calculated surveillance due date | Unchanged | |
| 178 | +# | Ceased confirmation date | Today | |
| 179 | +# | Ceased confirmation details | AUTO TESTING: confirm immediate manual cease | |
| 180 | +# | Ceased confirmation user ID | User's ID | |
| 181 | +# | Clinical reason for cease | Null | |
| 182 | +# | Lynch due date | Null | |
| 183 | +# | Lynch due date reason | Unchanged | |
| 184 | +# | Lynch due date date of change | Unchanged | |
| 185 | +# | Screening due date | Null | |
| 186 | +# | Screening due date date of change | Unchanged | |
| 187 | +# | Screening due date reason | Ceased | |
| 188 | +# | Screening status | Ceased | |
| 189 | +# | Screening status reason | No Colon (programme assessed) | |
| 190 | +# | Screening status date of change | Today | |
| 191 | +# | Surveillance due date | Null | |
| 192 | +# | Surveillance due date reason | Ceased | |
| 193 | +# | Surveillance due date date of change | Today | |
| 194 | + |
| 195 | + |
| 196 | +# Scenario: Subject is at status Ceased, outside screening population, cease for Informal Death |
| 197 | + |
| 198 | +# Screening status reason is set, but because the status itself is not changing the status date of change is not changed. |
| 199 | + |
| 200 | +# Given I log in to BCSS "England" as user role "Hub Manager" |
| 201 | +# And there is a subject who meets the following criteria: |
| 202 | +# | Screening status | Ceased | |
| 203 | +# | Screening status reason | Outside screening population | |
| 204 | + |
| 205 | +# When Comment: NHS number |
| 206 | + |
| 207 | +# When I view the subject |
| 208 | +# And I manually cease the subject with reason "Informal Death" |
| 209 | +# And I pause for "5" seconds to let the process complete |
| 210 | +# Then my subject has been updated as follows: |
| 211 | +# | Calculated FOBT due date | Unchanged | |
| 212 | +# | Calculated lynch due date | Null | |
| 213 | +# | Calculated surveillance due date | Unchanged | |
| 214 | +# | Ceased confirmation date | Today | |
| 215 | +# | Ceased confirmation details | AUTO TESTING: confirm immediate manual cease | |
| 216 | +# | Ceased confirmation user ID | User's ID | |
| 217 | +# | Clinical reason for cease | Null | |
| 218 | +# | Lynch due date | Null | |
| 219 | +# | Lynch due date reason | Unchanged | |
| 220 | +# | Lynch due date date of change | Unchanged | |
| 221 | +# | Screening due date | Null | |
| 222 | +# | Screening due date date of change | Unchanged | |
| 223 | +# | Screening due date reason | Unchanged | |
| 224 | +# | Screening status | Ceased | |
| 225 | +# | Screening status reason | Informal Death | |
| 226 | +# | Screening status date of change | Unchanged | |
| 227 | +# | Surveillance due date | Null | |
| 228 | +# | Surveillance due date reason | Unchanged | |
| 229 | +# | Surveillance due date date of change | Unchanged | |
| 230 | + |
| 231 | + |
| 232 | +# Scenario: Subject is at status Ceased, outside screening population, cease for No Colon (subject request) |
| 233 | + |
| 234 | +# Screening status reason is set, but because the status itself is not changing the status date of change is not changed. |
| 235 | + |
| 236 | +# Given I log in to BCSS "England" as user role "Hub Manager" |
| 237 | +# And there is a subject who meets the following criteria: |
| 238 | +# | Screening status | Ceased | |
| 239 | +# | Screening status reason | Outside screening population | |
| 240 | + |
| 241 | +# When Comment: NHS number |
| 242 | + |
| 243 | +# When I view the subject |
| 244 | +# And I manually cease the subject with reason "No Colon (subject request)" |
| 245 | +# And I pause for "5" seconds to let the process complete |
| 246 | +# Then my subject has been updated as follows: |
| 247 | +# | Calculated FOBT due date | Unchanged | |
| 248 | +# | Calculated lynch due date | Null | |
| 249 | +# | Calculated surveillance due date | Unchanged | |
| 250 | +# | Ceased confirmation date | Today | |
| 251 | +# | Ceased confirmation details | AUTO TESTING: confirm not-immediate manual cease | |
| 252 | +# | Ceased confirmation user ID | User's ID | |
| 253 | +# | Clinical reason for cease | Null | |
| 254 | +# | Lynch due date | Null | |
| 255 | +# | Lynch due date reason | Unchanged | |
| 256 | +# | Lynch due date date of change | Unchanged | |
| 257 | +# | Screening due date | Null | |
| 258 | +# | Screening due date date of change | Unchanged | |
| 259 | +# | Screening due date reason | Unchanged | |
| 260 | +# | Screening status | Ceased | |
| 261 | +# | Screening status reason | No Colon (subject request) | |
| 262 | +# | Screening status date of change | Unchanged | |
| 263 | +# | Surveillance due date | Null | |
| 264 | +# | Surveillance due date reason | Unchanged | |
| 265 | +# | Surveillance due date date of change | Unchanged | |
0 commit comments