Skip to content

Commit

Permalink
Shifting: Skip changing last_consultation.category if `patient_cate…
Browse files Browse the repository at this point in the history
…gory` is not present in `validated_data` (#1481)
  • Loading branch information
rithviknishad authored Jul 27, 2023
1 parent 9f62e7a commit c11bef1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions care/facility/api/serializers/shifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def update(self, instance, validated_data):
new_instance = super().update(instance, validated_data)

patient = new_instance.patient
patient_category = validated_data.pop("patient_category")
patient_category = validated_data.pop("patient_category", None)
if patient.last_consultation and patient_category is not None:
patient.last_consultation.category = patient_category
patient.last_consultation.save(update_fields=["category"])
Expand Down Expand Up @@ -394,7 +394,7 @@ def create(self, validated_data):
patient.allow_transfer = True
patient.save()

patient_category = validated_data.pop("patient_category")
patient_category = validated_data.pop("patient_category", None)
if patient.last_consultation and patient_category is not None:
patient.last_consultation.category = patient_category
patient.last_consultation.save(update_fields=["category"])
Expand Down

0 comments on commit c11bef1

Please sign in to comment.