Skip to content

Commit 3110b6d

Browse files
committed
VED-740: Add meta for search by patient.identifier entries
1 parent f86fd26 commit 3110b6d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

backend/src/fhir_repository.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,12 @@ def find_immunizations(self, patient_identifier: str, vaccine_types: list):
408408
items = [x for x in raw_items if x["PatientSK"].split("#")[0] in vaccine_types]
409409

410410
# Return a list of the FHIR immunization resource JSON items
411-
final_resources = [json.loads(item["Resource"]) for item in items]
411+
final_resources = [{
412+
**json.loads(item["Resource"]),
413+
"meta": {"versionId": int(item.get("Version", 1))}
414+
}
415+
for item in items
416+
]
412417

413418
return final_resources
414419
else:

backend/tests/test_fhir_repository.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,16 +743,18 @@ def test_exclude_deleted(self):
743743

744744
def test_map_results_to_immunizations(self):
745745
"""it should map Resource list into a list of Immunizations"""
746-
imms1 = {"id": 1}
747-
imms2 = {"id": 2}
746+
imms1 = {"id": 1, "meta": {"versionId": 1}}
747+
imms2 = {"id": 2, "meta": {"versionId": 1}}
748748
items = [
749749
{
750750
"Resource": json.dumps(imms1),
751751
"PatientSK": "COVID19#some_other_text",
752+
"Version": "1"
752753
},
753754
{
754755
"Resource": json.dumps(imms2),
755756
"PatientSK": "COVID19#some_other_text",
757+
"Version": "1"
756758
},
757759
]
758760

0 commit comments

Comments
 (0)