Skip to content

Commit 12413ac

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 highlighted to readers Add highlight_to_readers column to participants_symptom Use 'Highlight to image readers' tag on medical info page Add heading_description to skin and nipple change templates
1 parent af742ad commit 12413ac

16 files changed

Lines changed: 246 additions & 26 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/nipple_change.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
{% from "nhsuk/components/fieldset/macro.jinja" import fieldset %}
44

55
{% block form %}
6+
{% if heading_description %}
7+
<div class="nhsuk-inset-text nhsuk-u-margin-top-0 nhsuk-u-margin-bottom-4">
8+
<p>{{ heading_description }}</p>
9+
</div>
10+
{% endif %}
11+
612
{% do form.symptom_sub_type.add_conditional_html('NIPPLE_CHANGE_OTHER', form.symptom_sub_type_details.as_field_group()) %}
713

814
{% do form.when_started.add_divider_after("OVER_THREE_YEARS", "or") %}

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/jinja2/mammograms/medical_information/symptoms/forms/skin_change.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
{% from "nhsuk/components/fieldset/macro.jinja" import fieldset %}
44

55
{% block form %}
6+
{% if heading_description %}
7+
<div class="nhsuk-inset-text nhsuk-u-margin-top-0 nhsuk-u-margin-bottom-4">
8+
<p>{{ heading_description }}</p>
9+
</div>
10+
{% endif %}
11+
612
{% include "mammograms/medical_information/symptoms/forms/inline_area_radios.jinja" %}
713

814
{% do form.symptom_sub_type.add_conditional_html('SKIN_CHANGE_OTHER', form.symptom_sub_type_details.as_field_group()) %}

manage_breast_screening/mammograms/presenters/symptom_presenter.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.urls import reverse
2-
from django.utils.html import escape
2+
from django.utils.html import escape, format_html
33
from django.utils.safestring import mark_safe
44

55
from manage_breast_screening.core.template_helpers import (
@@ -139,8 +139,17 @@ def build_summary_list_row(self, include_actions=True):
139139
]
140140
)
141141

142+
if self._symptom.highlight_to_readers:
143+
key = {
144+
"html": format_html(
145+
'{}<br><strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
146+
self._symptom.symptom_type.name,
147+
)
148+
}
149+
else:
150+
key = {"text": self._symptom.symptom_type.name}
142151
result = {
143-
"key": {"text": self._symptom.symptom_type.name},
152+
"key": key,
144153
"value": {"html": html},
145154
}
146155

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: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ def test_formats_symptoms_summary_list(self):
5151
area=SymptomAreas.BOTH_BREASTS,
5252
)
5353

54+
symptom3 = SymptomFactory.create(
55+
other=True,
56+
appointment=appointment,
57+
when_started=RelativeDateChoices.LESS_THAN_THREE_MONTHS,
58+
area=SymptomAreas.RIGHT_BREAST,
59+
symptom_sub_type_details="abc",
60+
)
61+
62+
symptom4 = SymptomFactory.create(
63+
other=True,
64+
appointment=appointment,
65+
when_started=RelativeDateChoices.LESS_THAN_THREE_MONTHS,
66+
area=SymptomAreas.LEFT_BREAST,
67+
highlight_to_readers=False,
68+
symptom_sub_type_details="xyz",
69+
)
70+
5471
presenter = MedicalInformationPresenter(appointment)
5572

5673
assert presenter.symptom_rows == [
@@ -66,12 +83,46 @@ def test_formats_symptoms_summary_list(self):
6683
],
6784
},
6885
"key": {
69-
"text": "Lump",
86+
"html": 'Lump<br><strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
7087
},
7188
"value": {
7289
"html": "Left breast<br>Not sure<br>Symptom is intermittent<br>Stopped: resolved date<br>Not investigated<br>Additional information: abc",
7390
},
7491
},
92+
{
93+
"actions": {
94+
"items": [
95+
{
96+
"text": "Change",
97+
"classes": "nhsuk-link--no-visited-state",
98+
"visuallyHiddenText": "other",
99+
"href": f"/mammograms/{appointment.id}/record-medical-information/other/{symptom3.id}/",
100+
},
101+
],
102+
},
103+
"key": {
104+
"html": 'Other<br><strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>'
105+
},
106+
"value": {
107+
"html": "Description: abc<br>Right breast<br>Less than 3 months ago<br>Not investigated"
108+
},
109+
},
110+
{
111+
"actions": {
112+
"items": [
113+
{
114+
"text": "Change",
115+
"classes": "nhsuk-link--no-visited-state",
116+
"visuallyHiddenText": "other",
117+
"href": f"/mammograms/{appointment.id}/record-medical-information/other/{symptom4.id}/",
118+
}
119+
]
120+
},
121+
"key": {"text": "Other"},
122+
"value": {
123+
"html": "Description: xyz<br>Left breast<br>Less than 3 months ago<br>Not investigated"
124+
},
125+
},
75126
{
76127
"actions": {
77128
"items": [
@@ -84,7 +135,7 @@ def test_formats_symptoms_summary_list(self):
84135
],
85136
},
86137
"key": {
87-
"text": "Swelling or shape change",
138+
"html": 'Swelling or shape change<br><strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
88139
},
89140
"value": {
90141
"html": "Both breasts<br>Less than 3 months ago<br>Not investigated",

manage_breast_screening/mammograms/tests/presenters/test_symptom_presenter.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_formats_intermittent_stopped_and_additional_information(self):
135135
assert presenter.intermittent_line == "Symptom is intermittent"
136136
assert presenter.additional_information_line == "Additional information: abc"
137137

138-
def test_formats_for_summary_list(self):
138+
def test_formats_lump_for_summary_list(self):
139139
symptom = SymptomFactory.create(
140140
lump=True,
141141
when_started=RelativeDateChoices.NOT_SURE,
@@ -159,13 +159,48 @@ def test_formats_for_summary_list(self):
159159
],
160160
},
161161
"key": {
162-
"text": "Lump",
162+
"html": 'Lump<br><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",
166166
},
167167
}
168168

169+
@pytest.mark.parametrize("highlight_to_readers", [True, False])
170+
def test_formats_other_for_summary_list(self, highlight_to_readers):
171+
symptom = SymptomFactory.create(
172+
breast_pain=True,
173+
when_started=RelativeDateChoices.LESS_THAN_THREE_MONTHS,
174+
area=SymptomAreas.LEFT_BREAST,
175+
highlight_to_readers=highlight_to_readers,
176+
)
177+
178+
presenter = SymptomPresenter(symptom)
179+
180+
if highlight_to_readers:
181+
expected_key = {
182+
"html": 'Breast pain<br><strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
183+
}
184+
else:
185+
expected_key = {"text": "Breast pain"}
186+
187+
assert presenter.summary_list_row == {
188+
"actions": {
189+
"items": [
190+
{
191+
"text": "Change",
192+
"classes": "nhsuk-link--no-visited-state",
193+
"visuallyHiddenText": "breast pain",
194+
"href": f"/mammograms/{symptom.appointment_id}/record-medical-information/breast-pain/{symptom.id}/",
195+
}
196+
]
197+
},
198+
"key": expected_key,
199+
"value": {
200+
"html": "Left breast<br>Less than 3 months ago<br>Not investigated"
201+
},
202+
}
203+
169204
def test_delete_message_html(self):
170205
lump = SymptomFactory.create(lump=True)
171206
presenter = SymptomPresenter(lump)

0 commit comments

Comments
 (0)