This commit is contained in:
markiantorno 2021-05-25 13:36:07 -04:00
parent 9a82457b36
commit 30e45f54ed
101 changed files with 3070 additions and 1443 deletions

View File

@ -32,7 +32,8 @@ package org.hl7.fhir.convertors;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.convertors.loaders.R2016MayToR4Loader;
import org.hl7.fhir.convertors.loaders.R2ToR4Loader;
import org.hl7.fhir.convertors.loaders.R3ToR4Loader;
@ -401,13 +402,13 @@ public class ExtensionDefinitionGenerator {
private byte[] saveResource(Resource resource, FHIRVersion v) throws IOException, FHIRException {
if (v == FHIRVersion._3_0_1) {
org.hl7.fhir.dstu3.model.Resource res = VersionConvertor_30_40.convertResource(resource, true);
org.hl7.fhir.dstu3.model.Resource res = VersionConvertor_30_40.convertResource(resource, new BaseAdvisor_30_40(false));
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(res);
} else if (v == FHIRVersion._1_4_0) {
org.hl7.fhir.dstu2016may.model.Resource res = VersionConvertor_14_40.convertResource(resource);
return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(res);
} else if (v == FHIRVersion._1_0_2) {
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_40.convertResource(resource, advisor);
return new org.hl7.fhir.dstu2.formats.JsonParser().composeBytes(res);
} else if (v == FHIRVersion._4_0_0) {
@ -419,18 +420,17 @@ public class ExtensionDefinitionGenerator {
private Resource loadResource(InputStream inputStream, FHIRVersion v) throws IOException, FHIRException {
if (v == FHIRVersion._3_0_1) {
org.hl7.fhir.dstu3.model.Resource res = new org.hl7.fhir.dstu3.formats.JsonParser().parse(inputStream);
return VersionConvertor_30_40.convertResource(res, true);
return VersionConvertor_30_40.convertResource(res, new BaseAdvisor_30_40(false));
} else if (v == FHIRVersion._1_4_0) {
org.hl7.fhir.dstu2016may.model.Resource res = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(inputStream);
return VersionConvertor_14_40.convertResource(res);
} else if (v == FHIRVersion._1_0_2) {
org.hl7.fhir.dstu2.model.Resource res = new org.hl7.fhir.dstu2.formats.JsonParser().parse(inputStream);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
return VersionConvertor_10_40.convertResource(res, advisor);
} else if (v == FHIRVersion._4_0_0) {
return new JsonParser().parse(inputStream);
} else
throw new Error("Unsupported version " + v);
}
}

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.convertors;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
@ -235,7 +235,7 @@ public class VersionConversionService {
throw new FHIRException("Conversion from R3 to 2016May version is not supported for resources of type "+src.fhirType());
case R4:
if (useJava && VersionConvertor_30_40.convertsResource(src.fhirType()))
return saveResource40(VersionConvertor_30_40.convertResource(src, false), dstFormat, style);
return saveResource40(VersionConvertor_30_40.convertResource(src), dstFormat, style);
else
throw new FHIRException("todo: use script based conversion....");
case STU3: return saveResource30(src, dstFormat, style);
@ -259,7 +259,7 @@ public class VersionConversionService {
case R4: return saveResource40(src, dstFormat, style);
case STU3:
if (useJava && VersionConvertor_30_40.convertsResource(src.fhirType()))
return saveResource30(VersionConvertor_30_40.convertResource(src, false), dstFormat, style);
return saveResource30(VersionConvertor_30_40.convertResource(src), dstFormat, style);
else
throw new FHIRException("todo: use script based conversion....");
default: throw new FHIRException("FHIR Version 'unknown' is not supported by the inter-version convertor");

View File

@ -1,6 +1,6 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.convertors.conv10_30.*;
import org.hl7.fhir.dstu2.model.CodeableConcept;
import org.hl7.fhir.dstu2.utils.ToolingExtensions;
@ -2725,7 +2725,7 @@ public class VersionConvertor_10_30 extends VersionConvertor_Base {
return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem()));
}
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException {
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, BaseAdvisor_10_30 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2.model.Parameters)
return Parameters10_30.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src);
@ -2876,7 +2876,7 @@ public class VersionConvertor_10_30 extends VersionConvertor_Base {
throw new FHIRException("Unknown resource " + src.fhirType());
}
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_10_30 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu3.model.Parameters)
return Parameters10_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src);

View File

@ -1,6 +1,6 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.conv10_40.*;
import org.hl7.fhir.dstu2.model.CodeableConcept;
import org.hl7.fhir.dstu2.model.Parameters;
@ -10,19 +10,17 @@ import org.hl7.fhir.dstu2.model.Reference;
import org.hl7.fhir.dstu2.utils.ToolingExtensions;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.conformance.ProfileUtilities;
import org.hl7.fhir.r4.model.CanonicalType;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.*;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent;
import org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent;
import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent;
import org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent;
import org.hl7.fhir.r4.model.TerminologyCapabilities;
import org.hl7.fhir.r4.model.UnsignedIntType;
import org.hl7.fhir.r4.terminologies.CodeSystemUtilities;
import org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -2282,23 +2280,53 @@ public class VersionConvertor_10_40 extends VersionConvertor_Base {
}
public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_10_40(), extensionsToIgnore);
}
public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, BaseAdvisor_10_40 advisor, 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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(ext -> {
if (advisor.useAdvisorForExtension(ext)) {
Extension convertExtension = new Extension();
advisor.handleExtension(ext, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(ext) && !Arrays.asList(extensionsToIgnore).contains(ext.getUrl())) {
tgt.addExtension(convertExtension(ext));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_10_40::convertExtension)
.forEach(tgt::addModifierExtension);
}
public static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_10_40(), extensionsToIgnore);
}
public static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, BaseAdvisor_10_40 advisor, 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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.dstu2.model.Extension convertExtension = new org.hl7.fhir.dstu2.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_10_40::convertExtension)
.forEach(tgt::addModifierExtension);
}
public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException {
@ -2794,7 +2822,7 @@ public class VersionConvertor_10_40 extends VersionConvertor_Base {
return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem()));
}
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor40 advisor) throws FHIRException {
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2.model.Parameters)
return Parameters10_40.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src);
@ -2917,7 +2945,11 @@ public class VersionConvertor_10_40 extends VersionConvertor_Base {
throw new FHIRException("Unknown resource " + src.fhirType());
}
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, VersionConvertorAdvisor40 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_10_40());
}
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters)
return Parameters10_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src);
@ -2946,7 +2978,7 @@ public class VersionConvertor_10_40 extends VersionConvertor_Base {
if (src instanceof org.hl7.fhir.r4.model.Condition)
return Condition10_40.convertCondition((org.hl7.fhir.r4.model.Condition) src);
if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement)
return Conformance10_40.convertConformance((org.hl7.fhir.r4.model.CapabilityStatement) src);
return Conformance10_40.convertConformance((org.hl7.fhir.r4.model.CapabilityStatement) src, advisor);
if (src instanceof org.hl7.fhir.r4.model.DetectedIssue)
return DetectedIssue10_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src);
if (src instanceof org.hl7.fhir.r4.model.DeviceMetric)
@ -3001,7 +3033,7 @@ public class VersionConvertor_10_40 extends VersionConvertor_Base {
if (src instanceof org.hl7.fhir.r4.model.Practitioner)
return Practitioner10_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src);
if (src instanceof org.hl7.fhir.r4.model.Questionnaire)
return Questionnaire10_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src);
return Questionnaire10_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src, advisor);
if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse)
return QuestionnaireResponse10_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src);
if (src instanceof org.hl7.fhir.r4.model.RiskAssessment)
@ -3044,10 +3076,6 @@ public class VersionConvertor_10_40 extends VersionConvertor_Base {
return convertResource(src, null);
}
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException {
return convertResource(src, null);
}
public static UnsignedIntType convertUnsignedIntToPositive(PositiveIntType src) {
org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType();
copyElement(src, tgt);

View File

@ -1,8 +1,9 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.convertors.conv10_50.*;
import org.hl7.fhir.dstu2.model.CodeableConcept;
import org.hl7.fhir.dstu2.model.Extension;
import org.hl7.fhir.dstu2.model.Parameters;
import org.hl7.fhir.dstu2.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.dstu2.model.Reference;
@ -22,6 +23,7 @@ import org.hl7.fhir.r5.terminologies.CodeSystemUtilities;
import org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -2299,23 +2301,53 @@ public class VersionConvertor_10_50 extends VersionConvertor_Base {
}
public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_10_50(), extensionsToIgnore);
}
public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, BaseAdvisor_10_50 advisor, 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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_10_50::convertExtension)
.forEach(tgt::addModifierExtension);
}
public static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_10_50(), extensionsToIgnore);
}
public static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, BaseAdvisor_10_50 advisor, 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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
Extension convertExtension = new Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_10_50::convertExtension)
.forEach(tgt::addModifierExtension);
}
public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException {
@ -2817,7 +2849,11 @@ public class VersionConvertor_10_50 extends VersionConvertor_Base {
return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem()));
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor50 advisor) throws FHIRException {
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_10_50());
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2.model.Parameters)
return Parameters10_50.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src);
@ -2929,10 +2965,18 @@ public class VersionConvertor_10_50 extends VersionConvertor_Base {
return TestScript10_50.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src);
if (src instanceof org.hl7.fhir.dstu2.model.ValueSet)
return ValueSet10_50.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, VersionConvertorAdvisor50 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_10_50());
}
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters)
return Parameters10_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src);
@ -3018,7 +3062,7 @@ public class VersionConvertor_10_50 extends VersionConvertor_Base {
if (src instanceof org.hl7.fhir.r5.model.Provenance)
return Provenance10_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src);
if (src instanceof org.hl7.fhir.r5.model.Questionnaire)
return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src);
return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src, advisor);
if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse)
return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src);
if (src instanceof org.hl7.fhir.r5.model.RiskAssessment)
@ -3040,7 +3084,11 @@ public class VersionConvertor_10_50 extends VersionConvertor_Base {
return TestScript10_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src);
if (src instanceof org.hl7.fhir.r5.model.ValueSet)
return ValueSet10_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src, advisor);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src) {
@ -3056,12 +3104,4 @@ public class VersionConvertor_10_50 extends VersionConvertor_Base {
public static boolean convertsResource(String rt) {
return Utilities.existsInList(rt, "Parameters", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "Bundle", "CarePlan", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "CapabilityStatement", "DetectedIssue", "DeviceMetric", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Group", "HealthcareService", "ImplementationGuide", "ListResource", "Location", "MedicationDispense", "MedicationStatement", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "Person", "Practitioner", "Questionnaire", "QuestionnaireResponse", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "StructureDefinition", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "TestScript", "ValueSet");
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException {
return convertResource(src, null);
}
public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException {
return convertResource(src, null);
}
}

View File

@ -8,6 +8,7 @@ import org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscri
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;

View File

@ -1,8 +1,11 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_40;
import org.hl7.fhir.convertors.conv14_40.*;
import org.hl7.fhir.dstu2016may.model.CodeableConcept;
import org.hl7.fhir.dstu2016may.model.Extension;
import org.hl7.fhir.dstu2016may.model.Reference;
import org.hl7.fhir.dstu2016may.model.Resource;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.conformance.ProfileUtilities;
import org.hl7.fhir.r4.model.CanonicalType;
@ -11,6 +14,7 @@ import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscrimin
import org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -2401,24 +2405,64 @@ public class VersionConvertor_14_40 extends VersionConvertor_Base {
return ok;
}
static public 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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src,
org.hl7.fhir.r4.model.DomainResource tgt,
String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_14_40(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src,
org.hl7.fhir.r4.model.DomainResource tgt,
BaseAdvisor_14_40 advisor,
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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_14_40::convertExtension)
.forEach(tgt::addModifierExtension);
}
static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src,
org.hl7.fhir.dstu2016may.model.DomainResource tgt,
String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_14_40(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src,
org.hl7.fhir.dstu2016may.model.DomainResource tgt,
BaseAdvisor_14_40 advisor,
String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.dstu2016may.model.Extension convertExtension = new org.hl7.fhir.dstu2016may.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_14_40::convertExtension)
.forEach(tgt::addModifierExtension);
}
static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException {
@ -2650,6 +2694,10 @@ public class VersionConvertor_14_40 extends VersionConvertor_Base {
}
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_14_40());
}
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src, BaseAdvisor_14_40 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters)
return Parameters14_40.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src);
@ -2685,10 +2733,18 @@ public class VersionConvertor_14_40 extends VersionConvertor_Base {
return StructureMap14_40.convertStructureMap((org.hl7.fhir.dstu2016may.model.StructureMap) src);
if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet)
return ValueSet14_40.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_14_40());
}
public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_14_40 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters)
return Parameters14_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src);
@ -2722,7 +2778,11 @@ public class VersionConvertor_14_40 extends VersionConvertor_Base {
return StructureMap14_40.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src);
if (src instanceof org.hl7.fhir.r4.model.ValueSet)
return ValueSet14_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
public static boolean convertsResource(String rt) {

View File

@ -1,5 +1,6 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_50;
import org.hl7.fhir.convertors.conv14_50.*;
import org.hl7.fhir.dstu2016may.model.CodeableConcept;
import org.hl7.fhir.dstu2016may.model.Reference;
@ -11,6 +12,7 @@ import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscrimin
import org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -2425,23 +2427,53 @@ public class VersionConvertor_14_50 extends VersionConvertor_Base {
}
static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_14_50(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, BaseAdvisor_14_50 advisor, 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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(extension -> convertExtension(extension))
.forEach(tgt::addModifierExtension);
}
static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_14_50(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, BaseAdvisor_14_50 advisor, 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())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t));
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension())
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.dstu2016may.model.Extension convertExtension = new org.hl7.fhir.dstu2016may.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_14_50::convertExtension)
.forEach(tgt::addModifierExtension);
}
static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException {
@ -2673,6 +2705,10 @@ public class VersionConvertor_14_50 extends VersionConvertor_Base {
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_14_50());
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src, BaseAdvisor_14_50 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters)
return Parameters14_50.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src);
@ -2708,10 +2744,18 @@ public class VersionConvertor_14_50 extends VersionConvertor_Base {
return StructureMap14_50.convertStructureMap((org.hl7.fhir.dstu2016may.model.StructureMap) src);
if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet)
return ValueSet14_50.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_14_50());
}
public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_14_50 advisor) throws FHIRException {
if (src == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters)
return Parameters14_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src);
@ -2745,7 +2789,11 @@ public class VersionConvertor_14_50 extends VersionConvertor_Base {
return StructureMap14_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src);
if (src instanceof org.hl7.fhir.r5.model.ValueSet)
return ValueSet14_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
public static boolean convertsResource(String rt) {

View File

@ -1,5 +1,6 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.convertors.conv30_40.*;
import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
@ -11,6 +12,7 @@ import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -3140,23 +3142,53 @@ public class VersionConvertor_30_40 extends VersionConvertor_Base {
}
static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_30_40(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, BaseAdvisor_30_40 advisor, 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())
if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2));
for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension())
if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_30_40::convertExtension)
.forEach(tgt::addModifierExtension);
}
static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_30_40(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, BaseAdvisor_30_40 advisor, 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())
if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2));
for (org.hl7.fhir.r4.model.Extension t3 : src.getModifierExtension())
if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_30_40::convertExtension)
.forEach(tgt::addModifierExtension);
}
static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException {
@ -4336,7 +4368,11 @@ public class VersionConvertor_30_40 extends VersionConvertor_Base {
return tgt;
}
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, boolean nullOk) throws FHIRException {
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_30_40());
}
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_30_40 advisor) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.dstu3.model.Parameters)
return Parameters30_40.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src);
@ -4503,11 +4539,15 @@ public class VersionConvertor_30_40 extends VersionConvertor_Base {
return TestScript30_40.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src);
if (src instanceof org.hl7.fhir.dstu3.model.ValueSet)
return ValueSet30_40.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src);
if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) throw new FHIRException("Unknown resource " + src.fhirType());
else return null;
}
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, boolean nullOk) throws FHIRException {
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_30_40());
}
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_30_40 advisor) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters) {
if (((org.hl7.fhir.r4.model.Parameters) src).hasParameter("profile-url"))
@ -4672,7 +4712,7 @@ public class VersionConvertor_30_40 extends VersionConvertor_Base {
return TestScript30_40.convertTestScript((org.hl7.fhir.r4.model.TestScript) src);
if (src instanceof org.hl7.fhir.r4.model.ValueSet)
return ValueSet30_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src);
if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) throw new FHIRException("Unknown resource " + src.fhirType());
else return null;
}

View File

