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 %} + +
+
+ + {% include "includes/notification.html" %} + +
+
+ +
+
+ +

Reports

+

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 +}) }} + + +
+
+ +{% endblock %} diff --git a/app/views/reports/check.html b/app/views/reports/check.html index 6d3a936a..22f5b776 100644 --- a/app/views/reports/check.html +++ b/app/views/reports/check.html @@ -19,37 +19,55 @@

{{ pageName }}

- {% set dataFields = [] %} - - {% for field in data.patientDataToReport %} - {% set dataFields = (dataFields.push(field), dataFields) %} - {% endfor %} - {% for field in data.staffDataToReport %} - {% set dataFields = (dataFields.push(field), dataFields) %} - {% endfor %} - {% for field in data.siteDataToReport %} - {% set dataFields = (dataFields.push(field), dataFields) %} - {% endfor %} - {% for field in data.consentAndEligibilityDataToReport %} - {% set dataFields = (dataFields.push(field), dataFields) %} - {% endfor %} - {% for field in data.vaccinationDataToReport %} - {% set dataFields = (dataFields.push(field), dataFields) %} - {% endfor %} - {% for field in data.paymentDataToReport %} - {% set dataFields = (dataFields.push(field), dataFields) %} - {% endfor %} + {% set patientData = data.patientDataToReport or [] %} + {% set staffData = data.staffDataToReport or [] %} + {% set siteData = data.siteDataToReport or [] %} + {% set consentAndEligibilityData = data.consentAndEligibilityDataToReport or [] %} + {% set vaccinationData = data.vaccinationDataToReport or [] %} + {% set paymentData = data.paymentDataToReport or [] %} {% set dataValue %} - {{ dataFields | join(", ") }} + {% if (patientData | length) > 0 %} +

Patient data

+

{{ patientData | join(", ") }}

+ {% endif %} + + {% if (staffData | length) > 0 %} +

Staff data

+

{{ staffData | join(", ") }}

+ {% endif %} + + {% if (siteData | length) > 0 %} +

Site data

+

{{ siteData | join(", ") }}

+ {% endif %} + + {% if (consentAndEligibilityData | length) > 0 %} +

Consent and eligibility data

+

{{ consentAndEligibilityData | join(", ") }}

+ {% endif %} + + {% if (vaccinationData | length) > 0 %} +

Vaccination data

+

{{ vaccinationData | join(", ") }}

+ {% endif %} + + {% if (paymentData | length) > 0 %} +

Payment information

+

{{ paymentData | join(", ") }}

+ {% endif %} {% endset %} {% set sitesHtml %} - + {% if (sites | length) > 2 %} + {{ sites | length }} sites selected + {% else %} + + {% endif %} {% endset %} {% set pharmaciesHtml %} @@ -60,14 +78,13 @@

{{ pageName }}

{% endset %} - {% set vaccinesToReportText = "" %} - {% if data.vaccinesToReport %} - {% set vaccinesToReportDisplay = [] %} - {% for vaccine in (data.vaccinesToReport | sort(false, false, "name")) %} - {% set vaccinesToReportDisplay = (vaccinesToReportDisplay.push(vaccine ), vaccinesToReportDisplay) %} - {% endfor %} - {% set vaccinesToReportText = vaccinesToReportDisplay | join(", ") %} - {% endif %} + {% set vaccinesToReportHtml %} + + {% endset %} {{ summaryList({ rows: [ @@ -110,10 +127,10 @@

{{ pageName }}

}, { key: { - text: ("Vaccines" if (data.vaccinesToReport | length) > 1 else "Vaccine") + text: ("Vaccines" if (vaccinesToReportDisplay | length) > 1 else "Vaccine") }, value: { - text: vaccinesToReportText if data.vaccines + html: vaccinesToReportHtml }, actions: { items: [ @@ -181,7 +198,7 @@

{{ pageName }}

text: "Data" }, value: { - text: dataValue + html: dataValue }, actions: { items: [ diff --git a/app/views/reports/choose-data.html b/app/views/reports/choose-data.html index 5076d211..073b0bb0 100644 --- a/app/views/reports/choose-data.html +++ b/app/views/reports/choose-data.html @@ -6,8 +6,16 @@ {% block beforeContent %} + {% if currentOrganisation.type == "Pharmacy HQ" %} + {% set backLinkHref = "/reports/choose-pharmacies" %} + {% elif (currentOrganisation.sites | length) == 1 %} + {% set backLinkHref = "/reports/choose-vaccines" %} + {% else %} + {% set backLinkHref = "/reports/choose-site" %} + {% endif %} + {{ backLink({ - href: "/reports/choose-site", + href: backLinkHref, text: "Back" }) }} {% endblock %} diff --git a/app/views/reports/choose-dates.html b/app/views/reports/choose-dates.html index 367579bc..fbee8642 100644 --- a/app/views/reports/choose-dates.html +++ b/app/views/reports/choose-dates.html @@ -143,10 +143,6 @@ "value": "Last7days", "text": "Last 7 days (includes today)" }, - { - "value": "Last14days", - "text": "Last 14 days (includes today)" - }, { "value": "Last31days", "text": "Last 31 days (includes today)" @@ -155,6 +151,10 @@ "value": "Last90days", "text": "Last 90 days (includes today)" }, + { + "value": "LastCalendarMonth", + "text": "Last calendar month" + }, { divider: "or" }, diff --git a/app/views/reports/creating-report.html b/app/views/reports/creating-report.html new file mode 100644 index 00000000..cfb9ca86 --- /dev/null +++ b/app/views/reports/creating-report.html @@ -0,0 +1,25 @@ +{% extends 'layout.html' %} + +{% set pageName = "We are creating your report" %} + +{% set currentSection = "reports" %} + + +{% block content %} +
+
+ +

We are creating your report

+ +

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 +

+ + +
+
+{% endblock %} diff --git a/app/views/reports/download.html b/app/views/reports/download.html index ff31a7b5..40b1d9b8 100644 --- a/app/views/reports/download.html +++ b/app/views/reports/download.html @@ -11,8 +11,6 @@

Your report is ready

-

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 @@

Reports

"href": "/reports/choose-dates" }) }} +

+ Prototype only: Simulate when someone else is creating a report +

+ {% else %}

You have not yet recorded any vaccinations.

{% endif %}