Skip to content

Commit 736a441

Browse files
Misc fixes (#167)
1 parent 37734aa commit 736a441

File tree

5 files changed

+50
-12
lines changed

5 files changed

+50
-12
lines changed

app/lib/generators/mammogram-generator.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ const generateMammogramImages = ({
185185
(sum, view) => sum + view.images.length,
186186
0
187187
)
188+
189+
// Calculate images per breast
190+
const rightBreastImages = Object.values(views)
191+
.filter((view) => view.side === 'right')
192+
.reduce((sum, view) => sum + view.images.length, 0)
193+
194+
const leftBreastImages = Object.values(views)
195+
.filter((view) => view.side === 'left')
196+
.reduce((sum, view) => sum + view.images.length, 0)
197+
188198
const allTimestamps = Object.values(views)
189199
.flatMap((view) => view.images.map((img) => img.timestamp))
190200
.sort()
@@ -202,7 +212,11 @@ const generateMammogramImages = ({
202212
standardViewsCompleted: Object.keys(views).length === 4,
203213
startTime: allTimestamps[0],
204214
endTime: allTimestamps[allTimestamps.length - 1],
205-
hasRepeat
215+
hasRepeat,
216+
imagesByBreast: {
217+
right: rightBreastImages,
218+
left: leftBreastImages
219+
}
206220
}
207221
}
208222
}

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@
2323
{% endset %}
2424

2525
{% set mammogramHistoryContentsSummary %}
26-
Last mammogrogram {{ "2022-03-23" | formatDate | formatRelativeDate | asHint }}
26+
{# Last mammogrogram {{ "2022-03-23" | formatDate | formatRelativeDate | asHint }} #}
2727
{% endset %}
2828

2929
{% set hasAdditionalMammograms = event.previousMammograms | length > 0 %}
3030

3131
{% if hasAdditionalMammograms %}
32-
{% set mammogramHistoryContentsSummary = ((event.previousMammograms | length) + 1) ~ " mammograms added" %}
32+
{% set mammogramHistoryContentsSummary = ((event.previousMammograms | length)) ~ " new " + ("mammogram" | pluralise(event.previousMammograms | length)) + " added" %}
3333
{% endif %}
3434

35+
3536
{% switch displayFormat %}
3637
{% case 'flat' %}
3738
<h2 id="{{ sectionId }}">{{ sectionHeading }}</h2>
@@ -53,7 +54,7 @@
5354
id: sectionId,
5455
classes: "nhsuk-expander js-expandable-section",
5556
summaryText: "Mammogram history",
56-
_contentsSummary: mammogramHistoryContentsSummary,
57+
contentsSummary: mammogramHistoryContentsSummary,
5758
subtitle: "The last confirmed mammogram and any added manually since then",
5859
html: mammogramHistoryHtml,
5960
status: "To review",
@@ -156,6 +157,25 @@
156157
{% include "medical-information/medical-history/index.njk" %}
157158
{% endset %}
158159

160+
{% set medicalInfoCount = 0 %}
161+
{% if event.medicalInformation.medicalHistory %}
162+
{% for type, historyGroup in event.medicalInformation.medicalHistory %}
163+
{% for item in historyGroup %}
164+
{% set medicalInfoCount = medicalInfoCount + 1 %}
165+
{% endfor %}
166+
{% endfor %}
167+
{% endif %}
168+
169+
{{ medicalInfoCount | log("Medical info count") }}
170+
171+
{% set contentsSummary %}
172+
{% if medicalInfoCount > 0 %}
173+
{{ medicalInfoCount }} {{ "item" | pluralise(medicalInfoCount) }} added
174+
{% else %}
175+
No information added
176+
{% endif %}
177+
{% endset %}
178+
159179
{% switch displayFormat %}
160180
{% case 'flat' %}
161181
<h2>{{ sectionHeading }}</h2>
@@ -174,7 +194,7 @@
174194
id: "medical-history",
175195
classes: "nhsuk-expander js-expandable-section",
176196
summaryText: sectionHeading,
177-
contentsSummary: "No information added",
197+
contentsSummary: contentsSummary,
178198
subtitle: subHeading,
179199
html: medicalHistoryHtml,
180200
status: "To review"

app/views/_templates/layout-app.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
{% if flashSuccess | isString %}
129129
{{ notificationBanner({
130130
text: flashSuccess,
131-
type: "success"
131+
type: "success",
132+
disableAutoFocus: true if disableAutoFocus else false
132133
}) }}
133134
{% else %}
134135
{% set html = flashSuccess.html %}
@@ -143,7 +144,8 @@
143144
title: flashSuccess.title,
144145
html: html,
145146
text: flashSuccess.text,
146-
type: "success"
147+
type: "success",
148+
disableAutoFocus: true if disableAutoFocus else false
147149
}) }}
148150
{% endif %}
149151
{% endif %}

app/views/events/record-medical-information.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
{% set showWorkflowNav = true %}
1717

1818
{% set activeTab = 'record-medical-information' %}
19+
{% set disableAutoFocus = true %}
1920

2021
{% block pageContent %}
2122

app/views/events/review.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
{% extends 'layout-app.html' %}
32

43

@@ -36,17 +35,19 @@
3635

3736
{% set valueHtml = "No" %}
3837

38+
{% set imageCount = event.mammogramData.metadata.totalImages %}
39+
3940
{% set imagesCardHtml %}
4041
<ul class="nhsuk-list nhsuk-list--bullet">
41-
<li>2 right breast images</li>
42-
<li>3 left breast images (one repeat)</li>
42+
<li>{{ event.mammogramData.metadata.imagesByBreast.right }} right breast {{ "image" | pluralise(event.mammogramData.metadata.imagesByBreast.right) }}</li>
43+
<li>{{ event.mammogramData.metadata.imagesByBreast.left }} left breast {{ "image" | pluralise(event.mammogramData.metadata.imagesByBreast.left) }}</li>
4344
</ul>
4445

4546
<p><a href="./imaging">View or update imaging information</a></p>
4647
{% endset %}
4748

4849
{{ card({
49-
heading: "5 images taken",
50+
heading: imageCount ~ " images taken",
5051
headingLevel: "2",
5152
feature: true,
5253
descriptionHtml: imagesCardHtml
@@ -124,4 +125,4 @@
124125

125126
{# <p><a href="./attended-not-screened-reason">Screening cannot proceed</a></p> #}
126127

127-
{% endblock %}
128+
{% endblock %}

0 commit comments

Comments
 (0)