@@ -2125,6 +2125,310 @@ def test_check_behaviour_of_other_drugs_administered_fields_in_incomplete_datase
21252125 LogoutPage (page ).log_out ()
21262126
21272127
2128+ @pytest .mark .regression
2129+ @pytest .mark .vpn_required
2130+ @pytest .mark .investigation_dataset_tests
2131+ @pytest .mark .bcss_additional_tests
2132+ @pytest .mark .colonoscopy_dataset_tests
2133+ def test_check_drug_validation_for_subject_older_than_70_in_incomplete_dataset (
2134+ page : Page ,
2135+ ) -> None :
2136+ """
2137+ Scenario: Check drug dose validation specific to a subject aged 70 or older in an incomplete endoscopy investigation dataset
2138+ This checks the drug dose validation for Midazolam, which has a different recommended range for subjects aged 70 or older.
2139+ """
2140+ nhs_no = get_subject_older_than_70_with_new_colonsocopy_dataset ()
2141+
2142+ UserTools .user_login (page , "Screening Centre Manager at BCS001" )
2143+
2144+ BasePage (page ).go_to_screening_subject_search_page ()
2145+ search_subject_episode_by_nhs_number (page , nhs_no )
2146+
2147+ SubjectScreeningSummaryPage (page ).click_datasets_link ()
2148+ SubjectDatasetsPage (page ).click_investigation_show_datasets ()
2149+
2150+ InvestigationDatasetsPage (page ).bowel_cancer_screening_page_title_contains_text (
2151+ "Investigation Datasets"
2152+ )
2153+ InvestigationDatasetsPage (page ).click_show_drug_information ()
2154+ DatasetFieldUtil (page ).populate_select_locator_for_field_inside_div (
2155+ other_drugs_administered_string , div_drug_details_string , YesNoOptions .YES
2156+ )
2157+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2158+ other_drugs_administered_string , "Yes"
2159+ )
2160+
2161+ InvestigationDatasetsPage (page ).check_visibility_of_drug_type (
2162+ other_drugs_administered_string , 1 , True
2163+ )
2164+ InvestigationDatasetsPage (page ).check_visibility_of_drug_dose (
2165+ other_drugs_administered_string , 1 , True
2166+ )
2167+ InvestigationDatasetsPage (page ).assert_drug_type_text (
2168+ other_drugs_administered_string , 1 , ""
2169+ )
2170+ InvestigationDatasetsPage (page ).assert_drug_dose_text (
2171+ other_drugs_administered_string , 1 , ""
2172+ )
2173+
2174+ drug_info_list = [
2175+ (OtherDrugsAdministeredDrugTypeOptions .MIDAZOLAM , "0.99" ),
2176+ ]
2177+ drug_information = InvestigationDatasetCompletion (page ).build_drug_information_dict (
2178+ drug_info_list , other_drugs_administered_string
2179+ )
2180+ InvestigationDatasetsPage (page ).assert_dialog_text (
2181+ "The recommended dose for Midazolam is 1 - 2.5 mg for patients aged 70 or over. Please check and re-enter as necessary." ,
2182+ True ,
2183+ )
2184+ InvestigationDatasetCompletion (page ).fill_out_drug_information (drug_information )
2185+
2186+ InvestigationDatasetsPage (page ).assert_drug_type_text (
2187+ other_drugs_administered_string ,
2188+ 1 ,
2189+ OtherDrugsAdministeredDrugTypeOptions .MIDAZOLAM ,
2190+ )
2191+ InvestigationDatasetsPage (page ).assert_drug_dose_text (
2192+ other_drugs_administered_string , 1 , "0.99"
2193+ )
2194+
2195+ drug_info_list = [
2196+ (None , "1" ),
2197+ ]
2198+ drug_information = InvestigationDatasetCompletion (page ).build_drug_information_dict (
2199+ drug_info_list , other_drugs_administered_string
2200+ )
2201+ InvestigationDatasetCompletion (page ).fill_out_drug_information (drug_information )
2202+ InvestigationDatasetsPage (page ).assert_drug_dose_text (
2203+ other_drugs_administered_string , 1 , "1"
2204+ )
2205+
2206+ drug_info_list = [
2207+ (None , "2.51" ),
2208+ ]
2209+ drug_information = InvestigationDatasetCompletion (page ).build_drug_information_dict (
2210+ drug_info_list , other_drugs_administered_string
2211+ )
2212+ InvestigationDatasetsPage (page ).assert_dialog_text (
2213+ "The recommended dose for Midazolam is 1 - 2.5 mg for patients aged 70 or over. Please check and re-enter as necessary." ,
2214+ True ,
2215+ )
2216+ InvestigationDatasetCompletion (page ).fill_out_drug_information (drug_information )
2217+
2218+ InvestigationDatasetsPage (page ).assert_drug_dose_text (
2219+ other_drugs_administered_string , 1 , "2.51"
2220+ )
2221+
2222+ drug_info_list = [
2223+ (None , "2.5" ),
2224+ ]
2225+ drug_information = InvestigationDatasetCompletion (page ).build_drug_information_dict (
2226+ drug_info_list , other_drugs_administered_string
2227+ )
2228+ InvestigationDatasetCompletion (page ).fill_out_drug_information (drug_information )
2229+ InvestigationDatasetsPage (page ).assert_drug_dose_text (
2230+ other_drugs_administered_string , 1 , "2.5"
2231+ )
2232+
2233+ LogoutPage (page ).log_out ()
2234+
2235+
2236+ @pytest .mark .regression
2237+ @pytest .mark .vpn_required
2238+ @pytest .mark .investigation_dataset_tests
2239+ @pytest .mark .bcss_additional_tests
2240+ @pytest .mark .colonoscopy_dataset_tests
2241+ def test_check_dropdown_lists_and_default_field_values_in_endoscopy_information_section (
2242+ page : Page ,
2243+ ) -> None :
2244+ """
2245+ Scenario: Check dropdown lists and default field values in the Endoscopy Information section of a new Colonoscopy investigation dataset
2246+ """
2247+ nhs_no = get_subject_with_new_colonoscopy_investigation_dataset ()
2248+ UserTools .user_login (page , "Screening Centre Manager at BCS001" )
2249+ BasePage (page ).go_to_screening_subject_search_page ()
2250+ search_subject_episode_by_nhs_number (page , nhs_no )
2251+ SubjectScreeningSummaryPage (page ).click_datasets_link ()
2252+ SubjectDatasetsPage (page ).click_investigation_show_datasets ()
2253+
2254+ InvestigationDatasetsPage (page ).bowel_cancer_screening_page_title_contains_text (
2255+ "Investigation Datasets"
2256+ )
2257+ InvestigationDatasetsPage (page ).click_show_endoscopy_information ()
2258+ field_names = [
2259+ "Endoscope inserted" ,
2260+ "Procedure type" ,
2261+ "Bowel preparation quality" ,
2262+ "Comfort during examination" ,
2263+ "Comfort during recovery" ,
2264+ "Sedation during examination" ,
2265+ "Sedation during recovery" ,
2266+ "Endoscopist defined extent" ,
2267+ "Scope imager used" ,
2268+ "Retroverted view" ,
2269+ "Start of intubation time" ,
2270+ "Start of extubation time" ,
2271+ "End time of procedure" ,
2272+ "Scope ID" ,
2273+ "Detection assistant (AI) used?" ,
2274+ "Insufflation" ,
2275+ "Outcome at time of procedure" ,
2276+ "Late outcome" ,
2277+ ]
2278+ InvestigationDatasetsPage (page ).are_fields_on_page (
2279+ "Endoscopy Information" , None , field_names
2280+ )
2281+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2282+ "Endoscope inserted" , YesNoOptions .YES
2283+ )
2284+ InvestigationDatasetsPage (page ).are_fields_on_page (
2285+ "Endoscopy Information" , None , ["Why Endoscope Not Inserted" ], False
2286+ )
2287+ DatasetFieldUtil (page ).assert_radio_to_right_is_selected (
2288+ "Procedure type" , "Diagnostic" , "divColonoscopeFields"
2289+ )
2290+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2291+ "Bowel preparation quality" , ""
2292+ )
2293+ dropdown_values = [
2294+ "Excellent" ,
2295+ "Good" ,
2296+ "Adequate/Fair" ,
2297+ "Poor" ,
2298+ "Inadequate" ,
2299+ ]
2300+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2301+ "Bowel preparation quality" , dropdown_values
2302+ )
2303+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2304+ "Comfort during examination" , ""
2305+ )
2306+ dropdown_values = [
2307+ "No discomfort" ,
2308+ "Minimal discomfort" ,
2309+ "Mild discomfort" ,
2310+ "Moderate discomfort" ,
2311+ "Severe discomfort" ,
2312+ ]
2313+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2314+ "Comfort during examination" , dropdown_values
2315+ )
2316+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2317+ "Comfort during recovery" , ""
2318+ )
2319+ dropdown_values = [
2320+ "No discomfort" ,
2321+ "Minimal discomfort" ,
2322+ "Mild discomfort" ,
2323+ "Moderate discomfort" ,
2324+ "Severe discomfort" ,
2325+ ]
2326+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2327+ "Comfort during recovery" , dropdown_values
2328+ )
2329+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2330+ "Sedation during examination" , "Unsedated" , "divSedationExamReadOnly"
2331+ )
2332+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2333+ "Sedation during recovery" , "Unsedated" , "divSedationRecoveryReadOnly"
2334+ )
2335+ InvestigationDatasetsPage (page ).are_fields_on_page (
2336+ "Endoscopy Information" , None , ["Intended extent of examination" ], False
2337+ )
2338+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2339+ "Endoscopist defined extent" , ""
2340+ )
2341+ dropdown_values = [
2342+ "Anus" ,
2343+ "Rectum" ,
2344+ "Sigmoid Colon" ,
2345+ "Descending Colon" ,
2346+ "Splenic Flexure" ,
2347+ "Transverse Colon" ,
2348+ "Hepatic Flexure" ,
2349+ "Ascending Colon" ,
2350+ "Caecum" ,
2351+ "Ileum" ,
2352+ "Anastomosis" ,
2353+ "Appendix" ,
2354+ ]
2355+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2356+ "Endoscopist defined extent" , dropdown_values
2357+ )
2358+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2359+ "Scope imager used" , ""
2360+ )
2361+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2362+ "Scope imager used" , ["Yes" , "No" ]
2363+ )
2364+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2365+ "Retroverted view" , ""
2366+ )
2367+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2368+ "Retroverted view" , ["Yes" , "No" ]
2369+ )
2370+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2371+ "Start of intubation time" , ""
2372+ )
2373+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2374+ "Start of extubation time" , ""
2375+ )
2376+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2377+ "End time of procedure" , ""
2378+ )
2379+ InvestigationDatasetsPage (page ).are_fields_on_page (
2380+ "Endoscopy Information" , None , ["Withdrawal time" ], False
2381+ )
2382+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text ("Scope ID" , "" )
2383+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2384+ "Detection Assistant (AI) used?" , "No"
2385+ )
2386+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2387+ "Detection Assistant (AI) used?" , ["Yes" , "No" ]
2388+ )
2389+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text ("Insufflation" , "" )
2390+ dropdown_values = [
2391+ "Air" ,
2392+ "Carbon Dioxide" ,
2393+ "Carbon Dioxide changed to Air mid procedure" ,
2394+ "Air changed to Carbon Dioxide mid procedure" ,
2395+ "Water" ,
2396+ "Water and Carbon Dioxide" ,
2397+ "Water and Air" ,
2398+ "Water and Carbon Dioxide and Air" ,
2399+ ]
2400+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2401+ "Insufflation" , dropdown_values
2402+ )
2403+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text (
2404+ "Outcome at time of procedure" , ""
2405+ )
2406+ dropdown_values = [
2407+ "Leave department" ,
2408+ "Planned hospital admission for observation/social reasons" ,
2409+ "Unplanned hospital admission" ,
2410+ ]
2411+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2412+ "Outcome at time of procedure" , dropdown_values
2413+ )
2414+ DatasetFieldUtil (page ).assert_cell_to_right_has_expected_text ("Late outcome" , "" )
2415+ dropdown_values = [
2416+ "No complications" ,
2417+ "Condition resolved" ,
2418+ "Telephone consultation" ,
2419+ "Outpatient consultation" ,
2420+ "Hospital admission" ,
2421+ ]
2422+ DatasetFieldUtil (page ).assert_select_to_right_has_values (
2423+ "Late outcome" , dropdown_values
2424+ )
2425+
2426+ LogoutPage (page ).log_out ()
2427+
2428+
2429+ # Helper Functions
2430+
2431+
21282432def check_role_access_to_edit_investigation_dataset (
21292433 page : Page ,
21302434 nhs_no : str ,
@@ -2275,3 +2579,35 @@ def get_subject_younger_than_70_with_new_colonsocopy_dataset() -> str:
22752579 nhs_no = df .iloc [0 ]["subject_nhs_number" ]
22762580 logging .info (f"NHS Number: { nhs_no } " )
22772581 return nhs_no
2582+
2583+
2584+ def get_subject_older_than_70_with_new_colonsocopy_dataset () -> str :
2585+ """
2586+ Gets a subject with the following criteria:
2587+ "latest episode status": "open",
2588+ "latest episode latest investigation dataset": "colonoscopy_new",
2589+ "subject age": ">= 70"
2590+ Returns:
2591+ str: The nhs number of a subject matching the criteria
2592+ """
2593+ criteria = {
2594+ "latest episode status" : "open" ,
2595+ "latest episode latest investigation dataset" : "colonoscopy_new" ,
2596+ "subject age" : ">= 70" ,
2597+ }
2598+ user = User ()
2599+ subject = Subject ()
2600+
2601+ builder = SubjectSelectionQueryBuilder ()
2602+
2603+ query , bind_vars = builder .build_subject_selection_query (
2604+ criteria = criteria ,
2605+ user = user ,
2606+ subject = subject ,
2607+ subjects_to_retrieve = 1 ,
2608+ )
2609+
2610+ df = OracleDB ().execute_query (query , bind_vars )
2611+ nhs_no = df .iloc [0 ]["subject_nhs_number" ]
2612+ logging .info (f"NHS Number: { nhs_no } " )
2613+ return nhs_no
0 commit comments