Skip to content

Commit 257f7ef

Browse files
Update consent flow for recording previous doses of MMR
1 parent 3e63382 commit 257f7ef

7 files changed

Lines changed: 134 additions & 82 deletions

File tree

app/controllers/parent.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const parentController = {
150150
data: 'consent.decision',
151151
value: ReplyDecision.Refused
152152
},
153-
[`/${session_id}/${consent_uuid}/new/first-dose`]: {
153+
[`/${session_id}/${consent_uuid}/new/first-dose-country`]: {
154154
data: 'consent.decision',
155155
value: ReplyDecision.AlreadyVaccinated
156156
}
@@ -181,7 +181,7 @@ export const parentController = {
181181
ReplyRefusal.Medical
182182
]
183183
},
184-
[`/${session_id}/${consent_uuid}/new/first-dose`]: {
184+
[`/${session_id}/${consent_uuid}/new/first-dose-country`]: {
185185
data: 'consent.refusalReason',
186186
value: ReplyRefusal.AlreadyVaccinatedMMR
187187
},
@@ -195,8 +195,10 @@ export const parentController = {
195195
[`/${session_id}/${consent_uuid}/new/check-answers`]: true
196196
},
197197
// First and second dose journey
198-
[`/${session_id}/${consent_uuid}/new/first-dose`]: {},
199-
[`/${session_id}/${consent_uuid}/new/second-dose`]: {
198+
[`/${session_id}/${consent_uuid}/new/first-dose-country`]: {},
199+
[`/${session_id}/${consent_uuid}/new/first-dose-date`]: {},
200+
[`/${session_id}/${consent_uuid}/new/second-dose-country`]: {},
201+
[`/${session_id}/${consent_uuid}/new/second-dose-date`]: {
200202
[`/${session_id}/${consent_uuid}/new/check-answers`]: true
201203
}
202204
}
@@ -330,8 +332,8 @@ export const parentController = {
330332

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

337339
// Only ask for details if question does not have sub-questions

app/locales/en.js

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -599,36 +599,43 @@ export const en = {
599599
label: 'Details of 1st MMR dose',
600600
title: 'When and where did your child get their 1st MMR dose?',
601601
description: 'The 1st dose is usually offered at 12 months',
602+
country: {
603+
title:
604+
'Which country was the 1st dose of the MMR vaccination given in?',
605+
label: 'Country'
606+
},
602607
createdAt: {
608+
title: 'When was the 1st dose given?',
603609
label: 'Date of vaccination'
604610
},
605-
location: {
606-
label: 'Location'
607-
},
608-
country: {
609-
label: 'Country'
611+
scheduled: {
612+
title: 'Was the 1st dose given when your child was 12 months old?',
613+
hint: 'This is usually the child’s age when the 1st dose is offered'
610614
}
611615
},
612616
secondDose: {
613617
label: 'Details of 2nd MMR dose',
614618
title: 'When and where did your child get their 2nd MMR dose?',
615619
description:
616-
'The 2nd dose is usually offered when children are 3 years old'
617-
},
618-
previousDose: {
619-
createdAt: {
620-
label: 'Date',
621-
title: 'Date of vaccination',
622-
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'
620+
'The 2nd dose is usually offered when children are 3 years and 4 months old',
621+
country: {
622+
title:
623+
'Which country was the 2nd dose of the MMR vaccination given in?',
624+
label: 'Country'
623625
},
624-
location: {
625-
label: 'Location',
626-
title: 'Location',
627-
hint: 'Give the name and address of the GP surgery if you can remember it'
626+
createdAt: {
627+
title: 'When was the 2nd dose given?',
628+
label: 'Date of vaccination'
628629
},
630+
scheduled: {
631+
title:
632+
'Was the 2nd dose given when your child was 3 years and 4 months old?',
633+
hint: 'This is usually the child’s age when the 2nd dose is offered'
634+
}
635+
},
636+
previousDose: {
629637
country: {
630638
label: 'Country',
631-
title: 'Country',
632639
england: 'England',
633640
scotland: 'Scotland',
634641
wales: 'Wales',
@@ -637,6 +644,14 @@ export const en = {
637644
},
638645
countryOther: {
639646
title: 'Which country was the vaccination given in?'
647+
},
648+
createdAt: {
649+
label: 'Date',
650+
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'
651+
},
652+
scheduled: {
653+
yes: 'Yes',
654+
no: 'No'
640655
}
641656
},
642657
healthAnswers: {

app/models/reply.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { fakerEN_GB as faker } from '@faker-js/faker'
2+
import { addMonths } from 'date-fns'
23
import _ from 'lodash'
34

45
import vaccines from '../datasets/vaccines.js'
@@ -87,7 +88,7 @@ export class Reply {
8788
// Some values only valid if the consent request was received
8889
if (this.delivered) {
8990
this.decision =
90-
options.refusalReason === ReplyRefusal.AlreadyVaccinatedMMR
91+
options?.refusalReason === ReplyRefusal.AlreadyVaccinatedMMR
9192
? ReplyDecision.AlreadyVaccinated
9293
: options?.decision
9394
this.alternative =
@@ -111,8 +112,17 @@ export class Reply {
111112

112113
if (this.decision === ReplyDecision.AlreadyVaccinated) {
113114
this.firstDose = options?.firstDose && new Vaccination(options.firstDose)
115+
116+
if (options?.firstDose?.scheduled) {
117+
this.firstDose.createdAt = addMonths(this.child?.dob, 12)
118+
}
119+
114120
this.secondDose =
115121
options?.secondDose && new Vaccination(options.secondDose)
122+
123+
if (options?.secondDose?.scheduled) {
124+
this.secondDose.createdAt = addMonths(this.child?.dob, 40)
125+
}
116126
}
117127

118128
if (

app/models/vaccination.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
* @property {number} [dose] - Dosage (ml)
7575
* @property {string} [sequence] - Dose sequence
7676
* @property {string} [protocol] - Protocol
77+
* @property {boolean} [scheduled] - Vaccination date was on schedule
7778
* @property {string} [note] - Note
7879
* @property {string} [country] - Country
7980
* @property {string} [clinic_id] - Clinic ID
@@ -100,7 +101,7 @@ export class Vaccination {
100101
this.updatedAt = options?.updatedAt && new Date(options.updatedAt)
101102
this.locationType = options?.locationType
102103
this.country = options?.country
103-
this.countryOther = options?.countryOther
104+
this.countryOther = this.country === 'Other' && options?.countryOther
104105
this.selfId = options?.selfId && stringToBoolean(options.selfId)
105106
this.identifiedBy = this.selfId !== true && options?.identifiedBy
106107
this.outcome = options?.outcome
@@ -116,6 +117,7 @@ export class Vaccination {
116117
this.protocol = this.given
117118
? options?.protocol || VaccinationProtocol.PGD
118119
: undefined
120+
this.scheduled = stringToBoolean(options.scheduled)
119121
this.note = options?.note || ''
120122
this.country = 'England'
121123
this.clinic_id = options?.clinic_id

app/views/parent/form/check-answers.njk

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,13 @@
187187
rows: summaryRows(consent, {
188188
createdAt: {
189189
label: __("consent.previousDose.createdAt.label"),
190-
value: consent.firstDose.formatted.createdAt,
191-
href: editPath("first-dose")
192-
},
193-
location: {
194-
label: __("consent.previousDose.location.label"),
195-
value: consent.firstDose.location,
196-
href: editPath("first-dose")
190+
value: consent.firstDose.formatted.createdAt_date,
191+
href: editPath("first-dose-date")
197192
},
198193
country: {
199194
label: __("consent.previousDose.country.label"),
200195
value: consent.firstDose.formatted.country,
201-
href: editPath("first-dose")
196+
href: editPath("first-dose-country")
202197
}
203198
})
204199
}) if consent.decision == ReplyDecision.AlreadyVaccinated }}
@@ -211,18 +206,13 @@
211206
rows: summaryRows(consent, {
212207
createdAt: {
213208
label: __("consent.previousDose.createdAt.label"),
214-
value: consent.secondDose.formatted.createdAt,
215-
href: editPath("second-dose")
216-
},
217-
location: {
218-
label: __("consent.previousDose.location.label"),
219-
value: consent.secondDose.location,
220-
href: editPath("second-dose")
209+
value: consent.secondDose.formatted.createdAt_date,
210+
href: editPath("second-dose-date")
221211
},
222212
country: {
223213
label: __("consent.previousDose.country.label"),
224214
value: consent.secondDose.formatted.country,
225-
href: editPath("second-dose")
215+
href: editPath("second-dose-country")
226216
}
227217
})
228218
}) if consent.decision == ReplyDecision.AlreadyVaccinated }}
Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,14 @@
11
{% extends "_layouts/form.njk" %}
22

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

55
{% block form %}
6-
{{ appHeading({
7-
title: title
8-
}) }}
9-
10-
{{ __("consent." + key + ".description") | nhsukMarkdown }}
11-
12-
{{ input({
13-
type: "hidden",
14-
value: VaccinationOutcome.AlreadyVaccinated,
15-
decorate: ["consent", key, "outcome"]
16-
}) }}
17-
18-
{{ input({
19-
type: "hidden",
20-
value: "1P" if key == "firstDose" else "2P",
21-
decorate: ["consent", key, "sequence"]
22-
}) }}
23-
24-
{{ dateInput({
25-
fieldset: {
26-
legend: {
27-
text: __("consent.previousDose.createdAt.title"),
28-
size: "m"
29-
}
30-
},
31-
hint: { text: __("consent.previousDose.createdAt.hint") },
32-
decorate: ["consent", key, "createdAt_"]
33-
}) }}
34-
35-
{{ input({
36-
label: {
37-
text: __("consent.previousDose.location.title"),
38-
size: "m"
39-
},
40-
hint: { text: __("consent.previousDose.location.hint") },
41-
decorate: ["consent", key, "location"]
42-
}) }}
43-
446
{{ radios({
457
fieldset: {
468
legend: {
47-
text: __("consent.previousDose.country.title"),
48-
size: "m"
9+
isPageHeading: true,
10+
text: title,
11+
size: "l"
4912
}
5013
},
5114
items: [
@@ -66,6 +29,7 @@
6629
},
6730
{
6831
text: __("consent.previousDose.country.other"),
32+
value: "Other",
6933
conditional: {
7034
html: select({
7135
label: { text: __("consent.previousDose.countryOther.title") },
@@ -80,4 +44,16 @@
8044
],
8145
decorate: ["consent", key, "country"]
8246
}) }}
47+
48+
{{ input({
49+
type: "hidden",
50+
value: VaccinationOutcome.AlreadyVaccinated,
51+
decorate: ["consent", key, "outcome"]
52+
}) }}
53+
54+
{{ input({
55+
type: "hidden",
56+
value: "1P" if key == "firstDose" else "2P",
57+
decorate: ["consent", key, "sequence"]
58+
}) }}
8359
{% endblock %}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{% extends "_layouts/form.njk" %}
2+
3+
{% set domestic = consent[key].country in ["England", "Scotland", "Wales", "Northern Ireland"] %}
4+
{% if domestic %}
5+
{% set title = __("consent." + key + ".scheduled.title") %}
6+
{% else %}
7+
{% set title = __("consent." + key + ".createdAt.title") %}
8+
{% endif %}
9+
10+
{% block form %}
11+
{% if domestic %}
12+
{{ radios({
13+
fieldset: {
14+
legend: {
15+
isPageHeading: true,
16+
text: title,
17+
size: "l"
18+
}
19+
},
20+
hint: {
21+
text: __("consent." + key + ".scheduled.hint")
22+
},
23+
items: [
24+
{
25+
text: __("consent.previousDose.scheduled.yes")
26+
},
27+
{
28+
text: __("consent.previousDose.scheduled.no"),
29+
conditional: {
30+
html: dateInput({
31+
fieldset: {
32+
legend: {
33+
text: __("consent." + key + ".createdAt.title")
34+
}
35+
},
36+
hint: { text: __("consent.previousDose.createdAt.hint") },
37+
decorate: ["consent", key, "createdAt_"]
38+
})
39+
}
40+
}
41+
],
42+
decorate: ["consent", key, "scheduled"]
43+
}) }}
44+
{% else %}
45+
{{ dateInput({
46+
fieldset: {
47+
legend: {
48+
isPageHeading: true,
49+
text: title,
50+
size: "l"
51+
}
52+
},
53+
hint: { text: __("consent.previousDose.createdAt.hint") },
54+
decorate: ["consent", key, "createdAt_"]
55+
}) }}
56+
{% endif %}
57+
{% endblock %}

0 commit comments

Comments
 (0)