Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/filters/nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const join = (input, delimiter = '', attribute = null, options = {}) => {
* @param {string} userId - ID of the user
* @param {object} [options] - Display options
* @param {boolean} [options.identifyCurrentUser] - Whether to add "(you)" for current user
* @param {boolean} [options.useYou] - Return just "you" for the current user
* @param {string} [options.format] - Name format: 'full', 'short', or 'initial'
* @returns {string} User's name in requested format
*/
Expand Down Expand Up @@ -126,8 +127,13 @@ const getUsername = function (userId, options = {}) {
}

const currentUser = this.ctx.data.currentUser
if (options.identifyCurrentUser && user.id === currentUser.id) {
return `${formattedName} (you)`
if (currentUser && user.id === currentUser.id) {
if (options.useYou) {
return 'you'
}
if (options.identifyCurrentUser) {
return `${formattedName} (you)`
}
}

return formattedName
Expand Down
11 changes: 9 additions & 2 deletions app/lib/generators/medical-information/symptoms-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ const generateSymptom = (options = {}) => {
symptom.isSignificant = Math.random() < 0.1
}

// Some symptoms are signs noted by the mammographer rather than reported
// by the participant. Breast pain is excluded as it cannot be observed.
if (type !== 'Breast pain' && Math.random() < 0.2) {
symptom.isMammographerObserved = true
}

// Add user who added the symptom
if (options.addedByUserId) {
symptom.addedByUserId = options.addedByUserId
Expand Down Expand Up @@ -335,8 +341,9 @@ const generateSymptom = (options = {}) => {
}
}

// 20% chance of symptom notes
if (Math.random() < 0.2) {
// 20% chance of symptom notes - skipped for mammographer-noted signs as
// the note options are all participant-reported
if (!symptom.isMammographerObserved && Math.random() < 0.2) {
const symptomNotesOptions = [
'Noticed during self-examination',
'Partner noticed the change',
Expand Down
18 changes: 13 additions & 5 deletions app/lib/utils/medical-information.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// app/lib/utils/medical-information.js

const medicalHistoryTypes = require('../../data/medical-history-types')
const { startLowerCase } = require('./strings')

/**
* Check whether a string names a medical history type, by type or slug
Expand Down Expand Up @@ -287,31 +288,33 @@ const countMedicalHistoryItems = (medicalHistory) => {
/**
* Summarise a single symptom into a concise string
*
* Output is lowercase - run through the sentenceCase filter when displaying
*
* @param {Object} symptom - The symptom object
* @returns {string} A summary string like "Lump (right breast)" or "Nipple change: bloody discharge (both nipples)"
* @returns {string} A summary string like "lump (right breast)" or "nipple change: bloody discharge (both nipples)"
*/
const summariseSymptom = (symptom) => {
if (!symptom || !symptom.type) {
return ''
}

let summary = symptom.type
let summary = startLowerCase(symptom.type)

// Add sub-type details for specific symptom types
if (symptom.type === 'Nipple change' && symptom.nippleChangeType) {
const changeType =
symptom.nippleChangeType === 'other' && symptom.nippleChangeDescription
? symptom.nippleChangeDescription
: symptom.nippleChangeType
summary += `: ${changeType}`
summary += `, ${changeType}`
} else if (symptom.type === 'Skin change' && symptom.skinChangeType) {
const changeType =
symptom.skinChangeType === 'other' && symptom.skinChangeDescription
? symptom.skinChangeDescription
: symptom.skinChangeType
summary += `: ${changeType}`
summary += `, ${changeType}`
} else if (symptom.type === 'Other' && symptom.otherDescription) {
summary = symptom.otherDescription
summary = startLowerCase(symptom.otherDescription)
}

// Add location
Expand Down Expand Up @@ -353,6 +356,11 @@ const summariseSymptom = (symptom) => {
summary += ` (${location})`
}

// Flag signs noted by the mammographer rather than reported by the participant
if (symptom.isMammographerObserved) {
summary = `sign: ${summary}`
}

return summary
}

Expand Down
11 changes: 10 additions & 1 deletion app/routes/appointments/symptoms.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,12 @@ module.exports = (router) => {
symptomNotes: symptomTemp.symptomNotes
}

// For new symptoms, add the creation timestamp
// For new symptoms, record when and who added them
if (isNewSymptom) {
symptom.dateAdded = new Date().toISOString()
symptom.addedByUserId = data.currentUser?.id
} else {
symptom.addedByUserId = symptomTemp.addedByUserId
}

if (symptomTypeConfig) {
Expand Down Expand Up @@ -266,6 +269,12 @@ module.exports = (router) => {
symptom.isIntermittent = true
}

// Sign noted by the mammographer rather than reported by the participant
const observedValue = symptomTemp.isMammographerObserved
symptom.isMammographerObserved = Array.isArray(observedValue)
? observedValue.includes('yes')
: observedValue === 'yes' || observedValue === true

symptom.hasStopped =
Array.isArray(symptomTemp.hasStopped) &&
symptomTemp.hasStopped.includes('yes')
Expand Down
2 changes: 1 addition & 1 deletion app/views/_includes/medical-information/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
{# -------------------------------------------------------------- #}
{# Symptoms #}
{% set sectionHeading = "Symptoms" %}
{% set subHeading = "Any problems or symptoms, including lumps, swelling, rashes or nipple changes" %}
{% set subHeading = "Any signs or symptoms, including lumps, swelling, rashes or nipple changes" %}
{% set sectionId = sectionHeading | kebabCase %}
{% set scrollTo = sectionId %}

Expand Down
4 changes: 2 additions & 2 deletions app/views/_includes/summary-lists/medical-info-summary.njk
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
{% if symptomsCount == 0 %}
<p>No symptoms added</p>
{% elif symptomsCount == 1 %}
<p>{{ symptomSummaries[0] }}</p>
<p>{{ symptomSummaries[0] | sentenceCase }}</p>
{% else %}
<ul class="nhsuk-list">
{% for summary in symptomSummaries %}
<li>{{ summary }}</li>
<li>{{ summary | sentenceCase }}</li>
{% endfor %}
</ul>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
{# Build the value (right column) - all supporting details #}
{% set valueLines = [] %}

{# Sign noted by the mammographer rather than reported by the participant #}
{% if symptom.isMammographerObserved %}
{% set notedByName = (symptom.addedByUserId | getUsername({ format: "short", useYou: true })) or "mammographer" %}
{% set valueLines = valueLines | push("Sign noted by " + notedByName) %}
{% endif %}

{# Add sub-type as first line with appropriate descriptor #}
{% if symptom.type == "Nipple change" and symptom.nippleChangeType %}
{% if symptom.nippleChangeType == "other" and symptom.nippleChangeDescription %}
Expand Down
2 changes: 1 addition & 1 deletion app/views/_includes/workflow/workflow-side-navigation.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% set workflowSteps = [
{ id: 'confirm-identity', label: 'Confirm identity' },
{ id: 'review-medical-information', label: 'Review medical information' },
{ id: 'take-images', label: 'Take images' },
{ id: 'take-images', label: 'Take mammogram images' },
{ id: 'check-information', label: 'Check information' }
] %}

Expand Down
2 changes: 1 addition & 1 deletion app/views/appointments/images-before-mammography.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% extends 'layout-appointment.html' %}


{% set pageHeading = "Awaiting images" %}
{% set pageHeading = "Take mammogram images" %}
{% set showNavigation = true %}
{% set activeWorkflowStep = 'take-images' %}
{% set hideBackLink = true %}
Expand Down
2 changes: 1 addition & 1 deletion app/views/appointments/images-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% set hideBackLink = true %}
{% set activeWorkflowStep = 'take-images' %}

{% set pageHeading = "Manually record image information" %}
{% set pageHeading = "Take mammogram images" %}

{% set gridColumn = "nhsuk-grid-column-two-thirds" %}

Expand Down
19 changes: 19 additions & 0 deletions app/views/appointments/medical-information/symptoms/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ <h1 class="nhsuk-heading-l">

{% endif %}

{# Whether this is a sign noted by the mammographer rather than a symptom reported by the participant #}
{{ checkboxes({
idPrefix: "isMammographerObserved",
name: "appointment[symptomTemp][isMammographerObserved]",
fieldset: {
legend: {
text: "Clinical sign",
size: "m"
}
},
items: [
{
value: "yes",
text: "Mammographer-noted sign",
checked: true if appointment.symptomTemp.isMammographerObserved else false
}
]
}) }}

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-one-half">

Expand Down