Skip to content

Commit 8064044

Browse files
committed
show breast cancer history cards on the medical info page
This introduces the *card content* for the innermost cards that display breast cancer history items within the medical history card. When there is more than one of these cards, they have card headings, Item 1, Item 2 etc, which affects the overall heading hierarchy. If there is only one, this heading is left out. In a future commit, I'll align the card part with the latest card from the design system, and move the change links into the card. At that point we may want to also remove the padding around the card content. The prototype is using a custom card design, so I'll see which customisations are still necessary after the new design system version is out.
1 parent 71e7091 commit 8064044

File tree

4 files changed

+51
-158
lines changed

4 files changed

+51
-158
lines changed

manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{% from "nhsuk/components/inset-text/macro.jinja" import insetText %}
55
{% from "nhsuk/components/summary-list/macro.jinja" import summaryList %}
66
{% from "components/participant-details/summary_list_rows.jinja" import last_mammogram_html %}
7+
{% from "mammograms/medical_information/medical_history/cards/breast_cancer_history_card.jinja" import breast_cancer_history_card %}
78

89
{% block step_content %}
910

@@ -64,15 +65,6 @@
6465
{% endcall %}
6566

6667
{% set medical_history_card_html %}
67-
{% set breast_cancer_history_html %}
68-
{% for presented_item in presenter.breast_cancer_history %}
69-
<a style="float: right" class="nhsuk-link nhsuk-link--no-visited-state" href="{{ presented_item.change_link.href}}">
70-
{{ presented_item.change_link.text }}<span class="nhsuk-u-visually-hidden">{{ presented_item.change_link.visually_hidden_text }}</span>
71-
</a><br>
72-
{{ summaryList(presented_item.summary_list_params) }}
73-
{% endfor %}
74-
{% endset %}
75-
7668
{% set mastectomy_or_lumpectomy_history_html %}
7769
{% for presented_item in presenter.mastectomy_or_lumpectomy_history %}
7870
<a style="float: right" class="nhsuk-link nhsuk-link--no-visited-state" href="{{ presented_item.change_link.href}}">
@@ -125,19 +117,10 @@
125117
{% endfor %}
126118
{% endset %}
127119

