diff --git a/project/npda/templates/dashboard/components/cards/ethnicity_card.html b/project/npda/templates/dashboard/components/cards/ethnicity_card.html
index ec35fe46..f2860375 100644
--- a/project/npda/templates/dashboard/components/cards/ethnicity_card.html
+++ b/project/npda/templates/dashboard/components/cards/ethnicity_card.html
@@ -3,15 +3,21 @@
Ethnicity
{% endblock card_title%}
{% block card_body %}
-
+{% if charts.pt_ethnicity_tree_map_data.no_eligible_patients %}
+
+ No eligible patients.
+
+{% else %}
+
-
-
+
+
+{% endif %}
{% endblock %}
diff --git a/project/npda/views/dashboard/dashboard.py b/project/npda/views/dashboard/dashboard.py
index b006f2dd..7b31af21 100644
--- a/project/npda/views/dashboard/dashboard.py
+++ b/project/npda/views/dashboard/dashboard.py
@@ -325,6 +325,7 @@ def dashboard(request):
},
"pt_ethnicity_tree_map_data": json.dumps(
{
+ "no_eligible_patients": not pt_ethnicity_value_counts,
"data": pt_ethnicity_value_counts,
"parent_color_map": constants.ethnicities.ETHNICITY_PARENT_COLOR_MAP,
"child_parent_map": constants.ethnicities.ETHNICITY_CHILD_PARENT_MAP,
@@ -354,4 +355,6 @@ def dashboard(request):
"aggregation_level": "pdu",
}
+ print(f"!! {context['charts']['pt_ethnicity_tree_map_data']}")
+
return render(request, template_name=template, context=context)
diff --git a/project/npda/views/dashboard/helpers.py b/project/npda/views/dashboard/helpers.py
index 7b5df4d3..4eb6e813 100644
--- a/project/npda/views/dashboard/helpers.py
+++ b/project/npda/views/dashboard/helpers.py
@@ -722,9 +722,9 @@ def get_pt_demographic_value_counts(
"sex", "ethnicity", "index_of_multiple_deprivation_quintile"
)
sex_map = dict(SEX_TYPE)
- sex_counts = Counter(sex_map.get(item["sex"]) for item in all_values)
+ sex_counts = Counter(sex_map[item["sex"]] for item in all_values if item["sex"] in sex_map)
ethnicity_map = dict(ETHNICITIES)
- ethnicity_counts = Counter(ethnicity_map.get(item["ethnicity"]) for item in all_values)
+ ethnicity_counts = Counter(ethnicity_map[item["ethnicity"]] for item in all_values if item["ethnicity"] in ethnicity_map)
imd_map = {
1: "1st Quintile",
2: "2nd Quintile",