Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/assets/stylesheets/components/_details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,21 @@
@include nhsuk-responsive-padding(4, "right");
}
}

.app-details--notify-message {
.nhsuk-details__text {
padding: nhsuk-spacing(4);
border: 1px solid $nhsuk-border-colour;
background-color: nhsuk-colour("white");
font-family: Helvetica, Arial, sans-serif;

.nhsuk-inset-text {
margin-top: 0;
border-color: $nhsuk-border-colour;

@include nhsuk-responsive-padding(2, "bottom");
@include nhsuk-responsive-padding(2, "top");
@include nhsuk-responsive-margin(4, "bottom");
}
}
}
291 changes: 291 additions & 0 deletions app/controllers/activity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
import activity from '../datasets/activity.js'
import { ArchiveRecordReason, AuditEventType, ScreenOutcome } from '../enums.js'
import { generateParent } from '../generators/parent.js'
import {
AuditEvent,
Gillick,
Patient,
Reply,
Session,
Vaccination
} from '../models.js'

export const activityController = {
list(request, response) {
const { data } = request.session

const auditEvent = (event) => new AuditEvent(event, data)
const createdBy_uid = Object.values(data.users)[0].uid
const gillickCompetent = new Gillick({
q1: true,
q2: true,
q3: true,
q4: true,
q5: true
})
const gillickNotCompetent = new Gillick({
q1: true,
q2: true,
q3: true,
q4: true,
q5: false
})
const patient = Patient.findAll(data).find(
({ hasMissingNhsNumber, invalid }) => !hasMissingNhsNumber && !invalid
)
const mergedPatient = Patient.findAll(data).find(
({ uuid, hasMissingNhsNumber, invalid }) =>
uuid !== patient.uuid && !hasMissingNhsNumber && !invalid
)
const reply = Reply.findAll(data).find(
(reply) => !reply.selfConsent && reply.given
)
const session = Session.findOne(Object.values(data.sessions)[0].id, data)
const vaccinationGiven = Vaccination.findAll(data).find(
(vaccination) => vaccination.given
)
const vaccinationNotGiven = Vaccination.findAll(data).find(
(vaccination) => !vaccination.given
)

// Parent for use in Notify activities; force having both email and phone
const parent = generateParent(patient.lastName)
parent.email =
parent.email ||
`${parent.fullName.replace(' ', '.').toLowerCase()}@example.com`
parent.tel = parent.tel || '07700 900000'

const activityLog = [
{
title: 'Attendance',
items: [
auditEvent({
name: activity.attendance.present(session),
createdBy_uid,
programme_ids: ['menacwy', 'td-ipv']
}),
auditEvent({
name: activity.attendance.absent(session),
createdBy_uid,
programme_ids: ['menacwy', 'td-ipv']
})
]
},
{
title: 'Consent',
items: [
auditEvent({
name: activity.consent.created(reply),
createdBy_uid,
programme_ids: ['flu']
}),
auditEvent({
name: activity.consent.updated(reply),
createdBy_uid,
programme_ids: ['flu']
}),
auditEvent({
name: activity.consent.matched(reply),
createdBy_uid,
programme_ids: ['flu']
}),
auditEvent({
name: activity.consent.invalid(reply),
createdBy_uid,
programme_ids: ['flu']
}),
auditEvent({
name: activity.consent.withdrawn(reply),
createdBy_uid,
programme_ids: ['flu']
})
]
},
{
title: 'Gillick',
items: [
auditEvent({
name: activity.gillick.created(gillickCompetent),
note: 'Child happy to proceed',
createdBy_uid,
programme_ids: ['hpv']
}),
auditEvent({
name: activity.gillick.created(gillickNotCompetent),
note: 'Child did not understand the side effects',
createdBy_uid,
programme_ids: ['hpv']
}),
auditEvent({
name: activity.gillick.updated(gillickCompetent),
note: 'Child now happy to proceed',
createdBy_uid,
programme_ids: ['hpv']
}),
auditEvent({
name: activity.gillick.updated(gillickNotCompetent),
note: 'Child is no longer happy to proceed',
createdBy_uid,
programme_ids: ['hpv']
})
]
},
{
title: 'Notes',
items: [
auditEvent({
name: activity.note.created(AuditEventType.SessionNote),
note: 'Mum phoned to say child will be arriving at school at 11am',
createdBy_uid,
programme_ids: ['flu']
}),
auditEvent({
name: activity.note.created(AuditEventType.RecordNote),
note: 'Child gave consent for HPV and flu vaccinations under Gillick competence and does not want their parents to be notified.',
createdBy_uid
})
]
},
{
title: 'Notify',
items: [
'invite',
'invite-reminder',
'invite-clinic',
'invite-clinic-reminder',
'consent-given',
'consent-given-changed-school',
'consent-needs-triage',
'consent-refused',
'consent-unknown-contact',
'triage-delay-vaccination',
'triage-do-not-vaccinate',
'triage-invite-to-clinic',
'triage-vaccinate',
'triage-vaccinate-second-dose',
'vaccination-reminder',
'vaccination-given',
'vaccination-not-administered',
'vaccination-already-had',
'vaccination-deleted'
].map((name) =>
auditEvent({
name: activity.notify[name](parent),
messageRecipient: parent,
messageTemplate: name,
patient_uuid: patient.uuid,
programme_ids: session.programme_ids,
session_id: session.id
})
)
},
{
title: 'Patient',
items: [
auditEvent({
name: activity.patient.archived({
archiveReason: ArchiveRecordReason.Other
}),
note: 'A brief note about why child record was archived.',
createdBy_uid
}),
auditEvent({
name: activity.patient.expired,
note: `${patient.fullName} was vaccinated`,
createdBy_uid
}),
auditEvent({
name: activity.patient.merged(mergedPatient, patient),
createdBy_uid
})
]
},
{
title: 'Pre-screening',
items: [
auditEvent({
name: activity.preScreen.created,
note: 'A brief note about the pre-screening checks.',
createdBy_uid,
programme_ids: ['flu']
})
]
},
{
title: 'PSD',
items: [
auditEvent({
name: activity.psd.added,
createdBy_uid,
programme_ids: ['flu']
}),
auditEvent({
name: activity.psd.invalidated,
createdBy_uid,
programme_ids: ['flu']
})
]
},
{
title: 'Session',
items: [
auditEvent({
name: activity.session.added(session),
programme_ids: ['flu']
}),
auditEvent({
name: activity.session.removed(session),
createdBy_uid,
programme_ids: ['flu']
})
]
},
{
title: 'Triage',
items: [
auditEvent({
name: activity.triage.decision({
outcome: ScreenOutcome.DelayVaccination
}),
note: 'A brief note about the triage decision.',
createdBy_uid,
programme_ids: ['flu']
})
]
},
{
title: 'Vaccination',
items: [
auditEvent({
name: activity.vaccination.recorded(vaccinationGiven),
note: 'A brief note about the vaccination session.',
createdBy_uid,
programme_ids: [vaccinationGiven.programme_id],
vaccination_uuid: vaccinationGiven.uuid
}),
auditEvent({
name: activity.vaccination.recorded(vaccinationNotGiven),
note: 'A brief note about the vaccination session.',
createdBy_uid,
programme_ids: [vaccinationNotGiven.programme_id],
vaccination_uuid: vaccinationNotGiven.uuid
}),
auditEvent({
name: activity.vaccination.added,
createdBy_uid,
programme_ids: [vaccinationGiven.programme_id],
vaccination_uuid: vaccinationGiven.uuid
}),
auditEvent({
name: activity.vaccination.uploaded,
createdBy_uid,
programme_ids: [vaccinationGiven.programme_id],
vaccination_uuid: vaccinationGiven.uuid
})
]
}
]

response.render('activity/list', { activityLog })
}
}
5 changes: 2 additions & 3 deletions app/controllers/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,10 @@ export const consentController = {
)

