Skip to content

Commit c23bd85

Browse files
authored
Merge pull request #56 from NHSDigital/ask-for-medical-info
Ask for medical information page
2 parents b5c9e8f + 9c4f4d5 commit c23bd85

5 files changed

Lines changed: 107 additions & 23 deletions

File tree

manage_breast_screening/record_a_mammogram/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def save(self):
1818
class AskForMedicalInformationForm(forms.Form):
1919
decision = forms.ChoiceField(
2020
choices=(
21-
("continue", "Yes"),
22-
("dropout", "No - proceed to imaging"),
21+
("yes", "Yes"),
22+
("no", "No - proceed to imaging"),
2323
),
2424
required=True,
2525
widget=forms.RadioSelect(),

manage_breast_screening/record_a_mammogram/tests/test_views.py

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,108 @@
55
from manage_breast_screening.clinics.tests.factories import AppointmentFactory
66

77

8+
@pytest.fixture
9+
def appointment():
10+
return AppointmentFactory.create()
11+
12+
813
@pytest.mark.django_db
914
class TestStartScreening:
10-
@pytest.fixture(autouse=True)
11-
def setup(self):
12-
self.appointment = AppointmentFactory.create()
13-
14-
def test_appointment_continued(self, client):
15+
def test_appointment_continued(self, client, appointment):
1516
response = client.post(
1617
reverse(
17-
"record_a_mammogram:start_screening", kwargs={"id": self.appointment.pk}
18+
"record_a_mammogram:start_screening", kwargs={"id": appointment.pk}
1819
),
1920
{"decision": "continue"},
2021
)
2122
assertRedirects(
2223
response,
2324
reverse(
2425
"record_a_mammogram:ask_for_medical_information",
25-
kwargs={"id": self.appointment.pk},
26+
kwargs={"id": appointment.pk},
2627
),
2728
)
2829

29-
def test_appointment_stopped(self, client):
30+
def test_appointment_stopped(self, client, appointment):
3031
response = client.post(
3132
reverse(
32-
"record_a_mammogram:start_screening", kwargs={"id": self.appointment.pk}
33+
"record_a_mammogram:start_screening", kwargs={"id": appointment.pk}
3334
),
3435
{"decision": "dropout"},
3536
)
3637
assertRedirects(
3738
response,
3839
reverse(
3940
"record_a_mammogram:appointment_cannot_go_ahead",
40-
kwargs={"id": self.appointment.pk},
41+
kwargs={"id": appointment.pk},
4142
),
4243
)
4344

44-
def test_renders_invalid_form(self, client):
45+
def test_renders_invalid_form(self, client, appointment):
4546
response = client.post(
4647
reverse(
47-
"record_a_mammogram:start_screening", kwargs={"id": self.appointment.pk}
48+
"record_a_mammogram:start_screening", kwargs={"id": appointment.pk}
4849
),
4950
{},
5051
)
5152
assertContains(response, "There is a problem")
5253

5354

5455
@pytest.mark.django_db
55-
class TestCheckIn:
56-
@pytest.fixture(autouse=True)
57-
def setup(self):
58-
self.appointment = AppointmentFactory.create()
56+
class TestAskForMedicalInformation:
57+
def test_continue_to_record(self, client, appointment):
58+
response = client.post(
59+
reverse(
60+
"record_a_mammogram:ask_for_medical_information",
61+
kwargs={"id": appointment.pk},
62+
),
63+
{"decision": "yes"},
64+
)
65+
assertRedirects(
66+
response,
67+
reverse(
68+
"record_a_mammogram:record_medical_information",
69+
kwargs={"id": appointment.pk},
70+
),
71+
)
72+
73+
def test_continue_to_imaging(self, client, appointment):
74+
response = client.post(
75+
reverse(
76+
"record_a_mammogram:ask_for_medical_information",
77+
kwargs={"id": appointment.pk},
78+
),
79+
{"decision": "no"},
80+
)
81+
assertRedirects(
82+
response,
83+
reverse(
84+
"record_a_mammogram:awaiting_images",
85+
kwargs={"id": appointment.pk},
86+
),
87+
)
88+
89+
def test_renders_invalid_form(self, client, appointment):
90+
response = client.post(
91+
reverse(
92+
"record_a_mammogram:ask_for_medical_information",
93+
kwargs={"id": appointment.pk},
94+
),
95+
{},
96+
)
97+
assertContains(response, "There is a problem")
98+
5999

60-
def test_known_redirect(self, client):
100+
@pytest.mark.django_db
101+
class TestCheckIn:
102+
def test_known_redirect(self, client, appointment):
61103
response = client.post(
62-
reverse("record_a_mammogram:check_in", kwargs={"id": self.appointment.pk}),
104+
reverse("record_a_mammogram:check_in", kwargs={"id": appointment.pk}),
63105
{"next": "start-screening"},
64106
)
65107
assertRedirects(
66108
response,
67109
reverse(
68-
"record_a_mammogram:start_screening", kwargs={"id": self.appointment.pk}
110+
"record_a_mammogram:start_screening", kwargs={"id": appointment.pk}
69111
),
70112
)

manage_breast_screening/record_a_mammogram/views.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.views.generic import FormView
77

88
from manage_breast_screening.clinics.models import Appointment
9+
from manage_breast_screening.participants.models import Participant
910

1011
from ..clinics.models import Appointment
1112
from .forms import (
@@ -18,6 +19,8 @@
1819

1920
Status = Appointment.Status
2021

22+
APPOINTMENT_CANNOT_PROCEED = "Appointment cannot proceed"
23+
2124
logger = logging.getLogger(__name__)
2225

2326

@@ -111,12 +114,35 @@ def get_context_data(self, **kwargs):
111114
)
112115
return context
113116

117+
def get_context_data(self, **kwargs):
118+
context = super().get_context_data(**kwargs)
119+
id = self.kwargs["id"]
120+
participant = Participant.objects.get(screeningepisode__appointment__id=id)
121+
122+
context.update(
123+
{
124+
"participant": participant,
125+
"caption": participant.full_name,
126+
"title": "Medical information",
127+
"decision_legend": "Has the participant shared any relevant medical information?",
128+
"cannot_continue_link": {
129+
"href": reverse(
130+
"record_a_mammogram:appointment_cannot_go_ahead",
131+
kwargs={"id": id},
132+
),
133+
"text": APPOINTMENT_CANNOT_PROCEED,
134+
},
135+
}
136+
)
137+
138+
return context
139+
114140
def form_valid(self, form):
115141
form.save()
116142

117143
appointment = self.get_appointment()
118144

119-
if form.cleaned_data["decision"] == "continue":
145+
if form.cleaned_data["decision"] == "yes":
120146
return redirect(
121147
"record_a_mammogram:record_medical_information", id=appointment.pk
122148
)
@@ -170,6 +196,7 @@ def appointment_cannot_go_ahead(request, id):
170196
"title": "Appointment cannot go ahead",
171197
"caption": participant.full_name,
172198
"form": form,
199+
"decision_legend": "Does the appointment need to be rescheduled?",
173200
},
174201
)
175202

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
{% extends "wizard_step.jinja" %}
22

