Skip to content

Commit 5f4fb33

Browse files
committed
Added Investigation Dataset util guide and refactored a couple of docstrings
1 parent b0bf81a commit 5f4fb33

File tree

3 files changed

+148
-5
lines changed

3 files changed

+148
-5
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 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+
```

tests/smokescreen/test_compartment_6.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_compartment_6(page: Page) -> None:
2020
This is the main compartment 6 method
2121
This test fills out the investigation datasets for different subjects to get different outcomes for a diagnostic test
2222
based on the test results and the subject's age, then prints the diagnostic test result letters.
23-
If the subject is old enough and they get a high-risk or LNPCP result, then they are handed over
23+
If the subject is old enough and they get a high-risk or LNPCP result, then they are handed over
2424
into symptomatic care, and the relevant letters are printed.
2525
"""
2626

utils/investigation_dataset.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,28 @@ class InvestigationDatasetResults(StrEnum):
6161
class InvestigationDatasetCompletion:
6262
"""
6363
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.
64+
It contains methods to fill out the forms, and progress episodes, based on the
65+
age of the subject and the test result.
66+
67+
This class provides methods to:
68+
- Navigate to the investigation datasets page for a subject.
69+
- Fill out investigation dataset forms with default or result-specific data.
70+
- Handle different investigation outcomes (e.g., HIGH_RISK, LNPCP, NORMAL) by populating relevant form fields and sections.
71+
- Add and configure polyp information and interventions to trigger specific result scenarios.
72+
- Save the completed investigation dataset.
6573
"""
6674

6775
def __init__(self, page: Page):
6876
self.page = page
6977
self.estimate_whole_polyp_size_string = "Estimate of whole polyp size"
7078
self.polyp_access_string = "Polyp Access"
7179

72-
def complete_with_result(self, nhs_no: str, result: str):
80+
def complete_with_result(self, nhs_no: str, result: str) -> None:
7381
"""This method fills out the investigation dataset forms based on the test result and the subject's age.
7482
Args:
7583
nhs_no (str): The NHS number of the subject.
7684
result (str): The result of the investigation dataset.
85+
Should be one of InvestigationDatasetResults (HIGH_RISK, LNPCP, NORMAL).
7786
"""
7887
if result == InvestigationDatasetResults.HIGH_RISK:
7988
self.go_to_investigation_datasets_page(nhs_no)
@@ -119,7 +128,7 @@ def go_to_investigation_datasets_page(self, nhs_no) -> None:
119128
SubjectDatasetsPage(self.page).click_investigation_show_datasets()
120129

121130
def default_investigation_dataset_forms(self) -> None:
122-
"""This method fills out the first art of the default investigation dataset form."""
131+
"""This method fills out the first part of the default investigation dataset form."""
123132
# Investigation Dataset
124133
InvestigationDatasetsPage(self.page).select_site_lookup_option(
125134
SiteLookupOptions.RL401
@@ -200,7 +209,7 @@ def investigation_datasets_failure_reason(self) -> None:
200209
)
201210

202211
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."""
212+
"""This method fills out the polyp information section of the investigation dataset form to trigger a high risk result."""
204213
# Polyp Information
205214
InvestigationDatasetsPage(self.page).click_add_polyp_button()
206215
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
@@ -323,6 +332,7 @@ def progress_episode_based_on_result(self, result: str, younger: bool) -> None:
323332
"""This method progresses the episode based on the result of the investigation dataset.
324333
Args:
325334
result (str): The result of the investigation dataset.
335+
Should be one of InvestigationDatasetResults (HIGH_RISK, LNPCP, NORMAL).
326336
younger (bool): True if the subject is younger than 50, False otherwise.
327337
"""
328338
if result == InvestigationDatasetResults.HIGH_RISK:

0 commit comments

Comments
 (0)