|
4 | 4 | import logging |
5 | 5 | from typing import List |
6 | 6 | from utils.calendar_picker import CalendarPicker |
| 7 | +from enum import Enum |
| 8 | + |
| 9 | + |
| 10 | +class ContactDirection(Enum): |
| 11 | + TO_PATIENT = "20159" |
| 12 | + FROM_PATIENT = "20160" |
| 13 | + |
| 14 | + |
| 15 | +class ContactMethod(Enum): |
| 16 | + IN_PERSON = "16028" |
| 17 | + TELEPHONE = "16029" |
| 18 | + VISIT = "16030" |
| 19 | + LETTER = "20012" |
7 | 20 |
|
8 | 21 |
|
9 | 22 | class AdvanceFOBTScreeningEpisodePage(BasePage): |
@@ -85,9 +98,10 @@ def __init__(self, page: Page): |
85 | 98 | ) |
86 | 99 | # Contact recording locators |
87 | 100 | self.contact_direction_dropdown = self.page.get_by_label("Contact Direction") |
88 | | - self.contact_type_dropdown = self.page.get_by_label( |
89 | | - "Contact made between patient" |
| 101 | + self.contact_made_between_dropdown = self.page.get_by_label( |
| 102 | + "Contact made between patient and" |
90 | 103 | ) |
| 104 | + self.contact_method_dropdown = self.page.get_by_label("Contact Method") |
91 | 105 | self.call_date_input = self.page.locator("#UI_CALL_DATE") |
92 | 106 | self.start_time_input = self.page.locator("#UI_START_TIME") |
93 | 107 | self.end_time_input = self.page.locator("#UI_END_TIME") |
@@ -259,10 +273,13 @@ def record_contact_close_episode_no_contact(self) -> None: |
259 | 273 | "[CONTACT RECORD] Starting contact recording flow with outcome: Close Episode - No Contact" |
260 | 274 | ) |
261 | 275 |
|
262 | | - # Step 1: Select direction and contact type |
263 | | - self.contact_direction_dropdown.select_option("20159") |
264 | | - self.contact_type_dropdown.select_option("1171") |
265 | | - logging.info("[CONTACT RECORD] Selected direction and contact type") |
| 276 | + # Step 1: Select direction and contact method and practitioner |
| 277 | + self.contact_direction_dropdown.select_option(ContactDirection.TO_PATIENT.value) |
| 278 | + self.contact_method_dropdown.select_option(ContactMethod.TELEPHONE.value) |
| 279 | + self.select_any_practitioner() |
| 280 | + logging.info( |
| 281 | + "[CONTACT RECORD] Selected direction, contact method, and practitioner" |
| 282 | + ) |
266 | 283 |
|
267 | 284 | # Step 2: Pick calendar date using V1 calendar picker |
268 | 285 | calendar_picker = CalendarPicker(self.page) |
@@ -359,3 +376,23 @@ def click_redirect_to_reestablish_suitability_for_diagnostic_test_repatient_cont |
359 | 376 | self.safe_accept_dialog( |
360 | 377 | self.redirect_to_reestablish_suitability_for_diagnostic_test_repatient_contact |
361 | 378 | ) |
| 379 | + |
| 380 | + def select_any_practitioner(self) -> None: |
| 381 | + """ |
| 382 | + Selects any practitioner from the 'Contact made between patient and' dropdown. |
| 383 | + Skips the empty default option and selects the first available practitioner. |
| 384 | + """ |
| 385 | + logging.info("[CONTACT RECORD] Selecting any practitioner from dropdown") |
| 386 | + |
| 387 | + # Get all available options |
| 388 | + options = self.contact_made_between_dropdown.locator("option").all() |
| 389 | + for option in options: |
| 390 | + value = option.get_attribute("value") |
| 391 | + if value and value.strip(): |
| 392 | + self.contact_made_between_dropdown.select_option(value) |
| 393 | + logging.info( |
| 394 | + f"[CONTACT RECORD] Selected practitioner with value: {value}" |
| 395 | + ) |
| 396 | + return |
| 397 | + |
| 398 | + logging.warning("[CONTACT RECORD] No valid practitioner found to select") |
0 commit comments