Skip to content

Commit 051f645

Browse files
committed
wip
1 parent 186d393 commit 051f645

File tree

4 files changed

+68
-81
lines changed

4 files changed

+68
-81
lines changed

pages/datasets/cancer_audit_datasets_page.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def select_first_definitive_teatment_information_option(self, option: str) -> No
175175
NOT_REPORTED_CODE = "202140~~202188"
176176

177177

178-
class ASAGradeOptions(StrEnum):
178+
class CancerASAGradeOptions(StrEnum):
179179
"""Enum for ASA Grade options."""
180180

181181
FIT = "17009"
@@ -186,38 +186,38 @@ class ASAGradeOptions(StrEnum):
186186
NOT_KNOWN = "17015"
187187

188188

189-
class YesNoOptions(StrEnum):
189+
class CancerYesNoOptions(StrEnum):
190190
"""Enum for YesNo options."""
191191

192192
YES = "17058"
193193
NO = "17059"
194194

195195

196-
class RadiologyYesNoOptions(StrEnum):
196+
class CancerRadiologyYesNoOptions(StrEnum):
197197
"""Enum for Yes/No options specific to Radiology fields"""
198198

199199
YES = "17058~~204365"
200200
NO = "17059~~204366"
201201
NOT_REPORTED = "202140"
202202

203203

204-
class TaggingAgentDrugAdministeredOptions(StrEnum):
204+
class CancerTaggingAgentDrugAdministeredOptions(StrEnum):
205205
"""Enum for Tagging Agent Given Drugs Administered"""
206206

207207
YES = "17058~~204368"
208208
NO = "17059"
209209
NOT_REPORTED = "202140"
210210

211211

212-
class MetastasesPresentOptions(StrEnum):
212+
class CancerMetastasesPresentOptions(StrEnum):
213213
"""Enum for Metastases Present options."""
214214

215215
CERTAIN = "17131~~202199"
216216
NONE = "17130"
217217
NOT_REPORTED = NOT_REPORTED_CODE
218218

219219

220-
class FinalPreTreatmentTCategoryOptions(StrEnum):
220+
class CancerFinalPreTreatmentTCategoryOptions(StrEnum):
221221
"""Enum for Final Pre-Treatment T Category options."""
222222

223223
CTX = "17356"
@@ -229,7 +229,7 @@ class FinalPreTreatmentTCategoryOptions(StrEnum):
229229
NOT_REPORTED = NOT_REPORTED_CODE
230230

231231

232-
class FinalPreTreatmentNCategoryOptions(StrEnum):
232+
class CancerFinalPreTreatmentNCategoryOptions(StrEnum):
233233
"""Enum for Final Pre-Treatment N Category options."""
234234

235235
CNX = "202201"
@@ -239,7 +239,7 @@ class FinalPreTreatmentNCategoryOptions(StrEnum):
239239
NOT_REPORTED = NOT_REPORTED_CODE
240240

241241

242-
class ReasonNoTreatmentRecievedOptions(StrEnum):
242+
class CancerReasonNoTreatmentReceivedOptions(StrEnum):
243243
"""Enum for Reason No Treatment Received options."""
244244

245245
ADVANCED_DISEASE = "99016"
@@ -250,7 +250,7 @@ class ReasonNoTreatmentRecievedOptions(StrEnum):
250250
UNKNOWN = "99018"
251251

252252

253-
class PreviouslyExcisedTumorOptions(StrEnum):
253+
class CancerPreviouslyExcisedTumorOptions(StrEnum):
254254
"""Enum for Previously Excised Tumor options."""
255255

256256
YES = "17058~~305403"
@@ -259,14 +259,14 @@ class PreviouslyExcisedTumorOptions(StrEnum):
259259
NOT_REPORTED = "202140"
260260

261261

262-
class TreatmentTypeOptions(StrEnum):
262+
class CancerTreatmentTypeOptions(StrEnum):
263263
"""Enum for Treatment Type options."""
264264

265265
SURGICAL = "202143"
266266
NON_SURGICAL = "202144"
267267

268268

269-
class TreatmentGivenOptions(StrEnum):
269+
class CancerTreatmentGivenOptions(StrEnum):
270270
"""Enum for Treatment Given options."""
271271

272272
CHEMOTHERAPY = "202160~~202184,202217,202218,202219,202220,202221,202222,202223,202224,202225,202226,202227,202228,202287,305395,305397"
@@ -285,14 +285,14 @@ class CancerTreatmentIntentOptions(StrEnum):
285285
NOT_KNOWN = "17373"
286286

287287

288-
class NHSOrPrivateOptions(StrEnum):
288+
class CancerNHSOrPrivateOptions(StrEnum):
289289
"""Enum for NHS or Private options."""
290290

291291
NHS = "202153~~202177,202178"
292292
PRIVATE = "202154~~202179"
293293

