Skip to content

Commit

Permalink
Field to classify location as an ICU or Ward or Other (#1708)
Browse files Browse the repository at this point in the history
* Add WARD as a new room type choice in
AssetLocation model

* update tests
  • Loading branch information
GokulramGHV authored Dec 7, 2023
1 parent 261d024 commit 84ead2a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions care/facility/api/serializers/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 22 additions & 0 deletions care/facility/migrations/0394_alter_assetlocation_location_type.py
Original file line number Diff line number Diff line change
@@ -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
),
),
]
1 change: 1 addition & 0 deletions care/facility/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
3 changes: 3 additions & 0 deletions care/facility/tests/test_asset_location_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand All @@ -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}/",
Expand All @@ -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/",
Expand Down

0 comments on commit 84ead2a

Please sign in to comment.