Skip to content

Commit 24a2b8a

Browse files
2 dec 2025 bugfixes (#206)
* Default standard views on manual details * Remove buttons which don't allow multiple * Use referrers to return to the page we were on and persist flash messages
1 parent fcc2406 commit 24a2b8a

File tree

5 files changed

+65
-37
lines changed

5 files changed

+65
-37
lines changed

app/routes/events.js

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,15 @@ module.exports = (router) => {
286286
// Event within clinic context
287287
router.get('/clinics/:clinicId/events/:eventId', (req, res) => {
288288
const { clinicId, eventId } = req.params
289-
// res.render('events/show', {
290-
// })
291-
res.redirect(`/clinics/${clinicId}/events/${eventId}/appointment`)
289+
290+
// Preserve query parameters when redirecting
291+
const queryString = Object.keys(req.query).length
292+
? '?' + new URLSearchParams(req.query).toString()
293+
: ''
294+
295+
res.redirect(
296+
`/clinics/${clinicId}/events/${eventId}/appointment${queryString}`
297+
)
292298
})
293299

294300
router.post(
@@ -2699,7 +2705,12 @@ module.exports = (router) => {
26992705
req.flash('success', 'Appointment cancellation undone')
27002706
}
27012707

2702-
res.redirect(`/clinics/${clinicId}/events/${eventId}`)
2708+
// Use referrer system to return to originating page
2709+
const returnUrl = getReturnUrl(
2710+
`/clinics/${clinicId}/events/${eventId}/appointment`,
2711+
req.query.referrerChain
2712+
)
2713+
res.redirect(returnUrl)
27032714
})
27042715

27052716
// Handle undo reschedule appointment
@@ -2724,33 +2735,48 @@ module.exports = (router) => {
27242735
req.flash('success', 'Reschedule request undone')
27252736
}
27262737

2727-
res.redirect(`/clinics/${clinicId}/events/${eventId}`)
2738+
// Use referrer system to return to originating page
2739+
const returnUrl = getReturnUrl(
2740+
`/clinics/${clinicId}/events/${eventId}/appointment`,
2741+
req.query.referrerChain
2742+
)
2743+
res.redirect(returnUrl)
27282744
}
27292745
)
27302746

27312747
// Handle undo check in
2732-
router.get(
2733-
'/clinics/:clinicId/events/:eventId/undo-check-in',
2734-
(req, res) => {
2735-
const { clinicId, eventId } = req.params
2736-
const data = req.session.data
2737-
const event = getEvent(data, eventId)
2748+
router.get('/clinics/:clinicId/events/:eventId/undo-check-in', (req, res) => {
2749+
const { clinicId, eventId } = req.params
2750+
const data = req.session.data
2751+
const event = getEvent(data, eventId)
27382752

2739-
if (event && event.status === 'event_checked_in') {
2740-
const participantName = getFullName(data.participant)
2753+
if (event && event.status === 'event_checked_in') {
2754+
const participantName = getFullName(data.participant)
27412755

2742-
// Save changes
2743-
saveTempEventToEvent(data)
2756+
// Save changes
2757+
saveTempEventToEvent(data)
27442758

2745-
// Revert to scheduled status
2746-
updateEventStatus(data, eventId, 'event_scheduled')
2759+
// Revert to scheduled status
2760+
updateEventStatus(data, eventId, 'event_scheduled')
27472761

2748-
req.flash('success', `${participantName} is no longer checked in for their appointment`)
2749-
2750-
return res.redirect(`/clinics/${clinicId}`)
2751-
}
2762+
req.flash(
2763+
'success',
2764+
`${participantName} is no longer checked in for their appointment`
2765+
)
27522766

2753-
res.redirect(`/clinics/${clinicId}/events/${eventId}`)
2767+
// Use referrer system to return to originating page
2768+
const returnUrl = getReturnUrl(
2769+
`/clinics/${clinicId}`,
2770+
req.query.referrerChain
2771+
)
2772+
return res.redirect(returnUrl)
27542773
}
2755-
)
2756-
}
2774+
2775+
// Use referrer system for fallback too
2776+
const returnUrl = getReturnUrl(
2777+
`/clinics/${clinicId}/events/${eventId}/appointment`,
2778+
req.query.referrerChain
2779+
)
2780+
res.redirect(returnUrl)
2781+
})
2782+
}

app/views/_includes/medical-information/medical-history/index.njk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,17 @@
608608

