Skip to content

Commit d1ae6da

Browse files
Replace close session with invite to clinic
1 parent 2147f4b commit d1ae6da

7 files changed

Lines changed: 52 additions & 71 deletions

File tree

app/controllers/session.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,11 @@ export const sessionController = {
685685
response.redirect(session.uri)
686686
},
687687

688-
close(request, response) {
688+
inviteToClinic(request, response) {
689689
const { account } = request.app.locals
690690
const { session_id } = request.params
691691
const { data } = request.session
692-
const { __ } = response.locals
692+
const { __mf } = response.locals
693693

694694
// Update session as closed
695695
const session = Session.update(session_id, { closed: true }, data)
@@ -701,11 +701,13 @@ export const sessionController = {
701701
programme_ids.some((id) => session.programme_ids.includes(id))
702702
)
703703

704+
// Find patients to invite to clinic
705+
const patientSessionsForClinic = session.patientSessionsForClinic.map(
706+
(patient) => patient.uuid
707+
)
708+
704709
// Move patients to clinic
705710
if (clinic) {
706-
const patientSessionsForClinic = session.patientSessionsForClinic.map(
707-
(patient) => patient.uuid
708-
)
709711
for (const patientSession of patientSessionsForClinic) {
710712
const patient = Patient.findOne(patientSession.patient_uuid, data)
711713
patientSession.removeFromSession({
@@ -716,7 +718,12 @@ export const sessionController = {
716718
}
717719
}
718720

719-
request.flash('success', __(`session.close.success`, { session }))
721+
request.flash(
722+
'success',
723+
__mf(`session.inviteToClinic.success`, {
724+
count: patientSessionsForClinic.length
725+
})
726+
)
720727

721728
response.redirect(session.uri)
722729
}

app/locales/en.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,26 +1892,16 @@ export const en = {
18921892
lastName: 'Last name'
18931893
}
18941894
},
1895-
close: {
1896-
title: 'Close session',
1895+
inviteToClinic: {
1896+
title: 'Invite parents to book a clinic appointment',
1897+
label: 'Send clinic invitations',
1898+
count:
1899+
'{count, plural, =0 {No children} one {1 child} other {# children}} were not vaccinated at this school and have not already been invited to a clinic.',
18971900
description:
1898-
'All sessions for this school have been completed.\n\nWhen you close this session, the following children will be invited to community clinics:',
1899-
confirm: 'Close session',
1900-
success: '{{session.name}} has been closed'
1901-
},
1902-
closingSummary: {
1903-
noConsentRequest: {
1904-
count:
1905-
'{count, plural, =0 {No children} one {1 child} other {# children}} whose parents did not receive a consent request'
1906-
},
1907-
noConsentResponse: {
1908-
count:
1909-
'{count, plural, =0 {No children} one {1 child} other {# children}} whose parents did not give a consent response'
1910-
},
1911-
couldNotVaccinate: {
1912-
count:
1913-
'{count, plural, =0 {No children} one {1 child} other {# children}} who could not be vaccinated'
1914-
}
1901+
'You can send invitations to their parents to book an appointment to have their children vaccinated at a clinic.\n\nThe next clinic is on %s.',
1902+
confirm: 'Send clinic invitations',
1903+
success:
1904+
'{count, plural, =0 {No children} one {1 child} other {# children}} invited to the clinic'
19151905
}
19161906
},
19171907
texts: {

app/models/session.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -641,31 +641,23 @@ export class Session {
641641
}
642642

643643
/**
644-
* Get closing summary
644+
* Get patient sessions that can be moved to a clinic session
645645
*
646-
* @returns {object} Closing summary
646+
* @returns {Array<PatientSession>} Patient sessions
647647
*/
648-
get closingSummary() {
649-
return {
650-
noConsentRequest: this.patients.filter(
651-
({ consent }) => consent === ConsentOutcome.NotDelivered
652-
),
653-
noConsentResponse: this.patients.filter(
654-
({ consent }) => consent === ConsentOutcome.NoResponse
655-
),
656-
couldNotVaccinate: this.patients.filter(
657-
({ report }) => report !== PatientStatus.Vaccinated
658-
)
659-
}
648+
get patientSessionsForClinic() {
649+
return this.patients.filter(({ report }) => report === PatientStatus.Due)
660650
}
661651

662652
/**
663-
* Get patient sessions that can be moved to a clinic session
653+
* Get next available clinic session
664654
*
665-
* @returns {Array<PatientSession>} Patient sessions
655+
* @returns {Session} Session
666656
*/
667-
get patientSessionsForClinic() {
668-
return this.patients.filter(({ report }) => report === PatientStatus.Due)
657+
get nextProgrammeClinic() {
658+
return Session.findAll(this.context).find(
659+
(session) => session.type === SessionType.Clinic
660+
)
669661
}
670662

671663
/**

app/routes/session.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ router.all('/:session_id/edit/:view', session.readForm('edit'))
2323
router.get('/:session_id/edit/:view', session.showForm)
2424
router.post('/:session_id/edit/:view', session.updateForm)
2525

26-
router.post('/:session_id/close', session.close)
26+
router.post('/:session_id/invite-to-clinic', session.inviteToClinic)
2727
router.post('/:session_id/instructions', session.giveInstructions)
2828
router.post('/:session_id/offline', session.downloadFile)
2929
router.post('/:session_id/reminders', session.sendReminders)

app/views/session/close.njk

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% extends "_layouts/form.njk" %}
2+
3+
{% set title = __("session.inviteToClinic.title") %}
4+
{% set confirmButtonText = __("session.inviteToClinic.confirm") %}
5+
6+
{% block form %}
7+
{{ appHeading({
8+
caption: session.location.name,
9+
title: title
10+
}) }}
11+
12+
{{ __mf("session.inviteToClinic.count", {
13+
count: session.patientSessionsForClinic.length
14+
}) | nhsukMarkdown }}
15+
16+
{{ __("session.inviteToClinic.description", session.nextProgrammeClinic.formatted.date) | nhsukMarkdown }}
17+
{% endblock %}

app/views/session/show.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
},
4949
{
5050
classes: "nhsuk-button--secondary",
51-
text: __("session.close.title"),
52-
href: session.uri + "/close"
51+
text: __("session.inviteToClinic.label"),
52+
href: session.uri + "/invite-to-clinic"
5353
} if session.isCompleted
5454
],
5555
links: [{

0 commit comments

Comments
 (0)