Skip to content

Commit 25c2539

Browse files
Update date question to be explicit about whether it's within 6 months (#210)
* Update date question to be explicit about whether it's within 6 months
1 parent a5c5604 commit 25c2539

File tree

4 files changed

+70
-45
lines changed

4 files changed

+70
-45
lines changed

app/routes/events.js

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -694,41 +694,25 @@ module.exports = (router) => {
694694
function checkIfRecentMammogram(mammogram) {
695695
if (!mammogram) return false
696696

697-
const now = dayjs()
698-
const sixMonthsAgo = now.subtract(6, 'month')
699-
700697
// Check based on date type
701-
if (mammogram.dateType === 'dateKnown' && mammogram.dateTaken) {
698+
if (mammogram.dateType === 'lessThanSixMonths') {
699+
// User explicitly indicated mammogram was less than 6 months ago
700+
return true
701+
} else if (mammogram.dateType === 'moreThanSixMonths') {
702+
// User explicitly indicated mammogram was more than 6 months ago
703+
return false
704+
} else if (mammogram.dateType === 'dateKnown' && mammogram.dateTaken) {
705+
// Calculate from exact date
706+
const now = dayjs()
707+
const sixMonthsAgo = now.subtract(6, 'month')
702708
const date = mammogram.dateTaken
709+
703710
if (date.year && date.month && date.day) {
704711
const mammogramDate = dayjs(
705712
`${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
706713
)
707714
return mammogramDate.isAfter(sixMonthsAgo)
708715
}
709-
} else if (
710-
mammogram.dateType === 'approximateDate' &&
711-
mammogram.approximateDate
712-
) {
713-
// Try to parse approximate date text
714-
const approxText = mammogram.approximateDate.toLowerCase()
715-
716-
// Check for common time patterns that would indicate recent mammogram
717-
if (
718-
approxText.includes('month ago') ||
719-
approxText.includes('1 month') ||
720-
approxText.includes('2 month') ||
721-
approxText.includes('3 month') ||
722-
approxText.includes('4 month') ||
723-
approxText.includes('5 month') ||
724-
approxText.includes('last month') ||
725-
approxText.includes('weeks ago') ||
726-
approxText.includes('few weeks') ||
727-
approxText.includes('last week') ||
728-
approxText.includes('days ago')
729-
) {
730-
return true
731-
}
732716
}
733717

734718
return false

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,18 @@
4545
{% set mammogramValueLines = mammogramValueLines | push(
4646
previousMammogram.dateTaken | formatDate + " (" + (previousMammogram.dateTaken | formatDate | formatRelativeDate | asHint) + ")"
4747
) %}
48-
{% elseif previousMammogram.dateType == 'approximateDate' %}
49-
{% set mammogramValueLines = mammogramValueLines | push("Approximate date: " + previousMammogram.approximateDate) %}
48+
{% elseif previousMammogram.dateType == 'moreThanSixMonths' %}
49+
{% set dateText = "Approximately taken 6 months or more ago" %}
50+
{% if previousMammogram.approximateDate %}
51+
{% set dateText = dateText + ": " + previousMammogram.approximateDate %}
52+
{% endif %}
53+
{% set mammogramValueLines = mammogramValueLines | push(dateText) %}
54+
{% elseif previousMammogram.dateType == 'lessThanSixMonths' %}
55+
{% set dateText = "Approximately taken less than 6 months ago" %}
56+
{% if previousMammogram.approximateDate %}
57+
{% set dateText = dateText + ": " + previousMammogram.approximateDate %}
58+
{% endif %}
59+
{% set mammogramValueLines = mammogramValueLines | push(dateText) %}
5060
{% else %}
5161
{% set mammogramValueLines = mammogramValueLines | push("Date unknown") %}
5262
{% endif %}

app/views/events/previous-mammograms/appointment-should-not-proceed.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,23 @@ <h1 class="nhsuk-heading-l">
2222
</h1>
2323

2424
{% set previousMammogram = event.previousMammogramTemp %}
25-
{% set mammogramDate = previousMammogram.dateTaken %}
26-
{% set timeAgo = mammogramDate | formatRelativeDate %}
2725

28-
<p>
29-
The mammogram added took place {{ timeAgo }}. It is not recommended to take breast x-rays within 6 months of each other.
30-
</p>
26+
{% if previousMammogram.dateType == 'dateKnown' %}
27+
{% set mammogramDate = previousMammogram.dateTaken %}
28+
{% set timeAgo = mammogramDate | formatRelativeDate %}
29+
<p>
30+
The mammogram added took place {{ timeAgo }}. Breast x-rays should not be taken within 6 months of a previous mammogram.
31+
</p>
32+
{% else %}
33+
<p>
34+
The mammogram added was less than 6 months ago. Breast x-rays should not be taken within 6 months of a previous mammogram.
35+
</p>
36+
{% if previousMammogram.approximateDate %}
37+
<p>
38+
Approximate date provided: {{ previousMammogram.approximateDate }}
39+
</p>
40+
{% endif %}
41+
{% endif %}
3142

3243
{{ radios({
3344
name: "event[appointmentStopped][needsReschedule]",

app/views/events/previous-mammograms/form.html

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,40 @@ <h1 class="nhsuk-heading-l">
166166
}) }}
167167
{% endset %}
168168

169-
{% set approximateDateHtml %}
169+
{% set moreThanSixMonthsHtml %}
170170
{{ input({
171-
id: "approximateDate",
171+
id: "approximateDateMoreThan",
172172
name: "event[previousMammogramTemp][approximateDate]",
173173
label: {
174-
text: "Enter an approximate date",
175-
classes: "nhsuk-u-visually-hidden"
174+
text: "Approximate date"
176175
},
177176
hint: {
178-
text: "For example, 9 months ago"
177+
text: "For example, April 2018 or summer 2021"
179178
},
180179
classes: "nhsuk-u-width-two-thirds",
181180
value: event.previousMammogramTemp.approximateDate
182181
}) }}
183182
{% endset %}
184183

185-
{# Radios for when were they taken - choices 'Date known' and 'Enter approximate date' and 'Not sure' #}
184+
{% set lessThanSixMonthsHtml %}
185+
<p>This appointment will need to stop and you will be prompted to reschedule once 6 months has passed.</p>
186+
187+
{{ input({
188+
id: "approximateDateLessThan",
189+
name: "event[previousMammogramTemp][approximateDate]",
190+
label: {
191+
text: "Approximate date"
192+
},
193+
hint: {
194+
text: "For example, April 2018 or summer 2021"
195+
},
196+
classes: "nhsuk-u-width-two-thirds",
197+
value: event.previousMammogramTemp.approximateDate
198+
}) }}
199+
200+
{% endset %}
201+
202+
{# Radios for when were they taken #}
186203
{{ radios({
187204
idPrefix: "dateType",
188205
name: "event[previousMammogramTemp][dateType]",
@@ -203,15 +220,18 @@ <h1 class="nhsuk-heading-l">
203220
}
204221
},
205222
{
206-
value: "approximateDate",
207-
text: "Enter an approximate date",
223+
value: "moreThanSixMonths",
224+
text: "Not sure (6 months or more ago)",
208225
conditional: {
209-
html: approximateDateHtml
226+
html: moreThanSixMonthsHtml
210227
}
211228
},
212229
{
213-
value: "notSure",
214-
text: "Not sure"
230+
value: "lessThanSixMonths",
231+
text: "Not sure (less than 6 months ago)",
232+
conditional: {
233+
html: lessThanSixMonthsHtml
234+
}
215235
}
216236
]
217237
}) }}

0 commit comments

Comments
 (0)