From c208c46231aaac7a606cb0eeec44685bec363e83 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Sat, 22 Apr 2023 23:02:39 +0530 Subject: [PATCH] Add additional fields in shifting form (#1265) Add additional fields for shifting form --- care/facility/api/serializers/shifting.py | 26 ++++++++++++-- .../migrations/0349_auto_20230422_2058.py | 34 +++++++++++++++++++ .../migrations/0350_auto_20230422_2114.py | 28 +++++++++++++++ care/facility/models/shifting.py | 15 ++++++-- 4 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 care/facility/migrations/0349_auto_20230422_2058.py create mode 100644 care/facility/migrations/0350_auto_20230422_2114.py diff --git a/care/facility/api/serializers/shifting.py b/care/facility/api/serializers/shifting.py index e02a7dbd03..0707d239f0 100644 --- a/care/facility/api/serializers/shifting.py +++ b/care/facility/api/serializers/shifting.py @@ -11,6 +11,7 @@ ) from care.facility.models import ( BREATHLESSNESS_CHOICES, + CATEGORY_CHOICES, FACILITY_TYPES, SHIFTING_STATUS_CHOICES, VEHICLE_CHOICES, @@ -24,6 +25,9 @@ from care.users.api.serializers.user import UserBaseMinimumSerializer from care.utils.notification_handler import NotificationGenerator from care.utils.serializer.external_id_field import ExternalIdSerializerField +from care.utils.serializer.phonenumber_ispossible_field import ( + PhoneNumberIsPossibleField, +) from config.serializers import ChoiceField @@ -143,7 +147,9 @@ class ShiftingSerializer(serializers.ModelSerializer): patient_object = PatientListSerializer(source="patient", read_only=True) status = ChoiceField(choices=SHIFTING_STATUS_CHOICES) - breathlessness_level = ChoiceField(choices=BREATHLESSNESS_CHOICES, required=False) + breathlessness_level = ChoiceField( + choices=BREATHLESSNESS_CHOICES, required=False, allow_null=True + ) orgin_facility = ExternalIdSerializerField( queryset=Facility.objects.all(), allow_null=False, required=True @@ -169,14 +175,28 @@ class ShiftingSerializer(serializers.ModelSerializer): source="assigned_facility", read_only=True ) - assigned_facility_type = ChoiceField(choices=FACILITY_TYPES, required=False) - preferred_vehicle_choice = ChoiceField(choices=VEHICLE_CHOICES, required=False) + assigned_facility_type = ChoiceField( + choices=FACILITY_TYPES, required=False, allow_null=True + ) + preferred_vehicle_choice = ChoiceField( + choices=VEHICLE_CHOICES, required=False, allow_null=True + ) assigned_to_object = UserBaseMinimumSerializer(source="assigned_to", read_only=True) created_by_object = UserBaseMinimumSerializer(source="created_by", read_only=True) last_edited_by_object = UserBaseMinimumSerializer( source="last_edited_by", read_only=True ) + patient_category = ChoiceField(choices=CATEGORY_CHOICES, required=False) + ambulance_driver_name = serializers.CharField( + required=False, allow_null=True, allow_blank=True + ) + ambulance_phone_number = PhoneNumberIsPossibleField( + required=False, allow_null=True, allow_blank=True + ) + ambulance_number = serializers.CharField( + required=False, allow_null=True, allow_blank=True + ) def __init__(self, instance=None, **kwargs): if instance: diff --git a/care/facility/migrations/0349_auto_20230422_2058.py b/care/facility/migrations/0349_auto_20230422_2058.py new file mode 100644 index 0000000000..428eda53a3 --- /dev/null +++ b/care/facility/migrations/0349_auto_20230422_2058.py @@ -0,0 +1,34 @@ +# Generated by Django 2.2.11 on 2023-04-22 15:28 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('facility', '0348_merge_20230421_1917'), + ] + + operations = [ + migrations.AddField( + model_name='shiftingrequest', + name='ambulance_driver_name', + field=models.TextField(blank=True, default=''), + ), + migrations.AddField( + model_name='shiftingrequest', + name='ambulance_number', + field=models.TextField(blank=True, default=''), + ), + migrations.AddField( + model_name='shiftingrequest', + name='ambulance_phone_number', + field=models.CharField(blank=True, default='', max_length=14, validators=[django.core.validators.RegexValidator(code='invalid_mobile', message='Please Enter 10/11 digit mobile number or landline as 0', regex='^((\\+91|91|0)[\\- ]{0,1})?[456789]\\d{9}$')]), + ), + migrations.AddField( + model_name='shiftingrequest', + name='patient_category', + field=models.CharField(choices=[('Comfort', 'Comfort Care'), ('Stable', 'Stable'), ('Moderate', 'Abnormal'), ('Critical', 'Critical')], max_length=8, null=True), + ), + ] diff --git a/care/facility/migrations/0350_auto_20230422_2114.py b/care/facility/migrations/0350_auto_20230422_2114.py new file mode 100644 index 0000000000..13b1fe81ed --- /dev/null +++ b/care/facility/migrations/0350_auto_20230422_2114.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2.11 on 2023-04-22 15:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('facility', '0349_auto_20230422_2058'), + ] + + operations = [ + migrations.AlterField( + model_name='shiftingrequest', + name='assigned_facility_type', + field=models.IntegerField(blank=True, choices=[(1, 'Educational Inst'), (2, 'Private Hospital'), (3, 'Other'), (4, 'Hostel'), (5, 'Hotel'), (6, 'Lodge'), (7, 'TeleMedicine'), (8, 'Govt Hospital'), (9, 'Labs'), (800, 'Primary Health Centres'), (801, '24x7 Public Health Centres'), (802, 'Family Health Centres'), (803, 'Community Health Centres'), (820, 'Urban Primary Health Center'), (830, 'Taluk Hospitals'), (831, 'Taluk Headquarters Hospitals'), (840, 'Women and Child Health Centres'), (850, 'General hospitals'), (860, 'District Hospitals'), (870, 'Govt Medical College Hospitals'), (900, 'Co-operative hospitals'), (910, 'Autonomous healthcare facility'), (950, 'Corona Testing Labs'), (1000, 'Corona Care Centre'), (1010, 'COVID-19 Domiciliary Care Center'), (1100, 'First Line Treatment Centre'), (1200, 'Second Line Treatment Center'), (1300, 'Shifting Centre'), (1400, 'Covid Management Center'), (1500, 'Request Approving Center'), (1510, 'Request Fulfilment Center'), (1600, 'District War Room')], default=None, null=True), + ), + migrations.AlterField( + model_name='shiftingrequest', + name='breathlessness_level', + field=models.IntegerField(blank=True, choices=[(10, 'NOT SPECIFIED'), (15, 'NOT BREATHLESS'), (20, 'MILD'), (30, 'MODERATE'), (40, 'SEVERE')], default=10, null=True), + ), + migrations.AlterField( + model_name='shiftingrequest', + name='preferred_vehicle_choice', + field=models.IntegerField(blank=True, choices=[(10, 'D Level Ambulance'), (20, 'All double chambered Ambulance with EMT'), (30, 'Ambulance without EMT'), (40, 'Car'), (50, 'Auto-rickshaw')], default=None, null=True), + ), + ] diff --git a/care/facility/models/shifting.py b/care/facility/models/shifting.py index 81446f9b19..93143106fb 100644 --- a/care/facility/models/shifting.py +++ b/care/facility/models/shifting.py @@ -7,6 +7,7 @@ pretty_boolean, reverse_choices, ) +from care.facility.models.patient_base import CATEGORY_CHOICES from care.users.models import User, phone_number_regex SHIFTING_STATUS_CHOICES = ( @@ -54,7 +55,7 @@ class ShiftingRequest(FacilityBaseModel): related_name="shifting_approving_facility", ) assigned_facility_type = models.IntegerField( - choices=FACILITY_TYPES, default=None, null=True + choices=FACILITY_TYPES, default=None, null=True, blank=True ) assigned_facility = models.ForeignKey( "Facility", @@ -71,7 +72,7 @@ class ShiftingRequest(FacilityBaseModel): reason = models.TextField(default="", blank=True) vehicle_preference = models.TextField(default="", blank=True) preferred_vehicle_choice = models.IntegerField( - choices=VEHICLE_CHOICES, default=None, null=True + choices=VEHICLE_CHOICES, default=None, null=True, blank=True ) comments = models.TextField(default="", blank=True) refering_facility_contact_name = models.TextField(default="", blank=True) @@ -84,7 +85,7 @@ class ShiftingRequest(FacilityBaseModel): ) breathlessness_level = models.IntegerField( - choices=BREATHLESSNESS_CHOICES, default=10, null=False, blank=False + choices=BREATHLESSNESS_CHOICES, default=10, null=True, blank=True ) is_assigned_to_user = models.BooleanField(default=False) @@ -94,6 +95,14 @@ class ShiftingRequest(FacilityBaseModel): null=True, related_name="shifting_assigned_to", ) + patient_category = models.CharField( + choices=CATEGORY_CHOICES, max_length=8, blank=False, null=True + ) + ambulance_driver_name = models.TextField(default="", blank=True) + ambulance_phone_number = models.CharField( + max_length=14, validators=[phone_number_regex], default="", blank=True + ) + ambulance_number = models.TextField(default="", blank=True) created_by = models.ForeignKey( User, on_delete=models.SET_NULL,