Skip to content

Commit 465c365

Browse files
committed
VED-740: correcting parseobj response failure
1 parent 1c25877 commit 465c365

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

backend/src/fhir_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def get_immunization_by_identifier(self, aws_event) -> dict:
102102
try:
103103
if resource := self.fhir_service.get_immunization_by_identifier(
104104
identifiers, imms_vax_type_perms, identifier, element):
105-
return FhirController.create_response(200, json.dumps(resource))
105+
return FhirController.create_response(200, resource)
106106
except UnauthorizedVaxError as unauthorized:
107107
return self.create_response(403, unauthorized.to_operation_outcome())
108108

backend/src/models/utils/generic_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Generic utilities"""
22

33
import datetime
4-
4+
import json
55
from typing import Literal, Union, Optional, Dict, Any
66
from fhir.resources.R4B.bundle import (
77
Bundle as FhirBundle,
@@ -179,7 +179,8 @@ def form_json(response, _elements, identifier, baseurl):
179179
entry=[entry],
180180
total=1)
181181

182-
data = fhir_bundle.dict(by_alias=True)
182+
183+
data = json.loads(fhir_bundle.json(by_alias=True))
183184
data["total"] = data.pop("total")
184185
return data
185186

backend/tests/utils/test_generic_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Generic utils for tests"""
22

3-
import json
43
import unittest
54
from src.models.utils.generic_utils import form_json
65
from tests.utils.generic_utils import load_json_data
@@ -13,7 +12,7 @@ def setUp(self):
1312
self.response = {
1413
"resource": load_json_data("completed_covid19_immunization_event.json"),
1514
"id": "f10b59b3-fc73-4616-99c9-9e882ab31184",
16-
"version": 2,
15+
"version": "2",
1716
}
1817

1918
self.maxDiff = None
@@ -30,7 +29,7 @@ def test_identifier_only_returns_full_resource(self):
3029
out = form_json(self.response, None, self.identifier, self.baseurl)
3130
self.assertEqual(out["total"], 1)
3231
self.assertEqual(out["link"][0]["url"], f"{self.baseurl}?identifier={self.identifier}")
33-
self.assertDictEqual(json.loads(out["entry"][0]["resource"]), json.loads(self.response["resource"]))
32+
self.assertDictEqual(out["entry"][0]["resource"], self.response["resource"])
3433
self.assertEqual(out["entry"][0]["fullUrl"], f"{self.baseurl}/{self.response['id']}")
3534

3635
def test_identifier_with_id_element_truncates_to_id(self):

0 commit comments

Comments
 (0)