Skip to content

Commit a377687

Browse files
Review activity log items
1 parent f11a87a commit a377687

18 files changed

Lines changed: 645 additions & 110 deletions

File tree

app/assets/stylesheets/components/_details.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,21 @@
1212
@include nhsuk-responsive-padding(4, "right");
1313
}
1414
}
15+
16+
.app-details--notify-message {
17+
.nhsuk-details__text {
18+
padding: nhsuk-spacing(4);
19+
border: 1px solid $nhsuk-border-colour;
20+
background-color: nhsuk-colour("white");
21+
font-family: Helvetica, Arial, sans-serif;
22+
23+
.nhsuk-inset-text {
24+
margin-top: 0;
25+
border-color: $nhsuk-border-colour;
26+
27+
@include nhsuk-responsive-padding(2, "bottom");
28+
@include nhsuk-responsive-padding(2, "top");
29+
@include nhsuk-responsive-margin(4, "bottom");
30+
}
31+
}
32+
}

app/controllers/activity.js

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
import activity from '../datasets/activity.js'
2+
import { ArchiveRecordReason, AuditEventType, ScreenOutcome } from '../enums.js'
3+
import { generateParent } from '../generators/parent.js'
4+
import {
5+
AuditEvent,
6+
Gillick,
7+
Patient,
8+
Reply,
9+
Session,
10+
Vaccination
11+
} from '../models.js'
12+
13+
export const activityController = {
14+
list(request, response) {
15+
const { data } = request.session
16+
17+
const auditEvent = (event) => new AuditEvent(event, data)
18+
const createdBy_uid = Object.values(data.users)[0].uid
19+
const gillickCompetent = new Gillick({
20+
q1: true,
21+
q2: true,
22+
q3: true,
23+
q4: true,
24+
q5: true
25+
})
26+
const gillickNotCompetent = new Gillick({
27+
q1: true,
28+
q2: true,
29+
q3: true,
30+
q4: true,
31+
q5: false
32+
})
33+
const patient = Patient.findAll(data).find(
34+
({ hasMissingNhsNumber, invalid }) => !hasMissingNhsNumber && !invalid
35+
)
36+
const parent = generateParent(patient.lastName)
37+
const mergedPatient = Patient.findAll(data).find(
38+
({ uuid, hasMissingNhsNumber, invalid }) =>
39+
uuid !== patient.uuid && !hasMissingNhsNumber && !invalid
40+
)
41+
const reply = Reply.findAll(data).find((reply) => !reply.selfConsent)
42+
const session = Session.findOne(Object.values(data.sessions)[0].id, data)
43+
const vaccinationGiven = Vaccination.findAll(data).find(
44+
(vaccination) => vaccination.given
45+
)
46+
const vaccinationNotGiven = Vaccination.findAll(data).find(
47+
(vaccination) => !vaccination.given
48+
)
49+
50+
const activityLog = [
51+
{
52+
title: 'Attendance',
53+
items: [
54+
auditEvent({
55+
name: activity.attendance.present(session),
56+
createdBy_uid,
57+
programme_ids: ['menacwy', 'td-ipv']
58+
}),
59+
auditEvent({
60+
name: activity.attendance.absent(session),
61+
createdBy_uid,
62+
programme_ids: ['menacwy', 'td-ipv']
63+
})
64+
]
65+
},
66+
{
67+
title: 'Consent',
68+
items: [
69+
auditEvent({
70+
name: activity.consent.created(reply),
71+
createdBy_uid,
72+
programme_ids: ['flu']
73+
}),
74+
auditEvent({
75+
name: activity.consent.updated(reply),
76+
createdBy_uid,
77+
programme_ids: ['flu']
78+
}),
79+
auditEvent({
80+
name: activity.consent.matched(reply),
81+
createdBy_uid,
82+
programme_ids: ['flu']
83+
}),
84+
auditEvent({
85+
name: activity.consent.invalid(reply),
86+
createdBy_uid,
87+
programme_ids: ['flu']
88+
}),
89+
auditEvent({
90+
name: activity.consent.withdrawn(reply),
91+
createdBy_uid,
92+
programme_ids: ['flu']
93+
})
94+
]
95+
},
96+
{
97+
title: 'Gillick',
98+
items: [
99+
auditEvent({
100+
name: activity.gillick.created(gillickCompetent),
101+
note: 'Child happy to proceed',
102+
createdBy_uid,
103+
programme_ids: ['hpv']
104+
}),
105+
auditEvent({
106+
name: activity.gillick.created(gillickNotCompetent),
107+
note: 'Child did not understand the side effects',
108+
createdBy_uid,
109+
programme_ids: ['hpv']
110+
}),
111+
auditEvent({
112+
name: activity.gillick.updated(gillickCompetent),
113+
note: 'Child now happy to proceed',
114+
createdBy_uid,
115+
programme_ids: ['hpv']
116+
}),
117+
auditEvent({
118+
name: activity.gillick.updated(gillickNotCompetent),
119+
note: 'Child is no longer happy to proceed',
120+
createdBy_uid,
121+
programme_ids: ['hpv']
122+
})
123+
]
124+
},
125+
{
126+
title: 'Notes',
127+
items: [
128+
auditEvent({
129+
name: activity.note.created(AuditEventType.SessionNote),
130+
note: 'Mum phoned to say child will be arriving at school at 11am',
131+
createdBy_uid,
132+
programme_ids: ['flu']
133+
}),
134+
auditEvent({
135+
name: activity.note.created(AuditEventType.RecordNote),
136+
note: 'Child gave consent for HPV and flu vaccinations under Gillick competence and does not want their parents to be notified.',
137+
createdBy_uid
138+
})
139+
]
140+
},
141+
{
142+
title: 'Notify',
143+
items: [
144+
'invite',
145+
'invite-reminder',
146+
'invite-clinic',
147+
'invite-clinic-reminder',
148+
'consent-given',
149+
'consent-given-changed-school',
150+
'consent-needs-triage',
151+
'consent-refused',
152+
'consent-unknown-contact',
153+
'triage-delay-vaccination',
154+
'triage-do-not-vaccinate',
155+
'triage-invite-to-clinic',
156+
'triage-vaccinate',
157+
'triage-vaccinate-second-dose',
158+
'vaccination-reminder',
159+
'vaccination-given',
160+
'vaccination-not-administered',
161+
'vaccination-already-had',
162+
'vaccination-deleted'
163+
].map((name) =>
164+
auditEvent({
165+
name: activity.notify[name](parent),
166+
messageRecipient: parent,
167+
messageTemplate: name,
168+
patient_uuid: patient.uuid,
169+
programme_ids: session.programme_ids,
170+
session_id: session.id
171+
})
172+
)
173+
},
174+
{
175+
title: 'Patient',
176+
items: [
177+
auditEvent({
178+
name: activity.patient.archived({
179+
archiveReason: ArchiveRecordReason.Other
180+
}),
181+
note: 'A brief note about why child record was archived.',
182+
createdBy_uid
183+
}),
184+
auditEvent({
185+
name: activity.patient.expired,
186+
note: `${patient.fullName} was vaccinated`,
187+
createdBy_uid
188+
}),
189+
auditEvent({
190+
name: activity.patient.merged(mergedPatient, patient),
191+
createdBy_uid
192+
})
193+
]
194+
},
195+
{
196+
title: 'Pre-screening',
197+
items: [
198+
auditEvent({
199+
name: activity.preScreen.created,
200+
note: 'A brief note about the pre-screening checks.',
201+
createdBy_uid,
202+
programme_ids: ['flu']
203+
})
204+
]
205+
},
206+
{
207+
title: 'PSD',
208+
items: [
209+
auditEvent({
210+
name: activity.psd.added,
211+
programme_ids: ['flu']
212+
}),
213+
auditEvent({
214+
name: activity.psd.invalidated,
215+
createdBy_uid,
216+
programme_ids: ['flu']
217+
})
218+
]
219+
},
220+
{
221+
title: 'Session',
222+
items: [
223+
auditEvent({
224+
name: activity.session.added(session),
225+
programme_ids: ['flu']
226+
}),
227+
auditEvent({
228+
name: activity.session.removed(session),
229+
createdBy_uid,
230+
programme_ids: ['flu']
231+
})
232+
]
233+
},
234+
{
235+
title: 'Triage',
236+
items: [
237+
auditEvent({
238+
name: activity.triage.decision({
239+
outcome: ScreenOutcome.DelayVaccination
240+
}),
241+
note: 'A brief note about the triage decision.',
242+
createdBy_uid,
243+
programme_ids: ['flu']
244+
})
245+
]
246+
},
247+
{
248+
title: 'Vaccination',
249+
items: [
250+
auditEvent({
251+
name: activity.vaccination.added,
252+
createdBy_uid,
253+
programme_ids: ['flu']
254+
}),
255+
auditEvent({
256+
name: activity.vaccination.recorded(vaccinationGiven),
257+
note: 'A brief note about the vaccination session.',
258+
createdBy_uid,
259+
programme_ids: ['flu']
260+
}),
261+
auditEvent({
262+
name: activity.vaccination.recorded(vaccinationNotGiven),
263+
note: 'A brief note about the vaccination session.',
264+
createdBy_uid,
265+
programme_ids: ['flu']
266+
}),
267+
auditEvent({
268+
name: activity.vaccination.uploaded,
269+
createdBy_uid,
270+
programme_ids: ['flu']
271+
})
272+
]
273+
}
274+
]
275+
276+
response.render('activity/list', { activityLog })
277+
}
278+
}

