|
| 1 | +# Utility Guide: Investigation Dataset Utility |
| 2 | + |
| 3 | +The Investigation Dataset Utility provides methods to fill out the investigation dataset forms, and progress episodes, based on the age of the subject and the test results. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Utility Guide: Investigation Dataset Utility](#utility-guide-investigation-dataset-utility) |
| 8 | + - [Table of Contents](#table-of-contents) |
| 9 | + - [Using the Investigation Dataset Utility](#using-the-investigation-dataset-utility) |
| 10 | + - [Investigation Dataset Completion - Required Arguments](#investigation-dataset-completion---required-arguments) |
| 11 | + - [After Investigation Dataset Complete - Required Arguments](#after-investigation-dataset-complete---required-arguments) |
| 12 | + - [Investigation Dataset Specific Functions](#investigation-dataset-specific-functions) |
| 13 | + - [Example Usage](#example-usage) |
| 14 | + |
| 15 | +## Using the Investigation Dataset Utility |
| 16 | + |
| 17 | +To use the Investigation Dataset Utility, import the `InvestigationDatasetCompletion` and/or `AfterInvestigationDatasetComplete` classes from the `utils.investigation_dataset` directory into your test file and call the relevant methods as required. |
| 18 | + |
| 19 | +## Investigation Dataset Completion - Required Arguments |
| 20 | + |
| 21 | +The methods in this utility require specific arguments. Below is a summary of the required arguments for key methods: |
| 22 | + |
| 23 | + Required arguments for initialization: |
| 24 | + - page (Page): The Playwright Page object used for browser automation. |
| 25 | + |
| 26 | + Required arguments for main method: |
| 27 | + - nhs_no (str): The NHS number of the subject. |
| 28 | + - result (str): The result of the investigation dataset. Should be one of InvestigationDatasetResults (HIGH_RISK, LNPCP, NORMAL). |
| 29 | + |
| 30 | +## After Investigation Dataset Complete - Required Arguments |
| 31 | + |
| 32 | +The methods in this utility require specific arguments. Below is a summary of the required arguments for key methods: |
| 33 | + |
| 34 | + Required arguments for initialization: |
| 35 | + - page (Page): The Playwright Page object used for browser automation. |
| 36 | + |
| 37 | + Required arguments for main method: |
| 38 | + - result (str): The result of the investigation dataset. Should be one of InvestigationDatasetResults (HIGH_RISK, LNPCP, NORMAL). |
| 39 | + - younger (bool): True if the subject is younger than 50, False otherwise. |
| 40 | + |
| 41 | + |
| 42 | +## Investigation Dataset Specific Functions |
| 43 | + |
| 44 | +The `investigation_dataset` utility is used to complete the investigation dataset forms for a subject.It contains methods to fill out the forms, and progress episodes, based on the age of the subject and the test result. Below are their key functions: |
| 45 | + |
| 46 | +1. **`complete_with_result(self, nhs_no: str, result: str) -> None`** |
| 47 | + This method fills out the investigation dataset forms based on the test result and the subject's age. |
| 48 | + |
| 49 | + - **Arguments**: |
| 50 | + - nhs_no (str): The NHS number of the subject. |
| 51 | + - result (str): The result of the investigation dataset. Should be one of InvestigationDatasetResults (HIGH_RISK, LNPCP, NORMAL). |
| 52 | + |
| 53 | +1. **`go_to_investigation_datasets_page(self, nhs_no) -> None`** |
| 54 | + This method navigates to the investigation datasets page for a subject. |
| 55 | + |
| 56 | + - **Arguments**: |
| 57 | + - nhs_no (str): The NHS number of the subject. |
| 58 | + |
| 59 | +1. **`default_investigation_dataset_forms(self) -> None`** |
| 60 | + This method fills out the first part of the default investigation dataset form. |
| 61 | + |
| 62 | +1. **`default_investigation_dataset_forms_continuation(self) -> None`** |
| 63 | + This method fills out the second part of the default investigation dataset form. |
| 64 | + |
| 65 | +1. **`investigation_datasets_failure_reason(self) -> None`** |
| 66 | + This method fills out the failure reason section of the investigation dataset form. |
| 67 | + |
| 68 | +1. **`polyps_for_high_risk_result(self) -> None`** |
| 69 | + This method fills out the polyp information section of the investigation dataset form to trigger a high risk result. |
| 70 | + |
| 71 | +1. **`polyps_for_lnpcp_result(self) -> None`** |
| 72 | + This method fills out the polyp information section of the investigation dataset form to trigger a LNPCP result. |
| 73 | + |
| 74 | +1. **`polyp1_intervention(self) -> None`** |
| 75 | + This method fills out the intervention section of the investigation dataset form for polyp 1. |
| 76 | + |
| 77 | +1. **`save_investigation_dataset(self) -> None`** |
| 78 | + This method saves the investigation dataset form. |
| 79 | + |
| 80 | +1. **`progress_episode_based_on_result(self, result: str, younger: bool) -> None`** |
| 81 | + This method progresses the episode based on the result of the investigation dataset. |
| 82 | + - **Arguments**: |
| 83 | + - result (str): The result of the investigation dataset. Should be one of InvestigationDatasetResults (HIGH_RISK, LNPCP, NORMAL). |
| 84 | + - younger (bool): True if the subject is younger than 50, False otherwise. |
| 85 | + |
| 86 | +1. **`after_high_risk_result(self) -> None`** |
| 87 | + This method advances an episode that has a high-risk result. |
| 88 | + |
| 89 | +1. **`after_lnpcp_result(self) -> None`** |
| 90 | + This method advances an episode that has a LNPCP result. |
| 91 | + |
| 92 | +1. **`after_normal_result(self) -> None`** |
| 93 | + This method advances an episode that has a normal result. |
| 94 | + |
| 95 | +1. **`handover_subject_to_symptomatic_care(self) -> None`** |
| 96 | + This method hands over a subject to symptomatic care. |
| 97 | + |
| 98 | +1. **`record_diagnosis_date(self) -> None`** |
| 99 | + This method records the diagnosis date for a subject. |
| 100 | + |
| 101 | +## Example Usage |
| 102 | + |
| 103 | +```python |
| 104 | +from playwright.sync_api import sync_playwright |
| 105 | +from utils.investigation_dataset import ( |
| 106 | + InvestigationDatasetCompletion, |
| 107 | + InvestigationDatasetResults, |
| 108 | + AfterInvestigationDatasetComplete, |
| 109 | +) |
| 110 | + |
| 111 | +def example_investigation_dataset_usage(nhs_no: str, result: str, younger: bool) -> None: |
| 112 | + # Start Playwright and open a browser/page (simplified for example) |
| 113 | + with sync_playwright() as p: |
| 114 | + browser = p.chromium.launch(headless=True) |
| 115 | + page = browser.new_page() |
| 116 | + |
| 117 | + # Complete the investigation dataset for a subject |
| 118 | + investigation = InvestigationDatasetCompletion(page) |
| 119 | + investigation.complete_with_result(nhs_no, result) |
| 120 | + |
| 121 | + # Progress the episode based on the result and subject's age |
| 122 | + after_investigation = AfterInvestigationDatasetComplete(page) |
| 123 | + after_investigation.progress_episode_based_on_result(result, younger) |
| 124 | + |
| 125 | + browser.close() |
| 126 | + |
| 127 | +# Example usage: |
| 128 | +example_investigation_dataset_usage( |
| 129 | + nhs_no="1234567890", |
| 130 | + result=InvestigationDatasetResults.HIGH_RISK, |
| 131 | + younger=True |
| 132 | +) |
| 133 | +``` |
0 commit comments