Skip to content

Commit bed5535

Browse files
committed
Cater for malformed/missing identifier
1 parent c43ce02 commit bed5535

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lambdas/recordforwarder/src/service/fhir_batch_service.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212

1313
def uplift_legacy_identifier(immunization: dict):
1414
# This code the above constants can be safely removed once DPS carries out it's data migration to update legacy
15-
# identifiers as it will become redundant. Please see issue VED-904 for more information.
16-
identifier_system = immunization["identifier"][0]["system"]
15+
# identifiers as it should become redundant. However, it may be worth keeping in case legacy format identifiers are
16+
# received for some reason. Please see issue VED-904 for more information.
17+
identifier = immunization.get("identifier")
18+
19+
if identifier is None or len(identifier) == 0:
20+
# Return here to allow validation to raise appropriate error
21+
return
22+
23+
identifier_system = immunization.get("identifier")[0].get("system")
1724

1825
if identifier_system == TPP_V2_SUPPLIER_IDENTIFIER_SYSTEM:
1926
immunization["identifier"][0]["system"] = TPP_V5_SUPPLIER_IDENTIFIER_SYSTEM

0 commit comments

Comments
 (0)