Skip to content

Commit b48c08a

Browse files
committed
Allow symptoms to be highlighted to image readers
Add option for breast pain and other symptoms to be highlighted to readers Display info text for symptoms that are always higlighted to readers Add highlight_to_readers column to participants_symptom Use 'Highlight to image readers' tag on medical info page
1 parent af742ad commit b48c08a

14 files changed

Lines changed: 87 additions & 23 deletions

File tree

manage_breast_screening/mammograms/forms/symptom_forms.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from manage_breast_screening.nhsuk_forms.forms import FormWithConditionalFields
2020
from manage_breast_screening.nhsuk_forms.utils import YesNo, yes_no, yes_no_field
2121
from manage_breast_screening.participants.models.symptom import (
22+
HighlightToReaderChoices,
2223
NippleChangeChoices,
2324
RelativeDateChoices,
2425
SkinChangeChoices,
@@ -80,6 +81,13 @@ class CommonFields:
8081
widget=Textarea(attrs={"rows": 5}),
8182
error_messages={"required": "Enter details of any investigations"},
8283
)
84+
highlight_to_readers = ChoiceField(
85+
choices=HighlightToReaderChoices,
86+
label="Highlight this symptom to readers?",
87+
error_messages={
88+
"required": "Select whether this symptom should be highlighted to image readers"
89+
},
90+
)
8391
additional_information = CharField(
8492
required=False,
8593
label="Additional info (optional)",
@@ -151,6 +159,9 @@ def initial_values(self, instance):
151159
"when_resolved": instance.when_resolved,
152160
"investigated": yes_no(instance.investigated),
153161
"investigation_details": instance.investigation_details,
162+
"highlight_to_readers": HighlightToReaderChoices.YES
163+
if instance.highlight_to_readers
164+
else HighlightToReaderChoices.NO,
154165
"additional_information": instance.additional_information,
155166
}
156167

@@ -184,6 +195,10 @@ def model_values(self):
184195
intermittent = self.cleaned_data.get("intermittent", False)
185196
recently_resolved = self.cleaned_data.get("recently_resolved", False)
186197
when_resolved = self.cleaned_data.get("when_resolved", "")
198+
highlight_to_readers = (
199+
self.cleaned_data.get("highlight_to_readers", HighlightToReaderChoices.YES)
200+
== HighlightToReaderChoices.YES
201+
)
187202
additional_information = self.cleaned_data.get("additional_information", "")
188203

189204
return dict(
@@ -199,6 +214,7 @@ def model_values(self):
199214
intermittent=intermittent,
200215
recently_resolved=recently_resolved,
201216
when_resolved=when_resolved,
217+
highlight_to_readers=highlight_to_readers,
202218
additional_information=additional_information,
203219
)
204220

@@ -470,6 +486,7 @@ class OtherSymptomForm(SymptomForm):
470486
when_resolved = CommonFields.when_resolved
471487
investigated = CommonFields.investigated
472488
investigation_details = CommonFields.investigation_details
489+
highlight_to_readers = CommonFields.highlight_to_readers
473490
additional_information = CommonFields.additional_information
474491

475492
def __init__(self, instance=None, **kwargs):
@@ -514,6 +531,7 @@ class BreastPainForm(SymptomForm):
514531
when_resolved = CommonFields.when_resolved
515532
investigated = CommonFields.investigated
516533
investigation_details = CommonFields.investigation_details
534+
highlight_to_readers = CommonFields.highlight_to_readers
517535
additional_information = CommonFields.additional_information
518536

519537
def __init__(self, instance=None, **kwargs):

manage_breast_screening/mammograms/jinja2/mammograms/medical_information/symptoms/forms/breast_pain.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
{{ form.investigated.as_field_group() }}
3232

33+
{{ form.highlight_to_readers.as_field_group() }}
34+
3335
{{ form.additional_information.as_field_group() }}
3436

3537
<div class="nhsuk-button-group">

manage_breast_screening/mammograms/jinja2/mammograms/medical_information/symptoms/forms/other.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
{{ form.investigated.as_field_group() }}
3434

35+
{{ form.highlight_to_readers.as_field_group() }}
36+
3537
{{ form.additional_information.as_field_group() }}
3638

3739
<div class="nhsuk-button-group">

manage_breast_screening/mammograms/presenters/symptom_presenter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,13 @@ def build_summary_list_row(self, include_actions=True):
139139
]
140140
)
141141

142+
if self._symptom.highlight_to_readers:
143+
tag = '<strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>'
144+
key = {"html": mark_safe(f"{escape(self._symptom.symptom_type.name)}{tag}")}
145+
else:
146+
key = {"text": self._symptom.symptom_type.name}
142147
result = {
143-
"key": {"text": self._symptom.symptom_type.name},
148+
"key": key,
144149
"value": {"html": html},
145150
}
146151

