Skip to content

Commit

Permalink
Adds support to specify and filter ration card category of a patient (#…
Browse files Browse the repository at this point in the history
…2201)

* Adds support to specify and filter ration card category of a patient

* Show ration card category in discharge summary

---------

Co-authored-by: Vignesh Hari <[email protected]>
  • Loading branch information
rithviknishad and vigneshhari authored May 28, 2024
1 parent de22042 commit 9edfed0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
3 changes: 2 additions & 1 deletion care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
),
),
]
11 changes: 10 additions & 1 deletion care/facility/models/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions care/templates/reports/patient_discharge_summary_pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ <h3 class="text-lg text-gray-900">
<p class="flex-grow">
<span class="text-sm text-gray-500">Address:</span> {{patient.address}}
</p>
<p class="flex-grow">
<span class="text-sm text-gray-500">Ration Card Category:</span> {{patient.get_ration_card_category_display|field_name_to_label}}
</p>
</div>
</div>

Expand Down
2 changes: 2 additions & 0 deletions care/utils/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
ConsultationDiagnosis,
ICD11Diagnosis,
)
from care.facility.models.patient import RationCardCategory
from care.users.models import District, State


Expand Down Expand Up @@ -275,6 +276,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
Expand Down

0 comments on commit 9edfed0

Please sign in to comment.