@ -1,5 +1,6 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
import org.hl7.fhir.convertors.conv30_50.*;
import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
@ -8,6 +9,7 @@ import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -3208,34 +3210,70 @@ public class VersionConvertor_30_50 extends VersionConvertor_Base {
throw new FHIRException("Unknown type " + src.fhirType());
}
static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r5.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()) {
if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2));
}
for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) {
if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3));
}
}
static public boolean isExemptExtension(String url, String[] extensionsToIgnore) {
boolean ok = false;
for (String s : extensionsToIgnore) if (s.equals(url)) ok = true;
return ok;
}
static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException {
static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src,
org.hl7.fhir.r5.model.DomainResource tgt,
String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_30_50(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src,
org.hl7.fhir.r5.model.DomainResource tgt,
BaseAdvisor_30_50 advisor,
String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
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()) {
if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2));
}
for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) {
if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3));
}
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_30_50::convertExtension)
.forEach(tgt::addModifierExtension);
}
static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src,
org.hl7.fhir.dstu3.model.DomainResource tgt,
String... extensionsToIgnore) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_30_50(), extensionsToIgnore);
}
static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src,
org.hl7.fhir.dstu3.model.DomainResource tgt,
BaseAdvisor_30_50 advisor,
String... extensionsToIgnore) throws FHIRException {
copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))
.map(VersionConvertor_30_50::convertExtension)
.forEach(tgt::addModifierExtension);
}
static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException {
@ -4594,7 +4632,11 @@ public class VersionConvertor_30_50 extends VersionConvertor_Base {
return tgt;
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, boolean nullOk) throws FHIRException {
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_30_50());
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_30_50 advisor) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.dstu3.model.Parameters)
return Parameters30_50.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src);
@ -4753,11 +4795,15 @@ public class VersionConvertor_30_50 extends VersionConvertor_Base {
return TestScript30_50.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src);
if (src instanceof org.hl7.fhir.dstu3.model.ValueSet)
return ValueSet30_50.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src);
if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) throw new FHIRException("Unknown resource " + src.fhirType());
else return null;
}
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, boolean nullOk) throws FHIRException {
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_30_50());
}
public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_30_50 advisor) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters) {
if (((org.hl7.fhir.r5.model.Parameters) src).hasParameter("profile-url"))
@ -4913,7 +4959,7 @@ public class VersionConvertor_30_50 extends VersionConvertor_Base {
return TestScript30_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src);
if (src instanceof org.hl7.fhir.r5.model.ValueSet)
return ValueSet30_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src);
if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()) throw new FHIRException("Unknown resource " + src.fhirType());
else return null;
}

View File

