Skip to content

Commit f064d17

Browse files
authored
Merge pull request #754 from NHSDigital/DTOSS-11452-mastectomy-and-lumpectomy
Add mastectomy or lumpectomy history form
2 parents 81a64ea + 8eaef2c commit f064d17

18 files changed

+951
-7
lines changed

manage_breast_screening/data/west_tester_today_clinic_data.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ clinic:
175175
right_breast_other_surgery:
176176
- RECONSTRUCTION
177177
left_breast_other_surgery:
178-
- NO_SURGERY
178+
- NO_OTHER_SURGERY
179179
year_of_surgery: 2018
180180
surgery_reason: RISK_REDUCTION
181181
additional_details: Right mastectomy with reconstruction following genetic testing

manage_breast_screening/mammograms/forms/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .breast_augmentation_history_form import BreastAugmentationHistoryForm
44
from .cyst_history_form import CystHistoryForm
55
from .implanted_medical_device_history_form import ImplantedMedicalDeviceHistoryForm
6+
from .mastectomy_or_lumpectomy_history_form import MastectomyOrLumpectomyHistoryForm
67
from .record_medical_information_form import RecordMedicalInformationForm
78
from .screening_appointment_form import ScreeningAppointmentForm
89
from .special_appointment_forms import (
@@ -19,5 +20,6 @@
1920
"ScreeningAppointmentForm",
2021
"ProvideSpecialAppointmentDetailsForm",
2122
"MarkReasonsTemporaryForm",
23+
"MastectomyOrLumpectomyHistoryForm",
2224
"ImplantedMedicalDeviceHistoryForm",
2325
]
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
from django.forms import widgets
2+
from django.forms.widgets import RadioSelect, Textarea
3+
4+
from manage_breast_screening.core.services.auditor import Auditor
5+
from manage_breast_screening.nhsuk_forms.fields import (
6+
CharField,
7+
ChoiceField,
8+
YearField,
9+
)
10+
from manage_breast_screening.nhsuk_forms.fields.choice_fields import (
11+
MultipleChoiceField,
12+
)
13+
from manage_breast_screening.nhsuk_forms.forms import FormWithConditionalFields
14+
from manage_breast_screening.participants.models.mastectomy_or_lumpectomy_history_item import (
15+
MastectomyOrLumpectomyHistoryItem,
16+
)
17+
18+
19+
class MastectomyOrLumpectomyHistoryForm(FormWithConditionalFields):
20+
right_breast_procedure = ChoiceField(
21+
label="Right breast",
22+
visually_hidden_label_prefix="What procedure have they had in their ",
23+
visually_hidden_label_suffix="?",
24+
label_classes="nhsuk-fieldset__legend--s",
25+
widget=RadioSelect,
26+
choices=MastectomyOrLumpectomyHistoryItem.Procedure,
27+
error_messages={
28+
"required": "Select which procedure they have had in the right breast",
29+
},
30+
)
31+
left_breast_procedure = ChoiceField(
32+
label="Left breast",
33+
visually_hidden_label_prefix="What procedure have they had in their ",
34+
visually_hidden_label_suffix="?",
35+
label_classes="nhsuk-fieldset__legend--s",
36+
widget=RadioSelect,
37+
choices=MastectomyOrLumpectomyHistoryItem.Procedure,
38+
error_messages={
39+
"required": "Select which procedure they have had in the left breast",
40+
},
41+
)
42+
right_breast_other_surgery = MultipleChoiceField(
43+
label="Right breast",
44+
visually_hidden_label_prefix="What other surgery have they had in their ",
45+
visually_hidden_label_suffix="?",
46+
label_classes="nhsuk-fieldset__legend--s",
47+
choices=MastectomyOrLumpectomyHistoryItem.Surgery,
48+
error_messages={
49+
"required": "Select any other surgery they have had in the right breast",
50+
},
51+
exclusive_choices={"NO_OTHER_SURGERY"},
52+
)
53+
left_breast_other_surgery = MultipleChoiceField(
54+
label="Left breast",
55+
visually_hidden_label_prefix="What other surgery have they had in their ",
56+
visually_hidden_label_suffix="?",
57+
label_classes="nhsuk-fieldset__legend--s",
58+
choices=MastectomyOrLumpectomyHistoryItem.Surgery,
59+
error_messages={
60+
"required": "Select any other surgery they have had in the left breast",
61+
},
62+
exclusive_choices={"NO_OTHER_SURGERY"},
63+
)
64+
year_of_surgery = YearField(
65+
hint="Leave blank if unknown",
66+
required=False,
67+
label="Year of surgery (optional)",
68+
label_classes="nhsuk-label--m",
69+
classes="nhsuk-input--width-4",
70+
)
71+
surgery_reason = ChoiceField(
72+
choices=MastectomyOrLumpectomyHistoryItem.SurgeryReason,
73+
label="Why was this surgery done?",
74+
widget=widgets.RadioSelect,
75+
error_messages={"required": "Select the reason for surgery"},
76+
)
77+
surgery_other_reason_details = CharField(
78+
required=False,
79+
label="Provide details",
80+
error_messages={"required": "Provide details of the surgery"},
81+
classes="nhsuk-u-width-two-thirds",
82+
)
83+
additional_details = CharField(
84+
hint="Include any other relevant information about the surgery",
85+
required=False,
86+
label="Additional details (optional)",
87+
label_classes="nhsuk-label--m",
88+
widget=Textarea(attrs={"rows": 4}),
89+
max_words=500,
90+
error_messages={"max_words": "Additional details must be 500 words or less"},
91+
)
92+
93+
def __init__(self, *args, participant, **kwargs):
94+
super().__init__(*args, **kwargs)
95+
96+
self.given_field_value(
97+
"surgery_reason",
98+
MastectomyOrLumpectomyHistoryItem.SurgeryReason.OTHER_REASON,
99+
).require_field("surgery_other_reason_details")
100+
101+
def model_values(self):
102+
return dict(
103+
left_breast_procedure=self.cleaned_data.get("left_breast_procedure", None),
104+
right_breast_procedure=self.cleaned_data.get(
105+
"right_breast_procedure", None
106+
),
107+
left_breast_other_surgery=self.cleaned_data.get(
108+
"left_breast_other_surgery", []
109+
),
110+
right_breast_other_surgery=self.cleaned_data.get(
111+
"right_breast_other_surgery", []
112+
),
113+
year_of_surgery=self.cleaned_data.get("year_of_surgery", None),
114+
surgery_reason=self.cleaned_data.get("surgery_reason", None),
115+
surgery_other_reason_details=self.cleaned_data.get(
116+
"surgery_other_reason_details", ""
117+
),
118+
additional_details=self.cleaned_data.get("additional_details", ""),
119+
)
120+
121+
def create(self, appointment, request):
122+
auditor = Auditor.from_request(request)
123+
field_values = self.model_values()
124+
125+
mastectomy_or_lumpectomy_history = (
126+
appointment.mastectomy_or_lumpectomy_history_items.create(
127+
appointment=appointment,
128+
**field_values,
129+
)
130+
)
131+
132+
auditor.audit_create(mastectomy_or_lumpectomy_history)
133+
134+
return mastectomy_or_lumpectomy_history
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
6+
{% block form %}
7+
<p>
8+
This is designed to capture information on prophylactic or elective surgery.
9+
<a href="{{ presenter.add_breast_cancer_history_link.href }}" class="nhsuk-link">
10+
Add breast cancer details
11+
</a>
12+
if that was the reason for this surgery.
13+
</p>
14+
15+
<h2 aria-hidden="true">What procedure has {{ participant_first_name }} had?</h2>
16+
<div class="nhsuk-grid-row">
17+
<div class="nhsuk-grid-column-one-half">
18+
{% do form.right_breast_procedure.add_divider_after("MASTECTOMY_NO_TISSUE_REMAINING", "or") %}
19+
{{ form.right_breast_procedure.as_field_group() }}
20+
</div>
21+
<div class="nhsuk-grid-column-one-half">
22+
{% do form.left_breast_procedure.add_divider_after("MASTECTOMY_NO_TISSUE_REMAINING", "or") %}
23+
{{ form.left_breast_procedure.as_field_group() }}
24+
</div>
25+
</div>
26+
27+
<h2 aria-hidden="true">What other surgery has {{ participant_first_name }} had?</h2>
28+
<div class="nhsuk-grid-row">
29+
<div class="nhsuk-grid-column-one-half">
30+
{% do form.right_breast_other_surgery.add_divider_after("SYMMETRISATION", "or") %}
31+
{{ form.right_breast_other_surgery.as_field_group() }}
32+
</div>
33+
<div class="nhsuk-grid-column-one-half">
34+
{% do form.left_breast_other_surgery.add_divider_after("SYMMETRISATION", "or") %}
35+
{{ form.left_breast_other_surgery.as_field_group() }}
36+
</div>
37+
</div>
38+
39+
{{ form.year_of_surgery.as_field_group() }}
40+
41+
{{ form.surgery_reason.as_field_group() }}
42+
43+
{{ form.additional_details.as_field_group() }}
44+
45+
<div class="nhsuk-button-group">
46+
{{ button({
47+
"text": "Save"
48+
}) }}
49+
</div>
50+
{% endblock %}
51+

manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
{% for presented_item in presenter.mastectomy_or_lumpectomy_history %}
4545
{{ summaryList(presented_item.summary_list_params) }}
4646
{% endfor %}
47+
<a href="{{ presenter.add_mastectomy_or_lumpectomy_history_link.href }}" class="nhsuk-link nhsuk-link--no-visited-state">{{ presenter.add_mastectomy_or_lumpectomy_history_link.text }}</a><br>
4748
{% endset %}
4849

4950
{% set implanted_medical_device_history_html %}

manage_breast_screening/mammograms/presenters/mastectomy_or_lumpectomy_history_item_presenter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, mastectomy_or_lumpectomy_history_item):
2525
else "Not specified"
2626
)
2727
self.surgery_reason = self._item.get_surgery_reason_display()
28+
self.surgery_other_reason_details = self._item.surgery_other_reason_details
2829
self.additional_details = nl2br(self._item.additional_details)
2930

3031
@property
@@ -61,6 +62,10 @@ def summary_list_params(self):
6162
"key": {"text": "Surgery reason"},
6263
"value": {"html": self.surgery_reason},
6364
},
65+
{
66+
"key": {"text": "Surgery other reason details"},
67+
"value": {"text": self.surgery_other_reason_details},
68+
},
6469
{
6570
"key": {"text": "Additional details"},
6671
"value": {"html": self.additional_details},

manage_breast_screening/mammograms/presenters/medical_information_presenter.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,15 @@ def add_benign_lump_history_link(self):
209209
"href": url,
210210
"text": "Add benign lump history",
211211
}
212+
213+
@property
214+
def add_mastectomy_or_lumpectomy_history_link(self):
215+
url = reverse(
216+
"mammograms:add_mastectomy_or_lumpectomy_history_item",
217+
kwargs={"pk": self.appointment.pk},
218+
)
219+
220+
return {
221+
"href": url,
222+
"text": "Add mastectomy or lumpectomy history",
223+
}

0 commit comments

Comments
 (0)