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..98e0d4ec 100644 --- a/app/data/session-data-defaults.js +++ b/app/data/session-data-defaults.js @@ -22,7 +22,7 @@ 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", "GP (ODS code only)"], staffDataOptions: ["Recorder", "Vaccinator"], locationDataOptions: ["Site name", "Site ODS code", "Location type"], consentAndEligibilityDataOptions: ["Consent", "Eligibility", "Estimated due date"], diff --git a/app/routes/reports.js b/app/routes/reports.js index 230ac52a..f3d8f5be 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 }) @@ -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': @@ -229,6 +260,19 @@ module.exports = (router) => { from = new Date(today.getTime() - (31 * days)).toISOString().substring(0,10) to = today.toISOString().substring(0,10) break + case 'Last90days': + from = new Date(today.getTime() - (90 * days)).toISOString().substring(0,10) + to = today.toISOString().substring(0,10) + break + 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 +281,8 @@ module.exports = (router) => { sites, pharmacies, from, - to + to, + vaccinesToReportDisplay }) }) @@ -252,7 +297,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 %}