Skip to content

Commit

Permalink
Fix patient discharge_reason filter and add it to export (#1820)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Jan 13, 2024
1 parent a92b60a commit e5ba880
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions care/facility/api/serializers/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,12 @@ def validate_date_of_birth(self, value):
def create(self, validated_data):
raise NotImplementedError

def save(self, **kwargs):
self.instance.facility = self.validated_data["facility"]
def update(self, instance, validated_data):
instance.facility = validated_data["facility"]

with transaction.atomic():
consultation = PatientConsultation.objects.filter(
patient=self.instance, discharge_date__isnull=True
patient=instance, discharge_date__isnull=True
).first()

if consultation:
Expand All @@ -470,7 +470,9 @@ def save(self, **kwargs):
ConsultationBed.objects.filter(
consultation=consultation, end_date__isnull=True
).update(end_date=now())
self.instance.save()

instance.save()
return instance


class PatientNotesSerializer(serializers.ModelSerializer):
Expand Down

0 comments on commit e5ba880

Please sign in to comment.