3+
{% block stepContent %}
4+
<p>Ask them about any:</p>
5+
<ul class="nhsuk-list nhsuk-list--bullet">
6+
<li>history of breast cancer</li>
7+
<li>lump examinations or biopsies</li>
8+
<li>other procedures in the breast or chest area</li>
9+
<li>recent breast changes or symptoms</li>
10+
<li>breast features (such as moles) that may appear on an x-ray</li>
11+
<li>relevant medication (such as HRT)</li>
12+
</ul>
13+
{% endblock %}

manage_breast_screening/templates/wizard_step.jinja

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"errorMessage": errorMessage,
6767
"hint": {
6868
"html": decision_hint|e
69-
},
69+
} if decision_hint,
7070
"items": [
7171
{
7272
"value": form.decision.field.choices[0][0],
@@ -90,8 +90,12 @@
9090
</div>
9191
</div>
9292
</form>
93+
{% endif %}
9394

95+
{% if cannot_continue_link %}
96+
<p><a class="nhsuk-link nhsuk-link--no-visited-state" href="{{ cannot_continue_link.href }}">{{ cannot_continue_link.text }}</a></p>
9497
{% endif %}
9598
</div>
99+
96100
</div>
97101
{% endblock pageContent %}

0 commit comments

Comments
 (0)