Skip to content

Commit aca778f

Browse files
Review activity log items
1 parent f11a87a commit aca778f

18 files changed

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

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)