Skip to content

Commit b791443

Browse files
Record a previous vaccination when getting verbal consent
1 parent 97f70cf commit b791443

6 files changed

Lines changed: 133 additions & 38 deletions

File tree

app/controllers/patient-session.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const patientSessionController = {
9292
canGillick:
9393
programme.type !== ProgrammeType.Flu &&
9494
session.isActive &&
95+
!vaccinated &&
9596
!consentGiven,
9697
// Patient can be triaged
9798
canTriage: consentGiven,

app/controllers/reply.js

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const replyController = {
7979
const { account, invalidUuid } = request.app.locals
8080
const { reply_uuid } = request.params
8181
const { data } = request.session
82-
const { __, patientSession, triage } = response.locals
82+
const { __, patientSession, triage, vaccination } = response.locals
8383

8484
let reply
8585
let next
@@ -106,6 +106,32 @@ export const replyController = {
106106
})
107107
}
108108

109+
// Create vaccination if refusal reason is vaccination already given
110+
if (reply?.refusalReason === ReplyRefusal.AlreadyVaccinated) {
111+
const createdVaccination = Vaccination.create(
112+
{
113+
outcome: VaccinationOutcome.AlreadyVaccinated,
114+
patient_uuid: patientSession.patient.uuid,
115+
patientSession_uuid: patientSession.uuid,
116+
programme_id: patientSession.programme.id,
117+
session_id: patientSession.session.id,
118+
createdBy_uid: account.uid || '000123456789',
119+
createdAt_: vaccination.createdAt_,
120+
clinic_id: vaccination.clinic_id,
121+
school_id: vaccination.school_id,
122+
locationName: vaccination.locationName,
123+
addressLine1: vaccination.addressLine1,
124+
addressLine2: vaccination.addressLine2,
125+
addressLevel1: vaccination.addressLevel1,
126+
country: vaccination.country,
127+
locationType: vaccination.locationType
128+
},
129+
data
130+
)
131+
132+
patientSession.patient.recordVaccination(createdVaccination)
133+
}
134+
109135
// Invalidate any replaced response
110136
if (invalidUuid) {
111137
Reply.update(invalidUuid, { invalid: true }, data)
@@ -122,6 +148,7 @@ export const replyController = {
122148
// Clean up session data
123149
delete data.reply
124150
delete data.triage
151+
delete data.vaccination
125152

126153
request.flash(
127154
'success',
@@ -136,7 +163,7 @@ export const replyController = {
136163
return (request, response, next) => {
137164
const { reply_uuid } = request.params
138165
const { data, referrer } = request.session
139-
const { patientSession, triage } = response.locals
166+
const { patientSession, triage, vaccination } = response.locals
140167

141168
let reply
142169
if (type === 'edit') {
@@ -172,6 +199,11 @@ export const replyController = {
172199
...data?.wizard?.triage // Wizard values
173200
}
174201

202+
response.locals.vaccination = {
203+
...(type === 'edit' && vaccination), // Previous values
204+
...data?.wizard?.vaccination // Wizard values
205+
}
206+
175207
const journey = {
176208
[`/`]: {},
177209
[`/${reply_uuid}/${type}/respondent`]: {},
@@ -204,11 +236,11 @@ export const replyController = {
204236
[`/${reply_uuid}/${type}/refusal-reason`]: {
205237
[`/${reply_uuid}/${type}/refusal-reason-details`]: {
206238
data: 'reply.refusalReason',
207-
values: [
208-
ReplyRefusal.AlreadyVaccinated,
209-
ReplyRefusal.GettingElsewhere,
210-
ReplyRefusal.Medical
211-
]
239+
values: [ReplyRefusal.GettingElsewhere, ReplyRefusal.Medical]
240+
},
241+
[`/${reply_uuid}/${type}/refusal-already-vaccinated`]: {
242+
data: 'reply.refusalReason',
243+
value: ReplyRefusal.AlreadyVaccinated
212244
},
213245
[`/${reply_uuid}/${type}/refusal-notification`]: {
214246
data: 'reply.refusalReason',
@@ -294,13 +326,12 @@ export const replyController = {
294326
},
295327

296328
updateForm(request, response) {
297-
const { account } = request.app.locals
298329
const { respondent } = request.body
299330
const { reply_uuid } = request.params
300331
const { data } = request.session
301-
const { paths, patientSession, reply, triage } = response.locals
332+
let { paths, patientSession, triage, vaccination } = response.locals
302333

303-
Reply.update(reply_uuid, request.body.reply, data.wizard)
334+
const reply = Reply.update(reply_uuid, request.body.reply, data.wizard)
304335

305336
// Create parent based on choice of respondent
306337
if (respondent) {
@@ -312,7 +343,7 @@ export const replyController = {
312343
break
313344
case 'self':
314345
reply.method = ReplyMethod.InPerson
315-
reply.parent = false
346+
reply.parent = null
316347
reply.selfConsent = true
317348
break
318349
case 'parent-1': // Consent response is from CHIS record
@@ -336,27 +367,19 @@ export const replyController = {
336367
}
337368
}
338369

339-
// Store vaccination if refusal reason is vaccination already given
340-
if (request.body.reply?.refusalReason === ReplyRefusal.AlreadyVaccinated) {
341-
response.locals.vaccination = {
342-
outcome: VaccinationOutcome.AlreadyVaccinated,
343-
patient_uuid: patientSession.patient.uuid,
344-
session_id: patientSession.session.id,
345-
createdBy_uid: account.uid,
346-
...(data.reply?.note && { note: data.reply.note })
347-
}
348-
}
349-
350370
delete data.healthAnswers
351371
delete data.respondent
352372

353-
Reply.update(reply_uuid, reply, data.wizard)
354-
355373
data.wizard.triage = {
356374
...triage, // Previous values
357375
...request.body?.triage // New value
358376
}
359377

378+
data.wizard.vaccination = {
379+
...vaccination, // Previous values
380+
...request?.body?.vaccination // Wizard values
381+
}
382+
360383
response.redirect(
361384
paths.next ||
362385
`${patientSession.uri}/replies/${reply_uuid}/new/check-answers`

app/locales/en.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,14 +1799,15 @@ export const en = {
17991799
refusalReasonDetails: {
18001800
label: 'Refusal details',
18011801
title: {
1802-
[ReplyRefusal.AlreadyVaccinated]:
1803-
'Where did the child get their vaccination?',
18041802
[ReplyRefusal.GettingElsewhere]:
18051803
'Where will the child get their vaccination?',
18061804
[ReplyRefusal.Medical]:
18071805
'What medical reasons prevent the child from being vaccinated?'
18081806
}
18091807
},
1808+
alreadyVaccinated: {
1809+
title: 'When and where did the child get their vaccination?'
1810+
},
18101811
note: {
18111812
title: 'Notes',
18121813
label: 'Notes'

app/models/patient.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ export class Patient extends Child {
718718
this.vaccination_uuids.push(vaccination.uuid)
719719

720720
this.addEvent({
721-
name: activity.vaccination.recorded(vaccination),
721+
name: 'activity.vaccination.recorded(vaccination)',
722722
note: vaccination.note,
723723
createdAt: vaccination.updatedAt || vaccination.createdAt,
724724
createdBy_uid: vaccination.createdBy_uid,
@@ -745,15 +745,17 @@ export class Patient extends Child {
745745
}
746746

747747
for (const parent of this.parents) {
748-
this.addEvent({
749-
name: activity.notify['vaccination-reminder'](parent),
750-
messageRecipient: parent,
751-
messageTemplate: 'vaccination-reminder',
752-
createdAt: removeDays(vaccination.createdAt, 7),
753-
patient_uuid: this.uuid,
754-
programme_ids: [vaccination.programme_id],
755-
session_id: vaccination.session.id
756-
})
748+
if (vaccination.outcome !== VaccinationOutcome.AlreadyVaccinated) {
749+
this.addEvent({
750+
name: activity.notify['vaccination-reminder'](parent),
751+
messageRecipient: parent,
752+
messageTemplate: 'vaccination-reminder',
753+
createdAt: removeDays(vaccination.createdAt, 7),
754+
patient_uuid: this.uuid,
755+
programme_ids: [vaccination.programme_id],
756+
session_id: vaccination.session.id
757+
})
758+
}
757759

758760
this.addEvent({
759761
name: activity.notify[messageTemplate](parent),
@@ -762,7 +764,7 @@ export class Patient extends Child {
762764
createdAt: vaccination.updatedAt || vaccination.createdAt,
763765
patient_uuid: this.uuid,
764766
programme_ids: [vaccination.programme_id],
765-
session_id: vaccination.session.id,
767+
session_id: vaccination.session?.id,
766768
vaccination_uuid: vaccination.uuid
767769
})
768770
}

app/views/patient-session/show.njk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
{% block content %}
2424
{{ super() }}
25-
2625
<div class="nhsuk-grid-row">
2726
<div class="app-grid-column-patient-record" data-module="app-sticky">
2827
{{ summaryList({
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{% extends "_layouts/form.njk" %}
2+
3+
{% set title = __("reply.alreadyVaccinated.title") %}
4+
5+
{% block form %}
6+
{{ appHeading({
7+
caption: patient.fullName,
8+
title: title
9+
}) }}
10+
11+
{{ dateInput({
12+
fieldset: {
13+
legend: {
14+
classes: "nhsuk-fieldset__legend--m",
15+
text: __("vaccination.createdAt_date.label")
16+
}
17+
},
18+
hint: { text: __("vaccination.createdAt_date.hint") },
19+
decorate: "vaccination.createdAt_"
20+
}) }}
21+
22+
{{ radios({
23+
fieldset: {
24+
legend: {
25+
classes: "nhsuk-fieldset__legend--m",
26+
text: __("vaccination.location.label")
27+
}
28+
},
29+
items: [
30+
{
31+
text: LocationType.Home
32+
},
33+
{
34+
text: LocationType.Clinic,
35+
conditional: {
36+
html: select({
37+
label: { text: __("vaccination.clinic_id.title") },
38+
items: locationItems(data.clinics, vaccination.clinic_id),
39+
decorate: "vaccination.clinic_id",
40+
attributes: {
41+
"data-module": "app-autocomplete"
42+
}
43+
})
44+
}
45+
},
46+
{
47+
text: LocationType.School,
48+
conditional: {
49+
html: select({
50+
label: { text: __("vaccination.school_id.title") },
51+
items: locationItems(data.schools, vaccination.school_id),
52+
decorate: "vaccination.school_id",
53+
attributes: {
54+
"data-module": "app-autocomplete"
55+
}
56+
})
57+
}
58+
},
59+
{
60+
divider: "or"
61+
},
62+
{
63+
text: LocationType.Other,
64+
hint: { text: __("vaccination.locationOther.hint") }
65+
}
66+
],
67+
decorate: "vaccination.locationType"
68+
}) }}
69+
{% endblock %}

0 commit comments

Comments
 (0)