Skip to content

Commit addf244

Browse files
committed
Only set heading_description for symptoms that use it
1 parent 194faa5 commit addf244

1 file changed

Lines changed: 53 additions & 9 deletions

File tree

manage_breast_screening/mammograms/views/symptom_views.py

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
)
2323
from .mixins import InProgressAppointmentMixin, MedicalInformationMixin
2424

25+
HEADING_DESCRIPTION_KEY = "heading_description"
26+
HEADING_DESCRIPTION_SUFFIX = " a recognised symptom of breast cancer. Information recorded here will be highlighted during image reading."
27+
2528

2629
class BaseSymptomFormView(InProgressAppointmentMixin, FormView):
2730
"""
@@ -58,18 +61,11 @@ def get_context_data(self, **kwargs):
5861
"caption": participant.full_name,
5962
"heading": f"Details of the {self.symptom_type_name.lower()}",
6063
"page_title": f"Details of the {self.symptom_type_name.lower()}",
61-
"heading_description": self._get_heading_description(),
6264
},
6365
)
6466

6567
return context
6668

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-
7369

7470
class AddSymptomView(BaseSymptomFormView):
7571
"""
@@ -144,6 +140,11 @@ class AddSymptomLumpView(AddSymptomView):
144140
form_class = LumpForm
145141
template_name = "mammograms/medical_information/symptoms/forms/simple_symptom.jinja"
146142

143+
def get_context_data(self, **kwargs):
144+
context = super().get_context_data(**kwargs)
145+
context[HEADING_DESCRIPTION_KEY] = "Lumps are" + HEADING_DESCRIPTION_SUFFIX
146+
return context
147+
147148

148149
class AddSymptomSwellingOrShapeChangeView(AddSymptomView):
149150
"""
@@ -154,6 +155,13 @@ class AddSymptomSwellingOrShapeChangeView(AddSymptomView):
154155
form_class = SwellingOrShapeChangeForm
155156
template_name = "mammograms/medical_information/symptoms/forms/simple_symptom.jinja"
156157

158+
def get_context_data(self, **kwargs):
159+
context = super().get_context_data(**kwargs)
160+
context[HEADING_DESCRIPTION_KEY] = (
161+
"Swelling or shape change is" + HEADING_DESCRIPTION_SUFFIX
162+
)
163+
return context
164+
157165

158166
class AddSymptomSkinChangeView(AddSymptomView):
159167
"""
@@ -164,6 +172,11 @@ class AddSymptomSkinChangeView(AddSymptomView):
164172
form_class = SkinChangeForm
165173
template_name = "mammograms/medical_information/symptoms/forms/skin_change.jinja"
166174

175+
def get_context_data(self, **kwargs):
176+
context = super().get_context_data(**kwargs)
177+
context[HEADING_DESCRIPTION_KEY] = "Skin change is" + HEADING_DESCRIPTION_SUFFIX
178+
return context
179+
167180

168181
class AddSymptomNippleChangeView(AddSymptomView):
169182
"""
@@ -174,6 +187,13 @@ class AddSymptomNippleChangeView(AddSymptomView):
174187
form_class = NippleChangeForm
175188
template_name = "mammograms/medical_information/symptoms/forms/nipple_change.jinja"
176189

190+
def get_context_data(self, **kwargs):
191+
context = super().get_context_data(**kwargs)
192+
context[HEADING_DESCRIPTION_KEY] = (
193+
"Nipple change is" + HEADING_DESCRIPTION_SUFFIX
194+
)
195+
return context
196+
177197

178198
class AddOtherSymptomView(AddSymptomView):
179199
"""
@@ -185,7 +205,7 @@ class AddOtherSymptomView(AddSymptomView):
185205
template_name = "mammograms/medical_information/symptoms/forms/other.jinja"
186206

187207
def get_context_data(self, **kwargs):
188-
context = super().get_context_data()
208+
context = super().get_context_data(**kwargs)
189209
context["heading"] = "Symptom details"
190210
return context
191211

@@ -212,6 +232,11 @@ class UpdateSymptomLumpView(UpdateSymptomView):
212232
def extra_filters(self):
213233
return {"symptom_type_id": SymptomType.LUMP}
214234

235+
def get_context_data(self, **kwargs):
236+
context = super().get_context_data(**kwargs)
237+
context[HEADING_DESCRIPTION_KEY] = "Lumps are" + HEADING_DESCRIPTION_SUFFIX
238+
return context
239+
215240

216241
class UpdateSymptomSwellingOrShapeChangeView(UpdateSymptomView):
217242
"""
@@ -225,6 +250,13 @@ class UpdateSymptomSwellingOrShapeChangeView(UpdateSymptomView):
225250
def extra_filters(self):
226251
return {"symptom_type_id": SymptomType.SWELLING_OR_SHAPE_CHANGE}
227252

253+
def get_context_data(self, **kwargs):
254+
context = super().get_context_data(**kwargs)
255+
context[HEADING_DESCRIPTION_KEY] = (
256+
"Swelling or shape change is" + HEADING_DESCRIPTION_SUFFIX
257+
)
258+
return context
259+
228260

229261
class UpdateSymptomSkinChangeView(UpdateSymptomView):
230262
"""
@@ -238,6 +270,11 @@ class UpdateSymptomSkinChangeView(UpdateSymptomView):
238270
def extra_filters(self):
239271
return {"symptom_type_id": SymptomType.SKIN_CHANGE}
240272

273+
def get_context_data(self, **kwargs):
274+
context = super().get_context_data(**kwargs)
275+
context[HEADING_DESCRIPTION_KEY] = "Skin change is" + HEADING_DESCRIPTION_SUFFIX
276+
return context
277+
241278

242279
class UpdateSymptomNippleChangeView(UpdateSymptomView):
243280
"""
@@ -251,6 +288,13 @@ class UpdateSymptomNippleChangeView(UpdateSymptomView):
251288
def extra_filters(self):
252289
return {"symptom_type_id": SymptomType.NIPPLE_CHANGE}
253290

291+
def get_context_data(self, **kwargs):
292+
context = super().get_context_data(**kwargs)
293+
context[HEADING_DESCRIPTION_KEY] = (
294+
"Nipple change is" + HEADING_DESCRIPTION_SUFFIX
295+
)
296+
return context
297+
254298

255299
class UpdateOtherSymptomView(UpdateSymptomView):
256300
"""
@@ -265,7 +309,7 @@ def extra_filters(self):
265309
return {"symptom_type_id": SymptomType.OTHER}
266310

267311
def get_context_data(self, **kwargs):
268-
context = super().get_context_data()
312+
context = super().get_context_data(**kwargs)
269313
context["heading"] = "Symptom details"
270314
return context
271315

0 commit comments

Comments
 (0)