Skip to content

Commit 4267a21

Browse files
committed
Merge branch 'feature/BCSS-22014-surveillanceregressiontests-scenario-2' of github.com:NHSDigital/bcss-playwright into feature/BCSS-21996--survellianceregressiontests-scenario-1
2 parents 69f2358 + 312733e commit 4267a21

19 files changed

+1160
-827
lines changed

classes/repositories/subject_repository.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,19 @@ def get_early_subject_to_be_invited_for_surveillance(
299299
FROM screening_subject_t ss
300300
INNER JOIN sd_contact_t c ON ss.subject_nhs_number = c.nhs_number
301301
WHERE c.responsible_sc_id = :screeningCentreId
302-
AND c.deduction_reason IS NULL
303-
AND c.date_of_death IS NULL
304-
AND TRUNC (ss.surveillance_screen_due_date) <= TO_DATE(:sDueCountDate, 'DD/MM/YYYY')
305-
AND ss.screening_status_id = 4006
306-
AND c.date_of_death IS NULL
307-
AND NOT EXISTS (
308-
SELECT 1
309-
FROM ep_subject_episode_t ep
310-
WHERE ep.screening_subject_id = ss.screening_subject_id
311-
AND ep.episode_status_id IN (11352, 11354)
312-
)
313-
ORDER BY TRUNC(ss.surveillance_screen_due_date)
314-
FETCH FIRST 1 ROW ONLY
302+
AND c.deduction_reason IS NULL
303+
AND c.date_of_death IS NULL
304+
AND TRUNC (ss.surveillance_screen_due_date) <= TO_DATE(:sDueCountDate, 'DD/MM/YYYY')
305+
AND ss.screening_status_id = 4006
306+
AND c.date_of_death IS NULL
307+
AND NOT EXISTS (
308+
SELECT 1
309+
FROM ep_subject_episode_t ep
310+
WHERE ep.screening_subject_id = ss.screening_subject_id
311+
AND ep.episode_status_id IN (11352, 11354)
312+
)
313+
ORDER BY TRUNC(ss.surveillance_screen_due_date)
314+
FETCH FIRST 1 ROW ONLY
315315
"""
316316
parameters = {
317317
"screeningCentreId": int(screening_centre_id),
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Utility Guide: Generate Health Check Forms
2+
3+
The **Generate Health Check Forms utility** provides helper methods for generating health check forms and inviting surveillance subjects early in BCSS.<br>
4+
This utility interacts with the UI and database to automate the process of producing health check forms for eligible subjects.
5+
6+
## Table of Contents
7+
8+
- [Utility Guide: Generate Health Check Forms](#utility-guide-generate-health-check-forms)
9+
- [Table of Contents](#table-of-contents)
10+
- [Summary of Utility Methods](#summary-of-utility-methods)
11+
- [Main Methods](#main-methods)
12+
- [`invite_surveillance_subjects_early`](#invite_surveillance_subjects_early)
13+
- [`find_early_invite_subjects`](#find_early_invite_subjects)
14+
- [Prerequisites](#prerequisites)
15+
- [Supporting Classes](#supporting-classes)
16+
- [Example Usage](#example-usage)
17+
18+
---
19+
20+
## Summary of Utility Methods
21+
22+
| Method | Purpose | Key Arguments | Expected Behaviour |
23+
|--------------------------------------|-------------------------------------------------------------------------|------------------------------|--------------------|
24+
| `invite_surveillance_subjects_early` | Generates health check forms and invites a surveillance subject early. | `screening_centre_id` (`str`)| Navigates UI, recalculates due count, finds subject, generates forms, returns NHS number. |
25+
| `find_early_invite_subjects` | Finds an eligible subject for early surveillance invitation. | `screening_centre_id` (`str`), `surveillance_due_count_date` (`str`) | Returns NHS number of eligible subject. |
26+
27+
---
28+
29+
## Main Methods
30+
31+
### `invite_surveillance_subjects_early`
32+
33+
Generates health check forms and invites a surveillance subject early by automating the relevant UI steps.
34+
35+
**Arguments:**
36+
37+
- `screening_centre_id` (`str`): The screening centre ID for which to generate forms and invite a subject.
38+
39+
**How it works:**
40+
41+
1. Navigates to the Surveillance page and then to the Produce Health Check Forms page.
42+
2. Sets the "Surveillance Due Count Volume" to 1.
43+
3. Clicks the "Recalculate" button to update the due count.
44+
4. Retrieves the current "Surveillance Due Count Date" from the UI.
45+
5. Finds an eligible subject for early invitation using the due count date and centre ID.
46+
6. Clicks the "Generate Health Check Forms" button.
47+
7. Returns the NHS number of the invited subject.
48+
49+
**Returns:**
50+
51+
- `str`: The NHS number of the early-invite subject.
52+
53+
---
54+
55+
### `find_early_invite_subjects`
56+
57+
Finds an eligible subject for early surveillance invitation based on the due count date and screening centre.
58+
59+
**Arguments:**
60+
61+
- `screening_centre_id` (`str`): The screening centre ID.
62+
- `surveillance_due_count_date` (`str`): The due count date as a string.
63+
64+
**How it works:**
65+
66+
1. Uses the `SubjectRepository` to query the database for a subject eligible for early surveillance invitation.
67+
2. Returns the NHS number of the found subject.
68+
69+
**Returns:**
70+
71+
- `str`: The NHS number of the eligible subject.
72+
73+
---
74+
75+
## Prerequisites
76+
77+
Before using the Generate Health Check Forms utility, ensure that the following prerequisites are met:
78+
79+
1. **UI Access**: The utility requires access to the BCSS UI and a valid Playwright `Page` object.
80+
2. **Database Access**: The utility uses the `SubjectRepository` to query the database for eligible subjects.
81+
3. **Screening Centre ID**: You must provide a valid screening centre ID for which to generate forms and invite subjects.
82+
83+
---
84+
85+
## Supporting Classes
86+
87+
These classes are required by the utility:
88+
89+
- `BasePage` — Provides navigation and common UI actions.
90+
- `SurveillancePage` — Handles navigation to the surveillance section.
91+
- `ProduceHealthCheckFormsPage` — Interacts with the health check forms UI.
92+
- `SubjectRepository` — Queries the database for eligible subjects.
93+
94+
---
95+
96+
## Example Usage
97+
98+
```python
99+
from utils.generate_health_check_forms_util import GenerateHealthCheckFormsUtil
100+
101+
# Assume you have a Playwright page object and a valid screening centre ID
102+
page = ... # Playwright Page object
103+
screening_centre_id = "12345"
104+
105+
# Create the utility
106+
health_check_util = GenerateHealthCheckFormsUtil(page)
107+
108+
# Invite a surveillance subject early and generate health check forms
109+
nhs_no = health_check_util.invite_surveillance_subjects_early(screening_centre_id)
110+
111+
print(f"Invited subject NHS number: {nhs_no}")
112+
```

0 commit comments

Comments
 (0)