From 1ec78d403757a0c502daf895592db4c48b3ea727 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 28 May 2024 12:12:16 +0530 Subject: [PATCH 1/2] Adds support to specify and filter ration card category of a patient --- care/facility/api/viewsets/patient.py | 3 +- ...istration_ration_card_category_and_more.py | 38 +++++++++++++++++++ care/facility/models/patient.py | 11 +++++- care/utils/tests/test_utils.py | 2 + 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 care/facility/migrations/0439_historicalpatientregistration_ration_card_category_and_more.py diff --git a/care/facility/api/viewsets/patient.py b/care/facility/api/viewsets/patient.py index a79360d76c..9f02e535d0 100644 --- a/care/facility/api/viewsets/patient.py +++ b/care/facility/api/viewsets/patient.py @@ -73,7 +73,7 @@ ConditionVerificationStatus, ) from care.facility.models.notification import Notification -from care.facility.models.patient import PatientNotesEdit +from care.facility.models.patient import PatientNotesEdit, RationCardCategory from care.facility.models.patient_base import ( DISEASE_STATUS_DICT, NewDischargeReasonEnum, @@ -124,6 +124,7 @@ class PatientFilterSet(filters.FilterSet): method="filter_by_category", choices=CATEGORY_CHOICES, ) + ration_card_category = filters.ChoiceFilter(choices=RationCardCategory.choices) def filter_by_category(self, queryset, name, value): if value: diff --git a/care/facility/migrations/0439_historicalpatientregistration_ration_card_category_and_more.py b/care/facility/migrations/0439_historicalpatientregistration_ration_card_category_and_more.py new file mode 100644 index 0000000000..e40f20b2cc --- /dev/null +++ b/care/facility/migrations/0439_historicalpatientregistration_ration_card_category_and_more.py @@ -0,0 +1,38 @@ +# Generated by Django 4.2.8 on 2024-05-28 05:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("facility", "0438_alter_dailyround_patient_category_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="historicalpatientregistration", + name="ration_card_category", + field=models.CharField( + choices=[ + ("NO_CARD", "Non-card holder"), + ("BPL", "BPL"), + ("APL", "APL"), + ], + max_length=8, + null=True, + ), + ), + migrations.AddField( + model_name="patientregistration", + name="ration_card_category", + field=models.CharField( + choices=[ + ("NO_CARD", "Non-card holder"), + ("BPL", "BPL"), + ("APL", "APL"), + ], + max_length=8, + null=True, + ), + ), + ] diff --git a/care/facility/models/patient.py b/care/facility/models/patient.py index 94a06f0f5f..9c30e76914 100644 --- a/care/facility/models/patient.py +++ b/care/facility/models/patient.py @@ -7,6 +7,7 @@ from django.db.models import Case, F, Func, JSONField, Value, When from django.db.models.functions import Coalesce, Now from django.utils import timezone +from django.utils.translation import gettext_lazy as _ from simple_history.models import HistoricalRecords from care.abdm.models import AbhaNumber @@ -43,6 +44,12 @@ from care.utils.models.validators import mobile_or_landline_number_validator +class RationCardCategory(models.TextChoices): + NON_CARD_HOLDER = "NO_CARD", _("Non-card holder") + BPL = "BPL", _("BPL") + APL = "APL", _("APL") + + class PatientRegistration(PatientBaseModel, PatientPermissionMixin): # fields in the PatientSearch model PATIENT_SEARCH_KEYS = [ @@ -140,7 +147,9 @@ class TestTypeEnum(enum.Enum): default="", verbose_name="Passport Number of Foreign Patients", ) - # aadhar_no = models.CharField(max_length=255, default="", verbose_name="Aadhar Number of Patient") + ration_card_category = models.CharField( + choices=RationCardCategory.choices, null=True, max_length=8 + ) is_medical_worker = models.BooleanField( default=False, verbose_name="Is the Patient a Medical Worker" diff --git a/care/utils/tests/test_utils.py b/care/utils/tests/test_utils.py index acb286f043..bc59e9b997 100644 --- a/care/utils/tests/test_utils.py +++ b/care/utils/tests/test_utils.py @@ -32,6 +32,7 @@ ConsultationDiagnosis, ICD11Diagnosis, ) +from care.facility.models.patient import RationCardCategory from care.users.models import District, State @@ -276,6 +277,7 @@ def get_patient_data(cls, district, state) -> dict: "date_of_receipt_of_information": make_aware( datetime(2020, 4, 1, 15, 30, 00) ), + "ration_card_category": RationCardCategory.NON_CARD_HOLDER, } @classmethod From b17d099242e8d19071a6a993256f98f3943b9ce2 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 28 May 2024 12:12:27 +0530 Subject: [PATCH 2/2] Show ration card category in discharge summary --- care/templates/reports/patient_discharge_summary_pdf.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/care/templates/reports/patient_discharge_summary_pdf.html b/care/templates/reports/patient_discharge_summary_pdf.html index 48c05155b1..dedb64803d 100644 --- a/care/templates/reports/patient_discharge_summary_pdf.html +++ b/care/templates/reports/patient_discharge_summary_pdf.html @@ -66,6 +66,9 @@

Address: {{patient.address}}

+

+ Ration Card Category: {{patient.get_ration_card_category_display|field_name_to_label}} +