diff --git a/project/npda/templates/partials/patient_table.html b/project/npda/templates/partials/patient_table.html index 8b19b7c6..50f6895e 100644 --- a/project/npda/templates/partials/patient_table.html +++ b/project/npda/templates/partials/patient_table.html @@ -163,7 +163,7 @@ {% endif %} - {{ patient.nhs_number }} + {{ patient.nhs_number|format_nhs_number }} diff --git a/project/npda/templatetags/npda_tags.py b/project/npda/templatetags/npda_tags.py index da213dce..cc76e2f5 100644 --- a/project/npda/templatetags/npda_tags.py +++ b/project/npda/templatetags/npda_tags.py @@ -309,3 +309,10 @@ def get_item(dictionary:dict, key:str): @register.simple_tag def docs_url(): return settings.DOCS_URL + +@register.filter +def format_nhs_number(nhs_number): + if nhs_number and len(nhs_number) >= 10: + return f"{nhs_number[:3]} {nhs_number[3:6]} {nhs_number[6:]}" + + return nhs_number