Skip to content
Open
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
31 changes: 31 additions & 0 deletions app/routes/appointments/medical-information.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,37 @@ module.exports = (router) => {
}
)

// Save pregnancy/breastfeeding from modal form
router.post(
'/clinics/:clinicId/appointments/:appointmentId/medical-information/pregnancy-and-breastfeeding-save',
(req, res) => {
const { clinicId, appointmentId } = req.params
const data = req.session.data

const postedFactors = req.body?.breastDensityFactors
const factors = (
Array.isArray(postedFactors)
? postedFactors
: postedFactors
? [postedFactors]
: []
).filter((factor) => factor && factor !== '_unchecked')

if (data.appointment?.id !== appointmentId) {
res.status(409).send()
return
}

const medicalInformation = data.appointment.medicalInformation || {}
medicalInformation.breastDensityFactors = factors
data.appointment.medicalInformation = medicalInformation

delete data.breastDensityFactors

res.redirect(modalBreakout(`/clinics/${clinicId}/appointments/${appointmentId}/review-medical-information`))
}
)

// Save breast features (includes converting JSON string to structured data)
router.post(
'/clinics/:clinicId/appointments/:appointmentId/medical-information/record-breast-features/save',
Expand Down
17 changes: 9 additions & 8 deletions app/views/_includes/forms/breast-density-factors.njk
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,16 @@
value: {
html: hrtInputHtml if allowEdits else hrtSummaryHtml
}
},
{
key: {
text: "Pregnant or breastfeeding"
},
value: {
html: pregnantOrBreastfeedingInputHtml if allowEdits else pregnantOrBreastfeedingSummaryHtml
}
}
]
} | removeLastRowBorder ) }}

<p class="nhsuk-u-margin-top-4">
{{ button({
text: "Add pregnancy and breastfeeding",
href: contextUrl + "/medical-information/pregnancy-and-breastfeeding",
variant: "secondary",
small: true
} | openInModal) }}
</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{# app/views/appointments/medical-information/pregnancy-and-breastfeeding.html #}

{% extends parentLayout or 'layout-appointment.html' %}

{% set pageHeading = "Pregnancy and breastfeeding" %}
{% set formAction = "./pregnancy-and-breastfeeding-save" %}

{% block pageContent %}

{% set breastDensityFactors = appointment.medicalInformation | getBreastDensityFactors %}

<h1 class="nhsuk-heading-l">{{ pageHeading }}</h1>

{{ checkboxes({
name: "breastDensityFactors",
values: breastDensityFactors.factors,
classes: "nhsuk-checkboxes--small",
fieldset: {
legend: {
text: "Is " + participant.demographicInformation.firstName + " pregnant or breastfeeding?",
classes: "nhsuk-fieldset__legend--s"
}
},
items: [
{
value: "pregnant",
text: "Pregnant"
},
{
value: "breastfeeding",
text: "Breastfeeding"
}
]
}) }}

{{ button({
text: "Save"
}) }}

{% endblock %}