Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ clinic:
right_breast_other_surgery:
- RECONSTRUCTION
left_breast_other_surgery:
- NO_SURGERY
- NO_OTHER_SURGERY
year_of_surgery: 2018
surgery_reason: RISK_REDUCTION
additional_details: Right mastectomy with reconstruction following genetic testing
Expand Down
2 changes: 2 additions & 0 deletions manage_breast_screening/mammograms/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .breast_augmentation_history_form import BreastAugmentationHistoryForm
from .cyst_history_form import CystHistoryForm
from .implanted_medical_device_history_form import ImplantedMedicalDeviceHistoryForm
from .mastectomy_or_lumpectomy_history_form import MastectomyOrLumpectomyHistoryForm
from .record_medical_information_form import RecordMedicalInformationForm
from .screening_appointment_form import ScreeningAppointmentForm
from .special_appointment_forms import (
Expand All @@ -19,5 +20,6 @@
"ScreeningAppointmentForm",
"ProvideSpecialAppointmentDetailsForm",
"MarkReasonsTemporaryForm",
"MastectomyOrLumpectomyHistoryForm",
"ImplantedMedicalDeviceHistoryForm",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
from django.forms import widgets
from django.forms.widgets import RadioSelect, Textarea

from manage_breast_screening.core.services.auditor import Auditor
from manage_breast_screening.nhsuk_forms.fields import (
CharField,
ChoiceField,
YearField,
)
from manage_breast_screening.nhsuk_forms.fields.choice_fields import (
MultipleChoiceField,
)
from manage_breast_screening.nhsuk_forms.forms import FormWithConditionalFields
from manage_breast_screening.participants.models.mastectomy_or_lumpectomy_history_item import (
MastectomyOrLumpectomyHistoryItem,
)


class MastectomyOrLumpectomyHistoryForm(FormWithConditionalFields):
right_breast_procedure = ChoiceField(
label="Right breast",
visually_hidden_label_prefix="What procedure have they had in their ",
visually_hidden_label_suffix="?",
label_classes="nhsuk-fieldset__legend--s",
widget=RadioSelect,
choices=MastectomyOrLumpectomyHistoryItem.Procedure,
error_messages={
"required": "Select which procedure they have had in the right breast",
},
)
left_breast_procedure = ChoiceField(
label="Left breast",
visually_hidden_label_prefix="What procedure have they had in their ",
visually_hidden_label_suffix="?",
label_classes="nhsuk-fieldset__legend--s",
widget=RadioSelect,
choices=MastectomyOrLumpectomyHistoryItem.Procedure,
error_messages={
"required": "Select which procedure they have had in the left breast",
},
)
right_breast_other_surgery = MultipleChoiceField(
label="Right breast",
visually_hidden_label_prefix="What other surgery have they had in their ",
visually_hidden_label_suffix="?",
label_classes="nhsuk-fieldset__legend--s",
choices=MastectomyOrLumpectomyHistoryItem.Surgery,
error_messages={
"required": "Select any other surgery they have had in the right breast",
},
exclusive_choices={"NO_OTHER_SURGERY"},
)
left_breast_other_surgery = MultipleChoiceField(
label="Left breast",
visually_hidden_label_prefix="What other surgery have they had in their ",
visually_hidden_label_suffix="?",
label_classes="nhsuk-fieldset__legend--s",
choices=MastectomyOrLumpectomyHistoryItem.Surgery,
error_messages={
"required": "Select any other surgery they have had in the left breast",
},
exclusive_choices={"NO_OTHER_SURGERY"},
)
year_of_surgery = YearField(
hint="Leave blank if unknown",
required=False,
label="Year of surgery (optional)",
label_classes="nhsuk-label--m",
classes="nhsuk-input--width-4",
)
surgery_reason = ChoiceField(
choices=MastectomyOrLumpectomyHistoryItem.SurgeryReason,
label="Why was this surgery done?",
widget=widgets.RadioSelect,
error_messages={"required": "Select the reason for surgery"},
)
surgery_other_reason_details = CharField(
required=False,
label="Provide details",
error_messages={"required": "Provide details of the surgery"},
classes="nhsuk-u-width-two-thirds",
)
additional_details = CharField(
hint="Include any other relevant information about the surgery",
required=False,
label="Additional details (optional)",
label_classes="nhsuk-label--m",
widget=Textarea(attrs={"rows": 4}),
max_words=500,
error_messages={"max_words": "Additional details must be 500 words or less"},
)

def __init__(self, *args, participant, **kwargs):
super().__init__(*args, **kwargs)

self.given_field_value(
"surgery_reason",
MastectomyOrLumpectomyHistoryItem.SurgeryReason.OTHER_REASON,
).require_field("surgery_other_reason_details")

def model_values(self):
return dict(
left_breast_procedure=self.cleaned_data.get("left_breast_procedure", None),
right_breast_procedure=self.cleaned_data.get(
"right_breast_procedure", None
),
left_breast_other_surgery=self.cleaned_data.get(
"left_breast_other_surgery", []
),
right_breast_other_surgery=self.cleaned_data.get(
"right_breast_other_surgery", []
),
year_of_surgery=self.cleaned_data.get("year_of_surgery", None),
surgery_reason=self.cleaned_data.get("surgery_reason", None),
surgery_other_reason_details=self.cleaned_data.get(
"surgery_other_reason_details", ""
),
additional_details=self.cleaned_data.get("additional_details", ""),
)

def create(self, appointment, request):
auditor = Auditor.from_request(request)
field_values = self.model_values()

mastectomy_or_lumpectomy_history = (
appointment.mastectomy_or_lumpectomy_history_items.create(
appointment=appointment,
**field_values,
)
)

auditor.audit_create(mastectomy_or_lumpectomy_history)

return mastectomy_or_lumpectomy_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{% extends "layout-form.jinja" %}
{% from "nhsuk/components/button/macro.jinja" import button %}
{% from "nhsuk/components/fieldset/macro.jinja" import fieldset %}


{% block form %}
<p>
This is designed to capture information on prophylactic or elective surgery.
<a href="{{ presenter.add_breast_cancer_history_link.href }}" class="nhsuk-link">
Add breast cancer details
</a>
if that was the reason for this surgery.
</p>

<h2 aria-hidden="true">What procedure has {{ participant_first_name }} had?</h2>
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-one-half">
{% do form.right_breast_procedure.add_divider_after("MASTECTOMY_NO_TISSUE_REMAINING", "or") %}
{{ form.right_breast_procedure.as_field_group() }}
</div>
<div class="nhsuk-grid-column-one-half">
{% do form.left_breast_procedure.add_divider_after("MASTECTOMY_NO_TISSUE_REMAINING", "or") %}
{{ form.left_breast_procedure.as_field_group() }}
</div>
</div>

<h2 aria-hidden="true">What other surgery has {{ participant_first_name }} had?</h2>
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-one-half">
{% do form.right_breast_other_surgery.add_divider_after("SYMMETRISATION", "or") %}
{{ form.right_breast_other_surgery.as_field_group() }}
</div>
<div class="nhsuk-grid-column-one-half">
{% do form.left_breast_other_surgery.add_divider_after("SYMMETRISATION", "or") %}
{{ form.left_breast_other_surgery.as_field_group() }}
</div>
</div>

{{ form.year_of_surgery.as_field_group() }}

{{ form.surgery_reason.as_field_group() }}

{{ form.additional_details.as_field_group() }}

<div class="nhsuk-button-group">
{{ button({
"text": "Save"
}) }}
</div>
{% endblock %}

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
{% for presented_item in presenter.mastectomy_or_lumpectomy_history %}
{{ summaryList(presented_item.summary_list_params) }}
{% endfor %}
<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>
{% endset %}

{% set implanted_medical_device_history_html %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self, mastectomy_or_lumpectomy_history_item):
else "Not specified"
)
self.surgery_reason = self._item.get_surgery_reason_display()
self.surgery_other_reason_details = self._item.surgery_other_reason_details
self.additional_details = nl2br(self._item.additional_details)

@property
Expand Down Expand Up @@ -61,6 +62,10 @@ def summary_list_params(self):
"key": {"text": "Surgery reason"},
"value": {"html": self.surgery_reason},
},
{
"key": {"text": "Surgery other reason details"},
"value": {"text": self.surgery_other_reason_details},
},
{
"key": {"text": "Additional details"},
"value": {"html": self.additional_details},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,15 @@ def add_benign_lump_history_link(self):
"href": url,
"text": "Add benign lump history",
}

@property
def add_mastectomy_or_lumpectomy_history_link(self):
url = reverse(
"mammograms:add_mastectomy_or_lumpectomy_history_item",
kwargs={"pk": self.appointment.pk},
)

return {
"href": url,
"text": "Add mastectomy or lumpectomy history",
}
Loading