From 98bea6613dc12e38c2ed4cb27813922577c0c8a2 Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Tue, 7 Apr 2026 15:16:16 +0100 Subject: [PATCH] Allow parents to say when and where a previous vaccination was given --- app/controllers/parent.js | 18 +++-- app/locales/en.js | 4 ++ app/models/reply.js | 6 +- app/views/parent/form/check-answers.njk | 93 +++++++++++++++---------- app/views/parent/form/previous-dose.njk | 73 +++++++++++++++++++ 5 files changed, 150 insertions(+), 44 deletions(-) create mode 100644 app/views/parent/form/previous-dose.njk diff --git a/app/controllers/parent.js b/app/controllers/parent.js index 743ccb3d9..eb886dfb2 100644 --- a/app/controllers/parent.js +++ b/app/controllers/parent.js @@ -175,11 +175,11 @@ export const parentController = { [`/${session_id}/${consent_uuid}/new/refusal-reason`]: { [`/${session_id}/${consent_uuid}/new/refusal-reason-details`]: { data: 'consent.refusalReason', - values: [ - ReplyRefusal.AlreadyVaccinated, - ReplyRefusal.GettingElsewhere, - ReplyRefusal.Medical - ] + values: [ReplyRefusal.GettingElsewhere, ReplyRefusal.Medical] + }, + [`/${session_id}/${consent_uuid}/new/previous-dose`]: { + data: 'consent.refusalReason', + value: ReplyRefusal.AlreadyVaccinated }, [`/${session_id}/${consent_uuid}/new/first-dose-country`]: { data: 'consent.refusalReason', @@ -194,7 +194,11 @@ export const parentController = { [`/${session_id}/${consent_uuid}/new/consultation`]: { [`/${session_id}/${consent_uuid}/new/check-answers`]: true }, - // First and second dose journey + // Previous single dose journey + [`/${session_id}/${consent_uuid}/new/previous-dose`]: { + [`/${session_id}/${consent_uuid}/new/check-answers`]: true + }, + // Previous multi-dose journey [`/${session_id}/${consent_uuid}/new/first-dose-country`]: {}, [`/${session_id}/${consent_uuid}/new/first-dose-date`]: {}, [`/${session_id}/${consent_uuid}/new/second-dose-country`]: {}, @@ -322,7 +326,7 @@ export const parentController = { showForm(request, response) { let { view } = request.params const { consent } = response.locals - let key + let key = kebabToCamelCase(view) // All health questions use the same view if (view.startsWith('health-question-')) { diff --git a/app/locales/en.js b/app/locales/en.js index 9a09bd0ea..5ba8f3fd2 100644 --- a/app/locales/en.js +++ b/app/locales/en.js @@ -895,8 +895,11 @@ export const en = { } }, previousDose: { + label: 'Details of %s vaccination', + title: 'When and where did your child get their %s vaccination?', country: { label: 'Country', + title: 'Which country was the vaccination given in?', england: 'England', scotland: 'Scotland', wales: 'Wales', @@ -908,6 +911,7 @@ export const en = { }, createdAt: { label: 'Date', + title: 'When was the vaccination given?', hint: 'If you do not know the exact date of the vaccination, leave the day field empty and enter your best guess for the month' }, scheduled: { diff --git a/app/models/reply.js b/app/models/reply.js index fcb1024f9..29d27612d 100644 --- a/app/models/reply.js +++ b/app/models/reply.js @@ -112,7 +112,11 @@ export class Reply { : stringToBoolean(options?.invalid) || false } - if (this.decision === ReplyDecision.AlreadyVaccinated) { + if ( + [ReplyDecision.AlreadyVaccinated, ReplyDecision.Refused].includes( + this.decision + ) + ) { this.firstDose = options?.firstDose && new Vaccination(options.firstDose) if (options?.firstDose?.scheduled) { diff --git a/app/views/parent/form/check-answers.njk b/app/views/parent/form/check-answers.njk index 062c30884..75131cf2a 100644 --- a/app/views/parent/form/check-answers.njk +++ b/app/views/parent/form/check-answers.njk @@ -179,41 +179,62 @@ ) }) if consent.given }} - {{ summaryList({ - card: { - heading: __("consent.firstDose.label"), - headingSize: "m" - }, - rows: summaryRows(consent, { - createdAt: { - label: __("consent.previousDose.createdAt.label"), - value: consent.firstDose.formatted.createdAt_date, - href: editPath("first-dose-date") - }, - country: { - label: __("consent.previousDose.country.label"), - value: consent.firstDose.formatted.country, - href: editPath("first-dose-country") - } - }) - }) if consent.decision == ReplyDecision.AlreadyVaccinated }} + {% if SessionPresetName.MMR in session.presetNames and consent.decision == ReplyDecision.AlreadyVaccinated %} + {{ summaryList({ + card: { + heading: __("consent.firstDose.label"), + headingSize: "m" + }, + rows: summaryRows(consent, { + createdAt: { + label: __("consent.previousDose.createdAt.label"), + value: consent.firstDose.formatted.createdAt_date, + href: editPath("first-dose-date") + }, + country: { + label: __("consent.previousDose.country.label"), + value: consent.firstDose.formatted.country, + href: editPath("first-dose-country") + } + }) + }) }} - {{ summaryList({ - card: { - heading: __("consent.secondDose.label"), - headingSize: "m" - }, - rows: summaryRows(consent, { - createdAt: { - label: __("consent.previousDose.createdAt.label"), - value: consent.secondDose.formatted.createdAt_date, - href: editPath("second-dose-date") - }, - country: { - label: __("consent.previousDose.country.label"), - value: consent.secondDose.formatted.country, - href: editPath("second-dose-country") - } - }) - }) if consent.decision == ReplyDecision.AlreadyVaccinated }} + {{ summaryList({ + card: { + heading: __("consent.secondDose.label"), + headingSize: "m" + }, + rows: summaryRows(consent, { + createdAt: { + label: __("consent.previousDose.createdAt.label"), + value: consent.secondDose.formatted.createdAt_date, + href: editPath("second-dose-date") + }, + country: { + label: __("consent.previousDose.country.label"), + value: consent.secondDose.formatted.country, + href: editPath("second-dose-country") + } + }) + }) }} + {% elif consent.refusalReason == ReplyRefusal.AlreadyVaccinated %} + {{ summaryList({ + card: { + heading: __("consent.previousDose.label", session.programmes[0].nameSentenceCase), + headingSize: "m" + }, + rows: summaryRows(consent, { + createdAt: { + label: __("consent.previousDose.createdAt.label"), + value: consent.firstDose.formatted.createdAt_date, + href: editPath("previous-dose") + }, + country: { + label: __("consent.previousDose.country.label"), + value: consent.firstDose.formatted.country, + href: editPath("previous-dose") + } + }) + }) }} + {% endif %} {% endblock %} diff --git a/app/views/parent/form/previous-dose.njk b/app/views/parent/form/previous-dose.njk new file mode 100644 index 000000000..c0deddf74 --- /dev/null +++ b/app/views/parent/form/previous-dose.njk @@ -0,0 +1,73 @@ +{% extends "_layouts/form.njk" %} + +{% set title = __("consent.previousDose.title", session.programmes[0].nameSentenceCase) %} + +{% block form %} + {{ appHeading({ + title: title + }) }} + + {{ dateInput({ + fieldset: { + legend: { + text: __("consent.previousDose.createdAt.title"), + size: "m" + } + }, + hint: { text: __("consent.previousDose.createdAt.hint") }, + decorate: "consent.firstDose.createdAt_" + }) }} + + {{ radios({ + fieldset: { + legend: { + text: __("consent.previousDose.country.title"), + size: "m" + } + }, + items: [ + { + text: __("consent.previousDose.country.england") + }, + { + text: __("consent.previousDose.country.scotland") + }, + { + text: __("consent.previousDose.country.wales") + }, + { + text: __("consent.previousDose.country.ni") + }, + { + divider: "or" + }, + { + text: __("consent.previousDose.country.other"), + value: "Other", + conditional: { + html: select({ + label: { text: __("consent.previousDose.countryOther.title") }, + items: otherCountryItems(Country, consent.previousDose.countryOther), + decorate: "consent.firstDose.countryOther", + attributes: { + "data-module": "app-autocomplete" + } + }) + } + } + ], + decorate: "consent.firstDose.country" + }) }} + + {{ input({ + type: "hidden", + value: VaccinationOutcome.AlreadyVaccinated, + decorate: "consent.firstDose.outcome" + }) }} + + {{ input({ + type: "hidden", + value: session.programmes[0].sequenceDefault, + decorate: "consent.firstDose.sequence" + }) }} +{% endblock %}