Move ignore extension logic in 10_50 convertors
This commit is contained in:
parent
bcef732576
commit
8c86328002
|
@ -24,9 +24,8 @@ public class BaseAdvisor_10_50 extends BaseAdvisor50<org.hl7.fhir.dstu2.model.Ex
|
|||
|
||||
public boolean ignoreExtension(@Nonnull String path,
|
||||
@Nonnull String url) {
|
||||
final List<String> paths = Arrays.asList(path.split(","));
|
||||
final String lastPath = paths.get(paths.size() - 1);
|
||||
return (lastPath.equals("CapabilityStatement")) && (conformanceIgnoredUrls.contains(url));
|
||||
// no globally ignored extensions here.
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean ignoreType(@Nonnull String path,
|
||||
|
|
|
@ -144,14 +144,18 @@ public class VersionConvertor_10_50 {
|
|||
}
|
||||
}
|
||||
|
||||
public void copyDomainResource(@Nonnull org.hl7.fhir.dstu2.model.DomainResource src,
|
||||
@Nonnull org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException {
|
||||
resourceConvertor.copyDomainResource(src, tgt);
|
||||
public void copyDomainResource(
|
||||
@Nonnull org.hl7.fhir.dstu2.model.DomainResource src,
|
||||
@Nonnull org.hl7.fhir.r5.model.DomainResource tgt,
|
||||
String ... extensionUrlsToIgnore) throws FHIRException {
|
||||
resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore);
|
||||
}
|
||||
|
||||
public void copyDomainResource(@Nonnull org.hl7.fhir.r5.model.DomainResource src,
|
||||
@Nonnull org.hl7.fhir.dstu2.model.DomainResource tgt) throws FHIRException {
|
||||
resourceConvertor.copyDomainResource(src, tgt);
|
||||
public void copyDomainResource(
|
||||
@Nonnull org.hl7.fhir.r5.model.DomainResource src,
|
||||
@Nonnull org.hl7.fhir.dstu2.model.DomainResource tgt,
|
||||
String ... extensionUrlsToIgnore) throws FHIRException {
|
||||
resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore);
|
||||
}
|
||||
|
||||
public void copyElement(@Nonnull org.hl7.fhir.dstu2.model.Element src,
|
||||
|
|
|
@ -20,6 +20,12 @@ import org.hl7.fhir.r5.model.CapabilityStatement.SystemRestfulInteraction;
|
|||
|
||||
public class Conformance10_50 {
|
||||
|
||||
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.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus> convertConditionalDeleteStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CapabilityStatement.ConditionalDeleteStatus> src) throws FHIRException {
|
||||
if (src == null || src.isEmpty())
|
||||
return null;
|
||||
|
@ -72,7 +78,7 @@ public class Conformance10_50 {
|
|||
if (src == null || src.isEmpty())
|
||||
return null;
|
||||
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
|
||||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
|
||||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
|
||||
if (src.hasUrlElement())
|
||||
tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
|
||||
if (src.hasVersionElement())
|
||||
|
@ -103,8 +109,8 @@ public class Conformance10_50 {
|
|||
tgt.setImplementation(convertConformanceImplementationComponent(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.dstu2.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.dstu2.model.Conformance.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 (CapabilityStatementRestComponent r : src.getRest())
|
||||
for (CapabilityStatementRestResourceComponent rr : r.getResource())
|
||||
|
@ -155,7 +161,7 @@ public class Conformance10_50 {
|
|||
if (src.hasFhirVersion())
|
||||
tgt.setFhirVersion(org.hl7.fhir.r5.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.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.dstu2.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.Conformance.ConformanceRestComponent t : src.getRest())
|
||||
tgt.addRest(convertConformanceRestComponent(t));
|
||||
|
|
|
@ -8,6 +8,8 @@ import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Narrative10_50;
|
|||
import org.hl7.fhir.dstu2.model.Extension;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Resource10_50 {
|
||||
|
||||
public final BaseAdvisor_10_50 advisor;
|
||||
|
@ -264,7 +266,10 @@ public class Resource10_50 {
|
|||
}
|
||||
}
|
||||
|
||||
public void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException {
|
||||
public void copyDomainResource(
|
||||
org.hl7.fhir.dstu2.model.DomainResource src,
|
||||
org.hl7.fhir.r5.model.DomainResource tgt,
|
||||
String ... extensionUrlsToIgnore) throws FHIRException {
|
||||
copyResource(src, tgt);
|
||||
if (src.hasText()) tgt.setText(Narrative10_50.convertNarrative(src.getText()));
|
||||
src.getContained().stream()
|
||||
|
@ -275,7 +280,7 @@ public class Resource10_50 {
|
|||
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
|
||||
advisor.handleExtension(ConversionContext10_50.INSTANCE.path(), extension, convertExtension);
|
||||
tgt.addExtension(convertExtension);
|
||||
} else if (!advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension)) {
|
||||
} else if (!advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
|
||||
tgt.addExtension(Extension10_50.convertExtension(extension));
|
||||
}
|
||||
});
|
||||
|
@ -285,7 +290,10 @@ public class Resource10_50 {
|
|||
.forEach(tgt::addModifierExtension);
|
||||
}
|
||||
|
||||
public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt) throws FHIRException {
|
||||
public void copyDomainResource(
|
||||
org.hl7.fhir.r5.model.DomainResource src,
|
||||
org.hl7.fhir.dstu2.model.DomainResource tgt,
|
||||
String ... extensionUrlsToIgnore) throws FHIRException {
|
||||
copyResource(src, tgt);
|
||||
if (src.hasText()) tgt.setText(Narrative10_50.convertNarrative(src.getText()));
|
||||
src.getContained().stream()
|
||||
|
@ -296,7 +304,7 @@ public class Resource10_50 {
|
|||
Extension convertExtension = new Extension();
|
||||
advisor.handleExtension(ConversionContext10_50.INSTANCE.path(), extension, convertExtension);
|
||||
tgt.addExtension(convertExtension);
|
||||
} else if (!advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension)) {
|
||||
} else if (!advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
|
||||
tgt.addExtension(Extension10_50.convertExtension(extension));
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue