From f4f94c2bc338938866fefbd1b8820089f7965afb Mon Sep 17 00:00:00 2001 From: Steve Webber <198724792+swebberuk@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:12:44 +0100 Subject: [PATCH 1/2] Show significant symptoms reported --- .../medical_information/section_cards.jinja | 6 +- .../medical_information_presenter.py | 8 ++ .../presenters/symptom_presenter.py | 1 + .../test_medical_information_presenter.py | 86 +++++++++++++++++-- .../reading/jinja2/read_image.jinja | 11 ++- manage_breast_screening/reading/views.py | 8 +- 6 files changed, 109 insertions(+), 11 deletions(-) diff --git a/manage_breast_screening/mammograms/jinja2/mammograms/medical_information/section_cards.jinja b/manage_breast_screening/mammograms/jinja2/mammograms/medical_information/section_cards.jinja index 59f567617..5939b1c0a 100644 --- a/manage_breast_screening/mammograms/jinja2/mammograms/medical_information/section_cards.jinja +++ b/manage_breast_screening/mammograms/jinja2/mammograms/medical_information/section_cards.jinja @@ -93,9 +93,9 @@ {% endif %} {% endmacro %} -{% macro symptoms_content(presented_medical_info, read_only=false) %} - {% set symptom_rows = presented_medical_info.read_only_symptom_rows if read_only else presented_medical_info.symptom_rows %} -
Any problems or symptoms, including lumps, swelling, rashes or nipple changes
+{% macro symptoms_content(presented_medical_info, read_only=false, significant_only=false) %} + {% set symptom_rows = presented_medical_info.significant_symptom_rows if significant_only else presented_medical_info.read_only_symptom_rows if read_only else presented_medical_info.symptom_rows %} + {%- if not significant_only %}Any problems or symptoms, including lumps, swelling, rashes or nipple changes
{% endif %} {% if symptom_rows %} {{ summaryList({ "rows": symptom_rows diff --git a/manage_breast_screening/mammograms/presenters/medical_information_presenter.py b/manage_breast_screening/mammograms/presenters/medical_information_presenter.py index 85d4dde8a..29a7ee451 100644 --- a/manage_breast_screening/mammograms/presenters/medical_information_presenter.py +++ b/manage_breast_screening/mammograms/presenters/medical_information_presenter.py @@ -175,6 +175,14 @@ def read_only_symptom_rows(self): for symptom in self.symptoms ] + @property + def significant_symptom_rows(self): + return [ + symptom.build_summary_list_row(include_actions=False) + for symptom in self.symptoms + if symptom.highlight_to_readers + ] + @property def symptom_buttons(self): return [ diff --git a/manage_breast_screening/mammograms/presenters/symptom_presenter.py b/manage_breast_screening/mammograms/presenters/symptom_presenter.py index 0db9e1d9a..ed4270d2f 100644 --- a/manage_breast_screening/mammograms/presenters/symptom_presenter.py +++ b/manage_breast_screening/mammograms/presenters/symptom_presenter.py @@ -19,6 +19,7 @@ class SymptomPresenter: def __init__(self, symptom): self._symptom = symptom + self.highlight_to_readers = symptom.highlight_to_readers @property def area_line(self): diff --git a/manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py b/manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py index e0b2a12ed..e03c64eb9 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py @@ -31,9 +31,7 @@ @pytest.mark.django_db class TestRecordMedicalInformationPresenter: - def test_formats_symptoms_summary_list(self): - appointment = AppointmentFactory.create() - + def _create_default_symptoms(self, appointment): symptom1 = SymptomFactory.create( lump=True, appointment=appointment, @@ -43,14 +41,12 @@ def test_formats_symptoms_summary_list(self): when_resolved="resolved date", additional_information="abc", ) - symptom2 = SymptomFactory.create( swelling_or_shape_change=True, appointment=appointment, when_started=RelativeDateChoices.LESS_THAN_THREE_MONTHS, area=SymptomAreas.BOTH_BREASTS, ) - symptom3 = SymptomFactory.create( other=True, appointment=appointment, @@ -58,7 +54,6 @@ def test_formats_symptoms_summary_list(self): area=SymptomAreas.RIGHT_BREAST, symptom_sub_type_details="abc", ) - symptom4 = SymptomFactory.create( other=True, appointment=appointment, @@ -67,6 +62,13 @@ def test_formats_symptoms_summary_list(self): highlight_to_readers=False, symptom_sub_type_details="xyz", ) + return symptom1, symptom2, symptom3, symptom4 + + def test_symptom_rows(self): + appointment = AppointmentFactory.create() + symptom1, symptom2, symptom3, symptom4 = self._create_default_symptoms( + appointment + ) presenter = MedicalInformationPresenter(appointment) @@ -143,6 +145,78 @@ def test_formats_symptoms_summary_list(self): }, ] + def test_read_only_symptom_rows(self): + appointment = AppointmentFactory.create() + self._create_default_symptoms(appointment) + + presenter = MedicalInformationPresenter(appointment) + + assert presenter.read_only_symptom_rows == [ + { + "key": { + "html": 'LumpAny problems or symptoms, including lumps, swelling, rashes or nipple changes
{% endif %} +{% macro symptoms_content(presented_medical_info, read_only=false) %} + {% set symptom_rows = presented_medical_info.read_only_symptom_rows if read_only else presented_medical_info.symptom_rows %} +Any problems or symptoms, including lumps, swelling, rashes or nipple changes
{% if symptom_rows %} {{ summaryList({ "rows": symptom_rows diff --git a/manage_breast_screening/reading/jinja2/read_image.jinja b/manage_breast_screening/reading/jinja2/read_image.jinja index 88e821195..1b4eb004a 100644 --- a/manage_breast_screening/reading/jinja2/read_image.jinja +++ b/manage_breast_screening/reading/jinja2/read_image.jinja @@ -5,7 +5,6 @@ {% from "nhsuk/components/tag/macro.jinja" import tag %} {% from "nhsuk/components/warning-callout/macro.jinja" import warningCallout %} {% from "mammograms/check_information/medical_information_card.jinja" import medical_summary_card %} -{% from "mammograms/medical_information/section_cards.jinja" import symptoms_content %} {# djlint:off H006 #} @@ -61,7 +60,9 @@ {% if medical_information_presenter.significant_symptom_rows %} {{ warningCallout({ "heading": "Significant symptoms reported", - "html": symptoms_content(medical_information_presenter, significant_only=True, read_only=True), + "html": summaryList({ + "rows": medical_information_presenter.significant_symptom_rows + }), }) }} {% endif %}