// Add to session
patient.addToSession(patientSession)
patient.addToSession(patientSession.session)

// Invite parent to give consent
const session = Session.findOne(patientSession.session_id, data)
patient.inviteToSession(session)
patient.requestConsent(patientSession)

// Link consent with patient record
consent.linkToPatient(patient)
Expand Down
23 changes: 6 additions & 17 deletions app/controllers/patient-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import {
PreScreenQuestion,
ProgrammeType,
RegistrationOutcome,
ScreenOutcome,
UserRole,
VaccinationOutcome,
VaccineMethod
} from '../enums.js'
import {
Gillick,
Instruction,
PatientSession,
Programme,
Expand Down Expand Up @@ -259,16 +257,11 @@ export const patientSessionController = {
gillick.updatedAt = today()
}

const name = __(`patientSession.gillick.${type}.success`)
request.flash('success', name)
gillick.createdBy_uid = account.uid

patientSession.assessGillick(
{
name,
createdBy_uid: account.uid
},
new Gillick(gillick)
)
request.flash('success', __(`patientSession.gillick.${type}.success`))

patientSession.assessGillick(gillick)

// Clean up session data
delete data.patientSession?.gillick
Expand Down Expand Up @@ -304,8 +297,8 @@ export const patientSessionController = {
const { account } = request.app.locals
const { __, back, patient, patientSession } = response.locals

patient.inviteToSession({
session: patientSession.session,
patient.requestConsent({
patientSession,
createdBy_uid: account.uid
})

Expand Down Expand Up @@ -353,10 +346,6 @@ export const patientSessionController = {
patientSession.recordTriage({
outcome: triage.outcome,
outcomeAt_: triage.outcomeAt_,
name:
triage.outcome === ScreenOutcome.NeedsTriage
? 'Triaged decision: Keep in triage'
: `Triaged decision: ${triage.outcome}`,
note: triage.note,
createdBy_uid: account.uid
})
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export const sessionController = {
patientSession.removeFromSession({
createdBy_uid: account.uid
})
patient.addToSession(patientSession)
patient.addToSession(patientSession.session)
Patient.update(patientSession.patient_uuid, {}, data)
}
}
Expand Down
Loading