Skip to content

Commit

Permalink
updates for assetbed boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
DraKen0009 committed Dec 28, 2024
1 parent 2e72d44 commit b0eb29e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion care/facility/api/serializers/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ class AssetActionSerializer(Serializer):
required=True,
)
data = JSONField(required=False)
options = JSONField(required=False)

class Meta:
fields = ("type", "data")
fields = ("type", "data", "options")


class DummyAssetOperateSerializer(Serializer):
Expand Down
2 changes: 1 addition & 1 deletion care/facility/api/serializers/bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def validate(self, attrs):
valid_asset_classes = [
member.name
for member in AssetClasses.all()
if member.value.can_be_linked_to_asset_bed()
if member.name == "HL7MONITOR"
]
if asset.asset_class not in valid_asset_classes:
raise ValidationError(
Expand Down
10 changes: 6 additions & 4 deletions care/utils/assetintegration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ def get_headers(self):

def _validate_response(self, response: requests.Response):
try:
if response.status_code >= status.HTTP_400_BAD_REQUEST:
raise APIException(response.text, response.status_code)
if response.status_code == status.HTTP_400_BAD_REQUEST:
raise ValidationError(response.text)
if response.status_code > status.HTTP_400_BAD_REQUEST:
raise APIException(response.text, str(response.status_code))
return response.json()

except requests.Timeout as e:
raise APIException({"error": "Request Timeout"}, 504) from e
raise APIException({"error": "Request Timeout"}, "504") from e

except json.decoder.JSONDecodeError as e:
raise APIException(
{"error": "Invalid Response"}, response.status_code
{"error": "Invalid Response"}, str(response.status_code)
) from e

def api_post(self, url, data=None, timeout=None):
Expand Down

0 comments on commit b0eb29e

Please sign in to comment.