@ -1,9 +1,11 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
import org.hl7.fhir.convertors.conv40_50.*;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CodeableReference;
import java.util.Arrays;
import java.util.stream.Collectors;
/*
@ -3387,19 +3389,53 @@ public class VersionConvertor_40_50 extends VersionConvertor_Base {
}
protected static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_40_50());
}
protected static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, BaseAdvisor_40_50 advisor) 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));
for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension)) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension))
.map(VersionConvertor_40_50::convertExtension)
.forEach(tgt::addModifierExtension);
}
protected static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException {
copyDomainResource(src, tgt, new BaseAdvisor_40_50());
}
protected static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, BaseAdvisor_40_50 advisor) 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));
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t));
src.getContained().stream()
.map(resource -> convertResource(resource, advisor))
.forEach(tgt::addContained);
src.getExtension().forEach(extension -> {
if (advisor.useAdvisorForExtension(extension)) {
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
advisor.handleExtension(extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension(extension)) {
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension(extension))
.map(VersionConvertor_40_50::convertExtension)
.forEach(tgt::addModifierExtension);
}
protected static void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException {
@ -3417,6 +3453,10 @@ public class VersionConvertor_40_50 extends VersionConvertor_Base {
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_40_50());
}
public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_40_50 advisor) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters)
return Parameters40_50.convertParameters((org.hl7.fhir.r4.model.Parameters) src);
@ -3664,10 +3704,18 @@ public class VersionConvertor_40_50 extends VersionConvertor_Base {
return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r4.model.VerificationResult) src);
if (src instanceof org.hl7.fhir.r4.model.VisionPrescription)
return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r4.model.VisionPrescription) src);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()){
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException {
return convertResource(src, new BaseAdvisor_40_50());
}
public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, BaseAdvisor_40_50 advisor) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters)
return Parameters40_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src);
@ -3916,7 +3964,11 @@ public class VersionConvertor_40_50 extends VersionConvertor_Base {
return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r5.model.VerificationResult) src);
if (src instanceof org.hl7.fhir.r5.model.VisionPrescription)
return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r5.model.VisionPrescription) src);
throw new FHIRException("Unknown resource " + src.fhirType());
if (advisor.failFastOnNullOrUnknownEntry()){
throw new FHIRException("Unknown resource " + src.fhirType());
} else {
return null;
}
}
protected static org.hl7.fhir.r5.model.CodeType convertResourceEnum(org.hl7.fhir.r4.model.CodeType src) {

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication;
@ -23,7 +23,7 @@ public class Bundle10_30 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.Bundle convertBundle(org.hl7.fhir.dstu3.model.Bundle src, VersionConvertorAdvisor30 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Bundle convertBundle(org.hl7.fhir.dstu3.model.Bundle src, BaseAdvisor_10_30 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle();
@ -43,7 +43,7 @@ public class Bundle10_30 {
return convertBundle(src, null);
}
public static org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent src, VersionConvertorAdvisor30 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent src, BaseAdvisor_10_30 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
if (advisor.ignoreEntry(src, FhirPublication.DSTU2))

View File

@ -3,7 +3,7 @@ package org.hl7.fhir.convertors.conv10_30;
import java.util.List;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.dstu2.model.ValueSet;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
@ -185,7 +185,7 @@ public class ValueSet10_30 {
return tgt;
}
public static org.hl7.fhir.dstu3.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, VersionConvertorAdvisor30 advisor) throws FHIRException {
public static org.hl7.fhir.dstu3.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, BaseAdvisor_10_30 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet();
@ -260,7 +260,7 @@ public class ValueSet10_30 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.dstu3.model.ValueSet src, VersionConvertorAdvisor30 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.dstu3.model.ValueSet src, BaseAdvisor_10_30 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet();

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication;
@ -23,7 +23,7 @@ public class Bundle10_40 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.Bundle convertBundle(org.hl7.fhir.r4.model.Bundle src, VersionConvertorAdvisor40 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Bundle convertBundle(org.hl7.fhir.r4.model.Bundle src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle();
@ -62,7 +62,7 @@ public class Bundle10_40 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent src, VersionConvertorAdvisor40 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
if (advisor.ignoreEntry(src, FhirPublication.DSTU2))

View File

@ -2,6 +2,7 @@ package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertorConstants;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent;
import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent;
@ -53,11 +54,11 @@ public class Conformance10_40 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.Conformance convertConformance(org.hl7.fhir.r4.model.CapabilityStatement src) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Conformance convertConformance(org.hl7.fhir.r4.model.CapabilityStatement src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
VersionConvertor_10_40.copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
VersionConvertor_10_40.copyDomainResource(src, tgt, advisor);
if (src.hasUrlElement())
tgt.setUrlElement(VersionConvertor_10_40.convertUri(src.getUrlElement()));
if (src.hasVersionElement())

View File

@ -1,318 +1,336 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.ContactDetail;
import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent;
public class Questionnaire10_40 {
public static org.hl7.fhir.dstu2.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r4.model.Questionnaire src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire();
VersionConvertor_10_40.copyDomainResource(src, tgt);
for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement()));
if (src.hasStatus())
tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
if (src.hasDate())
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement()));
if (src.hasPublisherElement())
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement()));
for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(t1));
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup();
root.setTitle(src.getTitle());
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) {
root.addConcept(VersionConvertor_10_40.convertCoding(t));
public static org.hl7.fhir.dstu2.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r4.model.Questionnaire src, BaseAdvisor_10_40 advisor) {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire();
VersionConvertor_10_40.copyDomainResource(src, tgt, advisor);
for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement()));
if (src.hasStatus())
tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
if (src.hasDate())
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement()));
if (src.hasPublisherElement())
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement()));
for (ContactDetail t : src.getContact())
for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom())
tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(t1));
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup();
root.setTitle(src.getTitle());
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) {
root.addConcept(VersionConvertor_10_40.convertCoding(t));
}
for (org.hl7.fhir.r4.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
if (t.getType() == org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP)
root.addGroup(convertQuestionnaireGroupComponent(t));
else
root.addQuestion(convertQuestionnaireQuestionComponent(t));
return tgt;
}
public static org.hl7.fhir.r4.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu2.model.Questionnaire src) throws FHIRException {
return convertQuestionnaire(src, null);
}
public static org.hl7.fhir.r4.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu2.model.Questionnaire src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Questionnaire tgt = new org.hl7.fhir.r4.model.Questionnaire();
VersionConvertor_10_40.copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement()));
if (src.hasStatus())
tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
if (src.hasDate())
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement()));
if (src.hasPublisherElement())
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement()));
for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
tgt.addContact(convertQuestionnaireContactComponent(t));
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = src.getGroup();
tgt.setTitle(root.getTitle());
for (org.hl7.fhir.dstu2.model.Coding t : root.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
for (org.hl7.fhir.dstu2.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
tgt.addItem(convertQuestionnaireGroupComponent(root));
return tgt;
}
public static org.hl7.fhir.r4.model.ContactDetail convertQuestionnaireContactComponent(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail();
VersionConvertor_10_40.copyElement(src, tgt);
tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(src));
return tgt;
}
public static org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent convertQuestionnaireGroupComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent tgt = new org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addConcept(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
if (t.getType() == org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP)
tgt.addGroup(convertQuestionnaireGroupComponent(t));
else
tgt.addQuestion(convertQuestionnaireQuestionComponent(t));
return tgt;
}
public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireGroupComponent(org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.dstu2.model.Coding t : src.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
tgt.setType(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP);
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
for (org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent t : src.getGroup())
tgt.addItem(convertQuestionnaireGroupComponent(t));
for (org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent t : src.getQuestion())
tgt.addItem(convertQuestionnaireQuestionComponent(t));
return tgt;
}
static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> convertQuestionnaireItemType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormatEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch (src.getValue()) {
case BOOLEAN:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.BOOLEAN);
break;
case DECIMAL:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.DECIMAL);
break;
case INTEGER:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.INTEGER);
break;
case DATE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.DATE);
break;
case DATETIME:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.DATETIME);
break;
case TIME:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.TIME);
break;
case STRING:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.STRING);
break;
case TEXT:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.TEXT);
break;
case URL:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.URL);
break;
case CHOICE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.CHOICE);
break;
case OPENCHOICE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.OPENCHOICE);
break;
case ATTACHMENT:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.ATTACHMENT);
break;
case REFERENCE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.REFERENCE);
break;
case QUANTITY:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.QUANTITY);
break;
default:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.NULL);
break;
}
return tgt;
}
public static org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent convertQuestionnaireQuestionComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent tgt = new org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addConcept(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
if (src.hasType())
tgt.setTypeElement(convertQuestionnaireItemType(src.getTypeElement()));
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
if (src.hasAnswerValueSetElement())
tgt.setOptions(VersionConvertor_10_40.convertCanonicalToReference(src.getAnswerValueSetElement()));
for (QuestionnaireItemAnswerOptionComponent t : src.getAnswerOption())
if (t.hasValueCoding())
try {
tgt.addOption(VersionConvertor_10_40.convertCoding(t.getValueCoding()));
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e);
}
for (org.hl7.fhir.r4.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) if (t.getType() == org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP)
root.addGroup(convertQuestionnaireGroupComponent(t));
else
root.addQuestion(convertQuestionnaireQuestionComponent(t));
return tgt;
}
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
tgt.addGroup(convertQuestionnaireGroupComponent(t));
return tgt;
}
public static org.hl7.fhir.r4.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu2.model.Questionnaire src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Questionnaire tgt = new org.hl7.fhir.r4.model.Questionnaire();
VersionConvertor_10_40.copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement()));
if (src.hasStatus())
tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
if (src.hasDate())
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement()));
if (src.hasPublisherElement())
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement()));
for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) tgt.addContact(convertQuestionnaireContactComponent(t));
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = src.getGroup();
tgt.setTitle(root.getTitle());
for (org.hl7.fhir.dstu2.model.Coding t : root.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
for (org.hl7.fhir.dstu2.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
tgt.addItem(convertQuestionnaireGroupComponent(root));
return tgt;
}
public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireQuestionComponent(org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.dstu2.model.Coding t : src.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
if (src.hasType())
tgt.setTypeElement(convertQuestionnaireQuestionType(src.getTypeElement()));
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
if (src.hasOptions())
tgt.setAnswerValueSetElement(VersionConvertor_10_40.convertReferenceToCanonical(src.getOptions()));
for (org.hl7.fhir.dstu2.model.Coding t : src.getOption())
tgt.addAnswerOption().setValue(VersionConvertor_10_40.convertCoding(t));
for (org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent t : src.getGroup())
tgt.addItem(convertQuestionnaireGroupComponent(t));
return tgt;
}
public static org.hl7.fhir.r4.model.ContactDetail convertQuestionnaireContactComponent(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail();
VersionConvertor_10_40.copyElement(src, tgt);
tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(src));
return tgt;
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> convertQuestionnaireQuestionType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemTypeEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch (src.getValue()) {
case BOOLEAN:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.BOOLEAN);
break;
case DECIMAL:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DECIMAL);
break;
case INTEGER:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.INTEGER);
break;
case DATE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATE);
break;
case DATETIME:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATETIME);
break;
case INSTANT:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATETIME);
break;
case TIME:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TIME);
break;
case STRING:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.STRING);
break;
case TEXT:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TEXT);
break;
case URL:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.URL);
break;
case CHOICE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.CHOICE);
break;
case OPENCHOICE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.OPENCHOICE);
break;
case ATTACHMENT:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.ATTACHMENT);
break;
case REFERENCE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.REFERENCE);
break;
case QUANTITY:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.QUANTITY);
break;
default:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.NULL);
break;
}
return tgt;
}
public static org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent convertQuestionnaireGroupComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent tgt = new org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addConcept(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) if (t.getType() == org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP)
tgt.addGroup(convertQuestionnaireGroupComponent(t));
else
tgt.addQuestion(convertQuestionnaireQuestionComponent(t));
return tgt;
static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus> convertQuestionnaireStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Enumerations.PublicationStatus> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatusEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch (src.getValue()) {
case DRAFT:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.DRAFT);
break;
case ACTIVE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.PUBLISHED);
break;
case RETIRED:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.RETIRED);
break;
default:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.NULL);
break;
}
return tgt;
}
public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireGroupComponent(org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.dstu2.model.Coding t : src.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
tgt.setType(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP);
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
for (org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent t : src.getGroup()) tgt.addItem(convertQuestionnaireGroupComponent(t));
for (org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent t : src.getQuestion()) tgt.addItem(convertQuestionnaireQuestionComponent(t));
return tgt;
}
static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> convertQuestionnaireItemType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormatEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch(src.getValue()) {
case BOOLEAN:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.BOOLEAN);
break;
case DECIMAL:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.DECIMAL);
break;
case INTEGER:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.INTEGER);
break;
case DATE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.DATE);
break;
case DATETIME:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.DATETIME);
break;
case TIME:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.TIME);
break;
case STRING:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.STRING);
break;
case TEXT:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.TEXT);
break;
case URL:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.URL);
break;
case CHOICE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.CHOICE);
break;
case OPENCHOICE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.OPENCHOICE);
break;
case ATTACHMENT:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.ATTACHMENT);
break;
case REFERENCE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.REFERENCE);
break;
case QUANTITY:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.QUANTITY);
break;
default:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat.NULL);
break;
}
return tgt;
}
public static org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent convertQuestionnaireQuestionComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent tgt = new org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addConcept(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
if (src.hasType())
tgt.setTypeElement(convertQuestionnaireItemType(src.getTypeElement()));
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
if (src.hasAnswerValueSetElement())
tgt.setOptions(VersionConvertor_10_40.convertCanonicalToReference(src.getAnswerValueSetElement()));
for (QuestionnaireItemAnswerOptionComponent t : src.getAnswerOption()) if (t.hasValueCoding())
try {
tgt.addOption(VersionConvertor_10_40.convertCoding(t.getValueCoding()));
} catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e);
}
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) tgt.addGroup(convertQuestionnaireGroupComponent(t));
return tgt;
}
public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireQuestionComponent(org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent();
VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement())
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
for (org.hl7.fhir.dstu2.model.Coding t : src.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
if (src.hasTextElement())
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
if (src.hasType())
tgt.setTypeElement(convertQuestionnaireQuestionType(src.getTypeElement()));
if (src.hasRequiredElement())
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
if (src.hasOptions())
tgt.setAnswerValueSetElement(VersionConvertor_10_40.convertReferenceToCanonical(src.getOptions()));
for (org.hl7.fhir.dstu2.model.Coding t : src.getOption()) tgt.addAnswerOption().setValue(VersionConvertor_10_40.convertCoding(t));
for (org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent t : src.getGroup()) tgt.addItem(convertQuestionnaireGroupComponent(t));
return tgt;
}
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> convertQuestionnaireQuestionType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemTypeEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch(src.getValue()) {
case BOOLEAN:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.BOOLEAN);
break;
case DECIMAL:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DECIMAL);
break;
case INTEGER:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.INTEGER);
break;
case DATE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATE);
break;
case DATETIME:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATETIME);
break;
case INSTANT:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATETIME);
break;
case TIME:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TIME);
break;
case STRING:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.STRING);
break;
case TEXT:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TEXT);
break;
case URL:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.URL);
break;
case CHOICE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.CHOICE);
break;
case OPENCHOICE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.OPENCHOICE);
break;
case ATTACHMENT:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.ATTACHMENT);
break;
case REFERENCE:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.REFERENCE);
break;
case QUANTITY:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.QUANTITY);
break;
default:
tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.NULL);
break;
}
return tgt;
}
static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus> convertQuestionnaireStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Enumerations.PublicationStatus> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatusEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch(src.getValue()) {
case DRAFT:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.DRAFT);
break;
case ACTIVE:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.PUBLISHED);
break;
case RETIRED:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.RETIRED);
break;
default:
tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.NULL);
break;
}
return tgt;
}
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Enumerations.PublicationStatus> convertQuestionnaireStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Enumerations.PublicationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch(src.getValue()) {
case DRAFT:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT);
break;
case PUBLISHED:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
break;
case RETIRED:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED);
break;
default:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL);
break;
}
return tgt;
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Enumerations.PublicationStatus> convertQuestionnaireStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Enumerations.PublicationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory());
VersionConvertor_10_40.copyElement(src, tgt);
switch (src.getValue()) {
case DRAFT:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT);
break;
case PUBLISHED:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
break;
case RETIRED:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED);
break;
default:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL);
break;
}
return tgt;
}
}

View File

@ -3,7 +3,7 @@ package org.hl7.fhir.convertors.conv10_40;
import java.util.List;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.dstu2.model.ValueSet;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.BooleanType;
@ -190,7 +190,7 @@ public class ValueSet10_40 {
return convertValueSet(src, null);
}
public static org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, VersionConvertorAdvisor40 advisor) throws FHIRException {
public static org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet();
@ -264,11 +264,11 @@ public class ValueSet10_40 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src, VersionConvertorAdvisor40 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src, BaseAdvisor_10_40 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet();
VersionConvertor_10_40.copyDomainResource(src, tgt);
VersionConvertor_10_40.copyDomainResource(src, tgt, advisor);
if (src.hasUrlElement())
tgt.setUrlElement(VersionConvertor_10_40.convertUri(src.getUrlElement()));
for (org.hl7.fhir.r4.model.Identifier i : src.getIdentifier()) tgt.setIdentifier(VersionConvertor_10_40.convertIdentifier(i));

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_50;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication;
@ -27,7 +27,7 @@ public class Bundle10_50 {
return convertBundle(src, null);
}
public static org.hl7.fhir.dstu2.model.Bundle convertBundle(org.hl7.fhir.r5.model.Bundle src, VersionConvertorAdvisor50 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Bundle convertBundle(org.hl7.fhir.r5.model.Bundle src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle();
@ -62,7 +62,7 @@ public class Bundle10_50 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent src, VersionConvertorAdvisor50 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
if (advisor.ignoreEntry(src, FhirPublication.DSTU2))

View File

@ -2,6 +2,7 @@ package org.hl7.fhir.convertors.conv10_50;
import org.hl7.fhir.convertors.VersionConvertorConstants;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent;
@ -54,10 +55,14 @@ public class Conformance10_50 {
}
public static org.hl7.fhir.dstu2.model.Conformance convertConformance(org.hl7.fhir.r5.model.CapabilityStatement src) throws FHIRException {
return convertConformance(src, new BaseAdvisor_10_50());
}
public static org.hl7.fhir.dstu2.model.Conformance convertConformance(org.hl7.fhir.r5.model.CapabilityStatement src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
VersionConvertor_10_50.copyDomainResource(src, tgt, "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown");
VersionConvertor_10_50.copyDomainResource(src, tgt, advisor);
if (src.hasUrlElement())
tgt.setUrlElement(VersionConvertor_10_50.convertUri(src.getUrlElement()));
if (src.hasVersionElement())

View File

@ -1,10 +1,13 @@
package org.hl7.fhir.convertors.conv10_50;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat;
import org.hl7.fhir.dstu2.model.Resource;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.ContactDetail;
import org.hl7.fhir.r5.model.Questionnaire;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireAnswerConstraint;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent;
@ -34,6 +37,10 @@ public class Questionnaire10_50 {
}
public static org.hl7.fhir.dstu2.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r5.model.Questionnaire src) throws FHIRException {
return convertQuestionnaire(src, new BaseAdvisor_10_50());
}
public static org.hl7.fhir.dstu2.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r5.model.Questionnaire src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire();

View File

@ -3,7 +3,7 @@ package org.hl7.fhir.convertors.conv10_50;
import java.util.List;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.dstu2.model.ValueSet;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.BooleanType;
@ -186,7 +186,7 @@ public class ValueSet10_50 {
return tgt;
}
public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.r5.model.ValueSet src, VersionConvertorAdvisor50 advisor) throws FHIRException {
public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.r5.model.ValueSet src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet();
@ -241,7 +241,7 @@ public class ValueSet10_50 {
return convertValueSet(src, null);
}
public static org.hl7.fhir.r5.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, VersionConvertorAdvisor50 advisor) throws FHIRException {
public static org.hl7.fhir.r5.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, BaseAdvisor_10_50 advisor) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r5.model.ValueSet tgt = new org.hl7.fhir.r5.model.ValueSet();

View File

@ -50,7 +50,7 @@ public class Bundle30_40 {
if (src.hasFullUrl())
tgt.setFullUrlElement(VersionConvertor_30_40.convertUri(src.getFullUrlElement()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource()));
if (src.hasSearch())
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
if (src.hasRequest())
@ -69,7 +69,7 @@ public class Bundle30_40 {
if (src.hasFullUrl())
tgt.setFullUrlElement(VersionConvertor_30_40.convertUri(src.getFullUrlElement()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource()));
if (src.hasSearch())
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
if (src.hasRequest())
@ -133,7 +133,7 @@ public class Bundle30_40 {
if (src.hasLastModified())
tgt.setLastModifiedElement(VersionConvertor_30_40.convertInstant(src.getLastModifiedElement()));
if (src.hasOutcome())
tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome(), false));
tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome()));
return tgt;
}
@ -151,7 +151,7 @@ public class Bundle30_40 {
if (src.hasLastModified())
tgt.setLastModifiedElement(VersionConvertor_30_40.convertInstant(src.getLastModifiedElement()));
if (src.hasOutcome())
tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome(), false));
tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome()));
return tgt;
}

View File

@ -33,7 +33,7 @@ public class Parameters30_40 {
if (src.hasValue())
tgt.setValue(VersionConvertor_30_40.convertType(src.getValue()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource()));
for (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent t : src.getPart()) tgt.addPart(convertParametersParameterComponent(t));
return tgt;
}
@ -48,7 +48,7 @@ public class Parameters30_40 {
if (src.hasValue())
tgt.setValue(VersionConvertor_30_40.convertType(src.getValue()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource()));
for (org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent t : src.getPart()) tgt.addPart(convertParametersParameterComponent(t));
return tgt;
}

View File

@ -50,7 +50,7 @@ public class Bundle30_50 {
if (src.hasFullUrl())
tgt.setFullUrlElement(VersionConvertor_30_50.convertUri(src.getFullUrlElement()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource()));
if (src.hasSearch())
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
if (src.hasRequest())
@ -69,7 +69,7 @@ public class Bundle30_50 {
if (src.hasFullUrl())
tgt.setFullUrlElement(VersionConvertor_30_50.convertUri(src.getFullUrlElement()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource()));
if (src.hasSearch())
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
if (src.hasRequest())
@ -133,7 +133,7 @@ public class Bundle30_50 {
if (src.hasLastModified())
tgt.setLastModifiedElement(VersionConvertor_30_50.convertInstant(src.getLastModifiedElement()));
if (src.hasOutcome())
tgt.setOutcome(VersionConvertor_30_50.convertResource(src.getOutcome(), false));
tgt.setOutcome(VersionConvertor_30_50.convertResource(src.getOutcome()));
return tgt;
}
@ -151,7 +151,7 @@ public class Bundle30_50 {
if (src.hasLastModified())
tgt.setLastModifiedElement(VersionConvertor_30_50.convertInstant(src.getLastModifiedElement()));
if (src.hasOutcome())
tgt.setOutcome(VersionConvertor_30_50.convertResource(src.getOutcome(), false));
tgt.setOutcome(VersionConvertor_30_50.convertResource(src.getOutcome()));
return tgt;
}

View File

@ -33,7 +33,7 @@ public class Parameters30_50 {
if (src.hasValue())
tgt.setValue(VersionConvertor_30_50.convertType(src.getValue()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource()));
for (org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent t : src.getPart()) tgt.addPart(convertParametersParameterComponent(t));
return tgt;
}
@ -48,7 +48,7 @@ public class Parameters30_50 {
if (src.hasValue())
tgt.setValue(VersionConvertor_30_50.convertType(src.getValue()));
if (src.hasResource())
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource(), false));
tgt.setResource(VersionConvertor_30_50.convertResource(src.getResource()));
for (org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent t : src.getPart()) tgt.addPart(convertParametersParameterComponent(t));
return tgt;
}

View File

@ -1,43 +1,36 @@
package org.hl7.fhir.convertors.loaders;
import org.hl7.fhir.dstu3.context.SimpleWorkerContext.IContextResourceLoader;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.ElementDefinition;
import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.utilities.npm.NpmPackage;
import java.util.ArrayList;
import java.util.List;
public abstract class BaseLoaderR3 implements IContextResourceLoader {
public interface ILoaderKnowledgeProvider {
/**
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
}
public static class NullLoaderKnowledgeProvider implements ILoaderKnowledgeProvider {
@Override
public String getResourcePath(Resource resource) {
return null;
}
}
protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/";
protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
protected boolean patchUrls;
protected boolean killPrimitives;;
protected boolean killPrimitives;
private String[] types;
private ILoaderKnowledgeProvider lkp;
@ -46,7 +39,7 @@ public abstract class BaseLoaderR3 implements IContextResourceLoader {
this.types = types;
this.lkp = lkp;
}
public String[] getTypes() {
return types;
}
@ -79,6 +72,4 @@ public abstract class BaseLoaderR3 implements IContextResourceLoader {
r.setUserData("path", path);
}
}
}

View File

@ -1,44 +1,36 @@
package org.hl7.fhir.convertors.loaders;
import org.hl7.fhir.r4.context.SimpleWorkerContext.IContextResourceLoader;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.CanonicalType;
import org.hl7.fhir.r4.model.ElementDefinition;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.utilities.npm.NpmPackage;
import java.util.ArrayList;
import java.util.List;
public abstract class BaseLoaderR4 implements IContextResourceLoader {
public interface ILoaderKnowledgeProvider {
/**
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
}
public static class NullLoaderKnowledgeProvider implements ILoaderKnowledgeProvider {
@Override
public String getResourcePath(Resource resource) {
return null;
}
}
protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/";
protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
protected boolean patchUrls;
protected boolean killPrimitives;;
protected boolean killPrimitives;
private String[] types;
private ILoaderKnowledgeProvider lkp;
@ -47,7 +39,7 @@ public abstract class BaseLoaderR4 implements IContextResourceLoader {
this.types = types;
this.lkp = lkp;
}
public String[] getTypes() {
return types;
}
@ -80,6 +72,4 @@ public abstract class BaseLoaderR4 implements IContextResourceLoader {
r.setUserData("path", path);
}
}
}

View File

@ -1,33 +1,28 @@
package org.hl7.fhir.convertors.loaders;
import com.google.gson.JsonSyntaxException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.npm.NpmPackage;
import com.google.gson.JsonSyntaxException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public abstract class BaseLoaderR5 implements IContextResourceLoader {
public abstract class BaseLoaderR5 implements IContextResourceLoader {
public interface ILoaderKnowledgeProvider {
/**
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
ILoaderKnowledgeProvider forNewPackage(NpmPackage npm) throws JsonSyntaxException, IOException;
}
public static class NullLoaderKnowledgeProvider implements ILoaderKnowledgeProvider {
@Override
public String getResourcePath(Resource resource) {
@ -39,17 +34,16 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
return this;
}
}
protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/";
protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
protected boolean patchUrls;
protected boolean killPrimitives;;
protected boolean killPrimitives;
protected String[] types;
protected ILoaderKnowledgeProvider lkp;
@ -58,7 +52,7 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
this.types = types;
this.lkp = lkp;
}
public String[] getTypes() {
return types;
}
@ -111,9 +105,7 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
} else if (VersionUtilities.isR2BVer(npm.fhirVersion())) {
return new R2016MayToR5Loader(types, lkp.forNewPackage(npm));
} else {
throw new FHIRException("Unsupported FHIR Version "+npm.fhirVersion());
throw new FHIRException("Unsupported FHIR Version " + npm.fhirVersion());
}
}
}

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_14_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_40;
import org.hl7.fhir.dstu2016may.formats.JsonParser;
import org.hl7.fhir.dstu2016may.formats.XmlParser;
import org.hl7.fhir.dstu2016may.model.Resource;
@ -56,9 +56,9 @@ import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r5.model.FhirPublication;
public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResourceLoader, VersionConvertorAdvisor40 {
public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResourceLoader {
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_14_40 advisor = new BaseAdvisor_14_40();
public R2016MayToR4Loader() {
super(new String[0], null);
@ -71,7 +71,7 @@ public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResource
r2016may = new JsonParser().parse(stream);
else
r2016may = new XmlParser().parse(stream);
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_14_40.convertResource(r2016may);
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_14_40.convertResource(r2016may, advisor);
Bundle b;
if (r4 instanceof Bundle)
@ -83,7 +83,7 @@ public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResource
b.addEntry().setResource(r4).setFullUrl(r4 instanceof MetadataResource ? ((MetadataResource) r4).getUrl() : null);
}
for (CodeSystem cs : cslist) {
for (CodeSystem cs : advisor.getCslist()) {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
@ -111,23 +111,4 @@ public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResource
}
return b;
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_14_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_50;
import org.hl7.fhir.dstu2016may.formats.JsonParser;
import org.hl7.fhir.dstu2016may.formats.XmlParser;
import org.hl7.fhir.dstu2016may.model.Resource;
@ -50,13 +50,13 @@ import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertorAdvisor50 {
public class R2016MayToR5Loader extends BaseLoaderR5 {
public R2016MayToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp);
}
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_14_50 advisor = new BaseAdvisor_14_50();
@Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
@ -65,7 +65,7 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor
r2016may = new JsonParser().parse(stream);
else
r2016may = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_14_50.convertResource(r2016may);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_14_50.convertResource(r2016may, advisor);
Bundle b;
if (r5 instanceof Bundle)
@ -77,7 +77,7 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor
b.addEntry().setResource(r5).setFullUrl(r5 instanceof CanonicalResource ? ((CanonicalResource) r5).getUrl() : null);
}
for (CodeSystem cs : cslist) {
for (CodeSystem cs : advisor.getCslist()) {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
@ -116,7 +116,7 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_14_50.convertResource(r2016may);
setPath(r5);
if (!cslist.isEmpty()) {
if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems");
}
if (killPrimitives) {
@ -146,24 +146,4 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor
}
}
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -37,7 +37,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.dstu2.formats.JsonParser;
import org.hl7.fhir.dstu2.formats.XmlParser;
import org.hl7.fhir.dstu2.model.Resource;
@ -49,13 +49,11 @@ import org.hl7.fhir.dstu3.model.MetadataResource;
import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication;
public class R2ToR3Loader extends BaseLoaderR3 implements VersionConvertorAdvisor30 {
public class R2ToR3Loader extends BaseLoaderR3 {
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_10_30 advisor_10_30 = new BaseAdvisor_10_30();
public R2ToR3Loader() {
super(new String[0], new NullLoaderKnowledgeProvider());
@ -63,27 +61,27 @@ public class R2ToR3Loader extends BaseLoaderR3 implements VersionConvertorAdviso
@Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
Resource r2 = null;
Resource r2;
if (isJson)
r2 = new JsonParser().parse(stream);
else
r2 = new XmlParser().parse(stream);
org.hl7.fhir.dstu3.model.Resource r3 = VersionConvertor_10_30.convertResource(r2, this);
org.hl7.fhir.dstu3.model.Resource r3 = VersionConvertor_10_30.convertResource(r2, advisor_10_30);
Bundle b;
if (r3 instanceof Bundle)
if (r3 instanceof Bundle) {
b = (Bundle) r3;
else {
} else {
b = new Bundle();
b.setId(UUID.randomUUID().toString().toLowerCase());
b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r3).setFullUrl(r3 instanceof MetadataResource ? ((MetadataResource) r3).getUrl() : null);
}
for (CodeSystem cs : cslist) {
advisor_10_30.getCslist().forEach(cs -> {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
}
cslist.clear();
});
advisor_10_30.getCslist().clear();
if (killPrimitives) {
List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>();
for (BundleEntryComponent be : b.getEntry()) {
@ -96,33 +94,14 @@ public class R2ToR3Loader extends BaseLoaderR3 implements VersionConvertorAdviso
b.getEntry().removeAll(remove);
}
if (patchUrls) {
for (BundleEntryComponent be : b.getEntry()) {
if (be.hasResource() && be.getResource() instanceof StructureDefinition) {
StructureDefinition sd = (StructureDefinition) be.getResource();
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
}
}
b.getEntry().stream()
.filter(be -> be.hasResource() && be.getResource() instanceof StructureDefinition)
.map(be -> (StructureDefinition) be.getResource())
.forEach(sd -> {
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
});
}
return b;
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.dstu2.formats.JsonParser;
import org.hl7.fhir.dstu2.formats.XmlParser;
import org.hl7.fhir.dstu2.model.Resource;
@ -54,9 +54,9 @@ import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r5.model.FhirPublication;
public class R2ToR4Loader extends BaseLoaderR4 implements VersionConvertorAdvisor40 {
public class R2ToR4Loader extends BaseLoaderR4 {
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_10_40 advisor = new BaseAdvisor_10_40();
public R2ToR4Loader() {
super(new String[0], new NullLoaderKnowledgeProvider());
@ -69,23 +69,24 @@ public class R2ToR4Loader extends BaseLoaderR4 implements VersionConvertorAdviso
r2 = new JsonParser().parse(stream);
else
r2 = new XmlParser().parse(stream);
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_10_40.convertResource(r2, this);
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_10_40.convertResource(r2, advisor);
Bundle b;
if (r4 instanceof Bundle)
if (r4 instanceof Bundle) {
b = (Bundle) r4;
else {
} else {
b = new Bundle();
b.setId(UUID.randomUUID().toString().toLowerCase());
b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r4).setFullUrl(r4 instanceof MetadataResource ? ((MetadataResource) r4).getUrl() : null);
}
// Add any code systems defined as part of processing value sets to the end of the converted Bundle
for (CodeSystem cs : cslist) {
advisor.getCslist().forEach(cs -> {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
}
cslist.clear();
});
advisor.getCslist().clear();
if (killPrimitives) {
List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>();
for (BundleEntryComponent be : b.getEntry()) {
@ -98,33 +99,14 @@ public class R2ToR4Loader extends BaseLoaderR4 implements VersionConvertorAdviso
b.getEntry().removeAll(remove);
}
if (patchUrls) {
for (BundleEntryComponent be : b.getEntry()) {
if (be.hasResource() && be.getResource() instanceof StructureDefinition) {
StructureDefinition sd = (StructureDefinition) be.getResource();
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
}
}
b.getEntry().stream()
.filter(be -> be.hasResource() && be.getResource() instanceof StructureDefinition)
.map(be -> (StructureDefinition) be.getResource())
.forEach(sd -> {
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
});
}
return b;
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.dstu2.formats.JsonParser;
import org.hl7.fhir.dstu2.formats.XmlParser;
import org.hl7.fhir.dstu2.model.Resource;
@ -50,13 +50,13 @@ import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader, VersionConvertorAdvisor50 {
public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader {
public R2ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp);
}
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_10_50 advisor = new BaseAdvisor_10_50();
@Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
@ -65,23 +65,25 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
r2 = new JsonParser().parse(stream);
else
r2 = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_10_50.convertResource(r2, this);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_10_50.convertResource(r2, advisor);
Bundle b;
if (r5 instanceof Bundle)
if (r5 instanceof Bundle) {
b = (Bundle) r5;
else {
} else {
b = new Bundle();
b.setId(UUID.randomUUID().toString().toLowerCase());
b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r5).setFullUrl(r5 instanceof CanonicalResource ? ((CanonicalResource) r5).getUrl() : null);
}
// Add any code systems defined as part of processing value sets to the end of the converted Bundle
for (CodeSystem cs : cslist) {
for (CodeSystem cs : advisor.getCslist()) {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
}
cslist.clear();
advisor.getCslist().clear();
if (killPrimitives) {
List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>();
for (BundleEntryComponent be : b.getEntry()) {
@ -113,9 +115,9 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
r2 = new JsonParser().parse(stream);
else
r2 = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_10_50.convertResource(r2, this);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_10_50.convertResource(r2, advisor);
setPath(r5);
if (!cslist.isEmpty()) {
if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems");
}
if (killPrimitives) {
@ -145,24 +147,4 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
}
}
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_30_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.dstu3.formats.JsonParser;
import org.hl7.fhir.dstu3.formats.XmlParser;
import org.hl7.fhir.dstu3.model.Resource;
@ -50,9 +50,9 @@ import org.hl7.fhir.r4.model.Bundle.BundleType;
import org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind;
public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader, VersionConvertorAdvisor40 {
public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader {
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_30_40 advisor = new BaseAdvisor_30_40();
public R3ToR4Loader() {
super(new String[0], new NullLoaderKnowledgeProvider());
@ -65,7 +65,7 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader
r3 = new JsonParser().parse(stream);
else
r3 = new XmlParser().parse(stream);
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_30_40.convertResource(r3, false);
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_30_40.convertResource(r3, advisor);
Bundle b;
if (r4 instanceof Bundle)
@ -76,7 +76,7 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader
b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r4).setFullUrl(r4 instanceof MetadataResource ? ((MetadataResource) r4).getUrl() : null);
}
for (CodeSystem cs : cslist) {
for (CodeSystem cs : advisor.getCslist()) {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
@ -118,24 +118,4 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader
}
}
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, org.hl7.fhir.r5.model.FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_30_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
import org.hl7.fhir.dstu3.formats.JsonParser;
import org.hl7.fhir.dstu3.formats.XmlParser;
import org.hl7.fhir.dstu3.model.Resource;
@ -50,13 +50,13 @@ import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader, VersionConvertorAdvisor50 {
public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader {
public R3ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp);
}
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_30_50 advisor = new BaseAdvisor_30_50();
@Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
@ -65,7 +65,7 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
r3 = new JsonParser().parse(stream);
else
r3 = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_30_50.convertResource(r3, false);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_30_50.convertResource(r3, advisor);
Bundle b;
if (r5 instanceof Bundle)
@ -76,7 +76,7 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r5).setFullUrl(r5 instanceof CanonicalResource ? ((CanonicalResource) r5).getUrl() : null);
}
for (CodeSystem cs : cslist) {
for (CodeSystem cs : advisor.getCslist()) {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
@ -115,10 +115,10 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
r3 = new JsonParser().parse(stream);
else
r3 = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_30_50.convertResource(r3, false);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_30_50.convertResource(r3);
setPath(r5);
if (!cslist.isEmpty()) {
if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems");
}
if (killPrimitives) {
@ -148,23 +148,4 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
}
}
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.formats.JsonParser;
import org.hl7.fhir.r4.formats.XmlParser;
@ -50,13 +50,13 @@ import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader, VersionConvertorAdvisor50 {
public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader {
public R4ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp);
}
private List<CodeSystem> cslist = new ArrayList<>();
private final BaseAdvisor_40_50 advisor = new BaseAdvisor_40_50();
@Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
@ -65,7 +65,7 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
r4 = new JsonParser().parse(stream);
else
r4 = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_40_50.convertResource(r4);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_40_50.convertResource(r4, advisor);
Bundle b;
if (r5 instanceof Bundle)
@ -76,7 +76,7 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r5).setFullUrl(r5 instanceof CanonicalResource ? ((CanonicalResource) r5).getUrl() : null);
}
for (CodeSystem cs : cslist) {
for (CodeSystem cs : advisor.getCslist()) {
BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl());
be.setResource(cs);
@ -118,7 +118,7 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_40_50.convertResource(r4);
setPath(r5);
if (!cslist.isEmpty()) {
if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems");
}
if (killPrimitives) {
@ -148,23 +148,4 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
}
}
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -37,7 +37,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser;
@ -47,12 +46,13 @@ import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
public class R5ToR5Loader extends BaseLoaderR5 implements VersionConvertorAdvisor50 {
public class R5ToR5Loader extends BaseLoaderR5 {
public R5ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp);
}
// TODO Grahame, will this ever be populated? No conversion is being done?
private List<CodeSystem> cslist = new ArrayList<>();
@Override
@ -143,23 +143,4 @@ public class R5ToR5Loader extends BaseLoaderR5 implements VersionConvertorAdviso
}
}
}
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
cs.setValueSet(vs.getUrl());
cslist.add(cs);
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -22,7 +22,7 @@ public class XVersionLoader {
switch (VersionUtilities.getMajMin(version)) {
case "1.0": return VersionConvertor_10_50.convertResource(new org.hl7.fhir.dstu2.formats.XmlParser().parse(stream));
case "1.4": return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(stream));
case "3.0": return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(stream), false);
case "3.0": return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(stream));
case "4.0": return VersionConvertor_40_50.convertResource(new org.hl7.fhir.r4.formats.XmlParser().parse(stream));
case "5.0": return new org.hl7.fhir.r5.formats.XmlParser().parse(stream);
}
@ -36,7 +36,7 @@ public class XVersionLoader {
switch (VersionUtilities.getMajMin(version)) {
case "1.0": return VersionConvertor_10_50.convertResource(new org.hl7.fhir.dstu2.formats.JsonParser().parse(stream));
case "1.4": return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(stream));
case "3.0": return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(stream), false);
case "3.0": return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(stream));
case "4.0": return VersionConvertor_40_50.convertResource(new org.hl7.fhir.r4.formats.JsonParser().parse(stream));
case "5.0": return new org.hl7.fhir.r5.formats.JsonParser().parse(stream);
}

View File

@ -39,7 +39,7 @@ import java.io.IOException;
import java.util.Date;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.dstu3.formats.IParser.OutputStyle;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
@ -50,7 +50,7 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication;
import org.hl7.fhir.utilities.Utilities;
public class IGPackConverter102 implements VersionConvertorAdvisor30 {
public class IGPackConverter102 extends BaseAdvisor_10_30 {
public static void main(String[] args) throws Exception {
new IGPackConverter102().process();

View File

@ -29,31 +29,13 @@ package org.hl7.fhir.convertors.misc;
*/
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r5.model.FhirPublication;
public class IGR2ConvertorAdvisor implements VersionConvertorAdvisor40 {
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
public class IGR2ConvertorAdvisor extends BaseAdvisor_10_40 {
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -30,28 +30,14 @@ package org.hl7.fhir.convertors.misc;
*/
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.FhirPublication;
import org.hl7.fhir.r5.model.ValueSet;
public class IGR2ConvertorAdvisor5 implements VersionConvertorAdvisor50 {
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
public class IGR2ConvertorAdvisor5 extends BaseAdvisor_10_50 {
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId());
}
@Override
public CodeSystem getCodeSystem(ValueSet src) {
return null;
}
}

View File

@ -9,6 +9,8 @@ import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.hl7.fhir.convertors.*;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.json.JSONUtil;
@ -217,9 +219,9 @@ public class NpmPackageVersionConverter {
} else if (VersionUtilities.isR3Ver(version)) {
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(res);
} else if (VersionUtilities.isR4Ver(version)) {
return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(VersionConvertor_30_40.convertResource(res, false));
return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(VersionConvertor_30_40.convertResource(res));
} else if (VersionUtilities.isR5Ver(version)) {
return new org.hl7.fhir.r5.formats.JsonParser().composeBytes(VersionConvertor_30_50.convertResource(res, false));
return new org.hl7.fhir.r5.formats.JsonParser().composeBytes(VersionConvertor_30_50.convertResource(res));
}
} else if (VersionUtilities.isR4Ver(currentVersion)) {
org.hl7.fhir.r4.model.Resource res = new org.hl7.fhir.r4.formats.JsonParser().parse(cnt);
@ -228,7 +230,7 @@ public class NpmPackageVersionConverter {
} else if (VersionUtilities.isR2BVer(version)) {
return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(VersionConvertor_14_40.convertResource(res));
} else if (VersionUtilities.isR3Ver(version)) {
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(VersionConvertor_30_40.convertResource(res, true));
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(VersionConvertor_30_40.convertResource(res, new BaseAdvisor_30_40(false)));
} else if (VersionUtilities.isR4Ver(version)) {
return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(res);
} else if (VersionUtilities.isR5Ver(version)) {
@ -241,7 +243,7 @@ public class NpmPackageVersionConverter {
} else if (VersionUtilities.isR2BVer(version)) {
return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(VersionConvertor_14_50.convertResource(res));
} else if (VersionUtilities.isR3Ver(version)) {
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(VersionConvertor_30_50.convertResource(res, true));
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(VersionConvertor_30_50.convertResource(res, new BaseAdvisor_30_50(false)));
} else if (VersionUtilities.isR4Ver(version)) {
return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(VersionConvertor_40_50.convertResource(res));
} else if (VersionUtilities.isR5Ver(version)) {

View File

@ -1,13 +1,13 @@
package org.hl7.fhir.convertors.misc;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r5.model.FhirPublication;
class PR2Handler implements VersionConvertorAdvisor40 {
class PR2Handler extends BaseAdvisor_10_40 {
@Override
public boolean ignoreEntry(Bundle.BundleEntryComponent src, FhirPublication publication) {

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.convertors.misc;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
@ -57,7 +57,7 @@ public class PackagePreparer {
Bundle b = (Bundle) r;
for (BundleEntryComponent be : b.getEntry()) {
try {
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_30_40.convertResource(be.getResource(), false);
org.hl7.fhir.r4.model.Resource r4 = VersionConvertor_30_40.convertResource(be.getResource());
if (r4.getId().startsWith(r4.fhirType()+"-"))
be.getResource().setId(r4.getId().substring(r4.fhirType().length()+1));
if (be.getResource().hasId())
@ -69,7 +69,7 @@ public class PackagePreparer {
}
}
} else if (r.hasId())
new org.hl7.fhir.r4.formats.JsonParser().compose(new FileOutputStream(Utilities.path(Utilities.getDirectoryForFile(f.getAbsolutePath()), r.fhirType()+"-"+r.getId()+".json")), VersionConvertor_30_40.convertResource(r, false));
new org.hl7.fhir.r4.formats.JsonParser().compose(new FileOutputStream(Utilities.path(Utilities.getDirectoryForFile(f.getAbsolutePath()), r.fhirType()+"-"+r.getId()+".json")), VersionConvertor_30_40.convertResource(r));
else
System.out.println(f.getName()+" has no id");
} catch (Exception e) {

View File

@ -204,7 +204,7 @@ public class UTGVersionSorter {
System.out.println("Load "+id);
NpmPackage npm = pcm.loadPackage(id);
for (PackageResourceInformation p : npm.listIndexedResources("CodeSystem", "ValueSet")) {
CanonicalResource r = (CanonicalResource) VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(npm.load(p)), false);
CanonicalResource r = (CanonicalResource) VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(npm.load(p)));
res.put(r.getUrl(), r);
}
return res;

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.convertors.txClient;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
@ -70,24 +70,24 @@ public class TerminologyClientR3 implements TerminologyClient {
@Override
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> params) throws FHIRException {
org.hl7.fhir.dstu3.model.ValueSet vs2 = (org.hl7.fhir.dstu3.model.ValueSet) VersionConvertor_30_50.convertResource(vs, false);
org.hl7.fhir.dstu3.model.ExpansionProfile p2 = (org.hl7.fhir.dstu3.model.ExpansionProfile) VersionConvertor_30_50.convertResource(p, false);
org.hl7.fhir.dstu3.model.ValueSet vs2 = (org.hl7.fhir.dstu3.model.ValueSet) VersionConvertor_30_50.convertResource(vs);
org.hl7.fhir.dstu3.model.ExpansionProfile p2 = (org.hl7.fhir.dstu3.model.ExpansionProfile) VersionConvertor_30_50.convertResource(p);
vs2 = client.expandValueset(vs2, p2, params); // todo: second parameter
return (ValueSet) VersionConvertor_30_50.convertResource(vs2, false);
return (ValueSet) VersionConvertor_30_50.convertResource(vs2);
}
@Override
public Parameters validateCS(Parameters pin) throws FHIRException {
org.hl7.fhir.dstu3.model.Parameters p2 = (org.hl7.fhir.dstu3.model.Parameters) VersionConvertor_30_50.convertResource(pin, false);
org.hl7.fhir.dstu3.model.Parameters p2 = (org.hl7.fhir.dstu3.model.Parameters) VersionConvertor_30_50.convertResource(pin);
p2 = client.operateType(org.hl7.fhir.dstu3.model.CodeSystem.class, "validate-code", p2);
return (Parameters) VersionConvertor_30_50.convertResource(p2, false);
return (Parameters) VersionConvertor_30_50.convertResource(p2);
}
@Override
public Parameters validateVS(Parameters pin) throws FHIRException {
org.hl7.fhir.dstu3.model.Parameters p2 = (org.hl7.fhir.dstu3.model.Parameters) VersionConvertor_30_50.convertResource(pin, false);
org.hl7.fhir.dstu3.model.Parameters p2 = (org.hl7.fhir.dstu3.model.Parameters) VersionConvertor_30_50.convertResource(pin);
p2 = client.operateType(org.hl7.fhir.dstu3.model.ValueSet.class, "validate-code", p2);
return (Parameters) VersionConvertor_30_50.convertResource(p2, false);
return (Parameters) VersionConvertor_30_50.convertResource(p2);
}
@Override
@ -110,12 +110,12 @@ public class TerminologyClientR3 implements TerminologyClient {
@Override
public CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException {
return (CapabilityStatement) VersionConvertor_30_50.convertResource(client.getCapabilitiesStatementQuick(), false);
return (CapabilityStatement) VersionConvertor_30_50.convertResource(client.getCapabilitiesStatementQuick());
}
@Override
public Parameters lookupCode(Map<String, String> params) throws FHIRException {
return (Parameters) VersionConvertor_30_50.convertResource(client.lookupCode(params), false);
return (Parameters) VersionConvertor_30_50.convertResource(client.lookupCode(params));
}
@Override
@ -125,7 +125,7 @@ public class TerminologyClientR3 implements TerminologyClient {
@Override
public Bundle validateBatch(Bundle batch) {
return (Bundle) VersionConvertor_30_50.convertResource(client.transaction((org.hl7.fhir.dstu3.model.Bundle) VersionConvertor_30_50.convertResource(batch, false)), false);
return (Bundle) VersionConvertor_30_50.convertResource(client.transaction((org.hl7.fhir.dstu3.model.Bundle) VersionConvertor_30_50.convertResource(batch)));
}
@Override
@ -140,7 +140,7 @@ public class TerminologyClientR3 implements TerminologyClient {
if (r3 == null) {
throw new FHIRException("Unable to fetch resource "+Utilities.pathURL(getAddress(), type, id));
}
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_30_50.convertResource(r3, false);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_30_50.convertResource(r3);
if (r5 != null) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 (internal representation)");
}

View File

@ -0,0 +1,32 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor30
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor30
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor30
import org.hl7.fhir.dstu3.model.CodeSystem
import org.hl7.fhir.dstu3.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_10_30(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor30, CodeSystemAdvisor30, ExtensionAdvisor30<org.hl7.fhir.dstu2.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun ignoreExtension(path: String, url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,49 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor40
import org.hl7.fhir.r4.model.CodeSystem
import org.hl7.fhir.r4.model.Expression
import org.hl7.fhir.r4.model.Type
import org.hl7.fhir.r4.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_10_40(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor40, CodeSystemAdvisor40, ExtensionAdvisor40<org.hl7.fhir.dstu2.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
//todo put only in capabilty statement
//todo methods to convert extension should always take path
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
private val ignoredExtensionTypes = listOf(
Expression::class.java,
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
//todo path - Observation.value
// "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"
//
override fun ignoreExtension(url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun ignoreType(type: Type): Boolean {
return ignoredExtensionTypes.contains(type::class.java)
}
override fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,42 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor50
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.DataType
import org.hl7.fhir.r5.model.Expression
import org.hl7.fhir.r5.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_10_50(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor50, CodeSystemAdvisor50, ExtensionAdvisor50<org.hl7.fhir.dstu2.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
private val ignoredExtensionTypes = listOf(
Expression::class.java,
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun ignoreExtension(url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun ignoreType(type: DataType): Boolean {
return ignoredExtensionTypes.contains(type::class.java)
}
override fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,34 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor30
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor30
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor30
import org.hl7.fhir.dstu3.model.CodeSystem
import org.hl7.fhir.dstu3.model.Type
import org.hl7.fhir.dstu3.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_14_30(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor30, CodeSystemAdvisor30, ExtensionAdvisor30<org.hl7.fhir.dstu2016may.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun ignoreExtension(path: String, url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,43 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor40
import org.hl7.fhir.r4.model.CodeSystem
import org.hl7.fhir.r4.model.Expression
import org.hl7.fhir.r4.model.Type
import org.hl7.fhir.r4.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_14_40(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor40, CodeSystemAdvisor40, ExtensionAdvisor40<org.hl7.fhir.dstu2016may.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
private val ignoredExtensionTypes = listOf(
Expression::class.java,
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun ignoreExtension(url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun ignoreType(type: Type): Boolean {
return ignoredExtensionTypes.contains(type::class.java)
}
override fun handleCodeSystem(tgtcs: org.hl7.fhir.r4.model.CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,34 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor50
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.ValueSet
import java.util.*
open class BaseAdvisor_14_50(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor50, CodeSystemAdvisor50,
ExtensionAdvisor50<org.hl7.fhir.dstu2016may.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun ignoreExtension(url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,38 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor40
import org.hl7.fhir.r4.model.CodeSystem
import org.hl7.fhir.r4.model.Expression
import org.hl7.fhir.r4.model.Extension
import org.hl7.fhir.r4.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_30_40(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor40, CodeSystemAdvisor40, ExtensionAdvisor40<org.hl7.fhir.dstu3.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
private val ignoredExtensionTypes = listOf(
Expression::class.java,
)
override fun ignoreExtension(ext: Extension): Boolean {
return (ignoredUrls.contains(ext.url) || (ignoredExtensionTypes.contains(ext.value::class.java)))
}
override fun handleCodeSystem(tgtcs: CodeSystem, srcvs: ValueSet) {
tgtcs.id = srcvs.id
tgtcs.valueSet = srcvs.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,33 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor50
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.Expression
import org.hl7.fhir.r5.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_30_50(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor50, CodeSystemAdvisor50, ExtensionAdvisor50<org.hl7.fhir.dstu3.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
private val ignoredExtensionTypes = listOf(
Expression::class.java,
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,33 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor50
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor50
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.Expression
import org.hl7.fhir.r5.model.ValueSet
import java.util.ArrayList
open class BaseAdvisor_40_50(val failFast: Boolean = true): BaseAdvisor, BundleAdvisor50, CodeSystemAdvisor50, ExtensionAdvisor50<org.hl7.fhir.r4.model.Extension> {
val cslist = ArrayList<CodeSystem>()
private val ignoredUrls = listOf(
"http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown",
)
private val ignoredExtensionTypes = listOf(
Expression::class.java,
)
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {
tgtcs.id = source.id
tgtcs.valueSet = source.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,11 @@
package org.hl7.fhir.convertors.advisors.interfaces
interface BaseAdvisor {
/**
* During conversion, we may be provided with a null, or unknown Resource. This method returns true if the implementer
* wants to fail fast in an unknown or null state.
*/
@JvmDefault
fun failFastOnNullOrUnknownEntry(): Boolean
}

View File

@ -1,9 +1,6 @@
package org.hl7.fhir.convertors.advisors
package org.hl7.fhir.convertors.advisors.interfaces.bundle
import org.hl7.fhir.dstu3.model.Bundle
import org.hl7.fhir.dstu3.model.CodeSystem
import org.hl7.fhir.dstu3.model.ValueSet
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.r5.model.FhirPublication
/*
@ -43,7 +40,7 @@ import org.hl7.fhir.r5.model.FhirPublication
*
* @author grahame
*/
interface VersionConvertorAdvisor30 {
interface BundleAdvisor30 {
/**
* When processing a bundle during conversion, we can choose whether to ignore an entry in the bundle. We return
@ -59,32 +56,8 @@ interface VersionConvertorAdvisor30 {
* @param targetVersion [FhirPublication] of the target version
* @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation.
*/
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean
/**
* In R2, code systems are internal to value sets, but in subsequent versions, they
* exist as separate resources. The convertor will create the code system, and then
* call this routine for the host to decide what to do with it
*
* It can make it a contained resource, or it can put it somewhere else
*
* @param tgtcs
* @param source
* @throws FHIRException
*/
@Throws(FHIRException::class)
fun handleCodeSystem(tgtcs: CodeSystem?, source: ValueSet?)
/**
* when converting from R3 to R2, and converting a value set, the convertor will need
* to find the code system a value set is referring to, so it can include it inline.
*
* This routine should find the actual resource
*
* @param src
* @return
* @throws FHIRException
*/
@Throws(FHIRException::class)
fun getCodeSystem(src: ValueSet?): CodeSystem?
@JvmDefault
fun ignoreEntry(src: Bundle.BundleEntryComponent, targetVersion: FhirPublication): Boolean {
return false
}
}

View File

@ -1,9 +1,7 @@
package org.hl7.fhir.convertors.advisors
package org.hl7.fhir.convertors.advisors.interfaces.bundle
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.CodeSystem
import org.hl7.fhir.r4.model.ValueSet
import org.hl7.fhir.r4.model.*
import org.hl7.fhir.r5.model.FhirPublication
/*
@ -43,7 +41,7 @@ import org.hl7.fhir.r5.model.FhirPublication
*
* @author grahame
*/
interface VersionConvertorAdvisor40 {
interface BundleAdvisor40 {
/**
* When processing a bundle during conversion, we can choose whether to ignore an entry in the bundle. We return
@ -59,32 +57,8 @@ interface VersionConvertorAdvisor40 {
* @param targetVersion [FhirPublication] of the target version
* @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation.
*/
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean
/**
* In R2, code systems are internal to value sets, but in subsequent versions, they
* exist as separate resources. The convertor will create the code system, and then
* call this routine for the host to decide what to do with it
*
* It can make it a contained resource, or it can put it somewhere else
*
* @param tgtcs
* @param source
* @throws FHIRException
*/
@Throws(FHIRException::class)
fun handleCodeSystem(tgtcs: CodeSystem?, source: ValueSet?)
/**
* when converting from R4 to R2, and converting a value set, the convertor will need
* to find the code system a value set is referring to, so it can include it inline.
*
* This routine should find the actual resource
*
* @param src
* @return
* @throws FHIRException
*/
@Throws(FHIRException::class)
fun getCodeSystem(src: ValueSet?): CodeSystem?
@JvmDefault
fun ignoreEntry(src: Bundle.BundleEntryComponent, targetVersion: FhirPublication): Boolean {
return false
}
}

View File

@ -1,6 +1,8 @@
package org.hl7.fhir.convertors.advisors
package org.hl7.fhir.convertors.advisors.interfaces.bundle
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.r5.model.Expression
import org.hl7.fhir.r5.model.Extension
import org.hl7.fhir.r5.model.Bundle
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.FhirPublication
@ -34,7 +36,7 @@ import org.hl7.fhir.r5.model.ValueSet
POSSIBILITY OF SUCH DAMAGE.
*/
interface VersionConvertorAdvisor50 {
interface BundleAdvisor50 {
/**
* When processing a bundle during conversion, we can choose whether to ignore an entry in the bundle. We return
@ -50,32 +52,8 @@ interface VersionConvertorAdvisor50 {
* @param targetVersion [FhirPublication] of the target version
* @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation.
*/
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean
/**
* In R2, code systems are internal to value sets, but in subsequent versions, they
* exist as separate resources. The convertor will create the code system, and then
* call this routine for the host to decide what to do with it
*
* It can make it a contained resource, or it can put it somewhere else
*
* @param tgtcs
* @param source
* @throws FHIRException
*/
@Throws(FHIRException::class)
fun handleCodeSystem(tgtcs: CodeSystem?, source: ValueSet?)
/**
* when converting from R5 to R2, and converting a value set, the convertor will need
* to find the code system a value set is referring to, so it can include it inline.
*
* This routine should find the actual resource
*
* @param src
* @return
* @throws FHIRException
*/
@Throws(FHIRException::class)
fun getCodeSystem(src: ValueSet?): CodeSystem?
@JvmDefault
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean {
return false
}
}

View File

@ -0,0 +1,77 @@
package org.hl7.fhir.convertors.advisors.interfaces.codesystem
import org.hl7.fhir.dstu3.model.CodeSystem
import org.hl7.fhir.dstu3.model.ValueSet
import org.hl7.fhir.exceptions.FHIRException
import java.util.ArrayList
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/ /**
* This interface is passed into the version conversion routines when on of the
* converters is producing or converting R3 resources.
*
* The interface allows users of the code to
* 1. manage the life cycle of new resources created (or needed) during the conversion process
* 2. manage how unknown content etc is handled
*
* @author grahame
*/
interface CodeSystemAdvisor30 {
/**
* In R2, code systems are internal to value sets, but in subsequent versions, they
* exist as separate resources. The convertor will create the code system, and then
* call this routine for the host to decide what to do with it
*
* It can make it a contained resource, or it can put it somewhere else
*
* @param tgtcs
* @param source
* @throws FHIRException
*/
@JvmDefault
@Throws(FHIRException::class)
fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {}
/**
* when converting from R3 to R2, and converting a value set, the convertor will need
* to find the code system a value set is referring to, so it can include it inline.
*
* This routine should find the actual resource
*
* @param src
* @return
* @throws FHIRException
*/
@JvmDefault
@Throws(FHIRException::class)
fun getCodeSystem(src: ValueSet): CodeSystem? {
return null
}
}

View File

@ -0,0 +1,77 @@
package org.hl7.fhir.convertors.advisors.interfaces.codesystem
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.r4.model.*
import org.hl7.fhir.r5.model.FhirPublication
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/ /**
* This interface is passed into the version conversion routines when on of the
* converters is producing or converting R4 resources.
*
* The interface allows users of the code to
* 1. manage the life cycle of new resources created (or needed) during the conversion process
* 2. manage how unknown content etc is handled
*
* @author grahame
*/
interface CodeSystemAdvisor40 {
/**
* In R2, code systems are internal to value sets, but in subsequent versions, they
* exist as separate resources. The convertor will create the code system, and then
* call this routine for the host to decide what to do with it
*
* It can make it a contained resource, or it can put it somewhere else
*
* @param tgtcs
* @param source
* @throws FHIRException
*/
@JvmDefault
@Throws(FHIRException::class)
fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {}
/**
* when converting from R4 to R2, and converting a value set, the convertor will need
* to find the code system a value set is referring to, so it can include it inline.
*
* This routine should find the actual resource
*
* @param src
* @return
* @throws FHIRException
*/
@JvmDefault
@Throws(FHIRException::class)
fun getCodeSystem(src: ValueSet?): CodeSystem? {
return null
}
}

View File

@ -0,0 +1,71 @@
package org.hl7.fhir.convertors.advisors.interfaces.codesystem
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.r5.model.Expression
import org.hl7.fhir.r5.model.Extension
import org.hl7.fhir.r5.model.Bundle
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.FhirPublication
import org.hl7.fhir.r5.model.ValueSet
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
interface CodeSystemAdvisor50 {
/**
* In R2, code systems are internal to value sets, but in subsequent versions, they
* exist as separate resources. The convertor will create the code system, and then
* call this routine for the host to decide what to do with it
*
* It can make it a contained resource, or it can put it somewhere else
*
* @param tgtcs
* @param source
* @throws FHIRException
*/
@JvmDefault
@Throws(FHIRException::class)
fun handleCodeSystem(tgtcs: CodeSystem, source: ValueSet) {}
/**
* when converting from R5 to R2, and converting a value set, the convertor will need
* to find the code system a value set is referring to, so it can include it inline.
*
* This routine should find the actual resource
*
* @param src
* @return
* @throws FHIRException
*/
@JvmDefault
@Throws(FHIRException::class)
fun getCodeSystem(src: ValueSet): CodeSystem? {
return null
}
}

View File

@ -0,0 +1,73 @@
package org.hl7.fhir.convertors.advisors.interfaces.extension
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.instance.model.api.IBaseExtension
import org.hl7.fhir.dstu3.model.Extension
import org.hl7.fhir.dstu3.model.Type
/**
* When converting an Extension from R4, value types support in the source version are not always supported
* in the target version. For example, if when converting a source R4 Extension to DSTU2, the [Expression] type in the
* source is not supported in the target version.
*
* The default behavior for such conversions of this type is to treat the operation as a 'lossy' conversion,
* ignoring all non-supported fields. However, if identified ahead of time, developers can utilize a convertor
* advisor to process these unsupported [Extension] as they see fit.
*
*/
interface ExtensionAdvisor30<T: IBaseExtension<T,*>> {
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(path: String, ext: Extension): Boolean {
return ignoreExtension(path, ext.url) || ignoreType(path, ext.value)
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(path: String, ext: T): Boolean {
return ignoreExtension(path, ext.url) || ignoreType(path, ext.value)
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(path: String, url: String): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(path: String, type: Any): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(path: String, type: Type): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun useAdvisorForExtension(path: String, ext: Extension): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun useAdvisorForExtension(path: String, ext: T): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun handleExtension(path: String, src: Extension, tgt: T) {
// Override to add code to handle specific extensions
}
@JvmDefault
@Throws(FHIRException::class)
fun handleExtension(path: String, src: T, tgt: Extension) {
// Override to add code to handle specific extensions
}
}

View File

@ -0,0 +1,73 @@
package org.hl7.fhir.convertors.advisors.interfaces.extension
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.instance.model.api.IBaseExtension
import org.hl7.fhir.r4.model.Extension
import org.hl7.fhir.r4.model.Type
/**
* When converting an Extension from R4, value types support in the source version are not always supported
* in the target version. For example, if when converting a source R4 Extension to DSTU2, the [Expression] type in the
* source is not supported in the target version.
*
* The default behavior for such conversions of this type is to treat the operation as a 'lossy' conversion,
* ignoring all non-supported fields. However, if identified ahead of time, developers can utilize a convertor
* advisor to process these unsupported [Extension] as they see fit.
*
*/
interface ExtensionAdvisor40<T : IBaseExtension<T, *>> {
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(ext: Extension): Boolean {
return ext.url?.let { ignoreExtension(ext.url) } ?: false || ext.value?.let { ignoreType(ext.value) } ?: false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(ext: T): Boolean {
return ext.url?.let { ignoreExtension(ext.url) } ?: false || ext.value?.let { ignoreType(ext.value) } ?: false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(url: String): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(type: Any): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(type: Type): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun useAdvisorForExtension(ext: Extension): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun useAdvisorForExtension(ext: T): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun handleExtension(src: Extension, tgt: T) {
// Override to add code to handle specific extensions
}
@JvmDefault
@Throws(FHIRException::class)
fun handleExtension(src: T, tgt: Extension) {
// Override to add code to handle specific extensions
}
}

View File

@ -0,0 +1,73 @@
package org.hl7.fhir.convertors.advisors.interfaces.extension
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.instance.model.api.IBaseExtension
import org.hl7.fhir.r5.model.DataType
import org.hl7.fhir.r5.model.Extension
/**
* When converting an Extension from R4, value types support in the source version are not always supported
* in the target version. For example, if when converting a source R4 Extension to DSTU2, the [Expression] type in the
* source is not supported in the target version.
*
* The default behavior for such conversions of this type is to treat the operation as a 'lossy' conversion,
* ignoring all non-supported fields. However, if identified ahead of time, developers can utilize a convertor
* advisor to process these unsupported [Extension] as they see fit.
*
*/
interface ExtensionAdvisor50<T: IBaseExtension<T, *>> {
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(ext: Extension): Boolean {
return ext.url?.let { ignoreExtension(ext.url) } ?: false || ext.value?.let { ignoreType(ext.value) } ?: false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(ext: T): Boolean {
return ext.url?.let { ignoreExtension(ext.url) } ?: false || ext.value?.let { ignoreType(ext.value) } ?: false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(url: String): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(type: DataType): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(type: Any): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun useAdvisorForExtension(ext: Extension): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun useAdvisorForExtension(ext: T): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun handleExtension(src: Extension, tgt: T) {
// Override to add code to handle specific extensions
}
@JvmDefault
@Throws(FHIRException::class)
fun handleExtension(src: T, tgt: Extension) {
// Override to add code to handle specific extensions
}
}

View File

@ -0,0 +1,4 @@
package org.hl7.fhir.convertors.loaders
class BaseLoader {
}

View File

@ -35,7 +35,7 @@ public class VersionConvertorPrimitiveType30_50Test {
@Test
public void testAuditEvent() throws FHIRFormatError, IOException {
org.hl7.fhir.dstu3.model.AuditEvent ae3 = (org.hl7.fhir.dstu3.model.AuditEvent) new org.hl7.fhir.dstu3.formats.JsonParser().parse(AUDIT_EVENT_SOURCE);
org.hl7.fhir.r5.model.AuditEvent ae5 = (org.hl7.fhir.r5.model.AuditEvent) VersionConvertor_30_50.convertResource(ae3, false);
org.hl7.fhir.r5.model.AuditEvent ae5 = (org.hl7.fhir.r5.model.AuditEvent) VersionConvertor_30_50.convertResource(ae3);
Assertions.assertEquals(ae5.getId(), ae3.getId());
}
@ -43,7 +43,7 @@ public class VersionConvertorPrimitiveType30_50Test {
@Test
public void testProvenance() throws FHIRFormatError, IOException {
org.hl7.fhir.dstu3.model.Provenance ae3 = (org.hl7.fhir.dstu3.model.Provenance) new org.hl7.fhir.dstu3.formats.JsonParser().parse(PROVENANCE_SOURCE);
org.hl7.fhir.r5.model.Provenance ae5 = (org.hl7.fhir.r5.model.Provenance) VersionConvertor_30_50.convertResource(ae3, false);
org.hl7.fhir.r5.model.Provenance ae5 = (org.hl7.fhir.r5.model.Provenance) VersionConvertor_30_50.convertResource(ae3);
Assertions.assertEquals(ae5.getId(), ae3.getId());
}

View File

@ -0,0 +1,65 @@
package org.hl7.fhir.convertors.advisors;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.advisors.support.ExpressionAdvisor40;
import org.hl7.fhir.r4.model.Expression;
import org.hl7.fhir.r4.model.Extension;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Expression40Test {
@Test
@DisplayName("Test ValueExpression conversion R4 -> DSTU3, without advisor. Lossy conversion.")
public void testValueExpressionConversion40_10() throws IOException {
InputStream r4_stream = this.getClass().getResourceAsStream("/questionnaire_with_expression_40.json");
org.hl7.fhir.r4.model.Questionnaire r4_input = (org.hl7.fhir.r4.model.Questionnaire) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_stream);
InputStream r2_stream = this.getClass().getResourceAsStream("/questionnaire_with_omitted_expression_40_10.json");
org.hl7.fhir.dstu2.model.Questionnaire r2_expected_output = (org.hl7.fhir.dstu2.model.Questionnaire) new org.hl7.fhir.dstu2.formats.JsonParser().parse(r2_stream);
org.hl7.fhir.dstu2.model.Questionnaire convertedDstu2Questionnaire = (org.hl7.fhir.dstu2.model.Questionnaire) VersionConvertor_10_40.convertResource(r4_input);
org.hl7.fhir.dstu2.formats.JsonParser dstu2_parser = new org.hl7.fhir.dstu2.formats.JsonParser();
String composeString1 = dstu2_parser.composeString(convertedDstu2Questionnaire);
String composeString2 = dstu2_parser.composeString(r2_expected_output);
System.out.println("Expected out ->\n"+ composeString2 + "\n\nActual out ->\n" + composeString1);
Assertions.assertTrue(r2_expected_output.equalsDeep(convertedDstu2Questionnaire));
}
@Test
@DisplayName("Ensure base advisor ignores Expression types and doesn't explode.")
public void testBaseAdvisorExpressionIgore() throws IOException {
Expression exp = new Expression();
exp.setExpression("x + y = z");
Extension ext = new Extension();
ext.setValue(exp);
BaseAdvisor_10_40 baseAdvisor1040 = new BaseAdvisor_10_40();
Assertions.assertTrue(baseAdvisor1040.ignoreExtension(ext));
}
@Test
@DisplayName("Test Advisor is used in Expression R4 -> DSTU3 conversion.")
public void testAdvisorExpressionConversion40_10() throws IOException {
InputStream r4_stream = this.getClass().getResourceAsStream("/questionnaire_with_expression_40.json");
org.hl7.fhir.r4.model.Questionnaire r4_input = (org.hl7.fhir.r4.model.Questionnaire) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_stream);
InputStream r2_stream = this.getClass().getResourceAsStream("/questionnaire_with_converted_expression_40_10.json");
org.hl7.fhir.dstu2.model.Questionnaire r2_expected_output = (org.hl7.fhir.dstu2.model.Questionnaire) new org.hl7.fhir.dstu2.formats.JsonParser().parse(r2_stream);
org.hl7.fhir.dstu2.model.Questionnaire convertedDstu2Questionnaire = (org.hl7.fhir.dstu2.model.Questionnaire) VersionConvertor_10_40.convertResource(r4_input, new ExpressionAdvisor40());
org.hl7.fhir.dstu2.formats.JsonParser dstu2_parser = new org.hl7.fhir.dstu2.formats.JsonParser();
String composeString1 = dstu2_parser.composeString(convertedDstu2Questionnaire);
String composeString2 = dstu2_parser.composeString(r2_expected_output);
System.out.println("Expected out ->\n"+ composeString2 + "\n\nActual out ->\n" + composeString1);
Assertions.assertTrue(r2_expected_output.equalsDeep(convertedDstu2Questionnaire));
}
}

View File

@ -0,0 +1,65 @@
package org.hl7.fhir.convertors.advisors;
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.convertors.advisors.support.ExpressionAdvisor50;
import org.hl7.fhir.r5.model.Expression;
import org.hl7.fhir.r5.model.Extension;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Expression50Test {
@Test
@DisplayName("Test ValueExpression conversion R5 -> DSTU2, without advisor. Lossy conversion.")
public void testValueExpressionConversion50_10() throws IOException {
InputStream r5_stream = this.getClass().getResourceAsStream("/questionnaire_with_expression_50.json");
org.hl7.fhir.r5.model.Questionnaire r5_input = (org.hl7.fhir.r5.model.Questionnaire) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_stream);
InputStream r2_stream = this.getClass().getResourceAsStream("/questionnaire_with_omitted_expression_40_10.json");
org.hl7.fhir.dstu2.model.Questionnaire r2_expected_output = (org.hl7.fhir.dstu2.model.Questionnaire) new org.hl7.fhir.dstu2.formats.JsonParser().parse(r2_stream);
org.hl7.fhir.dstu2.model.Questionnaire convertedDstu2Questionnaire = (org.hl7.fhir.dstu2.model.Questionnaire) VersionConvertor_10_50.convertResource(r5_input);
org.hl7.fhir.dstu2.formats.JsonParser dstu2_parser = new org.hl7.fhir.dstu2.formats.JsonParser();
String composeString1 = dstu2_parser.composeString(convertedDstu2Questionnaire);
String composeString2 = dstu2_parser.composeString(r2_expected_output);
System.out.println("Expected out ->\n"+ composeString2 + "\n\nActual out ->\n" + composeString1);
Assertions.assertTrue(r2_expected_output.equalsDeep(convertedDstu2Questionnaire));
}
@Test
@DisplayName("Ensure base advisor ignores Expression types and doesn't explode.")
public void testBaseAdvisorExpressionIgore() throws IOException {
Expression exp = new Expression();
exp.setExpression("x + y = z");
Extension ext = new Extension();
ext.setValue(exp);
BaseAdvisor_10_50 baseAdvisor50 = new BaseAdvisor_10_50();
Assertions.assertTrue(baseAdvisor50.ignoreExtension(ext));
}
@Test
@DisplayName("Test Advisor is used in Expression R5 -> DSTU3 conversion.")
public void testAdvisorExpressionConversion50_10() throws IOException {
InputStream r5_stream = this.getClass().getResourceAsStream("/questionnaire_with_expression_50.json");
org.hl7.fhir.r5.model.Questionnaire r5_input = (org.hl7.fhir.r5.model.Questionnaire) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_stream);
InputStream r2_stream = this.getClass().getResourceAsStream("/questionnaire_with_converted_expression_40_10.json");
org.hl7.fhir.dstu2.model.Questionnaire r2_expected_output = (org.hl7.fhir.dstu2.model.Questionnaire) new org.hl7.fhir.dstu2.formats.JsonParser().parse(r2_stream);
org.hl7.fhir.dstu2.model.Questionnaire convertedDstu2Questionnaire = (org.hl7.fhir.dstu2.model.Questionnaire) VersionConvertor_10_50.convertResource(r5_input, new ExpressionAdvisor50());
org.hl7.fhir.dstu2.formats.JsonParser dstu2_parser = new org.hl7.fhir.dstu2.formats.JsonParser();
String composeString1 = dstu2_parser.composeString(convertedDstu2Questionnaire);
String composeString2 = dstu2_parser.composeString(r2_expected_output);
System.out.println("Expected out ->\n"+ composeString2 + "\n\nActual out ->\n" + composeString1);
Assertions.assertTrue(r2_expected_output.equalsDeep(convertedDstu2Questionnaire));
}
}

View File

@ -0,0 +1,29 @@
package org.hl7.fhir.convertors.advisors.support
import org.hl7.fhir.convertors.VersionConvertor_10_40
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40
import org.hl7.fhir.dstu2.model.StringType
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.r4.model.Expression
import org.hl7.fhir.r4.model.Extension
class ExpressionAdvisor40 : BaseAdvisor_10_40() {
@Throws(FHIRException::class)
override fun useAdvisorForExtension(ext: Extension): Boolean {
return ext.hasValue() && ext.value is Expression
}
@Throws(FHIRException::class)
override fun handleExtension(src: Extension, tgt: org.hl7.fhir.dstu2.model.Extension) {
when {
(src.value is Expression) -> {
val type = StringType()
type.valueAsString = (src.value as Expression).expression
tgt.setValue(type)
if (src.hasUrlElement()) tgt.urlElement = VersionConvertor_10_40.convertUri(src.urlElement)
}
else -> throw FHIRException("Unknown extension type passed in to custom convertor method.")
}
}
}

View File

@ -0,0 +1,27 @@
package org.hl7.fhir.convertors.advisors.support
import org.hl7.fhir.convertors.VersionConvertor_10_50
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50
import org.hl7.fhir.dstu2.model.StringType
import org.hl7.fhir.exceptions.FHIRException
import org.hl7.fhir.r5.model.Expression
import org.hl7.fhir.r5.model.Extension
open class ExpressionAdvisor50 : BaseAdvisor_10_50() {
override fun useAdvisorForExtension(ext: Extension): Boolean {
return ext.hasValue() && ext.value is Expression
}
override fun handleExtension(src: Extension, tgt: org.hl7.fhir.dstu2.model.Extension) {
when {
(src.value is Expression) -> {
val type = StringType()
type.valueAsString = (src.value as Expression).expression
tgt.setValue(type)
if (src.hasUrlElement()) tgt.urlElement = VersionConvertor_10_50.convertUri(src.urlElement)
}
else -> throw FHIRException("Unknown extension type passed in to custom convertor method.")
}
}
}

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.convertors.loaders.R2ToR3Loader;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@ -16,7 +16,6 @@ public class AdministrativeGender10_30Test {
public void testMedicationRequestConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/administrative_gender_null.json");
org.hl7.fhir.dstu2.model.Patient dstu2 = (org.hl7.fhir.dstu2.model.Patient) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor30 advisor = new R2ToR3Loader();
org.hl7.fhir.dstu3.model.Resource stu_actual = VersionConvertor_10_30.convertResource(dstu2, advisor);
VersionConvertor_10_30.convertResource(dstu2, new BaseAdvisor_10_30());
}
}

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.convertors.loaders.R2ToR3Loader;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -29,8 +29,7 @@ public class AllergyIntolerance10_30Test {
InputStream stu_exepected_input = this.getClass().getResourceAsStream(stu_path);
org.hl7.fhir.dstu2.model.AllergyIntolerance dstu2 = (org.hl7.fhir.dstu2.model.AllergyIntolerance) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor30 advisor = new R2ToR3Loader();
org.hl7.fhir.dstu3.model.Resource stu_actual = VersionConvertor_10_30.convertResource(dstu2, advisor);
org.hl7.fhir.dstu3.model.Resource stu_actual = VersionConvertor_10_30.convertResource(dstu2, new BaseAdvisor_10_30());
org.hl7.fhir.dstu3.formats.JsonParser stu_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource stu_expected = stu_parser.parse(stu_exepected_input);

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -14,35 +14,35 @@ import java.io.InputStream;
import java.util.stream.Stream;
public class AllergyIntolerance10_40Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(
Arguments.of("/0_allergy_intolerance_10.json", "/0_allergy_intolerance_40.json"),
Arguments.of("/1_allergy_intolerance_10.json", "/1_allergy_intolerance_40.json")
);
}
@ParameterizedTest
@MethodSource("filesPaths")
@DisplayName("Test 10_40 AllergyIntolerance conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_path);
org.hl7.fhir.dstu2.model.AllergyIntolerance dstu2 = (org.hl7.fhir.dstu2.model.AllergyIntolerance) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
if (!r4_expected.equalsDeep(r4_actual)) {
System.out.println("Expected");
System.out.println(r4_parser.composeString(r4_expected));
System.out.println();
System.out.println("Actual");
System.out.println(r4_parser.composeString(r4_actual));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)
);
private static Stream<Arguments> filesPaths() {
return Stream.of(
Arguments.of("/0_allergy_intolerance_10.json", "/0_allergy_intolerance_40.json"),
Arguments.of("/1_allergy_intolerance_10.json", "/1_allergy_intolerance_40.json")
);
}
@ParameterizedTest
@MethodSource("filesPaths")
@DisplayName("Test 10_40 AllergyIntolerance conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_path);
org.hl7.fhir.dstu2.model.AllergyIntolerance dstu2 = (org.hl7.fhir.dstu2.model.AllergyIntolerance) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
if (!r4_expected.equalsDeep(r4_actual)) {
System.out.println("Expected");
System.out.println(r4_parser.composeString(r4_expected));
System.out.println();
System.out.println("Actual");
System.out.println(r4_parser.composeString(r4_actual));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)
);
}
}

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -11,21 +11,21 @@ import java.io.IOException;
import java.io.InputStream;
public class Medication10_40Test {
@Test
@DisplayName("Test 10_40 Medication conversion")
public void testMedicationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_medication_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_medication_40.json");
@Test
@DisplayName("Test 10_40 Medication conversion")
public void testMedicationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_medication_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_medication_40.json");
org.hl7.fhir.dstu2.model.Medication dstu2 = (org.hl7.fhir.dstu2.model.Medication) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.dstu2.model.Medication dstu2 = (org.hl7.fhir.dstu2.model.Medication) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
}

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -14,29 +14,29 @@ import java.io.InputStream;
import java.util.stream.Stream;
public class MedicationRequest10_40Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(
Arguments.of("/0_medication_request_10.json", "/0_medication_request_40.json"),
Arguments.of("/1_medication_request_10.json", "/1_medication_request_40.json")
);
}
private static Stream<Arguments> filesPaths() {
return Stream.of(
Arguments.of("/0_medication_request_10.json", "/0_medication_request_40.json"),
Arguments.of("/1_medication_request_10.json", "/1_medication_request_40.json")
);
}
@ParameterizedTest
@MethodSource("filesPaths")
@DisplayName("Test 10_40 MedicationRequest conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_path);
@ParameterizedTest
@MethodSource("filesPaths")
@DisplayName("Test 10_40 MedicationRequest conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_path);
org.hl7.fhir.dstu2.model.MedicationOrder dstu2 = (org.hl7.fhir.dstu2.model.MedicationOrder) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.dstu2.model.MedicationOrder dstu2 = (org.hl7.fhir.dstu2.model.MedicationOrder) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
}

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -11,21 +11,21 @@ import java.io.IOException;
import java.io.InputStream;
public class Observation10_40Test {
@Test
@DisplayName("Test 10_40 Observation conversion")
public void testObservationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_observation_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_observation_40.json");
@Test
@DisplayName("Test 10_40 Observation conversion")
public void testObservationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_observation_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_observation_40.json");
org.hl7.fhir.dstu2.model.Observation dstu2 = (org.hl7.fhir.dstu2.model.Observation) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.dstu2.model.Observation dstu2 = (org.hl7.fhir.dstu2.model.Observation) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
}

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -11,21 +11,21 @@ import java.io.IOException;
import java.io.InputStream;
public class Procedure10_40Test {
@Test
@DisplayName("Test 10_40 Procedure conversion")
public void testProcedureConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_procedure_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_procedure_40.json");
@Test
@DisplayName("Test 10_40 Procedure conversion")
public void testProcedureConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_procedure_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_procedure_40.json");
org.hl7.fhir.dstu2.model.Procedure dstu2 = (org.hl7.fhir.dstu2.model.Procedure) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.dstu2.model.Procedure dstu2 = (org.hl7.fhir.dstu2.model.Procedure) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
}

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.hl7.fhir.r4.formats.JsonParser;
import org.junit.jupiter.api.Assertions;
@ -12,23 +12,23 @@ import java.io.IOException;
import java.io.InputStream;
public class ValueSet10_40Test {
@Test
@DisplayName("Test 10_40 ValueSet conversion")
public void testValueSetConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_valueset_vision_base_codes_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_valueset_vision_base_codes_40.json");
@Test
@DisplayName("Test 10_40 ValueSet conversion")
public void testValueSetConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_valueset_vision_base_codes_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_valueset_vision_base_codes_40.json");
org.hl7.fhir.dstu2.model.ValueSet dstu2 = (org.hl7.fhir.dstu2.model.ValueSet) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.dstu2.model.ValueSet dstu2 = (org.hl7.fhir.dstu2.model.ValueSet) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
JsonParser parser = new JsonParser();
String composeString = parser.composeString(r4_actual);
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
JsonParser parser = new JsonParser();
String composeString = parser.composeString(r4_actual);
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
}

View File

@ -1,6 +1,7 @@
package org.hl7.fhir.convertors.conv30_40;
import org.hl7.fhir.convertors.VersionConvertor_30_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@ -16,7 +17,7 @@ public class Device30_40Test {
InputStream dstu3_expected_output = this.getClass().getResourceAsStream("/0_device_30.json");
org.hl7.fhir.r4.model.Device r4_actual = (org.hl7.fhir.r4.model.Device) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_input);
org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertor_30_40.convertResource(r4_actual, true);
org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertor_30_40.convertResource(r4_actual, new BaseAdvisor_30_40(false));
org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
@ -32,7 +33,7 @@ public class Device30_40Test {
InputStream dstu3_expected_output = this.getClass().getResourceAsStream("/1_device_30.json");
org.hl7.fhir.r4.model.Device r4_actual = (org.hl7.fhir.r4.model.Device) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_input);
org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertor_30_40.convertResource(r4_actual, true);
org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertor_30_40.convertResource(r4_actual, new BaseAdvisor_30_40(false));
org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);

View File

@ -1,20 +1,42 @@
{"resourceType": "AllergyIntolerance",
{
"resourceType": "AllergyIntolerance",
"recordedDate": "2015-11-07T22:56:34",
"status": "confirmed",
"criticality": "CRITH",
"id": "TKebKfLXzu6Sp.LY-IpvpmQB",
"onset": "2014-03-07T00:00:00Z",
"recorder": {"display": "MOORE, NICK",
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB"},
"patient": {"display": "Jason Argonaut",
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"},
"substance": {"text": "STRAWBERRY",
"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "892484",
"display": "STRAWBERRY"},
{"system": "http://fdasis.nlm.nih.gov",
"recorder": {
"display": "MOORE, NICK",
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB"
},
"patient": {
"display": "Jason Argonaut",
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"
},
"substance": {
"text": "STRAWBERRY",
"coding": [
{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "892484",
"display": "STRAWBERRY"
},
{
"system": "http://fdasis.nlm.nih.gov",
"code": "4J2TY8Y81V",
"display": "STRAWBERRY"}]},
"reaction": [{"certainty": "confirmed",
"onset": "2014-03-07T00:00:00Z",
"manifestation": [{"text": "Anaphylaxis"}]}]}
"display": "STRAWBERRY"
}
]
},
"reaction": [
{
"certainty": "confirmed",
"onset": "2014-03-07T00:00:00Z",
"manifestation": [
{
"text": "Anaphylaxis"
}
]
}
]
}

View File

@ -0,0 +1,147 @@
{
"resourceType": "Questionnaire",
"id": "3141",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>\n 1.Comorbidity?\n 1.1 Cardial Comorbidity\n 1.1.1 Angina?\n 1.1.2 MI?\n 1.2 Vascular Comorbidity?\n ...\n Histopathology\n Abdominal\n pT category?\n ...\n </pre>\n </div>"
},
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression",
"valueString": "%resource.item I where (I.linkId = 'a1' and I.answer[0].value <> 0) or (I.linkId = 'a2' and I.answer[0].value in { 1, 2 })"
}
],
"status": "draft",
"date": "2012-01",
"subjectType": [
"Patient"
],
"group": {
"title": "Cancer Quality Forum Questionnaire 2012",
"group": [
{
"linkId": "1",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "COMORBIDITY"
}
],
"question": [
{
"linkId": "1.1",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORB"
}
],
"type": "choice",
"options": {
"reference": "http://hl7.org/fhir/ValueSet/yesnodontknow"
},
"group": [
{
"linkId": "1.1.1",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "CARDIAL"
}
],
"question": [
{
"linkId": "1.1.1.1",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBCAR"
}
],
"type": "choice",
"options": {
"reference": "http://hl7.org/fhir/ValueSet/yesnodontknow"
},
"group": [
{
"linkId": "1.1.1.1.1",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMCAR00",
"display": "Angina Pectoris"
},
{
"system": "http://snomed.info/sct",
"code": "194828000",
"display": "Angina (disorder)"
}
]
},
{
"linkId": "1.1.1.1.2",
"concept": [
{
"system": "http://snomed.info/sct",
"code": "22298006",
"display": "Myocardial infarction (disorder)"
}
]
}
]
},
{
"linkId": "1.1.1.2",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBVAS"
}
],
"type": "choice",
"options": {
"reference": "http://hl7.org/fhir/ValueSet/yesnodontknow"
}
}
]
}
]
}
]
},
{
"linkId": "2",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "HISTOPATHOLOGY"
}
],
"group": [
{
"linkId": "2.1",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "ABDOMINAL"
}
],
"question": [
{
"linkId": "2.1.2",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "STADPT",
"display": "pT category"
}
],
"type": "choice"
}
]
}
]
}
]
}
}

View File

@ -0,0 +1,166 @@
{
"resourceType": "Questionnaire",
"id": "3141",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>\n 1.Comorbidity?\n 1.1 Cardial Comorbidity\n 1.1.1 Angina?\n 1.1.2 MI?\n 1.2 Vascular Comorbidity?\n ...\n Histopathology\n Abdominal\n pT category?\n ...\n </pre>\n </div>"
},
"url": "http://hl7.org/fhir/Questionnaire/3141",
"title": "Cancer Quality Forum Questionnaire 2012",
"status": "draft",
"subjectType": [
"Patient"
],
"date": "2012-01",
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression",
"valueExpression": {
"language": "text/cql",
"expression": "%resource.item I where (I.linkId = 'a1' and I.answer[0].value <> 0) or (I.linkId = 'a2' and I.answer[0].value in { 1, 2 })"
}
}
],
"item": [
{
"linkId": "1",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "COMORBIDITY"
}
],
"type": "group",
"item": [
{
"linkId": "1.1",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORB"
}
],
"prefix": "1",
"type": "choice",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow",
"item": [
{
"linkId": "1.1.1",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "CARDIAL"
}
],
"type": "group",
"enableWhen": [
{
"question": "1.1",
"operator": "=",
"answerCoding": {
"system": "http://terminology.hl7.org/CodeSystem/v2-0136",
"code": "Y"
}
}
],
"item": [
{
"linkId": "1.1.1.1",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBCAR"
}
],
"prefix": "1.1",
"type": "choice",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow",
"item": [
{
"linkId": "1.1.1.1.1",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMCAR00",
"display": "Angina Pectoris"
},
{
"system": "http://snomed.info/sct",
"code": "194828000",
"display": "Angina (disorder)"
}
],
"prefix": "1.1.1",
"type": "choice",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow"
},
{
"linkId": "1.1.1.1.2",
"code": [
{
"system": "http://snomed.info/sct",
"code": "22298006",
"display": "Myocardial infarction (disorder)"
}
],
"prefix": "1.1.2",
"type": "choice",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow"
}
]
},
{
"linkId": "1.1.1.2",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBVAS"
}
],
"prefix": "1.2",
"type": "choice",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow"
}
]
}
]
}
]
},
{
"linkId": "2",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "HISTOPATHOLOGY"
}
],
"type": "group",
"item": [
{
"linkId": "2.1",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "ABDOMINAL"
}
],
"type": "group",
"item": [
{
"linkId": "2.1.2",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "STADPT",
"display": "pT category"
}
],
"type": "choice"
}
]
}
]
}
]
}

