Skip to content

Commit f98e9bc

Browse files
Highlight health answers with a yes response
1 parent 119a9a1 commit f98e9bc

8 files changed

Lines changed: 52 additions & 43 deletions

File tree

app/assets/stylesheets/components/_card.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,14 @@ $_orange-text-colour: nhsuk-shade(nhsuk-colour("warm-yellow"), 70%);
180180
}
181181
}
182182
}
183+
184+
// Ensure border colour inside warning cards can be seen and matches
185+
.nhsuk-card--warning {
186+
blockquote {
187+
border-left-color: nhsuk-colour("black");
188+
}
189+
190+
.nhsuk-summary-list__row {
191+
border-color: nhsuk-colour("yellow");
192+
}
193+
}

app/assets/stylesheets/vendor/nhsuk-frontend/overrides/_summary-list.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
@use "sass:color";
21
@use "../core" as *;
32

4-
// Ensure border colour inside warning callout can be seen and matches
5-
.nhsuk-card--warning {
6-
.nhsuk-summary-list__row {
7-
border-color: color.scale(color.mix($nhsuk-border-colour, nhsuk-colour("yellow"), 50%), $lightness: -10%);
8-
}
9-
}
10-
113
// Reduce space between summary list and button group
124
.nhsuk-summary-list:has(+ .nhsuk-button-group) {
135
@include nhsuk-responsive-margin(4, "bottom");

app/controllers/reply.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
Vaccination
1616
} from '../models.js'
1717
import { today } from '../utils/date.js'
18-
import { hasAnswersNeedingTriage } from '../utils/reply.js'
18+
import { countAnswersNeedingTriage } from '../utils/reply.js'
1919
import { formatParent } from '../utils/string.js'
2020
import {
2121
getScreenOutcomesForConsentMethod,
@@ -199,7 +199,7 @@ export const replyController = {
199199
},
200200
[`/${reply_uuid}/${type}/notify-parent`]: {},
201201
[`/${reply_uuid}/${type}/health-answers`]: {
202-
[`/${reply_uuid}/${type}/${hasAnswersNeedingTriage(request.session.data.reply?.healthAnswers) ? 'triage' : 'check-answers'}`]: true
202+
[`/${reply_uuid}/${type}/${countAnswersNeedingTriage(request.session.data.reply?.healthAnswers) ? 'triage' : 'check-answers'}`]: true
203203
},
204204
[`/${reply_uuid}/${type}/refusal-reason`]: {
205205
[`/${reply_uuid}/${type}/refusal-reason-details`]: {

app/locales/en.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,9 @@ export const en = {
881881
}
882882
},
883883
healthAnswers: {
884-
label: 'All answers to health questions'
884+
label: 'Answers to health questions',
885+
count:
886+
'Answers to health questions{count, plural, =0 {} one {, including 1 Yes response} other {, including # Yes responses}}'
885887
},
886888
healthQuestions,
887889
home: {

app/models/consent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Reply } from '../models.js'
2-
import { hasAnswersNeedingTriage } from '../utils/reply.js'
2+
import { countAnswersNeedingTriage } from '../utils/reply.js'
33
import { formatLinkWithSecondaryText } from '../utils/string.js'
44

55
/**
@@ -10,10 +10,10 @@ export class Consent extends Reply {
1010
/**
1111
* Answers in this consent response need triage
1212
*
13-
* @returns {boolean} Answers need triage
13+
* @returns {boolean} Has answers needing triage
1414
*/
1515
get hasAnswersNeedingTriage() {
16-
return hasAnswersNeedingTriage(this.healthAnswers)
16+
return countAnswersNeedingTriage(this.healthAnswers) > 0
1717
}
1818

1919
/**

app/models/patient-session.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import {
3737
import {
3838
getConsentOutcome,
3939
getConsentHealthAnswers,
40-
getConsentRefusalReasons
40+
getConsentRefusalReasons,
41+
countAnswersNeedingTriage
4142
} from '../utils/reply.js'
4243
import {
4344
getConsentOutcomeStatus,
@@ -614,6 +615,15 @@ export class PatientSession {
614615
return getConsentHealthAnswers(this)
615616
}
616617

618+
/**
619+
* At least one answer in consent health answers needs triage
620+
*
621+
* @returns {number} Number of answers needing triage
622+
*/
623+
get answersNeedingTriageCount() {
624+
return countAnswersNeedingTriage(this.consentHealthAnswers)
625+
}
626+
617627
/**
618628
* Get responses with triage notes for consent health answers
619629
*

app/utils/reply.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export const getHealthAnswers = (vaccine, healthCondition) => {
280280
* @returns {string} Triage note
281281
*/
282282
export const getTriageNote = (healthAnswers, healthCondition) => {
283-
if (hasAnswersNeedingTriage(healthAnswers)) {
283+
if (countAnswersNeedingTriage(healthAnswers)) {
284284
return healthConditions[healthCondition].triageNote
285285
}
286286
}
@@ -338,19 +338,17 @@ export const getRefusalReason = (type, decision) => {
338338
* Has health answers needing triage
339339
*
340340
* @param {object} healthAnswers - Health answers
341-
* @returns {boolean} Has health answers needing triage
341+
* @returns {number} Number of health answers needing triage
342342
*/
343-
export const hasAnswersNeedingTriage = (healthAnswers) => {
343+
export const countAnswersNeedingTriage = (healthAnswers) => {
344344
if (!healthAnswers) {
345-
return false
345+
return 0
346346
}
347347

348-
// Ignore answer to asthma question, as only its sub-questions get triaged
349-
const nonConditionalAnswers = Object.fromEntries(
350-
Object.entries(healthAnswers).filter(([key]) => key !== 'asthma')
351-
)
348+
const ignoredKeys = new Set(['asthma'])
352349

353-
return Object.values(nonConditionalAnswers).find(
354-
(answer) => answer.answer === 'Yes'
355-
)
350+
return Object.entries(healthAnswers)
351+
.filter(([key]) => !ignoredKeys.has(key))
352+
.flatMap(([, answer]) => (Array.isArray(answer) ? answer : [answer]))
353+
.filter((answer) => answer.answer === 'Yes').length
356354
}

app/views/patient-session/_consent.njk

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,17 @@
101101
}) if parent.email or parent.tel }}
102102
{% endfor %}
103103
{% endif %}
104-
105-
{# Health answers #}
106-
{% if patientSession.consentHealthAnswers %}
107-
<hr class="nhsuk-section-break nhsuk-section-break--visible nhsuk-section-break--m">
108-
109-
{{ appHeading({
110-
classes: "nhsuk-u-margin-bottom-2",
111-
level: 4,
112-
size: "s",
113-
title: __("healthAnswers.label")
114-
}) }}
115-
116-
{{ summaryList({
117-
classes: "app-summary-list--full-width",
118-
rows: healthAnswerRows(patientSession.consentHealthAnswers)
119-
}) }}
120-
{% endif %}
121104
{% endcall %}
105+
106+
{# Health answers #}
107+
{{ summaryList({
108+
card: {
109+
classes: "nhsuk-card--warning" if patientSession.answersNeedingTriageCount,
110+
heading: __mf("healthAnswers.count", {
111+
count: patientSession.answersNeedingTriageCount
112+
}),
113+
headingLevel: 3
114+
},
115+
classes: "app-summary-list--full-width",
116+
rows: healthAnswerRows(patientSession.consentHealthAnswers)
117+
}) if patientSession.consentHealthAnswers }}

0 commit comments

Comments
 (0)