Skip to content

Commit

Permalink
Add Telemedicine as a rounds type option (#1760)
Browse files Browse the repository at this point in the history
* Add TELEMEDICINE as a rounds type option

* Validate rounds_type for Telemedicine Rounds

* Update migrations

* update migrations
  • Loading branch information
Ashesh3 authored Dec 19, 2023
1 parent 5177552 commit 3063a58
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
26 changes: 20 additions & 6 deletions care/facility/api/serializers/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
from care.facility.models.bed import Bed
from care.facility.models.daily_round import DailyRound
from care.facility.models.notification import Notification
from care.facility.models.patient_base import CURRENT_HEALTH_CHOICES, SYMPTOM_CHOICES
from care.facility.models.patient_base import (
CURRENT_HEALTH_CHOICES,
SYMPTOM_CHOICES,
SuggestionChoices,
)
from care.users.api.serializers.user import UserBaseMinimumSerializer
from care.utils.notification_handler import NotificationGenerator
from care.utils.queryset.consultation import get_consultation_queryset
Expand Down Expand Up @@ -180,14 +184,24 @@ def create(self, validated_data):
# Authorisation Checks End

with transaction.atomic():
consultation = get_object_or_404(
get_consultation_queryset(self.context["request"].user).filter(
id=validated_data["consultation"].id
)
)
if (
validated_data.get("rounds_type")
== DailyRound.RoundsType.TELEMEDICINE.value
and consultation.suggestion != SuggestionChoices.DC
):
raise ValidationError(
{
"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:
consultation = get_object_or_404(
get_consultation_queryset(self.context["request"].user).filter(
id=validated_data["consultation"].id
)
)
last_objects = DailyRound.objects.filter(
consultation=consultation
).order_by("-created_date")
Expand Down
26 changes: 26 additions & 0 deletions care/facility/migrations/0403_alter_dailyround_rounds_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.6 on 2023-12-09 10:13

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("facility", "0402_patientconsultation_new_discharge_reason"),
]

operations = [
migrations.AlterField(
model_name="dailyround",
name="rounds_type",
field=models.IntegerField(
choices=[
(0, "NORMAL"),
(100, "VENTILATOR"),
(200, "ICU"),
(300, "AUTOMATED"),
(400, "TELEMEDICINE"),
],
default=0,
),
),
]
1 change: 1 addition & 0 deletions care/facility/models/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class RoundsType(enum.Enum):
VENTILATOR = 100
ICU = 200
AUTOMATED = 300
TELEMEDICINE = 400

RoundsTypeChoice = [(e.value, e.name) for e in RoundsType]
RoundsTypeDict = covert_choice_dict(RoundsTypeChoice)
Expand Down

0 comments on commit 3063a58

Please sign in to comment.