Move ignore extension logic in 30_40 convertors
This commit is contained in:
parent
33f28daf33
commit
42cf58cfbb
|
@ -25,13 +25,7 @@ public class BaseAdvisor_30_40 extends BaseAdvisor40<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);
|
|
||||||
if (lastPath.equals("CapabilityStatement")) {
|
|
||||||
return capabilityStatementIgnoredUrls.contains(url);
|
|
||||||
} else if (lastPath.equals("Immunization")) {
|
|
||||||
return immunizationIgnoredUrls.contains(url);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,13 +133,13 @@ public class VersionConvertor_30_40 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDomainResource(@Nonnull org.hl7.fhir.dstu3.model.DomainResource src,
|
public void copyDomainResource(@Nonnull org.hl7.fhir.dstu3.model.DomainResource src,
|
||||||
@Nonnull org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException {
|
@Nonnull org.hl7.fhir.r4.model.DomainResource tgt, String... extensionUrlsToIgnore) throws FHIRException {
|
||||||
resourceConvertor.copyDomainResource(src, tgt);
|
resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDomainResource(@Nonnull org.hl7.fhir.r4.model.DomainResource src,
|
public void copyDomainResource(@Nonnull org.hl7.fhir.r4.model.DomainResource src,
|
||||||
@Nonnull org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException {
|
@Nonnull org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionUrlsToIgnore) throws FHIRException {
|
||||||
resourceConvertor.copyDomainResource(src, tgt);
|
resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyElement(@Nonnull org.hl7.fhir.dstu3.model.Element src,
|
public void copyElement(@Nonnull org.hl7.fhir.dstu3.model.Element src,
|
||||||
|
|
|
@ -20,11 +20,17 @@ import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
|
||||||
public class CapabilityStatement30_40 {
|
public class CapabilityStatement30_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
|
||||||
|
};
|
||||||
|
|
||||||
public static org.hl7.fhir.dstu3.model.CapabilityStatement convertCapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement src) throws FHIRException {
|
public static org.hl7.fhir.dstu3.model.CapabilityStatement convertCapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement src) throws FHIRException {
|
||||||
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_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
|
ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
|
||||||
if (src.hasUrl())
|
if (src.hasUrl())
|
||||||
tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
|
tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
|
||||||
if (src.hasVersion())
|
if (src.hasVersion())
|
||||||
|
@ -62,8 +68,8 @@ public class CapabilityStatement30_40 {
|
||||||
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.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 (org.hl7.fhir.r4.model.CodeType t : src.getPatchFormat()) tgt.addPatchFormat(t.getValue());
|
for (org.hl7.fhir.r4.model.CodeType t : src.getPatchFormat()) tgt.addPatchFormat(t.getValue());
|
||||||
for (org.hl7.fhir.r4.model.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(t.getValue());
|
for (org.hl7.fhir.r4.model.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(t.getValue());
|
||||||
|
@ -128,7 +134,7 @@ public class CapabilityStatement30_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.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());
|
||||||
|
|
|
@ -20,6 +20,10 @@ public class Immunization30_40 {
|
||||||
|
|
||||||
public static final String NOT_GIVEN_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.notGiven";
|
public static final String NOT_GIVEN_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.notGiven";
|
||||||
|
|
||||||
|
private static final String[] IGNORED_EXTENSION_URLS = new String[]{
|
||||||
|
NOT_GIVEN_EXTENSION_URL
|
||||||
|
};
|
||||||
|
|
||||||
public static org.hl7.fhir.r4.model.Immunization convertImmunization(org.hl7.fhir.dstu3.model.Immunization src) throws FHIRException {
|
public static org.hl7.fhir.r4.model.Immunization convertImmunization(org.hl7.fhir.dstu3.model.Immunization src) throws FHIRException {
|
||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -82,8 +86,8 @@ public class Immunization30_40 {
|
||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.dstu3.model.Immunization tgt = new org.hl7.fhir.dstu3.model.Immunization();
|
org.hl7.fhir.dstu3.model.Immunization tgt = new org.hl7.fhir.dstu3.model.Immunization();
|
||||||
//FIXME add ignore
|
|
||||||
ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
|
ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
|
||||||
for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
|
for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
|
||||||
tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
|
tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
|
||||||
if (src.hasStatus()) {
|
if (src.hasStatus()) {
|
||||||
|
|
|
@ -7,6 +7,8 @@ import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Meta30_40;
|
||||||
import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Narrative30_40;
|
import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Narrative30_40;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Resource30_40 {
|
public class Resource30_40 {
|
||||||
|
|
||||||
public final BaseAdvisor_30_40 advisor;
|
public final BaseAdvisor_30_40 advisor;
|
||||||
|
@ -384,7 +386,8 @@ public class Resource30_40 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src,
|
public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src,
|
||||||
org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException {
|
org.hl7.fhir.r4.model.DomainResource tgt,
|
||||||
|
String... extensionUrlsToIgnore) throws FHIRException {
|
||||||
copyResource(src, tgt);
|
copyResource(src, tgt);
|
||||||
if (src.hasText()) tgt.setText(Narrative30_40.convertNarrative(src.getText()));
|
if (src.hasText()) tgt.setText(Narrative30_40.convertNarrative(src.getText()));
|
||||||
src.getContained().stream()
|
src.getContained().stream()
|
||||||
|
@ -396,7 +399,7 @@ public class Resource30_40 {
|
||||||
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
|
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
|
||||||
advisor.handleExtension(ConversionContext30_40.INSTANCE.path(), extension, convertExtension);
|
advisor.handleExtension(ConversionContext30_40.INSTANCE.path(), extension, convertExtension);
|
||||||
tgt.addExtension(convertExtension);
|
tgt.addExtension(convertExtension);
|
||||||
} else if (!advisor.ignoreExtension(ConversionContext30_40.INSTANCE.path(), extension)) {
|
} else if (!advisor.ignoreExtension(ConversionContext30_40.INSTANCE.path(), extension)&& !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
|
||||||
tgt.addExtension(Extension30_40.convertExtension(extension));
|
tgt.addExtension(Extension30_40.convertExtension(extension));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -407,7 +410,8 @@ public class Resource30_40 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src,
|
public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src,
|
||||||
org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException {
|
org.hl7.fhir.dstu3.model.DomainResource tgt,
|
||||||
|
String... extensionUrlsToIgnore) throws FHIRException {
|
||||||
copyResource(src, tgt);
|
copyResource(src, tgt);
|
||||||
if (src.hasText()) tgt.setText(Narrative30_40.convertNarrative(src.getText()));
|
if (src.hasText()) tgt.setText(Narrative30_40.convertNarrative(src.getText()));
|
||||||
src.getContained().stream()
|
src.getContained().stream()
|
||||||
|
@ -418,7 +422,7 @@ public class Resource30_40 {
|
||||||
org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension();
|
org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension();
|
||||||
advisor.handleExtension(ConversionContext30_40.INSTANCE.path(), extension, convertExtension);
|
advisor.handleExtension(ConversionContext30_40.INSTANCE.path(), extension, convertExtension);
|
||||||
tgt.addExtension(convertExtension);
|
tgt.addExtension(convertExtension);
|
||||||
} else if (!advisor.ignoreExtension(ConversionContext30_40.INSTANCE.path(), extension)) {
|
} else if (!advisor.ignoreExtension(ConversionContext30_40.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
|
||||||
tgt.addExtension(Extension30_40.convertExtension(extension));
|
tgt.addExtension(Extension30_40.convertExtension(extension));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue