Move ignore extension logic in 14_40 convertors
This commit is contained in:
parent
b9433f0e8c
commit
9a70ebb2c9
|
@ -13,8 +13,6 @@ import org.hl7.fhir.r4.model.Type;
|
|||
|
||||
public class BaseAdvisor_14_40 extends BaseAdvisor40<org.hl7.fhir.dstu2016may.model.Extension> {
|
||||
|
||||
final List<String> conformanceIgnoredUrls = Collections.singletonList("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
|
||||
private final List<String> ignoredUrls = new ArrayList<>(Collections.singletonList("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"));
|
||||
private final List<Class<?>> ignoredExtensionTypes = new ArrayList<>(Collections.singletonList(Expression.class));
|
||||
|
||||
public BaseAdvisor_14_40() {
|
||||
|
@ -27,13 +25,8 @@ public class BaseAdvisor_14_40 extends BaseAdvisor40<org.hl7.fhir.dstu2016may.mo
|
|||
|
||||
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);
|
||||
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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus> convertConditionalDeleteStatus(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Conformance.ConditionalDeleteStatus> 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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue