From cfcdff2b2b48cd6b5b7037b1166934cfc790fe69 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Mon, 11 Dec 2023 20:52:01 +0530 Subject: [PATCH] Add new discharge reason field to PatientConsultation model --- ...atientconsultation_new_discharge_reason.py | 28 +++++++++++++++++++ care/facility/models/patient_base.py | 11 ++++++++ care/facility/models/patient_consultation.py | 7 +++++ 3 files changed, 46 insertions(+) create mode 100644 care/facility/migrations/0402_patientconsultation_new_discharge_reason.py diff --git a/care/facility/migrations/0402_patientconsultation_new_discharge_reason.py b/care/facility/migrations/0402_patientconsultation_new_discharge_reason.py new file mode 100644 index 0000000000..37ad8d8991 --- /dev/null +++ b/care/facility/migrations/0402_patientconsultation_new_discharge_reason.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.6 on 2023-12-11 13:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("facility", "0401_merge_20231208_0054"), + ] + + operations = [ + migrations.AddField( + model_name="patientconsultation", + name="new_discharge_reason", + field=models.SmallIntegerField( + blank=True, + choices=[ + (-1, "UNKNOWN"), + (1, "RECOVERED"), + (2, "REFERRED"), + (3, "EXPIRED"), + (4, "LAMA"), + ], + default=None, + null=True, + ), + ), + ] diff --git a/care/facility/models/patient_base.py b/care/facility/models/patient_base.py index 0fd2d40eab..e47e461100 100644 --- a/care/facility/models/patient_base.py +++ b/care/facility/models/patient_base.py @@ -81,6 +81,17 @@ def reverse_choices(choices): ] +class NewDiseaseReasonEnum(IntegerChoices): + UNKNOWN = -1, _("Unknown") + RECOVERED = 1, _("Recovered") + REFERRED = 2, _("Referred") + EXPIRED = 3, _("Expired") + LAMA = 4, _("LAMA") + + +NEW_DISCHARGE_REASON_CHOICES = [(e.value, e.name) for e in NewDiseaseReasonEnum] + + class DiseaseStatusEnum(enum.IntEnum): SUSPECTED = 1 POSITIVE = 2 diff --git a/care/facility/models/patient_consultation.py b/care/facility/models/patient_consultation.py index b5e1bb02b1..451504cea9 100644 --- a/care/facility/models/patient_consultation.py +++ b/care/facility/models/patient_consultation.py @@ -15,6 +15,7 @@ ) from care.facility.models.patient_base import ( DISCHARGE_REASON_CHOICES, + NEW_DISCHARGE_REASON_CHOICES, REVERSE_CATEGORY_CHOICES, REVERSE_COVID_CATEGORY_CHOICES, SYMPTOM_CHOICES, @@ -136,6 +137,12 @@ class PatientConsultation(PatientBaseModel, ConsultationRelatedPermissionMixin): blank=True, null=True, ) + new_discharge_reason = models.SmallIntegerField( + choices=NEW_DISCHARGE_REASON_CHOICES, + default=None, + blank=True, + null=True, + ) discharge_notes = models.TextField(default="", null=True, blank=True) discharge_prescription = JSONField( default=dict, null=True, blank=True