diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java index c54dd81e1..a0ead0adb 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java @@ -11,10 +11,6 @@ import org.hl7.fhir.exceptions.FHIRException; public class BaseAdvisor_30_50 extends BaseAdvisor50 { - final List valueSetIgnoredUrls = Collections.singletonList("http://hl7.org/fhir/StructureDefinition/valueset-extensible"); - final List capabilityStatementIgnoredUrls = Arrays.asList("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown", - "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.profile"); - public BaseAdvisor_30_50() { } @@ -25,14 +21,8 @@ public class BaseAdvisor_30_50 extends BaseAdvisor50 paths = Arrays.asList(path.split(",")); - final String lastPath = paths.get(paths.size() - 1); - if ((lastPath.equals("ValueSet")) && (valueSetIgnoredUrls.contains(url))) { - return true; - } - else - return (lastPath.equals("CapabilityStatement")) && (capabilityStatementIgnoredUrls.contains(url)); - + // no globally ignored extensions here. + return false; } } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/VersionConvertor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/VersionConvertor_30_50.java index 5c6415958..a25194ea9 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/VersionConvertor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/VersionConvertor_30_50.java @@ -148,14 +148,14 @@ public class VersionConvertor_30_50 { public void copyElement(@Nonnull org.hl7.fhir.r5.model.Element src, @Nonnull org.hl7.fhir.dstu3.model.Element tgt, - String... var) throws FHIRException { - elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), var); + String... ignoredExtensionUrls) throws FHIRException { + elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), ignoredExtensionUrls); } public void copyBackboneElement(@Nonnull org.hl7.fhir.r5.model.BackboneElement src, @Nonnull org.hl7.fhir.dstu3.model.BackboneElement tgt, - String... var) throws FHIRException { - backboneElementConvertor.copyBackboneElement(src, tgt, var); + String... ignoredExtensionUrls) throws FHIRException { + backboneElementConvertor.copyBackboneElement(src, tgt, ignoredExtensionUrls); } public void copyBackboneElement(@Nonnull org.hl7.fhir.dstu3.model.BackboneElement src, diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java index 19ea47cde..2f8e62bd2 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java @@ -20,6 +20,14 @@ import org.hl7.fhir.exceptions.FHIRException; public class CapabilityStatement30_50 { + public static final String ACCEPT_UNKNOWN_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"; + public static final String PROFILE_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.profile"; + + private static final String[] IGNORED_EXTENSION_URLS = new String[]{ + ACCEPT_UNKNOWN_EXTENSION_URL, + PROFILE_EXTENSION_URL + }; + public static org.hl7.fhir.r5.model.CapabilityStatement convertCapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement src) throws FHIRException { if (src == null) return null; @@ -63,14 +71,14 @@ public class CapabilityStatement30_50 { if (src.hasFhirVersion()) tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(fixCode(src.getFhirVersion()))); if (src.hasAcceptUnknown()) - tgt.addExtension().setUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").setValue(new org.hl7.fhir.r5.model.CodeType(src.getAcceptUnknownElement().asStringValue())); + tgt.addExtension().setUrl(ACCEPT_UNKNOWN_EXTENSION_URL).setValue(new org.hl7.fhir.r5.model.CodeType(src.getAcceptUnknownElement().asStringValue())); for (org.hl7.fhir.dstu3.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat()) tgt.addPatchFormat(t.getValue()); for (org.hl7.fhir.dstu3.model.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(t.getValue()); for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest()) tgt.addRest(convertCapabilityStatementRestComponent(t)); for (org.hl7.fhir.dstu3.model.Reference t : src.getProfile()) - tgt.addExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.profile", Reference30_50.convertReference(t)); + tgt.addExtension(PROFILE_EXTENSION_URL, Reference30_50.convertReference(t)); for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent t : src.getMessaging()) tgt.addMessaging(convertCapabilityStatementMessagingComponent(t)); for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument()) @@ -90,7 +98,7 @@ public class CapabilityStatement30_50 { if (src == null) return null; org.hl7.fhir.dstu3.model.CapabilityStatement tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement(); - ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS); if (src.hasUrl()) tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement())); if (src.hasVersion()) @@ -128,8 +136,8 @@ public class CapabilityStatement30_50 { tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation())); if (src.hasFhirVersion()) tgt.setFhirVersion(src.getFhirVersion().toCode()); - if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown")) - tgt.setAcceptUnknown(org.hl7.fhir.dstu3.model.CapabilityStatement.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.dstu3.model.CapabilityStatement.UnknownContentCode.fromCode(src.getExtensionByUrl(ACCEPT_UNKNOWN_EXTENSION_URL).getValue().primitiveValue())); for (org.hl7.fhir.r5.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.r5.model.CodeType t : src.getPatchFormat()) tgt.addPatchFormat(t.getValue()); for (org.hl7.fhir.r5.model.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(t.getValue()); @@ -138,7 +146,7 @@ public class CapabilityStatement30_50 { for (org.hl7.fhir.r5.model.CanonicalType t : rr.getSupportedProfile()) tgt.addProfile(Reference30_50.convertCanonicalToReference(t)); for (org.hl7.fhir.r5.model.Extension ext : src.getExtension()) { - if ("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.profile".equals(ext.getUrl())) { + if (PROFILE_EXTENSION_URL.equals(ext.getUrl())) { tgt.addProfile(Reference30_50.convertReference((org.hl7.fhir.r5.model.Reference) ext.getValue())); } } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/ValueSet30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/ValueSet30_50.java index 77d6622d1..19b42ae82 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/ValueSet30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/ValueSet30_50.java @@ -19,6 +19,11 @@ import org.hl7.fhir.r5.model.BooleanType; public class ValueSet30_50 { + public static final String EXTENSIBLE_EXTENSION_URL = "http://hl7.org/fhir/StructureDefinition/valueset-extensible"; + + private static final String[] IGNORED_EXTENSION_URLS = new String[]{ + EXTENSIBLE_EXTENSION_URL + }; public static org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent src) throws FHIRException { if (src == null) return null; @@ -215,7 +220,7 @@ public class ValueSet30_50 { if (src.hasCopyright()) tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement())); if (src.hasExtensible()) - tgt.addExtension("http://hl7.org/fhir/StructureDefinition/valueset-extensible", new BooleanType(src.getExtensible())); + tgt.addExtension(EXTENSIBLE_EXTENSION_URL, new BooleanType(src.getExtensible())); if (src.hasCompose()) tgt.setCompose(convertValueSetComposeComponent(src.getCompose())); if (src.hasExpansion()) @@ -227,7 +232,7 @@ public class ValueSet30_50 { if (src == null) return null; org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet(); - ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS); if (src.hasUrl()) tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement())); for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) @@ -260,8 +265,8 @@ public class ValueSet30_50 { tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement())); if (src.hasCopyright()) tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement())); - if (src.hasExtension("http://hl7.org/fhir/StructureDefinition/valueset-extensible")) - tgt.setExtensible(((BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/valueset-extensible").getValue()).booleanValue()); + if (src.hasExtension(EXTENSIBLE_EXTENSION_URL)) + tgt.setExtensible(((BooleanType) src.getExtensionByUrl(EXTENSIBLE_EXTENSION_URL).getValue()).booleanValue()); if (src.hasCompose()) tgt.setCompose(convertValueSetComposeComponent(src.getCompose())); if (src.hasExpansion())