294294

295-
class TreatmentProviderLookupOptions(StrEnum):
295+
class CancerTreatmentProviderLookupOptions(StrEnum):
296296
"""Enum for Treatment Provider lookup options."""
297297

298298
ADVANCE_NURSE_PRACTITIONER_1 = "51905"
@@ -321,7 +321,7 @@ class TreatmentProviderLookupOptions(StrEnum):
321321
BUSHBURY_HEALTH_CENTRE = "51801"
322322

323323

324-
class ConsultantLookupOptions(StrEnum):
324+
class CancerConsultantLookupOptions(StrEnum):
325325
"""Enum for Consultant lookup options."""
326326

327327
B_FRAME = "201"

pages/datasets/investigation_dataset_page.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,12 @@ class ExtracolonicSummaryCodeOptions(StrEnum):
15771577
NOT_REPORTED = "202140"
15781578

15791579

1580+
class TaggingAgentDrugAdministeredOptions(StrEnum):
1581+
YES = "17058~~204368"
1582+
NO = "17059"
1583+
NOT_REPORTED = "202140"
1584+
1585+
15801586
# Registry of all known Enums to search when matching string values
15811587
ALL_ENUMS: List[type[Enum]] = [
15821588
obj

tests/regression/regression_tests/fobt_regression_tests/test_scenario_8.py

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22
import logging
3-
from datetime import datetime
43
from playwright.sync_api import Page
54
from pages.datasets.cancer_audit_datasets_page import (
6-
RadiologyYesNoOptions,
5+
CancerRadiologyYesNoOptions,
6+
)
7+
from pages.datasets.investigation_dataset_page import (
78
TaggingAgentDrugAdministeredOptions,
89
YesNoOptions,
910
)
@@ -18,53 +19,22 @@
1819
SegmentalInadequacyOptions,
1920
)
2021
from pages.datasets.subject_datasets_page import SubjectDatasetsPage
21-
from pages.screening_practitioner_appointments.appointment_detail_page import (
22-
AppointmentDetailPage,
23-
)
24-
from utils.calendar_picker import CalendarPicker
25-
from utils.datasets.investigation_datasets import (
26-
get_default_endoscopy_information,
27-
get_default_general_information,
28-
)
29-
from utils.oracle.subject_creation_util import CreateSubjectSteps
3022
from utils.user_tools import UserTools
3123
from utils.subject_assertion import subject_assertion
32-
from utils.call_and_recall_utils import CallAndRecallUtils
3324
from utils import screening_subject_page_searcher
34-
from utils.batch_processing import batch_processing
35-
from utils.fit_kit import FitKitLogged, FitKitGeneration
3625
from pages.screening_subject_search.subject_screening_summary_page import (
3726
SubjectScreeningSummaryPage,
3827
)
39-
from utils.appointments import book_appointments
4028
from pages.logout.log_out_page import LogoutPage
4129
from pages.base_page import BasePage
4230
from pages.screening_subject_search.advance_fobt_screening_episode_page import (
4331
AdvanceFOBTScreeningEpisodePage,
4432
)
45-
from pages.screening_subject_search.record_diagnosis_date_page import (
46-
RecordDiagnosisDatePage,
47-
)
4833
from utils.appointments import AppointmentAttendance
4934
from pages.datasets.colonoscopy_dataset_page import (
5035
ColonoscopyDatasetsPage,
5136
FitForColonoscopySspOptions,
5237
)
53-
from utils.sspi_change_steps import SSPIChangeSteps
54-
from pages.screening_subject_search.reopen_fobt_screening_episode_page import (
55-
ReopenFOBTScreeningEpisodePage,
56-
)
57-
from utils.oracle.oracle import OracleDB
58-
from utils.oracle.subject_selector import SubjectSelector
59-
from classes.subject_selection_query_builder.subject_selection_criteria_key import (
60-
SubjectSelectionCriteriaKey as Key,
61-
)
62-
from pages.screening_subject_search.contact_with_patient_page import (
63-
ContactWithPatientPage,
64-
)
65-
from pages.screening_subject_search.attend_diagnostic_test_page import (
66-
AttendDiagnosticTestPage,
67-
)
6838
from utils.investigation_dataset import InvestigationDatasetCompletion
6939
from pages.screening_subject_search.diagnostic_test_outcome_page import (
7040
DiagnosticTestOutcomePage,
@@ -533,11 +503,11 @@ def test_scenario_8(page: Page) -> None:
533503
# And I set the following fields and values within the Contrast, Tagging & Drug Information:
534504
# And I add the following Additional Bowel Preparation drugs and values within the Investigation Dataset for this subject:
535505
contrast_tagging_and_drug = {
536-
"iv buscopan administered": RadiologyYesNoOptions.NO,
506+
"iv buscopan administered": CancerRadiologyYesNoOptions.NO,
537507
"contraindicated": YesNoOptions.NO,
538-
"iv contrast administered": RadiologyYesNoOptions.NO,
508+
"iv contrast administered": CancerRadiologyYesNoOptions.NO,
539509
"tagging agent given": TaggingAgentDrugAdministeredOptions.YES,
540-
"additional bowel preparation administered": RadiologyYesNoOptions.YES,
510+
"additional bowel preparation administered": CancerRadiologyYesNoOptions.YES,
541511
"drug_type1": DrugTypeOptions.PICOLAX,
542512
"drug_dose1": "1",
543513
}

utils/investigation_dataset.py

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from altair import value
2+
from pandas import options
13
from playwright.sync_api import Page
24
from enum import StrEnum
35
from datetime import datetime
@@ -481,43 +483,52 @@ def fill_out_general_information(self, general_information: dict) -> None:
481483
def fill_out_contrast_tagging_and_drug_information(
482484
self, contrast_tagging_and_drug: dict
483485
) -> None:
484-
# Contrast Tagging & Drug Information
486+
logging.info("🧪 Filling out Contrast, Tagging & Drug Information")
485487
self.investigation_datasets_pom.click_show_contrast_tagging_and_drug_information()
486488

487-
# Use for loop and match-case for contrast tagging and drug fields
489+
field_map = {
490+
"iv buscopan administered": "#UI_BUSCOPAN_ADMINISTERED",
491+
"iv contrast administered": "#UI_CONTRAST_ADMINISTERED",
492+
"tagging agent given": "#UI_TAGGING_AGENT_GIVEN_DRUGS_ADMINISTERED",
493+
"additional bowel preparation administered": "#UI_ADDITIONAL_BOWEL_PREPARATION_ADMINISTERED",
494+
"contraindicated": "#UI_BUSCOPAN_CONTRAINDICATED",
495+
}
496+
normalized_map = {k.strip().lower(): v for k, v in field_map.items()}
497+
488498
for key, value in contrast_tagging_and_drug.items():
489-
match key:
490-
case "iv buscopan administered":
491-
DatasetFieldUtil(self.page).populate_select_locator_for_field(
492-
"IV Buscopan Administered", value
493-
)
494-
case "iv contrast administered":
495-
DatasetFieldUtil(self.page).populate_select_locator_for_field(
496-
"IV Contrast Administered", value
497-
)
498-
case "tagging agent given":
499-
DatasetFieldUtil(self.page).populate_select_locator_for_field(
500-
"Tagging Agent Given", value
499+
normalized_key = key.strip().lower()
500+
501+
if normalized_key in normalized_map:
502+
selector = normalized_map[normalized_key]
503+
504+
if normalized_key == "tagging agent given":
505+
logging.info(
506+
"🔍 Waiting for 'Tagging Agent Given' dropdown to become visible..."
501507
)
502-
case "additional bowel preparation administered":
503-
DatasetFieldUtil(self.page).populate_select_locator_for_field(
504-
"Additional Bowel Preparation Administered", value
508+
self.page.locator(selector).wait_for(state="visible")
509+
options = self.page.locator(selector + " option").all_inner_texts()
510+
logging.info(
511+
f"🧾 Options available in 'Tagging Agent Given': {options}"
505512
)
506-
case "contraindicated":
507-
DatasetFieldUtil(
508-
self.page
509-
).populate_select_locator_for_field_inside_div(
510-
"Contraindicated", "UI_BUSCOPAN_CONTRAINDICATED_ROW", value
513+
logging.info(
514+
f"✅ Dropdown visible. Selecting value: {to_enum_name_or_value(value)}"
511515
)
512-
case k if k.startswith(("drug_type", "drug_dose")):
513-
# Extract all drug-related keys/values from the main dict
514-
drug_info = {
515-
dk: dv
516-
for dk, dv in contrast_tagging_and_drug.items()
517-
if dk.startswith(("drug_type", "drug_dose"))
518-
}
519-
# Call the existing drug filling method once
520-
self.fill_out_drug_information(drug_info)
516+
else:
517+
logging.info(f"Setting {key}: {to_enum_name_or_value(value)}")
518+
519+
self.page.select_option(selector, value)
520+
521+
elif normalized_key.startswith(("drug_type", "drug_dose")):
522+
drug_info = {
523+
dk: dv
524+
for dk, dv in contrast_tagging_and_drug.items()
525+
if dk.strip().lower().startswith(("drug_type", "drug_dose"))
526+
}
527+
self.fill_out_drug_information(drug_info)
528+
break
529+
530+
else:
531+
logging.warning(f"⚠️ Unknown contrast field: {key}")
521532

522533
def fill_out_drug_information(self, drug_information: dict) -> None:
523534
"""

0 commit comments

Comments
 (0)