Skip to content

Commit ea7f44c

Browse files
authored
Merge pull request #448 from NHSDigital/dtos-10724-fix-other-area
[DTOS-10724] fix a few formatting issues in the symptom summary list
2 parents bd24344 + fc60db2 commit ea7f44c

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

manage_breast_screening/mammograms/presenters/medical_information_presenter.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
from manage_breast_screening.core.template_helpers import multiline_content
66
from manage_breast_screening.core.utils.date_formatting import format_approximate_date
7-
from manage_breast_screening.participants.models.symptom import SymptomType
7+
from manage_breast_screening.participants.models.symptom import (
8+
RelativeDateChoices,
9+
SymptomAreas,
10+
SymptomType,
11+
)
812

913
from .appointment_presenters import AppointmentPresenter
1014

@@ -23,10 +27,34 @@ class PresentedSymptom:
2327
stopped_line: str = ""
2428
additional_information_line: str = ""
2529

30+
@staticmethod
31+
def _present_symptom_area(symptom):
32+
if symptom.area == SymptomAreas.OTHER and symptom.area_description:
33+
location = f"Other: {symptom.area_description}"
34+
else:
35+
location = symptom.get_area_display()
36+
return location
37+
38+
@staticmethod
39+
def _present_started(symptom):
40+
match symptom.when_started:
41+
case RelativeDateChoices.SINCE_A_SPECIFIC_DATE:
42+
if symptom.year_started is None or symptom.month_started is None:
43+
# Shouldn't happen unless there is a bug in data entry
44+
return "Since a specific date"
45+
46+
return format_approximate_date(
47+
symptom.year_started, symptom.month_started
48+
)
49+
case RelativeDateChoices.NOT_SURE:
50+
return "Not sure"
51+
case _:
52+
return symptom.get_when_started_display() + " ago"
53+
2654
@classmethod
2755
def from_symptom(cls, symptom):
28-
location = symptom.get_area_display()
29-
started = symptom.get_when_started_display()
56+
location = cls._present_symptom_area(symptom)
57+
started = cls._present_started(symptom)
3058
if symptom.year_started is not None and symptom.month_started is not None:
3159
started = format_approximate_date(
3260
symptom.year_started, symptom.month_started

manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,29 @@ def test_presents_symptoms_with_area(self, area, expected_location):
4343
symptom_type_id="LUMP",
4444
symptom_type_name="Lump",
4545
location_line=expected_location,
46-
started_line="Less than 3 months",
46+
started_line="Less than 3 months ago",
47+
investigated_line="Not investigated",
48+
),
49+
]
50+
51+
def test_formats_area(self):
52+
symptom = SymptomFactory.create(
53+
lump=True,
54+
when_started=RelativeDateChoices.LESS_THAN_THREE_MONTHS,
55+
area=SymptomAreas.OTHER,
56+
area_description="abc",
57+
)
58+
59+
presenter = MedicalInformationPresenter(symptom.appointment)
60+
61+
assert presenter.symptoms == [
62+
PresentedSymptom(
63+
id=symptom.id,
64+
appointment_id=symptom.appointment_id,
65+
symptom_type_id="lump",
66+
symptom_type_name="Lump",
67+
location_line="Other: abc",
68+
started_line="Less than 3 months ago",
4769
investigated_line="Not investigated",
4870
)
4971
]
@@ -201,7 +223,7 @@ def test_formats_for_summary_list(self):
201223
"text": "Swelling or shape change",
202224
},
203225
"value": {
204-
"html": "Both breasts<br>Less than 3 months<br>Not investigated",
226+
"html": "Both breasts<br>Less than 3 months ago<br>Not investigated",
205227
},
206228
},
207229
]

0 commit comments

Comments
 (0)