Skip to content

Commit

Permalink
Drops support for cloning previous log update (#2127)
Browse files Browse the repository at this point in the history
* Drop support for cloning previous log update

* undo unrelated changes

---------

Co-authored-by: Vignesh Hari <vichuhari100@gmail.com>
  • Loading branch information
rithviknishad and vigneshhari committed May 15, 2024
1 parent a5171a8 commit 7726678
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 61 deletions.
60 changes: 0 additions & 60 deletions care/facility/api/serializers/daily_round.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from datetime import timedelta
from uuid import uuid4

from django.db import transaction
from django.utils import timezone
from django.utils.timezone import localtime, now
from rest_framework import serializers
from rest_framework.exceptions import ValidationError

from care.facility.events.handler import create_consultation_events

# from care.facility.api.serializers.bed import BedSerializer
from care.facility.models import (
CATEGORY_CHOICES,
COVID_CATEGORY_CHOICES,
Expand Down Expand Up @@ -89,10 +85,6 @@ class DailyRoundSerializer(serializers.ModelSerializer):
choices=DailyRound.InsulinIntakeFrequencyChoice, required=False
)

clone_last = serializers.BooleanField(
write_only=True, default=False, required=False
)

last_edited_by = UserBaseMinimumSerializer(read_only=True)
created_by = UserBaseMinimumSerializer(read_only=True)

Expand Down Expand Up @@ -201,58 +193,6 @@ def create(self, validated_data):
"rounds_type": "Telemedicine Rounds are only allowed for Domiciliary Care patients"
}
)
if "clone_last" in validated_data:
should_clone = validated_data.pop("clone_last")
if should_clone:
last_objects = DailyRound.objects.filter(
consultation=consultation
).order_by("-created_date")
if not last_objects.exists():
raise ValidationError(
{"daily_round": "No Daily Round record available to copy"}
)

if "rounds_type" not in validated_data:
raise ValidationError(
{"daily_round": "Rounds type is required to clone"}
)

rounds_type = validated_data.get("rounds_type")
if rounds_type == DailyRound.RoundsType.NORMAL.value:
fields_to_clone = [
"consultation_id",
"patient_category",
"taken_at",
"additional_symptoms",
"other_symptoms",
"physical_examination_info",
"other_details",
"bp",
"pulse",
"resp",
"temperature",
"rhythm",
"rhythm_detail",
"ventilator_spo2",
"consciousness_level",
]
cloned_daily_round_obj = DailyRound()
for field in fields_to_clone:
value = getattr(last_objects[0], field)
setattr(cloned_daily_round_obj, field, value)
else:
cloned_daily_round_obj = last_objects[0]

cloned_daily_round_obj.pk = None
cloned_daily_round_obj.rounds_type = rounds_type
cloned_daily_round_obj.created_by = self.context["request"].user
cloned_daily_round_obj.last_edited_by = self.context["request"].user
cloned_daily_round_obj.created_date = timezone.now()
cloned_daily_round_obj.modified_date = timezone.now()
cloned_daily_round_obj.external_id = uuid4()
cloned_daily_round_obj.save()
self.update_last_daily_round(cloned_daily_round_obj)
return self.update(cloned_daily_round_obj, validated_data)

if (
"action" in validated_data
Expand Down
1 change: 0 additions & 1 deletion care/facility/tests/test_patient_daily_rounds_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def setUpTestData(cls) -> None:
cls.consultation_with_bed.save()

cls.log_update = {
"clone_last": False,
"rounds_type": "NORMAL",
"patient_category": "Comfort",
"action": "DISCHARGE_RECOMMENDED",
Expand Down

0 comments on commit 7726678

Please sign in to comment.