Skip to content

Commit

Permalink
fix extreme centiles for template
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourpeas committed Nov 19, 2024
1 parent 900af59 commit af9a8c1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions project/npda/templatetags/npda_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit af9a8c1

Please sign in to comment.