View File

@ -0,0 +1,166 @@
{
"resourceType": "Questionnaire",
"id": "3141",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>\n 1.Comorbidity?\n 1.1 Cardial Comorbidity\n 1.1.1 Angina?\n 1.1.2 MI?\n 1.2 Vascular Comorbidity?\n ...\n Histopathology\n Abdominal\n pT category?\n ...\n </pre>\n </div>"
},
"url": "http://hl7.org/fhir/Questionnaire/3141",
"title": "Cancer Quality Forum Questionnaire 2012",
"status": "draft",
"subjectType": [
"Patient"
],
"date": "2012-01",
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression",
"valueExpression": {
"language": "text/cql",
"expression": "%resource.item I where (I.linkId = 'a1' and I.answer[0].value <> 0) or (I.linkId = 'a2' and I.answer[0].value in { 1, 2 })"
}
}
],
"item": [
{
"linkId": "1",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "COMORBIDITY"
}
],
"type": "group",
"item": [
{
"linkId": "1.1",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORB"
}
],
"prefix": "1",
"type": "coding",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow",
"item": [
{
"linkId": "1.1.1",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "CARDIAL"
}
],
"type": "group",
"enableWhen": [
{
"question": "1.1",
"operator": "=",
"answerCoding": {
"system": "http://terminology.hl7.org/CodeSystem/v2-0136",
"code": "Y"
}
}
],
"item": [
{
"linkId": "1.1.1.1",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBCAR"
}
],
"prefix": "1.1",
"type": "coding",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow",
"item": [
{
"linkId": "1.1.1.1.1",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMCAR00",
"display": "Angina Pectoris"
},
{
"system": "http://snomed.info/sct",
"code": "194828000",
"display": "Angina (disorder)"
}
],
"prefix": "1.1.1",
"type": "coding",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow"
},
{
"linkId": "1.1.1.1.2",
"code": [
{
"system": "http://snomed.info/sct",
"code": "22298006",
"display": "Myocardial infarction (disorder)"
}
],
"prefix": "1.1.2",
"type": "coding",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow"
}
]
},
{
"linkId": "1.1.1.2",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBVAS"
}
],
"prefix": "1.2",
"type": "coding",
"answerValueSet": "http://hl7.org/fhir/ValueSet/yesnodontknow"
}
]
}
]
}
]
},
{
"linkId": "2",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "HISTOPATHOLOGY"
}
],
"type": "group",
"item": [
{
"linkId": "2.1",
"code": [
{
"system": "http://example.org/system/code/sections",
"code": "ABDOMINAL"
}
],
"type": "group",
"item": [
{
"linkId": "2.1.2",
"code": [
{
"system": "http://example.org/system/code/questions",
"code": "STADPT",
"display": "pT category"
}
],
"type": "coding"
}
]
}
]
}
]
}

