From ac9c1ea70aa3ad2576e83e836c01f71561474abb Mon Sep 17 00:00:00 2001 From: Basilio Bogado <541149+basiliskus@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:34:41 -0700 Subject: [PATCH 1/2] Added fix for issue in RS: instead of removing PID-5.7 it replaces it with L when there is no extension --- .../hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java index 746bb72b7..ca569b479 100644 --- a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java +++ b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java @@ -275,7 +275,9 @@ public static Extension getPID5Extension(Bundle bundle) { public static void removePID5_7Extension(Bundle bundle) { Extension extension = getPID5Extension(bundle); if (extension != null && extension.hasExtension(HapiHelper.EXTENSION_XPN7_URL)) { - extension.removeExtension(HapiHelper.EXTENSION_XPN7_URL); + // Need to set the value for extension to empty instead of removing the extension, + // otherwise RS will set its own value in its place + extension.getExtensionByUrl(HapiHelper.EXTENSION_XPN7_URL).setValue(new StringType()); } } From 1af20f48589b61ce372dfb026022a0ef2de44cd3 Mon Sep 17 00:00:00 2001 From: Basilio Bogado <541149+basiliskus@users.noreply.github.com> Date: Thu, 11 Jul 2024 07:13:57 -0700 Subject: [PATCH 2/2] Changed removePID5_7Extension to setPID5_7ExtensionValue --- .../transformation/custom/RemovePatientNameTypeCode.java | 4 +++- .../cdc/trustedintermediary/external/hapi/HapiHelper.java | 8 ++++---- .../external/hapi/HapiHelperTest.groovy | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/RemovePatientNameTypeCode.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/RemovePatientNameTypeCode.java index 22aa2e109..eaf44962d 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/RemovePatientNameTypeCode.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/ruleengine/transformation/custom/RemovePatientNameTypeCode.java @@ -12,6 +12,8 @@ public class RemovePatientNameTypeCode implements CustomFhirTransformation { @Override public void transform(final FhirResource resource, final Map args) { Bundle bundle = (Bundle) resource.getUnderlyingResource(); - HapiHelper.removePID5_7Extension(bundle); + // Need to set the value for extension to empty instead of removing the extension, + // otherwise RS will set its own value in its place + HapiHelper.setPID5_7ExtensionValue(bundle, null); } } diff --git a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java index ca569b479..cb113e0a7 100644 --- a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java +++ b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelper.java @@ -272,12 +272,12 @@ public static Extension getPID5Extension(Bundle bundle) { return name.getExtensionByUrl(HapiHelper.EXTENSION_XPN_HUMAN_NAME_URL); } - public static void removePID5_7Extension(Bundle bundle) { + public static void setPID5_7ExtensionValue(Bundle bundle, String value) { Extension extension = getPID5Extension(bundle); if (extension != null && extension.hasExtension(HapiHelper.EXTENSION_XPN7_URL)) { - // Need to set the value for extension to empty instead of removing the extension, - // otherwise RS will set its own value in its place - extension.getExtensionByUrl(HapiHelper.EXTENSION_XPN7_URL).setValue(new StringType()); + extension + .getExtensionByUrl(HapiHelper.EXTENSION_XPN7_URL) + .setValue(new StringType(value)); } } diff --git a/shared/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelperTest.groovy b/shared/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelperTest.groovy index 8532a9d18..d8684a5db 100644 --- a/shared/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelperTest.groovy +++ b/shared/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiHelperTest.groovy @@ -457,7 +457,7 @@ class HapiHelperTest extends Specification { when: def bundle = new Bundle() - HapiHelper.removePID5_7Extension(bundle) + HapiHelper.setPID5_7ExtensionValue(bundle, null) then: HapiHelper.getPID5Extension(bundle) == null @@ -465,7 +465,7 @@ class HapiHelperTest extends Specification { when: HapiFhirHelper.createPIDPatient(bundle) HapiFhirHelper.setPID5Extension(bundle) - HapiHelper.removePID5_7Extension(bundle) + HapiHelper.setPID5_7ExtensionValue(bundle, null) then: HapiFhirHelper.getPID5_7Value(bundle) == null @@ -478,7 +478,7 @@ class HapiHelperTest extends Specification { HapiFhirHelper.getPID5_7Value(bundle) == pid5_7 when: - HapiHelper.removePID5_7Extension(bundle) + HapiHelper.setPID5_7ExtensionValue(bundle, null) then: HapiHelper.getPID5Extension(bundle) != null