From 9f62e7a38febe4bc90f56aa66d247805569f1559 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:45:46 +0530 Subject: [PATCH 1/2] Ignore admission date during discharge process if not provided (#1475) --- care/facility/api/serializers/patient_consultation.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/care/facility/api/serializers/patient_consultation.py b/care/facility/api/serializers/patient_consultation.py index 47bff65326..0c785232ca 100644 --- a/care/facility/api/serializers/patient_consultation.py +++ b/care/facility/api/serializers/patient_consultation.py @@ -437,7 +437,10 @@ def validate(self, attrs): raise ValidationError( {"death_datetime": "This field value cannot be in the future."} ) - if attrs.get("death_datetime") < self.instance.admission_date: + if ( + self.instance.admission_date + and attrs.get("death_datetime") < self.instance.admission_date + ): raise ValidationError( { "death_datetime": "This field value cannot be before the admission date." @@ -454,7 +457,10 @@ def validate(self, attrs): raise ValidationError( {"discharge_date": "This field value cannot be in the future."} ) - elif attrs.get("discharge_date") < self.instance.admission_date: + elif ( + self.instance.admission_date + and attrs.get("discharge_date") < self.instance.admission_date + ): raise ValidationError( { "discharge_date": "This field value cannot be before the admission date." From c11bef11eae1324599cbc5707ad5d593624cc3ab Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 27 Jul 2023 15:25:55 +0000 Subject: [PATCH 2/2] Shifting: Skip changing `last_consultation.category` if `patient_category` is not present in `validated_data` (#1481) --- care/facility/api/serializers/shifting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/care/facility/api/serializers/shifting.py b/care/facility/api/serializers/shifting.py index 8be8fc8863..8951a7691b 100644 --- a/care/facility/api/serializers/shifting.py +++ b/care/facility/api/serializers/shifting.py @@ -329,7 +329,7 @@ def update(self, instance, validated_data): new_instance = super().update(instance, validated_data) patient = new_instance.patient - patient_category = validated_data.pop("patient_category") + patient_category = validated_data.pop("patient_category", None) if patient.last_consultation and patient_category is not None: patient.last_consultation.category = patient_category patient.last_consultation.save(update_fields=["category"]) @@ -394,7 +394,7 @@ def create(self, validated_data): patient.allow_transfer = True patient.save() - patient_category = validated_data.pop("patient_category") + patient_category = validated_data.pop("patient_category", None) if patient.last_consultation and patient_category is not None: patient.last_consultation.category = patient_category patient.last_consultation.save(update_fields=["category"])