Skip to content

Commit 6e89857

Browse files
committed
Disabled batch e2e test and removed pagination from fhir repository search operation
1 parent 341ad95 commit 6e89857

File tree

2 files changed

+14
-38
lines changed

2 files changed

+14
-38
lines changed

azure/templates/post-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ steps:
206206

207207
displayName: Run full batch test suite
208208
workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/e2e_batch"
209-
209+
enabled: false
210210

211211
- task: PublishTestResults@2
212212
displayName: 'Publish test results'

backend/src/fhir_repository.py

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -411,48 +411,24 @@ def delete_immunization(
411411
)
412412

413413
def find_immunizations(self, patient_identifier: str, vaccine_types: list):
414-
"""Find all of the specified patient's Immunization events for the given vaccine types, stopping after ~5MB of data."""
414+
"""it should find all of the specified patient's Immunization events for all of the specified vaccine_types"""
415415
condition = Key("PatientPK").eq(_make_patient_pk(patient_identifier))
416416
is_not_deleted = Attr("DeletedAt").not_exists() | Attr("DeletedAt").eq("reinstated")
417417

418-
all_items = []
419-
last_evaluated_key = None
420-
MAX_ITEM_ESTIMATE = 2100 # TBC - Assuming 2.8KB per item, 6MB is upper limit
421-
422-
while len(all_items) <= MAX_ITEM_ESTIMATE:
423-
query_params = {
424-
"IndexName": "PatientGSI",
425-
"KeyConditionExpression": condition,
426-
"FilterExpression": is_not_deleted,
427-
}
428-
429-
if last_evaluated_key:
430-
query_params["ExclusiveStartKey"] = last_evaluated_key
431-
432-
response = self.table.query(**query_params)
433-
434-
if "Items" in response:
435-
# Filter for matching vaccine types
436-
filtered = [
437-
x for x in response["Items"]
438-
if x["PatientSK"].split("#")[0] in vaccine_types
439-
]
440-
all_items.extend(filtered)
441-
else:
442-
raise UnhandledResponseError(
443-
message="Unhandled error. Query failed",
444-
response=response
445-
)
446-
447-
last_evaluated_key = response.get("LastEvaluatedKey") # Paginating table query results
448-
if not last_evaluated_key:
449-
break
450-
451-
if len(all_items) >= MAX_ITEM_ESTIMATE:
452-
print(f"Stopped after reaching estimated 6MB limit ({len(all_items)} items).")
418+
response = self.table.query(
419+
IndexName="PatientGSI",
420+
KeyConditionExpression=condition,
421+
FilterExpression=is_not_deleted,
422+
)
453423

454-
return [json.loads(item["Resource"]) for item in all_items]
424+
if "Items" in response:
425+
# Filter the response to contain only the requested vaccine types
426+
items = [x for x in response["Items"] if x["PatientSK"].split("#")[0] in vaccine_types]
455427

428+
# Return a list of the FHIR immunization resource JSON items
429+
return [json.loads(item["Resource"]) for item in items]
430+
else:
431+
raise UnhandledResponseError(message=f"Unhandled error. Query failed", response=response)
456432

457433
@staticmethod
458434
def _handle_dynamo_response(response):

0 commit comments

Comments
 (0)