Skip to content

Commit

Permalink
Show error if doctor is not linked to the consultation facility (#2309)
Browse files Browse the repository at this point in the history
* Show error if doctor is not linked to the consultation facility

* Don't allow save if home facility is not set

* Update care/facility/api/serializers/patient_consultation.py

Co-authored-by: Aakash Singh <[email protected]>

* Fix linting

---------

Co-authored-by: Aakash Singh <[email protected]>
Co-authored-by: Vignesh Hari <[email protected]>
Co-authored-by: vigneshhari <[email protected]>
  • Loading branch information
4 people authored Aug 25, 2024
1 parent 2bcb20a commit 44e1618
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ def validate(self, attrs):
and self.instance.facility
or validated["patient"].facility
)
# Check if the Doctor is associated with the Facility (.facilities)
if not treating_physician.facilities.filter(id=facility.id).exists():
raise ValidationError(
"The treating doctor is no longer linked to this facility. Please update the respective field in the form before proceeding."
)

if (
treating_physician.home_facility
and treating_physician.home_facility != facility
Expand Down

0 comments on commit 44e1618

Please sign in to comment.