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] 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."