diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java index 1f2e88d2d..7d2146a69 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java @@ -2006,25 +2006,37 @@ public class VersionConvertor_10_40 { 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); tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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); tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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 { @@ -4215,7 +4227,9 @@ public class VersionConvertor_10_40 { tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); 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()) tgt.addFormat(t.getValue()); // for (org.hl7.fhir.dstu2.model.Reference t : src.getProfile()) @@ -4233,7 +4247,7 @@ public class VersionConvertor_10_40 { if (src == null || src.isEmpty()) return null; 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.setVersion(src.getVersion()); tgt.setName(src.getName()); @@ -4254,7 +4268,9 @@ public class VersionConvertor_10_40 { tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); if (src.hasFhirVersion()) 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()) tgt.addFormat(t.getValue()); for (CapabilityStatementRestComponent r : src.getRest()) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java index f093bc64b..8e8e437c4 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java @@ -2006,25 +2006,37 @@ public class VersionConvertor_10_50 { 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); tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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); tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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 { @@ -4219,7 +4231,9 @@ public class VersionConvertor_10_50 { tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); 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()) tgt.addFormat(t.getValue()); // for (org.hl7.fhir.dstu2.model.Reference t : src.getProfile()) @@ -4237,7 +4251,7 @@ public class VersionConvertor_10_50 { if (src == null || src.isEmpty()) return null; 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.setVersion(src.getVersion()); tgt.setName(src.getName()); @@ -4258,7 +4272,9 @@ public class VersionConvertor_10_50 { tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); if (src.hasFhirVersion()) 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()) tgt.addFormat(t.getValue()); for (CapabilityStatementRestComponent r : src.getRest()) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java index 809480331..451f22620 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java @@ -2258,26 +2258,38 @@ public class VersionConvertor_14_40 { 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); tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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); if (src.hasText()) tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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 { if (src == null || src.isEmpty()) @@ -3402,7 +3414,9 @@ public class VersionConvertor_14_40 { tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); 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()) tgt.addFormat(t.getValue()); // for (org.hl7.fhir.dstu2016may.model.Reference t : src.getProfile()) @@ -3432,7 +3446,7 @@ public class VersionConvertor_14_40 { if (src == null || src.isEmpty()) return null; 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()) tgt.setUrl(src.getUrl()); if (src.hasVersion()) @@ -3463,7 +3477,9 @@ public class VersionConvertor_14_40 { tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); 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()) tgt.addFormat(t.getValue()); for (CapabilityStatementRestComponent r : src.getRest()) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java index 9b13f76f0..fa081f542 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java @@ -2256,26 +2256,38 @@ public class VersionConvertor_14_50 { 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); tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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); if (src.hasText()) tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); 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()) - 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 { if (src == null || src.isEmpty()) @@ -3404,7 +3416,9 @@ public class VersionConvertor_14_50 { tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); 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()) tgt.addFormat(t.getValue()); // for (org.hl7.fhir.dstu2016may.model.Reference t : src.getProfile()) @@ -3434,7 +3448,7 @@ public class VersionConvertor_14_50 { if (src == null || src.isEmpty()) return null; 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()) tgt.setUrl(src.getUrl()); if (src.hasVersion()) @@ -3465,7 +3479,9 @@ public class VersionConvertor_14_50 { tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware())); tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation())); 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()) tgt.addFormat(t.getValue()); for (CapabilityStatementRestComponent r : src.getRest()) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java index b2a22eae4..93ca745a8 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java @@ -2949,27 +2949,39 @@ public class VersionConvertor_30_40 { 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); if (src.hasText()) tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); 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()) - 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); if (src.hasText()) tgt.setText(convertNarrative(src.getText())); for (org.hl7.fhir.r4.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); 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()) - 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 { if (src == null) @@ -4680,8 +4692,9 @@ public class VersionConvertor_30_40 { tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation())); if (src.hasFhirVersion()) tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); -// if (src.hasAcceptUnknown()) -// 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.dstu3.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat()) @@ -4704,7 +4717,7 @@ public class VersionConvertor_30_40 { if (src == null) return null; 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()) tgt.setUrl(src.getUrl()); if (src.hasVersion()) @@ -4743,8 +4756,9 @@ public class VersionConvertor_30_40 { tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation())); if (src.hasFhirVersion()) tgt.setFhirVersion(src.getFhirVersion().toCode()); -// if (src.hasAcceptUnknown()) -// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); + if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown")) + 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()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.r4.model.CodeType t : src.getPatchFormat()) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java index 3f4d0a7c7..1ed4f0cd5 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java @@ -2932,22 +2932,23 @@ public class VersionConvertor_30_50 { for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) { - boolean ok = true; - for (String s : extensionsToIgnore) - if (s.equals(t2.getUrl())) - ok = false; - if (ok) + if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); } for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) { - boolean ok = true; - for (String s : extensionsToIgnore) - if (s.equals(t3.getUrl())) - ok = false; - if (ok) + if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) 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 { copyResource(src, tgt); if (src.hasText()) @@ -2955,20 +2956,12 @@ public class VersionConvertor_30_50 { for (org.hl7.fhir.r5.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); for (org.hl7.fhir.r5.model.Extension t2 : src.getExtension()) { - boolean ok = true; - for (String s : extensionsToIgnore) - if (s.equals(t2.getUrl())) - ok = false; - if (ok) + if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); } for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) { - boolean ok = true; - for (String s : extensionsToIgnore) - if (s.equals(t3.getUrl())) - ok = false; - if (ok) - tgt.addModifierExtension(convertExtension(t3)); + if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) + tgt.addModifierExtension(convertExtension(t3)); } } 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())); if (src.hasFhirVersion()) tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion())); -// if (src.hasAcceptUnknown()) -// 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.dstu3.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat()) @@ -4704,7 +4698,7 @@ public class VersionConvertor_30_50 { if (src == null) return null; 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()) tgt.setUrl(src.getUrl()); if (src.hasVersion()) @@ -4743,8 +4737,9 @@ public class VersionConvertor_30_50 { tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation())); if (src.hasFhirVersion()) tgt.setFhirVersion(src.getFhirVersion().toCode()); -// if (src.hasAcceptUnknown()) -// tgt.setAcceptUnknown(convertUnknownContentCode(src.getAcceptUnknown())); + if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown")) + 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()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.r5.model.CodeType t : src.getPatchFormat()) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index 4d294d497..a58c3fa8b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -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.Type; 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.ConceptSetComponent; import org.hl7.fhir.utilities.StandardsStatus; @@ -816,5 +817,23 @@ public class ToolingExtensions { // 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)); + } + }