1- # Create a new util that can populate the investigations dataset to get the following
2- # results:
3-
4- # High risk
5- # LNPCP
6- # Normal
7-
8- # This needs to be done as there is a lot of repeat code between the three results
9- # and we need 2 subjects with high risk and LNPCP results.
10- # Also create any utils to reduce the amount of duplicated code
11- # to as close to 0% as possible.
12-
13- # Update compartment 6
14-
15- # Add utility guide
16-
17- # In the code I have added these comments to show the different actions:
18- # This needs to be repeated for 1 subject, age does not matter - Normal Result
19- # This needs to be repeated for two subjects, one old and one not - LNPCP Result
20- # This needs to be repeated for two subjects, one old and one not - High Risk Result
21-
221from playwright .sync_api import Page
232from enum import StrEnum
243import logging
@@ -80,12 +59,22 @@ class InvestigationDatasetResults(StrEnum):
8059
8160
8261class InvestigationDatasetCompletion :
62+ """
63+ This class is used to complete the investigation dataset forms for a subject.
64+ It contains methods to fill out the forms based on the result of the investigation dataset.
65+ """
66+
8367 def __init__ (self , page : Page ):
8468 self .page = page
8569 self .estimate_whole_polyp_size_string = "Estimate of whole polyp size"
8670 self .polyp_access_string = "Polyp Access"
8771
8872 def complete_with_result (self , nhs_no : str , result : str ):
73+ """This method fills out the investigation dataset forms based on the test result and the subject's age.
74+ Args:
75+ nhs_no (str): The NHS number of the subject.
76+ result (str): The result of the investigation dataset.
77+ """
8978 if result == InvestigationDatasetResults .HIGH_RISK :
9079 self .go_to_investigation_datasets_page (nhs_no )
9180 self .default_investigation_dataset_forms ()
@@ -118,6 +107,10 @@ def complete_with_result(self, nhs_no: str, result: str):
118107 logging .error ("Incorrect result entered" )
119108
120109 def go_to_investigation_datasets_page (self , nhs_no ) -> None :
110+ """This method navigates to the investigation datasets page for a subject.
111+ Args:
112+ nhs_no (str): The NHS number of the subject.
113+ """
121114 verify_subject_event_status_by_nhs_no (
122115 self .page , nhs_no , "A323 - Post-investigation Appointment NOT Required"
123116 )
@@ -126,6 +119,7 @@ def go_to_investigation_datasets_page(self, nhs_no) -> None:
126119 SubjectDatasetsPage (self .page ).click_investigation_show_datasets ()
127120
128121 def default_investigation_dataset_forms (self ) -> None :
122+ """This method fills out the first art of the default investigation dataset form."""
129123 # Investigation Dataset
130124 InvestigationDatasetsPage (self .page ).select_site_lookup_option (
131125 SiteLookupOptions .RL401
@@ -145,11 +139,12 @@ def default_investigation_dataset_forms(self) -> None:
145139 DrugTypeOptions .BISACODYL
146140 )
147141 InvestigationDatasetsPage (self .page ).fill_drug_type_dose1 ("10" )
148- # Ensocopy Information
142+ # Endoscopy Information
149143 InvestigationDatasetsPage (self .page ).click_show_endoscopy_information ()
150144 InvestigationDatasetsPage (self .page ).check_endoscope_inserted_yes ()
151145
152146 def default_investigation_dataset_forms_continuation (self ) -> None :
147+ """This method fills out the second part of the default investigation dataset form."""
153148 DatasetFieldUtil (self .page ).populate_select_locator_for_field (
154149 "Bowel preparation quality" , BowelPreparationQualityOptions .GOOD
155150 )
@@ -195,6 +190,7 @@ def default_investigation_dataset_forms_continuation(self) -> None:
195190 )
196191
197192 def investigation_datasets_failure_reason (self ) -> None :
193+ """This method fills out the failure reason section of the investigation dataset form."""
198194 # Failure Information
199195 InvestigationDatasetsPage (self .page ).click_show_failure_information ()
200196 DatasetFieldUtil (self .page ).populate_select_locator_for_field_inside_div (
@@ -204,6 +200,7 @@ def investigation_datasets_failure_reason(self) -> None:
204200 )
205201
206202 def polyps_for_high_risk_result (self ) -> None :
203+ """This method fills out the polyp information section of the investigation dataset form o trigger a high risk result."""
207204 # Polyp Information
208205 InvestigationDatasetsPage (self .page ).click_add_polyp_button ()
209206 DatasetFieldUtil (self .page ).populate_select_locator_for_field_inside_div (
@@ -260,6 +257,7 @@ def polyps_for_high_risk_result(self) -> None:
260257 )
261258
262259 def polyps_for_lnpcp_result (self ) -> None :
260+ """This method fills out the polyp information section of the investigation dataset form to trigger a LNPCP result."""
263261 # Polyp Information
264262 InvestigationDatasetsPage (self .page ).click_add_polyp_button ()
265263 DatasetFieldUtil (self .page ).populate_select_locator_for_field_inside_div (
@@ -279,6 +277,7 @@ def polyps_for_lnpcp_result(self) -> None:
279277 self .polyp1_intervention ()
280278
281279 def polyp1_intervention (self ) -> None :
280+ """This method fills out the intervention section of the investigation dataset form for polyp 1."""
282281 InvestigationDatasetsPage (self .page ).click_polyp1_add_intervention_button ()
283282 DatasetFieldUtil (self .page ).populate_select_locator_for_field_inside_div (
284283 "Modality" ,
@@ -303,18 +302,29 @@ def polyp1_intervention(self) -> None:
303302 )
304303
305304 def save_investigation_dataset (self ) -> None :
305+ """This method saves the investigation dataset form."""
306306 InvestigationDatasetsPage (self .page ).check_dataset_complete_checkbox ()
307307 InvestigationDatasetsPage (self .page ).click_save_dataset_button ()
308308
309309
310310class AfterInvestigationDatasetComplete :
311+ """
312+ This class is used to progress the episode based on the result of the investigation dataset.
313+ It contains methods to handle the different outcomes of the investigation dataset.
314+ """
315+
311316 def __init__ (self , page : Page ) -> None :
312317 self .page = page
313318 self .a318_latest_event_status_string = (
314319 "A318 - Post-investigation Appointment NOT Required - Result Letter Created"
315320 )
316321
317- def progress_episode_based_on_result (self , result : str , younger : bool ):
322+ def progress_episode_based_on_result (self , result : str , younger : bool ) -> None :
323+ """This method progresses the episode based on the result of the investigation dataset.
324+ Args:
325+ result (str): The result of the investigation dataset.
326+ younger (bool): True if the subject is younger than 50, False otherwise.
327+ """
318328 if result == InvestigationDatasetResults .HIGH_RISK :
319329 self .after_high_risk_result ()
320330 if younger :
@@ -334,6 +344,7 @@ def progress_episode_based_on_result(self, result: str, younger: bool):
334344 logging .error ("Incorrect result entered" )
335345
336346 def after_high_risk_result (self ) -> None :
347+ """This method advances an episode that has a high-risk result."""
337348 InvestigationDatasetsPage (self .page ).expect_text_to_be_visible (
338349 "High-risk findings"
339350 )
@@ -361,6 +372,7 @@ def after_high_risk_result(self) -> None:
361372 DiagnosticTestOutcomePage (self .page ).click_save_button ()
362373
363374 def after_lnpcp_result (self ) -> None :
375+ """This method advances an episode that has a LNPCP result."""
364376 InvestigationDatasetsPage (self .page ).expect_text_to_be_visible ("LNPCP" )
365377 BasePage (self .page ).click_back_button ()
366378
@@ -384,7 +396,8 @@ def after_lnpcp_result(self) -> None:
384396 )
385397 DiagnosticTestOutcomePage (self .page ).click_save_button ()
386398
387- def after_normal_result (self ):
399+ def after_normal_result (self ) -> None :
400+ """This method advances an episode that has a normal result."""
388401 InvestigationDatasetsPage (self .page ).expect_text_to_be_visible (
389402 "Normal (No Abnormalities"
390403 )
@@ -417,6 +430,7 @@ def after_normal_result(self):
417430 )
418431
419432 def handover_subject_to_symptomatic_care (self ) -> None :
433+ """This method hands over a subject to symptomatic care."""
420434 SubjectScreeningSummaryPage (self .page ).verify_latest_event_status_value (
421435 "A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
422436 )
@@ -444,7 +458,8 @@ def handover_subject_to_symptomatic_care(self) -> None:
444458 "A385 - Handover into Symptomatic Care"
445459 )
446460
447- def record_diagnosis_date (self ):
461+ def record_diagnosis_date (self ) -> None :
462+ """This method records the diagnosis date for a subject."""
448463 SubjectScreeningSummaryPage (self .page ).verify_latest_event_status_value (
449464 self .a318_latest_event_status_string
450465 )
0 commit comments