diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_14_40.java index f72bccbf2..18e671aeb 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_14_40.java @@ -13,8 +13,6 @@ import org.hl7.fhir.r4.model.Type; public class BaseAdvisor_14_40 extends BaseAdvisor40 { - final List conformanceIgnoredUrls = Collections.singletonList("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"); - private final List ignoredUrls = new ArrayList<>(Collections.singletonList("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown")); private final List> ignoredExtensionTypes = new ArrayList<>(Collections.singletonList(Expression.class)); public BaseAdvisor_14_40() { @@ -27,13 +25,8 @@ public class BaseAdvisor_14_40 extends BaseAdvisor40 paths = Arrays.asList(path.split(",")); - final String lastPath = paths.get(paths.size() - 1); - if ((lastPath.equals("Conformance")) && (conformanceIgnoredUrls.contains(url))) { - return true; - } else { - return this.ignoredUrls.contains(url); - } + // no globally ignored extensions here. + return false; } public boolean ignoreType(@Nonnull String path, @Nonnull Type type) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/VersionConvertor_14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/VersionConvertor_14_40.java index eb0d50d5c..12d4051dd 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/VersionConvertor_14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/VersionConvertor_14_40.java @@ -137,14 +137,18 @@ public class VersionConvertor_14_40 { } } - public void copyDomainResource(@Nonnull org.hl7.fhir.dstu2016may.model.DomainResource src, - @Nonnull org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { - resourceConvertor.copyDomainResource(src, tgt); + public void copyDomainResource( + @Nonnull org.hl7.fhir.dstu2016may.model.DomainResource src, + @Nonnull org.hl7.fhir.r4.model.DomainResource tgt, + String... extensionUrlsToIgnore) throws FHIRException { + resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore); } - public void copyDomainResource(@Nonnull org.hl7.fhir.r4.model.DomainResource src, - @Nonnull org.hl7.fhir.dstu2016may.model.DomainResource tgt) throws FHIRException { - resourceConvertor.copyDomainResource(src, tgt); + public void copyDomainResource( + @Nonnull org.hl7.fhir.r4.model.DomainResource src, + @Nonnull org.hl7.fhir.dstu2016may.model.DomainResource tgt, + String... extensionUrlsToIgnore) throws FHIRException { + resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore); } public void copyElement(@Nonnull org.hl7.fhir.dstu2016may.model.Element src, diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Conformance14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Conformance14_40.java index 29ac51302..12734273f 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Conformance14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Conformance14_40.java @@ -19,6 +19,12 @@ import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResource public class Conformance14_40 { + public static final String ACCEPT_UNKNOWN_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"; + + private static final String[] IGNORED_EXTENSION_URLS = new String[]{ + ACCEPT_UNKNOWN_EXTENSION_URL + }; + static public org.hl7.fhir.r4.model.Enumeration convertConditionalDeleteStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -67,7 +73,7 @@ public class Conformance14_40 { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.Conformance tgt = new org.hl7.fhir.dstu2016may.model.Conformance(); - ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt); + ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS); if (src.hasUrl()) tgt.setUrlElement(Uri14_40.convertUri(src.getUrlElement())); if (src.hasVersion()) @@ -102,8 +108,8 @@ public class Conformance14_40 { if (src.hasImplementation()) tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); tgt.setFhirVersion(src.getFhirVersion().toCode()); - if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown")) - tgt.setAcceptUnknown(org.hl7.fhir.dstu2016may.model.Conformance.UnknownContentCode.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").getValue().primitiveValue())); + if (src.hasExtension(ACCEPT_UNKNOWN_EXTENSION_URL)) + tgt.setAcceptUnknown(org.hl7.fhir.dstu2016may.model.Conformance.UnknownContentCode.fromCode(src.getExtensionByUrl(ACCEPT_UNKNOWN_EXTENSION_URL).getValue().primitiveValue())); for (org.hl7.fhir.r4.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (CapabilityStatementRestComponent r : src.getRest()) for (CapabilityStatementRestResourceComponent rr : r.getResource()) @@ -159,7 +165,7 @@ public class Conformance14_40 { if (src.hasFhirVersion()) tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); if (src.hasAcceptUnknown()) - tgt.addExtension().setUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").setValue(new org.hl7.fhir.r4.model.CodeType(src.getAcceptUnknownElement().asStringValue())); + tgt.addExtension().setUrl(ACCEPT_UNKNOWN_EXTENSION_URL).setValue(new org.hl7.fhir.r4.model.CodeType(src.getAcceptUnknownElement().asStringValue())); for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.dstu2016may.model.Conformance.ConformanceRestComponent t : src.getRest()) tgt.addRest(convertConformanceRestComponent(t)); diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Resource14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Resource14_40.java index 08477d722..6d3bb6b94 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Resource14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv14_40/resources14_40/Resource14_40.java @@ -7,6 +7,8 @@ import org.hl7.fhir.convertors.conv14_40.datatypes14_40.Meta14_40; import org.hl7.fhir.convertors.conv14_40.datatypes14_40.Narrative14_40; import org.hl7.fhir.exceptions.FHIRException; +import java.util.Arrays; + public class Resource14_40 { public final BaseAdvisor_14_40 advisor; @@ -113,8 +115,10 @@ public class Resource14_40 { } } - public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, - org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { + public void copyDomainResource( + org.hl7.fhir.dstu2016may.model.DomainResource src, + org.hl7.fhir.r4.model.DomainResource tgt, + String... extensionUrlsToIgnore) throws FHIRException { copyResource(src, tgt); if (src.hasText()) tgt.setText(Narrative14_40.convertNarrative(src.getText())); src.getContained().stream() @@ -125,7 +129,7 @@ public class Resource14_40 { org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension(); advisor.handleExtension(ConversionContext14_40.INSTANCE.path(), extension, convertExtension); tgt.addExtension(convertExtension); - } else if (!advisor.ignoreExtension(ConversionContext14_40.INSTANCE.path(), extension)) { + } else if (!advisor.ignoreExtension(ConversionContext14_40.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) { tgt.addExtension(Extension14_40.convertExtension(extension)); } }); @@ -135,8 +139,10 @@ public class Resource14_40 { .forEach(tgt::addModifierExtension); } - public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, - org.hl7.fhir.dstu2016may.model.DomainResource tgt) throws FHIRException { + public void copyDomainResource( + org.hl7.fhir.r4.model.DomainResource src, + org.hl7.fhir.dstu2016may.model.DomainResource tgt, + String... extensionUrlsToIgnore) throws FHIRException { copyResource(src, tgt); if (src.hasText()) tgt.setText(Narrative14_40.convertNarrative(src.getText())); src.getContained().stream() @@ -147,7 +153,7 @@ public class Resource14_40 { org.hl7.fhir.dstu2016may.model.Extension convertExtension = new org.hl7.fhir.dstu2016may.model.Extension(); advisor.handleExtension(ConversionContext14_40.INSTANCE.path(), extension, convertExtension); tgt.addExtension(convertExtension); - } else if (!advisor.ignoreExtension(ConversionContext14_40.INSTANCE.path(), extension)) { + } else if (!advisor.ignoreExtension(ConversionContext14_40.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) { tgt.addExtension(Extension14_40.convertExtension(extension)); } });