Skip to content

Commit 00dca7f

Browse files
authored
Merge pull request #474 from NHSDigital/dtos-10726-add-edit-skin-change
[DTOS-10726] add/edit skin change symptoms
2 parents aff6019 + b4123fe commit 00dca7f

File tree

15 files changed

+631
-37
lines changed

15 files changed

+631
-37
lines changed

manage_breast_screening/mammograms/forms/symptom_forms.py

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from manage_breast_screening.participants.models.symptom import (
2121
RelativeDateChoices,
2222
SymptomAreas,
23+
SymptomSubType,
2324
SymptomType,
2425
)
2526

@@ -63,7 +64,7 @@ class CommonFields:
6364
investigated = yes_no_field(
6465
label="Has this been investigated?",
6566
error_messages={
66-
"required": "Select whether the lump has been investigated or not"
67+
"required": "Select whether the symptom has been investigated or not"
6768
},
6869
)
6970
investigation_details = CharField(
@@ -101,6 +102,8 @@ def __init__(self, symptom_type, instance=None, **kwargs):
101102
kwargs["initial"] = {
102103
"area": instance.area,
103104
"area_description": instance.area_description,
105+
"symptom_sub_type": instance.symptom_sub_type_id,
106+
"symptom_sub_type_details": instance.symptom_sub_type_details,
104107
"when_started": instance.when_started,
105108
"specific_date": (instance.month_started, instance.year_started),
106109
"intermittent": instance.intermittent,
@@ -200,6 +203,8 @@ def _model_values(self):
200203
"""
201204
area = self.cleaned_data["area"]
202205
area_description = self.cleaned_data.get("area_description", "")
206+
symptom_sub_type = self.cleaned_data.get("symptom_sub_type")
207+
symptom_sub_type_details = self.cleaned_data.get("symptom_sub_type_details", "")
203208
when_started = self.cleaned_data.get("when_started")
204209
specific_date = self.cleaned_data.get("specific_date")
205210
investigated = self.cleaned_data.get("investigated") == YesNo.YES
@@ -212,6 +217,8 @@ def _model_values(self):
212217
return dict(
213218
area=area,
214219
area_description=area_description,
220+
symptom_sub_type_id=symptom_sub_type,
221+
symptom_sub_type_details=symptom_sub_type_details,
215222
investigated=investigated,
216223
investigation_details=investigation_details,
217224
when_started=when_started,
@@ -326,3 +333,77 @@ def __init__(self, instance=None, **kwargs):
326333
predicate_field="investigated",
327334
predicate_field_value=YesNo.YES,
328335
)
336+
337+
338+
class SkinChangeForm(SymptomForm):
339+
class SymptomSubTypeChoices(TextChoices):
340+
SORES_OR_CYSTS = SymptomSubType.SORES_OR_CYSTS, "Sores or cysts"
341+
DIMPLES_OR_INDENTATION = (
342+
SymptomSubType.DIMPLES_OR_INDENTATION,
343+
"Dimples or indentation",
344+
)
345+
RASH = SymptomSubType.RASH, "Rash"
346+
COLOUR_CHANGE = SymptomSubType.COLOUR_CHANGE, "Colour change"
347+
OTHER = SymptomSubType.OTHER, "Other"
348+
349+
area = ChoiceField(
350+
choices=RightLeftOtherChoices,
351+
label="Where is the skin change located?",
352+
error_messages={"required": "Select the location of the skin change"},
353+
)
354+
area_description = CharField(
355+
required=False,
356+
label="Describe the specific area",
357+
hint="For example, the left armpit",
358+
error_messages={
359+
"required": "Describe the specific area where the skin change is located"
360+
},
361+
classes="nhsuk-u-width-two-thirds",
362+
)
363+
symptom_sub_type = ChoiceField(
364+
choices=SymptomSubTypeChoices,
365+
label="How has the skin changed?",
366+
error_messages={"required": "Select how the skin has changed"},
367+
)
368+
symptom_sub_type_details = CharField(
369+
required=False,
370+
label="Describe the change",
371+
error_messages={"required": "Enter a description of the change"},
372+
classes="nhsuk-u-width-two-thirds",
373+
)
374+
when_started = CommonFields.when_started
375+
specific_date = CommonFields.specific_date
376+
intermittent = CommonFields.intermittent
377+
recently_resolved = CommonFields.recently_resolved
378+
when_resolved = CommonFields.when_resolved
379+
investigated = CommonFields.investigated
380+
investigation_details = CommonFields.investigation_details
381+
additional_information = CommonFields.additional_information
382+
383+
def __init__(self, instance=None, **kwargs):
384+
super().__init__(
385+
symptom_type=SymptomType.SKIN_CHANGE,
386+
instance=instance,
387+
**kwargs,
388+
)
389+
390+
self.set_conditionally_required(
391+
conditionally_required_field="area_description",
392+
predicate_field="area",
393+
predicate_field_value=RightLeftOtherChoices.OTHER,
394+
)
395+
self.set_conditionally_required(
396+
conditionally_required_field="symptom_sub_type_details",
397+
predicate_field="symptom_sub_type",
398+
predicate_field_value=self.SymptomSubTypeChoices.OTHER,
399+
)
400+
self.set_conditionally_required(
401+
conditionally_required_field="specific_date",
402+
predicate_field="when_started",
403+
predicate_field_value=RelativeDateChoices.SINCE_A_SPECIFIC_DATE,
404+
)
405+
self.set_conditionally_required(
406+
conditionally_required_field="investigation_details",
407+
predicate_field="investigated",
408+
predicate_field_value=YesNo.YES,
409+
)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{% extends "layout-form.jinja" %}
2+
{% from "nhsuk/components/button/macro.jinja" import button %}
3+
{% from "nhsuk/components/fieldset/macro.jinja" import fieldset %}
4+
5+
{% block form %}
6+
{% do form.area.add_divider_after("LEFT", "or") %}
7+
{% do form.area.add_conditional_html(
8+
'OTHER',
9+
form.area_description.as_field_group()
10+
) %}
11+
12+
{% do form.symptom_sub_type.add_conditional_html('OTHER', form.symptom_sub_type_details.as_field_group()) %}
13+
14+
15+
{% do form.when_started.add_divider_after("OVER_THREE_YEARS", "or") %}
16+
{% do form.when_started.add_divider_after("SINCE_A_SPECIFIC_DATE", "or") %}
17+
{% do form.when_started.add_conditional_html(
18+
'SINCE_A_SPECIFIC_DATE',
19+
form.specific_date.as_field_group()
20+
) %}
21+
22+
{% do form.recently_resolved.add_conditional_html('true', form.when_resolved.as_field_group()) %}
23+
24+
{% do form.investigated.add_conditional_html('YES', form.investigation_details.as_field_group()) %}
25+
26+
{{ form.area.as_field_group() }}
27+
28+
{{ form.symptom_sub_type.as_field_group() }}
29+
30+
{% call fieldset({
31+
"legend": {
32+
"text": form.when_started.label,
33+
"classes": "nhsuk-fieldset__legend--m"
34+
}
35+
}) %}
36+
{{ form.when_started.as_field_group() }}
37+
<br>
38+
{{ form.intermittent.as_field_group() }}
39+
{{ form.recently_resolved.as_field_group() }}
40+
{% endcall %}
41+
42+
{{ form.investigated.as_field_group() }}
43+
44+
{{ form.additional_information.as_field_group() }}
45+
46+
<div class="nhsuk-button-group">
47+
{{ button({
48+
"text": "Save symptom"
49+
}) }}
50+
</div>
51+
52+
{% if delete_link %}
53+
<p class="nhsuk-u-margin-top-4">
54+
<a href="{{ delete_link.href }}" class="{{ delete_link.class }}">
55+
{{ delete_link.text }}
56+
</a>
57+
</p>
58+
{% endif %}
59+
{% endblock %}

manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
<p class="nhsuk-u-margin-top-4 nhsuk-u-margin-bottom-0">
2727
<a href="{{ presenter.add_lump_link.href }}" class="nhsuk-link nhsuk-link--no-visited-state">{{ presenter.add_lump_link.text }}</a><br>
28-
<a href="{{ presenter.add_swelling_or_shape_change_link.href }}" class="nhsuk-link nhsuk-link--no-visited-state">{{ presenter.add_swelling_or_shape_change_link.text }}</a>
28+
<a href="{{ presenter.add_swelling_or_shape_change_link.href }}" class="nhsuk-link nhsuk-link--no-visited-state">{{ presenter.add_swelling_or_shape_change_link.text }}</a><br>
29+
<a href="{{ presenter.add_skin_change_link.href }}" class="nhsuk-link nhsuk-link--no-visited-state">{{ presenter.add_skin_change_link.text }}</a>
2930
</p>
3031
{% endcall %}
3132

manage_breast_screening/mammograms/presenters/medical_information_presenter.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class PresentedSymptom:
1717
symptom_type_name: str
1818
location_line: str
1919
started_line: str
20+
change_type_line: str = ""
2021
investigated_line: str = ""
2122
intermittent_line: str = ""
2223
stopped_line: str = ""
@@ -46,12 +47,25 @@ def from_symptom(cls, symptom):
4647
else ""
4748
)
4849

50+
change_type_line = ""
51+
if symptom.symptom_type_id == SymptomType.SKIN_CHANGE:
52+
if (
53+
symptom.symptom_sub_type_id == "OTHER"
54+
and symptom.symptom_sub_type_details
55+
):
56+
change_type_line = f"Change type: {symptom.symptom_sub_type_details}"
57+
else:
58+
change_type_line = (
59+
f"Change type: {symptom.symptom_sub_type.name.lower()}"
60+
)
61+
4962
return cls(
5063
id=symptom.id,
5164
appointment_id=symptom.appointment_id,
5265
symptom_type_id=symptom.symptom_type_id,
5366
symptom_type_name=symptom.symptom_type.name,
5467
location_line=location,
68+
change_type_line=change_type_line,
5569
started_line=started,
5670
investigated_line=investigated,
5771
intermittent_line=intermittent,
@@ -65,6 +79,8 @@ def change_view(self):
6579
return "mammograms:change_symptom_lump"
6680
case SymptomType.SWELLING_OR_SHAPE_CHANGE:
6781
return "mammograms:change_symptom_swelling_or_shape_change"
82+
case SymptomType.SKIN_CHANGE:
83+
return "mammograms:change_symptom_skin_change"
6884
case _:
6985
raise ValueError(self.symptom_type_id)
7086

@@ -77,6 +93,7 @@ def build_summary_list_row(self, include_actions=True):
7793
[
7894
line
7995
for line in [
96+
self.change_type_line,
8097
self.location_line,
8198
self.started_line,
8299
self.investigated_line,
@@ -154,7 +171,24 @@ def add_swelling_or_shape_change_link(self):
154171
"href": url,
155172
"text": (
156173
"Add another swelling or shape change"
157-
if SymptomType.LUMP in self.existing_symptom_type_ids
174+
if SymptomType.SWELLING_OR_SHAPE_CHANGE
175+
in self.existing_symptom_type_ids
158176
else "Add a swelling or shape change"
159177
),
160178
}
179+
180+
@property
181+
def add_skin_change_link(self):
182+
url = reverse(
183+
"mammograms:add_symptom_skin_change",
184+
kwargs={"pk": self.appointment.pk},
185+
)
186+
187+
return {
188+
"href": url,
189+
"text": (
190+
"Add another skin change"
191+
if SymptomType.SKIN_CHANGE in self.existing_symptom_type_ids
192+
else "Add a skin change"
193+
),
194+
}

0 commit comments

Comments
 (0)