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

updates for Shifting status: Canceled #1272

Merged
merged 4 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions care/facility/api/serializers/shifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ShiftingSerializer(serializers.ModelSerializer):
"TRANSFER IN PROGRESS",
"COMPLETED",
"PATIENT EXPIRED",
"CANCELLED",
]
]

Expand All @@ -90,6 +91,7 @@ class ShiftingSerializer(serializers.ModelSerializer):
# "TRANSFER IN PROGRESS",
"COMPLETED",
# "PATIENT EXPIRED",
# "CANCELLED",
]
]

Expand All @@ -107,6 +109,7 @@ class ShiftingSerializer(serializers.ModelSerializer):
"TRANSFER IN PROGRESS",
# "COMPLETED",
"PATIENT EXPIRED",
"CANCELLED",
]
]

Expand All @@ -124,6 +127,7 @@ class ShiftingSerializer(serializers.ModelSerializer):
# "TRANSFER IN PROGRESS",
"COMPLETED",
# "PATIENT EXPIRED",
# "CANCELLED",
]
]

Expand Down Expand Up @@ -209,6 +213,11 @@ def validate_shifting_approving_facility(self, value):
return value

def update(self, instance, validated_data):
if instance.status == REVERSE_SHIFTING_STATUS_CHOICES["CANCELLED"]:
raise ValidationError("Permission Denied, Shifting request was cancelled.")
elif instance.status == REVERSE_SHIFTING_STATUS_CHOICES["COMPLETED"]:
raise ValidationError("Permission Denied, Shifting request was completed.")

# Dont allow editing origin or patient
validated_data.pop("orgin_facility")
validated_data.pop("patient")
Expand All @@ -231,6 +240,11 @@ def update(self, instance, validated_data):

if "status" in validated_data:
status = validated_data["status"]
if status == REVERSE_SHIFTING_STATUS_CHOICES[
"CANCELLED"
] and not has_facility_permission(user, instance.origin_facility):
raise ValidationError({"status": ["Permission Denied"]})

if settings.PEACETIME_MODE:
if (
status in self.PEACETIME_SHIFTING_STATUS
Expand Down
1 change: 1 addition & 0 deletions care/facility/models/shifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
(70, "TRANSFER IN PROGRESS"),
(80, "COMPLETED"),
(90, "PATIENT EXPIRED"),
(100, "CANCELLED"),
)

VEHICLE_CHOICES = [
Expand Down