Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
sainak marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -32,6 +32,7 @@
ConsultationDiagnosis,
ICD11Diagnosis,
)
from care.facility.models.patient import RationCardCategory
from care.users.models import District, State


Expand Down Expand Up @@ -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
Expand Down
Loading