Skip to content

Commit 053efec

Browse files
Andyg79mepr1adrianoaru-nhs
authored
Feature/bcss 20521 c6 investigation dataset navigation util (#75)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This took a lot of repeated code from compartment 6 and put it into a utility. Note: Adriano was a key contributor. ## Context <!-- Why is this change required? What problem does it solve? --> ## Type of changes This was required to remove repeated code and to make the process of completing an investigation dataset easier to use and maintain. <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [x] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes. --------- Co-authored-by: mepr1 <[email protected]> Co-authored-by: adrianoaru-nhs <[email protected]> Co-authored-by: Adriano Aru <[email protected]>
1 parent ea3bc92 commit 053efec

File tree

4 files changed

+682
-418
lines changed

4 files changed

+682
-418
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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 70, False otherwise.
40+
41+
## Investigation Dataset Specific Functions
42+
43+
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:
44+
45+
1. **`complete_with_result(self, nhs_no: str, result: str) -> None`**
46+
This method fills out the investigation dataset forms based on the test result and the subject's age.
47+
48+
- **Arguments**:
49+
- nhs_no (str): The NHS number of the subject.
50+
- result (str): The result of the investigation dataset. Should be one of InvestigationDatasetResults (HIGH_RISK, LNPCP NORMAL).
51+
52+
2. **`go_to_investigation_datasets_page(self, nhs_no) -> None`**
53+
This method navigates to the investigation datasets page for a subject.
54+
55+
- **Arguments**:
56+
- nhs_no (str): The NHS number of the subject.
57+
58+
3. **`default_investigation_dataset_forms(self) -> None`**
59+
This method fills out the first part of the default investigation dataset form.
60+
61+
4. **`default_investigation_dataset_forms_continuation(self) -> None`**
62+
This method fills out the second part of the default investigation dataset form.
63+
64+
5. **`investigation_datasets_failure_reason(self) -> None`**
65+
This method fills out the failure reason section of the investigation dataset form.
66+
67+
6. **`polyps_for_high_risk_result(self) -> None`**
68+
This method fills out the polyp information section of the investigation dataset form to trigger a high risk result.
69+
70+
7. **`polyps_for_lnpcp_result(self) -> None`**
71+
This method fills out the polyp information section of the investigation dataset form to trigger a LNPCP result.
72+
73+
8. **`polyp1_intervention(self) -> None`**
74+
This method fills out the intervention section of the investigation dataset form for polyp 1.
75+
76+
9. **`save_investigation_dataset(self) -> None`**
77+
This method saves the investigation dataset form.
78+
79+
10. **`progress_episode_based_on_result(self, result: str, younger: bool) -> None`**
80+
This method progresses the episode based on the result of the investigation dataset.
81+
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+
11. **`after_high_risk_result(self) -> None`**
87+
This method advances an episode that has a high-risk result.
88+
89+
12. **`after_lnpcp_result(self) -> None`**
90+
This method advances an episode that has a LNPCP result.
91+
92+
13. **`after_normal_result(self) -> None`**
93+
This method advances an episode that has a normal result.
94+
95+
14. **`handover_subject_to_symptomatic_care(self) -> None`**
96+
This method hands over a subject to symptomatic care.
97+
98+
15. **`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+
```

pages/datasets/investigation_dataset_page.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, page: Page):
1010
super().__init__(page)
1111
self.page = page
1212

13-
# Colonoscopy datasets page locators
13+
# Investigation datasets page locators
1414
self.site_lookup_link = self.page.locator("#UI_SITE_SELECT_LINK")
1515
self.practitioner_link = self.page.locator("#UI_SSP_PIO_SELECT_LINK")
1616
self.testing_clinician_link = self.page.locator(
@@ -26,7 +26,7 @@ def __init__(self, page: Page):
2626
"#anchorColonoscopy"
2727
)
2828
self.endoscope_inserted_yes = self.page.locator("#radScopeInsertedYes")
29-
self.theraputic_procedure_type = self.page.get_by_role(
29+
self.therapeutic_procedure_type = self.page.get_by_role(
3030
"radio", name="Therapeutic"
3131
)
3232
self.diagnostic_procedure_type = self.page.get_by_role(
@@ -143,12 +143,12 @@ def check_endoscope_inserted_yes(self) -> None:
143143
"""
144144
self.endoscope_inserted_yes.check()
145145

146-
def select_theraputic_procedure_type(self) -> None:
146+
def select_therapeutic_procedure_type(self) -> None:
147147
"""
148148
This method is designed to select the therapeutic procedure type.
149149
It selects the therapeutic procedure type.
150150
"""
151-
self.theraputic_procedure_type.check()
151+
self.therapeutic_procedure_type.check()
152152

153153
def select_diagnostic_procedure_type(self) -> None:
154154
"""
@@ -242,6 +242,7 @@ class PractitionerOptions(StrEnum):
242242

243243
class TestingClinicianOptions(StrEnum):
244244
"""Enum for testing clinician options"""
245+
245246
__test__ = False
246247

247248
BORROWING_PROPERTY = "886"

0 commit comments

Comments
 (0)