diff --git a/app/data/organisations.js b/app/data/organisations.js index bfe3b7bd..c24b2585 100644 --- a/app/data/organisations.js +++ b/app/data/organisations.js @@ -1074,7 +1074,7 @@ module.exports = [ }, { id: "RW382", - name: "Ear nose and throad RMCH" + name: "Ear nose and throat RMCH" }, { id: "RW391", diff --git a/app/data/session-data-defaults.js b/app/data/session-data-defaults.js index 6a081ab9..87bd3907 100644 --- a/app/data/session-data-defaults.js +++ b/app/data/session-data-defaults.js @@ -22,11 +22,11 @@ module.exports = { vaccinationsRecorded: vaccinationsRecorded, // These are the options for extracting CSV reports - patientDataOptions: ["Name", "NHS number", "Gender", "Date of birth", "Address", "Postcode", "ODS code of their GP"], + patientDataOptions: ["Name", "NHS number", "Gender", "Date of birth", "Address", "Postcode", "Contact details", "GP (ODS code only)"], staffDataOptions: ["Recorder", "Vaccinator"], locationDataOptions: ["Site name", "Site ODS code", "Location type"], consentAndEligibilityDataOptions: ["Consent", "Eligibility", "Estimated due date"], - vaccinationDataOptions: ["Vaccine type", "Product", "Batch", "Batch expiry date", "Dose sequence", "Dose amount", "Vaccination site", "Vaccination date", "Comments"], + vaccinationDataOptions: ["Vaccine type", "Product", "Batch", "Batch expiry date", "Dose sequence", "Dose amount", "Vaccination route", "Vaccination date", "Comments"], paymentDataOptions: [ {text: "Deposit ID", hint: "Set before we send the claim to NHSBSA"}, {text: "Claim ID", hint: "Set when NHSBSA have received the claim"} diff --git a/app/locals.js b/app/locals.js index 8a0697d7..36b1e6cb 100644 --- a/app/locals.js +++ b/app/locals.js @@ -15,6 +15,20 @@ module.exports = function(req, res, next) { 'December' ] + const now = new Date() + const lastMonthDate = new Date(now.getFullYear(), now.getMonth() - 1, 1) + res.locals.lastCalendarMonth = `${monthNames[lastMonthDate.getMonth()]} ${lastMonthDate.getFullYear()}` + + const dayOfWeek = now.getDay() // 0 = Sunday, 1 = Monday + const daysSinceMonday = (dayOfWeek === 0 ? 7 : dayOfWeek) - 1 + const lastMonday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - daysSinceMonday - 7) + const lastSunday = new Date(lastMonday.getFullYear(), lastMonday.getMonth(), lastMonday.getDate() + 6) + const formatWeekDay = (d) => { + const suffix = d.getDate() === lastSunday.getDate() && d.getMonth() === lastSunday.getMonth() ? ` ${monthNames[d.getMonth()]} ${d.getFullYear()}` : (d.getMonth() !== lastSunday.getMonth() ? ` ${monthNames[d.getMonth()]}` : '') + return `${d.getDate()}${suffix}` + } + res.locals.lastCalendarWeek = `${formatWeekDay(lastMonday)} to ${lastSunday.getDate()} ${monthNames[lastSunday.getMonth()]} ${lastSunday.getFullYear()}` + const dashboardUpdatedAt = new Date(Date.now() - (30 * 60 * 1000)) const hours24 = dashboardUpdatedAt.getHours() const hours12 = (hours24 % 12) || 12 diff --git a/app/routes/reports.js b/app/routes/reports.js index 230ac52a..5cad1831 100644 --- a/app/routes/reports.js +++ b/app/routes/reports.js @@ -46,9 +46,15 @@ module.exports = (router) => { }) router.post('/reports/choose-vaccines-answer', (req, res) => { + const data = req.session.data + const currentOrganisation = res.locals.currentOrganisation + const sites = currentOrganisation.sites || [] - if (res.locals.currentOrganisation.type === "Pharmacy HQ") { + if (currentOrganisation.type === "Pharmacy HQ") { res.redirect('/reports/choose-pharmacies') + } else if (sites.length === 1) { + data.siteIdsToReport = [sites[0].id] + res.redirect('/reports/choose-data') } else { res.redirect('/reports/choose-site') } @@ -106,9 +112,17 @@ module.exports = (router) => { }) router.get('/reports/choose-site', (req, res) => { + const data = req.session.data const currentOrganisation = res.locals.currentOrganisation const sites = currentOrganisation.sites || [] + + if (sites.length === 1) { + data.siteIdsToReport = [sites[0].id] + res.redirect('/reports/choose-data') + return + } + res.render('reports/choose-site', { sites }) @@ -170,7 +184,7 @@ module.exports = (router) => { } else { const error = { - text: "Select data for report", + text: "Select the data you want to include", href: "#data-1" } @@ -186,6 +200,7 @@ module.exports = (router) => { const data = req.session.data const currentOrganisation = res.locals.currentOrganisation const siteIds = data.siteIdsToReport || [] + const selectedVaccines = data.vaccinesToReport || [] const today = new Date() const days = 86400000 // number of milliseconds in a day @@ -203,6 +218,22 @@ module.exports = (router) => { const dateOption = data.date let from, to + let vaccinesToReportDisplay = selectedVaccines.filter((vaccineName) => vaccineName !== 'all') + + if (selectedVaccines.includes('all')) { + const organisationVaccines = currentOrganisation.vaccines || [] + let enabledVaccines = organisationVaccines.filter((vaccine) => vaccine.status === "enabled") + + // Temporary: show all vaccines if none have batches added + if (enabledVaccines.length === 0) { + enabledVaccines = data.vaccines + } + + vaccinesToReportDisplay = enabledVaccines.map((vaccine) => vaccine.name) + } + + vaccinesToReportDisplay = [...new Set(vaccinesToReportDisplay)] + .sort((a, b) => a.localeCompare(b)) switch (dateOption) { case 'custom_date_range': @@ -217,18 +248,25 @@ module.exports = (router) => { from = new Date(today.getTime() - (1 * days)).toISOString().substring(0,10) to = new Date(today.getTime() - (1 * days)).toISOString().substring(0,10) break - case 'Last7days': - from = new Date(today.getTime() - (7 * days)).toISOString().substring(0,10) - to = today.toISOString().substring(0,10) - break - case 'Last14days': - from = new Date(today.getTime() - (14 * days)).toISOString().substring(0,10) - to = today.toISOString().substring(0,10) + case 'LastCalendarWeek': { + const dayOfWeek = today.getDay() // 0 = Sunday, 1 = Monday, ... + const daysSinceMonday = (dayOfWeek === 0 ? 7 : dayOfWeek) - 1 + const lastMonday = new Date(today.getFullYear(), today.getMonth(), today.getDate() - daysSinceMonday - 7) + const lastSunday = new Date(lastMonday.getTime() + (6 * days)) + + from = lastMonday.toISOString().substring(0,10) + to = lastSunday.toISOString().substring(0,10) break - case 'Last31days': - from = new Date(today.getTime() - (31 * days)).toISOString().substring(0,10) - to = today.toISOString().substring(0,10) + } + case 'LastCalendarMonth': { + const firstDayOfThisMonth = new Date(today.getFullYear(), today.getMonth(), 1) + const firstDayOfLastMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1) + const lastDayOfLastMonth = new Date(firstDayOfThisMonth.getTime() - days) + + from = firstDayOfLastMonth.toISOString().substring(0,10) + to = lastDayOfLastMonth.toISOString().substring(0,10) break + } } @@ -237,7 +275,8 @@ module.exports = (router) => { sites, pharmacies, from, - to + to, + vaccinesToReportDisplay }) }) @@ -252,7 +291,7 @@ module.exports = (router) => { data.vaccinesToReport = null - res.redirect('/reports/download') + res.redirect('/reports/creating-report') }) } diff --git a/app/views/reports/alt-index.html b/app/views/reports/alt-index.html new file mode 100644 index 00000000..061cea89 --- /dev/null +++ b/app/views/reports/alt-index.html @@ -0,0 +1,37 @@ +{% extends 'layout.html' %} + +{% set pageName = "Reports" %} + +{% set currentSection = "reports" %} + +{% block content %} + +
Create and download reports.
+ + {% from "inset-text/macro.njk" import insetText %} + +{% set insetTextHtml %} +You need to wait before you can start creating a report. This is because another report is already in progress for your organisation.
+{% endset %} + +{{ insetText({ + html: insetTextHtml +}) }} + + +{{ patientData | join(", ") }}
+ {% endif %} + + {% if (staffData | length) > 0 %} +{{ staffData | join(", ") }}
+ {% endif %} + + {% if (siteData | length) > 0 %} +{{ siteData | join(", ") }}
+ {% endif %} + + {% if (consentAndEligibilityData | length) > 0 %} +{{ consentAndEligibilityData | join(", ") }}
+ {% endif %} + + {% if (vaccinationData | length) > 0 %} +{{ vaccinationData | join(", ") }}
+ {% endif %} + + {% if (paymentData | length) > 0 %} +{{ paymentData | join(", ") }}
+ {% endif %} {% endset %} {% set sitesHtml %} -This can take up to a few minutes.
+ +You can navigate away from this page but do not close this tab or window.
+ ++ Prototype only: Simulate report complete +
+ + +You have created a report from 16 July to 30 July 2024 for COVID-19 and flu at Verrington (RH635)
- {{ button({ "text": "Download report", "href": "/reports" diff --git a/app/views/reports/index.html b/app/views/reports/index.html index 635655c5..c88de817 100644 --- a/app/views/reports/index.html +++ b/app/views/reports/index.html @@ -31,6 +31,10 @@+ Prototype only: Simulate when someone else is creating a report +
+ {% else %}You have not yet recorded any vaccinations.
{% endif %}