Skip to content

Commit 00cec7f

Browse files
committed
wip
1 parent f3ea6b0 commit 00cec7f

File tree

4 files changed

+166
-96
lines changed

4 files changed

+166
-96
lines changed

pages/datasets/investigation_dataset_page.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def __init__(self, page: Page):
5858
"#anchorCompletionProof"
5959
)
6060
self.show_failure_information_details = self.page.locator("#anchorFailure")
61+
self.show_radiology_failure_information_details = self.page.locator(
62+
"#anchorRadiologyFailure"
63+
)
6164
self.add_polyp_button = self.page.get_by_role("button", name="Add Polyp")
6265
self.polyp1_add_intervention_button = self.page.get_by_role(
6366
"link", name=self.add_intervention_string
@@ -211,6 +214,13 @@ def click_show_radiology_information(self) -> None:
211214
"""
212215
self.click(self.show_radiology_information)
213216

217+
def click_show_radiology_failure_information(self) -> None:
218+
"""
219+
This method is designed to click on the show radiology failure information link.
220+
It clicks on the show radiology failure information link.
221+
"""
222+
self.click(self.show_radiology_failure_information_details)
223+
214224
def select_aspirant_endoscopist_option(self, option: str) -> None:
215225
"""
216226
This method is designed to select an aspirant endoscopist from the aspirant endoscopist options.
@@ -259,8 +269,9 @@ def click_show_suspected_findings_details(self) -> None:
259269
This method is designed to click on the show suspected findings details link.
260270
It clicks on the show suspected findings details link.
261271
"""
262-
logging.info("[DEBUG] Clicking on Show Suspected Findings Details")
263-
self.click(self.show_suspected_findings)
272+
logging.info("[DEBUG] Clicking on Show Suspected Findings Details")
273+
self.page.wait_for_timeout(1000)
274+
self.show_suspected_findings.click()
264275

265276
def select_drug_type_option1(self, option: str) -> None:
266277
"""

pages/screening_subject_search/diagnostic_test_outcome_page.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
import logging
2+
from click import option
13
from playwright.sync_api import Page, expect, Locator
24
from pages.base_page import BasePage
35
from enum import StrEnum
46

57

8+
class ReferralProcedureType(StrEnum):
9+
ENDOSCOPIC = "20356"
10+
RADIOLOGICAL = "20357"
11+
12+
13+
class ReasonForOnwardReferral(StrEnum):
14+
CURRENTLY_UNSUITABLE_FOR_ENDOSCOPIC_REFERRAL = "20358"
15+
FURTHER_CLINICAL_ASSESSMENT = "20359"
16+
INCOMPLETE_COLONIC_VISUALISATION = "20481"
17+
18+
619
class DiagnosticTestOutcomePage(BasePage):
720
"""Diagnostic Test Outcome Page locators and methods for interacting with the page."""
821

@@ -14,6 +27,10 @@ def __init__(self, page: Page):
1427
"Outcome of Diagnostic Test"
1528
)
1629
self.save_button = self.page.get_by_role("button", name="Save")
30+
self.referral_procedure_dropdown = self.page.locator(
31+
"#UI_REFERRAL_PROCEDURE_TYPE"
32+
)
33+
self.reason_for_onward_referral_dropdown = self.page.locator("#UI_COMPLETE_ID")
1734

