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 ,
@@ -234,6 +237,36 @@ def after_lnpcp_result(page: Page) -> None:
234237 page .get_by_role ("button" , name = "Save" ).click ()
235238
236239
240+ def handover_subject_to_symptomatic_care (page : Page ) -> None :
241+ SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
242+ "A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
243+ )
244+ SubjectScreeningSummaryPage (page ).click_advance_fobt_screening_episode_button ()
245+
246+ # The following code is on the advance fobt screening episode page
247+ page .get_by_role ("button" , name = "Handover into Symptomatic Care" ).click ()
248+
249+ # The following code is on the handover into symptomatic care page
250+ page .get_by_label ("Referral" ).select_option ("20445" )
251+ page .get_by_role ("button" , name = "Calendar" ).click ()
252+ CalendarPicker (page ).v1_calender_picker (datetime .today ())
253+ page .locator ("#UI_NS_CONSULTANT_PIO_SELECT_LINK" ).click ()
254+ option_locator = page .locator (
255+ '[value="201"]:visible'
256+ ) # Here value '201' is referring to Consultant B, Frame
257+ option_locator .wait_for (state = "visible" )
258+ option_locator .click ()
259+ page .get_by_role ("textbox" , name = "Notes" ).click ()
260+ page .get_by_role ("textbox" , name = "Notes" ).fill ("Test Automation" )
261+ page .once ("dialog" , lambda dialog : dialog .accept ())
262+ page .get_by_role ("button" , name = "Save" ).click ()
263+
264+ SubjectScreeningSummaryPage (page ).wait_for_page_title ()
265+ SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
266+ "A385 - Handover into Symptomatic Care"
267+ )
268+
269+
237270@pytest .mark .vpn_required
238271@pytest .mark .smokescreen
239272@pytest .mark .compartment6
@@ -252,7 +285,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
252285
253286 # This needs to be repeated for two subjects, one old and one not - High Risk Result
254287 # Older patient
255- nhs_no = "9056553305 "
288+ nhs_no = "9109877185 "
256289 go_to_investigation_datasets_page (page , nhs_no )
257290
258291 # The following code is on the investigation datasets page
@@ -264,35 +297,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
264297 save_investigation_dataset (page )
265298 after_high_risk_result (page )
266299
267- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
268- "A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
269- )
270- SubjectScreeningSummaryPage (page ).click_advance_fobt_screening_episode_button ()
271-
272- # The following code is on the advance fobt screening episode page
273- AdvanceFOBTScreeningEpisodePage (page ).click_handover_into_symptomatic_care_button ()
274-
275- # The following code is on the handover into symptomatic care page
276- page .get_by_label ("Referral" ).select_option ("20445" )
277- page .get_by_role ("button" , name = "Calendar" ).click ()
278- CalendarPicker (page ).v1_calender_picker (datetime .today ())
279- page .locator ("#UI_NS_CONSULTANT_PIO_SELECT_LINK" ).click ()
280- option_locator = page .locator (
281- '[value="201"]:visible'
282- ) # Here value '201' is refering to Consultant B, Frame
283- option_locator .wait_for (state = "visible" )
284- option_locator .click ()
285- page .get_by_role ("textbox" , name = "Notes" ).click ()
286- page .get_by_role ("textbox" , name = "Notes" ).fill ("Test Automation" )
287- page .once ("dialog" , lambda dialog : dialog .accept ())
288- page .get_by_role ("button" , name = "Save" ).click ()
289-
290- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
291- "A385 - Handover into Symptomatic Care"
292- )
300+ handover_subject_to_symptomatic_care (page )
293301
294302 # Younger patient
295- nhs_no = "9867208471 "
303+ nhs_no = "9624131880 "
296304 go_to_investigation_datasets_page (page , nhs_no )
297305
298306 # The following code is on the investigation datasets page
@@ -313,17 +321,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
313321 AdvanceFOBTScreeningEpisodePage (page ).click_record_diagnosis_date_button ()
314322
315323 # The following code is on the record diagnosis date page
316- page .locator ("#diagnosisDate" ).click ()
317- CalendarPicker (page ).v2_calendar_picker (datetime .today ())
318- page .get_by_role ("button" , name = "Save" ).click ()
324+ RecordDiagnosisDatePage (page ).enter_date_in_diagnosis_date_field (datetime .today ())
325+ RecordDiagnosisDatePage (page ).click_save_button ()
319326
320327 SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
321328 "A318 - Post-investigation Appointment NOT Required - Result Letter Created"
322329 )
323330
324331 # This needs to be repeated for two subjects, one old and one not - LNPCP Result
325332 # Older patient
326- nhs_no = "9840013254 "
333+ nhs_no = "9648064792 "
327334 go_to_investigation_datasets_page (page , nhs_no )
328335
329336 # The following code is on the investigation datasets page
@@ -335,35 +342,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
335342 save_investigation_dataset (page )
336343 after_lnpcp_result (page )
337344
338- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
339- "A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
340- )
341- SubjectScreeningSummaryPage (page ).click_advance_fobt_screening_episode_button ()
342-
343- # The following code is on the advance fobt screening episode page
344- page .get_by_role ("button" , name = "Handover into Symptomatic Care" ).click ()
345-
346- # The following code is on the handover into symptomatic care page
347- page .get_by_label ("Referral" ).select_option ("20445" )
348- page .get_by_role ("button" , name = "Calendar" ).click ()
349- CalendarPicker (page ).v1_calender_picker (datetime .today ())
350- page .locator ("#UI_NS_CONSULTANT_PIO_SELECT_LINK" ).click ()
351- option_locator = page .locator (
352- '[value="201"]:visible'
353- ) # Here value '201' is refering to Consultant B, Frame
354- option_locator .wait_for (state = "visible" )
355- option_locator .click ()
356- page .get_by_role ("textbox" , name = "Notes" ).click ()
357- page .get_by_role ("textbox" , name = "Notes" ).fill ("Test Automation" )
358- page .once ("dialog" , lambda dialog : dialog .accept ())
359- page .get_by_role ("button" , name = "Save" ).click ()
360-
361- SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
362- "A385 - Handover into Symptomatic Care"
363- )
345+ handover_subject_to_symptomatic_care (page )
364346
365347 # Younger patient
366- nhs_no = "9477527106 "
348+ nhs_no = "9627060208 "
367349 go_to_investigation_datasets_page (page , nhs_no )
368350
369351 # The following code is on the investigation datasets page
@@ -383,18 +365,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
383365 page .get_by_role ("button" , name = "Record Diagnosis Date" ).click ()
384366
385367 # The following code is on the record diagnosis date page
386- page .locator ("#diagnosisDate" ).click ()
387- CalendarPicker (page ).v2_calendar_picker (datetime .today ())
388- page .locator ("#diagnosisDate" ).press ("Enter" )
389- page .get_by_role ("button" , name = "Save" ).click ()
368+ RecordDiagnosisDatePage (page ).enter_date_in_diagnosis_date_field (datetime .today ())
369+ RecordDiagnosisDatePage (page ).click_save_button ()
390370
391371 SubjectScreeningSummaryPage (page ).verify_latest_event_status_value (
392372 "A318 - Post-investigation Appointment NOT Required - Result Letter Created"
393373 )
394374
395375 # This needs to be repeated for 1 subject, age does not matter - Normal Result
396- nhs_no = "9936724968 "
397- go_to_investigation_datasets_page (page , nhs_no )
376+ nhs_no_normal = "9965184321 "
377+ go_to_investigation_datasets_page (page , nhs_no_normal )
398378
399379 # The following code is on the investigation datasets page
400380 default_investigation_dataset_forms (page )
@@ -435,18 +415,8 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
435415 AdvanceFOBTScreeningEpisodePage (page ).click_record_diagnosis_date_button ()
436416
437417 # The following code is on the record diagnosis date page
438- page .locator ("#diagnosisDate" ).click ()
439- CalendarPicker (page ).v2_calendar_picker (datetime .today ())
440- page .get_by_role ("button" , name = "Save" ).click ()
441-
442- # 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:
443- # def get_first_visible_cell(page, values):
444- # if isinstance(values, str):
445- # values = [values]
446- # for name in values:
447- # locator = page.get_by_role("cell", name=name)
448- # if locator.is_visible():
449- # return locator
418+ RecordDiagnosisDatePage (page ).enter_date_in_diagnosis_date_field (datetime .today ())
419+ RecordDiagnosisDatePage (page ).click_save_button ()
450420
451421 batch_processing (
452422 page ,
@@ -459,6 +429,11 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
459429 ],
460430 )
461431
432+ # This is to check for the status of a normal subject as this NHS Number cannot be retrieved from the DB
433+ verify_subject_event_status_by_nhs_no (
434+ page , nhs_no_normal , "S61 - Normal (No Abnormalities Found)"
435+ )
436+
462437 batch_processing (
463438 page ,
464439 "A385" ,
0 commit comments