Skip to content

Commit 186d393

Browse files
committed
datasets wip
1 parent 05aee1c commit 186d393

File tree

3 files changed

+99
-43
lines changed

3 files changed

+99
-43
lines changed

pages/datasets/cancer_audit_datasets_page.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ class YesNoOptions(StrEnum):
193193
NO = "17059"
194194

195195

196+
class RadiologyYesNoOptions(StrEnum):
197+
"""Enum for Yes/No options specific to Radiology fields"""
198+
199+
YES = "17058~~204365"
200+
NO = "17059~~204366"
201+
NOT_REPORTED = "202140"
202+
203+
204+
class TaggingAgentDrugAdministeredOptions(StrEnum):
205+
"""Enum for Tagging Agent Given Drugs Administered"""
206+
207+
YES = "17058~~204368"
208+
NO = "17059"
209+
NOT_REPORTED = "202140"
210+
211+
196212
class MetastasesPresentOptions(StrEnum):
197213
"""Enum for Metastases Present options."""
198214

tests/regression/regression_tests/fobt_regression_tests/test_scenario_8.py

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import logging
33
from datetime import datetime
44
from playwright.sync_api import Page
5-
from pages.datasets.cancer_audit_datasets_page import YesNoOptions
5+
from pages.datasets.cancer_audit_datasets_page import (
6+
RadiologyYesNoOptions,
7+
TaggingAgentDrugAdministeredOptions,
8+
YesNoOptions,
9+
)
610
from pages.datasets.investigation_dataset_page import (
711
DrugTypeOptions,
812
ExaminationQualityOptions,
@@ -475,40 +479,40 @@ def test_scenario_8(page: Page) -> None:
475479
# screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
476480
# SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
477481

478-
# And I select Diagnostic Test Type "CT Colonography"
479-
AdvanceFOBTScreeningEpisodePage(page).select_test_type_dropdown_option(
480-
"CT Colonography"
481-
)
482-
# And I enter a Diagnostic Test First Offered Appointment Date of "today"
483-
AdvanceFOBTScreeningEpisodePage(page).click_calendar_button()
484-
CalendarPicker(page).v1_calender_picker(datetime.today())
482+
# # And I select Diagnostic Test Type "CT Colonography"
483+
# AdvanceFOBTScreeningEpisodePage(page).select_test_type_dropdown_option(
484+
# "CT Colonography"
485+
# )
486+
# # And I enter a Diagnostic Test First Offered Appointment Date of "today"
487+
# AdvanceFOBTScreeningEpisodePage(page).click_calendar_button()
488+
# CalendarPicker(page).v1_calender_picker(datetime.today())
485489

486-
# And I advance the subject's episode for "Invite for Diagnostic Test >>"
487-
AdvanceFOBTScreeningEpisodePage(page).click_invite_for_diagnostic_test_button()
490+
# # And I advance the subject's episode for "Invite for Diagnostic Test >>"
491+
# AdvanceFOBTScreeningEpisodePage(page).click_invite_for_diagnostic_test_button()
488492

489-
# Then my subject has been updated as follows:
490-
criteria = {
491-
"which diagnostic test": "Latest test in latest episode",
492-
"diagnostic test proposed type": "CT Colonography",
493-
"latest event status": "A59 Invited for Diagnostic Test",
494-
}
495-
subject_assertion(nhs_no, criteria)
493+
# # Then my subject has been updated as follows:
494+
# criteria = {
495+
# "which diagnostic test": "Latest test in latest episode",
496+
# "diagnostic test proposed type": "CT Colonography",
497+
# "latest event status": "A59 Invited for Diagnostic Test",
498+
# }
499+
# subject_assertion(nhs_no, criteria)
496500

497-
# When I select the advance episode option for "Attend Diagnostic Test"
498-
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
499-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
500-
AdvanceFOBTScreeningEpisodePage(page).click_attend_diagnostic_test_button()
501+
# # When I select the advance episode option for "Attend Diagnostic Test"
502+
# screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
503+
# SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
504+
# AdvanceFOBTScreeningEpisodePage(page).click_attend_diagnostic_test_button()
501505

502-
# And I attend the subject's diagnostic test today
503-
AttendDiagnosticTestPage(page).click_calendar_button()
504-
CalendarPicker(page).v1_calender_picker(datetime.today())
505-
AttendDiagnosticTestPage(page).click_save_button()
506+
# # And I attend the subject's diagnostic test today
507+
# AttendDiagnosticTestPage(page).click_calendar_button()
508+
# CalendarPicker(page).v1_calender_picker(datetime.today())
509+
# AttendDiagnosticTestPage(page).click_save_button()
506510

507-
# Then my subject has been updated as follows:
508-
criteria = {
509-
"latest event status": "A259 Attended Diagnostic Test",
510-
}
511-
subject_assertion(nhs_no, criteria)
511+
# # Then my subject has been updated as follows:
512+
# criteria = {
513+
# "latest event status": "A259 Attended Diagnostic Test",
514+
# }
515+
# subject_assertion(nhs_no, criteria)
512516

513517
# When I view the subject
514518
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
@@ -529,11 +533,11 @@ def test_scenario_8(page: Page) -> None:
529533
# And I set the following fields and values within the Contrast, Tagging & Drug Information:
530534
# And I add the following Additional Bowel Preparation drugs and values within the Investigation Dataset for this subject:
531535
contrast_tagging_and_drug = {
532-
"iv buscopan administered": YesNoOptions.NO,
536+
"iv buscopan administered": RadiologyYesNoOptions.NO,
533537
"contraindicated": YesNoOptions.NO,
534-
"iv contrast administered": YesNoOptions.NO,
535-
"tagging agent given": YesNoOptions.YES,
536-
"additional bowel preparation administered": YesNoOptions.YES,
538+
"iv contrast administered": RadiologyYesNoOptions.NO,
539+
"tagging agent given": TaggingAgentDrugAdministeredOptions.YES,
540+
"additional bowel preparation administered": RadiologyYesNoOptions.YES,
537541
"drug_type1": DrugTypeOptions.PICOLAX,
538542
"drug_dose1": "1",
539543
}

utils/investigation_dataset.py

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,23 @@ def complete_dataset_with_args(
424424
self.investigation_datasets_pom.click_save_dataset_button()
425425

426426
def fill_out_general_information(self, general_information: dict) -> None:
427+
"""
428+
Populates the General Information section of the Investigation Dataset form.
429+
430+
This method fills in site, practitioner, clinician, and radiologist details,
431+
as well as referral fitness and aspirant endoscopist status. It gracefully handles
432+
optional fields and skips any that are not provided in the input dictionary.
433+
434+
Args:
435+
general_information (dict): A dictionary containing general dataset fields.
436+
Expected keys include:
437+
- "site" (int): Index for site lookup dropdown.
438+
- "practitioner" (int): Index for practitioner dropdown.
439+
- "testing clinician" (int): Index for testing clinician dropdown.
440+
- "reporting radiologist" (Optional[int]): Index for radiologist dropdown.
441+
- "fit for subsequent endoscopic referral" (Optional[str]): Enum value for referral fitness.
442+
- "aspirant endoscopist" (Optional[int or None]): Index for aspirant dropdown, or None to mark absence.
443+
"""
427444
self.investigation_datasets_pom.select_site_lookup_option_index(
428445
general_information["site"]
429446
)
@@ -433,28 +450,33 @@ def fill_out_general_information(self, general_information: dict) -> None:
433450
self.investigation_datasets_pom.select_testing_clinician_option_index(
434451
general_information["testing clinician"]
435452
)
436-
if general_information["reporting radiologist"]:
453+
454+
if general_information.get("reporting radiologist") is not None:
437455
InvestigationDatasetsPage(
438456
self.page
439457
).select_reporting_radiologist_option_index(
440458
general_information["reporting radiologist"]
441459
)
442-
if general_information["fit for subsequent endoscopic referral"]:
460+
461+
if (
462+
general_information.get("fit for subsequent endoscopic referral")
463+
is not None
464+
):
443465
DatasetFieldUtil(self.page).populate_select_locator_for_field(
444466
"Fit for Subsequent Endoscopic Referral",
445467
general_information["fit for subsequent endoscopic referral"],
446468
)
447-
if general_information["aspirant endoscopist"]:
448-
if general_information["aspirant endoscopist"] is None:
469+
470+
if "aspirant endoscopist" in general_information:
471+
aspirant = general_information["aspirant endoscopist"]
472+
if aspirant is None:
449473
InvestigationDatasetsPage(
450474
self.page
451475
).check_aspirant_endoscopist_not_present()
452476
else:
453477
InvestigationDatasetsPage(
454478
self.page
455-
).select_aspirant_endoscopist_option_index(
456-
general_information["aspirant endoscopist"]
457-
)
479+
).select_aspirant_endoscopist_option_index(aspirant)
458480

459481
def fill_out_contrast_tagging_and_drug_information(
460482
self, contrast_tagging_and_drug: dict
@@ -537,11 +559,25 @@ def fill_out_tagging_agent_given_drug_information(
537559
"""
538560
This method completes the tagging agent given drug information section of the investigation dataset.
539561
Args:
540-
drug_information (dict): A dictionary containing the drug types and dosages.
562+
drug_information (dict): A dictionary containing the drug types, dosages, and tagging agent status.
563+
Expected keys:
564+
- "tagging agent given": Enum value for tagging agent administered (e.g. YES/NO)
565+
- "drug_type{n}": Enum value for drug type at index n
566+
- "drug_dose{n}": String value for drug dose at index n
541567
"""
542568
logging.info("Filling out tagging agent given drug information")
543569

544-
# Define mapping for each drug type/dose prefix and their selectors
570+
# Handle tagging agent administered status
571+
if "tagging agent given" in drug_information:
572+
logging.info(
573+
f"Setting tagging agent given: {to_enum_name_or_value(drug_information['tagging agent given'])}"
574+
)
575+
self.page.select_option(
576+
"#UI_TAGGING_AGENT_GIVEN_DRUGS_ADMINISTERED",
577+
drug_information["tagging agent given"],
578+
)
579+
580+
# Define mapping for drug type/dose fields
545581
drug_map = {
546582
"drug_type": ("#UI_TAGGING_AGENT_GIVEN_DRUG{}", True),
547583
"drug_dose": ("#UI_TAGGING_AGENT_GIVEN_DRUG_DOSE{}", False),

0 commit comments

Comments
 (0)