Move ignore extension logic in 30_50 convertors Part 2
This commit is contained in:
parent
05148a54c8
commit
33f28daf33
|
@ -11,10 +11,6 @@ import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
|
||||||
public class BaseAdvisor_30_50 extends BaseAdvisor50<org.hl7.fhir.dstu3.model.Extension> {
|
public class BaseAdvisor_30_50 extends BaseAdvisor50<org.hl7.fhir.dstu3.model.Extension> {
|
||||||
|
|
||||||
final List<String> valueSetIgnoredUrls = Collections.singletonList("http://hl7.org/fhir/StructureDefinition/valueset-extensible");
|
|
||||||
final List<String> 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() {
|
public BaseAdvisor_30_50() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,14 +21,8 @@ public class BaseAdvisor_30_50 extends BaseAdvisor50<org.hl7.fhir.dstu3.model.Ex
|
||||||
@Override
|
@Override
|
||||||
public boolean ignoreExtension(@Nonnull String path,
|
public boolean ignoreExtension(@Nonnull String path,
|
||||||
@Nonnull String url) throws FHIRException {
|
@Nonnull String url) throws FHIRException {
|
||||||
final List<String> paths = Arrays.asList(path.split(","));
|
// no globally ignored extensions here.
|
||||||
final String lastPath = paths.get(paths.size() - 1);
|
return false;
|
||||||
if ((lastPath.equals("ValueSet")) && (valueSetIgnoredUrls.contains(url))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return (lastPath.equals("CapabilityStatement")) && (capabilityStatementIgnoredUrls.contains(url));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,14 +148,14 @@ public class VersionConvertor_30_50 {
|
||||||
|
|
||||||
public void copyElement(@Nonnull org.hl7.fhir.r5.model.Element src,
|
public void copyElement(@Nonnull org.hl7.fhir.r5.model.Element src,
|
||||||
@Nonnull org.hl7.fhir.dstu3.model.Element tgt,
|
@Nonnull org.hl7.fhir.dstu3.model.Element tgt,
|
||||||
String... var) throws FHIRException {
|
String... ignoredExtensionUrls) throws FHIRException {
|
||||||
elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), var);
|
elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), ignoredExtensionUrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyBackboneElement(@Nonnull org.hl7.fhir.r5.model.BackboneElement src,
|
public void copyBackboneElement(@Nonnull org.hl7.fhir.r5.model.BackboneElement src,
|
||||||
@Nonnull org.hl7.fhir.dstu3.model.BackboneElement tgt,
|
@Nonnull org.hl7.fhir.dstu3.model.BackboneElement tgt,
|
||||||
String... var) throws FHIRException {
|
String... ignoredExtensionUrls) throws FHIRException {
|
||||||
backboneElementConvertor.copyBackboneElement(src, tgt, var);
|
backboneElementConvertor.copyBackboneElement(src, tgt, ignoredExtensionUrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyBackboneElement(@Nonnull org.hl7.fhir.dstu3.model.BackboneElement src,
|
public void copyBackboneElement(@Nonnull org.hl7.fhir.dstu3.model.BackboneElement src,
|
||||||
|
|
|
@ -20,6 +20,14 @@ import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
|
||||||
public class CapabilityStatement30_50 {
|
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 {
|
public static org.hl7.fhir.r5.model.CapabilityStatement convertCapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement src) throws FHIRException {
|
||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -63,14 +71,14 @@ public class CapabilityStatement30_50 {
|
||||||
if (src.hasFhirVersion())
|
if (src.hasFhirVersion())
|
||||||
tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(fixCode(src.getFhirVersion())));
|
tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(fixCode(src.getFhirVersion())));
|
||||||
if (src.hasAcceptUnknown())
|
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.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.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.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(t.getValue());
|
||||||
for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest())
|
for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest())
|
||||||
tgt.addRest(convertCapabilityStatementRestComponent(t));
|
tgt.addRest(convertCapabilityStatementRestComponent(t));
|
||||||
for (org.hl7.fhir.dstu3.model.Reference t : src.getProfile())
|
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())
|
for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent t : src.getMessaging())
|
||||||
tgt.addMessaging(convertCapabilityStatementMessagingComponent(t));
|
tgt.addMessaging(convertCapabilityStatementMessagingComponent(t));
|
||||||
for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument())
|
for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument())
|
||||||
|
@ -90,7 +98,7 @@ public class CapabilityStatement30_50 {
|
||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.dstu3.model.CapabilityStatement tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement();
|
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())
|
if (src.hasUrl())
|
||||||
tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
|
tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
|
||||||
if (src.hasVersion())
|
if (src.hasVersion())
|
||||||
|
@ -128,8 +136,8 @@ public class CapabilityStatement30_50 {
|
||||||
tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation()));
|
tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation()));
|
||||||
if (src.hasFhirVersion())
|
if (src.hasFhirVersion())
|
||||||
tgt.setFhirVersion(src.getFhirVersion().toCode());
|
tgt.setFhirVersion(src.getFhirVersion().toCode());
|
||||||
if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"))
|
if (src.hasExtension(ACCEPT_UNKNOWN_EXTENSION_URL))
|
||||||
tgt.setAcceptUnknown(org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").getValue().primitiveValue()));
|
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.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.CodeType t : src.getPatchFormat()) tgt.addPatchFormat(t.getValue());
|
||||||
for (org.hl7.fhir.r5.model.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(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())
|
for (org.hl7.fhir.r5.model.CanonicalType t : rr.getSupportedProfile())
|
||||||
tgt.addProfile(Reference30_50.convertCanonicalToReference(t));
|
tgt.addProfile(Reference30_50.convertCanonicalToReference(t));
|
||||||
for (org.hl7.fhir.r5.model.Extension ext : src.getExtension()) {
|
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()));
|
tgt.addProfile(Reference30_50.convertReference((org.hl7.fhir.r5.model.Reference) ext.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,11 @@ import org.hl7.fhir.r5.model.BooleanType;
|
||||||
|
|
||||||
public class ValueSet30_50 {
|
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 {
|
public static org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent src) throws FHIRException {
|
||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -215,7 +220,7 @@ public class ValueSet30_50 {
|
||||||
if (src.hasCopyright())
|
if (src.hasCopyright())
|
||||||
tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
|
tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
|
||||||
if (src.hasExtensible())
|
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())
|
if (src.hasCompose())
|
||||||
tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
|
tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
|
||||||
if (src.hasExpansion())
|
if (src.hasExpansion())
|
||||||
|
@ -227,7 +232,7 @@ public class ValueSet30_50 {
|
||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet();
|
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())
|
if (src.hasUrl())
|
||||||
tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
|
tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
|
||||||
for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
|
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()));
|
tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
|
||||||
if (src.hasCopyright())
|
if (src.hasCopyright())
|
||||||
tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
|
tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
|
||||||
if (src.hasExtension("http://hl7.org/fhir/StructureDefinition/valueset-extensible"))
|
if (src.hasExtension(EXTENSIBLE_EXTENSION_URL))
|
||||||
tgt.setExtensible(((BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/valueset-extensible").getValue()).booleanValue());
|
tgt.setExtensible(((BooleanType) src.getExtensionByUrl(EXTENSIBLE_EXTENSION_URL).getValue()).booleanValue());
|
||||||
if (src.hasCompose())
|
if (src.hasCompose())
|
||||||
tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
|
tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
|
||||||
if (src.hasExpansion())
|
if (src.hasExpansion())
|
||||||
|
|
Loading…
Reference in New Issue