Skip to content

Commit e746e9a

Browse files
Review activity log items
1 parent 182057a commit e746e9a

18 files changed

Lines changed: 560 additions & 107 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+
border-left: none;
19+
background-color: nhsuk-colour("white");
20+
font-family: Helvetica, Arial, sans-serif;
21+
padding: nhsuk-spacing(4);
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: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
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 parent = generateParent('Jones')
34+
const patient = Patient.findAll(data).find(
35+
({ hasMissingNhsNumber, invalid }) => !hasMissingNhsNumber && !invalid
36+
)
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+
recipient: parent,
167+
template: name,
168+
programme_ids: ['mmr']
169+
})
170+
)
171+
},
172+
{
173+
title: 'Patient',
174+
items: [
175+
auditEvent({
176+
name: activity.patient.archived({
177+
archiveReason: ArchiveRecordReason.Other
178+
}),
179+
note: 'A brief note about why child record was archived.',
180+
createdBy_uid
181+
}),
182+
auditEvent({
183+
name: activity.patient.expired,
184+
note: `${patient.fullName} was vaccinated`,
185+
createdBy_uid
186+
}),
187+
auditEvent({
188+
name: activity.patient.merged(mergedPatient, patient),
189+
createdBy_uid
190+
})
191+
]
192+
},
193+
{
194+
title: 'Pre-screening',
195+
items: [
196+
auditEvent({
197+
name: activity.preScreen.created,
198+
note: 'A brief note about the pre-screening checks.',
199+
createdBy_uid,
200+
programme_ids: ['flu']
201+
})
202+
]
203+
},
204+
{
205+
title: 'PSD',
206+
items: [
207+
auditEvent({
208+
name: activity.psd.added,
209+
programme_ids: ['flu']
210+
}),
211+
auditEvent({
212+
name: activity.psd.invalidated,
213+
createdBy_uid,
214+
programme_ids: ['flu']
215+
})
216+
]
217+
},
218+
{
219+
title: 'Session',
220+
items: [
221+
auditEvent({
222+
name: activity.session.added(session),
223+
programme_ids: ['flu']
224+
}),
225+
auditEvent({
226+
name: activity.session.removed(session),
227+
createdBy_uid,
228+
programme_ids: ['flu']
229+
})
230+
]
231+
},
232+
{
233+
title: 'Triage',
234+
items: [
235+
auditEvent({
236+
name: activity.triage.decision({
237+
outcome: ScreenOutcome.DelayVaccination
238+
}),
239+
note: 'A brief note about the triage decision.',
240+
createdBy_uid,
241+
programme_ids: ['flu']
242+
})
243+
]
244+
},
245+
{
246+
title: 'Vaccination',
247+
items: [
248+
auditEvent({
249+
name: activity.vaccination.added,
250+
createdBy_uid,
251+
programme_ids: ['flu']
252+
}),
253+
auditEvent({
254+
name: activity.vaccination.recorded(vaccinationGiven),
255+
note: 'A brief note about the vaccination session.',
256+
createdBy_uid,
257+
programme_ids: ['flu']
258+
}),
259+
auditEvent({
260+
name: activity.vaccination.recorded(vaccinationNotGiven),
261+
note: 'A brief note about the vaccination session.',
262+
createdBy_uid,
263+
programme_ids: ['flu']
264+
}),
265+
auditEvent({
266+
name: activity.vaccination.uploaded,
267+
createdBy_uid,
268+
programme_ids: ['flu']
269+
})
270+
]
271+
}
272+
]
273+
274+
response.render('activity/list', { activityLog })
275+
}
276+
}

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)