diff --git a/care/facility/api/serializers/daily_round.py b/care/facility/api/serializers/daily_round.py index 5b9a005f0d..22a5f5dae7 100644 --- a/care/facility/api/serializers/daily_round.py +++ b/care/facility/api/serializers/daily_round.py @@ -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, @@ -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) @@ -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 diff --git a/care/facility/tests/test_patient_daily_rounds_api.py b/care/facility/tests/test_patient_daily_rounds_api.py index 07ccb87df6..7c5686275a 100644 --- a/care/facility/tests/test_patient_daily_rounds_api.py +++ b/care/facility/tests/test_patient_daily_rounds_api.py @@ -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",