Skip to content

Commit 132ae1b

Browse files
Fix logic for co-admin journey (#174)
I think I've now got this right...
1 parent 43618da commit 132ae1b

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

app/routes/vaccinate.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,31 @@ module.exports = router => {
303303

304304
})
305305

306+
router.post('/vaccinate/answer-eligibility', (req, res) => {
307+
const data = req.session.data
308+
309+
let nextPage;
310+
311+
if (data.patientName && data.patientName != "" && data.repeatPatient === "yes") {
312+
313+
if (data.vaccine === "Pertussis" || ((data.vaccine == "RSV") && (data.eligibility === "Pregnant"))) {
314+
nextPage = "/vaccinate/patient-estimated-due-date"
315+
} else {
316+
nextPage = "/vaccinate/consent"
317+
}
318+
319+
} else {
320+
321+
if ((data.vaccine === "COVID-19") || (data.vaccine == "Flu")) {
322+
nextPage = "/vaccinate/location"
323+
} else {
324+
nextPage = "/vaccinate/patient"
325+
}
326+
}
327+
328+
res.redirect(nextPage)
329+
})
330+
306331
// Routing page after DONE
307332
router.post('/vaccinate/what-next', (req, res) => {
308333

@@ -334,6 +359,7 @@ module.exports = router => {
334359
req.session.data.vaccine = ""
335360
req.session.data.vaccineProduct = ""
336361
req.session.data.vaccineBatch = ""
362+
req.session.data.eligibility = ""
337363

338364
res.redirect('/vaccinate/vaccine?repeatPatient=yes&repeatVaccination=no')
339365

@@ -354,11 +380,12 @@ module.exports = router => {
354380

355381
if (vaccineBatch === "add-new") {
356382
redirectPath = "/vaccinate/add-batch"
357-
} else if (vaccine === "Pertussis") {
358-
redirectPath = "/vaccinate/patient"
359-
} else {
360-
// RSV, Covid or Flu
383+
} else if (["COVID-19", "Flu", "RSV"].includes(data.vaccine)) {
361384
redirectPath = "/vaccinate/eligibility"
385+
} else if (data.repeatPatient === "yes") {
386+
redirectPath = "/vaccinate/patient-estimated-due-date"
387+
} else {
388+
redirectPath = "/vaccinate/patient"
362389
}
363390
res.redirect(redirectPath)
364391
})

app/views/vaccinate/check.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ <h2 class="nhsuk-heading-m">Vaccination</h2>
239239
}
240240
]
241241
}
242-
} if ((data.vaccine == "Pertussis") or (data.eligibility | arrayOrStringIncludes("Pregnant"))),
242+
} if ((data.vaccine == "Pertussis") or ((data.eligibility | arrayOrStringIncludes("Pregnant"))) and (data.vaccine == "RSV")),
243243
{
244244
key: {
245245
text: "Consent given by"

app/views/vaccinate/eligibility.html

Lines changed: 1 addition & 9 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.patientName and data.repeatPatient == "yes" %}
18-
{% set nextAction = "/vaccinate/injection-site" %}
19-
{% elseif data.vaccine == "COVID-19" or data.vaccine == "Flu" %}
20-
{% set nextAction = "/vaccinate/location" %}
21-
{% else %}
22-
{% set nextAction = "/vaccinate/patient" %}
23-
{% endif %}
24-
25-
<form action="{{ nextAction }}" method="post" novalidate>
17+
<form action="/vaccinate/answer-eligibility" method="post" novalidate>
2618

2719
{% if data.vaccine == "COVID-19" %}
2820
{% set eligibilityOptions = [

0 commit comments

Comments
 (0)