From ac772b6c4c60f9cb87032e7988e009977fa7fc88 Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Mon, 3 Jun 2024 16:33:02 +0100 Subject: [PATCH 1/7] Adds tab background colour functionality to Visit form, correspondent to errors in or successful form fields --- project/npda/templates/npda/visit_form.html | 25 +++++++++++++++++---- project/npda/views/visit.py | 3 +++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index 07fcf9dc..7ca0d5a4 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -29,7 +29,12 @@ {% endfor %}
- +
{% for field_category in form.categories %} {% with field_category|colour_for_category as background_colour %} @@ -70,7 +75,12 @@ {% endfor %}
- +
{% for field_category in form.categories %} {% with field_category|colour_for_category as background_colour %} @@ -117,8 +127,15 @@ {% endfor %}
- -
+ +
{% for field_category in form.categories %} {% with field_category|colour_for_category as background_colour %} {% if field_category == "Hospital Admission" %} diff --git a/project/npda/views/visit.py b/project/npda/views/visit.py index c3b53011..dfa67843 100644 --- a/project/npda/views/visit.py +++ b/project/npda/views/visit.py @@ -84,6 +84,8 @@ def get_context_data(self, **kwargs): context["form_method"] = "update" visit_instance = Visit.objects.get(pk=self.kwargs["pk"]) visit_categories = get_visit_categories(visit_instance) + context["routine_measurements_categories"] = ["Measurements", "HBA1c", "Treatment", "CGM", "BP"] + context["annual_review_categories"] = ["Foot Care", "DECS", "ACR", "Cholesterol", "Thyroid", "Coeliac", "Psychology", "Smoking", "Dietician", "Sick Day Rules", "Immunisation (flu)"] context["visit_categories"] = visit_categories categories_with_errors = [] categories_without_errors = [] @@ -94,6 +96,7 @@ def get_context_data(self, **kwargs): categories_with_errors.append(category["category"]) context["categories_with_errors"] = categories_with_errors context["categories_without_errors"] = categories_without_errors + return context def get_success_url(self): From 21937d403a4b3f6f5b6a11fc1ce5be79639d1797 Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Mon, 3 Jun 2024 16:42:23 +0100 Subject: [PATCH 2/7] More minor style changes to Visit form (boldening font) --- project/npda/templates/npda/visit_form.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index 7ca0d5a4..9ca91f9e 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -29,7 +29,7 @@ {% endfor %}
- - - Date: Wed, 5 Jun 2024 11:09:48 +0100 Subject: [PATCH 3/7] Adds extra context, fixes tabbing to patient visit form, removes for loops --- project/npda/templates/npda/visit_form.html | 20 ++++++++++++++------ project/npda/views/visit.py | 10 +++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index 9ca91f9e..8dbc3080 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -30,9 +30,13 @@
@@ -76,9 +80,13 @@
diff --git a/project/npda/views/visit.py b/project/npda/views/visit.py index dfa67843..a61268e1 100644 --- a/project/npda/views/visit.py +++ b/project/npda/views/visit.py @@ -84,16 +84,24 @@ def get_context_data(self, **kwargs): context["form_method"] = "update" visit_instance = Visit.objects.get(pk=self.kwargs["pk"]) visit_categories = get_visit_categories(visit_instance) + context["visit_categories"] = visit_categories context["routine_measurements_categories"] = ["Measurements", "HBA1c", "Treatment", "CGM", "BP"] context["annual_review_categories"] = ["Foot Care", "DECS", "ACR", "Cholesterol", "Thyroid", "Coeliac", "Psychology", "Smoking", "Dietician", "Sick Day Rules", "Immunisation (flu)"] - context["visit_categories"] = visit_categories categories_with_errors = [] categories_without_errors = [] + routine_measurements_categories_with_errors = [] + annual_review_categories_with_errors = [] for category in visit_categories: if category["has_error"] == False: categories_without_errors.append(category["category"]) else: categories_with_errors.append(category["category"]) + if category["category"] in context["routine_measurements_categories"]: + routine_measurements_categories_with_errors.append(category["category"]) + elif category["category"] in context["annual_review_categories"]: + annual_review_categories_with_errors.append(category["category"]) + context["routine_measurements_categories_with_errors"] = routine_measurements_categories_with_errors + context["annual_review_categories_with_errors"] = annual_review_categories_with_errors context["categories_with_errors"] = categories_with_errors context["categories_without_errors"] = categories_without_errors From 2b4ccd71377f31a5c884c30b162bdf8cf81da85b Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Wed, 5 Jun 2024 12:12:20 +0100 Subject: [PATCH 4/7] Update Routine Measurements section with error border for those categories with errors --- project/npda/templates/npda/visit_form.html | 9 ++++++++- project/npda/templatetags/npda_tags.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index 8dbc3080..a4436368 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -43,7 +43,14 @@ {% for field_category in form.categories %} {% with field_category|colour_for_category as background_colour %} {% if field_category == "Measurements" or field_category == "HBA1c" or field_category == "Treatment" or field_category == "CGM" or field_category == "BP"%} -
+
{% for field in form %} {% if field.field.category == field_category %}
diff --git a/project/npda/templatetags/npda_tags.py b/project/npda/templatetags/npda_tags.py index a5ffc63d..89f63076 100644 --- a/project/npda/templatetags/npda_tags.py +++ b/project/npda/templatetags/npda_tags.py @@ -47,7 +47,7 @@ def colour_for_category(category): # returns a colour for a given category colours = [ {"category": VisitCategories.HBA1, "colour": "rcpch_red_light_tint2"}, - {"category": VisitCategories.MEASUREMENT, "colour": "rcpch_red"}, + {"category": VisitCategories.MEASUREMENT, "colour": "rcpch_vivid_green"}, {"category": VisitCategories.TREATMENT, "colour": "rcpch_orange"}, {"category": VisitCategories.CGM, "colour": "rcpch_orange_light_tint2"}, {"category": VisitCategories.BP, "colour": "rcpch_yellow"}, From 96a58d171dd44037886a19f72b85342dcc90168d Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Wed, 5 Jun 2024 12:13:33 +0100 Subject: [PATCH 5/7] Add small margin to top of form --- project/npda/templates/npda/visit_form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index a4436368..6cfc182c 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -39,7 +39,7 @@ {% endif %}" aria-label="Routine Measurements" checked /> -
+
{% for field_category in form.categories %} {% with field_category|colour_for_category as background_colour %} {% if field_category == "Measurements" or field_category == "HBA1c" or field_category == "Treatment" or field_category == "CGM" or field_category == "BP"%} From ba824b1f8f8a46f842d57bdd00a79c7ec08c58c1 Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Wed, 5 Jun 2024 12:18:34 +0100 Subject: [PATCH 6/7] Adds error box to Hospital admission and fixes tabbing --- project/npda/templates/npda/visit_form.html | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index 6cfc182c..aa460776 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -44,12 +44,12 @@ {% with field_category|colour_for_category as background_colour %} {% if field_category == "Measurements" or field_category == "HBA1c" or field_category == "Treatment" or field_category == "CGM" or field_category == "BP"%}
{% for field in form %} {% if field.field.category == field_category %} @@ -144,9 +144,9 @@
+
{% for field in form %} {% if field.field.category == field_category %}
From 12fea19c8ff08d7d00c7190210cb6785f1c2c8a0 Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Wed, 5 Jun 2024 13:58:05 +0100 Subject: [PATCH 7/7] improves code readability of class attributes where conditionals are present --- project/npda/templates/npda/visit_form.html | 104 +++++++++++--------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index aa460776..ffe0c9bb 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -100,12 +100,28 @@ {% for field_category in form.categories %} {% with field_category|colour_for_category as background_colour %} {% if field_category == "Foot Care" or field_category == "DECS" or field_category == "ACR" or field_category == "Cholesterol" or field_category == "Thyroid" or field_category == "Coeliac" or field_category == "Psychology" or field_category == "Smoking" or field_category == "Dietician" or field_category == "Sick Day Rules" or field_category == "Immunisation (flu)" %} -
+
{{field_category}}
-
+
{% for field in form %} {% if field.field.category == field_category %}
@@ -151,50 +167,50 @@ "/>
- {% for field_category in form.categories %} - {% with field_category|colour_for_category as background_colour %} - {% if field_category == "Hospital Admission" %} -
- {% for field in form %} - {% if field.field.category == field_category %} -
-
- -
-
- {% if field.field.widget|is_select %} - - {% elif field.field.widget|is_dateinput %} - - - - {% else %} - + {% for field_category in form.categories %} + {% with field_category|colour_for_category as background_colour %} + {% if field_category == "Hospital Admission" %} +
{{ error|escape }} -

- {% endfor %} -
+ {% if "Hospital Admission" in categories_with_errors %} + outline outline-8 outline-rcpch_red + {% endif %}" + > + {% for field in form %} + {% if field.field.category == field_category %} +
+
+ +
+
+ {% if field.field.widget|is_select %} + + {% elif field.field.widget|is_dateinput %} + + + + {% else %} + + {% endif %} + {% for error in field.errors %} +

+ {{ error|escape }} +

+ {% endfor %} +
+
+ {% endif %} + {% endfor %}
- {% endif %} - {% endfor %} -
- {% endif %} - {% endwith %} - {% endfor %} + {% endif %} + {% endwith %} + {% endfor %}