From 4cbe387f61c752da23463d6036d32f8c7120591c Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Thu, 6 Jun 2024 20:47:22 +0530 Subject: [PATCH] update serializer validation --- .../facility/api/serializers/patient_consultation.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/care/facility/api/serializers/patient_consultation.py b/care/facility/api/serializers/patient_consultation.py index 86ffd6ad7e..6c0796328a 100644 --- a/care/facility/api/serializers/patient_consultation.py +++ b/care/facility/api/serializers/patient_consultation.py @@ -902,8 +902,10 @@ def validate(self, attrs): "Only Home Facility Staff can create consent for a Consultation" ) - if attrs.get("type") == ConsentType.PATIENT_CODE_STATUS and not attrs.get( - "patient_code_status" + if ( + attrs.get("type", None) + and attrs.get("type") == ConsentType.PATIENT_CODE_STATUS + and not attrs.get("patient_code_status") ): raise ValidationError( { @@ -913,8 +915,10 @@ def validate(self, attrs): } ) - if attrs.get("type") != ConsentType.PATIENT_CODE_STATUS and attrs.get( - "patient_code_status" + if ( + attrs.get("type", None) + and attrs["type"] != ConsentType.PATIENT_CODE_STATUS + and attrs.get("patient_code_status") ): raise ValidationError( {