Skip to content

Commit a2d4eeb

Browse files
authored
Merge pull request #842 from NHSDigital/DTOSS-11597-appointment-should-not-proceed-refactor
Appointment can't proceed if had mammogram within the last 6 months. Support updating of previous mammograms.
2 parents 1c2ca98 + 3acfa3d commit a2d4eeb

21 files changed

+1244
-371
lines changed

manage_breast_screening/core/jinja2/layout-app.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
}}
4141
{% endblock %}
4242

43+
{% block beforeContent %}
44+
{% if back_link_params %}
45+
{{ backLink(back_link_params) }}
46+
{% endif %}
47+
{% endblock beforeContent %}
48+
4349
{% block content %}
4450
{% block flash_messages %}
4551
{% set info_notification_params = get_notification_banner_params(

manage_breast_screening/core/jinja2/layout-form.jinja

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
{% from 'nhsuk/components/back-link/macro.jinja' import backLink %}
33
{% from 'django_form_helpers.jinja' import form_error_summary %}
44

5-
{% block beforeContent %}
6-
{% if back_link_params %}
7-
{{ backLink(back_link_params) }}
8-
{% endif %}
9-
{% endblock beforeContent %}
10-
115
{% block page_content %}
126
<div class="nhsuk-grid-row">
137
<div class="nhsuk-grid-column-two-thirds">

manage_breast_screening/core/views/generic.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,18 @@ def form_valid(self, form):
8686
auditor = Auditor.from_request(self.request)
8787
auditor.audit_create(created_object)
8888

89-
messages.add_message(
90-
self.request,
91-
messages.SUCCESS,
92-
self.get_success_message_content(created_object),
93-
)
89+
if self.should_add_message(form):
90+
messages.add_message(
91+
self.request,
92+
messages.SUCCESS,
93+
self.get_success_message_content(created_object),
94+
)
9495

9596
return super().form_valid(form)
9697

98+
def should_add_message(self, form) -> bool:
99+
return True
100+
97101

98102
class UpdateWithAuditView(NamedThingMixin, SingleObjectMixin, FormView):
99103
"""
@@ -159,14 +163,18 @@ def form_valid(self, form):
159163
auditor = Auditor.from_request(self.request)
160164
auditor.audit_update(created_object)
161165

162-
messages.add_message(
163-
self.request,
164-
messages.SUCCESS,
165-
self.get_success_message_content(created_object),
166-
)
166+
if self.should_add_message(form):
167+
messages.add_message(
168+
self.request,
169+
messages.SUCCESS,
170+
self.get_success_message_content(created_object),
171+
)
167172

168173
return super().form_valid(form)
169174

175+
def should_add_message(self, form) -> bool:
176+
return True
177+
170178

171179
class DeleteWithAuditView(NamedThingMixin, DeleteView):
172180
"""
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<input type="hidden" name="return_url" value="{{ return_url }}"/>
7+
8+
{% do form.location_type.add_divider_after("OUTSIDE_UK", "or") %}
9+
{{ form.location_type.as_field_group() }}
10+
11+
{{ form.when_taken.as_field_group() }}
12+
13+
{{ form.name_is_the_same.as_field_group() }}
14+
15+
{{ form.additional_information.as_field_group() }}
16+
17+
<div class="nhsuk-button-group">
18+
{{ button({
19+
"text": "Save"
20+
}) }}
21+
</div>
22+
{% endblock %}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% extends 'layout-app.jinja' %}
2+
{% from 'nhsuk/components/back-link/macro.jinja' import backLink %}
3+
{% from 'nhsuk/components/button/macro.jinja' import button %}
4+
{% from 'django_form_helpers.jinja' import form_error_summary %}
5+
6+
{% block page_content %}
7+
<div class="nhsuk-grid-row">
8+
<div class="nhsuk-grid-column-two-thirds">
9+
<h1 class="nhsuk-heading-l">
10+
{% if caption %}
11+
<span class="nhsuk-caption-l">
12+
{{ caption }}
13+
</span>
14+
{% endif %}
15+
{{ heading }}
16+
</h1>
17+
18+
<p>The mammogram added took place {{ time_since_previous_mammogram }}. It is not recommended to take breast x-rays within 6 months of each other.</p>
19+
20+
<p>Advise the participant that they will be invited for their next scheduled mammogram based on the information provided.</p>
21+
22+
<form action="{{ url('mammograms:attended_not_screened', kwargs={'appointment_pk': appointment.pk}) }}" method="post">
23+
<div class="nhsuk-button-group">
24+
{{ csrf_input }}
25+
{{ button({
26+
"text": "End appointment and return to clinic"
27+
}) }}
28+
</div>
29+
</form>
30+
31+
<p>
32+
<a href="{{ change_previous_mammogram_url }}">Edit previous mammogram details</a>
33+
</p>
34+
</div>
35+
</div>
36+
{% endblock %}

manage_breast_screening/mammograms/presenters/last_known_mammogram_presenter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010

1111
class LastKnownMammogramPresenter:
12-
def __init__(self, last_known_mammograms, participant_pk, current_url):
12+
def __init__(self, last_known_mammograms, appointment_pk, current_url):
1313
self._last_known_mammograms = last_known_mammograms
14-
self.participant_pk = participant_pk
14+
self.appointment_pk = appointment_pk
1515
self.current_url = current_url
1616

1717
@cached_property
@@ -66,8 +66,8 @@ def _present_mammogram(self, mammogram):
6666
def add_link(self):
6767
href = (
6868
reverse(
69-
"participants:add_previous_mammogram",
70-
kwargs={"pk": self.participant_pk},
69+
"mammograms:add_previous_mammogram",
70+
kwargs={"pk": self.appointment_pk},
7171
)
7272
+ f"?return_url={self.current_url}"
7373
)

manage_breast_screening/mammograms/presenters/medical_information_presenter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ def medical_information_url(self):
237237
def add_mammogram_button(self):
238238
url = (
239239
reverse(
240-
"participants:add_previous_mammogram",
241-
kwargs={"pk": self.appointment.participant.pk},
240+
"mammograms:add_previous_mammogram",
241+
kwargs={"pk": self.appointment.pk},
242242
)
243243
+ "?return_url="
244244
+ quote(self.medical_information_url)

manage_breast_screening/mammograms/tests/presenters/test_last_known_mammogram_presenter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def reported_earlier(self):
3535
def test_no_last_known_mammograms(self, reported_today):
3636
result = LastKnownMammogramPresenter(
3737
[],
38-
participant_pk=uuid4(),
38+
appointment_pk=uuid4(),
3939
current_url="/mammograms/abc",
4040
)
4141

@@ -45,7 +45,7 @@ def test_no_last_known_mammograms(self, reported_today):
4545
def test_last_known_mammograms_single(self, reported_today):
4646
result = LastKnownMammogramPresenter(
4747
[reported_today],
48-
participant_pk=uuid4(),
48+
appointment_pk=uuid4(),
4949
current_url="/mammograms/abc",
5050
)
5151

@@ -67,7 +67,7 @@ def test_last_known_mammograms_single(self, reported_today):
6767
def test_last_known_mammograms_multiple(self, reported_today, reported_earlier):
6868
result = LastKnownMammogramPresenter(
6969
[reported_today, reported_earlier],
70-
participant_pk=uuid4(),
70+
appointment_pk=uuid4(),
7171
current_url="/mammograms/abc",
7272
)
7373

@@ -95,17 +95,17 @@ def test_last_known_mammograms_multiple(self, reported_today, reported_earlier):
9595
]
9696

9797
def test_add_link(self, reported_today):
98-
participant_id = uuid4()
98+
appointment_pk = uuid4()
9999
current_url = "/mammograms/abc"
100100

101101
result = LastKnownMammogramPresenter(
102102
[reported_today],
103-
participant_pk=participant_id,
103+
appointment_pk=appointment_pk,
104104
current_url=current_url,
105105
)
106106

107107
assert result.add_link == {
108-
"href": f"/participants/{participant_id}/previous-mammograms/add?return_url={current_url}",
108+
"href": f"/mammograms/{appointment_pk}/previous-mammograms/add?return_url={current_url}",
109109
"text": "Add another",
110110
"visually_hidden_text": "mammogram",
111111
}

manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def test_add_mammogram_button(self):
267267

268268
assert MedicalInformationPresenter(appointment).add_mammogram_button == {
269269
"href": (
270-
f"/participants/{appointment.participant.pk}/previous-mammograms/add"
270+
f"/mammograms/{appointment.pk}/previous-mammograms/add"
271271
+ f"?return_url=/mammograms/{appointment.pk}/record-medical-information/"
272272
),
273273
"text": "Add another mammogram",

0 commit comments

Comments
 (0)