609609
<div class="nhsuk-button-group app-button-group--small">
610610
{% for typeData in data.medicalHistoryTypes %}
611-
{# {% if typeData.canHaveMultiple %} #}
611+
{% set existingItems = data.event.medicalInformation.medicalHistory[typeData.type] %}
612+
{% set hasExistingItem = existingItems and existingItems | length > 0 %}
613+
{% set canAdd = typeData.canHaveMultiple or not hasExistingItem %}
614+
615+
{% if canAdd %}
612616
{{ button({
613617
text: typeData.name,
614618
href: contextUrl + "/medical-information/medical-history/" + typeData.slug + "/add" | urlWithReferrer(referrerChain | appendReferrer(currentUrl), scrollTo),
615619
classes: "nhsuk-button--secondary app-button--small"
616620
}) }}
617-
{# {% endif %} #}
621+
{% endif %}
618622

619623
{% endfor %}
620624
</div>

app/views/events/appointment.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,19 @@
175175
actions: {
176176
items: [
177177
{
178-
href: "./undo-cancel",
178+
href: "./undo-cancel" | urlWithReferrer(currentUrl),
179179
text: "Undo cancel appointment",
180180
visuallyHiddenText: "appointment"
181181
}
182182
] if event.status == "event_cancelled" else ([
183183
{
184-
href: "./undo-reschedule",
184+
href: "./undo-reschedule" | urlWithReferrer(currentUrl),
185185
text: "Undo reschedule request",
186186
visuallyHiddenText: "appointment"
187187
}
188188
] if event.status == "event_rescheduled" else ([
189189
{
190-
href: "./undo-check-in",
190+
href: "./undo-check-in" | urlWithReferrer(currentUrl),
191191
text: "Undo check in",
192192
visuallyHiddenText: "appointment"
193193
}

app/views/events/cancel-or-reschedule-appointment/details.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
{% block pageContent %}
1010

11-
{% set unit = data.breastScreeningUnits | findById(clinic.breastScreeningUnitId) %}
12-
1311
<h1 class="nhsuk-heading-l">
1412
<span class="nhsuk-caption-l">
1513
{{ participant | getFullName }}

app/views/events/images-manual-details.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ <h1>{{ pageHeading }}</h1>
2727
{% set mammogramTemp = event.mammogramDataTemp or {} %}
2828
{% set mammogramViews = event.mammogramData.views or {} %}
2929

30-
{% set viewsRightBreastCCCount = mammogramTemp.viewsRightBreastCCCount or mammogramViews.rightCraniocaudal.count or "" %}
31-
{% set viewsRightBreastMLOCount = mammogramTemp.viewsRightBreastMLOCount or mammogramViews.rightMediolateralOblique.count or "" %}
32-
{% set viewsRightBreastEklundCount = mammogramTemp.viewsRightBreastEklundCount or mammogramViews.rightEklund.count or "" %}
33-
{% set viewsLeftBreastCCCount = mammogramTemp.viewsLeftBreastCCCount or mammogramViews.leftCraniocaudal.count or "" %}
34-
{% set viewsLeftBreastMLOCount = mammogramTemp.viewsLeftBreastMLOCount or mammogramViews.leftMediolateralOblique.count or "" %}
35-
{% set viewsLeftBreastEklundCount = mammogramTemp.viewsLeftBreastEklundCount or mammogramViews.leftEklund.count or "" %}
30+
{% set viewsRightBreastCCCount = mammogramTemp.viewsRightBreastCCCount or mammogramViews.rightCraniocaudal.count or "1" %}
31+
{% set viewsRightBreastMLOCount = mammogramTemp.viewsRightBreastMLOCount or mammogramViews.rightMediolateralOblique.count or "1" %}
32+
{% set viewsRightBreastEklundCount = mammogramTemp.viewsRightBreastEklundCount or mammogramViews.rightEklund.count or "0" %}
33+
{% set viewsLeftBreastCCCount = mammogramTemp.viewsLeftBreastCCCount or mammogramViews.leftCraniocaudal.count or "1" %}
34+
{% set viewsLeftBreastMLOCount = mammogramTemp.viewsLeftBreastMLOCount or mammogramViews.leftMediolateralOblique.count or "1" %}
35+
{% set viewsLeftBreastEklundCount = mammogramTemp.viewsLeftBreastEklundCount or mammogramViews.leftEklund.count or "0" %}
3636
{% set additionalDetails = mammogramTemp.additionalDetails or event.mammogramData.additionalDetails or "" %}
3737

3838
{# Set mammogramSource for partial mammography question - prefer temp data, fall back to final data #}

0 commit comments

Comments
 (0)