Skip to content

Commit 311b0fb

Browse files
WIP
1 parent c48dacc commit 311b0fb

8 files changed

Lines changed: 114 additions & 68 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: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,28 +141,30 @@ export const activityController = {
141141
{
142142
title: 'Notify',
143143
items: [
144-
'invitedToClinic',
145-
'invitedToClinicReminder',
146-
'requestedConsent',
147-
'requestedConsentReminder',
148-
'consentGiven',
149-
'consentGivenClinic',
150-
'consentGivenTriage',
151-
'consentRefused',
152-
'consentUnknownContact',
153-
'sessionReminder',
154-
'triageDelayVaccination',
155-
'triageDoNotVaccinate',
156-
'triageInviteToClinic',
157-
'triageSafeToVaccinate',
158-
'triageSecondDose',
159-
'vaccinationGiven',
160-
'vaccinationAlreadyGiven',
161-
'vaccinationDeleted',
162-
'vaccinationNotGiven'
144+
'invite-clinic',
145+
'invite-clinic-reminder',
146+
'invite',
147+
'invite-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'
163163
].map((name) =>
164164
auditEvent({
165165
name: activity.notify[name](parent),
166+
recipient: parent,
167+
template: name,
166168
programme_ids: ['mmr']
167169
})
168170
)

app/datasets/activity.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ export default {
77
},
88
consent: {
99
created: ({ decision, parent }) =>
10-
`${decision} by ${parent.formatted.fullNameAndRelationship}`,
10+
`${decision} by ${parent.fullNameAndRelationship}`,
1111
updated: ({ decision, parent }) =>
12-
`${decision} in updated response from ${parent.formatted.fullNameAndRelationship}`,
12+
`${decision} in updated response from ${parent.fullNameAndRelationship}`,
1313
matched: ({ parent }) =>
14-
`Consent response from ${parent.formatted.fullNameAndRelationship} manually matched with child record`,
14+
`Consent response from ${parent.fullNameAndRelationship} manually matched with child record`,
1515
invalid: ({ parent }) =>
16-
`Consent response from ${parent.formatted.fullNameAndRelationship} marked as invalid`,
16+
`Consent response from ${parent.fullNameAndRelationship} marked as invalid`,
1717
withdrawn: ({ parent }) =>
18-
`Consent response from ${parent.formatted.fullNameAndRelationship} withdrawn`
18+
`Consent response from ${parent.fullNameAndRelationship} withdrawn`
1919
},
2020
gillick: {
2121
created: (gillick) => gillick.competent,
@@ -25,44 +25,44 @@ export default {
2525
created: (type) => `${type} added`
2626
},
2727
notify: {
28-
invitedToClinic: (parent) =>
29-
`Invitation to book a clinic appointment<br>sent to ${parent.formatted.fullNameAndRelationship}, ${parent.email || parent.tel}`,
30-
invitedToClinicReminder: (parent) =>
31-
`Reminder to book a clinic appointment<br>sent to ${parent.formatted.fullNameAndRelationship}, ${parent.email || parent.tel}`,
32-
requestedConsent: (parent) =>
33-
`Consent request<br>sent to ${parent.formatted.fullNameAndRelationship}, ${parent.email || parent.tel}`,
34-
requestedConsentReminder: (parent) =>
35-
`Reminder to give or refuse consent<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
36-
consentGiven: (parent) =>
37-
`Confirmation of consent given<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
38-
consentGivenClinic: (parent) =>
39-
`Confirmation of consent given (clinic booking needed)<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
40-
consentGivenTriage: (parent) =>
41-
`Confirmation of consent given (triage needed)<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
42-
consentRefused: (parent) =>
43-
`Confirmation of consent refused<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
44-
consentUnknownContact: (parent) =>
45-
`Unknown parent contact details warning<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
46-
sessionReminder: (parent) =>
47-
`Session reminder<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
48-
triageDelayVaccination: (parent) =>
49-
`Confirmation of triage decision (delay vaccination)<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
50-
triageDoNotVaccinate: (parent) =>
51-
`Confirmation of triage decision (unable to vaccinate)<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
52-
triageInviteToClinic: (parent) =>
53-
`Confirmation of triage decision (invite to clinic)<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
54-
triageSafeToVaccinate: (parent) =>
55-
`Confirmation of triage decision (safe to vaccinate)<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
56-
triageSecondDose: (parent) =>
57-
`Confirmation of triage decision (2nd dose will be given in school)<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
58-
vaccinationAlreadyGiven: (parent) =>
59-
`Confirmation of vaccination discovered since consent<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
60-
vaccinationDeleted: (parent) =>
61-
`Apology for sending an incorrect message<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
62-
vaccinationGiven: (parent) =>
63-
`Confirmation of vaccination<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`,
64-
vaccinationNotGiven: (parent) =>
65-
`Confirmation of vaccination not given<br>sent to ${parent.fullName}, ${parent.email || parent.tel}`
28+
'invite-clinic': (parent) =>
29+
`Invitation to book a clinic appointment sent to ${parent.fullNameAndRelationship}`,
30+
'invite-clinic-reminder': (parent) =>
31+
`Reminder to book a clinic appointment sent to ${parent.fullNameAndRelationship}`,
32+
'invite': (parent) =>
33+
`Consent request sent to ${parent.fullNameAndRelationship}`,
34+
'invite-reminder': (parent) =>
35+
`Reminder to give or refuse consent sent to ${parent.fullNameAndRelationship}`,
36+
'consent-given': (parent) =>
37+
`Confirmation of consent given sent to ${parent.fullNameAndRelationship}`,
38+
'consent-given-changed-school': (parent) =>
39+
`Confirmation of consent given (clinic booking needed) sent to ${parent.fullNameAndRelationship}`,
40+
'consent-needs-triage': (parent) =>
41+
`Confirmation of consent given (triage needed) sent to ${parent.fullNameAndRelationship}`,
42+
'consent-refused': (parent) =>
43+
`Confirmation of consent refused sent to ${parent.fullNameAndRelationship}`,
44+
'consent-unknown-contact': (parent) =>
45+
`Unknown parent contact details warning sent to ${parent.fullNameAndRelationship}`,
46+
'triage-delay-vaccination': (parent) =>
47+
`Confirmation of triage decision (delay vaccination) sent to ${parent.fullNameAndRelationship}`,
48+
'triage-do-not-vaccinate': (parent) =>
49+
`Confirmation of triage decision (unable to vaccinate) sent to ${parent.fullNameAndRelationship}`,
50+
'triage-invite-to-clinic': (parent) =>
51+
`Confirmation of triage decision (invite to clinic) sent to ${parent.fullNameAndRelationship}`,
52+
'triage-vaccinate': (parent) =>
53+
`Confirmation of triage decision (safe to vaccinate) sent to ${parent.fullNameAndRelationship}`,
54+
'triage-vaccinate-second-dose': (parent) =>
55+
`Confirmation of triage decision (2nd dose will be given in school) sent to ${parent.fullNameAndRelationship}`,
56+
'vaccination-reminder': (parent) =>
57+
`Session reminder sent to ${parent.fullNameAndRelationship}`,
58+
'vaccination-given': (parent) =>
59+
`Confirmation of vaccination sent to ${parent.fullNameAndRelationship}`,
60+
'vaccination-not-administered': (parent) =>
61+
`Confirmation of vaccination not given sent to ${parent.fullNameAndRelationship}`,
62+
'vaccination-already-had': (parent) =>
63+
`Confirmation of vaccination discovered since consent sent to ${parent.fullNameAndRelationship}`,
64+
'vaccination-deleted': (parent) =>
65+
`Apology for sending an incorrect message sent to ${parent.fullNameAndRelationship}`
6666
},
6767
patient: {
6868
archived: (archive) => `Record archived: ${archive.archiveReason}`,

app/globals.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,31 @@ export default () => {
102102
}
103103

104104
globals.timelineItems = function (auditEvents) {
105-
const { filters } = this.ctx.settings.nunjucksEnv
105+
const { nunjucksEnv } = this.ctx.settings
106106
const timelineItems = []
107107

108108
for (const auditEvent of Object.values(auditEvents)) {
109109
timelineItems.push({
110110
headingText: formatMarkdown(auditEvent.name),
111111
isPastItem: auditEvent.isPastEvent,
112-
html: auditEvent.formatted?.note,
113-
description: filters.safe(
112+
html:
113+
auditEvent.note &&
114+
`<blockquote>${auditEvent.formatted?.note}</blockquote>`,
115+
description: nunjucksEnv.filters.safe(
114116
auditEvent.formatted.programmes + auditEvent.formatted.createdAtAndBy
115-
)
117+
),
118+
details: auditEvent.recipient && {
119+
classes: 'app-details--notify-message',
120+
summaryText: `Message sent to ${auditEvent.recipient?.email || auditEvent.recipient?.tel}`,
121+
html: formatMarkdown(
122+
nunjucksEnv.render(`emails/consent/${auditEvent.template}.njk`, {
123+
consent: this.ctx.consent,
124+
data: this.ctx,
125+
programme: this.ctx.programme,
126+
session: this.ctx.session
127+
})
128+
)
129+
}
116130
})
117131
}
118132

app/models/audit-event.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
* @property {string} name - Name
2626
* @property {string} [note] - Note
2727
* @property {boolean} [pinned] - Pinned
28+
* @property {object} [recipient] - Message recipient
29+
* @property {string} [template] - Message template name
2830
* @property {AuditEventType} [type] - Audit event type
2931
* @property {string} [outcome] - Outcome for activity type
3032
* @property {Date} [outcomeAt] - Date outcome invalidates
@@ -39,6 +41,8 @@ export class AuditEvent {
3941
this.name = options.name
4042
this.note = options.note
4143
this.pinned = stringToBoolean(options?.pinned)
44+
this.recipient = options?.recipient
45+
this.template = options?.template
4246
this.type = options?.type
4347
this.outcome = options?.outcome
4448
this.outcomeAt = options?.outcomeAt && new Date(options.outcomeAt)
@@ -137,8 +141,7 @@ export class AuditEvent {
137141
? [datetime, this.createdBy.fullName].join(` · `)
138142
: datetime,
139143
datetime,
140-
note:
141-
this.note && `<blockquote>${formatMarkdown(this.note)}</blockquote>`,
144+
note: this.note && formatMarkdown(this.note),
142145
outcome: this.outcome && formatTag(getScreenOutcomeStatus(this.outcome)),
143146
outcomeAt:
144147
this.outcomeAt && formatDate(this.outcomeAt, { dateStyle: 'long' }),

app/models/patient-session.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ export class PatientSession {
10421042
sendReminder(event, parent) {
10431043
this.patient.addEvent({
10441044
name: activity.notify.requestedConsentReminder(parent),
1045+
recipient: parent,
10451046
type: AuditEventType.Reminder,
10461047
createdBy_uid: event.createdBy_uid,
10471048
programme_ids: this.session.programme_ids

app/models/patient.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ export class Patient extends Child {
623623
for (const parent of this.parents) {
624624
this.addEvent({
625625
name: activity.notify.invitedToClinic(parent),
626+
recipient: parent,
626627
createdAt: session.openAt,
627628
createdBy_uid: session.createdBy_uid,
628629
programme_ids: session.programme_ids
@@ -642,6 +643,7 @@ export class Patient extends Child {
642643
if (parent.email && parent.emailStatus === NotifyEmailStatus.Delivered) {
643644
this.addEvent({
644645
name: activity.notify.requestedConsent(parent),
646+
recipient: parent,
645647
createdAt: patientSession.session.openAt,
646648
createdBy_uid: patientSession.session.createdBy_uid,
647649
programme_ids: patientSession.session.programme_ids

app/views/_macros/timeline.njk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{%- from "nhsuk/components/details/macro.njk" import details -%}
12
{% macro _timelineItem(params, item) %}
23
{% set headingLevel = params.headingLevel if params.headingLevel else 3 %}
34
{% set headingBold = "nhsuk-u-font-weight-bold" if item.active else "" %}
@@ -23,6 +24,11 @@
2324
{% elif item.text %}
2425
<p class="nhsuk-body">{{ item.text }}</p>
2526
{% endif %}
27+
{{ details({
28+
classes: item.details.classes,
29+
summaryText: item.details.summaryText,
30+
html: item.details.html | safe | trim
31+
}) if item.details }}
2632
</div>
2733
</li>
2834
{% endmacro %}

0 commit comments

Comments
 (0)