View File

@ -0,0 +1,141 @@
{
"resourceType": "Questionnaire",
"id": "3141",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>\n 1.Comorbidity?\n 1.1 Cardial Comorbidity\n 1.1.1 Angina?\n 1.1.2 MI?\n 1.2 Vascular Comorbidity?\n ...\n Histopathology\n Abdominal\n pT category?\n ...\n </pre>\n </div>"
},
"status": "draft",
"date": "2012-01",
"subjectType": [
"Patient"
],
"group": {
"title": "Cancer Quality Forum Questionnaire 2012",
"group": [
{
"linkId": "1",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "COMORBIDITY"
}
],
"question": [
{
"linkId": "1.1",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORB"
}
],
"type": "choice",
"options": {
"reference": "http://hl7.org/fhir/ValueSet/yesnodontknow"
},
"group": [
{
"linkId": "1.1.1",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "CARDIAL"
}
],
"question": [
{
"linkId": "1.1.1.1",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBCAR"
}
],
"type": "choice",
"options": {
"reference": "http://hl7.org/fhir/ValueSet/yesnodontknow"
},
"group": [
{
"linkId": "1.1.1.1.1",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMCAR00",
"display": "Angina Pectoris"
},
{
"system": "http://snomed.info/sct",
"code": "194828000",
"display": "Angina (disorder)"
}
]
},
{
"linkId": "1.1.1.1.2",
"concept": [
{
"system": "http://snomed.info/sct",
"code": "22298006",
"display": "Myocardial infarction (disorder)"
}
]
}
]
},
{
"linkId": "1.1.1.2",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "COMORBVAS"
}
],
"type": "choice",
"options": {
"reference": "http://hl7.org/fhir/ValueSet/yesnodontknow"
}
}
]
}
]
}
]
},
{
"linkId": "2",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "HISTOPATHOLOGY"
}
],
"group": [
{
"linkId": "2.1",
"concept": [
{
"system": "http://example.org/system/code/sections",
"code": "ABDOMINAL"
}
],
"question": [
{
"linkId": "2.1.2",
"concept": [
{
"system": "http://example.org/system/code/questions",
"code": "STADPT",
"display": "pT category"
}
],
"type": "choice"
}
]
}
]
}
]
}
}

