Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field to classify location as an ICU or Ward or Other #1708

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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