|
14 | 14 | from pages.screening_practitioner_appointments.book_appointment_page import ( |
15 | 15 | BookAppointmentPage, |
16 | 16 | ) |
17 | | -from pages.screening_subject_search import subject_screening_summary_page |
18 | 17 | from utils.calendar_picker import CalendarPicker |
19 | 18 | from utils.user_tools import UserTools |
20 | 19 | from datetime import datetime |
@@ -133,81 +132,81 @@ def book_appointments(page: Page, screening_centre: str, site: str) -> None: |
133 | 132 | ) |
134 | 133 |
|
135 | 134 |
|
136 | | -def mark_appointment_as_dna(page: Page, non_attendance_reason: str) -> None: |
137 | | - """ |
138 | | - Marks an appointment as DNA (Did Not Attend) |
139 | | - This process starts from the subject screening summary page. |
140 | | -
|
141 | | - This method navigates through the subject's episode and appointment pages, |
142 | | - selects the 'Attendance' radio option, and sets the given DNA reason. |
143 | | -
|
144 | | - Args: |
145 | | - page (Page): Playwright page object. |
146 | | - non_attendance_reason (str): Reason for non-attendance. Must match one of the following: |
147 | | - - "Patient did not attend" |
148 | | - - "Screening Centre did not attend" |
149 | | - - "Patient and Screening Centre did not attend" |
150 | | -
|
151 | | - Raises: |
152 | | - AssertionError: If expected elements are not found or interaction fails. |
153 | | - """ |
154 | | - appointment_detail_page = AppointmentDetailPage(page) |
155 | | - subject_screening_summary_page = SubjectScreeningSummaryPage(page) |
156 | | - episode_events_and_notes_page = EpisodeEventsAndNotesPage(page) |
157 | | - |
158 | | - logging.info( |
159 | | - f"[APPOINTMENT DNA] Starting DNA flow with reason: {non_attendance_reason}" |
160 | | - ) |
161 | | - subject_screening_summary_page.click_list_episodes() |
162 | | - subject_screening_summary_page.click_view_events_link() |
163 | | - episode_events_and_notes_page.click_most_recent_view_appointment_link() |
164 | | - appointment_detail_page.check_attendance_radio() |
165 | | - page.locator("#UI_NON_ATTENDANCE_REASON").select_option(label=non_attendance_reason) |
166 | | - appointment_detail_page.click_save_button(accept_dialog=True) |
167 | | - |
168 | | - logging.info("[APPOINTMENT DNA] DNA flow completed successfully") |
| 135 | +class AppointmentAttendance: |
| 136 | + def __init__(self, page: Page): |
| 137 | + self.page = page |
| 138 | + self.appointment_detail_page = AppointmentDetailPage(page) |
| 139 | + self.subject_screening_summary_page = SubjectScreeningSummaryPage(page) |
| 140 | + self.episode_events_and_notes_page = EpisodeEventsAndNotesPage(page) |
| 141 | + |
| 142 | + def mark_as_dna(self, non_attendance_reason: str) -> None: |
| 143 | + """ |
| 144 | + Marks an appointment as DNA (Did Not Attend) |
| 145 | + This process starts from the subject screening summary page. |
| 146 | +
|
| 147 | + This method navigates through the subject's episode and appointment pages, |
| 148 | + selects the 'Attendance' radio option, and sets the given DNA reason. |
| 149 | +
|
| 150 | + Args: |
| 151 | + page (Page): Playwright page object. |
| 152 | + non_attendance_reason (str): Reason for non-attendance. Must match one of the following: |
| 153 | + - "Patient did not attend" |
| 154 | + - "Screening Centre did not attend" |
| 155 | + - "Patient and Screening Centre did not attend" |
| 156 | +
|
| 157 | + Raises: |
| 158 | + AssertionError: If expected elements are not found or interaction fails. |
| 159 | + """ |
| 160 | + logging.info( |
| 161 | + f"[APPOINTMENT DNA] Starting DNA flow with reason: {non_attendance_reason}" |
| 162 | + ) |
| 163 | + self.subject_screening_summary_page.click_list_episodes() |
| 164 | + self.subject_screening_summary_page.click_view_events_link() |
| 165 | + self.episode_events_and_notes_page.click_most_recent_view_appointment_link() |
| 166 | + self.appointment_detail_page.check_attendance_radio() |
| 167 | + self.page.locator("#UI_NON_ATTENDANCE_REASON").select_option( |
| 168 | + label=non_attendance_reason |
| 169 | + ) |
| 170 | + self.appointment_detail_page.click_save_button(accept_dialog=True) |
169 | 171 |
|
| 172 | + logging.info("[APPOINTMENT DNA] DNA flow completed successfully") |
170 | 173 |
|
171 | | -def mark_appointment_as_attended(page: Page) -> None: |
172 | | - """ |
173 | | - Marks an appointment as attended and logs the auto-filled attendance details. |
174 | | - This process starts from the subject screening summary page. |
| 174 | + def mark_as_attended(self) -> None: |
| 175 | + """ |
| 176 | + Marks an appointment as attended and logs the auto-filled attendance details. |
| 177 | + This process starts from the subject screening summary page. |
175 | 178 |
|
176 | | - This method navigates through the subject's episode and appointment pages, |
177 | | - selects the 'Attendance' radio option, checks the 'Attended' checkbox, |
178 | | - and logs the resulting date and time values. |
| 179 | + This method navigates through the subject's episode and appointment pages, |
| 180 | + selects the 'Attendance' radio option, checks the 'Attended' checkbox, |
| 181 | + and logs the resulting date and time values. |
179 | 182 |
|
180 | | - Args: |
181 | | - page (Page): Playwright page object. |
| 183 | + Args: |
| 184 | + page (Page): Playwright page object. |
182 | 185 |
|
183 | | - Raises: |
184 | | - AssertionError: If expected elements are not found or interaction fails. |
185 | | - """ |
186 | | - appointment_detail_page = AppointmentDetailPage(page) |
187 | | - subject_screening_summary_page = SubjectScreeningSummaryPage(page) |
188 | | - episode_events_and_notes_page = EpisodeEventsAndNotesPage(page) |
189 | | - |
190 | | - logging.info("[APPOINTMENT ATTENDED] Starting attended flow") |
| 186 | + Raises: |
| 187 | + AssertionError: If expected elements are not found or interaction fails. |
| 188 | + """ |
| 189 | + logging.info("[APPOINTMENT ATTENDED] Starting attended flow") |
191 | 190 |
|
192 | | - subject_screening_summary_page.click_list_episodes() |
193 | | - subject_screening_summary_page.click_view_events_link() |
194 | | - episode_events_and_notes_page.click_most_recent_view_appointment_link() |
195 | | - appointment_detail_page.check_attendance_radio() |
| 191 | + self.subject_screening_summary_page.click_list_episodes() |
| 192 | + self.subject_screening_summary_page.click_view_events_link() |
| 193 | + self.episode_events_and_notes_page.click_most_recent_view_appointment_link() |
| 194 | + self.appointment_detail_page.check_attendance_radio() |
196 | 195 |
|
197 | | - # Check the 'Attended' checkbox |
198 | | - attended_checkbox = page.locator("#UI_ATTENDED") |
199 | | - attended_checkbox.check() |
| 196 | + # Check the 'Attended' checkbox |
| 197 | + attended_checkbox = self.page.locator("#UI_ATTENDED") |
| 198 | + attended_checkbox.check() |
200 | 199 |
|
201 | | - # Log the auto-filled attendance details |
202 | | - attended_date = page.locator("#UI_ATTENDED_DATE").input_value() |
203 | | - time_from = page.locator("#UI_ATTENDED_TIME_FROM").input_value() |
204 | | - time_to = page.locator("#UI_ATTENDED_TIME_TO").input_value() |
205 | | - meeting_mode = page.locator("#UI_NEW_MEETING_MODE").input_value() |
| 200 | + # Log the auto-filled attendance details |
| 201 | + attended_date = self.page.locator("#UI_ATTENDED_DATE").input_value() |
| 202 | + time_from = self.page.locator("#UI_ATTENDED_TIME_FROM").input_value() |
| 203 | + time_to = self.page.locator("#UI_ATTENDED_TIME_TO").input_value() |
| 204 | + meeting_mode = self.page.locator("#UI_NEW_MEETING_MODE").input_value() |
206 | 205 |
|
207 | | - logging.info( |
208 | | - f"[APPOINTMENT ATTENDED] How Attended: {meeting_mode}, Date: {attended_date}, Time From: {time_from}, Time To: {time_to}" |
209 | | - ) |
| 206 | + logging.info( |
| 207 | + f"[APPOINTMENT ATTENDED] How Attended: {meeting_mode}, Date: {attended_date}, Time From: {time_from}, Time To: {time_to}" |
| 208 | + ) |
210 | 209 |
|
211 | | - appointment_detail_page.click_save_button(accept_dialog=True) |
| 210 | + self.appointment_detail_page.click_save_button(accept_dialog=True) |
212 | 211 |
|
213 | | - logging.info("[APPOINTMENT ATTENDED] Attended flow completed successfully") |
| 212 | + logging.info("[APPOINTMENT ATTENDED] Attended flow completed successfully") |
0 commit comments