1835
def verify_diagnostic_test_outcome(self, outcome_name: str) -> None:
1936
"""
@@ -36,6 +53,35 @@ def click_save_button(self) -> None:
3653
"""Click the 'Save' button."""
3754
self.click(self.save_button)
3855

56+
def select_referral_procedure_type(self, value: ReferralProcedureType) -> None:
57+
"""Select Radiological or Endoscopic Referral value."""
58+
self.referral_procedure_dropdown.wait_for(state="visible")
59+
self.referral_procedure_dropdown.select_option(value=value)
60+
61+
def select_reason_for_onward_referral(self, value: ReasonForOnwardReferral) -> None:
62+
"""Select Reason for Onward Referral value."""
63+
self.reason_for_onward_referral_dropdown.wait_for(state="visible")
64+
self.reason_for_onward_referral_dropdown.select_option(value=value)
65+
66+
def select_first_valid_onward_referral_consultant(self) -> None:
67+
"""Selects the first valid consultant from the lookup dropdown inside the iframe."""
68+
self.page.locator("#UI_CONSULTANT_PIO_SELECT_LINK").click()
69+
70+
self.consultant_lookup_dropdown = self.page.frame_locator(
71+
"#UI_POPUP_wqggdxgaifr"
72+
).locator("#UI_RESULTS_cgywrngg")
73+
74+
self.consultant_lookup_dropdown.wait_for(state="visible")
75+
76+
options = self.consultant_lookup_dropdown.locator("option").all()
77+
for option in options:
78+
value = option.get_attribute("value")
79+
if value:
80+
self.consultant_lookup_dropdown.click() # Focus the dropdown
81+
self.consultant_lookup_dropdown.select_option(value=value)
82+
logging.info(f"Selected consultant with value: {value}")
83+
break
84+
3985

4086
class OutcomeOfDiagnosticTest(StrEnum):
4187
"""Enum for outcome of diagnostic test options."""
@@ -44,4 +90,4 @@ class OutcomeOfDiagnosticTest(StrEnum):
4490
REFER_SYMPTOMATIC = "20366"
4591
REFER_SURVEILLANCE = "20365"
4692
INVESTIGATION_COMPLETE = "20360"
47-
REFER_ANOTHER_DIAGNOSTIC_TEST = "20363"
93+
REFER_ANOTHER_DIAGNOSTIC_TEST = "20364"

tests/regression/regression_tests/fobt_regression_tests/test_scenario_8.py

Lines changed: 87 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
from pages.screening_subject_search.diagnostic_test_outcome_page import (
4242
DiagnosticTestOutcomePage,
4343
OutcomeOfDiagnosticTest,
44+
ReasonForOnwardReferral,
45+
ReferralProcedureType,
4446
)
4547

4648

@@ -394,9 +396,9 @@ def test_scenario_8(page: Page) -> None:
394396
# "surveillance due date reason": "Unchanged",
395397
# }
396398
# subject_assertion(nhs_no, criteria)
397-
nhs_no = "9668188616"
399+
398400
# When I view the subject
399-
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
401+
# screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
400402

401403
# # And I reopen the subject's episode for "Reopen to Reschedule Diagnostic Test"
402404
# SubjectScreeningSummaryPage(page).click_reopen_fobt_screening_episode_button()
@@ -487,95 +489,102 @@ def test_scenario_8(page: Page) -> None:
487489
# subject_assertion(nhs_no, criteria)
488490

489491
# When I view the subject
490-
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
492+
# screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
491493

492-
# And I edit the Investigation Dataset for this subject
493-
SubjectScreeningSummaryPage(page).click_datasets_link()
494-
SubjectDatasetsPage(page).click_investigation_show_datasets()
495-
496-
# And I set the following fields and values within the Investigation Dataset for this subject:
497-
general_information = {
498-
"site": 1,
499-
"practitioner": 1,
500-
"testing clinician": 1,
501-
"reporting radiologist": 2,
502-
"fit for subsequent endoscopic referral": YesNoOptions.YES,
503-
}
504-
505-
# And I set the following fields and values within the Contrast, Tagging & Drug Information:
506-
# And I add the following Additional Bowel Preparation drugs and values within the Investigation Dataset for this subject:
507-
contrast_tagging_and_drug = {
508-
"iv buscopan administered": CancerRadiologyYesNoOptions.NO,
509-
"contraindicated": YesNoOptions.NO,
510-
"iv contrast administered": IVConstantAdministeredOptions.NO,
511-
"tagging agent given": TaggingAgentDrugAdministeredOptions.YES,
512-
"additional bowel preparation administered": AdditionalBowelPrepAdministeredOptions.YES,
513-
"drug_type1": DrugTypeOptions.PICOLAX,
514-
"drug_dose1": "1",
515-
}
516-
517-
# And I add the following "Tagging Agent Given" drugs and doses within the Investigation Dataset for this subject:
518-
# | Gastrografin | 1 |
519-
tagging_agent_given_drug_information = {
520-
"drug_type1": DrugTypeOptions.GASTROGRAFIN,
521-
"drug_dose1": "1",
522-
}
523-
524-
# And I set the following fields and values within the Radiology Information:
525-
# And I set the following fields and values within the Radiology Information:
526-
radiology_information = {
527-
"examination_quality": ExaminationQualityOptions.GOOD,
528-
"scan_position": ScanPositionOptions.DUAL,
529-
"procedure_outcome": ProcedureOutcomeOptions.LEAVE_DEPARTMENT,
530-
"late_outcome": RadiologyLateOutcomeOptions.NO_COMPLICATIONS,
531-
"segmental_inadequacy": SegmentalInadequacyOptions.NO,
532-
"intracolonic_summary_code": IntracolonicSummaryCodeOptions.CX_INADEQUATE_STUDY,
533-
"extracolonic_summary_code": ExtracolonicSummaryCodeOptions.E4_IMPORTANT_REQUIRES_ACTION,
534-
}
535-
536-
suspected_findings = {
537-
"extracolonic summary code": ExtracolonicSummaryCodeOptions.E4_IMPORTANT_REQUIRES_ACTION,
538-
}
494+
# # And I edit the Investigation Dataset for this subject
495+
# SubjectScreeningSummaryPage(page).click_datasets_link()
496+
# SubjectDatasetsPage(page).click_investigation_show_datasets()
497+
498+
# # And I set the following fields and values within the Investigation Dataset for this subject:
499+
# general_information = {
500+
# "site": 1,
501+
# "practitioner": 1,
502+
# "testing clinician": 1,
503+
# "reporting radiologist": 2,
504+
# "fit for subsequent endoscopic referral": YesNoOptions.YES,
505+
# }
506+
507+
# # And I set the following fields and values within the Contrast, Tagging & Drug Information:
508+
# # And I add the following Additional Bowel Preparation drugs and values within the Investigation Dataset for this subject:
509+
# contrast_tagging_and_drug = {
510+
# "iv buscopan administered": CancerRadiologyYesNoOptions.NO,
511+
# "contraindicated": YesNoOptions.NO,
512+
# "iv contrast administered": IVConstantAdministeredOptions.NO,
513+
# "tagging agent given": TaggingAgentDrugAdministeredOptions.YES,
514+
# "additional bowel preparation administered": AdditionalBowelPrepAdministeredOptions.YES,
515+
# "drug_type1": DrugTypeOptions.PICOLAX,
516+
# "drug_dose1": "1",
517+
# }
518+
519+
# # And I add the following "Tagging Agent Given" drugs and doses within the Investigation Dataset for this subject:
520+
# # | Gastrografin | 1 |
521+
# tagging_agent_given_drug_information = {
522+
# "drug_type1": DrugTypeOptions.GASTROGRAFIN,
523+
# "drug_dose1": "1",
524+
# }
525+
526+
# # And I set the following fields and values within the Radiology Information:
527+
# # And I set the following fields and values within the Radiology Information:
528+
# radiology_information = {
529+
# "examination_quality": ExaminationQualityOptions.GOOD,
530+
# "scan_position": ScanPositionOptions.DUAL,
531+
# "procedure_outcome": ProcedureOutcomeOptions.LEAVE_DEPARTMENT,
532+
# "late_outcome": RadiologyLateOutcomeOptions.NO_COMPLICATIONS,
533+
# "segmental_inadequacy": SegmentalInadequacyOptions.NO,
534+
# "intracolonic_summary_code": IntracolonicSummaryCodeOptions.CX_INADEQUATE_STUDY,
535+
# }
536+
537+
# suspected_findings = {
538+
# "extracolonic summary code": ExtracolonicSummaryCodeOptions.E4_IMPORTANT_REQUIRES_ACTION,
539+
# }
539540

540541
# # And I set the following radiology failure reasons within the Investigation Dataset for this subject:
541542
# # | No failure reasons | NOTE - this can be left as default - there is only one option
542543

544+
# # And I open all minimized sections on the dataset
545+
# # And I mark the Investigation Dataset as completed
546+
# # # When I press the save Investigation Dataset button
547+
# # # And I press OK on my confirmation prompt
548+
# InvestigationDatasetCompletion(page).complete_dataset_with_args(
549+
# general_information=general_information,
550+
# contrast_tagging_and_drug=contrast_tagging_and_drug,
551+
# tagging_agent_given_drug_information=tagging_agent_given_drug_information,
552+
# radiology_information=radiology_information,
553+
# suspected_findings = suspected_findings,
554+
# )
543555

544-
# And I open all minimized sections on the dataset
545-
# And I mark the Investigation Dataset as completed
546-
# # When I press the save Investigation Dataset button
547-
# # And I press OK on my confirmation prompt
548-
InvestigationDatasetCompletion(page).complete_dataset_with_args(
549-
general_information=general_information,
550-
contrast_tagging_and_drug=contrast_tagging_and_drug,
551-
tagging_agent_given_drug_information=tagging_agent_given_drug_information,
552-
radiology_information=radiology_information,
553-
suspected_findings = suspected_findings,
554-
)
555-
556-
# Then my subject has been updated as follows:
557-
# TODO: For this assertion I'm getting:
558-
# [ASSERTION MISMATCH] Key: 'latest episode accumulated result' | Expected: 'Abnormal' | Actual: '<missing>'
556+
# # Then my subject has been updated as follows:
559557
# criteria = {
560558
# "latest episode accumulated result": "Abnormal",
561559
# }
562560
# subject_assertion(nhs_no, criteria)
563561

564-
# # When I view the subject
565-
# screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
562+
nhs_no = "9668188616" # TODO: Remove when subject search is re-added
566563

567-
# # And I select the advance episode option for "Enter Diagnostic Test Outcome"
568-
# SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
569-
# AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
564+
# When I view the subject
565+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
570566

571-
# # And I select Outcome of Diagnostic Test "Refer Another Diagnostic Test"
572-
# DiagnosticTestOutcomePage(page).select_test_outcome_option(
573-
# OutcomeOfDiagnosticTest.REFER_ANOTHER_DIAGNOSTIC_TEST
574-
# )
567+
# And I select the advance episode option for "Enter Diagnostic Test Outcome"
568+
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
569+
AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
570+
571+
# And I select Outcome of Diagnostic Test "Refer Another Diagnostic Test"
572+
DiagnosticTestOutcomePage(page).select_test_outcome_option(
573+
OutcomeOfDiagnosticTest.REFER_ANOTHER_DIAGNOSTIC_TEST
574+
)
575+
576+
# And I select Radiological or Endoscopic Referral value "Radiological"
577+
DiagnosticTestOutcomePage(page).select_referral_procedure_type(
578+
ReferralProcedureType.RADIOLOGICAL
579+
)
580+
581+
# And I select Reason for Onward Referral value "Currently Unsuitable for Endoscopic Referral"
582+
DiagnosticTestOutcomePage(page).select_reason_for_onward_referral(
583+
ReasonForOnwardReferral.CURRENTLY_UNSUITABLE_FOR_ENDOSCOPIC_REFERRAL
584+
)
575585

576-
# # # TODO: And I select Radiological or Endoscopic Referral value "Radiological"
577-
# # # And I select Reason for Onward Referral value "Currently Unsuitable for Endoscopic Referral"
578-
# # # And I set any onward referring clinician
586+
# And I set any onward referring clinician TODO: This step is not selecting a clinician so needs to be fixed
587+
DiagnosticTestOutcomePage(page).select_first_valid_onward_referral_consultant()
579588

580589
# # And I save the Diagnostic Test Outcome
581590
# DiagnosticTestOutcomePage(page).click_save_button()
@@ -586,7 +595,7 @@ def test_scenario_8(page: Page) -> None:
586595
# }
587596
# subject_assertion(nhs_no, criteria)
588597

589-
# # # When I advance the subject's episode for "Post-investigation Appointment Required"
598+
# # When I advance the subject's episode for "Post-investigation Appointment Required"
590599
# screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
591600
# SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
592601
# AdvanceFOBTScreeningEpisodePage(

utils/investigation_dataset.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def complete_dataset_with_args(
422422
"#UI_INTRACOLONIC_SUMMARY_CODE", intracolonic_summary_code
423423
)
424424

425-
# Suspected Fndings
425+
# Suspected Findings
426426
if suspected_findings is not None:
427427
logging.info("Filling out suspected findings")
428428
self.fill_out_suspected_findings(suspected_findings)
@@ -433,19 +433,23 @@ def complete_dataset_with_args(
433433
self.investigation_datasets_pom.click_save_dataset_button()
434434

435435
def fill_out_suspected_findings(self, suspected_findings: dict) -> None:
436-
""" """
437-
self.investigation_datasets_pom.click_show_suspected_findings_details()
438-
439-
if suspected_findings["extracolonic summary code"]:
440-
dropdown = self.page.locator("#UI_EXTRACOLONIC_SUMMARY_CODE")
441-
dropdown.wait_for(state="visible")
442-
self.page.wait_for_function(
443-
"document.querySelector('#UI_EXTRACOLONIC_SUMMARY_CODE').options.length > 1"
444-
)
445-
446-
dropdown.select_option(
447-
value=suspected_findings["extracolonic summary code"]
448-
)
436+
"""
437+
Populates the Suspected Findings section of the Investigation Dataset form.
438+
"""
439+
logging.info("Starting fill_out_suspected_findings")
440+
try:
441+
logging.info("About to click suspected findings details")
442+
self.investigation_datasets_pom.click_show_suspected_findings_details()
443+
logging.info("Clicked suspected findings details successfully")
444+
except Exception as e:
445+
logging.error(f"Error clicking on Show Suspected Findings Details: {e}")
446+
raise
447+
for key, value in suspected_findings.items():
448+
match key:
449+
case "extracolonic summary code":
450+
DatasetFieldUtil(self.page).populate_select_locator_for_field(
451+
"Extracolonic Summary Code", value
452+
)
449453

450454
def fill_out_general_information(self, general_information: dict) -> None:
451455
"""
@@ -638,7 +642,7 @@ def fill_out_radiology_information(self, radiology_data: dict) -> None:
638642
logging.info("Filling out Radiology Information")
639643

640644
self.investigation_datasets_pom.click_show_radiology_information()
641-
645+
self.investigation_datasets_pom.click_show_radiology_failure_information()
642646
# Define mapping for each radiology field and its selector
643647
radiology_map = {
644648
"examination_quality": "#UI_EXAM_QUALITY",

0 commit comments

Comments
 (0)