manage_breast_screening/mammograms/tests/forms/test_symptom_forms.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
)
2020
from manage_breast_screening.nhsuk_forms.choices import YesNo
2121
from manage_breast_screening.participants.models.symptom import (
22+
HighlightToReaderChoices,
2223
NippleChangeChoices,
2324
SkinChangeChoices,
2425
SymptomAreas,
@@ -588,6 +589,7 @@ def test_valid_form(self):
588589
"symptom_sub_type": SkinChangeChoices.COLOUR_CHANGE,
589590
"when_started": RelativeDateChoices.LESS_THAN_THREE_MONTHS,
590591
"investigated": YesNo.NO,
592+
"highlight_to_readers": HighlightToReaderChoices.YES,
591593
}
592594
)
593595
)
@@ -603,6 +605,9 @@ def test_missing_required_fields(self):
603605
"symptom_sub_type_details": ["Enter a description of the symptom"],
604606
"investigated": ["Select whether the symptom has been investigated or not"],
605607
"area": ["Select the location of the symptom"],
608+
"highlight_to_readers": [
609+
"Select whether this symptom should be highlighted to image readers"
610+
],
606611
}
607612

608613
def test_missing_conditionally_required_fields(self):
@@ -614,6 +619,7 @@ def test_missing_conditionally_required_fields(self):
614619
"symptom_sub_type_details": "abc symptom",
615620
"when_started": RelativeDateChoices.SINCE_A_SPECIFIC_DATE,
616621
"investigated": YesNo.YES,
622+
"highlight_to_readers": HighlightToReaderChoices.YES,
617623
}
618624
)
619625
)
@@ -641,6 +647,7 @@ def test_valid_form_with_conditionally_required_fields(self):
641647
"specific_date_0": "2",
642648
"specific_date_1": "2025",
643649
"investigation_details": "def",
650+
"highlight_to_readers": HighlightToReaderChoices.YES,
644651
}
645652
)
646653
)
@@ -658,6 +665,7 @@ def test_valid_form(self):
658665
"area_description_left_breast": "uoq",
659666
"when_started": RelativeDateChoices.LESS_THAN_THREE_MONTHS,
660667
"investigated": YesNo.NO,
668+
"highlight_to_readers": HighlightToReaderChoices.YES,
661669
}
662670
)
663671
)
@@ -672,6 +680,9 @@ def test_missing_required_fields(self):
672680
"when_started": ["Select how long the symptom has existed"],
673681
"investigated": ["Select whether the symptom has been investigated or not"],
674682
"area": ["Select the location of the pain"],
683+
"highlight_to_readers": [
684+
"Select whether this symptom should be highlighted to image readers"
685+
],
675686
}
676687

677688
def test_missing_conditionally_required_fields(self):
@@ -683,6 +694,7 @@ def test_missing_conditionally_required_fields(self):
683694
"when_started": RelativeDateChoices.SINCE_A_SPECIFIC_DATE,
684695
"investigated": YesNo.YES,
685696
"recently_resolved": True,
697+
"highlight_to_readers": HighlightToReaderChoices.YES,
686698
}
687699
)
688700
)
@@ -712,6 +724,7 @@ def test_valid_form_with_conditionally_required_fields(self):
712724
"investigation_details": "def",
713725
"recently_resolved": True,
714726
"when_resolved": "3 months ago",
727+
"highlight_to_readers": HighlightToReaderChoices.YES,
715728
}
716729
)
717730
)

manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_formats_symptoms_summary_list(self):
6666
],
6767
},
6868
"key": {
69-
"text": "Lump",
69+
"html": 'Lump<strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
7070
},
7171
"value": {
7272
"html": "Left breast<br>Not sure<br>Symptom is intermittent<br>Stopped: resolved date<br>Not investigated<br>Additional information: abc",
@@ -84,7 +84,7 @@ def test_formats_symptoms_summary_list(self):
8484
],
8585
},
8686
"key": {
87-
"text": "Swelling or shape change",
87+
"html": 'Swelling or shape change<strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
8888
},
8989
"value": {
9090
"html": "Both breasts<br>Less than 3 months ago<br>Not investigated",

manage_breast_screening/mammograms/tests/presenters/test_symptom_presenter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_formats_for_summary_list(self):
159159
],
160160
},
161161
"key": {
162-
"text": "Lump",
162+
"html": 'Lump<strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
163163
},
164164
"value": {
165165
"html": "Left breast<br>Not sure<br>Symptom is intermittent<br>Stopped: resolved date<br>Not investigated<br>Additional information: abc",

manage_breast_screening/mammograms/tests/views/test_symptom_views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from manage_breast_screening.nhsuk_forms.choices import YesNo
77
from manage_breast_screening.participants.models.symptom import (
8+
HighlightToReaderChoices,
89
NippleChangeChoices,
910
RelativeDateChoices,
1011
SkinChangeChoices,
@@ -409,6 +410,7 @@ def test_valid_post_redirects_to_appointment(
409410
"symptom_sub_type_details": "abc",
410411
"when_started": RelativeDateChoices.LESS_THAN_THREE_MONTHS.value,
411412
"investigated": YesNo.NO.value,
413+
"highlight_to_readers": HighlightToReaderChoices.YES.value,
412414
},
413415
)
414416
assertRedirects(
@@ -457,6 +459,7 @@ def test_valid_post_redirects_to_appointment(
457459
"symptom_sub_type_details": "abc",
458460
"when_started": RelativeDateChoices.LESS_THAN_THREE_MONTHS.value,
459461
"investigated": YesNo.NO.value,
462+
"highlight_to_readers": HighlightToReaderChoices.YES.value,
460463
},
461464
)
462465
assertRedirects(
@@ -494,6 +497,7 @@ def test_valid_post_redirects_to_appointment(
494497
"area_description_right_breast": "uiq",
495498
"when_started": RelativeDateChoices.LESS_THAN_THREE_MONTHS.value,
496499
"investigated": YesNo.NO.value,
500+
"highlight_to_readers": HighlightToReaderChoices.YES.value,
497501
},
498502
)
499503
assertRedirects(
@@ -542,6 +546,7 @@ def test_valid_post_redirects_to_appointment(
542546
"area_description_right_breast": "uiq",
543547
"when_started": RelativeDateChoices.LESS_THAN_THREE_MONTHS.value,
544548
"investigated": YesNo.NO.value,
549+
"highlight_to_readers": HighlightToReaderChoices.YES.value,
545550
},
546551
)
547552
assertRedirects(

manage_breast_screening/mammograms/views/symptom_views.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get_back_link_params(self):
4848
}
4949

5050
def get_context_data(self, **kwargs):
51-
context = super().get_context_data()
51+
context = super().get_context_data(**kwargs)
5252

5353
participant = self.appointment.participant
5454

@@ -58,11 +58,18 @@ def get_context_data(self, **kwargs):
5858
"caption": participant.full_name,
5959
"heading": f"Details of the {self.symptom_type_name.lower()}",
6060
"page_title": f"Details of the {self.symptom_type_name.lower()}",
61+
"heading_description": self._get_heading_description(),
6162
},
6263
)
6364

6465
return context
6566

67+
def _get_heading_description(self):
68+
suffix = " a recognised symptom of breast cancer. Information recorded here will be highlighted during image reading."
69+
if self.symptom_type_name == "lump":
70+
return "Lumps are" + suffix
71+
return f"{self.symptom_type_name.capitalize()} is" + suffix
72+
6673

6774
class AddSymptomView(BaseSymptomFormView):
6875
"""
@@ -137,13 +144,6 @@ class AddSymptomLumpView(AddSymptomView):
137144
form_class = LumpForm
138145
template_name = "mammograms/medical_information/symptoms/forms/simple_symptom.jinja"
139146

140-
def get_context_data(self, **kwargs):
141-
context = super().get_context_data(**kwargs)
142-
context["heading_description"] = (
143-
"Lumps are a recognised symptom of breast cancer. Information recorded here will be highlighted during image reading."
144-
)
145-
return context
146-
147147

148148
class AddSymptomSwellingOrShapeChangeView(AddSymptomView):
149149
"""
@@ -212,13 +212,6 @@ class UpdateSymptomLumpView(UpdateSymptomView):
212212
def extra_filters(self):
213213
return {"symptom_type_id": SymptomType.LUMP}
214214

215-
def get_context_data(self, **kwargs):
216-
context = super().get_context_data(**kwargs)
217-
context["heading_description"] = (
218-
"Record whether the lump is in the left breast, right breast or both."
219-
)
220-
return context
221-
222215

223216
class UpdateSymptomSwellingOrShapeChangeView(UpdateSymptomView):
224217
"""
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 6.0.4 on 2026-04-28 11:49
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('participants', '0001_squashed_0067_participantreportedmammogram_created_by_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='symptom',
15+
name='highlight_to_readers',
16+
field=models.BooleanField(default=True),
17+
),
18+
]

0 commit comments

Comments
 (0)