Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent destination facility from marking shift as complete #2114

Merged
merged 8 commits into from
Jun 24, 2024
13 changes: 12 additions & 1 deletion care/facility/api/serializers/shifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,18 @@ def update(self, instance, validated_data):
"status" in validated_data
and validated_data["status"] == REVERSE_SHIFTING_STATUS_CHOICES["COMPLETED"]
):
discharge_patient(instance.patient)
vigneshhari marked this conversation as resolved.
Show resolved Hide resolved
# Staff from the destination must not be able to mark the shift as complete.
destination_facility = (
validated_data["assigned_facility"] or instance.assigned_facility
sainak marked this conversation as resolved.
Show resolved Hide resolved
)
if destination_facility and user in destination_facility.users.all():
Ashesh3 marked this conversation as resolved.
Show resolved Hide resolved
raise ValidationError(
{
"status": [
"Permission Denied - Destination Facility cannot complete the shift"
]
}
)

old_status = instance.status
new_instance = super().update(instance, validated_data)
Expand Down
Loading