Skip to content

Commit 99e9457

Browse files
johnrimmer2frankierobertoAnna-Sutton
authored
Update patient search flow (#217)
This updates the patient search flow with some changes and additional screens. Changes: * postcode is optional on the initial search * there’s a different screen if you have more than 1 matching result, which tells you to refine the search (and where postcode becomes required) * if you choose to continue without an NHS number (after getting no results), then postcode and a gender field are required * on the check your answers screen, if there was no NHS number found, then the name, date of birth, postcode and gender are all shown with a 'Change' link, as these are now editable (but no change link shown if data came from PDS) --------- Co-authored-by: Frankie Roberto <[email protected]> Co-authored-by: Anna-Sutton <[email protected]>
1 parent a8a7dff commit 99e9457

File tree

6 files changed

+426
-26
lines changed

6 files changed

+426
-26
lines changed

app/routes/vaccinate.js

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,17 @@ module.exports = router => {
247247
})
248248
}
249249

250-
if (postcode === "") {
251-
postcodeError = "Enter a postcode"
252-
errors.push({
253-
text: postcodeError,
254-
href: "#postcode"
255-
})
256-
}
257-
258250
if (errors.length === 0) {
259251

260-
if (Number(dateOfBirth.day) %2) {
252+
// If day of month is odd, pretend there’s no search result
253+
if (Number(dateOfBirth.day) % 2) {
261254
res.redirect('/vaccinate/no-search-result')
255+
256+
// If postcode blank, pretend there’s multiple results
257+
} else if (postcode === "") {
258+
res.redirect('/vaccinate/refine-search-result')
259+
260+
// Otherwise pretend there is a single result
262261
} else {
263262
res.redirect('/vaccinate/search-result')
264263
}
@@ -271,9 +270,90 @@ module.exports = router => {
271270
postcodeError
272271
})
273272
}
273+
})
274+
275+
276+
router.get('/vaccinate/create-a-record', (req, res) => {
277+
278+
const firstName = req.session.data.firstName;
279+
const lastName = req.session.data.lastName;
280+
const dateOfBirth = req.session.data.dateOfBirth;
281+
const postcode = req.session.data.postcode;
282+
const gender = req.session.data.gender;
283+
let errors = []
284+
let firstNameError, lastNameError, dateOfBirthError, postcodeError, genderError
285+
286+
if (req.query.showErrors == 'yes') {
287+
if (firstName === "") {
288+
firstNameError = "Enter a first name"
289+
errors.push({
290+
text: firstNameError,
291+
href: "#firstName"
292+
})
293+
}
294+
295+
if (lastName === "") {
296+
lastNameError = "Enter a last name"
297+
errors.push({
298+
text: lastNameError,
299+
href: "#lastName"
300+
})
301+
}
302+
303+
if (dateOfBirth.day === "" || dateOfBirth.month === "" || dateOfBirth.year === "") {
304+
dateOfBirthError = "Enter a date of birth"
305+
errors.push({
306+
text: dateOfBirthError,
307+
href: "#dateOfBirth"
308+
})
309+
}
310+
311+
if (postcode === "") {
312+
postcodeError = "Enter a postcode"
313+
errors.push({
314+
text: postcodeError,
315+
href: "#postcode"
316+
})
317+
}
318+
319+
if (!gender) {
320+
genderError = "Select an option"
321+
errors.push({
322+
text: genderError,
323+
href: "#gender"
324+
})
325+
}
326+
}
327+
328+
res.render('vaccinate/create-a-record', {
329+
errors,
330+
firstNameError,
331+
lastNameError,
332+
dateOfBirthError,
333+
postcodeError,
334+
genderError
335+
})
336+
})
337+
338+
339+
router.post('/vaccinate/create-a-record', (req, res) => {
340+
const data = req.session.data
341+
const firstName = req.session.data.firstName;
342+
const lastName = req.session.data.lastName;
343+
const dateOfBirth = req.session.data.dateOfBirth;
344+
const postcode = req.session.data.postcode;
345+
const gender = req.session.data.gender;
346+
347+
if (firstName != '' && lastName != '' && dateOfBirth.day != '' && dateOfBirth.month != '' && dateOfBirth.year != '' && postcode != '' && gender != '') {
348+
349+
res.redirect('/vaccinate/consent')
350+
} else {
351+
res.redirect('/vaccinate/create-a-record?showErrors=yes')
352+
}
274353

275354
})
276355

