Skip to content

Commit 1a92ac6

Browse files
Update records section with filters (#468)
This is a design spike to look at how we could update the 'Records' section so that, instead of just searching for records by patient name or NHS number, you can also filter by: * vaccination type * batch number * vaccinator We’ve heard these could be useful in some circumstances, such as correcting mistakes or checking that records were recorded correctly. To accommodate these options, we could have a 'Filters' box, with the most common filters shown by default, and more available under a revealed section. The records could be sorted by date and time recorded (most recent first), with pagination at the bottom. By default, all vaccination records (from your organisation) would be shown (limited to most recent 500 or so?). This could mean that if you just need to correct a mistake recorded within the past few minutes or hour, you don't even need to use the filters at all, as it’ll be near the top of the list. I did also consider having the filters in a left hand column, but the space is pretty tight given the number of filters and the number of columns shown in the list. However it could be possible to make it work if the content is reduced down a bit. [Jira card](https://nhsd-jira.digital.nhs.uk/browse/RAVS-573) ## Screenshots ### Default filters <img width="2240" height="1945" alt="localhost_3000_records" src="https://github.com/user-attachments/assets/d5c0c613-5284-4451-89cb-f26b03bb29d8" /> ### Additional filters <img width="2240" height="3515" alt="localhost_3000_records (1)" src="https://github.com/user-attachments/assets/49fa6e31-adb2-455a-9c11-8477eeaf986d" />
1 parent 758603b commit 1a92ac6

File tree

11 files changed

+348
-73
lines changed

11 files changed

+348
-73
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use "sass:color";
2+
3+
.app-card--filters {
4+
background-color: color.scale(nhsuk-colour("grey-4"), $alpha: -50%);
5+
6+
.nhsuk-card__heading--feature {
7+
background-color: nhsuk-colour("grey-1");
8+
}
9+
}

app/assets/sass/components/_checkboxes.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,30 @@
33
.nhsuk-label {
44
box-sizing: border-box;
55
}
6+
7+
8+
.app-checkboxes--small {
9+
10+
.nhsuk-checkboxes__item,
11+
.nhsuk-radios__item {
12+
margin-bottom: 0;
13+
}
14+
15+
.nhsuk-checkboxes__label,
16+
.nhsuk-radios__label {
17+
padding-left: 0;
18+
19+
&::before {
20+
border-width: 3px;
21+
padding: 0;
22+
transform: scale(0.6667);
23+
transform-origin: center left;
24+
}
25+
26+
&::after {
27+
box-sizing: border-box;
28+
left: 3px;
29+
transform: rotate(-45deg) scale(0.6667);
30+
}
31+
}
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.app-search {
2+
display: flex;
3+
gap: nhsuk-spacing(1);
4+
5+
6+
.app-search--input {
7+
display: flex;
8+
flex: 1;
9+
margin: 0;
10+
}
11+
12+
.nhsuk-form-group {
13+
width: 100%;
14+
}
15+
16+
.app-search--button {
17+
display: flex;
18+
flex: 0;
19+
}
20+
}

app/assets/sass/main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
@import 'components/checkboxes';
1313

1414
// Local components or modifiers
15+
@import 'components/card';
1516
@import 'components/header';
1617
@import 'components/summary-list';
1718
@import 'components/table';
1819
@import 'components/button';
1920
@import 'components/filters';
21+
@import 'components/search';
2022
@import 'components/section';
2123
@import 'components/tag';
2224
@import 'components/numbered-heading';

app/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require('./routes/user-onboarding')(router)
1111
require('./routes/user-profile')(router)
1212
require('./routes/vaccines')(router)
1313
require('./routes/reports')(router)
14-
require('./routes/find-record')(router)
14+
require('./routes/records')(router)
1515
require('./routes/prototype-admin')(router)
1616
require('./routes/lists')(router)
1717
require('./routes/support')(router)

app/routes/helpers.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ module.exports = router => {
6969
const data = req.session.data
7070
const currentOrganisation = res.locals.currentOrganisation
7171

72+
const listOfFirstNames = ["Susana", "Steven", "Aleah", "Kaylen", "Stephan", "Donavon", "Emely", "Kailee", "Brooks", "Brenton", "Miles", "Emanuel", "Jedidiah", "Glenn", "Jude", "Ivory", "Austen", "Alyson", "Jaime", "Jordin", "Chad", "Janay", "Tahj", "Reginald", "Enoch", "Amiyah", "Benito", "April", "Joelle", "Brant"]
73+
74+
const listOfLastNames = ["Ross", "Friedman", "Switzer", "Devore", "Dominguez", "Kohn", "Moreau", "Farrar", "Hogue", "Goldsmith", "Wilkins", "Cornwell", "Wimberly", "Messer", "Woods", "Forrest", "Aiello", "Kuykendall", "Trout", "Bigelow", "Moreland", "Lentz", "Hurst", "Quinonez", "Pak", "McNally", "Longo", "Hunt", "Villa", "Breaux"]
75+
7276
const vaccinationsToAdd = parseInt(data.numberOfVaccinationsToAdd);
7377

7478
const dateToday = new Date()
@@ -78,28 +82,51 @@ module.exports = router => {
7882
const monthToday = (dateToday.getMonth() + 1)
7983
const yearToday = (dateToday.getFullYear())
8084

85+
const organisationVaccines = currentOrganisation.vaccines || []
86+
87+
const vaccinesEnabled = organisationVaccines
88+
.filter((vaccine) => vaccine.status === "enabled")
89+
90+
const vaccinators = data.users.filter(function(user) {
91+
const userInOrganisation = (user.organisations || []).find((userOrg) => userOrg.id === currentOrganisation.id)
92+
93+
return (userInOrganisation && userInOrganisation.vaccinator)
94+
})
8195

8296
for (let i = 0; i < vaccinationsToAdd; i++) {
8397

8498
const generatedId = Math.floor(Math.random() * 10000000).toString()
99+
const randomVaccine = randomItem(vaccinesEnabled)
100+
101+
const vaccineProductsInStock = data.vaccineStock.filter((vaccineStockItem) => vaccineStockItem.vaccine == randomVaccine.name)
102+
103+
const randomVaccineProduct = randomItem(vaccineProductsInStock)
104+
const randombatchNumber = randomItem(randomVaccineProduct.batches)
105+
106+
const vaccinator = randomItem(vaccinators)
107+
108+
const randomName = randomItem(listOfFirstNames) + " " + randomItem(listOfLastNames)
109+
110+
const randomNhsNumber = "9" + (100000000 + Math.floor(Math.random() * 900000000)).toString()
85111

86112
data.vaccinationsRecorded.push({
87113
id: generatedId,
114+
organisationId: "RW3",
88115
siteId: "RW3NM",
89116
date: {
90117
day: dayToday.toString(),
91118
month: monthToday.toString(),
92119
year: yearToday.toString()
93120
},
94-
vaccine: "RSV",
95-
vaccineProduct: "Abrysvo",
121+
vaccine: randomVaccine.name,
122+
vaccineProduct: randomVaccineProduct.vaccineProduct,
96123
patient: {
97-
name: "Jodie Brown",
98-
nhsNumber: "9123123123"
124+
name: randomName,
125+
nhsNumber: randomNhsNumber
99126
},
100-
batchNumber: "74725GJ0",
127+
batchNumber: randombatchNumber.batchNumber,
101128
batchExpiryDate: "2025-01-05",
102-
vaccinator: "Anna Brown",
129+
vaccinatorId: vaccinator.id,
103130
eligibility: ["Pregnant"],
104131
pregnancyDueDate: {
105132
day: "04",
@@ -113,7 +140,7 @@ module.exports = router => {
113140
})
114141
}
115142

116-
res.redirect('/home')
143+
res.redirect('/records')
117144
});
118145

119146

app/routes/record-vaccinations.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,6 @@ module.exports = router => {
596596
data.vaccinationDate.year = yearToday
597597
}
598598

599-
const vaccinator = data.users.find((user) => user.id === data.vaccinatorId)
600-
601599
data.vaccinationsRecorded.push({
602600
id: generatedId,
603601
date: data.vaccinationDate,
@@ -610,7 +608,7 @@ module.exports = router => {
610608
batchNumber: data.vaccineBatch,
611609
batchExpiryDate: "2025-12-05",
612610
siteId: data.deliveryTeam,
613-
vaccinator: (vaccinator.firstName + " " + vaccinator.lastName),
611+
vaccinatorId: data.vaccinatorId,
614612
eligibility: data.eligibility,
615613
pregnancyDueDate: data.pregnancyDueDate,
616614
consent: data.consent,
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
module.exports = router => {
22

3+
router.get('/records', (req, res) => {
4+
5+
const data = req.session.data
6+
7+
const currentOrganisation = res.locals.currentOrganisation
8+
9+
let vaccinationsRecorded = data.vaccinationsRecorded.filter((vaccination) => vaccination.organisationId === currentOrganisation.id)
10+
11+
const totalVaccinationsRecorded = vaccinationsRecorded.length
12+
13+
// Get a list of all the different vaccine names recorded so far
14+
const vaccinesRecorded = [...new Set(vaccinationsRecorded
15+
.map((record) => record.vaccine))]
16+
17+
const idOfVaccinators = [...new Set(vaccinationsRecorded.map((vaccination) => vaccination.vaccinatorId))]
18+
19+
const vaccinators = data.users.filter((user) => idOfVaccinators.includes(user.id))
20+
21+
const nameOrNhsNumberSearch = data.nameOrNhsNumber
22+
23+
if (nameOrNhsNumberSearch && nameOrNhsNumberSearch != "") {
24+
vaccinationsRecorded = vaccinationsRecorded.filter(function(record) {
25+
return (
26+
record.patient.name.toLowerCase().startsWith(nameOrNhsNumberSearch.toLowerCase()) ||
27+
(record.patient.nhsNumber === nameOrNhsNumberSearch)
28+
)
29+
})
30+
}
31+
32+
if (data.vaccinatorId && data.vaccinatorId != "") {
33+
vaccinationsRecorded = vaccinationsRecorded.filter(function(record) {
34+
return (
35+
record.vaccinatorId === data.vaccinatorId
36+
)
37+
})
38+
}
39+
40+
if (totalVaccinationsRecorded === 0) {
41+
res.render('records/no-vaccinations-recorded')
42+
} else {
43+
res.render('records/index', {
44+
vaccinesRecorded,
45+
vaccinationsRecorded,
46+
vaccinators
47+
})
48+
}
49+
})
50+
351
router.post('/records/answer-search', (req, res) => {
452
const data = req.session.data
553

app/views/records/check.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
{% block beforeContent %}
88
{{ backLink({
9-
href: "/records/patient-history",
9+
href: "/records",
1010
text: "Back"
1111
}) }}
1212
{% endblock %}
@@ -25,6 +25,9 @@
2525

2626
<h1 class="nhsuk-heading-l">{{ vaccination.patient.name }}’s {{vaccination.vaccine}} vaccination record</h1>
2727

28+
29+
{% set vaccinator = (data.users | findById(vaccination.vaccinatorId)) %}
30+
2831
{{ summaryList({
2932
rows: [
3033
{
@@ -138,7 +141,7 @@ <h1 class="nhsuk-heading-l">{{ vaccination.patient.name }}’s {{vaccination.vac
138141
text: "Vaccinator"
139142
},
140143
value: {
141-
text: vaccination.vaccinator
144+
text: (vaccinator.firstName + " " + vaccinator.lastName)
142145
},
143146
actions: {
144147
items: [

0 commit comments

Comments
 (0)