Skip to content

Commit

Permalink
Merge pull request #81 from rcpch:77-add-flagging-of-errors-to-visit-…
Browse files Browse the repository at this point in the history
…form

Change design of Visit form to load errors into form
  • Loading branch information
eatyourpeas authored May 31, 2024
2 parents 1795337 + 82fb02f commit a86bf06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 9 additions & 9 deletions project/npda/templates/npda/visit_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{% load npda_tags %}
{% csrf_token %}
{% block content %}
<div class="bg-rcpch_light_blue py-8">
<div class="w-full max-w-3xl mx-auto px-2 py-4 m-2 shadow-md bg-white font-montserrat">
<div class="flex justify-center bg-white py-8">
<div class="w-full mx-96 px-2 py-4 m-2 shadow-md bg-white font-montserrat">
<strong>{{title}}</strong>
<form id="update-form" method="post" {% if form_method == "create" %} action="{% url 'visit-create' patient_id %}" {% else %} action="{% url 'visit-update' patient_id=patient_id pk=visit.pk %}" {% endif %}>
{% csrf_token %}
Expand All @@ -29,10 +29,10 @@

<div role="tablist" class="tabs tabs-bordered">
<input type="radio" name="my_tabs_1" role="tab" class="tab" aria-label="Routine&nbsp;Measurements" checked/>
<div role="tabpanel" class="tab-content bg-base-100 border-base-300 rounded-none p-6">
<div role="tabpanel" class="tab-content bg-base-100 border-base-300 rounded-none">
{% 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"%}
<div class="flex flex-col mb-6 {% if background_colour %} bg-{{background_colour}} {% endif %}">
{% for field in form %}
{% if field.field.category == field_category %}
Expand Down Expand Up @@ -71,18 +71,18 @@
<div role="tabpanel" class="tab-content bg-base-100 border-base-300 rounded-none p-6">
{% 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)" %}
<div class="collapse collapse-arrow my-2 bg-base-200">
{% 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)" %}
<div class="collapse collapse-arrow my-2 bg-base-200 rounded-none {% if field_category in categories_with_errors %} bg-rcpch_red {% elif field_category in categories_without_errors %} bg-rcpch_pink {% else %} bg-rcpch_dark_blue {% endif %}">
<input type="radio" name="my-accordion-3" checked="checked" />
<div class="collapse-title text-xl font-medium">
<div class="collapse-title text-xl font-medium text-white">
<strong>{{field_category}}</strong>
</div>
<div class="collapse-content flex flex-col mb-6 {% if background_colour %} bg-{{background_colour}} {% endif %}">
<div class="collapse-content flex flex-col mb-6 text-lg {% if field_category in categories_with_errors %} bg-rcpch_red {% elif field_category in categories_without_errors %} bg-rcpch_pink {% else %} bg-rcpch_dark_blue {% endif %}">
{% for field in form %}
{% if field.field.category == field_category %}
<div class="flex flex-row my-2 mx-2">
<div class="flex items-center justify-center md:w-1/3">
<label for="{{ field.id_for_label }}" class="{% if background_colour == "rcpch_dark_blue" %} text-white-700 {% else %} text-gray-700 {% endif %} block font-bold md:text-center mb-1 md:mb-0 pr-4"><small>{{ field.label }}</small></label>
<label for="{{ field.id_for_label }}" class="text-white block font-bold mb-1 md:mb-0 pr-4 text-left"><small>{{ field.label }}</small></label>
</div>
<div class="flex space-between md:w-2/3">
{% if field.field.widget|is_select %}
Expand Down
14 changes: 14 additions & 0 deletions project/npda/views/visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from ..general_functions import get_visit_categories




class PatientVisitsListView(LoginRequiredMixin, OTPRequiredMixin, ListView):
model = Visit
template_name = "visits.html"
Expand Down Expand Up @@ -81,6 +83,18 @@ 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:
if category["has_error"] == False:
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):
Expand Down

0 comments on commit a86bf06

Please sign in to comment.