Skip to content

Commit b486425

Browse files
Update partial mammography (#189)
1 parent db3161d commit b486425

File tree

9 files changed

+179
-211
lines changed

9 files changed

+179
-211
lines changed

app/data/repeat-reasons.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ module.exports = [
1111
'Equipment technical fault',
1212
'Folded skin needs smoothing',
1313
'Pectoral muscle not visualised correctly',
14-
'Nipple not in profile',
1514
'Other'
1615
]

app/lib/utils/summary-list.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ const handleSummaryListMissingInformation = (
5151
row.key.text.toLowerCase()
5252
const href = row.actions?.items?.[0]?.href || '#'
5353

54-
const endText = keyText.endsWith('note') ? '' : ' details'
54+
const endText =
55+
keyText.endsWith('note') || keyText.endsWith('details')
56+
? ''
57+
: ' details'
5558

5659
return {
5760
...row,

app/routes/events.js

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,12 +1462,16 @@ module.exports = (router) => {
14621462
const data = req.session.data
14631463
const isPartialMammography = data.event.mammogramData.isPartialMammography
14641464

1465-
if (!isPartialMammography) {
1466-
res.redirect(`/clinics/${clinicId}/events/${eventId}/imaging`)
1467-
} else {
1468-
data.event.workflowStatus['take-images'] = 'completed'
1469-
res.redirect(`/clinics/${clinicId}/events/${eventId}/review`)
1470-
}
1465+
// Check if array includes 'yes' (checkbox format) or equals 'yes' (string format from manual entry)
1466+
const hasPartialMammography = Array.isArray(isPartialMammography)
1467+
? isPartialMammography.includes('yes')
1468+
: isPartialMammography === 'yes'
1469+
1470+
// Mark the workflow step as completed regardless of partial mammography status
1471+
data.event.workflowStatus['take-images'] = 'completed'
1472+
1473+
// Redirect to review page
1474+
res.redirect(`/clinics/${clinicId}/events/${eventId}/review`)
14711475
}
14721476
)
14731477

@@ -1559,44 +1563,16 @@ module.exports = (router) => {
15591563
machineRoom: mammogramData.machineRoom,
15601564
isPartialMammography:
15611565
mammogramData.isPartialMammography === 'yes' ? ['yes'] : [],
1566+
partialMammographyReasonSelect:
1567+
mammogramData.partialMammographyReasonSelect,
1568+
partialMammographyReasonComment:
1569+
mammogramData.partialMammographyReasonComment,
1570+
partialMammographyShouldReinvite:
1571+
mammogramData.partialMammographyShouldReinvite === 'yes' ? ['yes'] : [],
15621572
additionalDetails: mammogramData.additionalDetails,
15631573
viewsRightBreast: [],
15641574
viewsLeftBreast: []
1565-
}
1566-
1567-
// Split the combined partial mammography reason back into select and comment
1568-
if (mammogramData.partialMammographyReason) {
1569-
const reason = mammogramData.partialMammographyReason
1570-
// Check if it contains a colon (meaning it was a select + comment)
1571-
if (reason.includes(':')) {
1572-
const parts = reason.split(':')
1573-
formData.partialMammographyReasonSelect = parts[0].trim()
1574-
formData.partialMammographyReasonComment = parts
1575-
.slice(1)
1576-
.join(':')
1577-
.trim()
1578-
} else {
1579-
// Could be either just select or just comment
1580-
// Check if it matches one of the predefined reasons
1581-
const predefinedReasons = [
1582-
'Exam limited due to chronic disease condition',
1583-
'Withdrew consent',
1584-
'Unable to co-operate due to limited understanding of the procedure',
1585-
'Exam limited due to implanted medical device',
1586-
'Restricted mobility - unable to attain / maintain position',
1587-
'Exam performed in a wheelchair which restricted positioning',
1588-
'Other'
1589-
]
1590-
1591-
if (predefinedReasons.includes(reason)) {
1592-
formData.partialMammographyReasonSelect = reason
1593-
} else {
1594-
formData.partialMammographyReasonComment = reason
1595-
}
1596-
}
1597-
}
1598-
1599-
// Convert views back to checkbox/input format
1575+
} // Convert views back to checkbox/input format
16001576
for (const [viewKey, viewData] of Object.entries(mammogramData.views)) {
16011577
const breastKey =
16021578
viewData.side === 'right' ? 'viewsRightBreast' : 'viewsLeftBreast'
@@ -1699,6 +1675,8 @@ module.exports = (router) => {
16991675

17001676
// Handle partial mammography reason - combine select and comment
17011677
let partialMammographyReason = null
1678+
let partialMammographyShouldReinvite = null
1679+
17021680
if (formData.isPartialMammography?.includes('yes')) {
17031681
const reasonSelect = formData.partialMammographyReasonSelect
17041682
const reasonComment = formData.partialMammographyReasonComment
@@ -1710,6 +1688,12 @@ module.exports = (router) => {
17101688
} else if (reasonComment) {
17111689
partialMammographyReason = reasonComment
17121690
}
1691+
1692+
// Convert checkbox array to string for consistency
1693+
partialMammographyShouldReinvite =
1694+
formData.partialMammographyShouldReinvite?.includes('yes')
1695+
? 'yes'
1696+
: null
17131697
}
17141698

17151699
return {
@@ -1720,6 +1704,9 @@ module.exports = (router) => {
17201704
? 'yes'
17211705
: null,
17221706
partialMammographyReason,
1707+
partialMammographyReasonSelect: formData.partialMammographyReasonSelect,
1708+
partialMammographyReasonComment: formData.partialMammographyReasonComment,
1709+
partialMammographyShouldReinvite,
17231710
additionalDetails: formData.additionalDetails,
17241711
metadata: {
17251712
totalImages,
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{# app/views/events/_includes/partial-mammography-question.njk #}
2+
3+
{#
4+
Include for partial mammography question
5+
6+
Parameters:
7+
- namePrefix: string - prefix for form field names (e.g., "event[mammogramData]" or "event[mammogramDataTemp]")
8+
- mammogramSource: object - object containing the mammogram data with values
9+
#}
10+
11+
{% set reasonHtml %}
12+
13+
{% set partialMammographyReasons = [
14+
"Exam limited due to chronic disease condition",
15+
"Withdrew consent",
16+
"Unable to co-operate due to limited understanding of the procedure",
17+
"Exam limited due to implanted medical device",
18+
"Restricted mobility - unable to attain / maintain position",
19+
"Exam performed in a wheelchair which restricted positioning",
20+
"Other (provide details below)"
21+
] %}
22+
23+
{% set selectItems = [{
24+
value: "",
25+
text: "",
26+
selected: true,
27+
disabled: true,
28+
attributes: {
29+
style: "display:none;"
30+
}
31+
}] %}
32+
33+
{% for item in partialMammographyReasons %}
34+
{% set selectItem = {
35+
value: item,
36+
text: item
37+
} %}
38+
{% set selectItems = selectItems | push(selectItem) %}
39+
{% endfor %}
40+
41+
{{ select({
42+
id: "partialMammographyReasonSelect",
43+
name: namePrefix + "[partialMammographyReasonSelect]",
44+
label: {
45+
text: "Reason"
46+
},
47+
value: mammogramSource.partialMammographyReasonSelect,
48+
items: selectItems
49+
}) }}
50+
51+
{% set rescheduleFreeText %}
52+
{{ textarea({
53+
name: namePrefix + "[partialMammographyReasonComment]",
54+
value: mammogramSource.partialMammographyReasonComment,
55+
id: "partialMammographyReasonComment",
56+
label: {
57+
text: "Follow-up appointment information"
58+
},
59+
hint: {
60+
text: "Provide information to help arrange the appointment and complete the mammogram"
61+
},
62+
rows: 3
63+
}) }}
64+
{% endset %}
65+
66+
{{ checkboxes({
67+
idPrefix: "partialMammographyShouldReinvite",
68+
name: namePrefix + "[partialMammographyShouldReinvite]",
69+
values: mammogramSource.partialMammographyShouldReinvite,
70+
items: [
71+
{
72+
value: "yes",
73+
text: "Schedule another appointment to take more images",
74+
conditional: {
75+
html: rescheduleFreeText
76+
}
77+
}
78+
]
79+
}) }}
80+
81+
{% endset %}
82+
83+
{{ checkboxes({
84+
idPrefix: "isPartialMammography",
85+
name: namePrefix + "[isPartialMammography]",
86+
values: mammogramSource.isPartialMammography,
87+
fieldset: {
88+
legend: {
89+
text: "Record as partial mammography?",
90+
classes: "nhsuk-fieldset__legend--m",
91+
isPageHeading: false
92+
}
93+
},
94+
items: [
95+
{
96+
value: "yes",
97+
text: "Yes, partial mammography",
98+
conditional: {
99+
html: reasonHtml
100+
}
101+
}
102+
]
103+
}) }}

app/views/_includes/reading/opinion-ui.njk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,12 @@
167167

168168
{% endif %}
169169

170-
{% set isPartialMammography = event.mammogramData.isPartialMammography %}
171170
{% set partialMammographyHtml %}
172171
<p>
173172
<b>Partial mammography:</b> Patient was uncomfortable and asked to stop
174173
</p>
175174
{% endset %}
176-
{% if isPartialMammography %}
175+
{% if event.mammogramData.isPartialMammography == 'yes' %}
177176
<div class="nhsuk-grid-row">
178177
<div class="nhsuk-grid-column-two-thirds">
179178
{{ insetText({

app/views/_includes/summary-lists/medical-information/mammogram-image-data.njk

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
}) %}
108108

109109
{# Image counts #}
110-
{% set summaryRows = summaryRows | push({
110+
{# {% set summaryRows = summaryRows | push({
111111
key: {
112112
text: "Total images"
113113
},
@@ -116,44 +116,59 @@
116116
event.mammogramData.metadata.imagesByBreast.right + " right, " +
117117
event.mammogramData.metadata.imagesByBreast.left + " left)"
118118
}
119-
}) %}
119+
}) %} #}
120120

121-
{# Repeats and additional images #}
122-
{% if hasRepeatsOrExtras %}
121+
{# Partial mammography #}
122+
{% if event.mammogramData.isPartialMammography == 'yes' %}
123+
{% set partialMammographyHtml %}
124+
{% if event.mammogramData.partialMammographyReasonSelect %}
125+
<p class="nhsuk-u-margin-bottom-2"><strong>Reason:</strong> {{ event.mammogramData.partialMammographyReasonSelect }}</p>
126+
{% endif %}
127+
{% if event.mammogramData.partialMammographyShouldReinvite == 'yes' %}
128+
<p class="nhsuk-u-margin-bottom-2">Participant to be reinvited to complete the remaining images</p>
129+
{% endif %}
130+
{% if event.mammogramData.partialMammographyReasonComment %}
131+
<p class="nhsuk-u-margin-bottom-0"><strong>Follow-up appointment information:</strong> {{ event.mammogramData.partialMammographyReasonComment }}</p>
132+
{% endif %}
133+
{% if not event.mammogramData.partialMammographyReasonSelect and not event.mammogramData.partialMammographyReasonComment %}
134+
Yes, no reason provided
135+
{% endif %}
136+
{% endset %}
137+
123138
{% set summaryRows = summaryRows | push({
124139
key: {
125-
text: "Repeat reasons"
140+
text: "Partial mammography"
126141
},
127142
value: {
128-
html: repeatsHtml
143+
html: partialMammographyHtml
129144
},
130145
actions: {
131146
items: [
132147
{
133-
href: ("./images-manual-repeats" if isManualEntry else defaultHref) | urlWithReferrer(referrerChain, scrollTo),
148+
href: ("./images-manual-details" if isManualEntry else defaultHref) | urlWithReferrer(referrerChain, scrollTo),
134149
text: "Change",
135-
visuallyHiddenText: "repeat reasons"
150+
visuallyHiddenText: "partial mammography"
136151
}
137152
]
138153
}
139154
}) %}
140155
{% endif %}
141156

142-
{# Partial mammography #}
143-
{% if event.mammogramData.isPartialMammography == 'yes' %}
157+
{# Repeats and additional images #}
158+
{% if hasRepeatsOrExtras %}
144159
{% set summaryRows = summaryRows | push({
145160
key: {
146-
text: "Partial mammography"
161+
text: "Repeat reasons"
147162
},
148163
value: {
149-
text: event.mammogramData.partialMammographyReason or "Yes"
164+
html: repeatsHtml
150165
},
151166
actions: {
152167
items: [
153168
{
154-
href: ("./images-manual-details" if isManualEntry else defaultHref) | urlWithReferrer(referrerChain, scrollTo),
169+
href: ("./images-manual-repeats" if isManualEntry else defaultHref) | urlWithReferrer(referrerChain, scrollTo),
155170
text: "Change",
156-
visuallyHiddenText: "partial mammography"
171+
visuallyHiddenText: "repeat reasons"
157172
}
158173
]
159174
}

0 commit comments

Comments
 (0)