From 84ead2ad6f6c0c96e1065983fa41c6bea612afdf Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Thu, 7 Dec 2023 23:27:50 +0530 Subject: [PATCH] Field to classify location as an ICU or Ward or Other (#1708) * Add WARD as a new room type choice in AssetLocation model * update tests --- care/facility/api/serializers/asset.py | 1 + .../0394_alter_assetlocation_location_type.py | 22 +++++++++++++++++++ care/facility/models/asset.py | 1 + .../facility/tests/test_asset_location_api.py | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 care/facility/migrations/0394_alter_assetlocation_location_type.py diff --git a/care/facility/api/serializers/asset.py b/care/facility/api/serializers/asset.py index d52c46fe34..984b4874c2 100644 --- a/care/facility/api/serializers/asset.py +++ b/care/facility/api/serializers/asset.py @@ -40,6 +40,7 @@ class AssetLocationSerializer(ModelSerializer): facility = FacilityBareMinimumSerializer(read_only=True) id = UUIDField(source="external_id", read_only=True) + location_type = ChoiceField(choices=AssetLocation.RoomTypeChoices) def validate_middleware_address(self, value): value = (value or "").strip() diff --git a/care/facility/migrations/0394_alter_assetlocation_location_type.py b/care/facility/migrations/0394_alter_assetlocation_location_type.py new file mode 100644 index 0000000000..d96bd8df14 --- /dev/null +++ b/care/facility/migrations/0394_alter_assetlocation_location_type.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.5 on 2023-11-13 08:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ( + "facility", + "0393_rename_diagnosis_patientconsultation_deprecated_diagnosis_and_more", + ), + ] + + operations = [ + migrations.AlterField( + model_name="assetlocation", + name="location_type", + field=models.IntegerField( + choices=[(1, "OTHER"), (10, "ICU"), (20, "WARD")], default=1 + ), + ), + ] diff --git a/care/facility/models/asset.py b/care/facility/models/asset.py index bbdf39f957..d3ead51c85 100644 --- a/care/facility/models/asset.py +++ b/care/facility/models/asset.py @@ -34,6 +34,7 @@ class AssetLocation(BaseModel, AssetsPermissionMixin): class RoomType(enum.Enum): OTHER = 1 ICU = 10 + WARD = 20 RoomTypeChoices = [(e.value, e.name) for e in RoomType] diff --git a/care/facility/tests/test_asset_location_api.py b/care/facility/tests/test_asset_location_api.py index b859823c1b..2fbb244553 100644 --- a/care/facility/tests/test_asset_location_api.py +++ b/care/facility/tests/test_asset_location_api.py @@ -36,6 +36,7 @@ def test_create_asset_location(self): sample_data = { "name": "Test Asset Location", "middleware_address": "example.com", + "location_type": "ICU", } response = self.client.post( f"/api/v1/facility/{self.facility.external_id}/asset_location/", @@ -51,6 +52,7 @@ def test_update_asset_location(self): sample_data = { "name": "Updated Test Asset Location", "middleware_address": "updated.example.com", + "location_type": "WARD", } response = self.client.patch( f"/api/v1/facility/{self.facility.external_id}/asset_location/{self.asset_location.external_id}/", @@ -66,6 +68,7 @@ def test_create_asset_location_invalid_middleware(self): sample_data = { "name": "Test Asset Location", "middleware_address": "https://invalid.middleware.///", + "location_type": "OTHER", } response = self.client.post( f"/api/v1/facility/{self.facility.external_id}/asset_location/",