diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/UpdateUniversalServiceIdentifier.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/UpdateUniversalServiceIdentifier.java index 2194a969b..a80b65416 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/UpdateUniversalServiceIdentifier.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/UpdateUniversalServiceIdentifier.java @@ -17,6 +17,11 @@ * Service Identifier (OBR-4) */ public class UpdateUniversalServiceIdentifier implements CustomFhirTransformation { + + public static final String CHECK_VALUE_NAME = "checkValue"; + public static final String CODING_SYSTEM_NAME = "codingSystem"; + public static final String ALTERNATE_ID_NAME = "alternateId"; + @Override public void transform(FhirResource resource, Map args) { Bundle bundle = (Bundle) resource.getUnderlyingResource(); @@ -26,7 +31,7 @@ public void transform(FhirResource resource, Map args) { it -> { var allCodings = it.getCode().getCoding(); var codingSystemContainer = - getCodingSystemContainer(allCodings, args.get("checkValue")); + getCodingSystemContainer(allCodings, args.get(CHECK_VALUE_NAME)); if (codingSystemContainer == null) { // we're only interested in coding that matches the checkValue argument @@ -34,11 +39,14 @@ public void transform(FhirResource resource, Map args) { } // check for the coding system label and create or override it - updateCodingSystemLabel(codingSystemContainer, args.get("codingSystem")); + updateCodingSystemLabel(codingSystemContainer, args.get(CODING_SYSTEM_NAME)); // the alt id is stored on a separate coding object, so we need to filter // for it - updateAlternateCodingId(allCodings, args); + String alternateId = args.get(ALTERNATE_ID_NAME); + if (alternateId != null) { + updateAlternateCodingId(allCodings, alternateId); + } }); } @@ -81,7 +89,7 @@ private Coding getAltCodingContainer(List allCodings) { } /** Find and create or update the "Alternate Id" object in a given List */ - private void updateAlternateCodingId(List allCodings, Map args) { + private void updateAlternateCodingId(List allCodings, String alternateId) { var altCodingContainer = getAltCodingContainer(allCodings); if (altCodingContainer == null) { @@ -93,6 +101,6 @@ private void updateAlternateCodingId(List allCodings, Map