Skip to content

Commit 7df9358

Browse files
committed
resolve failing test
1 parent 973c8a2 commit 7df9358

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

lambdas/id_sync/src/ieds_db_operations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def extract_patient_resource_from_item(item: dict) -> dict | None:
151151
if not isinstance(patient_resource, dict):
152152
return None
153153

154+
# Otherwise, check contained
154155
for response in patient_resource.get("contained", []):
155156
if isinstance(response, dict) and response.get("resourceType") == "Patient":
156157
return response

lambdas/id_sync/tests/test_record_processor.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,16 @@ def test_process_record_success_update_required(self):
6969
# Provide one IEDS item that will match demographics via demographics_match
7070
matching_item = {
7171
"Resource": {
72-
"resourceType": "Patient",
73-
"name": [{"given": ["John"], "family": "Doe"}],
74-
"gender": "male",
75-
"birthDate": "1980-01-01",
72+
"resourceType": "Immunization",
73+
"contained": [
74+
{
75+
"resourceType": "Patient",
76+
"id": "Pat1",
77+
"name": [{"given": ["John"], "family": "Doe"}],
78+
"gender": "male",
79+
"birthDate": "1980-01-01",
80+
}
81+
]
7682
}
7783
}
7884
self.mock_get_items_from_patient_id.return_value = [matching_item]
@@ -104,10 +110,16 @@ def test_process_record_demographics_mismatch_skips_update(self):
104110
# IEDS items exist but do not match demographics
105111
non_matching_item = {
106112
"Resource": {
107-
"resourceType": "Patient",
108-
"name": [{"given": ["Bob"], "family": "Jones"}],
109-
"gender": "male",
110-
"birthDate": "1990-01-01",
113+
"resourceType": "Immunization",
114+
"contained": [
115+
{
116+
"resourceType": "Patient",
117+
"id": "Pat2",
118+
"name": [{"given": ["Bob"], "family": "Jones"}],
119+
"gender": "male",
120+
"birthDate": "1990-01-01",
121+
}
122+
]
111123
}
112124
}
113125
self.mock_get_items_from_patient_id.return_value = [non_matching_item]
@@ -176,9 +188,15 @@ def test_body_is_string(self):
176188
}
177189
self.mock_get_items_from_patient_id.return_value = [{
178190
"Resource": {
179-
"resourceType": "Patient",
180-
"name": [{"given": ["A"], "family": "B"}],
181-
"gender": "female", "birthDate": "1990-01-01"
191+
"resourceType": "Immunization",
192+
"contained": [
193+
{
194+
"resourceType": "Patient",
195+
"id": "Pat3",
196+
"name": [{"given": ["A"], "family": "B"}],
197+
"gender": "female", "birthDate": "1990-01-01"
198+
}
199+
]
182200
}
183201
}]
184202
self.mock_ieds_update_patient_id.return_value = {"status": "success"}

0 commit comments

Comments
 (0)