Skip to content

Commit 44e1618

Browse files
shivankackersainakvigneshhari
authored
Show error if doctor is not linked to the consultation facility (#2309)
* 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 <mail@singhaakash.dev> * Fix linting --------- Co-authored-by: Aakash Singh <mail@singhaakash.dev> Co-authored-by: Vignesh Hari <14056798+vigneshhari@users.noreply.github.com> Co-authored-by: vigneshhari <vichuhari100@gmail.com>
1 parent 2bcb20a commit 44e1618

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

care/facility/api/serializers/patient_consultation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,12 @@ def validate(self, attrs):
630630
and self.instance.facility
631631
or validated["patient"].facility
632632
)
633+
# Check if the Doctor is associated with the Facility (.facilities)
634+
if not treating_physician.facilities.filter(id=facility.id).exists():
635+
raise ValidationError(
636+
"The treating doctor is no longer linked to this facility. Please update the respective field in the form before proceeding."
637+
)
638+
633639
if (
634640
treating_physician.home_facility
635641
and treating_physician.home_facility != facility

0 commit comments

Comments
 (0)