From 2f45d2bba04e54f9c8cec247bdd40ca6dfc3c54f Mon Sep 17 00:00:00 2001 From: rivalee Date: Mon, 17 Aug 2026 09:43:23 +0100 Subject: [PATCH 1/2] first iteration --- .../appointments/medical-information.js | 31 ++++++++++++++ .../forms/breast-density-factors.njk | 12 ++---- .../pregnancy-and-breastfeeding.html | 40 +++++++++++++++++++ 3 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 app/views/appointments/medical-information/pregnancy-and-breastfeeding.html diff --git a/app/routes/appointments/medical-information.js b/app/routes/appointments/medical-information.js index 11dd646d..143c06b1 100644 --- a/app/routes/appointments/medical-information.js +++ b/app/routes/appointments/medical-information.js @@ -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', diff --git a/app/views/_includes/forms/breast-density-factors.njk b/app/views/_includes/forms/breast-density-factors.njk index a8a211e2..ad9f40ad 100644 --- a/app/views/_includes/forms/breast-density-factors.njk +++ b/app/views/_includes/forms/breast-density-factors.njk @@ -105,15 +105,11 @@ value: { html: hrtInputHtml if allowEdits else hrtSummaryHtml } - }, - { - key: { - text: "Pregnant or breastfeeding" - }, - value: { - html: pregnantOrBreastfeedingInputHtml if allowEdits else pregnantOrBreastfeedingSummaryHtml - } } ] } | removeLastRowBorder ) }} + +

+ {{ appLink({ text: "Pregnancy and breastfeeding", href: contextUrl + "/medical-information/pregnancy-and-breastfeeding" } | openInModal) }} +

diff --git a/app/views/appointments/medical-information/pregnancy-and-breastfeeding.html b/app/views/appointments/medical-information/pregnancy-and-breastfeeding.html new file mode 100644 index 00000000..584735f1 --- /dev/null +++ b/app/views/appointments/medical-information/pregnancy-and-breastfeeding.html @@ -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 %} + +

{{ pageHeading }}

+ + {{ 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 %} From 7c9d1f6d4b7de6c12fc1ca1e4f52441d0cf54ac1 Mon Sep 17 00:00:00 2001 From: rivalee Date: Mon, 17 Aug 2026 12:31:36 +0100 Subject: [PATCH 2/2] Replace link with button --- app/views/_includes/forms/breast-density-factors.njk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/_includes/forms/breast-density-factors.njk b/app/views/_includes/forms/breast-density-factors.njk index ad9f40ad..6439655f 100644 --- a/app/views/_includes/forms/breast-density-factors.njk +++ b/app/views/_includes/forms/breast-density-factors.njk @@ -110,6 +110,11 @@ } | removeLastRowBorder ) }}

- {{ appLink({ text: "Pregnancy and breastfeeding", href: contextUrl + "/medical-information/pregnancy-and-breastfeeding" } | openInModal) }} + {{ button({ + text: "Add pregnancy and breastfeeding", + href: contextUrl + "/medical-information/pregnancy-and-breastfeeding", + variant: "secondary", + small: true + } | openInModal) }}