Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for RemovePatientNameTypeCode transformation #1171

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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