Skip to content

Commit d61c6a2

Browse files
Allow users to add a batch as part of the flow (#165)
This lets users add a vaccine batch as part of the 'Record vaccination' flow. Only users with 'admin' or 'lead admin' permission would be able to do this - others would not see the 'Add a batch' option. ## Screenshots ### Selecting 'Add a new batch' ![Screenshot 2025-01-16 at 16 43 11](https://github.com/user-attachments/assets/cc184089-16a4-4150-9fe1-7ad2f9133d6a) ### Adding details of the new batch ![Screenshot 2025-01-16 at 16 43 56](https://github.com/user-attachments/assets/13e863d4-efa6-49f8-a55b-9c3e40e3f8a4)
1 parent 04222d6 commit d61c6a2

File tree

4 files changed

+58
-36
lines changed

4 files changed

+58
-36
lines changed

app/routes/vaccinate.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,26 @@ module.exports = router => {
230230
// Routing page after DONE
231231
router.post('/vaccinate/what-next', (req, res) => {
232232

233-
const answer = req.session.data.nextStep;
233+
const data = req.session.data
234+
const answer = data.nextStep
234235

235-
req.session.data.injectionSite = ""
236+
// Reset these value regardless of next step
237+
data.injectionSite = ""
238+
data.consent = ""
239+
data.consentName = ""
236240

237241
if (answer === 'same-vaccination-another-patient') {
238242

239243
req.session.data.patientName = ""
240244
req.session.data.nhsNumber = ""
241245

246+
// newly added batch becomes the default
247+
if (data.vaccineBatch == 'add-new') {
248+
data.vaccineBatch = data.newBatchNumber
249+
data.vaccineExpiryDate = data.newBatchExpiryDate
250+
data.newBatchNumber = ""
251+
}
252+
242253
res.redirect('/vaccinate/patient?repeatVaccination=yes&repeatPatient=no')
243254

244255
} else if (answer === 'same-patient-another-vaccination') {
@@ -256,25 +267,24 @@ module.exports = router => {
256267

257268
})
258269

270+
router.post('/vaccinate/answer-batch', (req, res) => {
259271

272+
const data = req.session.data
273+
const vaccineBatch = data.vaccineBatch
274+
const vaccine = data.vaccine
260275

261-
router.post('/vaccinate/answer-patient-nhs-number-known', (req, res) => {
262-
263-
const nhsNumberKnown = req.session.data.nhsNumberKnown;
264-
265-
if (nhsNumberKnown === "yes") {
266-
267-
req.session.data.patientName = "Jodie Brown"
268-
req.session.data.dateOfBirth = {day: "4", month: "7", year: "1964"}
269-
req.session.data.postcode = "GD3 I83"
276+
let redirectPath
270277

271-
res.redirect('/vaccinate/patient-history')
272-
} else if (nhsNumberKnown === "no") {
273-
res.redirect('/vaccinate/patient-search')
278+
if (vaccineBatch === "add-new") {
279+
redirectPath = "/vaccinate/add-batch"
280+
} else if (vaccine === "Pertussis") {
281+
redirectPath = "/vaccinate/patient"
282+
} else if (vaccine === "RSV") {
283+
redirectPath = "/vaccinate/eligibility"
274284
} else {
275-
res.redirect('/vaccinate/patient?showError=yes')
285+
redirectPath = "/vaccinate/location"
276286
}
277-
287+
res.redirect(redirectPath)
278288
})
279289

280290

app/views/vaccinate/add-batch-vaccinate.html renamed to app/views/vaccinate/add-batch.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,43 @@
1717
<div class="nhsuk-grid-row">
1818
<div class="nhsuk-grid-column-two-thirds">
1919

20-
<h1 class="nhsuks-heading-xl">Add batch</h1>
20+
<h1 class="nhsuks-heading-l">Add batch</h1>
2121

22-
<form action="/vaccinate/eligibility" method="post" novalidate="true">
22+
{% if data.vaccine == "Pertussis" %}
23+
{% set nextPage = "/vaccinate/patient" %}
24+
{% elseif data.vaccine == "RSV" %}
25+
{% set nextPage = "/vaccinate/eligibility" %}
26+
{% else %}
27+
{% set nextPage = "/vaccinate/location" %}
28+
{% endif %}
29+
30+
<form action="{{ nextPage }}" method="post" novalidate>
2331

2432
{{ input({
2533
"label": {
26-
"text": "Batch number",
34+
"text": data.vaccine + " batch number",
2735
classes: "nhsuk-label--s"
2836
},
2937
hint: {
3038
text: "For example, XX123456"
3139
},
3240
"id": "batch-number",
33-
"name": "batchNumber",
41+
"name": "newBatchNumber",
3442
classes: "nhsuk-input--width-20",
35-
value: data.batchNumber
43+
value: data.newBatchNumber
3644
}) }}
3745

3846

3947
{{ dateInput({
40-
"id": "batchExpiryDate",
41-
"namePrefix": "batchExpiryDate",
48+
"id": "newBatchExpiryDate",
49+
"namePrefix": "newBatchExpiryDate",
4250
"fieldset": {
4351
"legend": {
4452
"text": "Expiry date",
4553
"classes": "nhsuk-label--s"
4654
}
4755
},
48-
values: data.batchExpiryDate
56+
values: data.newBatchExpiryDate
4957
}) }}
5058

5159
{{ button({

app/views/vaccinate/batch.html

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@
1414
<div class="nhsuk-grid-row">
1515
<div class="nhsuk-grid-column-two-thirds">
1616

17-
{% if data.vaccine == "Pertussis" %}
18-
{% set nextPage = "/vaccinate/patient" %}
19-
{% elseif data.vaccine == "RSV" %}
20-
{% set nextPage = "/vaccinate/eligibility" %}
21-
{% else %}
22-
{% set nextPage = "/vaccinate/location" %}
23-
{% endif %}
24-
25-
<form action="{{ nextPage }}" method="post" novalidate>
17+
<form action="/vaccinate/answer-batch" method="post" novalidate>
2618

2719
{{ radios({
2820
"idPrefix": "vaccineBatch",
@@ -72,7 +64,8 @@
7264
},
7365
{
7466
"value": "add-new",
75-
"text": "Add a batch"
67+
"text": "Add a batch",
68+
checked: (data.vaccineBatch == "add-new")
7669
}
7770
]
7871
}) }}

app/views/vaccinate/check.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
{% endif %}
1919
{% endset %}
2020

21+
{% set batchHtml %}
22+
{% if data.vaccineBatch == "add-new" %}
23+
{{ data.newBatchNumber }}
24+
<br>Expires {{ (data.newBatchExpiryDate | isoDateFromDateInput | govukDate) }}
25+
{% else %}
26+
{{ data.vaccineBatch }}
27+
<br>Expires 4 January 2025
28+
{% endif %}
29+
30+
{% endset %}
31+
2132
{% block content %}
2233
<div class="nhsuk-grid-row">
2334
<div class="nhsuk-grid-column-two-thirds">
@@ -149,12 +160,12 @@ <h2 class="nhsuk-heading-m">Vaccination</h2>
149160
text: "Batch"
150161
},
151162
value: {
152-
html: data.vaccineBatch + "<br>Expires 4 January 2025"
163+
html: batchHtml
153164
},
154165
actions: {
155166
items: [
156167
{
157-
href: "/vaccinate/batch",
168+
href: ("/vaccinate/add-batch" if data.vaccineBatch == "add-new" else "/vaccinate/batch"),
158169
text: "Change",
159170
visuallyHiddenText: "vaccine batch"
160171
}

0 commit comments

Comments
 (0)