Skip to content

Commit a3ed159

Browse files
Update home page stats (#445)
This updates the layout of the stats shown on the 'Home' tab to make it more scalable to having more vaccine types, and also to show a breakdown by site. 🗂️ [Jira card](https://nhsd-jira.digital.nhs.uk/browse/RAVS-2784) ## Before Previously, a table was shown with a row for each of the past 7 days, and each vaccine type being given by that organisation in columns (with a Total at the end): <img width="2240" height="2978" alt="stats-before" src="https://github.com/user-attachments/assets/ce11d262-5faa-489a-a83e-88c88d8d1c44" /> However, this design doesn’t work so well when there are 7 or more vaccine types, as the width of the table gets too wide and the table becomes harder to read. ## After Instead, the new design splits the data into multiple tables which are shown as tabs. The first one has a row for each of the past 7 days but only shows the total. The second has a row for each vaccine type, and columns for Today, Past 7 days, Month to date and Total. The third one has a row for each site, and columns for Today, Past 7 days, Month to date and Total. The "By vaccination" and "By site" tabs are only shown if there are at least 2 vaccination types recorded or at least 2 different sites. ### Empty state <img width="2210" height="2170" alt="empty" src="https://github.com/user-attachments/assets/b92463e1-9410-4a3b-a080-a5581affc256" /> ### First tab only (single vaccination type, single tab) <img width="2210" height="3108" alt="localhost_3000_home (3)" src="https://github.com/user-attachments/assets/a46b4fff-f9b8-4c5e-990b-c3dcc1420663" /> ### By vaccination tab <img width="2210" height="2742" alt="by-vaccination" src="https://github.com/user-attachments/assets/5ab8a8d4-3944-43b6-afe3-f630f835de54" /> ### By site tab <img width="2210" height="2498" alt="by-site" src="https://github.com/user-attachments/assets/29462d1e-13de-4d4d-8f83-cecc5c08989e" /> --- The pull request also refactors this bit of the prototype quite a bit, and adds a new option to the 'Prototype data setup' section to record some dummy vaccinations.
1 parent d366b34 commit a3ed159

File tree

16 files changed

+519
-480
lines changed

16 files changed

+519
-480
lines changed

app/data/session-data-defaults.js

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -15,82 +15,7 @@ module.exports = {
1515
currentUserId: "2387441662601",
1616
currentOrganisationId: "RW3",
1717
currentRegionId: "Y62",
18-
vaccinationsRecorded: [
19-
{
20-
id: "ABC123",
21-
date: {
22-
day: "11",
23-
month: "11",
24-
year: "2024"
25-
},
26-
vaccine: "RSV",
27-
vaccineProduct: "Abrysvo",
28-
patient: {
29-
name: "Jodie Brown",
30-
nhsNumber: "9123123123"
31-
},
32-
batchNumber: "74725GJ0",
33-
batchExpiryDate: "2025-01-05",
34-
deliveryTeam: "Albert House",
35-
vaccinator: "Anna Brown",
36-
eligibility: ["Pregnant"],
37-
pregnancyDueDate: {
38-
day: "04",
39-
month: "02",
40-
year: "2025"
41-
},
42-
consent: "Patient",
43-
injectionSite: "Left arm",
44-
notes: "The patient has been taking Warfarin for 1 month as prescribed by GP.",
45-
editable: true
46-
},
47-
{
48-
id: "74HYD94",
49-
date: {
50-
day: "08",
51-
month: "09",
52-
year: "2024"
53-
},
54-
vaccine: "Flu",
55-
vaccineProduct: "Flucelvax Tetra - QIVc",
56-
patient: {
57-
name: "Jodie Brown",
58-
nhsNumber: "9123123123"
59-
},
60-
batchNumber: "872214",
61-
batchExpiryDate: "2024-12-13",
62-
deliveryTeam: "Albert House",
63-
vaccinator: "Anna Brown",
64-
eligibility: ["Based on age"],
65-
consent: "Patient",
66-
injectionSite: "Left arm",
67-
notes: "",
68-
editable: false
69-
},
70-
{
71-
id: "8174GSY",
72-
date: {
73-
day: "09",
74-
month: "09",
75-
year: "2021"
76-
},
77-
vaccine: "COVID-19",
78-
vaccineProduct: "Spikevax JN.1",
79-
patient: {
80-
name: "Jodie Brown",
81-
nhsNumber: "9123123123"
82-
},
83-
batchNumber: "PU1234",
84-
batchExpiryDate: "2022-02-15",
85-
deliveryTeam: "Albert House",
86-
vaccinator: "Anna Brown",
87-
eligibility: ["Based on age"],
88-
consent: "Patient",
89-
injectionSite: "Left arm",
90-
notes: "",
91-
editable: true
92-
}
93-
],
18+
vaccinationsRecorded: [],
9419
data: [
9520
"Patients", "Staff", "Site or delivery team", "Assessment and consent", "Vaccination"
9621
],

app/filters.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,36 @@ module.exports = function (env) { /* eslint-disable-line no-unused-vars */
4343
}
4444
}
4545

46+
/**
47+
* Returns the name of a month, eg 'November', when
48+
* given the number of the month, eg 11.
49+
*
50+
* Note that the month number should start from 1 for
51+
* January, rather than 0 (which is the default for
52+
* JavaScript date objects).
53+
*
54+
* @param {Integer, string} monthNumber - number of the month
55+
* @returns {String} Full name of the month in English
56+
*/
57+
filters.monthName = function(monthNumber) {
58+
59+
try {
60+
monthNumber = parseInt(monthNumber)
61+
62+
if (!monthNumber || (monthNumber < 1) || (monthNumber > 12)) {
63+
throw new Error('Invalid monthNumber - must be between 1 and 12')
64+
}
65+
66+
const date = new Date(Date.UTC(2000, (monthNumber - 1), 1, 0, 0, 0));
67+
const dateFormatter = new Intl.DateTimeFormat('en-GB', {month: 'long'});
68+
69+
return dateFormatter.format(date)
70+
71+
} catch (error) {
72+
return error.message.split(':')[0]
73+
}
74+
}
75+
4676
/* ------------------------------------------------------------------
4777
add your methods to the filters obj below this comment block:
4878
@example:

app/routes/helpers.js

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,59 @@ module.exports = router => {
5959
}
6060
}
6161

62-
6362
res.redirect('/vaccines')
6463
});
6564

65+
66+
router.post('/prototype-setup/add-vaccinations', (req, res) => {
67+
const data = req.session.data
68+
const currentOrganisation = res.locals.currentOrganisation
69+
70+
const vaccinationsToAdd = parseInt(data.numberOfVaccinationsToAdd);
71+
72+
const dateToday = new Date()
73+
74+
const dayToday = (dateToday.getDate())
75+
// Months in JavaScript are zero-indexed
76+
const monthToday = (dateToday.getMonth() + 1)
77+
const yearToday = (dateToday.getFullYear())
78+
79+
80+
for (let i = 0; i < vaccinationsToAdd; i++) {
81+
82+
const generatedId = Math.floor(Math.random() * 10000000).toString()
83+
84+
data.vaccinationsRecorded.push({
85+
id: generatedId,
86+
siteId: "RW3NM",
87+
date: {
88+
day: dayToday,
89+
month: monthToday,
90+
year: yearToday
91+
},
92+
vaccine: "RSV",
93+
vaccineProduct: "Abrysvo",
94+
patient: {
95+
name: "Jodie Brown",
96+
nhsNumber: "9123123123"
97+
},
98+
batchNumber: "74725GJ0",
99+
batchExpiryDate: "2025-01-05",
100+
vaccinator: "Anna Brown",
101+
eligibility: ["Pregnant"],
102+
pregnancyDueDate: {
103+
day: "04",
104+
month: "02",
105+
year: "2025"
106+
},
107+
consent: "Patient",
108+
injectionSite: "Left arm",
109+
notes: "The patient has been taking Warfarin for 1 month as prescribed by GP.",
110+
editable: true
111+
})
112+
}
113+
114+
res.redirect('/home')
115+
});
116+
66117
}

0 commit comments

Comments
 (0)