356+
277357
router.get('/vaccinate/patient-estimated-due-date', (req, res) => {
278358

279359
const showError = req.query.showError

app/views/vaccinate/check.html

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ <h2 class="nhsuk-heading-m">Patient</h2>
7171
text: "Name"
7272
},
7373
value: {
74-
text: data.patientName
74+
text: (data.patientName if data.patientName else data.firstName + " " + data.lastName)
7575
},
7676
actions: {
7777
items: [
78+
{
79+
href: "/vaccinate/create-a-record",
80+
text: "Change",
81+
visuallyHiddenText: "name"
82+
} if not data.nhsNumber
7883
]
7984
}
8085
},
@@ -87,6 +92,11 @@ <h2 class="nhsuk-heading-m">Patient</h2>
8792
},
8893
actions: {
8994
items: [
95+
{
96+
href: "/vaccinate/create-a-record",
97+
text: "Change",
98+
visuallyHiddenText: "date of birth"
99+
} if not data.nhsNumber
90100
]
91101
}
92102
},
@@ -111,6 +121,11 @@ <h2 class="nhsuk-heading-m">Patient</h2>
111121
},
112122
actions: {
113123
items: [
124+
{
125+
href: "/vaccinate/create-a-record",
126+
text: "Change",
127+
visuallyHiddenText: "postcode"
128+
} if not data.nhsNumber
114129
]
115130
}
116131
} if not data.nhsNumber,
@@ -125,7 +140,24 @@ <h2 class="nhsuk-heading-m">Patient</h2>
125140
items: [
126141
]
127142
}
128-
} if data.nhsNumber
143+
} if data.nhsNumber,
144+
{
145+
key: {
146+
text: "Gender"
147+
},
148+
value: {
149+
text: data.gender
150+
},
151+
actions: {
152+
items: [
153+
{
154+
href: "/vaccinate/create-a-record",
155+
text: "Change",
156+
visuallyHiddenText: "gender"
157+
} if not data.nhsNumber
158+
]
159+
}
160+
} if not data.nhsNumber
129161
]
130162
}) }}
131163

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{% extends 'layout.html' %}
2+
3+
{% set pageName = "Continue with no NHS number" %}
4+
5+
{% set currentSection = "vaccinate" %}
6+
7+
{% block beforeContent %}
8+
{{ backLink({ href: "/vaccinate/no-search-result" }) }}
9+
{% endblock %}
10+
11+
{% block content %}
12+
<div class="nhsuk-grid-row">
13+
<div class="nhsuk-grid-column-two-thirds">
14+
15+
{% if errors and ((errors | length) > 0) %}
16+
{{ errorSummary({
17+
titleText: "There is a problem",
18+
errorList: errors
19+
}) }}
20+
{% endif %}
21+
22+
<h1 class="nhsuk-heading-l">{{ pageName }}</h1>
23+
24+
<p> You need to {% if not data.postcode%} enter a postcode and {% endif %} select an option for gender. The vaccination record will only be sent to a GP if it can be matched with an NHS number later.</p>
25+
26+
<form action="/vaccinate/create-a-record" method="post">
27+
{{ input({
28+
label: {
29+
text: "First name"
30+
},
31+
id: "firstName",
32+
name: "firstName",
33+
value: data.firstName,
34+
classes: "nhsuk-input--width-20",
35+
errorMessage: {
36+
text: firstNameError
37+
} if firstNameError
38+
}) }}
39+
40+
{{ input({
41+
label: {
42+
text: "Last name"
43+
},
44+
id: "lastName",
45+
name: "lastName",
46+
value: data.lastName,
47+
classes: "nhsuk-input--width-20",
48+
errorMessage: {
49+
text: lastNameError
50+
} if lastNameError
51+
}) }}
52+
53+
{{ dateInput({
54+
id: "dateOfBirth",
55+
namePrefix: "dateOfBirth",
56+
fieldset: {
57+
legend: {
58+
text: "Date of birth",
59+
classes: ""
60+
}
61+
},
62+
hint: {
63+
text: "For example, 15 3 1984"
64+
},
65+
errorMessage: {
66+
text: dateOfBirthError
67+
} if dateOfBirthError,
68+
items: [
69+
{
70+
name: "day",
71+
classes: "nhsuk-input--width-2 " + ("nhsuk-input--error" if dateOfBirthError else ""),
72+
value: data.dateOfBirth.day
73+
},
74+
{
75+
name: "month",
76+
classes: "nhsuk-input--width-2 " + ("nhsuk-input--error" if dateOfBirthError else ""),
77+
value: data.dateOfBirth.month
78+
},
79+
{
80+
name: "year",
81+
classes: "nhsuk-input--width-4 " + ("nhsuk-input--error" if dateOfBirthError else ""),
82+
value: data.dateOfBirth.year
83+
}
84+
]
85+
}) }}
86+
87+
{{ input({
88+
label: {
89+
text: "Postcode"
90+
},
91+
id: "postcode",
92+
name: "postcode",
93+
value: data.postcode,
94+
classes: "nhsuk-input--width-10",
95+
errorMessage: {
96+
text: postcodeError
97+
} if postcodeError
98+
}) }}
99+
100+
{{ details({
101+
text: "If the patient is homeless",
102+
HTML: "
103+
<p>Enter the postcode ZZ99 3VZ </p>
104+
105+
"
106+
}) }}
107+
108+
{{ radios({
109+
idPrefix: "gender",
110+
name: "gender",
111+
value: data.gender,
112+
fieldset: {
113+
legend: {
114+
text: "Gender"
115+
}
116+
},
117+
errorMessage: {
118+
text: genderError
119+
} if genderError,
120+
items: [
121+
{
122+
value: "Male",
123+
text: "Male",
124+
checked: (data.gender === "Male")
125+
},
126+
{
127+
value: "Female",
128+
text: "Female",
129+
checked: (data.gender === "Female")
130+
},
131+
{
132+
value: "Other",
133+
text: "Other",
134+
checked: (data.gender === "Other")
135+
},
136+
{
137+
value: "Unknown",
138+
text: "Unknown",
139+
checked: (data.gender === "Unknown")
140+
}
141+
]
142+
}) }}
143+
144+
145+
{{ button({
146+
text: "Continue to vaccinate"
147+
}) }}
148+
</form>
149+
150+
151+
152+
</div>
153+
</div>
154+
155+
{% endblock %}
156+

0 commit comments

Comments
 (0)