Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Mar 15, 2024
1 parent 8616f5c commit 379cf51
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,16 @@ def validate(self, attrs):
validated = super().validate(attrs)
# TODO Add Bed Authorisation Validation

if (
not self.instance
and "suggestion" in validated
and validated["suggestion"] == SuggestionChoices.A
):
if not self.instance and "suggestion" in validated:
suggestion = validated["suggestion"]
patient_no = validated.get("patient_no")
if not patient_no:
if suggestion == SuggestionChoices.A and not patient_no:
raise ValidationError(
{"ip_no": ["This field is required for admission."]}
{"patient_no": "This field is required for admission."}
)
if PatientConsultation.objects.filter(
if (
suggestion == SuggestionChoices.A or suggestion == SuggestionChoices.OP
) and PatientConsultation.objects.filter(
patient_no=patient_no,
facility=(
self.instance.facility
Expand All @@ -537,7 +536,9 @@ def validate(self, attrs):
),
).exists():
raise ValidationError(
"Patient number must be unique within the facility."
{
"patient_no": "Consultation with this IP/OP number already exists within the facility."
}
)

if (
Expand Down

0 comments on commit 379cf51

Please sign in to comment.