Skip to content

Commit

Permalink
updates for Shifting status: Canceled (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak authored Apr 27, 2023
1 parent 80c6632 commit df7a4ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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 @@ -211,6 +215,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 @@ -233,6 +242,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

0 comments on commit df7a4ed

Please sign in to comment.