View File

@ -33,313 +33,281 @@ package org.hl7.fhir.dstu2.model;
*/
// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
import java.util.List;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseExtension;
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
import org.hl7.fhir.exceptions.FHIRException;
import java.util.List;
/**
* Optional Extensions Element - found in all resources.
*/
@DatatypeDef(name="Extension")
@DatatypeDef(name = "Extension")
public class Extension extends BaseExtension implements IBaseExtension<Extension, Type>, IBaseHasExtensions {
/**
* Source of the definition for the extension code - a logical name or a URL.
*/
@Child(name = "url", type = {UriType.class}, order=0, min=1, max=1, modifier=false, summary=false)
@Description(shortDefinition="identifies the meaning of the extension", formalDefinition="Source of the definition for the extension code - a logical name or a URL." )
protected UriType url;
/**
* Source of the definition for the extension code - a logical name or a URL.
*/
@Child(name = "url", type = {UriType.class}, order = 0, min = 1, max = 1, modifier = false, summary = false)
@Description(shortDefinition = "identifies the meaning of the extension", formalDefinition = "Source of the definition for the extension code - a logical name or a URL.")
protected UriType url;
/**
* Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).
*/
@Child(name = "value", type = {}, order=1, min=0, max=1, modifier=false, summary=false)
@Description(shortDefinition="Value of extension", formalDefinition="Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list)." )
protected org.hl7.fhir.dstu2.model.Type value;
/**
* Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).
*/
@Child(name = "value", type = {}, order = 1, min = 0, max = 1, modifier = false, summary = false)
@Description(shortDefinition = "Value of extension", formalDefinition = "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).")
protected org.hl7.fhir.dstu2.model.Type value;
private static final long serialVersionUID = 1029480965L;
private static final long serialVersionUID = 1029480965L;
/*
* Constructor
*/
public Extension() {
super();
}
public Extension() {
super();
}
/*
* Constructor
*/
public Extension(UriType url) {
super();
this.url = url;
}
public Extension(UriType url) {
super();
this.url = url;
}
/**
* @return {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
*/
public UriType getUrlElement() {
if (this.url == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Extension.url");
else if (Configuration.doAutoCreate())
this.url = new UriType(); // bb
return this.url;
}
/**
* @return {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
*/
public UriType getUrlElement() {
if (this.url == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Extension.url");
else if (Configuration.doAutoCreate())
this.url = new UriType(); // bb
return this.url;
}
public boolean hasUrlElement() {
return this.url != null && !this.url.isEmpty();
}
public boolean hasUrlElement() {
return this.url != null && !this.url.isEmpty();
}
public boolean hasUrl() {
return this.url != null && !this.url.isEmpty();
}
public boolean hasUrl() {
return this.url != null && !this.url.isEmpty();
}
/**
* @param value {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
*/
public Extension setUrlElement(UriType value) {
this.url = value;
return this;
}
/**
* @param value {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
*/
public Extension setUrlElement(UriType value) {
this.url = value;
return this;
}
/**
* @return Source of the definition for the extension code - a logical name or a URL.
*/
public String getUrl() {
return this.url == null ? null : this.url.getValue();
}
/**
* @return Source of the definition for the extension code - a logical name or a URL.
*/
public String getUrl() {
return this.url == null ? null : this.url.getValue();
}
/**
* @param value Source of the definition for the extension code - a logical name or a URL.
*/
public Extension setUrl(String value) {
if (this.url == null)
this.url = new UriType();
this.url.setValue(value);
return this;
}
/**
* @param value Source of the definition for the extension code - a logical name or a URL.
*/
public Extension setUrl(String value) {
if (this.url == null)
this.url = new UriType();
this.url.setValue(value);
return this;
}
/**
* @return {@link #value} (Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).)
*/
public org.hl7.fhir.dstu2.model.Type getValue() {
/**
* @return {@link #value} (Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).)
*/
public org.hl7.fhir.dstu2.model.Type getValue() {
return this.value;
}
public boolean hasValue() {
return this.value != null && !this.value.isEmpty();
}
/**
* @param value {@link #value} (Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).)
*/
public Extension setValue(org.hl7.fhir.dstu2.model.Type value) {
this.value = value;
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("url", "uri", "Source of the definition for the extension code - a logical name or a URL.", 0, java.lang.Integer.MAX_VALUE, url));
childrenList.add(new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, java.lang.Integer.MAX_VALUE, value));
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("url"))
this.url = castToUri(value); // UriType
else if (name.equals("value[x]"))
this.value = (org.hl7.fhir.dstu2.model.Type) value; // org.hl7.fhir.dstu2.model.Type
else
super.setProperty(name, value);
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("url")) {
throw new FHIRException("Cannot call addChild on a primitive type Extension.url");
} else if (name.equals("valueBoolean")) {
this.value = new BooleanType();
return this.value;
}
public boolean hasValue() {
return this.value != null && !this.value.isEmpty();
}
/**
* @param value {@link #value} (Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).)
*/
public Extension setValue(org.hl7.fhir.dstu2.model.Type value) {
this.value = value;
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("url", "uri", "Source of the definition for the extension code - a logical name or a URL.", 0, java.lang.Integer.MAX_VALUE, url));
childrenList.add(new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, java.lang.Integer.MAX_VALUE, value));
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("url"))
this.url = castToUri(value); // UriType
else if (name.equals("value[x]"))
this.value = (org.hl7.fhir.dstu2.model.Type) value; // org.hl7.fhir.dstu2.model.Type
else
super.setProperty(name, value);
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("url")) {
throw new FHIRException("Cannot call addChild on a primitive type Extension.url");
}
else if (name.equals("valueBoolean")) {
this.value = new BooleanType();
return this.value;
}
else if (name.equals("valueInteger")) {
this.value = new IntegerType();
return this.value;
}
else if (name.equals("valueDecimal")) {
this.value = new DecimalType();
return this.value;
}
else if (name.equals("valueBase64Binary")) {
this.value = new Base64BinaryType();
return this.value;
}
else if (name.equals("valueInstant")) {
this.value = new InstantType();
return this.value;
}
else if (name.equals("valueString")) {
this.value = new StringType();
return this.value;
}
else if (name.equals("valueUri")) {
this.value = new UriType();
return this.value;
}
else if (name.equals("valueDate")) {
this.value = new DateType();
return this.value;
}
else if (name.equals("valueDateTime")) {
this.value = new DateTimeType();
return this.value;
}
else if (name.equals("valueTime")) {
this.value = new TimeType();
return this.value;
}
else if (name.equals("valueCode")) {
this.value = new CodeType();
return this.value;
}
else if (name.equals("valueOid")) {
this.value = new OidType();
return this.value;
}
else if (name.equals("valueId")) {
this.value = new IdType();
return this.value;
}
else if (name.equals("valueUnsignedInt")) {
this.value = new UnsignedIntType();
return this.value;
}
else if (name.equals("valuePositiveInt")) {
this.value = new PositiveIntType();
return this.value;
}
else if (name.equals("valueMarkdown")) {
this.value = new MarkdownType();
return this.value;
}
else if (name.equals("valueAnnotation")) {
this.value = new Annotation();
return this.value;
}
else if (name.equals("valueAttachment")) {
this.value = new Attachment();
return this.value;
}
else if (name.equals("valueIdentifier")) {
this.value = new Identifier();
return this.value;
}
else if (name.equals("valueCodeableConcept")) {
this.value = new CodeableConcept();
return this.value;
}
else if (name.equals("valueCoding")) {
this.value = new Coding();
return this.value;
}
else if (name.equals("valueQuantity")) {
this.value = new Quantity();
return this.value;
}
else if (name.equals("valueRange")) {
this.value = new Range();
return this.value;
}
else if (name.equals("valuePeriod")) {
this.value = new Period();
return this.value;
}
else if (name.equals("valueRatio")) {
this.value = new Ratio();
return this.value;
}
else if (name.equals("valueSampledData")) {
this.value = new SampledData();
return this.value;
}
else if (name.equals("valueSignature")) {
this.value = new Signature();
return this.value;
}
else if (name.equals("valueHumanName")) {
this.value = new HumanName();
return this.value;
}
else if (name.equals("valueAddress")) {
this.value = new Address();
return this.value;
}
else if (name.equals("valueContactPoint")) {
this.value = new ContactPoint();
return this.value;
}
else if (name.equals("valueTiming")) {
this.value = new Timing();
return this.value;
}
else if (name.equals("valueReference")) {
this.value = new Reference();
return this.value;
}
else if (name.equals("valueMeta")) {
this.value = new Meta();
return this.value;
}
else
return super.addChild(name);
}
} else if (name.equals("valueInteger")) {
this.value = new IntegerType();
return this.value;
} else if (name.equals("valueDecimal")) {
this.value = new DecimalType();
return this.value;
} else if (name.equals("valueBase64Binary")) {
this.value = new Base64BinaryType();
return this.value;
} else if (name.equals("valueInstant")) {
this.value = new InstantType();
return this.value;
} else if (name.equals("valueString")) {
this.value = new StringType();
return this.value;
} else if (name.equals("valueUri")) {
this.value = new UriType();
return this.value;
} else if (name.equals("valueDate")) {
this.value = new DateType();
return this.value;
} else if (name.equals("valueDateTime")) {
this.value = new DateTimeType();
return this.value;
} else if (name.equals("valueTime")) {
this.value = new TimeType();
return this.value;
} else if (name.equals("valueCode")) {
this.value = new CodeType();
return this.value;
} else if (name.equals("valueOid")) {
this.value = new OidType();
return this.value;
} else if (name.equals("valueId")) {
this.value = new IdType();
return this.value;
} else if (name.equals("valueUnsignedInt")) {
this.value = new UnsignedIntType();
return this.value;
} else if (name.equals("valuePositiveInt")) {
this.value = new PositiveIntType();
return this.value;
} else if (name.equals("valueMarkdown")) {
this.value = new MarkdownType();
return this.value;
} else if (name.equals("valueAnnotation")) {
this.value = new Annotation();
return this.value;
} else if (name.equals("valueAttachment")) {
this.value = new Attachment();
return this.value;
} else if (name.equals("valueIdentifier")) {
this.value = new Identifier();
return this.value;
} else if (name.equals("valueCodeableConcept")) {
this.value = new CodeableConcept();
return this.value;
} else if (name.equals("valueCoding")) {
this.value = new Coding();
return this.value;
} else if (name.equals("valueQuantity")) {
this.value = new Quantity();
return this.value;
} else if (name.equals("valueRange")) {
this.value = new Range();
return this.value;
} else if (name.equals("valuePeriod")) {
this.value = new Period();
return this.value;
} else if (name.equals("valueRatio")) {
this.value = new Ratio();
return this.value;
} else if (name.equals("valueSampledData")) {
this.value = new SampledData();
return this.value;
} else if (name.equals("valueSignature")) {
this.value = new Signature();
return this.value;
} else if (name.equals("valueHumanName")) {
this.value = new HumanName();
return this.value;
} else if (name.equals("valueAddress")) {
this.value = new Address();
return this.value;
} else if (name.equals("valueContactPoint")) {
this.value = new ContactPoint();
return this.value;
} else if (name.equals("valueTiming")) {
this.value = new Timing();
return this.value;
} else if (name.equals("valueReference")) {
this.value = new Reference();
return this.value;
} else if (name.equals("valueMeta")) {
this.value = new Meta();
return this.value;
} else
return super.addChild(name);
}
public String fhirType() {
return "Extension";
}
public Extension copy() {
Extension dst = new Extension();
copyValues(dst);
dst.url = url == null ? null : url.copy();
dst.value = value == null ? null : value.copy();
return dst;
}
public Extension copy() {
Extension dst = new Extension();
copyValues(dst);
dst.url = url == null ? null : url.copy();
dst.value = value == null ? null : value.copy();
return dst;
}
protected Extension typedCopy() {
return copy();
}
protected Extension typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof Extension))
return false;
Extension o = (Extension) other;
return compareDeep(url, o.url, true) && compareDeep(value, o.value, true);
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof Extension))
return false;
Extension o = (Extension) other;
return compareDeep(url, o.url, true) && compareDeep(value, o.value, true);
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof Extension))
return false;
Extension o = (Extension) other;
return compareValues(url, o.url, true);
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof Extension))
return false;
Extension o = (Extension) other;
return compareValues(url, o.url, true);
}
public boolean isEmpty() {
return super.isEmpty() && (url == null || url.isEmpty()) && (value == null || value.isEmpty())
;
}
public boolean isEmpty() {
return super.isEmpty() && (url == null || url.isEmpty()) && (value == null || value.isEmpty())
;
}
}