app/controllers/consent.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,10 @@ export const consentController = {
159159
)
160160

161161
// Add to session
162-
patient.addToSession(patientSession)
162+
patient.addToSession(patientSession.session)
163163

164164
// Invite parent to give consent
165-
const session = Session.findOne(patientSession.session_id, data)
166-
patient.inviteToSession(session)
165+
patient.requestConsent(patientSession)
167166

168167
// Link consent with patient record
169168
consent.linkToPatient(patient)

app/controllers/patient-session.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import {
66
PreScreenQuestion,
77
ProgrammeType,
88
RegistrationOutcome,
9-
ScreenOutcome,
109
UserRole,
1110
VaccinationOutcome,
1211
VaccineMethod
1312
} from '../enums.js'
1413
import {
15-
Gillick,
1614
Instruction,
1715
PatientSession,
1816
Programme,
@@ -261,16 +259,11 @@ export const patientSessionController = {
261259
gillick.updatedAt = today()
262260
}
263261

264-
const name = __(`patientSession.gillick.${type}.success`)
265-
request.flash('success', name)
262+
gillick.createdBy_uid = account.uid
266263

267-
patientSession.assessGillick(
268-
{
269-
name,
270-
createdBy_uid: account.uid
271-
},
272-
new Gillick(gillick)
273-
)
264+
request.flash('success', __(`patientSession.gillick.${type}.success`))
265+
266+
patientSession.assessGillick(gillick)
274267

275268
// Clean up session data
276269
delete data.patientSession?.gillick
@@ -306,8 +299,8 @@ export const patientSessionController = {
306299
const { account } = request.app.locals
307300
const { __, back, patient, patientSession } = response.locals
308301

309-
patient.inviteToSession({
310-
session: patientSession.session,
302+
patient.requestConsent({
303+
patientSession,
311304
createdBy_uid: account.uid
312305
})
313306

@@ -355,10 +348,6 @@ export const patientSessionController = {
355348
patientSession.recordTriage({
356349
outcome: triage.outcome,
357350
outcomeAt_: triage.outcomeAt_,
358-
name:
359-
triage.outcome === ScreenOutcome.NeedsTriage
360-
? 'Triaged decision: Keep in triage'
361-
: `Triaged decision: ${triage.outcome}`,
362351
note: triage.note,
363352
createdBy_uid: account.uid
364353
})

app/controllers/session.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ export const sessionController = {
713713
patientSession.removeFromSession({
714714
createdBy_uid: account.uid
715715
})
716-
patient.addToSession(patientSession)
716+
patient.addToSession(patientSession.session)
717717
Patient.update(patientSession.patient_uuid, {}, data)
718718
}
719719
}

0 commit comments

Comments
 (0)