Skip to content

Commit

Permalink
update serializer validation
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Jun 6, 2024
1 parent 5841662 commit 4cbe387
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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(
{
Expand Down

0 comments on commit 4cbe387

Please sign in to comment.