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