Skip to content

Commit 31d49ea

Browse files
Support vaccinating children in post-16 education
1 parent 49fd9ea commit 31d49ea

16 files changed

Lines changed: 82 additions & 41 deletions

File tree

app/controllers/patient.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ export const patientController = {
3636

3737
const patient = Patient.findOne(patient_uuid, data)
3838

39-
const recordTitle = patient.post16
40-
? __('patient.label').replace('Child', 'Patient')
41-
: __('patient.label')
39+
const recordTitle =
40+
patient?.age >= 18
41+
? __('patient.label').replace('Child', 'Patient')
42+
: __('patient.label')
4243

4344
response.locals.patient = patient
4445

@@ -190,11 +191,11 @@ export const patientController = {
190191

191192
// Filter by display option
192193
for (const key of [
194+
'agedOutOfProgrammes',
193195
'archived',
194196
'hasImpairment',
195197
'hasAdjustment',
196-
'hasMissingNhsNumber',
197-
'post16'
198+
'hasMissingNhsNumber'
198199
]) {
199200
if (option?.includes(key)) {
200201
results = results.filter((patient) => patient[key])
@@ -224,7 +225,7 @@ export const patientController = {
224225
}))
225226

226227
// Year group filter options
227-
response.locals.yearGroupItems = [...Array(12).keys()].map((yearGroup) => ({
228+
response.locals.yearGroupItems = [...Array(14).keys()].map((yearGroup) => ({
228229
text: formatYearGroup(yearGroup),
229230
value: yearGroup,
230231
checked: yearGroups?.includes(yearGroup) ?? false

app/controllers/reply.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,23 @@ export const replyController = {
6363
patient_uuid: patientSession.patient.uuid,
6464
programme_id: patientSession.programme.id,
6565
session_id: patientSession.session.id,
66-
createdBy_uid: account.uid
66+
createdBy_uid: account.uid,
67+
selfConsent: patientSession?.patient?.post16
6768
},
6869
data
6970
)
7071

7172
// TODO: Use presenter
7273
const reply = new Reply(createdReply, data)
7374

74-
response.redirect(`${reply.uri}/new/respondent`)
75+
let next
76+
if (patientSession?.patient?.post16) {
77+
next = `${reply.uri}/new/decision`
78+
} else {
79+
next = `${reply.uri}/new/respondent`
80+
}
81+
82+
response.redirect(next)
7583
},
7684

7785
update(type) {
@@ -180,10 +188,6 @@ export const replyController = {
180188
response.locals.reply = new Reply(reply, data)
181189
response.locals.patient = patientSession.patient
182190

183-
// Child can self consent if assessed as Gillick competent
184-
const canSelfConsent =
185-
patientSession.gillick?.competent === GillickCompetent.True
186-
187191
// Only ask for programme if more than 1 administered in a session
188192
const isMultiProgrammeSession =
189193
patientSession.session.programmes.length > 1
@@ -215,7 +219,7 @@ export const replyController = {
215219
[`/${reply_uuid}/${type}/programme`]: {}
216220
}),
217221
[`/${reply_uuid}/${type}/decision`]: {
218-
[`/${reply_uuid}/${type}/${reply?.selfConsent ? 'notify-parent' : 'health-answers'}`]:
222+
[`/${reply_uuid}/${type}/${reply?.selfConsent && !patientSession.patient.post16 ? 'notify-parent' : 'health-answers'}`]:
219223
{
220224
data: 'reply.decision',
221225
value: ReplyDecision.Given
@@ -291,9 +295,10 @@ export const replyController = {
291295
)
292296
}
293297

294-
if (canSelfConsent) {
298+
// Child can self consent if assessed as Gillick competent
299+
if (patientSession.gillick?.competent === GillickCompetent.True) {
295300
response.locals.respondentItems.unshift({
296-
text: 'Child (Gillick competent)',
301+
text: `${reply?.patient?.fullName} (child)`,
297302
value: 'self'
298303
})
299304
}

app/controllers/school.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ export const schoolController = {
204204

205205
// Filter by display option
206206
for (const key of [
207+
'agedOutOfProgrammes',
207208
'archived',
208209
'hasImpairment',
209210
'hasAdjustment',
210-
'hasMissingNhsNumber',
211-
'post16'
211+
'hasMissingNhsNumber'
212212
]) {
213213
if (option?.includes(key)) {
214214
results = results.filter((patient) => patient[key])

app/controllers/session.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ export const sessionController = {
337337

338338
// Filter patient by display option
339339
for (const key of [
340+
'agedOutOfProgrammes',
340341
'archived',
341342
'hasImpairment',
342343
'hasAdjustment',
343-
'hasMissingNhsNumber',
344-
'post16'
344+
'hasMissingNhsNumber'
345345
]) {
346346
if (option?.includes(key)) {
347347
results = results.filter(({ patient }) => patient[key])

app/datasets/activity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export default {
77
absent: (session) => `Absent from session at ${session.location.name}`
88
},
99
consent: {
10-
created: ({ decision, parent, selfConsent }) =>
10+
created: ({ child, decision, parent, selfConsent }) =>
1111
selfConsent
12-
? `${decision} by child (Gillick competent)`
12+
? `${decision} by ${child?.fullName} (child)`
1313
: `${decision} by ${parent.fullNameAndRelationship}`,
1414
updated: ({ decision, parent }) =>
1515
`${decision} in updated response from ${parent.fullNameAndRelationship}`,

app/enums.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ export const PatientClinicStatus = {
352352
* @enum {string}
353353
*/
354354
export const PatientConsentStatus = {
355+
SelfConsent: 'Can self-consent',
355356
NotScheduled: 'No request scheduled',
356357
Scheduled: 'Request scheduled',
357358
NoDetails: 'No contact details',

app/generators/child.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export function generateChild() {
111111
{ value: 12, weight: 8 },
112112
{ value: 13, weight: 4 },
113113
{ value: 14, weight: 2 },
114-
{ value: 15, weight: 1 }
114+
{ value: 15, weight: 1 },
115+
{ value: 16, weight: 1 },
116+
{ value: 17, weight: 1 }
115117
])
116118

117119
// Calculate birth year
@@ -131,9 +133,15 @@ export function generateChild() {
131133
school_id = faker.helpers.arrayElement(['888888', '999999'])
132134
}
133135

134-
// Add examples of children who have aged out (over 16)
136+
// Add examples of children in post-16 education
135137
if (faker.datatype.boolean(0.05)) {
136138
dob = faker.date.birthdate({ min: 17, max: 18, mode: 'age' })
139+
school_id = '888888'
140+
}
141+
142+
// Add examples of children who have aged out (over 18)
143+
if (faker.datatype.boolean(0.1)) {
144+
dob = faker.date.birthdate({ min: 19, max: 21, mode: 'age' })
137145
school_id = ''
138146
}
139147

app/locales/en.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ export const en = {
14141414
hasAdjustment: 'Children needing reasonable adjustments',
14151415
hasImpairment: 'Children with impairments',
14161416
hasMissingNhsNumber: 'Children missing an NHS number',
1417-
post16: 'Children aged out of programmes'
1417+
agedOutOfProgrammes: 'Children aged out of programmes'
14181418
},
14191419
archiveReason: {
14201420
label: 'Reason archived'
@@ -1440,8 +1440,8 @@ export const en = {
14401440
hasMissingNhsNumber: {
14411441
label: 'Missing NHS number'
14421442
},
1443-
post16: {
1444-
label: 'Over 16 years old?',
1443+
agedOutOfProgrammes: {
1444+
label: 'Aged out of programmes?',
14451445
status:
14461446
'{{patient.fullName}} is no longer eligible for school age immunisations'
14471447
},

app/models/child.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,22 @@ export class Child {
179179
}
180180

181181
/**
182-
* Is the child over the age of 16?
182+
* Is the child aged 16 or over?
183+
* Children over the age of 16 can self-consent
183184
*
184-
* @returns {boolean} Child is over the age of 16
185+
* @returns {boolean} Child is aged 16 or over
185186
*/
186187
get post16() {
187-
return this.age >= 17
188+
return this.age >= 16
189+
}
190+
191+
/**
192+
* Is the child still eligible for SAIS vaccinations?
193+
*
194+
* @returns {boolean} Child still eligible for SAIS vaccinations
195+
*/
196+
get agedOutOfProgrammes() {
197+
return this.age >= 18
188198
}
189199

190200
/**
@@ -193,7 +203,7 @@ export class Child {
193203
* @returns {number|undefined} Year group, for example 8
194204
*/
195205
get yearGroup() {
196-
if (!this.post16) {
206+
if (!this.agedOutOfProgrammes) {
197207
return getYearGroup(this.dob)
198208
}
199209
}
@@ -283,7 +293,7 @@ export class Child {
283293
Object.values(this.address)
284294
.filter((string) => string)
285295
.join('<br>'),
286-
...(!this.post16 && {
296+
...(!this.agedOutOfProgrammes && {
287297
yearGroup,
288298
yearGroupWithRegistration:
289299
this.registrationGroup && yearGroup

app/models/patient-programme.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class PatientProgramme {
219219
}
220220
}
221221
case PatientStatus.Consent:
222-
return !this.patient?.hasNoContactDetails
222+
return !this.patient?.hasNoContactDetails || this.patient.post16
223223
case PatientStatus.Refused:
224224
return (
225225
this.lastPatientSession?.patientRefused ===
@@ -270,7 +270,10 @@ export class PatientProgramme {
270270
* @returns {boolean} Eligible for programme
271271
*/
272272
get eligible() {
273-
return getCurrentAcademicYear() >= this.year
273+
return (
274+
!this.patient?.agedOutOfProgrammes &&
275+
getCurrentAcademicYear() >= this.year
276+
)
274277
}
275278

276279
/**
@@ -507,7 +510,7 @@ export class PatientProgramme {
507510
get statusNotes() {
508511
switch (this.status) {
509512
case PatientStatus.Ineligible:
510-
return this.patient.post16
513+
return this.patient?.agedOutOfProgrammes
511514
? 'Not eligible for school age immunisation'
512515
: `Eligible from 1 September ${this.year}`
513516
case PatientStatus.Vaccinated:

0 commit comments

Comments
 (0)