From af9a8c134e3fe1af49dc505043940ea107b85872 Mon Sep 17 00:00:00 2001 From: eatyourpeas Date: Tue, 19 Nov 2024 15:17:06 +0000 Subject: [PATCH] fix extreme centiles for template --- project/npda/templatetags/npda_tags.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/project/npda/templatetags/npda_tags.py b/project/npda/templatetags/npda_tags.py index 81429108..d8a3130a 100644 --- a/project/npda/templatetags/npda_tags.py +++ b/project/npda/templatetags/npda_tags.py @@ -123,14 +123,23 @@ def centile_sds(field): Returns the centile and SDS for a given field """ if field.id_for_label == "id_height": - return field.form.instance.height_centile, field.form.instance.height_sds + centile = field.form.instance.height_centile + sds = field.form.instance.height_sds elif field.id_for_label == "id_weight": - return field.form.instance.weight_centile, field.form.instance.weight_sds + centile = field.form.instance.weight_centile + sds = field.form.instance.weight_sds elif field.id_for_label == "id_bmi": - return field.form.instance.bmi_centile, field.form.instance.bmi_sds + centile = field.form.instance.bmi_centile + sds = field.form.instance.bmi_sds else: return None, None + if centile is not None and centile >= 99.9: + centile = " ≥99.6ᵗʰ" + elif centile is not None and centile < 0.4: + centile = "≤0.4ᵗʰ" + return centile, sds + @register.filter def join_with_comma(value):