Move ignore extension logic in 10_40 convertors
This commit is contained in:
parent
8c86328002
commit
6f1b57dc15
|
@ -26,9 +26,8 @@ public class BaseAdvisor_10_40 extends BaseAdvisor40<org.hl7.fhir.dstu2.model.Ex
|
||||||
@Override
|
@Override
|
||||||
public boolean ignoreExtension(@Nonnull String path,
|
public boolean ignoreExtension(@Nonnull String path,
|
||||||
@Nonnull String url) {
|
@Nonnull String url) {
|
||||||
final List<String> paths = Arrays.asList(path.split(","));
|
// no globally ignored extensions here.
|
||||||
final String lastPath = paths.get(paths.size() - 1);
|
return false;
|
||||||
return (lastPath.equals("CapabilityStatement")) && (conformanceIgnoredUrls.contains(url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -143,14 +143,18 @@ public class VersionConvertor_10_40 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDomainResource(@Nonnull org.hl7.fhir.dstu2.model.DomainResource src,
|
public void copyDomainResource(
|
||||||
@Nonnull org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException {
|
@Nonnull org.hl7.fhir.dstu2.model.DomainResource src,
|
||||||
resourceConvertor.copyDomainResource(src, tgt);
|
@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,
|
public void copyDomainResource(
|
||||||
@Nonnull org.hl7.fhir.dstu2.model.DomainResource tgt) throws FHIRException {
|
@Nonnull org.hl7.fhir.r4.model.DomainResource src,
|
||||||
resourceConvertor.copyDomainResource(src, tgt);
|
@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,
|
public void copyElement(@Nonnull org.hl7.fhir.dstu2.model.Element src,
|
||||||
|
|
|
@ -21,6 +21,11 @@ import org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction;
|
||||||
|
|
||||||
public class Conformance10_40 {
|
public class Conformance10_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.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus> convertConditionalDeleteStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus> src) throws FHIRException {
|
static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus> convertConditionalDeleteStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus> src) throws FHIRException {
|
||||||
if (src == null || src.isEmpty())
|
if (src == null || src.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
@ -69,7 +74,7 @@ public class Conformance10_40 {
|
||||||
if (src == null || src.isEmpty())
|
if (src == null || src.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
|
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
|
||||||
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
|
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
|
||||||
if (src.hasUrlElement())
|
if (src.hasUrlElement())
|
||||||
tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement()));
|
tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement()));
|
||||||
if (src.hasVersionElement())
|
if (src.hasVersionElement())
|
||||||
|
@ -100,8 +105,8 @@ public class Conformance10_40 {
|
||||||
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
|
tgt.setImplementation(convertConformanceImplementationComponent(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.dstu2.model.Conformance.UnknownContentCode.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").getValue().primitiveValue()));
|
tgt.setAcceptUnknown(org.hl7.fhir.dstu2.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 (org.hl7.fhir.r4.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue());
|
||||||
for (CapabilityStatementRestComponent r : src.getRest())
|
for (CapabilityStatementRestComponent r : src.getRest())
|
||||||
for (CapabilityStatementRestResourceComponent rr : r.getResource())
|
for (CapabilityStatementRestResourceComponent rr : r.getResource())
|
||||||
|
@ -152,7 +157,7 @@ public class Conformance10_40 {
|
||||||
if (src.hasFhirVersion())
|
if (src.hasFhirVersion())
|
||||||
tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
|
tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(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.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.dstu2.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue());
|
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())
|
for (org.hl7.fhir.dstu2.model.Conformance.ConformanceRestComponent t : src.getRest())
|
||||||
tgt.addRest(convertConformanceRestComponent(t));
|
tgt.addRest(convertConformanceRestComponent(t));
|
||||||
|
|
|
@ -8,6 +8,8 @@ import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Narrative10_40;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.r4.model.Extension;
|
import org.hl7.fhir.r4.model.Extension;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Resource10_40 {
|
public class Resource10_40 {
|
||||||
|
|
||||||
public final BaseAdvisor_10_40 advisor;
|
public final BaseAdvisor_10_40 advisor;
|
||||||
|
@ -272,20 +274,22 @@ public class Resource10_40 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src,
|
public void copyDomainResource(
|
||||||
org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException {
|
org.hl7.fhir.dstu2.model.DomainResource src,
|
||||||
|
org.hl7.fhir.r4.model.DomainResource tgt,
|
||||||
|
String ... extensionUrlsToIgnore) throws FHIRException {
|
||||||
copyResource(src, tgt);
|
copyResource(src, tgt);
|
||||||
if (src.hasText()) tgt.setText(Narrative10_40.convertNarrative(src.getText()));
|
if (src.hasText()) tgt.setText(Narrative10_40.convertNarrative(src.getText()));
|
||||||
src.getContained().stream()
|
src.getContained().stream()
|
||||||
.map(this::convertResource)
|
.map(this::convertResource)
|
||||||
.forEach(tgt::addContained);
|
.forEach(tgt::addContained);
|
||||||
src.getExtension().forEach(ext -> {
|
src.getExtension().forEach(extension -> {
|
||||||
if (advisor.useAdvisorForExtension(ConversionContext10_40.INSTANCE.path(), ext)) {
|
if (advisor.useAdvisorForExtension(ConversionContext10_40.INSTANCE.path(), extension)) {
|
||||||
Extension convertExtension = new Extension();
|
Extension convertExtension = new Extension();
|
||||||
advisor.handleExtension(ConversionContext10_40.INSTANCE.path(), ext, convertExtension);
|
advisor.handleExtension(ConversionContext10_40.INSTANCE.path(), extension, convertExtension);
|
||||||
tgt.addExtension(convertExtension);
|
tgt.addExtension(convertExtension);
|
||||||
} else if (!advisor.ignoreExtension(ConversionContext10_40.INSTANCE.path(), ext)) {
|
} else if (!advisor.ignoreExtension(ConversionContext10_40.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
|
||||||
tgt.addExtension(Extension10_40.convertExtension(ext));
|
tgt.addExtension(Extension10_40.convertExtension(extension));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
src.getModifierExtension().stream()
|
src.getModifierExtension().stream()
|
||||||
|
@ -294,8 +298,10 @@ public class Resource10_40 {
|
||||||
.forEach(tgt::addModifierExtension);
|
.forEach(tgt::addModifierExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src,
|
public void copyDomainResource(
|
||||||
org.hl7.fhir.dstu2.model.DomainResource tgt) throws FHIRException {
|
org.hl7.fhir.r4.model.DomainResource src,
|
||||||
|
org.hl7.fhir.dstu2.model.DomainResource tgt,
|
||||||
|
String ... extensionUrlsToIgnore) throws FHIRException {
|
||||||
copyResource(src, tgt);
|
copyResource(src, tgt);
|
||||||
if (src.hasText()) tgt.setText(Narrative10_40.convertNarrative(src.getText()));
|
if (src.hasText()) tgt.setText(Narrative10_40.convertNarrative(src.getText()));
|
||||||
src.getContained().stream()
|
src.getContained().stream()
|
||||||
|
@ -306,7 +312,7 @@ public class Resource10_40 {
|
||||||
org.hl7.fhir.dstu2.model.Extension convertExtension = new org.hl7.fhir.dstu2.model.Extension();
|
org.hl7.fhir.dstu2.model.Extension convertExtension = new org.hl7.fhir.dstu2.model.Extension();
|
||||||
advisor.handleExtension(ConversionContext10_40.INSTANCE.path(), extension, convertExtension);
|
advisor.handleExtension(ConversionContext10_40.INSTANCE.path(), extension, convertExtension);
|
||||||
tgt.addExtension(convertExtension);
|
tgt.addExtension(convertExtension);
|
||||||
} else if (!advisor.ignoreExtension(ConversionContext10_40.INSTANCE.path(), extension)) {
|
} else if (!advisor.ignoreExtension(ConversionContext10_40.INSTANCE.path(), extension)&& !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
|
||||||
tgt.addExtension(Extension10_40.convertExtension(extension));
|
tgt.addExtension(Extension10_40.convertExtension(extension));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue