Skip to content

Commit

Permalink
Add additional fields in shifting form (#1265)
Browse files Browse the repository at this point in the history
Add additional fields for shifting form
  • Loading branch information
Ashesh3 authored Apr 22, 2023
1 parent 6650b79 commit c208c46
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 6 deletions.
26 changes: 23 additions & 3 deletions care/facility/api/serializers/shifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
)
from care.facility.models import (
BREATHLESSNESS_CHOICES,
CATEGORY_CHOICES,
FACILITY_TYPES,
SHIFTING_STATUS_CHOICES,
VEHICLE_CHOICES,
Expand All @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
34 changes: 34 additions & 0 deletions care/facility/migrations/0349_auto_20230422_2058.py
Original file line number Diff line number Diff line change
@@ -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<std code><phone number>', 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),
),
]
28 changes: 28 additions & 0 deletions care/facility/migrations/0350_auto_20230422_2114.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
15 changes: 12 additions & 3 deletions care/facility/models/shifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit c208c46

Please sign in to comment.