From 7bf25176fcd22de38aafebc8883b95549813338b Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Fri, 31 May 2024 15:30:38 +0100 Subject: [PATCH 01/14] Redesigns visit form colouring and adds error message continuity from Patient Visit list to visit form --- project/npda/templates/npda/visit_form.html | 18 +++++++++--------- project/npda/views/visit.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/project/npda/templates/npda/visit_form.html b/project/npda/templates/npda/visit_form.html index ba47c119..26e9d0a9 100644 --- a/project/npda/templates/npda/visit_form.html +++ b/project/npda/templates/npda/visit_form.html @@ -2,8 +2,8 @@ {% load npda_tags %} {% csrf_token %} {% block content %} -
-
+
+
{{title}}
{% csrf_token %} @@ -29,10 +29,10 @@
-
+
{% 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" %} + {% 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 %} @@ -71,18 +71,18 @@
{% for field_category in form.categories %} {% with field_category|colour_for_category as background_colour %} - {% if field_category == "BP" or 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)" %} -
+ {% 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 %}
- +
{% if field.field.widget|is_select %} diff --git a/project/npda/views/visit.py b/project/npda/views/visit.py index 2c120f94..7fab9caa 100644 --- a/project/npda/views/visit.py +++ b/project/npda/views/visit.py @@ -8,6 +8,7 @@ from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic import ListView from django.urls import reverse_lazy, reverse +import logging # Third party imports from two_factor.views.mixins import OTPRequiredMixin @@ -17,6 +18,8 @@ from ..forms.visit_form import VisitForm from ..general_functions import get_visit_categories +logger = logging.getLogger(__name__) + class PatientVisitsListView(LoginRequiredMixin, OTPRequiredMixin, ListView): model = Visit @@ -81,6 +84,21 @@ def get_context_data(self, **kwargs): context["title"] = "Edit Visit Details" context["button_title"] = "Edit Visit Details" 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 + categories_with_errors = [] + categories_without_errors = [] + for category in visit_categories: + print(category) + if category["has_error"] == False: + print("BELOW is category.category") + print(category["category"]) + categories_without_errors.append(category["category"]) + else: + 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 82fb02fc588b7446a5bd0e5df0afe1b163a2c4b8 Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Fri, 31 May 2024 15:32:22 +0100 Subject: [PATCH 02/14] Remove print statements from debugging, and remove logger --- project/npda/views/visit.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/project/npda/views/visit.py b/project/npda/views/visit.py index 7fab9caa..0cd5539a 100644 --- a/project/npda/views/visit.py +++ b/project/npda/views/visit.py @@ -8,7 +8,6 @@ from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic import ListView from django.urls import reverse_lazy, reverse -import logging # Third party imports from two_factor.views.mixins import OTPRequiredMixin @@ -18,7 +17,7 @@ from ..forms.visit_form import VisitForm from ..general_functions import get_visit_categories -logger = logging.getLogger(__name__) + class PatientVisitsListView(LoginRequiredMixin, OTPRequiredMixin, ListView): @@ -90,10 +89,7 @@ def get_context_data(self, **kwargs): categories_with_errors = [] categories_without_errors = [] for category in visit_categories: - print(category) if category["has_error"] == False: - print("BELOW is category.category") - print(category["category"]) categories_without_errors.append(category["category"]) else: categories_with_errors.append(category["category"]) From 82da30b1363bd72284c1b9f00d4e1a976f2760b8 Mon Sep 17 00:00:00 2001 From: Danny Cowen Date: Fri, 31 May 2024 10:22:30 +0100 Subject: [PATCH 03/14] Adds hyperscript --- project/npda/templates/base.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/npda/templates/base.html b/project/npda/templates/base.html index 28ac006f..5022e36c 100644 --- a/project/npda/templates/base.html +++ b/project/npda/templates/base.html @@ -19,15 +19,16 @@ +