Skip to content

Commit

Permalink
Bugfix for RemovePatientNameTypeCode transformation (#1171)
Browse files Browse the repository at this point in the history
* Added fix for issue in RS: instead of removing PID-5.7 it replaces it with L when there is no extension

* Changed removePID5_7Extension to setPID5_7ExtensionValue
  • Loading branch information
basiliskus authored Jul 11, 2024
1 parent 6c0cf7e commit eecec6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class RemovePatientNameTypeCode implements CustomFhirTransformation {
@Override
public void transform(final FhirResource<?> resource, final Map<String, String> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +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)) {
extension.removeExtension(HapiHelper.EXTENSION_XPN7_URL);
extension
.getExtensionByUrl(HapiHelper.EXTENSION_XPN7_URL)
.setValue(new StringType(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,15 @@ class HapiHelperTest extends Specification {

when:
def bundle = new Bundle()
HapiHelper.removePID5_7Extension(bundle)
HapiHelper.setPID5_7ExtensionValue(bundle, null)

then:
HapiHelper.getPID5Extension(bundle) == null

when:
HapiFhirHelper.createPIDPatient(bundle)
HapiFhirHelper.setPID5Extension(bundle)
HapiHelper.removePID5_7Extension(bundle)
HapiHelper.setPID5_7ExtensionValue(bundle, null)

then:
HapiFhirHelper.getPID5_7Value(bundle) == null
Expand All @@ -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
Expand Down

0 comments on commit eecec6e

Please sign in to comment.