Skip to content

Commit

Permalink
treat all non admission consultations as OP consultations
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Mar 15, 2024
1 parent 15abfe1 commit 55b7bff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,19 @@ def validate(self, attrs):
validated = super().validate(attrs)
# TODO Add Bed Authorisation Validation

if not self.instance and "suggestion" in validated:
if (
not self.instance or validated.get("patient_no") != self.instance.patient_no
) and "suggestion" in validated:
suggestion = validated["suggestion"]
patient_no = validated.get("patient_no")

if suggestion == SuggestionChoices.A and not patient_no:
raise ValidationError(
{"patient_no": "This field is required for admission."}
)

if (
suggestion == SuggestionChoices.A or suggestion == SuggestionChoices.OP
suggestion == SuggestionChoices.A or patient_no is not None
) and PatientConsultation.objects.filter(
patient_no=patient_no,
facility=(
Expand Down

0 comments on commit 55b7bff

Please sign in to comment.