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": 'Lump
Highlight to image readers', + }, + "value": { + "html": "Left breast
Not sure
Symptom is intermittent
Stopped: resolved date
Not investigated
Additional information: abc", + }, + }, + { + "key": { + "html": 'Other
Highlight to image readers' + }, + "value": { + "html": "Description: abc
Right breast
Less than 3 months ago
Not investigated" + }, + }, + { + "key": {"text": "Other"}, + "value": { + "html": "Description: xyz
Left breast
Less than 3 months ago
Not investigated" + }, + }, + { + "key": { + "html": 'Swelling or shape change
Highlight to image readers', + }, + "value": { + "html": "Both breasts
Less than 3 months ago
Not investigated", + }, + }, + ] + + def test_significant_symptom_rows(self): + appointment = AppointmentFactory.create() + self._create_default_symptoms(appointment) + + presenter = MedicalInformationPresenter(appointment) + + assert presenter.significant_symptom_rows == [ + { + "key": { + "html": 'Lump
Highlight to image readers', + }, + "value": { + "html": "Left breast
Not sure
Symptom is intermittent
Stopped: resolved date
Not investigated
Additional information: abc", + }, + }, + { + "key": { + "html": 'Other
Highlight to image readers' + }, + "value": { + "html": "Description: abc
Right breast
Less than 3 months ago
Not investigated" + }, + }, + { + "key": { + "html": 'Swelling or shape change
Highlight to image readers', + }, + "value": { + "html": "Both breasts
Less than 3 months ago
Not investigated", + }, + }, + ] + def test_add_lump_button(self): appointment = AppointmentFactory() diff --git a/manage_breast_screening/reading/jinja2/read_image.jinja b/manage_breast_screening/reading/jinja2/read_image.jinja index e0d7aeba4..88e821195 100644 --- a/manage_breast_screening/reading/jinja2/read_image.jinja +++ b/manage_breast_screening/reading/jinja2/read_image.jinja @@ -3,7 +3,9 @@ {% from "nhsuk/components/inset-text/macro.jinja" import insetText %} {% from "nhsuk/components/summary-list/macro.jinja" import summaryList %} {% 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 #} @@ -56,6 +58,13 @@ + {% if medical_information_presenter.significant_symptom_rows %} + {{ warningCallout({ + "heading": "Significant symptoms reported", + "html": symptoms_content(medical_information_presenter, significant_only=True, read_only=True), + }) }} + {% endif %} +

Image thumbnails ({{ images | length }})

@@ -112,7 +121,7 @@ }) }} {% endif %} - {{ medical_summary_card(presented_medical_information) }} + {{ medical_summary_card(check_medical_information_presenter) }}
{% endblock %} diff --git a/manage_breast_screening/reading/views.py b/manage_breast_screening/reading/views.py index 682a1cad7..530d6455f 100644 --- a/manage_breast_screening/reading/views.py +++ b/manage_breast_screening/reading/views.py @@ -10,6 +10,9 @@ from manage_breast_screening.mammograms.presenters.medical_history.check_medical_information_presenter import ( CheckMedicalInformationPresenter, ) +from manage_breast_screening.mammograms.presenters.medical_information_presenter import ( + MedicalInformationPresenter, +) from manage_breast_screening.participants.models import Appointment logger = getLogger(__name__) @@ -39,7 +42,10 @@ def get_context_data(self, **kwargs): "heading": participant.full_name, "caption": "Review images", "images": images, - "presented_medical_information": CheckMedicalInformationPresenter( + "check_medical_information_presenter": CheckMedicalInformationPresenter( + appointment + ), + "medical_information_presenter": MedicalInformationPresenter( appointment ), "notes_for_reader": appointment.study.additional_details, From 765b3f167432b6d663ea792ac3a9bc4dce78192d Mon Sep 17 00:00:00 2001 From: Steve Webber <198724792+swebberuk@users.noreply.github.com> Date: Wed, 29 Apr 2026 17:17:02 +0100 Subject: [PATCH 2/2] Revert changes to symptoms_content No longer use symptoms_content from read_image.jinja --- .../mammograms/medical_information/section_cards.jinja | 6 +++--- manage_breast_screening/reading/jinja2/read_image.jinja | 5 +++-- 2 files changed, 6 insertions(+), 5 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 5939b1c0a..59f567617 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, 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 %} +{% 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 %}