120+
{{ breast_cancer_history_card(presenter.breast_cancer_history) }}
121+
128122
{{ summaryList({
129123
"rows": [
130-
{
131-
"key": {
132-
"text": "Breast cancer history"
133-
},
134-
"value": {
135-
"html": breast_cancer_history_html
136-
},
137-
"actions": {
138-
"items": []
139-
}
140-
},
141124
{
142125
"key": {
143126
"text": "Implanted medical device history"
@@ -216,8 +199,8 @@
216199
}) }}
217200
{% endfor %}
218201
</div>
219-
220202
{% endset %}
203+
221204
{{ card({
222205
"heading": "Medical history",
223206
"descriptionHtml": medical_history_card_html
Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.urls import reverse
22

3-
from manage_breast_screening.core.template_helpers import multiline_content, nl2br
3+
from manage_breast_screening.core.template_helpers import nl2br
44
from manage_breast_screening.participants.models.medical_history.breast_cancer_history_item import (
55
BreastCancerHistoryItem,
66
)
@@ -12,19 +12,20 @@ def __init__(self, breast_cancer_history_item, counter=None):
1212
self.counter = counter
1313

1414
self.cancer_location = self._item.get_diagnosis_location_display()
15-
self.right_breast_procedures = self._item.get_right_breast_procedure_display()
16-
self.left_breast_procedures = self._item.get_left_breast_procedure_display()
15+
16+
self.right_breast_procedure = self._item.get_right_breast_procedure_display()
17+
self.left_breast_procedure = self._item.get_left_breast_procedure_display()
1718

1819
self.right_breast_other_surgery = self._format_multiple_choices(
1920
self._item.right_breast_other_surgery, BreastCancerHistoryItem.Surgery
2021
)
2122
self.left_breast_other_surgery = self._format_multiple_choices(
2223
self._item.left_breast_other_surgery, BreastCancerHistoryItem.Surgery
2324
)
24-
self.right_breast_treatment = self._format_multiple_choices(
25+
self.right_breast_treatments = self._format_multiple_choices(
2526
self._item.right_breast_treatment, BreastCancerHistoryItem.Treatment
2627
)
27-
self.left_breast_treatment = self._format_multiple_choices(
28+
self.left_breast_treatments = self._format_multiple_choices(
2829
self._item.left_breast_treatment, BreastCancerHistoryItem.Treatment
2930
)
3031
self.systemic_treatments = self._format_multiple_choices(
@@ -33,66 +34,8 @@ def __init__(self, breast_cancer_history_item, counter=None):
3334
)
3435
self.additional_details = nl2br(self._item.additional_details)
3536

36-
@property
37-
def summary_list_params(self):
38-
# This is a placeholder until we have a properly formatted table.
39-
return {
40-
"rows": [
41-
{
42-
"key": {"text": "Cancer location"},
43-
"value": {"html": self.cancer_location},
44-
},
45-
{
46-
"key": {"text": "Procedures"},
47-
"value": {
48-
"html": multiline_content(
49-
[
50-
f"Right breast: {self.right_breast_procedures}",
51-
f"Left breast: {self.left_breast_procedures}",
52-
]
53-
)
54-
},
55-
},
56-
{
57-
"key": {"text": "Other surgery"},
58-
"value": {
59-
"html": multiline_content(
60-
[
61-
f"Right breast: {self.right_breast_other_surgery}",
62-
f"Left breast: {self.left_breast_other_surgery}",
63-
]
64-
)
65-
},
66-
},
67-
{
68-
"key": {"text": "Treatment"},
69-
"value": {
70-
"html": multiline_content(
71-
[
72-
f"Right breast: {self.right_breast_treatment}",
73-
f"Left breast: {self.left_breast_treatment}",
74-
f"Systemic treatements: {self.systemic_treatments}",
75-
]
76-
)
77-
},
78-
},
79-
{
80-
"key": {"text": "Treatment location"},
81-
"value": {
82-
"html": self._item.get_intervention_location_display()
83-
+ ": "
84-
+ self._item.intervention_location_details
85-
},
86-
},
87-
{
88-
"key": {"text": "Additional details"},
89-
"value": {"html": self.additional_details},
90-
},
91-
],
92-
}
93-
9437
def _format_multiple_choices(self, choices, ChoiceClass):
95-
return ", ".join(ChoiceClass(choice).label for choice in choices)
38+
return [ChoiceClass(choice).label for choice in choices]
9639

9740
@property
9841
def change_link(self):
@@ -111,3 +54,10 @@ def change_link(self):
11154
else " breast cancer item"
11255
),
11356
}
57+
58+
@property
59+
def intervention_location(self):
60+
return {
61+
"type": self._item.get_intervention_location_display(),
62+
"details": self._item.intervention_location_details,
63+
}

manage_breast_screening/mammograms/tests/presenters/medical_history/test_breast_cancer_history_item_presenter.py

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
from manage_breast_screening.mammograms.presenters.medical_history.breast_cancer_history_item_presenter import (
24
BreastCancerHistoryItemPresenter,
35
)
@@ -10,69 +12,30 @@
1012

1113

1214
class TestBreastCancerHistoryItemPresenter:
13-
def test_single(self):
14-
item = BreastCancerHistoryItemFactory.build(
15+
@pytest.fixture
16+
def item(self):
17+
return BreastCancerHistoryItemFactory.build(
1518
diagnosis_location=BreastCancerHistoryItem.DiagnosisLocationChoices.RIGHT_BREAST,
1619
right_breast_procedure=BreastCancerHistoryItem.Procedure.LUMPECTOMY,
1720
intervention_location=BreastCancerHistoryItem.InterventionLocation.NHS_HOSPITAL,
1821
intervention_location_details="East Tester Hospital",
1922
additional_details="some details",
2023
)
2124

22-
presenter = BreastCancerHistoryItemPresenter(item)
23-
24-
assert presenter.summary_list_params == {
25-
"rows": [
26-
{
27-
"key": {
28-
"text": "Cancer location",
29-
},
30-
"value": {
31-
"html": "Right breast",
32-
},
33-
},
34-
{
35-
"key": {
36-
"text": "Procedures",
37-
},
38-
"value": {
39-
"html": "Right breast: Lumpectomy<br>Left breast: No procedure",
40-
},
41-
},
42-
{
43-
"key": {
44-
"text": "Other surgery",
45-
},
46-
"value": {
47-
"html": "Right breast: No other surgery<br>Left breast: No other surgery",
48-
},
49-
},
50-
{
51-
"key": {
52-
"text": "Treatment",
53-
},
54-
"value": {
55-
"html": "Right breast: No radiotherapy<br>Left breast: No radiotherapy<br>Systemic treatements: No systemic treatments",
56-
},
57-
},
58-
{
59-
"key": {
60-
"text": "Treatment location",
61-
},
62-
"value": {
63-
"html": "At an NHS hospital: East Tester Hospital",
64-
},
65-
},
66-
{
67-
"key": {
68-
"text": "Additional details",
69-
},
70-
"value": {
71-
"html": "some details",
72-
},
73-
},
74-
],
75-
}
25+
@pytest.fixture
26+
def presenter(self, item):
27+
return BreastCancerHistoryItemPresenter(item)
28+
29+
def test_attributes(self, presenter):
30+
assert presenter.cancer_location == "Right breast"
31+
assert presenter.right_breast_procedure == "Lumpectomy"
32+
assert presenter.left_breast_procedure == "No procedure"
33+
assert presenter.right_breast_other_surgery == ["No other surgery"]
34+
assert presenter.left_breast_other_surgery == ["No other surgery"]
35+
assert presenter.right_breast_treatments == ["No radiotherapy"]
36+
assert presenter.left_breast_treatments == ["No radiotherapy"]
37+
assert presenter.systemic_treatments == ["No systemic treatments"]
38+
assert presenter.additional_details == "some details"
7639

7740
def test_change_link(self):
7841
item = BreastCancerHistoryItemFactory.build()

manage_breast_screening/tests/system/clinical/test_breast_cancer_history.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ def then_i_am_back_on_the_medical_information_page(self):
115115
self.expect_url("mammograms:record_medical_information", pk=self.appointment.pk)
116116

117117
def and_the_history_item_is_added(self):
118-
key = self.page.locator(
119-
".nhsuk-summary-list__key",
120-
has=self.page.get_by_text("Breast cancer history", exact=True),
121-
)
122-
row = self.page.locator(".nhsuk-summary-list__row").filter(has=key)
118+
heading = self.page.get_by_role("heading").filter(has_text="Breast cancer")
119+
expect(heading).to_be_attached()
120+
121+
section = self.page.locator("section").filter(has=heading)
122+
expect(section).to_be_attached()
123+
124+
row = section.locator(".app-nested-info__row", has_text="Cancer location")
125+
123126
expect(row).to_contain_text("Right breast")
124127

125128
def and_the_message_says_device_added(self):
@@ -203,11 +206,10 @@ def when_i_select_breast_radiotherapy_in_right_breast(self):
203206
fieldset.get_by_label("Breast radiotherapy").click()
204207

205208
def and_the_history_item_shows_the_radiotherapy(self):
206-
key = self.page.locator(
207-
".nhsuk-summary-list__key",
208-
has=self.page.get_by_text("Breast cancer history", exact=True),
209-
)
210-
row = self.page.locator(".nhsuk-summary-list__row").filter(has=key)
209+
heading = self.page.get_by_role("heading").filter(has_text="Breast cancer")
210+
section = self.page.locator("section").filter(has=heading)
211+
row = section.locator(".app-nested-info__row", has_text="Treatment").first
212+
211213
expect(row).to_contain_text("Breast radiotherapy")
212214

213215
def and_the_message_says_breast_cancer_history_updated(self):
@@ -223,10 +225,5 @@ def and_i_click_delete_item(self):
223225
self.page.get_by_text("Delete item").click()
224226

225227
def and_the_history_item_is_gone(self):
226-
key = self.page.locator(
227-
".nhsuk-summary-list__key",
228-
has=self.page.get_by_text("Breast cancer history", exact=True),
229-
)
230-
row = self.page.locator(".nhsuk-summary-list__row").filter(has=key)
231-
expect(row).not_to_contain_text("Cancer location")
232-
expect(row.get_by_text("Change")).not_to_be_attached()
228+
heading = self.page.get_by_role("heading").filter(has_text="Breast cancer")
229+
expect(heading).not_to_be_attached()

0 commit comments

Comments
 (0)