fix for problem handling acceptUnknown publishing IGs

This commit is contained in:
Grahame Grieve 2019-10-16 00:12:51 +11:00
parent 0cf2cafb62
commit 593b86591c
7 changed files with 165 additions and 73 deletions

View File

@ -2006,25 +2006,37 @@ public class VersionConvertor_10_40 {
throw new FHIRException("Unknown type "+src.fhirType()); throw new FHIRException("Unknown type "+src.fhirType());
} }
public void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { private static boolean isExemptExtension(String url, String[] extensionsToIgnore) {
boolean ok = false;
for (String s : extensionsToIgnore)
if (s.equals(url))
ok = true;
return ok;
}
public void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) for (org.hl7.fhir.dstu2.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt) throws FHIRException { public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r4.model.Resource t : src.getContained()) for (org.hl7.fhir.r4.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) for (org.hl7.fhir.r4.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
public org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.dstu2.model.Parameters src) throws FHIRException { public org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.dstu2.model.Parameters src) throws FHIRException {
@ -4215,7 +4227,9 @@ public class VersionConvertor_10_40 {
tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.dstu2.model.CodeType t : src.getFormat()) for (org.hl7.fhir.dstu2.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
// for (org.hl7.fhir.dstu2.model.Reference t : src.getProfile()) // for (org.hl7.fhir.dstu2.model.Reference t : src.getProfile())
@ -4233,7 +4247,7 @@ public class VersionConvertor_10_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();
copyDomainResource(src, tgt); copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
tgt.setUrl(src.getUrl()); tgt.setUrl(src.getUrl());
tgt.setVersion(src.getVersion()); tgt.setVersion(src.getVersion());
tgt.setName(src.getName()); tgt.setName(src.getName());
@ -4254,7 +4268,9 @@ public class VersionConvertor_10_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());
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.r4.model.CodeType t : src.getFormat()) for (org.hl7.fhir.r4.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (CapabilityStatementRestComponent r : src.getRest()) for (CapabilityStatementRestComponent r : src.getRest())

View File

@ -2006,25 +2006,37 @@ public class VersionConvertor_10_50 {
throw new FHIRException("Unknown type "+src.fhirType()); throw new FHIRException("Unknown type "+src.fhirType());
} }
public void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException { private static boolean isExemptExtension(String url, String[] extensionsToIgnore) {
boolean ok = false;
for (String s : extensionsToIgnore)
if (s.equals(url))
ok = true;
return ok;
}
public void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) for (org.hl7.fhir.dstu2.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
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... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r5.model.Resource t : src.getContained()) for (org.hl7.fhir.r5.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) for (org.hl7.fhir.r5.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
public org.hl7.fhir.r5.model.Parameters convertParameters(org.hl7.fhir.dstu2.model.Parameters src) throws FHIRException { public org.hl7.fhir.r5.model.Parameters convertParameters(org.hl7.fhir.dstu2.model.Parameters src) throws FHIRException {
@ -4219,7 +4231,9 @@ public class VersionConvertor_10_50 {
tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.dstu2.model.CodeType t : src.getFormat()) for (org.hl7.fhir.dstu2.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
// for (org.hl7.fhir.dstu2.model.Reference t : src.getProfile()) // for (org.hl7.fhir.dstu2.model.Reference t : src.getProfile())
@ -4237,7 +4251,7 @@ public class VersionConvertor_10_50 {
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();
copyDomainResource(src, tgt); copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
tgt.setUrl(src.getUrl()); tgt.setUrl(src.getUrl());
tgt.setVersion(src.getVersion()); tgt.setVersion(src.getVersion());
tgt.setName(src.getName()); tgt.setName(src.getName());
@ -4258,7 +4272,9 @@ public class VersionConvertor_10_50 {
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());
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.r5.model.CodeType t : src.getFormat()) for (org.hl7.fhir.r5.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (CapabilityStatementRestComponent r : src.getRest()) for (CapabilityStatementRestComponent r : src.getRest())

View File

@ -2258,26 +2258,38 @@ public class VersionConvertor_14_40 {
throw new FHIRException("Unknown type "+src.fhirType()); throw new FHIRException("Unknown type "+src.fhirType());
} }
private static void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { private static boolean isExemptExtension(String url, String[] extensionsToIgnore) {
boolean ok = false;
for (String s : extensionsToIgnore)
if (s.equals(url))
ok = true;
return ok;
}
private static void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
private static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt) throws FHIRException { private static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
if (src.hasText()) if (src.hasText())
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r4.model.Resource t : src.getContained()) for (org.hl7.fhir.r4.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) for (org.hl7.fhir.r4.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
public static org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.dstu2016may.model.Parameters src) throws FHIRException { public static org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.dstu2016may.model.Parameters src) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
@ -3402,7 +3414,9 @@ public class VersionConvertor_14_40 {
tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getFormat()) for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
// for (org.hl7.fhir.dstu2016may.model.Reference t : src.getProfile()) // for (org.hl7.fhir.dstu2016may.model.Reference t : src.getProfile())
@ -3432,7 +3446,7 @@ public class VersionConvertor_14_40 {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2016may.model.Conformance tgt = new org.hl7.fhir.dstu2016may.model.Conformance(); org.hl7.fhir.dstu2016may.model.Conformance tgt = new org.hl7.fhir.dstu2016may.model.Conformance();
copyDomainResource(src, tgt); copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
if (src.hasUrl()) if (src.hasUrl())
tgt.setUrl(src.getUrl()); tgt.setUrl(src.getUrl());
if (src.hasVersion()) if (src.hasVersion())
@ -3463,7 +3477,9 @@ public class VersionConvertor_14_40 {
tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
tgt.setFhirVersion(src.getFhirVersion().toCode()); tgt.setFhirVersion(src.getFhirVersion().toCode());
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.r4.model.CodeType t : src.getFormat()) for (org.hl7.fhir.r4.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (CapabilityStatementRestComponent r : src.getRest()) for (CapabilityStatementRestComponent r : src.getRest())

View File

@ -2256,26 +2256,38 @@ public class VersionConvertor_14_50 {
throw new FHIRException("Unknown type "+src.fhirType()); throw new FHIRException("Unknown type "+src.fhirType());
} }
private static void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException { private static boolean isExemptExtension(String url, String[] extensionsToIgnore) {
boolean ok = false;
for (String s : extensionsToIgnore)
if (s.equals(url))
ok = true;
return ok;
}
private static void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
private static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt) throws FHIRException { private static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
if (src.hasText()) if (src.hasText())
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r5.model.Resource t : src.getContained()) for (org.hl7.fhir.r5.model.Resource t : src.getContained())
tgt.addContained(convertResource(t)); tgt.addContained(convertResource(t));
for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) for (org.hl7.fhir.r5.model.Extension t : src.getExtension())
tgt.addExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t)); if (!isExemptExtension(t.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t));
} }
public static org.hl7.fhir.r5.model.Parameters convertParameters(org.hl7.fhir.dstu2016may.model.Parameters src) throws FHIRException { public static org.hl7.fhir.r5.model.Parameters convertParameters(org.hl7.fhir.dstu2016may.model.Parameters src) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
@ -3404,7 +3416,9 @@ public class VersionConvertor_14_50 {
tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getFormat()) for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
// for (org.hl7.fhir.dstu2016may.model.Reference t : src.getProfile()) // for (org.hl7.fhir.dstu2016may.model.Reference t : src.getProfile())
@ -3434,7 +3448,7 @@ public class VersionConvertor_14_50 {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2016may.model.Conformance tgt = new org.hl7.fhir.dstu2016may.model.Conformance(); org.hl7.fhir.dstu2016may.model.Conformance tgt = new org.hl7.fhir.dstu2016may.model.Conformance();
copyDomainResource(src, tgt); copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
if (src.hasUrl()) if (src.hasUrl())
tgt.setUrl(src.getUrl()); tgt.setUrl(src.getUrl());
if (src.hasVersion()) if (src.hasVersion())
@ -3465,7 +3479,9 @@ public class VersionConvertor_14_50 {
tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
tgt.setFhirVersion(src.getFhirVersion().toCode()); tgt.setFhirVersion(src.getFhirVersion().toCode());
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); 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()));
for (org.hl7.fhir.r5.model.CodeType t : src.getFormat()) for (org.hl7.fhir.r5.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (CapabilityStatementRestComponent r : src.getRest()) for (CapabilityStatementRestComponent r : src.getRest())

View File

@ -2949,27 +2949,39 @@ public class VersionConvertor_30_40 {
throw new FHIRException("Unknown type "+src.fhirType()); throw new FHIRException("Unknown type "+src.fhirType());
} }
private static void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { private static boolean isExemptExtension(String url, String[] extensionsToIgnore) {
boolean ok = false;
for (String s : extensionsToIgnore)
if (s.equals(url))
ok = true;
return ok;
}
private static void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
if (src.hasText()) if (src.hasText())
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained())
tgt.addContained(convertResource(t1, false)); tgt.addContained(convertResource(t1, false));
for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension())
tgt.addExtension(convertExtension(t2)); if (!isExemptExtension(t2.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t2));
for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t3)); if (!isExemptExtension(t3.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t3));
} }
private static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException { private static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
if (src.hasText()) if (src.hasText())
tgt.setText(convertNarrative(src.getText())); tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r4.model.Resource t1 : src.getContained()) for (org.hl7.fhir.r4.model.Resource t1 : src.getContained())
tgt.addContained(convertResource(t1, false)); tgt.addContained(convertResource(t1, false));
for (org.hl7.fhir.r4.model.Extension t2 : src.getExtension()) for (org.hl7.fhir.r4.model.Extension t2 : src.getExtension())
tgt.addExtension(convertExtension(t2)); if (!isExemptExtension(t2.getUrl(), extensionsToIgnore))
tgt.addExtension(convertExtension(t2));
for (org.hl7.fhir.r4.model.Extension t3 : src.getModifierExtension()) for (org.hl7.fhir.r4.model.Extension t3 : src.getModifierExtension())
tgt.addModifierExtension(convertExtension(t3)); if (!isExemptExtension(t3.getUrl(), extensionsToIgnore))
tgt.addModifierExtension(convertExtension(t3));
} }
public static org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.dstu3.model.Parameters src) throws FHIRException { public static org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.dstu3.model.Parameters src) throws FHIRException {
if (src == null) if (src == null)
@ -4680,8 +4692,9 @@ public class VersionConvertor_30_40 {
tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation())); tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation()));
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.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); tgt.addExtension().setUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").setValue(
new org.hl7.fhir.r4.model.CodeType(src.getAcceptUnknownElement().asStringValue()));
for (org.hl7.fhir.dstu3.model.CodeType t : src.getFormat()) for (org.hl7.fhir.dstu3.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat()) for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat())
@ -4704,7 +4717,7 @@ public class VersionConvertor_30_40 {
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();
copyDomainResource(src, tgt); copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
if (src.hasUrl()) if (src.hasUrl())
tgt.setUrl(src.getUrl()); tgt.setUrl(src.getUrl());
if (src.hasVersion()) if (src.hasVersion())
@ -4743,8 +4756,9 @@ public class VersionConvertor_30_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.hasAcceptUnknown()) if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"))
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); tgt.setAcceptUnknown(org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.fromCode(
src.getExtensionByUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").getValue().primitiveValue()));
for (org.hl7.fhir.r4.model.CodeType t : src.getFormat()) for (org.hl7.fhir.r4.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (org.hl7.fhir.r4.model.CodeType t : src.getPatchFormat()) for (org.hl7.fhir.r4.model.CodeType t : src.getPatchFormat())

View File

@ -2932,22 +2932,23 @@ public class VersionConvertor_30_50 {
for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained())
tgt.addContained(convertResource(t1, false)); tgt.addContained(convertResource(t1, false));
for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) { for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) {
boolean ok = true; if (!isExemptExtension(t2.getUrl(), extensionsToIgnore))
for (String s : extensionsToIgnore)
if (s.equals(t2.getUrl()))
ok = false;
if (ok)
tgt.addExtension(convertExtension(t2)); tgt.addExtension(convertExtension(t2));
} }
for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) { for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) {
boolean ok = true; if (!isExemptExtension(t3.getUrl(), extensionsToIgnore))
for (String s : extensionsToIgnore)
if (s.equals(t3.getUrl()))
ok = false;
if (ok)
tgt.addModifierExtension(convertExtension(t3)); tgt.addModifierExtension(convertExtension(t3));
} }
} }
private static boolean isExemptExtension(String url, String[] extensionsToIgnore) {
boolean ok = false;
for (String s : extensionsToIgnore)
if (s.equals(url))
ok = true;
return ok;
}
private static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { private static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt); copyResource(src, tgt);
if (src.hasText()) if (src.hasText())
@ -2955,20 +2956,12 @@ public class VersionConvertor_30_50 {
for (org.hl7.fhir.r5.model.Resource t1 : src.getContained()) for (org.hl7.fhir.r5.model.Resource t1 : src.getContained())
tgt.addContained(convertResource(t1, false)); tgt.addContained(convertResource(t1, false));
for (org.hl7.fhir.r5.model.Extension t2 : src.getExtension()) { for (org.hl7.fhir.r5.model.Extension t2 : src.getExtension()) {
boolean ok = true; if (!isExemptExtension(t2.getUrl(), extensionsToIgnore))
for (String s : extensionsToIgnore)
if (s.equals(t2.getUrl()))
ok = false;
if (ok)
tgt.addExtension(convertExtension(t2)); tgt.addExtension(convertExtension(t2));
} }
for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) { for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) {
boolean ok = true; if (!isExemptExtension(t3.getUrl(), extensionsToIgnore))
for (String s : extensionsToIgnore) tgt.addModifierExtension(convertExtension(t3));
if (s.equals(t3.getUrl()))
ok = false;
if (ok)
tgt.addModifierExtension(convertExtension(t3));
} }
} }
public static org.hl7.fhir.r5.model.Parameters convertParameters(org.hl7.fhir.dstu3.model.Parameters src) throws FHIRException { public static org.hl7.fhir.r5.model.Parameters convertParameters(org.hl7.fhir.dstu3.model.Parameters src) throws FHIRException {
@ -4680,8 +4673,9 @@ public class VersionConvertor_30_50 {
tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation())); tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation()));
if (src.hasFhirVersion()) if (src.hasFhirVersion())
tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
// if (src.hasAcceptUnknown()) if (src.hasAcceptUnknown())
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); tgt.addExtension().setUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").setValue(
new org.hl7.fhir.r5.model.CodeType(src.getAcceptUnknownElement().asStringValue()));
for (org.hl7.fhir.dstu3.model.CodeType t : src.getFormat()) for (org.hl7.fhir.dstu3.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat()) for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat())
@ -4704,7 +4698,7 @@ public class VersionConvertor_30_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();
copyDomainResource(src, tgt); copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
if (src.hasUrl()) if (src.hasUrl())
tgt.setUrl(src.getUrl()); tgt.setUrl(src.getUrl());
if (src.hasVersion()) if (src.hasVersion())
@ -4743,8 +4737,9 @@ public class VersionConvertor_30_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.hasAcceptUnknown()) if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"))
// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); tgt.setAcceptUnknown(org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.fromCode(
src.getExtensionByUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").getValue().primitiveValue()));
for (org.hl7.fhir.r5.model.CodeType t : src.getFormat()) for (org.hl7.fhir.r5.model.CodeType t : src.getFormat())
tgt.addFormat(t.getValue()); tgt.addFormat(t.getValue());
for (org.hl7.fhir.r5.model.CodeType t : src.getPatchFormat()) for (org.hl7.fhir.r5.model.CodeType t : src.getPatchFormat())

View File

@ -81,6 +81,7 @@ import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType;
import org.hl7.fhir.r5.model.StringType; import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.Type; import org.hl7.fhir.r5.model.Type;
import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.UrlType;
import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent; import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent;
import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.utilities.StandardsStatus; import org.hl7.fhir.utilities.StandardsStatus;
@ -816,5 +817,23 @@ public class ToolingExtensions {
// return hasExtension(cs, EXT_OID); // return hasExtension(cs, EXT_OID);
// } // }
// //
public static void addUrlExtension(Element e, String url, String content) {
if (!StringUtils.isBlank(content)) {
Extension ex = getExtension(e, url);
if (ex != null)
ex.setValue(new CodeType(content));
else
e.getExtension().add(Factory.newExtension(url, new UrlType(content), true));
}
}
public static void addUrlExtension(DomainResource dr, String url, String value) {
Extension ex = getExtension(dr, url);
if (ex != null)
ex.setValue(new CodeType(value));
else
dr.getExtension().add(Factory.newExtension(url, new UrlType(value), true));
}
} }