Skip to content

Commit

Permalink
Merge branch 'master' into issue#1274
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari authored Jul 20, 2023
2 parents c0f42ca + 40cf031 commit c65a1cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
15 changes: 10 additions & 5 deletions care/facility/api/serializers/shifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from care.facility.models import (
BREATHLESSNESS_CHOICES,
CATEGORY_CHOICES,
FACILITY_TYPES,
SHIFTING_STATUS_CHOICES,
VEHICLE_CHOICES,
Expand Down Expand Up @@ -217,6 +218,7 @@ class ShiftingSerializer(serializers.ModelSerializer):
last_edited_by_object = UserBaseMinimumSerializer(
source="last_edited_by", read_only=True
)
patient_category = ChoiceField(choices=CATEGORY_CHOICES, required=False)
ambulance_driver_name = serializers.CharField(
required=False, allow_null=True, allow_blank=True
)
Expand Down Expand Up @@ -327,8 +329,10 @@ def update(self, instance, validated_data):
new_instance = super().update(instance, validated_data)

patient = new_instance.patient
patient.last_consultation.category = self.initial_data["patient_category"]
patient.last_consultation.save()
patient_category = self.validated_data.pop("patient_category")
if patient.last_consultation and patient_category is not None:
patient.last_consultation.category = patient_category
patient.last_consultation.save(update_fields=["category"])

if (
"status" in validated_data
Expand Down Expand Up @@ -390,9 +394,10 @@ def create(self, validated_data):
patient.allow_transfer = True
patient.save()

if patient.last_consultation:
patient.last_consultation.category = self.initial_data["patient_category"]
patient.last_consultation.save()
patient_category = self.validated_data.pop("patient_category")
if patient.last_consultation and patient_category is not None:
patient.last_consultation.category = patient_category
patient.last_consultation.save(update_fields=["category"])

validated_data["origin_facility"] = patient.facility

Expand Down
2 changes: 1 addition & 1 deletion care/facility/models/patient_icmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def is_symptomatic(self):
def symptomatic_international_traveller(
self,
):
return (
return bool(
self.patient.countries_travelled
and len(self.patient.countries_travelled) != 0
and (
Expand Down
14 changes: 4 additions & 10 deletions care/facility/utils/summarisation/facility_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@


def facility_capacity_summary():
capacity_objects = FacilityCapacity.objects.all().select_related(
"facility",
"facility__state",
"facility__district",
"facility__local_body",
)
capacity_objects = FacilityCapacity.objects.all()
capacity_summary = {}
current_date = localtime(now()).replace(hour=0, minute=0, second=0, microsecond=0)

Expand Down Expand Up @@ -106,11 +101,10 @@ def facility_capacity_summary():
capacity_summary[facility_obj.id]["inventory"] = temp_inventory_summary_obj

for capacity_object in capacity_objects:
facility_id = capacity_object.facility.id
facility_id = capacity_object.facility_id
if facility_id not in capacity_summary:
capacity_summary[facility_id] = FacilitySerializer(
capacity_object.facility
).data
# This facility is either deleted or not active
continue
if "availability" not in capacity_summary[facility_id]:
capacity_summary[facility_id]["availability"] = []
capacity_summary[facility_id]["availability"].append(
Expand Down

0 comments on commit c65a1cb

Please sign in to comment.