View File

@ -3,7 +3,6 @@ package org.hl7.fhir.validation;
import com.google.gson.JsonObject;
import lombok.Getter;
import org.hl7.fhir.convertors.*;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.elementmodel.Manager;
@ -650,7 +649,7 @@ public class IgLoader {
res = new org.hl7.fhir.dstu3.utils.StructureMapUtilities(null).parse(new String(content));
else
throw new FHIRException("Unsupported format for " + fn);
r = VersionConvertor_30_50.convertResource(res, false);
r = VersionConvertor_30_50.convertResource(res);
} else if (fhirVersion.startsWith("4.0")) {
org.hl7.fhir.r4.model.Resource res;
if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
@ -679,8 +678,7 @@ public class IgLoader {
res = new org.hl7.fhir.dstu2.formats.JsonParser().parse(new ByteArrayInputStream(content));
else
throw new FHIRException("Unsupported format for " + fn);
VersionConvertorAdvisor50 advisor = new org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor5();
r = VersionConvertor_10_50.convertResource(res, advisor);
r = VersionConvertor_10_50.convertResource(res, new org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor5());
} else if (fhirVersion.equals(Constants.VERSION) || "current".equals(fhirVersion)) {
if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
r = new XmlParser().parse(new ByteArrayInputStream(content));

View File

@ -38,7 +38,7 @@ import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.convertors.VersionConvertor_14_50;
import org.hl7.fhir.convertors.VersionConvertor_30_50;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.exceptions.FHIRException;
/**
@ -101,22 +101,14 @@ The interface is optimised for JNI.
*/
public class NativeHostServices {
private class NH_10_50_Advisor implements VersionConvertorAdvisor50 {
private class NH_10_50_Advisor extends BaseAdvisor_10_50 {
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override
public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException {
}
public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException {}
@Override
public CodeSystem getCodeSystem(ValueSet src) throws FHIRException {
throw new FHIRException("Code systems cannot be handled at this time"); // what to do? need thread local storage?
}
}
private ValidationEngine validator;
@ -129,7 +121,7 @@ public class NativeHostServices {
private String lastException = null;
private Object lock = new Object();
private VersionConvertorAdvisor50 conv_10_50_advisor = new NH_10_50_Advisor();
private final BaseAdvisor_10_50 conv_10_50_advisor = new NH_10_50_Advisor();
/**
* Create an instance of the service
@ -347,7 +339,7 @@ public class NativeHostServices {
if (VersionUtilities.isR3Ver(version)) {
org.hl7.fhir.dstu3.formats.ParserBase p3 = org.hl7.fhir.dstu3.formats.FormatUtilities.makeParser(fmt);
org.hl7.fhir.dstu3.model.Resource res3 = p3.parse(r);
Resource res4 = VersionConvertor_30_50.convertResource(res3, false);
Resource res4 = VersionConvertor_30_50.convertResource(res3);
org.hl7.fhir.r5.formats.ParserBase p4 = org.hl7.fhir.r5.formats.FormatUtilities.makeParser(fmt);
convertCount++;
return p4.composeBytes(res4);
@ -398,7 +390,7 @@ public class NativeHostServices {
if ("3.0".equals(version) || "3.0.1".equals(version) || "r3".equals(version)) {
org.hl7.fhir.r5.formats.ParserBase p4 = org.hl7.fhir.r5.formats.FormatUtilities.makeParser(fmt);
org.hl7.fhir.r5.model.Resource res4 = p4.parse(r);
org.hl7.fhir.dstu3.model.Resource res3 = VersionConvertor_30_50.convertResource(res4, false);
org.hl7.fhir.dstu3.model.Resource res3 = VersionConvertor_30_50.convertResource(res4);
org.hl7.fhir.dstu3.formats.ParserBase p3 = org.hl7.fhir.dstu3.formats.FormatUtilities.makeParser(fmt);
unConvertCount++;
return p3.composeBytes(res3);

View File

@ -4,7 +4,6 @@ import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hl7.fhir.convertors.*;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.convertors.txClient.TerminologyClientFactory;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
@ -527,7 +526,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
if (fn.endsWith(".html") || fn.endsWith(".htm") && r instanceof DomainResource)
new XhtmlComposer(XhtmlComposer.HTML, true).compose(s, ((DomainResource) r).getText().getDiv());
else if (version.startsWith("3.0")) {
org.hl7.fhir.dstu3.model.Resource res = VersionConvertor_30_50.convertResource(r, false);
org.hl7.fhir.dstu3.model.Resource res = VersionConvertor_30_50.convertResource(r);
if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
new org.hl7.fhir.dstu3.formats.XmlParser().setOutputStyle(org.hl7.fhir.dstu3.formats.IParser.OutputStyle.PRETTY).compose(s, res);
else if (fn.endsWith(".json") && !fn.endsWith("template.json"))
@ -555,8 +554,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
else
throw new FHIRException("Unsupported format for " + fn);
} else if (version.startsWith("1.0")) {
VersionConvertorAdvisor50 advisor = new org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor5();
org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_50.convertResource(r, advisor);
org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_50.convertResource(r, new org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor5());
if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
new org.hl7.fhir.dstu2.formats.JsonParser().setOutputStyle(org.hl7.fhir.dstu2.formats.IParser.OutputStyle.PRETTY).compose(s, res);
else if (fn.endsWith(".json") && !fn.endsWith("template.json"))

View File

@ -84,7 +84,7 @@ public class VersionConvertor {
} else if (VersionUtilities.isR3Ver(targetVer)) {
return getBytesDstu3(cnt, format, r3);
} else if (VersionUtilities.isR4Ver(targetVer)) {
return getBytesR4(cnt, format, VersionConvertor_30_40.convertResource(r3, false));
return getBytesR4(cnt, format, VersionConvertor_30_40.convertResource(r3));
} else {
throw new FHIRException("Target Version not supported yet: " + targetVer);
}
@ -107,7 +107,7 @@ public class VersionConvertor {
} else if (VersionUtilities.isR2BVer(targetVer)) {
return getBytesDstu2016(cnt, format, VersionConvertor_14_40.convertResource(r4));
} else if (VersionUtilities.isR3Ver(targetVer)) {
return getBytesDstu3(cnt, format, VersionConvertor_30_40.convertResource(r4, false));
return getBytesDstu3(cnt, format, VersionConvertor_30_40.convertResource(r4));
} else if (VersionUtilities.isR4Ver(targetVer)) {
return getBytesR4(cnt, format, r4);
} else {

View File

@ -215,7 +215,7 @@ public class MeasureValidator extends BaseValidator {
throw new FHIRException(context.formatMessage(I18nConstants.UNSUPPORTED_VERSION_R2B));
case STU3:
org.hl7.fhir.dstu3.model.Resource r3 = new org.hl7.fhir.dstu3.formats.JsonParser().parse(json);
Resource r5 = VersionConvertor_30_50.convertResource(r3, false);
Resource r5 = VersionConvertor_30_50.convertResource(r3);
if (r5 instanceof Measure)
return (Measure) r5;
else

View File

@ -226,7 +226,7 @@ public class QuestionnaireValidator extends BaseValidator {
return null;
case STU3:
org.hl7.fhir.dstu3.model.Resource r3 = new org.hl7.fhir.dstu3.formats.JsonParser().parse(json);
r5 = VersionConvertor_30_50.convertResource(r3, false);
r5 = VersionConvertor_30_50.convertResource(r3);
if (r5 instanceof Questionnaire)
return (Questionnaire) r5;
else

View File

@ -389,7 +389,7 @@ public class StructureDefinitionValidator extends BaseValidator {
}
if (VersionUtilities.isR3Ver(context.getVersion())) {
org.hl7.fhir.dstu3.model.Resource r3 = new org.hl7.fhir.dstu3.formats.JsonParser().parse(bs.toByteArray());
return (StructureDefinition) VersionConvertor_30_50.convertResource(r3, false);
return (StructureDefinition) VersionConvertor_30_50.convertResource(r3);
}
if (VersionUtilities.isR4Ver(context.getVersion())) {
org.hl7.fhir.r4.model.Resource r4 = new org.hl7.fhir.r4.formats.JsonParser().parse(bs.toByteArray());

View File

@ -204,7 +204,7 @@ public class ComparisonTests {
if (Constants.VERSION.equals(ver) || "5.0".equals(ver))
return new JsonParser().parse(inputStream);
else if (VersionUtilities.isR3Ver(ver))
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(inputStream), false);
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(inputStream));
else if (VersionUtilities.isR2BVer(ver))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(inputStream));
else if (VersionUtilities.isR2Ver(ver))
@ -217,7 +217,7 @@ public class ComparisonTests {
if (Constants.VERSION.equals(ver) || "5.0".equals(ver))
return new XmlParser().parse(inputStream);
else if (VersionUtilities.isR3Ver(ver))
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(inputStream), false);
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(inputStream));
else if (VersionUtilities.isR2BVer(ver))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(inputStream));
else if (VersionUtilities.isR2Ver(ver))

View File

@ -339,7 +339,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
if (Constants.VERSION.equals(version) || "5.0".equals(version))
return new JsonParser().parse(inputStream);
else if (org.hl7.fhir.dstu3.model.Constants.VERSION.equals(version) || "3.0".equals(version))
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(inputStream), false);
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(inputStream));
else if (org.hl7.fhir.dstu2016may.model.Constants.VERSION.equals(version) || "1.4".equals(version))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(inputStream));
else if (org.hl7.fhir.dstu2.model.Constants.VERSION.equals(version) || "1.0".equals(version))
@ -352,7 +352,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
if (Constants.VERSION.equals(version) || "5.0".equals(version))
return new XmlParser().parse(inputStream);
else if (org.hl7.fhir.dstu3.model.Constants.VERSION.equals(version) || "3.0".equals(version))
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(inputStream), false);
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(inputStream));
else if (org.hl7.fhir.dstu2016may.model.Constants.VERSION.equals(version) || "1.4".equals(version))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(inputStream));
else if (org.hl7.fhir.dstu2.model.Constants.VERSION.equals(version) || "1.0".equals(version))

Some files were not shown because too many files have changed in this diff Show More