1111from pages .datasets .subject_datasets_page import SubjectDatasetsPage
1212from utils .calendar_picker import CalendarPicker
1313from datetime import datetime
14+ from pages .screening_subject_search .record_diagnosis_date_page import (
15+ RecordDiagnosisDatePage ,
16+ )
1417from pages .datasets .investigation_dataset_page import (
1518 InvestigationDatasetsPage ,
1619 SiteLookupOptions ,
@@ -230,6 +233,36 @@ def after_lnpcp_result(page: Page) -> None:
230233 page .get_by_role ("button" , name = "Save" ).click ()
231234
232235
236+ def handover_subject_to_symptomatic_care (page : Page ) -> None :
237+ SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
238+ "A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
239+ )
240+ SubjectScreeningSummaryPage (page ).click_advance_fobt_screening_episode_button ()
241+
242+ # The following code is on the advance fobt screening episode page
243+ page .get_by_role ("button" , name = "Handover into Symptomatic Care" ).click ()
244+
245+ # The following code is on the handover into symptomatic care page
246+ page .get_by_label ("Referral" ).select_option ("20445" )
247+ page .get_by_role ("button" , name = "Calendar" ).click ()
248+ CalendarPicker (page ).v1_calender_picker (datetime .today ())
249+ page .locator ("#UI_NS_CONSULTANT_PIO_SELECT_LINK" ).click ()
250+ option_locator = page .locator (
251+ '[value="201"]:visible'
252+ ) # Here value '201' is referring to Consultant B, Frame
253+ option_locator .wait_for (state = "visible" )
254+ option_locator .click ()
255+ page .get_by_role ("textbox" , name = "Notes" ).click ()
256+ page .get_by_role ("textbox" , name = "Notes" ).fill ("Test Automation" )
257+ page .once ("dialog" , lambda dialog : dialog .accept ())
258+ page .get_by_role ("button" , name = "Save" ).click ()
259+
260+ SubjectScreeningSummaryPage (page ).wait_for_page_title ()
261+ SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
262+ "A385 - Handover into Symptomatic Care"
263+ )
264+
265+
233266@pytest .mark .vpn_required
234267@pytest .mark .smokescreen
235268@pytest .mark .compartment6
@@ -248,7 +281,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
248281
249282 # This needs to be repeated for two subjects, one old and one not - High Risk Result
250283 # Older patient
251- nhs_no = "9056553305 "
284+ nhs_no = "9109877185 "
252285 go_to_investigation_datasets_page (page , nhs_no )
253286
254287 # The following code is on the investigation datasets page
@@ -260,35 +293,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
260293 save_investigation_dataset (page )
261294 after_high_risk_result (page )
262295
263- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
264- "A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
265- )
266- SubjectScreeningSummaryPage (page ).click_advance_fobt_screening_episode_button ()
267-
268- # The following code is on the advance fobt screening episode page
269- page .get_by_role ("button" , name = "Handover into Symptomatic Care" ).click ()
270-
271- # The following code is on the handover into symptomatic care page
272- page .get_by_label ("Referral" ).select_option ("20445" )
273- page .get_by_role ("button" , name = "Calendar" ).click ()
274- CalendarPicker (page ).v1_calender_picker (datetime .today ())
275- page .locator ("#UI_NS_CONSULTANT_PIO_SELECT_LINK" ).click ()
276- option_locator = page .locator (
277- '[value="201"]:visible'
278- ) # Here value '201' is refering to Consultant B, Frame
279- option_locator .wait_for (state = "visible" )
280- option_locator .click ()
281- page .get_by_role ("textbox" , name = "Notes" ).click ()
282- page .get_by_role ("textbox" , name = "Notes" ).fill ("Test Automation" )
283- page .once ("dialog" , lambda dialog : dialog .accept ())
284- page .get_by_role ("button" , name = "Save" ).click ()
285-
286- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
287- "A385 - Handover into Symptomatic Care"
288- )
296+ handover_subject_to_symptomatic_care (page )
289297
290298 # Younger patient
291- nhs_no = "9867208471 "
299+ nhs_no = "9624131880 "
292300 go_to_investigation_datasets_page (page , nhs_no )
293301
294302 # The following code is on the investigation datasets page
@@ -309,17 +317,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
309317 page .get_by_role ("button" , name = "Record Diagnosis Date" ).click ()
310318
311319 # The following code is on the record diagnosis date page
312- page .locator ("#diagnosisDate" ).click ()
313- CalendarPicker (page ).v2_calendar_picker (datetime .today ())
314- page .get_by_role ("button" , name = "Save" ).click ()
320+ RecordDiagnosisDatePage (page ).enter_date_in_diagnosis_date_field (datetime .today ())
321+ RecordDiagnosisDatePage (page ).click_save_button ()
315322
316323 SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
317324 "A318 - Post-investigation Appointment NOT Required - Result Letter Created"
318325 )
319326
320327 # This needs to be repeated for two subjects, one old and one not - LNPCP Result
321328 # Older patient
322- nhs_no = "9840013254 "
329+ nhs_no = "9648064792 "
323330 go_to_investigation_datasets_page (page , nhs_no )
324331
325332 # The following code is on the investigation datasets page
@@ -331,35 +338,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
331338 save_investigation_dataset (page )
332339 after_lnpcp_result (page )
333340
334- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
335- "A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
336- )
337- SubjectScreeningSummaryPage (page ).click_advance_fobt_screening_episode_button ()
338-
339- # The following code is on the advance fobt screening episode page
340- page .get_by_role ("button" , name = "Handover into Symptomatic Care" ).click ()
341-
342- # The following code is on the handover into symptomatic care page
343- page .get_by_label ("Referral" ).select_option ("20445" )
344- page .get_by_role ("button" , name = "Calendar" ).click ()
345- CalendarPicker (page ).v1_calender_picker (datetime .today ())
346- page .locator ("#UI_NS_CONSULTANT_PIO_SELECT_LINK" ).click ()
347- option_locator = page .locator (
348- '[value="201"]:visible'
349- ) # Here value '201' is refering to Consultant B, Frame
350- option_locator .wait_for (state = "visible" )
351- option_locator .click ()
352- page .get_by_role ("textbox" , name = "Notes" ).click ()
353- page .get_by_role ("textbox" , name = "Notes" ).fill ("Test Automation" )
354- page .once ("dialog" , lambda dialog : dialog .accept ())
355- page .get_by_role ("button" , name = "Save" ).click ()
356-
357- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
358- "A385 - Handover into Symptomatic Care"
359- )
341+ handover_subject_to_symptomatic_care (page )
360342
361343 # Younger patient
362- nhs_no = "9477527106 "
344+ nhs_no = "9627060208 "
363345 go_to_investigation_datasets_page (page , nhs_no )
364346
365347 # The following code is on the investigation datasets page
@@ -379,18 +361,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
379361 page .get_by_role ("button" , name = "Record Diagnosis Date" ).click ()
380362
381363 # The following code is on the record diagnosis date page
382- page .locator ("#diagnosisDate" ).click ()
383- CalendarPicker (page ).v2_calendar_picker (datetime .today ())
384- page .locator ("#diagnosisDate" ).press ("Enter" )
385- page .get_by_role ("button" , name = "Save" ).click ()
364+ RecordDiagnosisDatePage (page ).enter_date_in_diagnosis_date_field (datetime .today ())
365+ RecordDiagnosisDatePage (page ).click_save_button ()
386366
387367 SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
388368 "A318 - Post-investigation Appointment NOT Required - Result Letter Created"
389369 )
390370
391371 # This needs to be repeated for 1 subject, age does not matter - Normal Result
392- nhs_no = "9936724968 "
393- go_to_investigation_datasets_page (page , nhs_no )
372+ nhs_no_normal = "9965184321 "
373+ go_to_investigation_datasets_page (page , nhs_no_normal )
394374
395375 # The following code is on the investigation datasets page
396376 default_investigation_dataset_forms (page )
@@ -431,18 +411,8 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
431411 page .get_by_role ("button" , name = "Record Diagnosis Date" ).click ()
432412
433413 # The following code is on the record diagnosis date page
434- page .locator ("#diagnosisDate" ).click ()
435- CalendarPicker (page ).v2_calendar_picker (datetime .today ())
436- page .get_by_role ("button" , name = "Save" ).click ()
437-
438- # Modification needs to be done to accept this list. it should check if any of the values in this list are present. Something like the following:
439- # def get_first_visible_cell(page, values):
440- # if isinstance(values, str):
441- # values = [values]
442- # for name in values:
443- # locator = page.get_by_role("cell", name=name)
444- # if locator.is_visible():
445- # return locator
414+ RecordDiagnosisDatePage (page ).enter_date_in_diagnosis_date_field (datetime .today ())
415+ RecordDiagnosisDatePage (page ).click_save_button ()
446416
447417 batch_processing (
448418 page ,
@@ -455,6 +425,11 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
455425 ],
456426 )
457427
428+ # This is to check for the status of a normal subject as this NHS Number cannot be retrieved from the DB
429+ verify_subject_event_status_by_nhs_no (
430+ page , nhs_no_normal , "S61 - Normal (No Abnormalities Found)"
431+ )
432+
458433 batch_processing (
459434 page ,
460435 "A385" ,
0 commit comments