Skip to content

Commit

Permalink
Fix patient discharge_reason filter and add it to export (#1818)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Jan 11, 2024
1 parent 470ce0d commit 2133846
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 2 additions & 6 deletions care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,8 @@ def filter_by_bed_type(self, queryset, name, value):
field_name="last_consultation__current_bed__bed__bed_type",
choice_dict=REVERSE_BED_TYPES,
)
last_consultation_discharge_reason = filters.ChoiceFilter(
field_name="last_consultation__discharge_reason",
choices=DISCHARGE_REASON_CHOICES,
)
last_consultation_discharge_reason = filters.ChoiceFilter(
field_name="last_consultation__discharge_reason",
last_consultation__new_discharge_reason = filters.ChoiceFilter(
field_name="last_consultation__new_discharge_reason",
choices=NewDischargeReasonEnum.choices,
)
last_consultation_assigned_to = filters.NumberFilter(
Expand Down
7 changes: 4 additions & 3 deletions care/facility/models/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
BLOOD_GROUP_CHOICES,
DISEASE_STATUS_CHOICES,
REVERSE_CATEGORY_CHOICES,
REVERSE_DISCHARGE_REASON_CHOICES,
REVERSE_NEW_DISCHARGE_REASON_CHOICES,
REVERSE_ROUTE_TO_FACILITY_CHOICES,
)
from care.facility.models.patient_consultation import PatientConsultation
Expand Down Expand Up @@ -527,6 +527,7 @@ def annotate_diagnosis_ids(*args, **kwargs):
# Last Consultation Details
"last_consultation__suggestion": "Decision after consultation",
"last_consultation__category": "Category",
"last_consultation__new_discharge_reason": "Reason for discharge",
"last_consultation__discharge_date": "Date of discharge",
"last_consultation__discharge_date__time": "Time of discharge",
}
Expand Down Expand Up @@ -559,8 +560,8 @@ def format_diagnoses(diagnosis_ids):
lambda x: REVERSE_ROUTE_TO_FACILITY_CHOICES.get(x, "-")
),
"last_consultation__category": lambda x: REVERSE_CATEGORY_CHOICES.get(x, "-"),
"last_consultation__discharge_reason": (
lambda x: REVERSE_DISCHARGE_REASON_CHOICES.get(x, "-")
"last_consultation__new_discharge_reason": (
lambda x: REVERSE_NEW_DISCHARGE_REASON_CHOICES.get(x, "-")
),
"last_consultation__discharge_date": format_as_date,
"last_consultation__discharge_date__time": format_as_time,
Expand Down
1 change: 1 addition & 0 deletions care/facility/models/patient_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ class BedType(enum.Enum):
REVERSE_BED_TYPE_CHOICES = reverse_choices(BedTypeChoices)
REVERSE_ROUTE_TO_FACILITY_CHOICES = reverse_choices(RouteToFacility.choices)
REVERSE_DISCHARGE_REASON_CHOICES = reverse_choices(DISCHARGE_REASON_CHOICES)
REVERSE_NEW_DISCHARGE_REASON_CHOICES = reverse_choices(NEW_DISCHARGE_REASON_CHOICES)

0 comments on commit 2133846

Please sign in to comment.