diff --git a/app/data/appointments.js b/app/data/appointments.js index 9e999f49..a090e2ce 100644 --- a/app/data/appointments.js +++ b/app/data/appointments.js @@ -62,7 +62,7 @@ module.exports = [ } }, vaccinations: [ - "flu", "RSV" + "COVID-19", "RSV" ] }, { diff --git a/app/data/organisations.js b/app/data/organisations.js index 6546f175..bfe3b7bd 100644 --- a/app/data/organisations.js +++ b/app/data/organisations.js @@ -9157,5 +9157,88 @@ module.exports = [ type: 'Pharmacy HQ', status: 'Active', region: "Y56" + }, + { + id: "FCX831", + name: "Riverside Community Pharmacy", + address: { + line1: "42 River Street", + town: "Bristol", + postcode: "BS2 8NT" + }, + type: "Community Pharmacy", + status: "Closed", + region: "Y56", + companyId: "P0191N", + vaccines: [ + {name: "COVID-19", status: "enabled"}, + {name: "flu", status: "enabled"} + ], + sites: [ + { + id: "FCX831-01", + name: "Riverside Community Pharmacy", + address: { + line1: "42 River Street", + town: "Bristol", + postcode: "BS2 8NT" + } + } + ] + }, + { + id: "FDX942", + name: "Central Health Pharmacy", + address: { + line1: "78 Main Street", + town: "Oxford", + postcode: "OX1 3HR" + }, + type: "Community Pharmacy", + status: "Closed", + region: "Y56", + companyId: "P0191N", + vaccines: [ + {name: "COVID-19", status: "enabled"} + ], + sites: [ + { + id: "FDX942-01", + name: "Central Health Pharmacy", + address: { + line1: "78 Main Street", + town: "Oxford", + postcode: "OX1 3HR" + } + } + ] + }, + { + id: "FEY153", + name: "Wellcare Pharmacy", + address: { + line1: "156 High Street", + town: "Edinburgh", + postcode: "EH8 8DH" + }, + type: "Community Pharmacy", + status: "Closed", + region: "Y56", + companyId: "P15951", + vaccines: [ + {name: "COVID-19", status: "enabled"}, + {name: "MMR", status: "enabled"} + ], + sites: [ + { + id: "FEY153-01", + name: "Wellcare Pharmacy", + address: { + line1: "156 High Street", + town: "Edinburgh", + postcode: "EH8 8DH" + } + } + ] } ] diff --git a/app/data/users.js b/app/data/users.js index f0a34580..27d8578c 100644 --- a/app/data/users.js +++ b/app/data/users.js @@ -98,6 +98,19 @@ module.exports = [ "firstName": "Paulina", "lastName": "Sloan" }, + { + "id": "7301948572610", + "email": "michael.reid@nhs.net", + "organisations": [ + { + "id": "P0191N", + "permissionLevel": "Group administrator", + "status": "Active" + } + ], + "firstName": "Michael", + "lastName": "Reid" + }, // Each pharmacy in Paulina Sloan’s chain has its own vaccinator, some of whom are also admins { "id": "46436346", @@ -155,6 +168,34 @@ module.exports = [ "firstName": "Samantha", "lastName": "Black" }, + { + "id": "2195407736418", + "email": "nina.hunt@nhs.net", + "organisations": [ + { + "id": "FA424", + "permissionLevel": "Administrator", + "status": "Active", + "vaccinator": true + } + ], + "firstName": "Nina", + "lastName": "Hunt" + }, + { + "id": "8701294465302", + "email": "liam.byrne@nhs.net", + "organisations": [ + { + "id": "FA02S", + "permissionLevel": "Recorder", + "status": "Active", + "vaccinator": false + } + ], + "firstName": "Liam", + "lastName": "Byrne" + }, // Amanda White is a group administrator for the // MediCare Health Ltd chain of pharmacies { @@ -170,6 +211,47 @@ module.exports = [ } ] }, + { + "firstName": "Farah", + "lastName": "Iqbal", + "id": "6015872204914", + "email": "farah.iqbal@nhs.net", + "organisations": [ + { + "id": "P15951", + "permissionLevel": "Group administrator", + "status": "Active" + } + ] + }, + { + "id": "3041597862150", + "email": "kyle.mason@nhs.net", + "organisations": [ + { + "id": "FX9141", + "permissionLevel": "Administrator", + "status": "Active", + "vaccinator": true + } + ], + "firstName": "Kyle", + "lastName": "Mason" + }, + { + "id": "4586231970421", + "email": "elise.turner@nhs.net", + "organisations": [ + { + "id": "FX4825", + "permissionLevel": "Recorder", + "status": "Active", + "vaccinator": true + } + ], + "firstName": "Elise", + "lastName": "Turner" + }, { "id": "34634617277", "email": "peter.orange@nhs.net", diff --git a/app/filters.js b/app/filters.js index 57aa92fc..f9d9a048 100644 --- a/app/filters.js +++ b/app/filters.js @@ -38,6 +38,25 @@ module.exports = function () { } } + filters.joinWithAnd = function(array) { + if (!Array.isArray(array) || array.length === 0) { + return '' + } + + const items = array.map((item) => String(item)) + items[0] = filters.capitaliseFirstLetter(items[0]) + + if (items.length === 1) { + return items[0] + } + + if (items.length === 2) { + return `${items[0]} and ${items[1]}` + } + + return `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}` + } + /** * Returns the name of a month, eg 'November', when * given the number of the month, eg 11. diff --git a/app/routes/pharmacies.js b/app/routes/pharmacies.js index 682c27e9..cab382f9 100644 --- a/app/routes/pharmacies.js +++ b/app/routes/pharmacies.js @@ -19,11 +19,15 @@ module.exports = router => { const companyId = res.locals.currentOrganisation.id - const organisations = data.organisations.filter((organisation) => organisation.companyId === companyId).sort(sortByNameThenPostcode()) + const allOrganisations = data.organisations.filter((organisation) => organisation.companyId === companyId).sort(sortByNameThenPostcode()) + + // Separate active/deactivated pharmacies from closed ones + const organisations = allOrganisations.filter((org) => org.status !== 'Closed') + const closedOrganisations = allOrganisations.filter((org) => org.status === 'Closed') let organisationUserCounts = {} - for (const organisation of organisations) { + for (const organisation of allOrganisations) { organisationUserCounts[organisation.id] = data.users .filter((user) => (user.organisations || []) .find((orgPermission) => orgPermission.id === organisation.id) @@ -33,6 +37,7 @@ module.exports = router => { res.render('pharmacies/index', { organisations, + closedOrganisations, organisationUserCounts, added }) @@ -103,6 +108,11 @@ module.exports = router => { router.get('/pharmacies/users',(req, res) => { const data = req.session.data const companyId = res.locals.currentOrganisation.id + const deactivatedGroupAdminId = req.query.deactivatedGroupAdminId + const deactivatedUserId = req.query.deactivatedUserId + const deactivatedFromPharmacyId = req.query.deactivatedFromPharmacyId + const deactivatedFromAllUserId = req.query.deactivatedFromAllUserId + const deactivatedFromAllCount = parseInt(req.query.deactivatedFromAllCount, 10) || 0 const pharmacies = data.organisations.filter((organisation) => organisation.companyId === companyId) const pharmacyIds = pharmacies.map(pharmacy => pharmacy.id) @@ -119,18 +129,102 @@ module.exports = router => { }) const groupAdministrators = users.filter(function(user) { - return user.organisations.find(org => org.permissionLevel === "Group administrator") + return user.organisations.find(org => org.permissionLevel === "Group administrator" && org.status !== 'Deactivated') + }) + + const deactivatedGroupAdmin = deactivatedGroupAdminId + ? data.users.find((user) => user.id === deactivatedGroupAdminId) + : undefined + + const deactivatedUser = deactivatedUserId + ? data.users.find((user) => user.id === deactivatedUserId) + : undefined + + const deactivatedFromPharmacy = deactivatedFromPharmacyId + ? data.organisations.find((organisation) => organisation.id === deactivatedFromPharmacyId) + : undefined + + const deactivatedFromAllUser = deactivatedFromAllUserId + ? data.users.find((user) => user.id === deactivatedFromAllUserId) + : undefined + + // Show only active users added to individual pharmacies in the general user list. + users = users.filter((user) => { + if (groupAdministrators.includes(user)) { + return false + } + + return (user.organisations || []).some((organisation) => { + return pharmacyIds.includes(organisation.id) && organisation.status !== 'Deactivated' + }) }) - // Filter out group admins from the general user list - users = users.filter((user) => !groupAdministrators.includes(user)) + const userPharmacyCounts = {} + + for (const user of users) { + userPharmacyCounts[user.id] = (user.organisations || []).filter((organisation) => { + return pharmacyIds.includes(organisation.id) && organisation.status !== 'Deactivated' + }).length + } res.render('pharmacies/users/index', { users, - groupAdministrators + groupAdministrators, + deactivatedGroupAdmin, + deactivatedUser, + deactivatedFromPharmacy, + deactivatedFromAllUser, + deactivatedFromAllCount, + userPharmacyCounts + }) + }) + + router.get('/pharmacies/:groupId/users/:userId/deactivate-from-group',(req, res) => { + const data = req.session.data + const groupId = req.params.groupId + const userId = req.params.userId + + const user = data.users.find((item) => item.id === userId) + + if (!user) { + return res.redirect('/pharmacies/users') + } + + const groupRole = (user.organisations || []).find((org) => org.id === groupId && org.permissionLevel === 'Group administrator') + + if (!groupRole) { + return res.redirect('/pharmacies/users') + } + + res.render('pharmacies/users/deactivate-from-group', { + user, + groupId, + groupName: (res.locals.currentOrganisation && res.locals.currentOrganisation.name) || 'this pharmacy group' }) }) + router.post('/pharmacies/:groupId/users/:userId/deactivate-from-group-answer',(req, res) => { + const data = req.session.data + const groupId = req.params.groupId + const userId = req.params.userId + + const user = data.users.find((item) => item.id === userId) + + if (!user) { + return res.redirect('/pharmacies/users') + } + + const groupRole = (user.organisations || []).find((org) => org.id === groupId && org.permissionLevel === 'Group administrator') + + if (!groupRole) { + return res.redirect('/pharmacies/users') + } + + groupRole.status = 'Deactivated' + + res.redirect(`/pharmacies/users?deactivatedGroupAdminId=${user.id}`) + }) + router.get('/pharmacies/users/new',(req, res) => { res.render('pharmacies/users/new') @@ -159,7 +253,15 @@ module.exports = router => { router.get('/pharmacies/users/new-select-pharmacies-check',(req, res) => { const data = req.session.data - const pharmacyIds = data.pharmacyIds + const pharmacyIds = data.pharmacyIds || [] + + if (pharmacyIds.length === 0) { + return res.redirect('/pharmacies/users/new-select-pharmacies') + } + + if (pharmacyIds.length === 1) { + return res.redirect('/pharmacies/users/new-permission-level') + } // Get pharmacies selected on previous page const pharmacies = data.organisations.filter((organisation) => pharmacyIds.includes(organisation.id)) @@ -170,6 +272,22 @@ module.exports = router => { }) }) + router.get('/pharmacies/users/new-select-pharmacies-check/remove/:pharmacyId', (req, res) => { + const data = req.session.data + const pharmacyId = req.params.pharmacyId + const pharmacyIds = Array.isArray(data.pharmacyIds) + ? data.pharmacyIds + : (data.pharmacyIds ? [data.pharmacyIds] : []) + + data.pharmacyIds = pharmacyIds.filter((id) => id !== pharmacyId) + + if (data.pharmacyIds.length === 0) { + return res.redirect('/pharmacies/users/new-select-pharmacies') + } + + res.redirect('/pharmacies/users/new-select-pharmacies-check') + }) + router.get('/pharmacies/users/new-permission-level',(req, res) => { const data = req.session.data const pharmacyIds = data.pharmacyIds || [] @@ -269,7 +387,7 @@ module.exports = router => { pharmacy.status = 'Deactivated' - res.redirect(`/pharmacies/${id}`) + res.redirect(`/pharmacies/${id}?deactivated=true`) }) router.get('/pharmacies/:id/add-user',(req, res) => { @@ -390,13 +508,15 @@ module.exports = router => { const data = req.session.data const pharmacyId = req.params.pharmacyId const userId = req.params.userId + const from = req.query.from === 'pharmacy' ? 'pharmacy' : 'user' const user = data.users.find(user => user.id === userId) const pharmacy = data.organisations.find(organisation => organisation.id === pharmacyId) res.render('pharmacies/users/deactivate-from-pharmacy', { user, - pharmacy + pharmacy, + from }) }) @@ -404,6 +524,7 @@ module.exports = router => { const data = req.session.data const pharmacyId = req.params.pharmacyId const userId = req.params.userId + const from = req.query.from === 'pharmacy' ? 'pharmacy' : 'user' const user = data.users.find(user => user.id === userId) const pharmacy = data.organisations.find(organisation => organisation.id === pharmacyId) @@ -412,8 +533,88 @@ module.exports = router => { role.status = 'Deactivated' - res.redirect(`/pharmacies/users/${user.id}?deactivatedFromPharmacyId=${pharmacy.id}`) + if (from === 'user') { + return res.redirect(`/pharmacies/users/${user.id}?deactivatedFromPharmacyId=${pharmacy.id}`) + } + + res.redirect(`/pharmacies/${pharmacy.id}?tab=deactivated&deactivatedUserId=${user.id}&deactivatedFromPharmacyId=${pharmacy.id}`) + + }) + + router.get('/pharmacies/:pharmacyId/users/:userId/reactivate', (req, res) => { + const data = req.session.data + const pharmacyId = req.params.pharmacyId + const userId = req.params.userId + + const user = data.users.find((item) => item.id === userId) + const pharmacy = data.organisations.find((organisation) => organisation.id === pharmacyId) + + if (!user || !pharmacy) { + return res.redirect('/pharmacies') + } + + const role = (user.organisations || []).find((item) => item.id === pharmacyId) + + if (!role) { + return res.redirect(`/pharmacies/${pharmacyId}?tab=deactivated`) + } + + role.status = 'Active' + + res.redirect(`/pharmacies/${pharmacyId}?tab=active&reactivatedUserId=${userId}&reactivatedFromPharmacyId=${pharmacyId}`) + }) + + router.get('/pharmacies/users/:userId/deactivate-from-all-pharmacies', (req, res) => { + const data = req.session.data + const userId = req.params.userId + const companyId = res.locals.currentOrganisation.id + + const user = data.users.find((item) => item.id === userId) + + if (!user) { + return res.redirect('/pharmacies/users') + } + + const activePharmacyRolesAtCompany = (user.organisations || []) + .map((role) => { + const pharmacy = data.organisations.find((organisation) => organisation.id === role.id) + return { role, pharmacy } + }) + .filter(({ role, pharmacy }) => pharmacy && pharmacy.companyId === companyId && role.permissionLevel !== 'Group administrator' && role.status !== 'Deactivated') + + if (activePharmacyRolesAtCompany.length === 0) { + return res.redirect(`/pharmacies/users/${userId}`) + } + + res.render('pharmacies/users/deactivate-from-all-pharmacies', { + user, + pharmacies: activePharmacyRolesAtCompany.map(({ pharmacy }) => pharmacy) + }) + }) + + router.post('/pharmacies/users/:userId/deactivate-from-all-pharmacies-answer', (req, res) => { + const data = req.session.data + const userId = req.params.userId + const companyId = res.locals.currentOrganisation.id + + const user = data.users.find((item) => item.id === userId) + + if (!user) { + return res.redirect('/pharmacies/users') + } + + const deactivatedPharmacyIds = [] + for (const role of (user.organisations || [])) { + const pharmacy = data.organisations.find((organisation) => organisation.id === role.id) + + if (pharmacy && pharmacy.companyId === companyId && role.permissionLevel !== 'Group administrator' && role.status !== 'Deactivated') { + role.status = 'Deactivated' + deactivatedPharmacyIds.push(pharmacy.id) + } + } + + res.redirect(`/pharmacies/users?deactivatedFromAllUserId=${userId}&deactivatedFromAllCount=${deactivatedPharmacyIds.length}`) }) @@ -456,17 +657,66 @@ module.exports = router => { }) }) + router.get('/pharmacies/users/:id/add-to-select-pharmacies-check', (req, res) => { + const data = req.session.data + const userId = req.params.id + const user = data.users.find(user => user.id === userId) + + const selectedPharmacyIds = data.addToPharmacyIds + ? (Array.isArray(data.addToPharmacyIds) ? data.addToPharmacyIds : [data.addToPharmacyIds]) + : [] + + if (selectedPharmacyIds.length === 0) { + return res.redirect(`/pharmacies/users/${userId}/add-to`) + } + + if (selectedPharmacyIds.length === 1) { + return res.redirect(`/pharmacies/users/${userId}/add-to-permission-level`) + } + + const pharmacies = data.organisations.filter((organisation) => selectedPharmacyIds.includes(organisation.id)) + + res.render('pharmacies/users/add-to-select-pharmacies-check', { + user, + pharmacies + }) + }) + + router.get('/pharmacies/users/:id/add-to-select-pharmacies-check/remove/:pharmacyId', (req, res) => { + const data = req.session.data + const userId = req.params.id + const pharmacyId = req.params.pharmacyId + + const selectedPharmacyIds = data.addToPharmacyIds + ? (Array.isArray(data.addToPharmacyIds) ? data.addToPharmacyIds : [data.addToPharmacyIds]) + : [] + + data.addToPharmacyIds = selectedPharmacyIds.filter((id) => id !== pharmacyId) + + if (data.addToPharmacyIds.length === 0) { + return res.redirect(`/pharmacies/users/${userId}/add-to`) + } + + res.redirect(`/pharmacies/users/${userId}/add-to-select-pharmacies-check`) + }) + router.get('/pharmacies/users/:id/add-to-permission-level',(req, res) => { const data = req.session.data const userId = req.params.id const user = data.users.find(user => user.id === userId) - const pharmacy = data.organisations.find(organisation => organisation.id === data.pharmacyId) + const selectedPharmacyIds = data.addToPharmacyIds + ? (Array.isArray(data.addToPharmacyIds) ? data.addToPharmacyIds : [data.addToPharmacyIds]) + : [] + const pharmacies = data.organisations.filter((organisation) => selectedPharmacyIds.includes(organisation.id)) + if (pharmacies.length === 0) { + return res.redirect(`/pharmacies/users/${userId}/add-to`) + } res.render('pharmacies/users/add-to-permission-level', { user, - pharmacy + pharmacies }) }) @@ -475,12 +725,18 @@ module.exports = router => { const userId = req.params.id const user = data.users.find(user => user.id === userId) - const pharmacy = data.organisations.find(organisation => organisation.id === data.pharmacyId) + const selectedPharmacyIds = data.addToPharmacyIds + ? (Array.isArray(data.addToPharmacyIds) ? data.addToPharmacyIds : [data.addToPharmacyIds]) + : [] + const pharmacies = data.organisations.filter((organisation) => selectedPharmacyIds.includes(organisation.id)) + if (pharmacies.length === 0) { + return res.redirect(`/pharmacies/users/${userId}/add-to`) + } res.render('pharmacies/users/add-to-check', { user, - pharmacy + pharmacies }) }) @@ -488,21 +744,46 @@ module.exports = router => { const data = req.session.data const id = req.params.id const user = data.users.find(user => user.id === id) - const pharmacy = data.organisations.find(organisation => organisation.id === data.pharmacyId) - user.organisations.push({ - id: pharmacy.id, - status: 'Active', - permissionLevel: data.permissionLevel, - vaccinator: (data.vaccinator === 'yes') - }) + const selectedPharmacyIds = data.addToPharmacyIds + ? (Array.isArray(data.addToPharmacyIds) ? data.addToPharmacyIds : [data.addToPharmacyIds]) + : [] + const pharmacies = data.organisations.filter((organisation) => selectedPharmacyIds.includes(organisation.id)) + + if (pharmacies.length === 0) { + return res.redirect(`/pharmacies/users/${id}/add-to`) + } + + const existingOrganisationIds = (user.organisations || []).map(organisation => organisation.id) + + const addedPharmacyIds = [] + + for (const pharmacy of pharmacies) { + if (!existingOrganisationIds.includes(pharmacy.id)) { + user.organisations.push({ + id: pharmacy.id, + status: 'Active', + permissionLevel: data.permissionLevel, + vaccinator: (data.vaccinator === 'yes') + }) + addedPharmacyIds.push(pharmacy.id) + } + } // Reset answers data.permissionLevel = '' data.vaccinator = '' - data.pharmacyId = '' + data.addToPharmacyIds = [] - res.redirect(`/pharmacies/users/${id}?addedToPharmacyId=${pharmacy.id}`) + if (addedPharmacyIds.length === 0) { + return res.redirect(`/pharmacies/users/${id}`) + } + + if (addedPharmacyIds.length > 1) { + res.redirect(`/pharmacies/users/${id}?addedToPharmacyIds=${addedPharmacyIds.join(',')}`) + } else { + res.redirect(`/pharmacies/users/${id}?addedToPharmacyId=${addedPharmacyIds[0]}`) + } }) @@ -511,10 +792,18 @@ module.exports = router => { const id = req.params.id const added = req.query.added const addedUserId = req.query.addedUserId + const deactivated = req.query.deactivated + const deactivatedUserId = req.query.deactivatedUserId + const deactivatedFromPharmacyId = req.query.deactivatedFromPharmacyId + const reactivatedUserId = req.query.reactivatedUserId + const reactivatedFromPharmacyId = req.query.reactivatedFromPharmacyId + const tab = (req.query.tab || 'active').toLowerCase() const organisation = data.organisations.find((organisation) => organisation.id === id) const addedUser = data.users.find((user) => user.id === addedUserId) + const deactivatedUser = data.users.find((user) => user.id === deactivatedUserId) + const reactivatedUser = data.users.find((user) => user.id === reactivatedUserId) const userOrganisationPermissions = {} @@ -523,16 +812,43 @@ module.exports = router => { .find((orgPermission) => orgPermission.id === organisation.id) ) + const usersByStatus = { + invited: [], + active: [], + deactivated: [] + } + for (const user of users) { userOrganisationPermissions[user.id] = user.organisations.find((userOrganisation) => userOrganisation.id === organisation.id) + + const userOrganisationStatus = userOrganisationPermissions[user.id].status + + if (userOrganisationStatus === 'Invited') { + usersByStatus.invited.push(user) + } else if (userOrganisationStatus === 'Deactivated') { + usersByStatus.deactivated.push(user) + } else { + usersByStatus.active.push(user) + } } + const validTabs = ['invited', 'active', 'deactivated'] + const currentTab = validTabs.includes(tab) ? tab : 'active' + const usersForTab = usersByStatus[currentTab] + res.render('pharmacies/pharmacy', { organisation, - users, + users: usersForTab, + usersByStatus, + currentTab, userOrganisationPermissions, added, - addedUser + addedUser, + deactivated, + deactivatedUser, + deactivatedFromPharmacyId, + reactivatedUser, + reactivatedFromPharmacyId }) }) @@ -543,27 +859,53 @@ module.exports = router => { const user = data.users.find((user) => user.id === id) const companyId = res.locals.currentOrganisation.id + if (!user) { + return res.redirect('/pharmacies/users') + } + const addedToPharmacyId = req.query.addedToPharmacyId + const addedToPharmacyIds = req.query.addedToPharmacyIds const deactivatedFromPharmacyId = req.query.deactivatedFromPharmacyId + const deactivatedFromAllPharmacies = req.query.deactivatedFromAllPharmacies === 'true' + const deactivatedFromAllPharmacyIds = (req.query.deactivatedFromAllPharmacyIds || '').split(',').filter(Boolean) + const deactivatedFromAllCount = deactivatedFromAllPharmacyIds.length - let addedToPharmacy, deactivatedFromPharmacy + let addedToPharmacy, addedToPharmacies, deactivatedFromPharmacy if (addedToPharmacyId) { addedToPharmacy = data.organisations.find(organisation => organisation.id === addedToPharmacyId) } + if (addedToPharmacyIds) { + const ids = addedToPharmacyIds.split(',').filter(Boolean) + addedToPharmacies = data.organisations.filter((organisation) => ids.includes(organisation.id)) + } if (deactivatedFromPharmacyId) { deactivatedFromPharmacy = data.organisations.find(organisation => organisation.id === deactivatedFromPharmacyId) } const totalPharmaciesAtOrganisation = data.organisations.filter(organisation => organisation.companyId === companyId).length - const pharmacyRoles = (user.organisations || []).filter(role => role.permissionLevel !== "Group administrator") + const pharmacyRoles = (user.organisations || []) + .filter((role) => role.permissionLevel !== 'Group administrator') + .filter((role) => role.status !== 'Deactivated') + .map((role) => { + const pharmacy = data.organisations.find((organisation) => organisation.id === role.id) + + return { + ...role, + pharmacy + } + }) + .filter((role) => role.pharmacy && role.pharmacy.companyId === companyId) - res.render('pharmacies/users/user', { + res.render('pharmacies/users/manage-ind-user', { user, pharmacyRoles, addedToPharmacy, + addedToPharmacies, deactivatedFromPharmacy, + deactivatedFromAllPharmacies, + deactivatedFromAllCount, totalPharmaciesAtOrganisation }) }) diff --git a/app/views/appointments/_cancelled.html b/app/views/appointments/_cancelled.html index 58e90892..b5e5c173 100644 --- a/app/views/appointments/_cancelled.html +++ b/app/views/appointments/_cancelled.html @@ -25,7 +25,7 @@
{{ appointment.patient.dateOfBirth | age }} old
- {{ (appointment.vaccinations | join(", ")) | capitaliseFirstLetter }} + {{ appointment.vaccinations | joinWithAnd }} diff --git a/app/views/appointments/_completed.html b/app/views/appointments/_completed.html index 5a838cbf..db279cba 100644 --- a/app/views/appointments/_completed.html +++ b/app/views/appointments/_completed.html @@ -24,7 +24,7 @@
{{ appointment.patient.dateOfBirth | age }} old
- {{ (appointment.vaccinations | join("
")) | capitaliseFirstLetter | safe }} + {{ appointment.vaccinations | joinWithAnd }} {% if appointment.patient.contactDetails.mobile %} diff --git a/app/views/appointments/_scheduled.html b/app/views/appointments/_scheduled.html index 0da0b9e1..333e12ca 100644 --- a/app/views/appointments/_scheduled.html +++ b/app/views/appointments/_scheduled.html @@ -28,7 +28,7 @@
{{ appointment.patient.dateOfBirth | age }} old
- {{ (appointment.vaccinations | join("
")) | capitaliseFirstLetter | safe }} + {{ appointment.vaccinations | joinWithAnd }} {% if appointment.patient.contactDetails.mobile %} diff --git a/app/views/pharmacies/users/welcome-email-group-admin.html b/app/views/emails/welcome-email-group-admin.html similarity index 100% rename from app/views/pharmacies/users/welcome-email-group-admin.html rename to app/views/emails/welcome-email-group-admin.html diff --git a/app/views/user-admin/_welcome-email.html b/app/views/emails/welcome-email-multiple-pharmacies.html similarity index 100% rename from app/views/user-admin/_welcome-email.html rename to app/views/emails/welcome-email-multiple-pharmacies.html diff --git a/app/views/emails/welcome-email.html b/app/views/emails/welcome-email.html new file mode 100644 index 00000000..611ed71b --- /dev/null +++ b/app/views/emails/welcome-email.html @@ -0,0 +1,42 @@ +

From: NHS Record a vaccination service (RAVS)
+ Subject: Start using Record a vaccination at (Pharmacy company) +

+
+ +

Dear (Name),

+ +

You’ve been invited to use the NHS Record a vaccination service as a group administrator for (Pharmacy company).

+ +

Get started

+ +

We’ve created an Okta account for you to securely access the service.

+ +

Here’s what you need to do:

+ +

1. Activate your Okta account

+ +

You’ll receive a 'Welcome to Okta' email (from noreply@okta.com).

+ +

Activate the link within 7 days.

+ +

If you cannot find the email, check your spam or junk.

+ +

2. Log in to Record a vaccination

+ +

Once you've activated your Okta account, log in to www.ravs.england.nhs.uk using your Okta username and password.

+ +

You can also access the service through your Okta account by selecting 'RAVS (PROD) app'.

+ +

Training and support

+

To help you get started, you can:

+ +

Kind regards,
+ NHS Record a vaccination

+ + + + diff --git a/app/views/includes/header.html b/app/views/includes/header.html index cf52f5c6..72ce5266 100644 --- a/app/views/includes/header.html +++ b/app/views/includes/header.html @@ -19,6 +19,12 @@ active: (currentSection == "pharmacies") }), navigationItems) %} + {% set navigationItems = (navigationItems.push({ + href: "/pharmacies/users", + text: "Users", + active: (currentSection == "pharmacies-users") + }), navigationItems) %} + {% endif %} diff --git a/app/views/pharmacies/add-user-check.html b/app/views/pharmacies/add-user-check.html index 04f041a3..2ee30845 100644 --- a/app/views/pharmacies/add-user-check.html +++ b/app/views/pharmacies/add-user-check.html @@ -100,17 +100,13 @@

Check and {% if existingUserWithSameEmail %}reactiva {% if existingUser %} -

{{ existingUser.firstName }} {{ existingUser.lastName }} will receive this email inviting them to use the service at {{ organisation.name }} ({{ organisation.id }}).

+

{{ existingUser.firstName }} {{ existingUser.lastName }} will receive this email.

{% else %} -

{{ data.firstName }} {{ data.lastName }} will receive this email inviting them to use the service at {{ organisation.name }} ({{ organisation.id }}).

+

{{ data.firstName }} {{ data.lastName }} will receive this email.

{% endif %}
- {% if existingUserWithSameEmail %} - {% include "user-admin/_reactivation-email.html" %} - {% else %} - {% include "user-admin/_welcome-email.html" %} - {% endif %} + {% include "emails/welcome-email.html" %}
diff --git a/app/views/pharmacies/add-user-permission-level.html b/app/views/pharmacies/add-user-permission-level.html index 0992b1e3..0c991cd0 100644 --- a/app/views/pharmacies/add-user-permission-level.html +++ b/app/views/pharmacies/add-user-permission-level.html @@ -1,7 +1,13 @@ {% extends 'layout.html' %} {% set currentSection = "pharmacies" %} -{% set pageName = "Add a user to " + organisation.name %} +{% if existingUser %} + {% set pageName = existingUser.firstName + " " + existingUser.lastName + "'s role at " + organisation.name + " (" + organisation.id + ")" %} +{% elseif data.firstName or data.lastName %} + {% set pageName = (data.firstName + " " + data.lastName) + "'s role at " + organisation.name + " (" + organisation.id + ")" %} +{% else %} + {% set pageName = "New user's role at " + organisation.name + " (" + organisation.id + ")" %} +{% endif %} {% block beforeContent %} {{ backLink({ @@ -13,13 +19,13 @@

- Add {% if existingUser %} - {{ existingUser.firstName }} {{ existingUser.lastName }} + {{ existingUser.firstName }} {{ existingUser.lastName }}'s role at {{ organisation.name }} ({{ organisation.id }}) + {% elseif data.firstName or data.lastName %} + {{ data.firstName }} {{ data.lastName }}'s role at {{ organisation.name }} ({{ organisation.id }}) {% else %} - a new user + Add a new user to {{ organisation.name }} ({{ organisation.id }}) {% endif %} - to {{ organisation.name }} ({{ organisation.id }})

diff --git a/app/views/pharmacies/index.html b/app/views/pharmacies/index.html index 1d181147..9f050bdb 100644 --- a/app/views/pharmacies/index.html +++ b/app/views/pharmacies/index.html @@ -4,7 +4,7 @@ {% block content %}
-
+
{% if added %} {% set html %} @@ -22,7 +22,7 @@

Pharmacies

-

Add pharmacies or manage users at an existing pharmacy.

+

Add pharmacies or manage an existing pharmacy.

{{ button({ text: "Add pharmacies", @@ -51,7 +51,10 @@

Pharmacies

Users - Actions + Status + + + Actions @@ -74,6 +77,9 @@

Pharmacies

{{ organisationUserCounts[organisation.id] }} + + {{ organisation.status }} + Manage @@ -82,6 +88,62 @@

Pharmacies

+ + {% if closedOrganisations.length > 0 %} +
+ + + Closed pharmacies ({{ closedOrganisations | length }}) + + +
+

The following pharmacies have been closed.

+ + + + + + + + + + + {% for organisation in closedOrganisations %} + + + + + + + {% endfor %} + +
+ Name + + Vaccines + + Users + + Status +
+ {{ organisation.name }} ({{ organisation.id}}) + + {% set vaccinesEnabled = [] %} + {% for vaccine in organisation.vaccines %} + {% if vaccine.status == "enabled" %} + {% set vaccinesEnabled = (vaccinesEnabled.push(vaccine.name), vaccinesEnabled) %} + {% endif %} + {% endfor %} + + {{ (vaccinesEnabled | sort | join(", ")) | capitaliseFirstLetter }} + + {{ organisationUserCounts[organisation.id] }} + + {{ organisation.status }} +
+
+
+ {% endif %}
diff --git a/app/views/pharmacies/pharmacy.html b/app/views/pharmacies/pharmacy.html index e27a2889..1c9ce629 100644 --- a/app/views/pharmacies/pharmacy.html +++ b/app/views/pharmacies/pharmacy.html @@ -28,6 +28,48 @@

}) }} {% endif %} + {% if deactivated == "true" %} + {% set html %} +

+ Pharmacy deactivated +

+

{{ organisation.name }} ({{ organisation.id }}) has been successfully deactivated.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + + {% if deactivatedUser and deactivatedFromPharmacyId == organisation.id %} + {% set html %} +

+ User deactivated +

+

{{ deactivatedUser.firstName }} {{ deactivatedUser.lastName }} has been successfully deactivated from {{ organisation.name }} ({{ organisation.id }}).

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + + {% if reactivatedUser and reactivatedFromPharmacyId == organisation.id %} + {% set html %} +

+ User reactivated +

+

{{ reactivatedUser.firstName }} {{ reactivatedUser.lastName }} has been successfully reactivated for {{ organisation.name }} ({{ organisation.id }}).

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} +

{{ pageName }}

{{ summaryList({ @@ -69,10 +111,6 @@

{{ pageName }}

{% endif %}

Users

-
-
-
-
{% if organisation.status != 'Deactivated' %} {{ button({ @@ -81,6 +119,27 @@

Users

}) }} {% endif %} + {{ appSecondaryNavigation({ + visuallyHiddenTitle: "Users by status", + items: [{ + text: "Invited (" + (usersByStatus.invited | length) + ")", + href: "/pharmacies/" + organisation.id + "?tab=invited", + current: (currentTab == "invited") + }, { + text: "Active (" + (usersByStatus.active | length) + ")", + href: "/pharmacies/" + organisation.id + "?tab=active", + current: (currentTab == "active") + }, { + text: "Deactivated (" + (usersByStatus.deactivated | length) + ")", + href: "/pharmacies/" + organisation.id + "?tab=deactivated", + current: (currentTab == "deactivated") + }] + }) }} +
+
+
+
+ {% if (users | length) > 0 %} @@ -118,15 +177,28 @@

Users

- {% endfor %}
{{ userOrganisationPermissions[user.id].status }} - Changepermission level for {{ user.firstName }} {{ user.lastName }} + + {% if userOrganisationPermissions[user.id].status == 'Invited' %} + {% elif userOrganisationPermissions[user.id].status == 'Deactivated' %} + Reactivate {{ user.firstName }} {{ user.lastName }} + {% else %} + Change permission level for {{ user.firstName }} {{ user.lastName }} +   + Deactivate {{ user.firstName }} {{ user.lastName }} + {% endif %}
{% else %} -

No users added yet.

+ {% if currentTab == "invited" %} +

No invited users.

+ {% elif currentTab == "deactivated" %} +

No deactivated users.

+ {% else %} +

No active users.

+ {% endif %} {% endif %}
diff --git a/app/views/pharmacies/users/add-to-check.html b/app/views/pharmacies/users/add-to-check.html index 254d626f..51ce1a52 100644 --- a/app/views/pharmacies/users/add-to-check.html +++ b/app/views/pharmacies/users/add-to-check.html @@ -4,7 +4,7 @@ {% block beforeContent %} {{ backLink({ - href: "/pharmacies/users/new", + href: "/pharmacies/users/" + user.id + "/add-to-permission-level", text: "Back" }) }} {% endblock %} @@ -13,12 +13,18 @@
-

Check and add user to pharmacy

+

+ {% if (pharmacies | length) > 1 %} + Check and add user to {{ pharmacies | length }} pharmacies + {% else %} + Check and add user to {{ pharmacies[0].name }} ({{ pharmacies[0].id }}) + {% endif %} +

{% set pharmaciesHtml %}
    {% for pharmacy in pharmacies %} -
  • {{ pharmacy.name }}
  • +
  • {{ pharmacy.name }} ({{ pharmacy.id }})
  • {% endfor %}
{% endset %} @@ -27,18 +33,26 @@

Check and add user to pharmacy

rows: [ { key: { - text: "User" + text: "Name" }, value: { - html: user.firstName + " " + user.lastName + "
" + user.email + text: user.firstName + " " + user.lastName } }, { key: { - text: "Pharmacy" + text: "Email address" }, value: { - html: pharmacy.name + " (" + pharmacy.id + ")" + text: user.email + } + }, + { + key: { + text: "Pharmacy" if (pharmacies | length) == 1 else "Pharmacies" + }, + value: { + html: pharmaciesHtml }, actions: { items: [ @@ -87,10 +101,14 @@

Check and add user to pharmacy

] }) }} -

{{ user.firstName }} will receive this email telling them they now have access to the pharmacy:

+

{{ user.firstName }} {{ user.lastName }} will receive this email.

- {% include "user-admin/_welcome-email.html" %} + {% if (pharmacies | length) > 1 %} + {% include "emails/welcome-email-multiple-pharmacies.html" %} + {% else %} + {% include "emails/welcome-email.html" %} + {% endif %}
diff --git a/app/views/pharmacies/users/add-to-permission-level.html b/app/views/pharmacies/users/add-to-permission-level.html index 971049f7..07223914 100644 --- a/app/views/pharmacies/users/add-to-permission-level.html +++ b/app/views/pharmacies/users/add-to-permission-level.html @@ -1,12 +1,13 @@ {% extends 'layout.html' %} {% set currentSection = "pharmacies-users" %} +{% set selectedPharmacy = (pharmacies | first) if (pharmacies | length) == 1 %} {% set pageName = "Add pharmacies" %} {% block beforeContent %} {{ backLink({ - href: "/pharmacies/users/" + user.id + "/add-to" + href: "/pharmacies/users/" + user.id + "/add-to-select-pharmacies-check" if (pharmacies | length) > 1 else "/pharmacies/users/" + user.id + "/add-to" }) }} {% endblock %} @@ -15,7 +16,42 @@
-

What should {{ user.firstName }} {{ user.lastName}}'s role at {{ pharmacy.name }} be?

+

+ {% if (pharmacies | length) == 1 and selectedPharmacy %} + {{ user.firstName }} {{ user.lastName }}'s role at {{ selectedPharmacy.name }} ({{ selectedPharmacy.id }}) + {% else %} + {{ user.firstName }} {{ user.lastName }}'s role + {% endif %} +

+ + {% if (pharmacies | length) > 1 %} +

These permissions will apply to the {{ pharmacies | length }} pharmacies.

+ {% endif %} + + {{ radios({ + name: "vaccinator", + fieldset: { + legend: { + text: "Are they a vaccinator?", + size: "s" + } + }, + hint: { + text: "Vaccination records include the name of the person who gave the vaccination" + }, + value: data.vaccinator, + items: [ + { + value: "yes", + text: "Yes", + id: "vaccinator" + }, + { + value: "no", + text: "No" + } + ] + }) }} {{ radios({ name: "permissionLevel", @@ -52,31 +88,6 @@

What should {{ user.firstName }} {{ user.lastName}}' ] }) }} - {{ radios({ - name: "vaccinator", - fieldset: { - legend: { - text: "Are they a vaccinator?", - size: "s" - } - }, - hint: { - text: "Vaccination records include the name of the person who gave the vaccination" - }, - value: data.vaccinator, - items: [ - { - value: "yes", - text: "Yes", - id: "vaccinator" - }, - { - value: "no", - text: "No" - } - ] - }) }} - {{ button({ text: "Continue" }) }} diff --git a/app/views/pharmacies/users/add-to-select-pharmacies-check.html b/app/views/pharmacies/users/add-to-select-pharmacies-check.html new file mode 100644 index 00000000..99b25756 --- /dev/null +++ b/app/views/pharmacies/users/add-to-select-pharmacies-check.html @@ -0,0 +1,51 @@ +{% extends 'layout.html' %} + +{% set currentSection = "pharmacies-users" %} + +{% block beforeContent %} + {{ backLink({ + href: "/pharmacies/users/" + user.id + "/add-to" + }) }} +{% endblock %} + +{% block content %} +
+
+ +

Check pharmacies

+ +

You are adding {{ user.firstName }} {{ user.lastName }} to these pharmacies.

+ + {% set rows = [] %} + + {% for pharmacy in pharmacies %} + + {% set removeHtml %} + Remove + {% endset %} + + {% set rows = (rows.push([ + { text: pharmacy.name + ", " + pharmacy.address.postcode + " (" + pharmacy.id + ")" }, + { html: removeHtml } + ]), rows) %} + {% endfor %} + + + {{ table({ + head: [ + { text: "Pharmacy" }, + { text: "" } + ], + rows: rows + }) }} + + + {{ button({ + text: "Continue", + href: "/pharmacies/users/" + user.id + "/add-to-permission-level" + }) }} + +
+
+ +{% endblock %} diff --git a/app/views/pharmacies/users/add-to.html b/app/views/pharmacies/users/add-to.html index b14ecbbb..9870c9ac 100644 --- a/app/views/pharmacies/users/add-to.html +++ b/app/views/pharmacies/users/add-to.html @@ -12,8 +12,8 @@ {% block content %}
-
- +
+ {% set items = [] %} @@ -24,18 +24,41 @@ }), items) %} {% endfor %} - {{ radios({ - id: "pharmacy-id", - name: "pharmacyId", - value: data.pharmacyId, - fieldset: { - legend: { - text: "Which pharmacy would you like to add " + user.firstName + " " + user.lastName + " to?", - size: "l" - } - }, - items: items - }) }} + {% call fieldset({ + legend: { + text: "Which pharmacies would you like to add " + user.firstName + " " + user.lastName + " to?", + size: "l" + } + }) %} + + {% if (pharmacies | length) > 10 %} + {{ input({ + id: "pharmacy-search", + name: "pharmacySearch", + type: "search", + label: { + text: "Search" + }, + classes: "nhsuk-input--width-20", + attributes: { + "data-module": "app-checkbox-filter" + }, + formGroup: { + classes: "nhsuk-u-margin-bottom-4" + } + }) }} + {% endif %} + +
+ {{ checkboxes({ + id: "pharmacy-ids", + name: "addToPharmacyIds", + values: data.addToPharmacyIds, + items: items + }) }} +
+ + {% endcall %} {{ button({ text: "Continue" diff --git a/app/views/pharmacies/users/check.html b/app/views/pharmacies/users/check.html index d914dcbe..7f55ff8d 100644 --- a/app/views/pharmacies/users/check.html +++ b/app/views/pharmacies/users/check.html @@ -13,12 +13,20 @@
-

Check and add {{ "group administrator" if data.permissionLevel == "Group administrator" else "user" }}

+

+ {% if data.groupAdministrator == "yes" %} + Check and add group administrator + {% elif (pharmacies | length) > 1 %} + Check and add user to {{ pharmacies | length }} pharmacies + {% else %} + Check and add user to {{ pharmacies[0].name }} ({{ pharmacies[0].id }}) + {% endif %} +

{% set pharmaciesHtml %}
    {% for pharmacy in pharmacies %} -
  • {{ pharmacy.name }}
  • +
  • {{ pharmacy.name }} ({{ pharmacy.id }})
  • {% endfor %}
{% endset %} @@ -95,7 +103,7 @@

Check and add {{ "group administrator" if data.permi }, { key: { - text: "Pharmacies" + text: "Pharmacy" if (pharmacies | length) == 1 else "Pharmacies" }, value: { html: pharmaciesHtml @@ -113,10 +121,14 @@

Check and add {{ "group administrator" if data.permi ] }) }} -

{{ data.firstName }} will receive this welcome email telling them how to access the service:

+

{{ data.firstName }} {{ data.lastName }} will receive this email.

- {% include "user-admin/_welcome-email.html" %} + {% if (pharmacies | length) > 1 %} + {% include "emails/welcome-email-multiple-pharmacies.html" %} + {% else %} + {% include "emails/welcome-email.html" %} + {% endif %}
diff --git a/app/views/pharmacies/users/deactivate-from-all-pharmacies.html b/app/views/pharmacies/users/deactivate-from-all-pharmacies.html new file mode 100644 index 00000000..7a80d5be --- /dev/null +++ b/app/views/pharmacies/users/deactivate-from-all-pharmacies.html @@ -0,0 +1,42 @@ +{% extends 'layout.html' %} + +{% set pageName = "Deactivate account" %} + +{% set currentSection = "pharmacies-users" %} + +{% block beforeContent %} + {{ backLink({ + href: "/pharmacies/users/" + user.id, + text: "Back" + }) }} +{% endblock %} + +{% block content %} +
+
+ +

Deactivate {{ user.firstName }} {{ user.lastName }} from {{ (pharmacies | length) | plural("pharmacy") }}

+ +

Once you deactivate {{ user.firstName }} {{ user.lastName }} ({{ user.email }}), they will not be able to sign in and use NHS Record a vaccination at any of these pharmacies:

+ +
    + {% for pharmacy in pharmacies %} +
  • {{ pharmacy.name }} ({{ pharmacy.id }})
  • + {% endfor %} +
+ +

Their Okta account will remain active, so they can continue to access other services.

+ +

You can reactivate their account anytime.

+ + + {{ button({ + text: "Deactivate", + classes: "nhsuk-button--warning" + }) }} + + +
+
+ +{% endblock %} diff --git a/app/views/pharmacies/users/deactivate-from-group.html b/app/views/pharmacies/users/deactivate-from-group.html new file mode 100644 index 00000000..0fa87f6f --- /dev/null +++ b/app/views/pharmacies/users/deactivate-from-group.html @@ -0,0 +1,36 @@ +{% extends 'layout.html' %} + +{% set pageName = "Deactivate account" %} + +{% set currentSection = "pharmacies-users" %} + +{% block beforeContent %} + {{ backLink({ + href: "/pharmacies/users", + text: "Back" + }) }} +{% endblock %} + +{% block content %} +
+
+ +

Deactivate {{ user.firstName }} {{ user.lastName }} from {{ groupName }}

+ +

Once you deactivate {{ user.firstName }} {{ user.lastName }} ({{ user.email }}), they will not be able to sign in and use NHS Record a vaccination for this pharmacy group. They’ll receive an email to confirm their account has been deactivated.

+ +

Their Okta account will remain active, so they can continue to access other services.

+ +

You can reactivate their account anytime.

+ +
+ {{ button({ + "text": "Deactivate", + classes: "nhsuk-button--warning" + }) }} +
+ +
+
+ +{% endblock %} diff --git a/app/views/pharmacies/users/deactivate-from-pharmacy.html b/app/views/pharmacies/users/deactivate-from-pharmacy.html index 8f0c5461..7a80e11d 100644 --- a/app/views/pharmacies/users/deactivate-from-pharmacy.html +++ b/app/views/pharmacies/users/deactivate-from-pharmacy.html @@ -6,7 +6,7 @@ {% block beforeContent %} {{ backLink({ - href: "/pharmacies/users/" + user.id, + href: ("/pharmacies/" + pharmacy.id) if from == "pharmacy" else ("/pharmacies/users/" + user.id), text: "Back" }) }} {% endblock %} @@ -16,15 +16,15 @@
-

Deactivate {{ user.firstName }} {{ user.lastName }} from {{ pharmacy.name }}

+

Deactivate {{ user.firstName }} {{ user.lastName }} from {{ pharmacy.name }} ({{ pharmacy.id }})

-

Once you deactivate {{ user.firstName }} {{ user.lastName }} ({{ user.email}}), they cannot sign in and use NHS Record a vaccination at this pharmacy. They’ll receive an email to confirm their account has been deactivated.

+

Once you deactivate {{ user.firstName }} {{ user.lastName }} ({{ user.email}}), they will not be able to sign in and use NHS Record a vaccination at this pharmacy. They’ll get an email to confirm their account has been deactivated.

Their Okta account will remain active, so they can continue to access other services.

You can reactivate their account anytime.

-
+ {{ button({ "text": "Deactivate", classes: "nhsuk-button--warning" diff --git a/app/views/pharmacies/users/index.html b/app/views/pharmacies/users/index.html new file mode 100644 index 00000000..227eb8ae --- /dev/null +++ b/app/views/pharmacies/users/index.html @@ -0,0 +1,138 @@ +{% extends 'layout.html' %} + +{% set pageName = "Users" %} +{% set currentSection = "pharmacies-users" %} + +{% block content %} +
+
+ {% if req.query.added == "true" %} + {{ notificationBanner({ + titleText: "Success", + html: "User added" + }) }} + {% endif %} + {% if deactivatedGroupAdmin %} + {% set html %} +

+ User deactivated +

+

{{ deactivatedGroupAdmin.firstName }} {{ deactivatedGroupAdmin.lastName }} has been successfully deactivated from the pharmacy group.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + {% if deactivatedUser and deactivatedFromPharmacy %} + {% set html %} +

+ User deactivated +

+

{{ deactivatedUser.firstName }} {{ deactivatedUser.lastName }} has been successfully deactivated from {{ deactivatedFromPharmacy.name }} ({{ deactivatedFromPharmacy.id }}).

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + {% if deactivatedFromAllUser %} + {% set html %} +

+ User deactivated +

+

{{ deactivatedFromAllUser.firstName }} {{ deactivatedFromAllUser.lastName }} has been successfully deactivated from {{ deactivatedFromAllCount | plural("pharmacy") }}.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + +

Users

+ +

Add a new user or change the permissions of an existing user.

+ + {{ button({ + text: "Add user", + href: "/pharmacies/users/new" + }) }} + +

Group administrators

+ + {% if groupAdministrators and (groupAdministrators | length) > 0 %} + + + + + + {% if (groupAdministrators | length) >= 2 %} + + {% endif %} + + + + {% for user in groupAdministrators %} + + + + {% if (groupAdministrators | length) >= 2 %} + + {% endif %} + + {% endfor %} + +
NameEmail
{{ user.firstName }} {{ user.lastName }}{{ user.email }} + Deactivate {{ user.firstName }} {{ user.lastName }} +
+ {% else %} +

No group administrators added yet.

+ {% endif %} + +

Active users at individual pharmacies

+ + {% if users and (users | length) > 0 %} + {% if (users | length) > 10 %} + {{ input({ + id: "pharmacy-search", + name: "pharmacySearch", + type: "search", + label: { + text: "Search" + }, + classes: "nhsuk-input--width-20", + formGroup: { + classes: "nhsuk-u-margin-bottom-4" + } + }) }} + {% endif %} + + + + + + + + + + + + {% for user in users %} + + + + + + + {% endfor %} + +
NameEmailPharmaciesActions
{{ user.firstName }} {{ user.lastName }}{{ user.email }}{{ userPharmacyCounts[user.id] or 0 }}Manage {{ user.firstName }} {{ user.lastName }}
+ {% else %} +

No users added to individual pharmacies yet.

+ {% endif %} +
+
+{% endblock %} diff --git a/app/views/pharmacies/users/manage-ind-user.html b/app/views/pharmacies/users/manage-ind-user.html new file mode 100644 index 00000000..64c0db5a --- /dev/null +++ b/app/views/pharmacies/users/manage-ind-user.html @@ -0,0 +1,144 @@ +{% extends 'layout.html' %} + +{% set currentSection = "pharmacies-users" %} +{% set pageName = user.firstName + " " + user.lastName %} + +{% block beforeContent %} + {{ backLink({ + href: "/pharmacies/users" + }) }} +{% endblock %} + +{% block content %} +
+
+ {% if addedToPharmacies and (addedToPharmacies | length) > 0 %} + {% set addedToPharmaciesWithOds = [] %} + {% for pharmacy in addedToPharmacies %} + {% set addedToPharmaciesWithOds = (addedToPharmaciesWithOds.push(pharmacy.name + " (" + pharmacy.id + ")"), addedToPharmaciesWithOds) %} + {% endfor %} + + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been added to {{ addedToPharmaciesWithOds | formatList }}.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + + {% elseif addedToPharmacy %} + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been added to {{ addedToPharmacy.name }} ({{ addedToPharmacy.id }}).

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + + {% if deactivatedFromPharmacy %} + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been deactivated from {{ deactivatedFromPharmacy.name }}.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + + {% if deactivatedFromAllPharmacies %} + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been deactivated from {{ deactivatedFromAllCount | plural('pharmacy') }}.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + +

{{ user.firstName }} {{ user.lastName }}

+ + {{ summaryList({ + rows: [ + { + key: { + text: "Email" + }, + value: { + text: user.email + } + } + ] + }) }} +
+
+ +
+
+

Access and permission levels

+ + {% if pharmacyRoles and (pharmacyRoles | length) > 0 %} + + + + + + + + + + + + {% for role in pharmacyRoles %} + + + + + + + + {% endfor %} + +
PharmacyPermission levelVaccinatorStatusActions
{{ role.pharmacy.name }} ({{ role.pharmacy.id }}){{ role.permissionLevel }}{{ "Yes" if role.vaccinator else "No" }}{{ role.status }} + Change permission level at {{ role.pharmacy.name }} + {% if role.status != 'Deactivated' %} +   + Deactivate from {{ role.pharmacy.name }} + {% endif %} +
+ +
+ {{ button({ + text: "Add to another pharmacy", + href: "/pharmacies/users/" + user.id + "/add-to", + classes: "nhsuk-button--secondary" + }) }} +
+ {% else %} +

This user is not currently added to any individual pharmacies.

+ + {{ button({ + text: "Add to a pharmacy", + href: "/pharmacies/users/" + user.id + "/add-to", + classes: "nhsuk-button--secondary" + }) }} + {% endif %} +
+
+{% endblock %} diff --git a/app/views/pharmacies/users/manage-select-pharmacy.html b/app/views/pharmacies/users/manage-select-pharmacy.html new file mode 100644 index 00000000..6da91839 --- /dev/null +++ b/app/views/pharmacies/users/manage-select-pharmacy.html @@ -0,0 +1,147 @@ +{% extends 'layout.html' %} + +{% set currentSection = "pharmacies-users" %} +{% set pageName = user.firstName + " " + user.lastName %} + +{% block beforeContent %} + {{ backLink({ + href: "/pharmacies/users" + }) }} +{% endblock %} + +{% block content %} +
+
+ {% if addedToPharmacies and (addedToPharmacies | length) > 0 %} + {% set addedToPharmaciesWithOds = [] %} + {% for pharmacy in addedToPharmacies %} + {% set addedToPharmaciesWithOds = (addedToPharmaciesWithOds.push(pharmacy.name + " (" + pharmacy.id + ")"), addedToPharmaciesWithOds) %} + {% endfor %} + + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been added to {{ addedToPharmaciesWithOds | formatList }}.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + + {% elseif addedToPharmacy %} + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been added to {{ addedToPharmacy.name }} ({{ addedToPharmacy.id }}).

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + + {% if deactivatedFromPharmacy %} + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been deactivated from {{ deactivatedFromPharmacy.name }}.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + + {% if deactivatedFromAllPharmacies %} + {% set html %} +

+ User updated +

+

{{ user.firstName }} {{ user.lastName }} has been deactivated from {{ deactivatedFromAllCount | plural('pharmacy') }}.

+ {% endset %} + + {{ notificationBanner({ + html: html, + type: "success" + }) }} + {% endif %} + +

{{ user.firstName }} {{ user.lastName }}

+ + {{ summaryList({ + rows: [ + { + key: { + text: "Email" + }, + value: { + text: user.email + } + } + ] + }) }} +
+
+ +
+
+

Access and permission levels

+ + {% if pharmacyRoles and (pharmacyRoles | length) > 0 %} + + + + + + + + + + + + {% for role in pharmacyRoles %} + + + + + + + + {% endfor %} + +
PharmacyPermission levelVaccinatorStatusActions
{{ role.pharmacy.name }} ({{ role.pharmacy.id }}){{ role.permissionLevel }}{{ "Yes" if role.vaccinator else "No" }}{{ role.status }} + Change permission level at {{ role.pharmacy.name }} + {% if role.status != 'Deactivated' %} +   + Deactivate from {{ role.pharmacy.name }} + {% endif %} +
+ +
+ {{ button({ + text: "Add to another pharmacy", + href: "/pharmacies/users/" + user.id + "/add-to", + classes: "nhsuk-button--secondary" + }) }} + {% if (pharmacyRoles | length) >= 2 %} + Deactivate from all pharmacies + {% endif %} +
+ {% else %} +

This user is not currently added to any individual pharmacies.

+ + {{ button({ + text: "Add to a pharmacy", + href: "/pharmacies/users/" + user.id + "/add-to", + classes: "nhsuk-button--secondary" + }) }} + {% endif %} +
+
+{% endblock %} diff --git a/app/views/pharmacies/users/new-permission-level.html b/app/views/pharmacies/users/new-permission-level.html index e01d527d..faa0b5b5 100644 --- a/app/views/pharmacies/users/new-permission-level.html +++ b/app/views/pharmacies/users/new-permission-level.html @@ -1,10 +1,11 @@ {% extends 'layout.html' %} {% set currentSection = "pharmacies-users" %} +{% set selectedPharmacy = (pharmacies | first) if (pharmacies | length) == 1 %} {% block beforeContent %} {{ backLink({ - href: "/pharmacies/users/new-select-pharmacies-check" + href: "/pharmacies/users/new-select-pharmacies" if (pharmacies | length) == 1 else "/pharmacies/users/new-select-pharmacies-check" }) }} {% endblock %} @@ -14,9 +15,17 @@ -

{{ data.firstName }} {{ data.lastName }}’s role

+

+ {% if (pharmacies | length) == 1 and selectedPharmacy %} + {{ data.firstName }} {{ data.lastName }}'s role at {{ selectedPharmacy.name }} ({{ selectedPharmacy.id }}) + {% else %} + {{ data.firstName }} {{ data.lastName }}'s role + {% endif %} +

-

These roles will apply to the {{ data.pharmacyIds | length }} pharmacies.

+ {% if (pharmacies | length) > 1 %} +

These permissions will apply to the {{ pharmacies | length }} pharmacies.

+ {% endif %} {{ radios({ name: "vaccinator", diff --git a/app/views/pharmacies/users/new-select-pharmacies-check.html b/app/views/pharmacies/users/new-select-pharmacies-check.html index cff3e136..75086f4b 100644 --- a/app/views/pharmacies/users/new-select-pharmacies-check.html +++ b/app/views/pharmacies/users/new-select-pharmacies-check.html @@ -14,40 +14,36 @@

Check pharmacies

-

These are the pharmacies you will give {{ data.firstName }} {{ data.lastName }} access to.

+

You are adding {{ data.firstName }} {{ data.lastName }} to these pharmacies.

- - {% set rows = [] %} + {% set rows = [] %} - {% for pharmacy in pharmacies %} + {% for pharmacy in pharmacies %} - {% set removeHtml %} - {{ button({ - text: "Remove", - classes: "nhsuk-button--secondary nhsuk-button--small nhsuk-u-margin-bottom-0" - }) }} - {% endset %} + {% set removeHtml %} + Remove + {% endset %} - {% set rows = (rows.push([ - { text: pharmacy.name + ", " + pharmacy.address.postcode + " (" + pharmacy.id + ")" }, - { html: removeHtml } - ]), rows) %} - {% endfor %} + {% set rows = (rows.push([ + { text: pharmacy.name + ", " + pharmacy.address.postcode + " (" + pharmacy.id + ")" }, + { html: removeHtml } + ]), rows) %} + {% endfor %} - {{ table({ - head: [ - { text: "Pharmacy" }, - { text: "" } - ], - rows: rows - }) }} + {{ table({ + head: [ + { text: "Pharmacy" }, + { text: "" } + ], + rows: rows + }) }} - {{ button({ - "text": "Continue" + {{ button({ + text: "Continue", + href: "/pharmacies/users/new-permission-level" }) }} -

diff --git a/app/views/pharmacies/users/new-select-pharmacies.html b/app/views/pharmacies/users/new-select-pharmacies.html index a1d0156f..c246bf17 100644 --- a/app/views/pharmacies/users/new-select-pharmacies.html +++ b/app/views/pharmacies/users/new-select-pharmacies.html @@ -12,9 +12,8 @@
-

Select pharmacies

+

Which pharmacies would you like to add {{ data.firstName }} {{ data.lastName }} to?

-

You can invite the new user to 1 or more of your pharmacies.

@@ -29,8 +28,9 @@

Select pharmacies

{% call fieldset({ legend: { - text: "Which pharmacies do you want to add " + data.firstName + " " + data.lastName + " to?", - size: "m" + text: "Select pharmacies", + size: "m", + classes: "nhsuk-u-visually-hidden" } }) %} diff --git a/app/views/reports/choose-vaccines.html b/app/views/reports/choose-vaccines.html index 1eb5ac18..506b89be 100644 --- a/app/views/reports/choose-vaccines.html +++ b/app/views/reports/choose-vaccines.html @@ -37,7 +37,7 @@ {% for vaccine in (enabledVaccines | sort(false, false, "name")) %} {% set items = (items.push({ value: vaccine.name, - text: (vaccine.name ) + text: (vaccine.name | capitaliseFirstLetter) }), items) %} {% endfor %} diff --git a/app/views/user-admin/_reactivation-email.html b/app/views/user-admin/_reactivation-email.html deleted file mode 100644 index 2a0a0c7e..00000000 --- a/app/views/user-admin/_reactivation-email.html +++ /dev/null @@ -1,13 +0,0 @@ -

From: ravs@england.nhs.uk
-Subject: Reactivated account: NHS Record a vaccination service (RAVS) -

-
- -

Hi {{ firstName}} {{ lastName}},

- -

We’ve reactivated your NHS Record a vaccination account. You can sign in using your Okta account.

- -

Reset your Okta password if you need to.

- -

Many thanks,
-NHS Record a vaccination

diff --git a/app/views/user-admin/check.html b/app/views/user-admin/check.html index 4f4c0d0c..099f7ac7 100644 --- a/app/views/user-admin/check.html +++ b/app/views/user-admin/check.html @@ -93,18 +93,10 @@

Check and {% if existingUserWithSameEmail %}reactiva }) }} - {% if existingUserWithSameEmail %} -

{{ data.firstName }} will be re-activated and sent this email:

- {% else %} -

{{ data.firstName }} will receive this welcome email with information about activating an account:

- {% endif %} +

{{ data.firstName }} will receive this welcome email with information about activating an account:

- {% if existingUserWithSameEmail %} - {% include "user-admin/_reactivation-email.html" %} - {% else %} - {% include "user-admin/_welcome-email.html" %} - {% endif %} + {% include "emails/welcome-email.html" %}