Skip to content

Commit dcc1297

Browse files
authored
Merge branch 'master' into AMB-2289-extend-unit-test
2 parents 54b6675 + 0bc6f62 commit dcc1297

15 files changed

+759
-269
lines changed

backend/src/filter.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def replace_address_postal_codes(imms: dict) -> dict:
4747
# Remove all other keys in the address dictionary
4848
keys_to_remove = [key for key in address.keys() if key != "postalCode"]
4949
for key in keys_to_remove:
50-
del address[key]
50+
del address[key]
5151

5252
return imms
5353

@@ -59,23 +59,23 @@ def replace_organization_values(imms: dict) -> dict:
5959
"""
6060
for performer in imms.get("performer", [{}]):
6161
if performer.get("actor", {}).get("type") == "Organization":
62-
62+
6363
# Obfuscate or set the identifier value and system.
6464
identifier = performer["actor"].get("identifier", {})
6565
if identifier.get("value") is not None:
6666
identifier["value"] = "N2N9I"
6767
identifier["system"] = Urls.ods_organization_code
6868
if identifier.get("system") is not None:
6969
identifier["system"] = Urls.ods_organization_code
70-
70+
7171
# Ensure only 'system' and 'value' remain in identifier
7272
keys = {"system", "value"}
7373
keys_to_remove = [key for key in identifier.keys() if key not in keys]
7474
for key in keys_to_remove:
7575
del identifier[key]
76-
76+
7777
# Remove all other fields except 'identifier' in actor
78-
keys_to_remove = [key for key in performer["actor"].keys() if key not in ("identifier","type")]
78+
keys_to_remove = [key for key in performer["actor"].keys() if key not in ("identifier", "type")]
7979
for key in keys_to_remove:
8080
del performer["actor"][key]
8181

@@ -108,9 +108,6 @@ def search(imms: dict, patient_full_url: str, bundle_patient: dict = None) -> di
108108
imms.pop("contained")
109109
imms["patient"] = create_reference_to_patient_resource(patient_full_url, bundle_patient)
110110
imms = add_use_to_identifier(imms)
111-
# Location identifier system and value are to be overwritten
112-
# (for backwards compatibility with Immunisation History API, as agreed with VDS team)
113-
imms["location"] = {"identifier": {"system": "urn:iso:std:iso:3166", "value": "GB"}}
114111
return imms
115112

116113
@staticmethod

backend/tests/sample_data/completed_covid19_immunization_event_filtered_for_search_using_bundle_patient_resource.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@
4646
"display": "AstraZeneca Ltd"
4747
},
4848
"location": {
49+
"type": "Location",
4950
"identifier": {
50-
"value": "GB",
51-
"system": "urn:iso:std:iso:3166"
51+
"value": "X99999",
52+
"system": "https://fhir.nhs.uk/Id/ods-organization-code"
5253
}
5354
},
5455
"lotNumber": "4120Z001",

filenameprocessor/src/audit_table.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def upsert_audit_table(
5757
Key={AuditTableKeys.MESSAGE_ID: {"S": message_id}},
5858
UpdateExpression="SET #status = :status",
5959
ExpressionAttributeNames={"#status": "status"},
60-
# TODO: Should this be set to file_status? The status may be 'processed' due to an exception occuring
61-
ExpressionAttributeValues={":status": {"S": FileStatus.PROCESSING}},
60+
ExpressionAttributeValues={":status": {"S": file_status}},
6261
ConditionExpression="attribute_exists(message_id)",
6362
)
6463
logger.info("%s file set for processing, and the status successfully updated in audit table", file_key)

filenameprocessor/src/file_name_processor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ def handle_record(record) -> dict:
4444
logger.error("Error obtaining file_key: %s", error)
4545
return {"statusCode": 500, "message": "Failed to download file key", "error": str(error)}
4646

47-
# The lambda is unintentionally invoked when a file is moved into a different folder in the source bucket.
48-
# Excluding file keys containing a "/" is a workaround to prevent the lambda from processing files that
49-
# are not in the root of the source bucket.
50-
if "data-sources" in bucket_name and "/" not in file_key:
47+
if "data-sources" in bucket_name:
48+
49+
# The lambda is unintentionally invoked when a file is moved into a different folder in the source bucket.
50+
# Excluding file keys containing a "/" is a workaround to prevent the lambda from processing files that
51+
# are not in the root of the source bucket.
52+
if "/" in file_key:
53+
message = "File skipped due to duplicate lambda invoaction"
54+
return {"statusCode": 200, "message": message, "file_key": file_key}
5155

5256
# Set default values for file-specific variables
5357
message_id = "Message id was not created"

0 commit comments

Comments
 (0)