Skip to content

Commit cfed5f5

Browse files
Reports changes (#430)
Choose data An update to the Reports section. If the user selects a time 'in the past' pre-streamlining they will see the 'old' version (or if it overlaps) and the 'new' version if they select dates post-streamlining. **New** <img width="2756" height="4020" alt="image" src="https://github.com/user-attachments/assets/73a0baa8-3fe5-4ede-bfa6-e6065930709d" /> **Old** <img width="2756" height="4596" alt="image" src="https://github.com/user-attachments/assets/79d3371d-8da5-44cf-8c28-e21d8b646bbf" /> --------- Co-authored-by: Frankie Roberto <[email protected]>
1 parent f168ebc commit cfed5f5

File tree

7 files changed

+249
-59
lines changed

7 files changed

+249
-59
lines changed

app/data/session-data-defaults.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ module.exports = {
1717
currentOrganisationId: "RW3",
1818
currentRegionId: "Y62",
1919
vaccinationsRecorded: [],
20+
21+
// These are the options for extracting CSV reports
22+
patientDataOptions: ["Name", "NHS number", "Gender", "Date of birth", "Address", "Postcode", "ODS code of their GP"],
23+
staffDataOptions: ["Recorder", "Vaccinator"],
24+
locationDataOptions: ["Site name", "Site ODS code", "Location type"],
25+
consentAndEligibilityDataOptions: ["Consent", "Eligibility", "Estimated due date"],
26+
vaccinationDataOptions: ["Vaccine type", "Product", "Batch", "Batch expiry date", "Dose amount", "Vaccination site", "Vaccination date", "Legal mechanism", "Comments"],
27+
2028
legalMechanisms: [
2129
{
2230
value: "National protocol",
@@ -38,9 +46,6 @@ module.exports = {
3846
}
3947
}
4048
],
41-
data: [
42-
"Patients", "Staff", "Site or delivery team", "Assessment and consent", "Vaccination"
43-
],
4449
careHomes: [
4550
{name: "Colin Care Home", code: "VL025", address1: "1 St James Street", town: "Manchester", postcode: "M1 63P"},
4651
{name: "Abacus Care Home", code: "VLA2K", address1: "30 Pleasant view gardens", town: "Leeds", postcode: "L8 1PD"},

app/routes/reports.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ module.exports = (router) => {
133133

134134
let from, to
135135

136-
console.log(dateOption)
137-
138136
switch (dateOption) {
139137
case 'custom_date_range':
140138
from = filters.isoDateFromDateInput(fromInput)

app/views/reports/check.html

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,29 @@
1717
<div class="nhsuk-grid-row">
1818
<div class="nhsuk-grid-column-two-thirds">
1919

20-
<h1 class="nhsuk-heading-xl">{{ pageName }}</h1>
20+
<h1 class="nhsuk-heading-l">{{ pageName }}</h1>
21+
22+
{% set dataFields = [] %}
23+
24+
{% for field in data.patientDataToReport %}
25+
{% set dataFields = (dataFields.push(field), dataFields) %}
26+
{% endfor %}
27+
{% for field in data.staffDataToReport %}
28+
{% set dataFields = (dataFields.push(field), dataFields) %}
29+
{% endfor %}
30+
{% for field in data.siteDataToReport %}
31+
{% set dataFields = (dataFields.push(field), dataFields) %}
32+
{% endfor %}
33+
{% for field in data.consentAndEligibilityDataToReport %}
34+
{% set dataFields = (dataFields.push(field), dataFields) %}
35+
{% endfor %}
36+
{% for field in data.vaccinationDataToReport %}
37+
{% set dataFields = (dataFields.push(field), dataFields) %}
38+
{% endfor %}
39+
40+
{% set dataValue %}
41+
{{ dataFields | join(", ") }}
42+
{% endset %}
2143

2244
{{ summaryList({
2345
rows: [
@@ -63,12 +85,12 @@ <h1 class="nhsuk-heading-xl">{{ pageName }}</h1>
6385
text: ("Vaccines" if (data.vaccines | length) > 1 else "Vaccine")
6486
},
6587
value: {
66-
text: (data.vaccines | sort(false, false, "name") | join(", ") | capitaliseFirstLetter) if data.vaccines
88+
text: (data.vaccinesToReport | sort(false, false, "name") | join(", ") | capitaliseFirstLetter) if data.vaccines
6789
},
6890
actions: {
6991
items: [
7092
{
71-
href: "/reports/choose-vaccines-2",
93+
href: "/reports/choose-vaccines",
7294
text: "Change",
7395
visuallyHiddenText: "change vaccines"
7496
}
@@ -80,12 +102,12 @@ <h1 class="nhsuk-heading-xl">{{ pageName }}</h1>
80102
text: ("Sites" if (data.reportSites | length) > 1 else "Site")
81103
},
82104
value: {
83-
text: (data.reportSites | join(", ")) if data.reportSites
105+
text: (data.sitesToReport | join(", ")) if data.sitesToReport
84106
},
85107
actions: {
86108
items: [
87109
{
88-
href: "/reports/choose-site-2",
110+
href: "/reports/choose-site",
89111
text: "Change",
90112
visuallyHiddenText: "change sites"
91113
}
@@ -97,7 +119,7 @@ <h1 class="nhsuk-heading-xl">{{ pageName }}</h1>
97119
text: "Data"
98120
},
99121
value: {
100-
text: (data.data | join(", ")) if data.data
122+
text: dataValue
101123
},
102124
actions: {
103125
items: [
@@ -109,13 +131,9 @@ <h1 class="nhsuk-heading-xl">{{ pageName }}</h1>
109131
]
110132
}
111133
}
112-
113-
114134
]
115135
}) }}
116136

117-
118-
119137
<form action="/reports/download" method="post">
120138
{{ button({
121139
"text": "Confirm and create report"

app/views/reports/choose-data.html

Lines changed: 183 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,52 +26,170 @@
2626
<form action="/reports/update-data" method="post" novalidate="true">
2727

2828

29+
{% set patientsHtml %}
30+
31+
{% set items = [] %}
32+
{% for option in data.patientDataOptions %}
33+
{% set items = (items.push({
34+
text: option,
35+
value: option
36+
}), items) %}
37+
{% endfor %}
38+
39+
{{ checkboxes({
40+
idPrefix: "patient-data",
41+
name: "patientDataToReport",
42+
fieldset: {
43+
legend: {
44+
text: "Patient data"
45+
}
46+
},
47+
values: data.patientDataToReport,
48+
items: items
49+
}) }}
50+
{% endset %}
51+
52+
{% set staffHtml %}
53+
54+
{% set items = [] %}
55+
{% for option in data.staffDataOptions %}
56+
{% set items = (items.push({
57+
text: option,
58+
value: option
59+
}), items) %}
60+
{% endfor %}
61+
62+
{{ checkboxes({
63+
idPrefix: "staff-data",
64+
name: "staffDataToReport",
65+
fieldset: {
66+
legend: {
67+
text: "Staff data"
68+
}
69+
},
70+
values: data.staffDataToReport,
71+
items: items
72+
}) }}
73+
{% endset %}
74+
75+
{% set sitesHtml %}
76+
77+
{% set items = [] %}
78+
{% for option in data.locationDataOptions %}
79+
{% set items = (items.push({
80+
text: option,
81+
value: option
82+
}), items) %}
83+
{% endfor %}
84+
85+
{{ checkboxes({
86+
idPrefix: "site-data",
87+
name: "siteDataToReport",
88+
fieldset: {
89+
legend: {
90+
text: "Site data"
91+
}
92+
},
93+
values: data.siteDataToReport,
94+
items: items
95+
}) }}
96+
{% endset %}
97+
98+
{% set consentAndEligibilityHtml %}
99+
100+
{% set items = [] %}
101+
{% for option in data.consentAndEligibilityDataOptions %}
102+
{% set items = (items.push({
103+
text: option,
104+
value: option
105+
}), items) %}
106+
{% endfor %}
107+
108+
{{ checkboxes({
109+
idPrefix: "consent-and-eligibility-data",
110+
name: "consentAndEligibilityDataToReport",
111+
fieldset: {
112+
legend: {
113+
text: "Consent and eligibility data"
114+
}
115+
},
116+
values: data.consentAndEligibilityDataToReport,
117+
items: items
118+
}) }}
119+
{% endset %}
120+
121+
{% set vaccinationHtml %}
122+
123+
{% set items = [] %}
124+
{% for option in data.vaccinationDataOptions %}
125+
{% set items = (items.push({
126+
text: option,
127+
value: option
128+
}), items) %}
129+
{% endfor %}
130+
131+
{{ checkboxes({
132+
idPrefix: "vaccination-data",
133+
name: "vaccinationDataToReport",
134+
fieldset: {
135+
legend: {
136+
text: "Vaccination data"
137+
}
138+
},
139+
values: data.vaccinationDataToReport,
140+
items: items
141+
}) }}
142+
{% endset %}
143+
29144
{{ checkboxes({
30145
idPrefix: "data",
31146
name: "data",
147+
attributes: {
148+
id: "data-fields"
149+
},
32150
errorMessage: {
33151
text: error.text
34152
} if error,
35153
fieldset: {
36154
legend: {
37155
text: "Choose data",
38156
isPageHeading: true,
39-
classes: "nhsuk-fieldset__legend--xl"
157+
classes: "nhsuk-fieldset__legend--l"
40158
}
41159
},
42160
values: data.data,
43161
items: [
44162
{
45163
value: "Patients",
46164
text: "Patients",
47-
hint: {
48-
text: "NHS number, name, date of birth, gender, address"
165+
conditional: {
166+
html: patientsHtml
49167
}
50168
},
51169
{
52170
value: "Staff",
53171
text: "Staff",
54-
hint: {
55-
text: "Recorder or vaccinator names and email addresses"
172+
conditional: {
173+
html: staffHtml
56174
}
57175
},
58176
{
59-
value: "Site or delivery team",
60-
text: "Site or delivery team",
61-
hint: {
62-
text: "Names and ODS codes"
177+
value: "Sites",
178+
text: "Sites",
179+
conditional: {
180+
html: sitesHtml
63181
}
64182
},{
65-
value: "Assessment and consent",
66-
text: "Assessment and consent",
67-
hint: {
68-
text: "Vaccinated and not givens, date, consent and eligibility details, and comments"
183+
value: "Consent and eligibility",
184+
text: "Consent and eligibility",
185+
conditional: {
186+
html: consentAndEligibilityHtml
69187
}
70188
},{
71189
value: "Vaccination",
72190
text: "Vaccination",
73-
hint: {
74-
text: "Date, vaccine details and dose given, site of body, legal mechanism and comments"
191+
conditional: {
192+
html: vaccinationHtml
75193
}
76194
}
77195
]
@@ -86,5 +204,55 @@
86204
</div>
87205
</div>
88206

207+
<script>
208+
function checkOrUncheckChildren(event) {
209+
210+
const checkboxClicked = event.target
211+
212+
const checkboxesControlled = document.getElementById(checkboxClicked.getAttribute('aria-controls')).querySelectorAll('input[type=checkbox')
213+
214+
for (checkbox of checkboxesControlled) {
215+
checkbox.checked = checkboxClicked.checked
216+
}
217+
}
218+
219+
const parentCheckboxes = document.getElementById('data-fields').querySelectorAll('input[type=checkbox][aria-controls]')
220+
221+
for (checkbox of parentCheckboxes) {
222+
checkbox.addEventListener('click', checkOrUncheckChildren)
223+
}
224+
225+
function uncheckParentIfAllUnchecked(event) {
226+
227+
const checkboxClicked = event.target
228+
229+
const parentGroup = checkboxClicked.closest('.nhsuk-checkboxes__conditional')
230+
231+
const parentGroupId = parentGroup.getAttribute('id')
232+
233+
const parentCheckbox = document.querySelector(`input[aria-controls=${parentGroupId}]`)
234+
235+
const allCheckboxesInGroup = parentGroup.querySelectorAll('input[type=checkbox]')
236+
237+
let checkboxStatuses = []
238+
239+
for (checkbox of allCheckboxesInGroup) {
240+
checkboxStatuses.push(checkbox.checked)
241+
}
242+
243+
if (!checkboxStatuses.includes(true)) {
244+
// Uncheck parent
245+
parentCheckbox.click()
246+
}
247+
}
248+
249+
const childCheckboxes = document.getElementById('data-fields').querySelectorAll('.nhsuk-checkboxes__conditional input[type=checkbox]')
250+
251+
for (checkbox of childCheckboxes) {
252+
checkbox.addEventListener('click', uncheckParentIfAllUnchecked)
253+
}
254+
255+
256+
</script>
89257

90258
{% endblock %}

app/views/reports/choose-site.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
<form action="/reports/choose-data" method="post">
2222

2323
{{ checkboxes({
24-
"idPrefix": "example",
25-
"name": "reportSites",
24+
"idPrefix": "sites-to-report",
25+
"name": "sitesToReport",
2626
"fieldset": {
2727
"legend": {
2828
"text": "Choose sites",
29-
"classes": "nhsuk-fieldset__legend--xl",
29+
"classes": "nhsuk-fieldset__legend--l",
3030
isPageHeading: true
3131
}
3232
},
33-
values: data.reportSites,
33+
values: data.sitesToReport,
3434
"items": [
3535
{
3636
"value": "Verington (RH63S)",

0 commit comments

Comments
 (0)