Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions app/controllers/parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const parentController = {
data: 'consent.decision',
value: ReplyDecision.Refused
},
[`/${session_id}/${consent_uuid}/new/first-dose`]: {
[`/${session_id}/${consent_uuid}/new/first-dose-country`]: {
data: 'consent.decision',
value: ReplyDecision.AlreadyVaccinated
}
Expand Down Expand Up @@ -181,7 +181,7 @@ export const parentController = {
ReplyRefusal.Medical
]
},
[`/${session_id}/${consent_uuid}/new/first-dose`]: {
[`/${session_id}/${consent_uuid}/new/first-dose-country`]: {
data: 'consent.refusalReason',
value: ReplyRefusal.AlreadyVaccinatedMMR
},
Expand All @@ -195,8 +195,10 @@ export const parentController = {
[`/${session_id}/${consent_uuid}/new/check-answers`]: true
},
// First and second dose journey
[`/${session_id}/${consent_uuid}/new/first-dose`]: {},
[`/${session_id}/${consent_uuid}/new/second-dose`]: {
[`/${session_id}/${consent_uuid}/new/first-dose-country`]: {},
[`/${session_id}/${consent_uuid}/new/first-dose-date`]: {},
[`/${session_id}/${consent_uuid}/new/second-dose-country`]: {},
[`/${session_id}/${consent_uuid}/new/second-dose-date`]: {
[`/${session_id}/${consent_uuid}/new/check-answers`]: true
}
}
Expand Down Expand Up @@ -330,8 +332,8 @@ export const parentController = {

// All previous dose questions use the same view
if (view.includes('-dose')) {
key = `${kebabToCamelCase(view.replace('-dose', ''))}Dose`
view = 'previous-dose'
key = `${view.match(/^(first|second)-dose/)?.[1]}Dose`
view = view.replace(/(?:first|second)(-)/g, 'previous$1')
}

// Only ask for details if question does not have sub-questions
Expand Down
2 changes: 1 addition & 1 deletion app/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ export const ReplyRefusal = {
GelatineMMR:
'Do not want my child to have the MMR vaccine that contains gelatine',
AlreadyVaccinated: 'Vaccine already received',
AlreadyVaccinatedMMR: 'Already had both doses of the MMR vaccination',
AlreadyVaccinatedMMR: 'Already had both doses of the MMR vaccine',
GettingElsewhere: 'Vaccine will be given elsewhere',
Medical: 'Medical reasons',
OutsideSchool: 'Do not want vaccination in school',
Expand Down
53 changes: 34 additions & 19 deletions app/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export const en = {
hint: 'This is suitable for children who do not use gelatine products, or if they cannot have the nasal spray vaccine for medical reasons'
},
alreadyVaccinated: {
label: 'My child has already had both doses of the MMR vaccination',
label: 'My child has already had both doses of the MMR vaccine',
hint: 'Children need 2 doses of the MMR vaccine to be fully protected'
},
no: {
Expand Down Expand Up @@ -578,7 +578,7 @@ export const en = {
other: ReplyRefusal.AlreadyVaccinated.replace('Vaccine', 'Vaccines')
},
alreadyVaccinatedMMR:
'My child has already had both doses of the MMR vaccination',
'My child has already had both doses of the MMR vaccine',
gettingElsewhere: {
one: ReplyRefusal.GettingElsewhere,
other: ReplyRefusal.GettingElsewhere.replace('Vaccine', 'Vaccines')
Expand All @@ -599,36 +599,43 @@ export const en = {
label: 'Details of 1st MMR dose',
title: 'When and where did your child get their 1st MMR dose?',
description: 'The 1st dose is usually offered at 12 months',
country: {
title:
'Which country was the 1st dose of the MMR vaccination given in?',
label: 'Country'
},
createdAt: {
title: 'When was the 1st dose given?',
label: 'Date of vaccination'
},
location: {
label: 'Location'
},
country: {
label: 'Country'
scheduled: {
title: 'Was the 1st dose given when your child was 12 months old?',
hint: 'This is usually the child’s age when the 1st dose is offered'
}
},
secondDose: {
label: 'Details of 2nd MMR dose',
title: 'When and where did your child get their 2nd MMR dose?',
description:
'The 2nd dose is usually offered when children are 3 years old'
},
previousDose: {
createdAt: {
label: 'Date',
title: 'Date of vaccination',
hint: 'If you do not know the exact date of the vaccination, you can leave the day field empty and enter your best guess for the month'
'The 2nd dose is usually offered when children are 3 years and 4 months old',
country: {
title:
'Which country was the 2nd dose of the MMR vaccination given in?',
label: 'Country'
},
location: {
label: 'Location',
title: 'Location',
hint: 'Give the name and address of the GP surgery if you can remember it'
createdAt: {
title: 'When was the 2nd dose given?',
label: 'Date of vaccination'
},
scheduled: {
title:
'Was the 2nd dose given when your child was 3 years and 4 months old?',
hint: 'This is usually the child’s age when the 2nd dose is offered'
}
},
previousDose: {
country: {
label: 'Country',
title: 'Country',
england: 'England',
scotland: 'Scotland',
wales: 'Wales',
Expand All @@ -637,6 +644,14 @@ export const en = {
},
countryOther: {
title: 'Which country was the vaccination given in?'
},
createdAt: {
label: 'Date',
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: {
yes: 'Yes',
no: 'No'
}
},
healthAnswers: {
Expand Down
12 changes: 11 additions & 1 deletion app/models/reply.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fakerEN_GB as faker } from '@faker-js/faker'
import { addMonths } from 'date-fns'
import _ from 'lodash'

import vaccines from '../datasets/vaccines.js'
Expand Down Expand Up @@ -87,7 +88,7 @@ export class Reply {
// Some values only valid if the consent request was received
if (this.delivered) {
this.decision =
options.refusalReason === ReplyRefusal.AlreadyVaccinatedMMR
options?.refusalReason === ReplyRefusal.AlreadyVaccinatedMMR
? ReplyDecision.AlreadyVaccinated
: options?.decision
this.alternative =
Expand All @@ -111,8 +112,17 @@ export class Reply {

if (this.decision === ReplyDecision.AlreadyVaccinated) {
this.firstDose = options?.firstDose && new Vaccination(options.firstDose)

if (options?.firstDose?.scheduled) {
this.firstDose.createdAt = addMonths(this.child?.dob, 12)
}

this.secondDose =
options?.secondDose && new Vaccination(options.secondDose)

if (options?.secondDose?.scheduled) {
this.secondDose.createdAt = addMonths(this.child?.dob, 40)
}
}

if (
Expand Down
4 changes: 3 additions & 1 deletion app/models/vaccination.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {
* @property {number} [dose] - Dosage (ml)
* @property {string} [sequence] - Dose sequence
* @property {string} [protocol] - Protocol
* @property {boolean} [scheduled] - Vaccination date was on schedule
* @property {string} [note] - Note
* @property {string} [country] - Country
* @property {string} [clinic_id] - Clinic ID
Expand All @@ -100,7 +101,7 @@ export class Vaccination {
this.updatedAt = options?.updatedAt && new Date(options.updatedAt)
this.locationType = options?.locationType
this.country = options?.country
this.countryOther = options?.countryOther
this.countryOther = this.country === 'Other' && options?.countryOther
this.selfId = options?.selfId && stringToBoolean(options.selfId)
this.identifiedBy = this.selfId !== true && options?.identifiedBy
this.outcome = options?.outcome
Expand All @@ -116,6 +117,7 @@ export class Vaccination {
this.protocol = this.given
? options?.protocol || VaccinationProtocol.PGD
: undefined
this.scheduled = stringToBoolean(options.scheduled)
this.note = options?.note || ''
this.country = 'England'
this.clinic_id = options?.clinic_id
Expand Down
22 changes: 6 additions & 16 deletions app/views/parent/form/check-answers.njk
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,13 @@
rows: summaryRows(consent, {
createdAt: {
label: __("consent.previousDose.createdAt.label"),
value: consent.firstDose.formatted.createdAt,
href: editPath("first-dose")
},
location: {
label: __("consent.previousDose.location.label"),
value: consent.firstDose.location,
href: editPath("first-dose")
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")
href: editPath("first-dose-country")
}
})
}) if consent.decision == ReplyDecision.AlreadyVaccinated }}
Expand All @@ -211,18 +206,13 @@
rows: summaryRows(consent, {
createdAt: {
label: __("consent.previousDose.createdAt.label"),
value: consent.secondDose.formatted.createdAt,
href: editPath("second-dose")
},
location: {
label: __("consent.previousDose.location.label"),
value: consent.secondDose.location,
href: editPath("second-dose")
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")
href: editPath("second-dose-country")
}
})
}) if consent.decision == ReplyDecision.AlreadyVaccinated }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,14 @@
{% extends "_layouts/form.njk" %}

{% set title = __("consent." + key + ".title") %}
{% set title = __("consent." + key + ".country.title") %}

{% block form %}
{{ appHeading({
title: title
}) }}

{{ __("consent." + key + ".description") | nhsukMarkdown }}

{{ input({
type: "hidden",
value: VaccinationOutcome.AlreadyVaccinated,
decorate: ["consent", key, "outcome"]
}) }}

{{ input({
type: "hidden",
value: "1P" if key == "firstDose" else "2P",
decorate: ["consent", key, "sequence"]
}) }}

{{ dateInput({
fieldset: {
legend: {
text: __("consent.previousDose.createdAt.title"),
size: "m"
}
},
hint: { text: __("consent.previousDose.createdAt.hint") },
decorate: ["consent", key, "createdAt_"]
}) }}

{{ input({
label: {
text: __("consent.previousDose.location.title"),
size: "m"
},
hint: { text: __("consent.previousDose.location.hint") },
decorate: ["consent", key, "location"]
}) }}

{{ radios({
fieldset: {
legend: {
text: __("consent.previousDose.country.title"),
size: "m"
isPageHeading: true,
text: title,
size: "l"
}
},
items: [
Expand All @@ -66,6 +29,7 @@
},
{
text: __("consent.previousDose.country.other"),
value: "Other",
conditional: {
html: select({
label: { text: __("consent.previousDose.countryOther.title") },
Expand All @@ -80,4 +44,16 @@
],
decorate: ["consent", key, "country"]
}) }}

{{ input({
type: "hidden",
value: VaccinationOutcome.AlreadyVaccinated,
decorate: ["consent", key, "outcome"]
}) }}

{{ input({
type: "hidden",
value: "1P" if key == "firstDose" else "2P",
decorate: ["consent", key, "sequence"]
}) }}
{% endblock %}
57 changes: 57 additions & 0 deletions app/views/parent/form/previous-dose-date.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% extends "_layouts/form.njk" %}

{% set domestic = consent[key].country in ["England", "Scotland", "Wales", "Northern Ireland"] %}
{% if domestic %}
{% set title = __("consent." + key + ".scheduled.title") %}
{% else %}
{% set title = __("consent." + key + ".createdAt.title") %}
{% endif %}

{% block form %}
{% if domestic %}
{{ radios({
fieldset: {
legend: {
isPageHeading: true,
text: title,
size: "l"
}
},
hint: {
text: __("consent." + key + ".scheduled.hint")
},
items: [
{
text: __("consent.previousDose.scheduled.yes")
},
{
text: __("consent.previousDose.scheduled.no"),
conditional: {
html: dateInput({
fieldset: {
legend: {
text: __("consent." + key + ".createdAt.title")
}
},
hint: { text: __("consent.previousDose.createdAt.hint") },
decorate: ["consent", key, "createdAt_"]
})
}
}
],
decorate: ["consent", key, "scheduled"]
}) }}
{% else %}
{{ dateInput({
fieldset: {
legend: {
isPageHeading: true,
text: title,
size: "l"
}
},
hint: { text: __("consent.previousDose.createdAt.hint") },
decorate: ["consent", key, "createdAt_"]
}) }}
{% endif %}
{% endblock %}