Skip to content

Commit 71e7091

Browse files
committed
create macros for breast cancer history item cards
These cards are displayed within the overall card for medical history, and are grouped under a section heading of "Breast cancer history". Since the design system card component is currently being updated, I've left the change link as a standalone link for now. When the new release is out, we'll move it into the card.
1 parent 2aa6f52 commit 71e7091

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{% from "components/nested-info-card/macro.jinja" import nestedInfoCard %}
2+
{% from "mammograms/medical_information/medical_history/cards/macros.jinja" import listWithDefault, itemWithDetails, paragraph %}
3+
4+
{% macro breast_cancer_history_card(breast_cancer_history) %}
5+
{% if breast_cancer_history %}
6+
<section>
7+
<h3 class="nhsuk-u-margin-bottom-2">Breast cancer</h3>
8+
{% endif %}
9+
{% for presented_item in breast_cancer_history %}
10+
{% set keyHeadingLevel = 5 if presented_item.counter else 4 %}
11+
12+
<!-- This will be replaced with the card's actions param, once the card updates are released. -->
13+
<a class="nhsuk-link nhsuk-link--no-visited-state" href="{{ presented_item.change_link.href }}">
14+
{{ presented_item.change_link.text }}<span class="nhsuk-u-visually-hidden">{{ presented_item.change_link.visually_hidden_text }}</span>
15+
</a>
16+
17+
{{
18+
nestedInfoCard({
19+
"card": {
20+
"heading": "Item " ~ presented_item.counter,
21+
"headingLevel": 4
22+
} if presented_item.counter else {},
23+
"headingLevel": keyHeadingLevel,
24+
"rows": [
25+
{
26+
"key": "Cancer location",
27+
"value": {
28+
"html": paragraph(presented_item.cancer_location)
29+
}
30+
},
31+
{
32+
"key": "Procedures",
33+
"value": {
34+
"rows": [
35+
{
36+
"columns": [
37+
{
38+
"heading": "Right breast",
39+
"html": paragraph(presented_item.right_breast_procedure)
40+
},
41+
{
42+
"heading": "Left breast",
43+
"html": paragraph(presented_item.left_breast_procedure)
44+
},
45+
]
46+
}
47+
]
48+
}
49+
},
50+
{
51+
"key": "Other surgery",
52+
"value": {
53+
"rows": [
54+
{
55+
"columns": [
56+
{
57+
"heading": "Right breast",
58+
"html": listWithDefault(presented_item.right_breast_other_surgery)
59+
},
60+
{
61+
"heading": "Left breast",
62+
"html": listWithDefault(presented_item.left_breast_other_surgery)
63+
},
64+
]
65+
}
66+
]
67+
}
68+
},
69+
{
70+
"key": "Treatment",
71+
"value": {
72+
"rows": [
73+
{
74+
"columns": [
75+
{
76+
"heading": "Right breast",
77+
"html": listWithDefault(presented_item.right_breast_treatments)
78+
},
79+
{
80+
"heading": "Left breast",
81+
"html": listWithDefault(presented_item.left_breast_treatments)
82+
},
83+
]
84+
},
85+
{
86+
"columns": [
87+
{
88+
"heading": "Systemic treatments",
89+
"html": listWithDefault(presented_item.systemic_treatments)
90+
}
91+
]
92+
}
93+
]
94+
}
95+
},
96+
{
97+
"key": "Treatment location",
98+
"value": {
99+
"html": itemWithDetails(presented_item.intervention_location)
100+
}
101+
},
102+
{
103+
"key": "Additional details",
104+
"value": {
105+
"html": paragraph(presented_item.additional_details)
106+
}
107+
} if presented_item.additional_details
108+
]
109+
})
110+
}}
111+
{% endfor %}
112+
{% if breast_cancer_history %}
113+
</section>
114+
{% endif %}
115+
{% endmacro %}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{# Present a plain list, or a default value if there are no items #}
2+
{% macro listWithDefault(items, default="None") %}
3+
{% if items %}
4+
<ul class="nhsuk-list">
5+
{% for item in items %}
6+
<li>{{ item }}</li>
7+
{% endfor %}
8+
</ul>
9+
{% else %}
10+
{{ default }}
11+
{% endif %}
12+
{% endmacro %}
13+
14+
{# Present an answer to a radio + details question #}
15+
{% macro itemWithDetails(item, default='Details not provided') %}
16+
{{ item.type }}
17+
{% if item.details %}
18+
<br>
19+
Details: {{ item.details }}
20+
{% elif default %}
21+
<br>
22+
{{ default }}
23+
{% endif %}
24+
{% endmacro %}
25+
26+
{% macro paragraph(item) %}
27+
<p>{{ item | nl2br }}</p>
28+
{% endmacro %}

0 commit comments

Comments
 (0)