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

View File

@ -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()); throw new FHIRException("Conversion from R3 to 2016May version is not supported for resources of type "+src.fhirType());
case R4: case R4:
if (useJava && VersionConvertor_30_40.convertsResource(src.fhirType())) 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 else
throw new FHIRException("todo: use script based conversion...."); throw new FHIRException("todo: use script based conversion....");
case STU3: return saveResource30(src, dstFormat, style); case STU3: return saveResource30(src, dstFormat, style);
@ -259,7 +259,7 @@ public class VersionConversionService {
case R4: return saveResource40(src, dstFormat, style); case R4: return saveResource40(src, dstFormat, style);
case STU3: case STU3:
if (useJava && VersionConvertor_30_40.convertsResource(src.fhirType())) 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 else
throw new FHIRException("todo: use script based conversion...."); throw new FHIRException("todo: use script based conversion....");
default: throw new FHIRException("FHIR Version 'unknown' is not supported by the inter-version convertor"); 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; 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.convertors.conv10_30.*;
import org.hl7.fhir.dstu2.model.CodeableConcept; import org.hl7.fhir.dstu2.model.CodeableConcept;
import org.hl7.fhir.dstu2.utils.ToolingExtensions; 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())); 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2.model.Parameters) if (src instanceof org.hl7.fhir.dstu2.model.Parameters)
return Parameters10_30.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); 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()); 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu3.model.Parameters) if (src instanceof org.hl7.fhir.dstu3.model.Parameters)
return Parameters10_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); return Parameters10_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src);

View File

@ -1,6 +1,6 @@
package org.hl7.fhir.convertors; 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.convertors.conv10_40.*;
import org.hl7.fhir.dstu2.model.CodeableConcept; import org.hl7.fhir.dstu2.model.CodeableConcept;
import org.hl7.fhir.dstu2.model.Parameters; 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.dstu2.utils.ToolingExtensions;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.conformance.ProfileUtilities; import org.hl7.fhir.r4.conformance.ProfileUtilities;
import org.hl7.fhir.r4.model.CanonicalType; import org.hl7.fhir.r4.model.*;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent; import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent;
import org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent; import org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent;
import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent;
import org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent; 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.r4.terminologies.CodeSystemUtilities;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; 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 { 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); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); .forEach(tgt::addContained);
for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) src.getExtension().forEach(ext -> {
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); 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 { 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); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); .forEach(tgt::addContained);
for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) src.getExtension().forEach(extension -> {
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); 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 { 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())); 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2.model.Parameters) if (src instanceof org.hl7.fhir.dstu2.model.Parameters)
return Parameters10_40.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); 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()); 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters) if (src instanceof org.hl7.fhir.r4.model.Parameters)
return Parameters10_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); 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) if (src instanceof org.hl7.fhir.r4.model.Condition)
return Condition10_40.convertCondition((org.hl7.fhir.r4.model.Condition) src); return Condition10_40.convertCondition((org.hl7.fhir.r4.model.Condition) src);
if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) 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) if (src instanceof org.hl7.fhir.r4.model.DetectedIssue)
return DetectedIssue10_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); return DetectedIssue10_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src);
if (src instanceof org.hl7.fhir.r4.model.DeviceMetric) 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) if (src instanceof org.hl7.fhir.r4.model.Practitioner)
return Practitioner10_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); return Practitioner10_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src);
if (src instanceof org.hl7.fhir.r4.model.Questionnaire) 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) if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse)
return QuestionnaireResponse10_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); return QuestionnaireResponse10_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src);
if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) 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); 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) { 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(); 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); copyElement(src, tgt);

View File

@ -1,8 +1,9 @@
package org.hl7.fhir.convertors; 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.convertors.conv10_50.*;
import org.hl7.fhir.dstu2.model.CodeableConcept; 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;
import org.hl7.fhir.dstu2.model.Parameters.ParametersParameterComponent; import org.hl7.fhir.dstu2.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.dstu2.model.Reference; 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 org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; 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 { 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); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); .forEach(tgt::addContained);
for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) src.getExtension().forEach(extension -> {
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); 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 { 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); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); .forEach(tgt::addContained);
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) src.getExtension().forEach(extension -> {
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); 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 { 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())); 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2.model.Parameters) if (src instanceof org.hl7.fhir.dstu2.model.Parameters)
return Parameters10_50.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); 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); return TestScript10_50.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src);
if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) if (src instanceof org.hl7.fhir.dstu2.model.ValueSet)
return ValueSet10_50.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters) if (src instanceof org.hl7.fhir.r5.model.Parameters)
return Parameters10_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); 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) if (src instanceof org.hl7.fhir.r5.model.Provenance)
return Provenance10_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); return Provenance10_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src);
if (src instanceof org.hl7.fhir.r5.model.Questionnaire) 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) if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse)
return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src);
if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) 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); return TestScript10_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src);
if (src instanceof org.hl7.fhir.r5.model.ValueSet) if (src instanceof org.hl7.fhir.r5.model.ValueSet)
return ValueSet10_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src, advisor); 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) { public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src) {
@ -3056,12 +3104,4 @@ public class VersionConvertor_10_50 extends VersionConvertor_Base {
public static boolean convertsResource(String rt) { 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"); 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.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

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

View File

@ -1,5 +1,6 @@
package org.hl7.fhir.convertors; 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.convertors.conv14_50.*;
import org.hl7.fhir.dstu2016may.model.CodeableConcept; import org.hl7.fhir.dstu2016may.model.CodeableConcept;
import org.hl7.fhir.dstu2016may.model.Reference; 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 org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; 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 { 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); copyResource(src, tgt);
tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); .forEach(tgt::addContained);
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) src.getExtension().forEach(extension -> {
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); 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 { 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); copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); .forEach(tgt::addContained);
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) src.getExtension().forEach(extension -> {
if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); 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 { 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 { 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters) if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters)
return Parameters14_50.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src); 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); return StructureMap14_50.convertStructureMap((org.hl7.fhir.dstu2016may.model.StructureMap) src);
if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet) if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet)
return ValueSet14_50.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src); 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 { 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 == null || src.isEmpty()) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters) if (src instanceof org.hl7.fhir.r5.model.Parameters)
return Parameters14_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); 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); return StructureMap14_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src);
if (src instanceof org.hl7.fhir.r5.model.ValueSet) if (src instanceof org.hl7.fhir.r5.model.ValueSet)
return ValueSet14_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src); 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) { public static boolean convertsResource(String rt) {

View File

@ -1,5 +1,6 @@
package org.hl7.fhir.convertors; 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.convertors.conv30_40.*;
import org.hl7.fhir.dstu3.model.Parameters; import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent; 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 org.hl7.fhir.utilities.Utilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; 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 { 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); copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); src.getContained().stream()
for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); .forEach(tgt::addContained);
for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) src.getExtension().forEach(extension -> {
if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3)); 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 { 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); copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r4.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); src.getContained().stream()
for (org.hl7.fhir.r4.model.Extension t2 : src.getExtension()) .map(resource -> convertResource(resource, advisor))
if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); .forEach(tgt::addContained);
for (org.hl7.fhir.r4.model.Extension t3 : src.getModifierExtension()) src.getExtension().forEach(extension -> {
if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3)); 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 { 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; 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 == null) return null;
if (src instanceof org.hl7.fhir.dstu3.model.Parameters) if (src instanceof org.hl7.fhir.dstu3.model.Parameters)
return Parameters30_40.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); 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); return TestScript30_40.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src);
if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) if (src instanceof org.hl7.fhir.dstu3.model.ValueSet)
return ValueSet30_40.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); 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; 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 == null) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters) { if (src instanceof org.hl7.fhir.r4.model.Parameters) {
if (((org.hl7.fhir.r4.model.Parameters) src).hasParameter("profile-url")) 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); return TestScript30_40.convertTestScript((org.hl7.fhir.r4.model.TestScript) src);
if (src instanceof org.hl7.fhir.r4.model.ValueSet) if (src instanceof org.hl7.fhir.r4.model.ValueSet)
return ValueSet30_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); 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; else return null;
} }

View File

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

View File

@ -1,9 +1,11 @@
package org.hl7.fhir.convertors; 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.convertors.conv40_50.*;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CodeableReference; import org.hl7.fhir.r5.model.CodeableReference;
import java.util.Arrays;
import java.util.stream.Collectors; 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 { 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); copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); .map(resource -> convertResource(resource, advisor))
for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); .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 { 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); copyResource(src, tgt);
if (src.hasText()) tgt.setText(convertNarrative(src.getText())); if (src.hasText()) tgt.setText(convertNarrative(src.getText()));
for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); src.getContained().stream()
for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); .map(resource -> convertResource(resource, advisor))
for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); .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 { 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 { 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 == null) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters) if (src instanceof org.hl7.fhir.r4.model.Parameters)
return Parameters40_50.convertParameters((org.hl7.fhir.r4.model.Parameters) src); 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); return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r4.model.VerificationResult) src);
if (src instanceof org.hl7.fhir.r4.model.VisionPrescription) if (src instanceof org.hl7.fhir.r4.model.VisionPrescription)
return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r4.model.VisionPrescription) src); 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 { 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 == null) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters) if (src instanceof org.hl7.fhir.r5.model.Parameters)
return Parameters40_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); 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); return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r5.model.VerificationResult) src);
if (src instanceof org.hl7.fhir.r5.model.VisionPrescription) if (src instanceof org.hl7.fhir.r5.model.VisionPrescription)
return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r5.model.VisionPrescription) src); 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) { 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; package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_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.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication; import org.hl7.fhir.r5.model.FhirPublication;
@ -23,7 +23,7 @@ public class Bundle10_30 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle(); 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); 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()) if (src == null || src.isEmpty())
return null; return null;
if (advisor.ignoreEntry(src, FhirPublication.DSTU2)) if (advisor.ignoreEntry(src, FhirPublication.DSTU2))

View File

@ -3,7 +3,7 @@ package org.hl7.fhir.convertors.conv10_30;
import java.util.List; import java.util.List;
import org.hl7.fhir.convertors.VersionConvertor_10_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.dstu2.model.ValueSet; import org.hl7.fhir.dstu2.model.ValueSet;
import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode; import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
@ -185,7 +185,7 @@ public class ValueSet10_30 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet(); org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet();
@ -260,7 +260,7 @@ public class ValueSet10_30 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet(); 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; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication; import org.hl7.fhir.r5.model.FhirPublication;
@ -23,7 +23,7 @@ public class Bundle10_40 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle(); org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle();
@ -62,7 +62,7 @@ public class Bundle10_40 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
if (advisor.ignoreEntry(src, FhirPublication.DSTU2)) 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.VersionConvertorConstants;
import org.hl7.fhir.convertors.VersionConvertor_10_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.exceptions.FHIRException;
import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent; import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent;
import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent; import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent;
@ -53,11 +54,11 @@ public class Conformance10_40 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance(); org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
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()) if (src.hasUrlElement())
tgt.setUrlElement(VersionConvertor_10_40.convertUri(src.getUrlElement())); tgt.setUrlElement(VersionConvertor_10_40.convertUri(src.getUrlElement()));
if (src.hasVersionElement()) if (src.hasVersionElement())

View File

@ -1,318 +1,336 @@
package org.hl7.fhir.convertors.conv10_40; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.exceptions.FHIRException;
import org.hl7.fhir.r4.model.ContactDetail; import org.hl7.fhir.r4.model.ContactDetail;
import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent; import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent;
public class Questionnaire10_40 { public class Questionnaire10_40 {
public static org.hl7.fhir.dstu2.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r4.model.Questionnaire src) throws FHIRException { 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire(); org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire();
VersionConvertor_10_40.copyDomainResource(src, tgt); VersionConvertor_10_40.copyDomainResource(src, tgt, advisor);
for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t)); for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
if (src.hasVersionElement()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement())); if (src.hasVersionElement())
if (src.hasStatus()) tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement()));
tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement())); if (src.hasStatus())
if (src.hasDate()) tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement())); if (src.hasDate())
if (src.hasPublisherElement()) tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement()));
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement())); if (src.hasPublisherElement())
for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(t1)); tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement()));
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup(); for (ContactDetail t : src.getContact())
root.setTitle(src.getTitle()); for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom())
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) { tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(t1));
root.addConcept(VersionConvertor_10_40.convertCoding(t)); 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())
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));
root.addGroup(convertQuestionnaireGroupComponent(t)); return tgt;
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 { 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.r4.model.Questionnaire tgt = new org.hl7.fhir.r4.model.Questionnaire(); org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent();
VersionConvertor_10_40.copyDomainResource(src, tgt); VersionConvertor_10_40.copyElement(src, tgt);
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t)); if (src.hasLinkIdElement())
if (src.hasVersionElement()) tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement()));
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement())); for (org.hl7.fhir.dstu2.model.Coding t : src.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
if (src.hasStatus()) if (src.hasTextElement())
tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement())); tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement()));
if (src.hasDate()) if (src.hasType())
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement())); tgt.setTypeElement(convertQuestionnaireQuestionType(src.getTypeElement()));
if (src.hasPublisherElement()) if (src.hasRequiredElement())
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement())); tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) tgt.addContact(convertQuestionnaireContactComponent(t)); if (src.hasRepeatsElement())
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = src.getGroup(); tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
tgt.setTitle(root.getTitle()); if (src.hasOptions())
for (org.hl7.fhir.dstu2.model.Coding t : root.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t)); tgt.setAnswerValueSetElement(VersionConvertor_10_40.convertReferenceToCanonical(src.getOptions()));
for (org.hl7.fhir.dstu2.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue()); for (org.hl7.fhir.dstu2.model.Coding t : src.getOption())
tgt.addItem(convertQuestionnaireGroupComponent(root)); tgt.addAnswerOption().setValue(VersionConvertor_10_40.convertCoding(t));
return tgt; 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 { 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); 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); VersionConvertor_10_40.copyElement(src, tgt);
tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(src)); switch (src.getValue()) {
return tgt; 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 { 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent tgt = new org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent(); 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); VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement()) switch (src.getValue()) {
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement())); case DRAFT:
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addConcept(VersionConvertor_10_40.convertCoding(t)); tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.DRAFT);
if (src.hasTextElement()) break;
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement())); case ACTIVE:
if (src.hasRequiredElement()) tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.PUBLISHED);
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement())); break;
if (src.hasRepeatsElement()) case RETIRED:
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement())); tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.RETIRED);
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) if (t.getType() == org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP) break;
tgt.addGroup(convertQuestionnaireGroupComponent(t)); default:
else tgt.setValue(org.hl7.fhir.dstu2.model.Questionnaire.QuestionnaireStatus.NULL);
tgt.addQuestion(convertQuestionnaireQuestionComponent(t)); break;
return tgt;
} }
return tgt;
}
public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireGroupComponent(org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent src) throws FHIRException { 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent(); 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); VersionConvertor_10_40.copyElement(src, tgt);
if (src.hasLinkIdElement()) switch (src.getValue()) {
tgt.setLinkIdElement(VersionConvertor_10_40.convertString(src.getLinkIdElement())); case DRAFT:
for (org.hl7.fhir.dstu2.model.Coding t : src.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t)); tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT);
if (src.hasTextElement()) break;
tgt.setTextElement(VersionConvertor_10_40.convertString(src.getTextElement())); case PUBLISHED:
tgt.setType(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP); tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
if (src.hasRequiredElement()) break;
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement())); case RETIRED:
if (src.hasRepeatsElement()) tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED);
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement())); break;
for (org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent t : src.getGroup()) tgt.addItem(convertQuestionnaireGroupComponent(t)); default:
for (org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent t : src.getQuestion()) tgt.addItem(convertQuestionnaireQuestionComponent(t)); tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL);
return tgt; break;
}
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;
} }
return tgt;
}
} }

View File

@ -3,7 +3,7 @@ package org.hl7.fhir.convertors.conv10_40;
import java.util.List; import java.util.List;
import org.hl7.fhir.convertors.VersionConvertor_10_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.dstu2.model.ValueSet; import org.hl7.fhir.dstu2.model.ValueSet;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.BooleanType;
@ -190,7 +190,7 @@ public class ValueSet10_40 {
return convertValueSet(src, null); 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet(); org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet();
@ -264,11 +264,11 @@ public class ValueSet10_40 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet(); 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()) if (src.hasUrlElement())
tgt.setUrlElement(VersionConvertor_10_40.convertUri(src.getUrlElement())); 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)); 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; package org.hl7.fhir.convertors.conv10_50;
import org.hl7.fhir.convertors.VersionConvertor_10_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.exceptions.FHIRException;
import org.hl7.fhir.r5.model.FhirPublication; import org.hl7.fhir.r5.model.FhirPublication;
@ -27,7 +27,7 @@ public class Bundle10_50 {
return convertBundle(src, null); 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle(); org.hl7.fhir.dstu2.model.Bundle tgt = new org.hl7.fhir.dstu2.model.Bundle();
@ -62,7 +62,7 @@ public class Bundle10_50 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
if (advisor.ignoreEntry(src, FhirPublication.DSTU2)) 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.VersionConvertorConstants;
import org.hl7.fhir.convertors.VersionConvertor_10_50; 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.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent; import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent; 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 { 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance(); org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
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()) if (src.hasUrlElement())
tgt.setUrlElement(VersionConvertor_10_50.convertUri(src.getUrlElement())); tgt.setUrlElement(VersionConvertor_10_50.convertUri(src.getUrlElement()));
if (src.hasVersionElement()) if (src.hasVersionElement())

View File

@ -1,10 +1,13 @@
package org.hl7.fhir.convertors.conv10_50; package org.hl7.fhir.convertors.conv10_50;
import org.hl7.fhir.convertors.VersionConvertor_10_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.Questionnaire.AnswerFormat;
import org.hl7.fhir.dstu2.model.Resource;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CodeType; import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.ContactDetail; 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.QuestionnaireAnswerConstraint;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent; 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 { 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire(); 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 java.util.List;
import org.hl7.fhir.convertors.VersionConvertor_10_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.dstu2.model.ValueSet; import org.hl7.fhir.dstu2.model.ValueSet;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.BooleanType; import org.hl7.fhir.r5.model.BooleanType;
@ -186,7 +186,7 @@ public class ValueSet10_50 {
return tgt; 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet(); 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); 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()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.r5.model.ValueSet tgt = new org.hl7.fhir.r5.model.ValueSet(); 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()) if (src.hasFullUrl())
tgt.setFullUrlElement(VersionConvertor_30_40.convertUri(src.getFullUrlElement())); tgt.setFullUrlElement(VersionConvertor_30_40.convertUri(src.getFullUrlElement()));
if (src.hasResource()) if (src.hasResource())
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource(), false)); tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource()));
if (src.hasSearch()) if (src.hasSearch())
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch())); tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
if (src.hasRequest()) if (src.hasRequest())
@ -69,7 +69,7 @@ public class Bundle30_40 {
if (src.hasFullUrl()) if (src.hasFullUrl())
tgt.setFullUrlElement(VersionConvertor_30_40.convertUri(src.getFullUrlElement())); tgt.setFullUrlElement(VersionConvertor_30_40.convertUri(src.getFullUrlElement()));
if (src.hasResource()) if (src.hasResource())
tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource(), false)); tgt.setResource(VersionConvertor_30_40.convertResource(src.getResource()));
if (src.hasSearch()) if (src.hasSearch())
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch())); tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
if (src.hasRequest()) if (src.hasRequest())
@ -133,7 +133,7 @@ public class Bundle30_40 {
if (src.hasLastModified()) if (src.hasLastModified())
tgt.setLastModifiedElement(VersionConvertor_30_40.convertInstant(src.getLastModifiedElement())); tgt.setLastModifiedElement(VersionConvertor_30_40.convertInstant(src.getLastModifiedElement()));
if (src.hasOutcome()) if (src.hasOutcome())
tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome(), false)); tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome()));
return tgt; return tgt;
} }
@ -151,7 +151,7 @@ public class Bundle30_40 {
if (src.hasLastModified()) if (src.hasLastModified())
tgt.setLastModifiedElement(VersionConvertor_30_40.convertInstant(src.getLastModifiedElement())); tgt.setLastModifiedElement(VersionConvertor_30_40.convertInstant(src.getLastModifiedElement()));
if (src.hasOutcome()) if (src.hasOutcome())
tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome(), false)); tgt.setOutcome(VersionConvertor_30_40.convertResource(src.getOutcome()));
return tgt; return tgt;
} }

View File

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

View File

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

View File

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

View File

@ -1,20 +1,14 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders;
import org.hl7.fhir.dstu3.context.SimpleWorkerContext.IContextResourceLoader; 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.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 abstract class BaseLoaderR3 implements IContextResourceLoader {
public interface ILoaderKnowledgeProvider { public interface ILoaderKnowledgeProvider {
/** /**
* get the path for references to this resource. * get the path for references to this resource.
*
* @param resource * @param resource
* @return null if not tracking paths * @return null if not tracking paths
*/ */
@ -27,17 +21,16 @@ public abstract class BaseLoaderR3 implements IContextResourceLoader {
return null; return null;
} }
} }
protected final String URL_BASE = "http://hl7.org/fhir/"; protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/"; 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_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/"; 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_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"; protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
protected boolean patchUrls; protected boolean patchUrls;
protected boolean killPrimitives;; protected boolean killPrimitives;
private String[] types; private String[] types;
private ILoaderKnowledgeProvider lkp; private ILoaderKnowledgeProvider lkp;
@ -79,6 +72,4 @@ public abstract class BaseLoaderR3 implements IContextResourceLoader {
r.setUserData("path", path); r.setUserData("path", path);
} }
} }
} }

View File

@ -1,21 +1,14 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders;
import org.hl7.fhir.r4.context.SimpleWorkerContext.IContextResourceLoader; 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.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 abstract class BaseLoaderR4 implements IContextResourceLoader {
public interface ILoaderKnowledgeProvider { public interface ILoaderKnowledgeProvider {
/** /**
* get the path for references to this resource. * get the path for references to this resource.
*
* @param resource * @param resource
* @return null if not tracking paths * @return null if not tracking paths
*/ */
@ -28,17 +21,16 @@ public abstract class BaseLoaderR4 implements IContextResourceLoader {
return null; return null;
} }
} }
protected final String URL_BASE = "http://hl7.org/fhir/"; protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/"; 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_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/"; 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_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"; protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
protected boolean patchUrls; protected boolean patchUrls;
protected boolean killPrimitives;; protected boolean killPrimitives;
private String[] types; private String[] types;
private ILoaderKnowledgeProvider lkp; private ILoaderKnowledgeProvider lkp;
@ -80,6 +72,4 @@ public abstract class BaseLoaderR4 implements IContextResourceLoader {
r.setUserData("path", path); r.setUserData("path", path);
} }
} }
} }

View File

@ -1,30 +1,25 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders;
import com.google.gson.JsonSyntaxException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; 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.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.npm.NpmPackage; import org.hl7.fhir.utilities.npm.NpmPackage;
import com.google.gson.JsonSyntaxException;
import java.io.IOException; 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 { public interface ILoaderKnowledgeProvider {
/** /**
* get the path for references to this resource. * get the path for references to this resource.
*
* @param resource * @param resource
* @return null if not tracking paths * @return null if not tracking paths
*/ */
String getResourcePath(Resource resource); String getResourcePath(Resource resource);
ILoaderKnowledgeProvider forNewPackage(NpmPackage npm) throws JsonSyntaxException, IOException; ILoaderKnowledgeProvider forNewPackage(NpmPackage npm) throws JsonSyntaxException, IOException;
} }
@ -39,17 +34,16 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
return this; return this;
} }
} }
protected final String URL_BASE = "http://hl7.org/fhir/"; protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/"; 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_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/"; 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_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"; protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
protected boolean patchUrls; protected boolean patchUrls;
protected boolean killPrimitives;; protected boolean killPrimitives;
protected String[] types; protected String[] types;
protected ILoaderKnowledgeProvider lkp; protected ILoaderKnowledgeProvider lkp;
@ -111,9 +105,7 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
} else if (VersionUtilities.isR2BVer(npm.fhirVersion())) { } else if (VersionUtilities.isR2BVer(npm.fhirVersion())) {
return new R2016MayToR5Loader(types, lkp.forNewPackage(npm)); return new R2016MayToR5Loader(types, lkp.forNewPackage(npm));
} else { } 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_14_40; 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.JsonParser;
import org.hl7.fhir.dstu2016may.formats.XmlParser; import org.hl7.fhir.dstu2016may.formats.XmlParser;
import org.hl7.fhir.dstu2016may.model.Resource; 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.r4.model.ValueSet;
import org.hl7.fhir.r5.model.FhirPublication; 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() { public R2016MayToR4Loader() {
super(new String[0], null); super(new String[0], null);
@ -71,7 +71,7 @@ public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResource
r2016may = new JsonParser().parse(stream); r2016may = new JsonParser().parse(stream);
else else
r2016may = new XmlParser().parse(stream); 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; Bundle b;
if (r4 instanceof Bundle) 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); 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); be.setResource(cs);
@ -111,23 +111,4 @@ public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResource
} }
return b; 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_14_50; 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.JsonParser;
import org.hl7.fhir.dstu2016may.formats.XmlParser; import org.hl7.fhir.dstu2016may.formats.XmlParser;
import org.hl7.fhir.dstu2016may.model.Resource; 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.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; 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) { public R2016MayToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp); super(types, lkp);
} }
private List<CodeSystem> cslist = new ArrayList<>(); private final BaseAdvisor_14_50 advisor = new BaseAdvisor_14_50();
@Override @Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { 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); r2016may = new JsonParser().parse(stream);
else else
r2016may = new XmlParser().parse(stream); 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; Bundle b;
if (r5 instanceof Bundle) 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); 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); 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); org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_14_50.convertResource(r2016may);
setPath(r5); setPath(r5);
if (!cslist.isEmpty()) { if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems"); throw new FHIRException("Error: Cannot have included code systems");
} }
if (killPrimitives) { 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_10_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.dstu2.formats.JsonParser; import org.hl7.fhir.dstu2.formats.JsonParser;
import org.hl7.fhir.dstu2.formats.XmlParser; import org.hl7.fhir.dstu2.formats.XmlParser;
import org.hl7.fhir.dstu2.model.Resource; 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;
import org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.dstu3.model.UriType; import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.exceptions.FHIRException; 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() { public R2ToR3Loader() {
super(new String[0], new NullLoaderKnowledgeProvider()); super(new String[0], new NullLoaderKnowledgeProvider());
@ -63,27 +61,27 @@ public class R2ToR3Loader extends BaseLoaderR3 implements VersionConvertorAdviso
@Override @Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
Resource r2 = null; Resource r2;
if (isJson) if (isJson)
r2 = new JsonParser().parse(stream); r2 = new JsonParser().parse(stream);
else else
r2 = new XmlParser().parse(stream); 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; Bundle b;
if (r3 instanceof Bundle) if (r3 instanceof Bundle) {
b = (Bundle) r3; b = (Bundle) r3;
else { } else {
b = new Bundle(); b = new Bundle();
b.setId(UUID.randomUUID().toString().toLowerCase()); b.setId(UUID.randomUUID().toString().toLowerCase());
b.setType(BundleType.COLLECTION); b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r3).setFullUrl(r3 instanceof MetadataResource ? ((MetadataResource) r3).getUrl() : null); 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); be.setResource(cs);
} });
cslist.clear(); advisor_10_30.getCslist().clear();
if (killPrimitives) { if (killPrimitives) {
List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>(); List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>();
for (BundleEntryComponent be : b.getEntry()) { for (BundleEntryComponent be : b.getEntry()) {
@ -96,33 +94,14 @@ public class R2ToR3Loader extends BaseLoaderR3 implements VersionConvertorAdviso
b.getEntry().removeAll(remove); b.getEntry().removeAll(remove);
} }
if (patchUrls) { if (patchUrls) {
for (BundleEntryComponent be : b.getEntry()) { b.getEntry().stream()
if (be.hasResource() && be.getResource() instanceof StructureDefinition) { .filter(be -> be.hasResource() && be.getResource() instanceof StructureDefinition)
StructureDefinition sd = (StructureDefinition) be.getResource(); .map(be -> (StructureDefinition) be.getResource())
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2)); .forEach(sd -> {
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE)); sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
} sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
} });
} }
return b; 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_10_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.dstu2.formats.JsonParser; import org.hl7.fhir.dstu2.formats.JsonParser;
import org.hl7.fhir.dstu2.formats.XmlParser; import org.hl7.fhir.dstu2.formats.XmlParser;
import org.hl7.fhir.dstu2.model.Resource; 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.r4.model.ValueSet;
import org.hl7.fhir.r5.model.FhirPublication; 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() { public R2ToR4Loader() {
super(new String[0], new NullLoaderKnowledgeProvider()); super(new String[0], new NullLoaderKnowledgeProvider());
@ -69,23 +69,24 @@ public class R2ToR4Loader extends BaseLoaderR4 implements VersionConvertorAdviso
r2 = new JsonParser().parse(stream); r2 = new JsonParser().parse(stream);
else else
r2 = new XmlParser().parse(stream); 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; Bundle b;
if (r4 instanceof Bundle) if (r4 instanceof Bundle) {
b = (Bundle) r4; b = (Bundle) r4;
else { } else {
b = new Bundle(); b = new Bundle();
b.setId(UUID.randomUUID().toString().toLowerCase()); b.setId(UUID.randomUUID().toString().toLowerCase());
b.setType(BundleType.COLLECTION); b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r4).setFullUrl(r4 instanceof MetadataResource ? ((MetadataResource) r4).getUrl() : null); 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 // 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); be.setResource(cs);
} });
cslist.clear(); advisor.getCslist().clear();
if (killPrimitives) { if (killPrimitives) {
List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>(); List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>();
for (BundleEntryComponent be : b.getEntry()) { for (BundleEntryComponent be : b.getEntry()) {
@ -98,33 +99,14 @@ public class R2ToR4Loader extends BaseLoaderR4 implements VersionConvertorAdviso
b.getEntry().removeAll(remove); b.getEntry().removeAll(remove);
} }
if (patchUrls) { if (patchUrls) {
for (BundleEntryComponent be : b.getEntry()) { b.getEntry().stream()
if (be.hasResource() && be.getResource() instanceof StructureDefinition) { .filter(be -> be.hasResource() && be.getResource() instanceof StructureDefinition)
StructureDefinition sd = (StructureDefinition) be.getResource(); .map(be -> (StructureDefinition) be.getResource())
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2)); .forEach(sd -> {
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE)); sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
} sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
} });
} }
return b; 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_10_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.dstu2.formats.JsonParser; import org.hl7.fhir.dstu2.formats.JsonParser;
import org.hl7.fhir.dstu2.formats.XmlParser; import org.hl7.fhir.dstu2.formats.XmlParser;
import org.hl7.fhir.dstu2.model.Resource; 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.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; 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) { public R2ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp); super(types, lkp);
} }
private List<CodeSystem> cslist = new ArrayList<>(); private final BaseAdvisor_10_50 advisor = new BaseAdvisor_10_50();
@Override @Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { 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); r2 = new JsonParser().parse(stream);
else else
r2 = new XmlParser().parse(stream); 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; Bundle b;
if (r5 instanceof Bundle) if (r5 instanceof Bundle) {
b = (Bundle) r5; b = (Bundle) r5;
else { } else {
b = new Bundle(); b = new Bundle();
b.setId(UUID.randomUUID().toString().toLowerCase()); b.setId(UUID.randomUUID().toString().toLowerCase());
b.setType(BundleType.COLLECTION); b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r5).setFullUrl(r5 instanceof CanonicalResource ? ((CanonicalResource) r5).getUrl() : null); 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 // 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); be.setResource(cs);
} }
cslist.clear();
advisor.getCslist().clear();
if (killPrimitives) { if (killPrimitives) {
List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>(); List<BundleEntryComponent> remove = new ArrayList<BundleEntryComponent>();
for (BundleEntryComponent be : b.getEntry()) { for (BundleEntryComponent be : b.getEntry()) {
@ -113,9 +115,9 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
r2 = new JsonParser().parse(stream); r2 = new JsonParser().parse(stream);
else else
r2 = new XmlParser().parse(stream); 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); setPath(r5);
if (!cslist.isEmpty()) { if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems"); throw new FHIRException("Error: Cannot have included code systems");
} }
if (killPrimitives) { 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_30_40; 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.JsonParser;
import org.hl7.fhir.dstu3.formats.XmlParser; import org.hl7.fhir.dstu3.formats.XmlParser;
import org.hl7.fhir.dstu3.model.Resource; 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.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind; 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() { public R3ToR4Loader() {
super(new String[0], new NullLoaderKnowledgeProvider()); super(new String[0], new NullLoaderKnowledgeProvider());
@ -65,7 +65,7 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader
r3 = new JsonParser().parse(stream); r3 = new JsonParser().parse(stream);
else else
r3 = new XmlParser().parse(stream); 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; Bundle b;
if (r4 instanceof Bundle) if (r4 instanceof Bundle)
@ -76,7 +76,7 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader
b.setType(BundleType.COLLECTION); b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r4).setFullUrl(r4 instanceof MetadataResource ? ((MetadataResource) r4).getUrl() : null); 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_30_50; 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.JsonParser;
import org.hl7.fhir.dstu3.formats.XmlParser; import org.hl7.fhir.dstu3.formats.XmlParser;
import org.hl7.fhir.dstu3.model.Resource; 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.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; 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) { public R3ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp); super(types, lkp);
} }
private List<CodeSystem> cslist = new ArrayList<>(); private final BaseAdvisor_30_50 advisor = new BaseAdvisor_30_50();
@Override @Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { 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); r3 = new JsonParser().parse(stream);
else else
r3 = new XmlParser().parse(stream); 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; Bundle b;
if (r5 instanceof Bundle) if (r5 instanceof Bundle)
@ -76,7 +76,7 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
b.setType(BundleType.COLLECTION); b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r5).setFullUrl(r5 instanceof CanonicalResource ? ((CanonicalResource) r5).getUrl() : null); 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); be.setResource(cs);
@ -115,10 +115,10 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
r3 = new JsonParser().parse(stream); r3 = new JsonParser().parse(stream);
else else
r3 = new XmlParser().parse(stream); 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); setPath(r5);
if (!cslist.isEmpty()) { if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems"); throw new FHIRException("Error: Cannot have included code systems");
} }
if (killPrimitives) { 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 java.util.UUID;
import org.hl7.fhir.convertors.VersionConvertor_40_50; 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.exceptions.FHIRException;
import org.hl7.fhir.r4.formats.JsonParser; import org.hl7.fhir.r4.formats.JsonParser;
import org.hl7.fhir.r4.formats.XmlParser; 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.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; 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) { public R4ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp); super(types, lkp);
} }
private List<CodeSystem> cslist = new ArrayList<>(); private final BaseAdvisor_40_50 advisor = new BaseAdvisor_40_50();
@Override @Override
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { 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); r4 = new JsonParser().parse(stream);
else else
r4 = new XmlParser().parse(stream); 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; Bundle b;
if (r5 instanceof Bundle) if (r5 instanceof Bundle)
@ -76,7 +76,7 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
b.setType(BundleType.COLLECTION); b.setType(BundleType.COLLECTION);
b.addEntry().setResource(r5).setFullUrl(r5 instanceof CanonicalResource ? ((CanonicalResource) r5).getUrl() : null); 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(); BundleEntryComponent be = b.addEntry();
be.setFullUrl(cs.getUrl()); be.setFullUrl(cs.getUrl());
be.setResource(cs); 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); org.hl7.fhir.r5.model.Resource r5 = VersionConvertor_40_50.convertResource(r4);
setPath(r5); setPath(r5);
if (!cslist.isEmpty()) { if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems"); throw new FHIRException("Error: Cannot have included code systems");
} }
if (killPrimitives) { 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.List;
import java.util.UUID; import java.util.UUID;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser; 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.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; 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) { public R5ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) {
super(types, lkp); super(types, lkp);
} }
// TODO Grahame, will this ever be populated? No conversion is being done?
private List<CodeSystem> cslist = new ArrayList<>(); private List<CodeSystem> cslist = new ArrayList<>();
@Override @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)) { switch (VersionUtilities.getMajMin(version)) {
case "1.0": return VersionConvertor_10_50.convertResource(new org.hl7.fhir.dstu2.formats.XmlParser().parse(stream)); 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 "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 "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); case "5.0": return new org.hl7.fhir.r5.formats.XmlParser().parse(stream);
} }
@ -36,7 +36,7 @@ public class XVersionLoader {
switch (VersionUtilities.getMajMin(version)) { switch (VersionUtilities.getMajMin(version)) {
case "1.0": return VersionConvertor_10_50.convertResource(new org.hl7.fhir.dstu2.formats.JsonParser().parse(stream)); 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 "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 "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); 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 java.util.Date;
import org.hl7.fhir.convertors.VersionConvertor_10_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.dstu3.formats.IParser.OutputStyle; import org.hl7.fhir.dstu3.formats.IParser.OutputStyle;
import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; 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.r5.model.FhirPublication;
import org.hl7.fhir.utilities.Utilities; 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 { public static void main(String[] args) throws Exception {
new IGPackConverter102().process(); new IGPackConverter102().process();

View File

@ -29,31 +29,13 @@ package org.hl7.fhir.convertors.misc;
*/ */
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40;
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.ValueSet; 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 @Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) { public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId()); 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.impl.BaseAdvisor_10_50;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.FhirPublication;
import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet;
public class IGR2ConvertorAdvisor5 implements VersionConvertorAdvisor50 { public class IGR2ConvertorAdvisor5 extends BaseAdvisor_10_50 {
@Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) {
return false;
}
@Override @Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) { public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
cs.setId(vs.getId()); 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.GzipCompressorInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream; import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.hl7.fhir.convertors.*; 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.TextFile;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.json.JSONUtil; import org.hl7.fhir.utilities.json.JSONUtil;
@ -217,9 +219,9 @@ public class NpmPackageVersionConverter {
} else if (VersionUtilities.isR3Ver(version)) { } else if (VersionUtilities.isR3Ver(version)) {
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(res); return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(res);
} else if (VersionUtilities.isR4Ver(version)) { } 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)) { } 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)) { } else if (VersionUtilities.isR4Ver(currentVersion)) {
org.hl7.fhir.r4.model.Resource res = new org.hl7.fhir.r4.formats.JsonParser().parse(cnt); 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)) { } else if (VersionUtilities.isR2BVer(version)) {
return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(VersionConvertor_14_40.convertResource(res)); return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(VersionConvertor_14_40.convertResource(res));
} else if (VersionUtilities.isR3Ver(version)) { } 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)) { } else if (VersionUtilities.isR4Ver(version)) {
return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(res); return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(res);
} else if (VersionUtilities.isR5Ver(version)) { } else if (VersionUtilities.isR5Ver(version)) {
@ -241,7 +243,7 @@ public class NpmPackageVersionConverter {
} else if (VersionUtilities.isR2BVer(version)) { } else if (VersionUtilities.isR2BVer(version)) {
return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(VersionConvertor_14_50.convertResource(res)); return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(VersionConvertor_14_50.convertResource(res));
} else if (VersionUtilities.isR3Ver(version)) { } 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)) { } else if (VersionUtilities.isR4Ver(version)) {
return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(VersionConvertor_40_50.convertResource(res)); return new org.hl7.fhir.r4.formats.JsonParser().composeBytes(VersionConvertor_40_50.convertResource(res));
} else if (VersionUtilities.isR5Ver(version)) { } else if (VersionUtilities.isR5Ver(version)) {

View File

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

View File

@ -57,7 +57,7 @@ public class PackagePreparer {
Bundle b = (Bundle) r; Bundle b = (Bundle) r;
for (BundleEntryComponent be : b.getEntry()) { for (BundleEntryComponent be : b.getEntry()) {
try { 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()+"-")) if (r4.getId().startsWith(r4.fhirType()+"-"))
be.getResource().setId(r4.getId().substring(r4.fhirType().length()+1)); be.getResource().setId(r4.getId().substring(r4.fhirType().length()+1));
if (be.getResource().hasId()) if (be.getResource().hasId())
@ -69,7 +69,7 @@ public class PackagePreparer {
} }
} }
} else if (r.hasId()) } 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 else
System.out.println(f.getName()+" has no id"); System.out.println(f.getName()+" has no id");
} catch (Exception e) { } catch (Exception e) {

View File

@ -204,7 +204,7 @@ public class UTGVersionSorter {
System.out.println("Load "+id); System.out.println("Load "+id);
NpmPackage npm = pcm.loadPackage(id); NpmPackage npm = pcm.loadPackage(id);
for (PackageResourceInformation p : npm.listIndexedResources("CodeSystem", "ValueSet")) { 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); res.put(r.getUrl(), r);
} }
return res; return res;

View File

@ -70,24 +70,24 @@ public class TerminologyClientR3 implements TerminologyClient {
@Override @Override
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> params) throws FHIRException { 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.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, false); 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 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 @Override
public Parameters validateCS(Parameters pin) throws FHIRException { 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); 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 @Override
public Parameters validateVS(Parameters pin) throws FHIRException { 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); 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 @Override
@ -110,12 +110,12 @@ public class TerminologyClientR3 implements TerminologyClient {
@Override @Override
public CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException { public CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException {
return (CapabilityStatement) VersionConvertor_30_50.convertResource(client.getCapabilitiesStatementQuick(), false); return (CapabilityStatement) VersionConvertor_30_50.convertResource(client.getCapabilitiesStatementQuick());
} }
@Override @Override
public Parameters lookupCode(Map<String, String> params) throws FHIRException { 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 @Override
@ -125,7 +125,7 @@ public class TerminologyClientR3 implements TerminologyClient {
@Override @Override
public Bundle validateBatch(Bundle batch) { 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 @Override
@ -140,7 +140,7 @@ public class TerminologyClientR3 implements TerminologyClient {
if (r3 == null) { if (r3 == null) {
throw new FHIRException("Unable to fetch resource "+Utilities.pathURL(getAddress(), type, id)); 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) { if (r5 != null) {
throw new FHIRException("Unable to convert resource "+Utilities.pathURL(getAddress(), type, id)+" to R5 (internal representation)"); 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.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 import org.hl7.fhir.r5.model.FhirPublication
/* /*
@ -43,7 +40,7 @@ import org.hl7.fhir.r5.model.FhirPublication
* *
* @author grahame * @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 * 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 * @param targetVersion [FhirPublication] of the target version
* @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation. * @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation.
*/ */
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean @JvmDefault
fun ignoreEntry(src: Bundle.BundleEntryComponent, targetVersion: FhirPublication): Boolean {
/** return false
* 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?
} }

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.exceptions.FHIRException
import org.hl7.fhir.r4.model.Bundle import org.hl7.fhir.r4.model.*
import org.hl7.fhir.r4.model.CodeSystem
import org.hl7.fhir.r4.model.ValueSet
import org.hl7.fhir.r5.model.FhirPublication import org.hl7.fhir.r5.model.FhirPublication
/* /*
@ -43,7 +41,7 @@ import org.hl7.fhir.r5.model.FhirPublication
* *
* @author grahame * @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 * 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 * @param targetVersion [FhirPublication] of the target version
* @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation. * @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation.
*/ */
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean @JvmDefault
fun ignoreEntry(src: Bundle.BundleEntryComponent, targetVersion: FhirPublication): Boolean {
/** return false
* 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?
} }

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.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.Bundle
import org.hl7.fhir.r5.model.CodeSystem import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.FhirPublication import org.hl7.fhir.r5.model.FhirPublication
@ -34,7 +36,7 @@ import org.hl7.fhir.r5.model.ValueSet
POSSIBILITY OF SUCH DAMAGE. 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 * 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 * @param targetVersion [FhirPublication] of the target version
* @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation. * @return [Boolean] True, if we are going to ignore this [Bundle.BundleEntryComponent] in this conversion operation.
*/ */
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean @JvmDefault
fun ignoreEntry(src: Bundle.BundleEntryComponent?, targetVersion: FhirPublication): Boolean {
/** return false
* 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?
} }

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 @Test
public void testAuditEvent() throws FHIRFormatError, IOException { 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.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()); Assertions.assertEquals(ae5.getId(), ae3.getId());
} }
@ -43,7 +43,7 @@ public class VersionConvertorPrimitiveType30_50Test {
@Test @Test
public void testProvenance() throws FHIRFormatError, IOException { 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.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()); 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; package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_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.hl7.fhir.convertors.loaders.R2ToR3Loader;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -16,7 +16,6 @@ public class AdministrativeGender10_30Test {
public void testMedicationRequestConversion() throws IOException { public void testMedicationRequestConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/administrative_gender_null.json"); 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); 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(); VersionConvertor_10_30.convertResource(dstu2, new BaseAdvisor_10_30());
org.hl7.fhir.dstu3.model.Resource stu_actual = VersionConvertor_10_30.convertResource(dstu2, advisor);
} }
} }

View File

@ -1,7 +1,7 @@
package org.hl7.fhir.convertors.conv10_30; package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_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.hl7.fhir.convertors.loaders.R2ToR3Loader;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -29,8 +29,7 @@ public class AllergyIntolerance10_30Test {
InputStream stu_exepected_input = this.getClass().getResourceAsStream(stu_path); 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); 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, new BaseAdvisor_10_30());
org.hl7.fhir.dstu3.model.Resource stu_actual = VersionConvertor_10_30.convertResource(dstu2, advisor);
org.hl7.fhir.dstu3.formats.JsonParser stu_parser = new org.hl7.fhir.dstu3.formats.JsonParser(); 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); 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; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -14,35 +14,35 @@ import java.io.InputStream;
import java.util.stream.Stream; import java.util.stream.Stream;
public class AllergyIntolerance10_40Test { public class AllergyIntolerance10_40Test {
private static Stream<Arguments> filesPaths() { private static Stream<Arguments> filesPaths() {
return Stream.of( return Stream.of(
Arguments.of("/0_allergy_intolerance_10.json", "/0_allergy_intolerance_40.json"), Arguments.of("/0_allergy_intolerance_10.json", "/0_allergy_intolerance_40.json"),
Arguments.of("/1_allergy_intolerance_10.json", "/1_allergy_intolerance_40.json") Arguments.of("/1_allergy_intolerance_10.json", "/1_allergy_intolerance_40.json")
); );
} }
@ParameterizedTest @ParameterizedTest
@MethodSource("filesPaths") @MethodSource("filesPaths")
@DisplayName("Test 10_40 AllergyIntolerance conversion") @DisplayName("Test 10_40 AllergyIntolerance conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException { public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path); InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_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); 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(); BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor); 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.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.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
if (!r4_expected.equalsDeep(r4_actual)) { if (!r4_expected.equalsDeep(r4_actual)) {
System.out.println("Expected"); System.out.println("Expected");
System.out.println(r4_parser.composeString(r4_expected)); System.out.println(r4_parser.composeString(r4_expected));
System.out.println(); System.out.println();
System.out.println("Actual"); System.out.println("Actual");
System.out.println(r4_parser.composeString(r4_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)
);
} }
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; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -11,21 +11,21 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class Medication10_40Test { public class Medication10_40Test {
@Test @Test
@DisplayName("Test 10_40 Medication conversion") @DisplayName("Test 10_40 Medication conversion")
public void testMedicationConversion() throws IOException { public void testMedicationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_medication_10.json"); InputStream dstu2_input = this.getClass().getResourceAsStream("/0_medication_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_medication_40.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); 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(); BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor); 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.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.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)); "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; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -14,29 +14,29 @@ import java.io.InputStream;
import java.util.stream.Stream; import java.util.stream.Stream;
public class MedicationRequest10_40Test { public class MedicationRequest10_40Test {
private static Stream<Arguments> filesPaths() { private static Stream<Arguments> filesPaths() {
return Stream.of( return Stream.of(
Arguments.of("/0_medication_request_10.json", "/0_medication_request_40.json"), Arguments.of("/0_medication_request_10.json", "/0_medication_request_40.json"),
Arguments.of("/1_medication_request_10.json", "/1_medication_request_40.json") Arguments.of("/1_medication_request_10.json", "/1_medication_request_40.json")
); );
} }
@ParameterizedTest @ParameterizedTest
@MethodSource("filesPaths") @MethodSource("filesPaths")
@DisplayName("Test 10_40 MedicationRequest conversion") @DisplayName("Test 10_40 MedicationRequest conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException { public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path); InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_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); 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(); BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor); 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.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.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)); "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; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -11,21 +11,21 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class Observation10_40Test { public class Observation10_40Test {
@Test @Test
@DisplayName("Test 10_40 Observation conversion") @DisplayName("Test 10_40 Observation conversion")
public void testObservationConversion() throws IOException { public void testObservationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_observation_10.json"); InputStream dstu2_input = this.getClass().getResourceAsStream("/0_observation_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_observation_40.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); 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(); BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor); 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.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.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)); "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; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.convertors.misc.IGR2ConvertorAdvisor;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -11,21 +11,21 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class Procedure10_40Test { public class Procedure10_40Test {
@Test @Test
@DisplayName("Test 10_40 Procedure conversion") @DisplayName("Test 10_40 Procedure conversion")
public void testProcedureConversion() throws IOException { public void testProcedureConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_procedure_10.json"); InputStream dstu2_input = this.getClass().getResourceAsStream("/0_procedure_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_procedure_40.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); 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(); BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor); 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.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.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)); "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; package org.hl7.fhir.convertors.conv10_40;
import org.hl7.fhir.convertors.VersionConvertor_10_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.convertors.misc.IGR2ConvertorAdvisor;
import org.hl7.fhir.r4.formats.JsonParser; import org.hl7.fhir.r4.formats.JsonParser;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
@ -12,23 +12,23 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class ValueSet10_40Test { public class ValueSet10_40Test {
@Test @Test
@DisplayName("Test 10_40 ValueSet conversion") @DisplayName("Test 10_40 ValueSet conversion")
public void testValueSetConversion() throws IOException { public void testValueSetConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_valueset_vision_base_codes_10.json"); 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"); 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); 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(); BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor); 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.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
JsonParser parser = new JsonParser(); JsonParser parser = new JsonParser();
String composeString = parser.composeString(r4_actual); String composeString = parser.composeString(r4_actual);
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input); org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)); "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; package org.hl7.fhir.convertors.conv30_40;
import org.hl7.fhir.convertors.VersionConvertor_30_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.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; 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"); 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.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.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); 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"); 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.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.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); 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", "recordedDate": "2015-11-07T22:56:34",
"status": "confirmed", "status": "confirmed",
"criticality": "CRITH", "criticality": "CRITH",
"id": "TKebKfLXzu6Sp.LY-IpvpmQB", "id": "TKebKfLXzu6Sp.LY-IpvpmQB",
"onset": "2014-03-07T00:00:00Z", "onset": "2014-03-07T00:00:00Z",
"recorder": {"display": "MOORE, NICK", "recorder": {
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB"}, "display": "MOORE, NICK",
"patient": {"display": "Jason Argonaut", "reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB"
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"}, },
"substance": {"text": "STRAWBERRY", "patient": {
"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", "display": "Jason Argonaut",
"code": "892484", "reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"
"display": "STRAWBERRY"}, },
{"system": "http://fdasis.nlm.nih.gov", "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", "code": "4J2TY8Y81V",
"display": "STRAWBERRY"}]}, "display": "STRAWBERRY"
"reaction": [{"certainty": "confirmed", }
"onset": "2014-03-07T00:00:00Z", ]
"manifestation": [{"text": "Anaphylaxis"}]}]} },
"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 // 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.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef; import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description; 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.IBaseExtension;
import org.hl7.fhir.instance.model.api.IBaseHasExtensions; 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. * Optional Extensions Element - found in all resources.
*/ */
@DatatypeDef(name="Extension") @DatatypeDef(name = "Extension")
public class Extension extends BaseExtension implements IBaseExtension<Extension, Type>, IBaseHasExtensions { public class Extension extends BaseExtension implements IBaseExtension<Extension, Type>, IBaseHasExtensions {
/** /**
* Source of the definition for the extension code - a logical name or a 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) @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." ) @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; 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). * 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) @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)." ) @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; protected org.hl7.fhir.dstu2.model.Type value;
private static final long serialVersionUID = 1029480965L; private static final long serialVersionUID = 1029480965L;
/* /*
* Constructor * Constructor
*/ */
public Extension() { public Extension() {
super(); super();
} }
/* /*
* Constructor * Constructor
*/ */
public Extension(UriType url) { public Extension(UriType url) {
super(); super();
this.url = url; 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 * @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() { public UriType getUrlElement() {
if (this.url == null) if (this.url == null)
if (Configuration.errorOnAutoCreate()) if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Extension.url"); throw new Error("Attempt to auto-create Extension.url");
else if (Configuration.doAutoCreate()) else if (Configuration.doAutoCreate())
this.url = new UriType(); // bb this.url = new UriType(); // bb
return this.url; return this.url;
} }
public boolean hasUrlElement() { public boolean hasUrlElement() {
return this.url != null && !this.url.isEmpty(); return this.url != null && !this.url.isEmpty();
} }
public boolean hasUrl() { public boolean hasUrl() {
return this.url != null && !this.url.isEmpty(); 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 * @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) { public Extension setUrlElement(UriType value) {
this.url = value; this.url = value;
return this; return this;
} }
/** /**
* @return Source of the definition for the extension code - a logical name or a URL. * @return Source of the definition for the extension code - a logical name or a URL.
*/ */
public String getUrl() { public String getUrl() {
return this.url == null ? null : this.url.getValue(); return this.url == null ? null : this.url.getValue();
} }
/** /**
* @param value Source of the definition for the extension code - a logical name or a URL. * @param value Source of the definition for the extension code - a logical name or a URL.
*/ */
public Extension setUrl(String value) { public Extension setUrl(String value) {
if (this.url == null) if (this.url == null)
this.url = new UriType(); this.url = new UriType();
this.url.setValue(value); this.url.setValue(value);
return this; 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).) * @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() { 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; return this.value;
} } else if (name.equals("valueInteger")) {
this.value = new IntegerType();
public boolean hasValue() { return this.value;
return this.value != null && !this.value.isEmpty(); } else if (name.equals("valueDecimal")) {
} this.value = new DecimalType();
return this.value;
/** } else if (name.equals("valueBase64Binary")) {
* @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).) this.value = new Base64BinaryType();
*/ return this.value;
public Extension setValue(org.hl7.fhir.dstu2.model.Type value) { } else if (name.equals("valueInstant")) {
this.value = value; this.value = new InstantType();
return this; return this.value;
} } else if (name.equals("valueString")) {
this.value = new StringType();
protected void listChildren(List<Property> childrenList) { return this.value;
super.listChildren(childrenList); } else if (name.equals("valueUri")) {
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)); this.value = new UriType();
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)); return this.value;
} } else if (name.equals("valueDate")) {
this.value = new DateType();
@Override return this.value;
public void setProperty(String name, Base value) throws FHIRException { } else if (name.equals("valueDateTime")) {
if (name.equals("url")) this.value = new DateTimeType();
this.url = castToUri(value); // UriType return this.value;
else if (name.equals("value[x]")) } else if (name.equals("valueTime")) {
this.value = (org.hl7.fhir.dstu2.model.Type) value; // org.hl7.fhir.dstu2.model.Type this.value = new TimeType();
else return this.value;
super.setProperty(name, value); } else if (name.equals("valueCode")) {
} this.value = new CodeType();
return this.value;
@Override } else if (name.equals("valueOid")) {
public Base addChild(String name) throws FHIRException { this.value = new OidType();
if (name.equals("url")) { return this.value;
throw new FHIRException("Cannot call addChild on a primitive type Extension.url"); } else if (name.equals("valueId")) {
} this.value = new IdType();
else if (name.equals("valueBoolean")) { return this.value;
this.value = new BooleanType(); } else if (name.equals("valueUnsignedInt")) {
return this.value; this.value = new UnsignedIntType();
} return this.value;
else if (name.equals("valueInteger")) { } else if (name.equals("valuePositiveInt")) {
this.value = new IntegerType(); this.value = new PositiveIntType();
return this.value; return this.value;
} } else if (name.equals("valueMarkdown")) {
else if (name.equals("valueDecimal")) { this.value = new MarkdownType();
this.value = new DecimalType(); return this.value;
return this.value; } else if (name.equals("valueAnnotation")) {
} this.value = new Annotation();
else if (name.equals("valueBase64Binary")) { return this.value;
this.value = new Base64BinaryType(); } else if (name.equals("valueAttachment")) {
return this.value; this.value = new Attachment();
} return this.value;
else if (name.equals("valueInstant")) { } else if (name.equals("valueIdentifier")) {
this.value = new InstantType(); this.value = new Identifier();
return this.value; return this.value;
} } else if (name.equals("valueCodeableConcept")) {
else if (name.equals("valueString")) { this.value = new CodeableConcept();
this.value = new StringType(); return this.value;
return this.value; } else if (name.equals("valueCoding")) {
} this.value = new Coding();
else if (name.equals("valueUri")) { return this.value;
this.value = new UriType(); } else if (name.equals("valueQuantity")) {
return this.value; this.value = new Quantity();
} return this.value;
else if (name.equals("valueDate")) { } else if (name.equals("valueRange")) {
this.value = new DateType(); this.value = new Range();
return this.value; return this.value;
} } else if (name.equals("valuePeriod")) {
else if (name.equals("valueDateTime")) { this.value = new Period();
this.value = new DateTimeType(); return this.value;
return this.value; } else if (name.equals("valueRatio")) {
} this.value = new Ratio();
else if (name.equals("valueTime")) { return this.value;
this.value = new TimeType(); } else if (name.equals("valueSampledData")) {
return this.value; this.value = new SampledData();
} return this.value;
else if (name.equals("valueCode")) { } else if (name.equals("valueSignature")) {
this.value = new CodeType(); this.value = new Signature();
return this.value; return this.value;
} } else if (name.equals("valueHumanName")) {
else if (name.equals("valueOid")) { this.value = new HumanName();
this.value = new OidType(); return this.value;
return this.value; } else if (name.equals("valueAddress")) {
} this.value = new Address();
else if (name.equals("valueId")) { return this.value;
this.value = new IdType(); } else if (name.equals("valueContactPoint")) {
return this.value; this.value = new ContactPoint();
} return this.value;
else if (name.equals("valueUnsignedInt")) { } else if (name.equals("valueTiming")) {
this.value = new UnsignedIntType(); this.value = new Timing();
return this.value; return this.value;
} } else if (name.equals("valueReference")) {
else if (name.equals("valuePositiveInt")) { this.value = new Reference();
this.value = new PositiveIntType(); return this.value;
return this.value; } else if (name.equals("valueMeta")) {
} this.value = new Meta();
else if (name.equals("valueMarkdown")) { return this.value;
this.value = new MarkdownType(); } else
return this.value; return super.addChild(name);
} }
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() { public String fhirType() {
return "Extension"; return "Extension";
} }
public Extension copy() { public Extension copy() {
Extension dst = new Extension(); Extension dst = new Extension();
copyValues(dst); copyValues(dst);
dst.url = url == null ? null : url.copy(); dst.url = url == null ? null : url.copy();
dst.value = value == null ? null : value.copy(); dst.value = value == null ? null : value.copy();
return dst; return dst;
} }
protected Extension typedCopy() { protected Extension typedCopy() {
return copy(); return copy();
} }
@Override @Override
public boolean equalsDeep(Base other) { public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other)) if (!super.equalsDeep(other))
return false; return false;
if (!(other instanceof Extension)) if (!(other instanceof Extension))
return false; return false;
Extension o = (Extension) other; Extension o = (Extension) other;
return compareDeep(url, o.url, true) && compareDeep(value, o.value, true); return compareDeep(url, o.url, true) && compareDeep(value, o.value, true);
} }
@Override @Override
public boolean equalsShallow(Base other) { public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other)) if (!super.equalsShallow(other))
return false; return false;
if (!(other instanceof Extension)) if (!(other instanceof Extension))
return false; return false;
Extension o = (Extension) other; Extension o = (Extension) other;
return compareValues(url, o.url, true); return compareValues(url, o.url, true);
} }
public boolean isEmpty() { public boolean isEmpty() {
return super.isEmpty() && (url == null || url.isEmpty()) && (value == null || value.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 com.google.gson.JsonObject;
import lombok.Getter; import lombok.Getter;
import org.hl7.fhir.convertors.*; import org.hl7.fhir.convertors.*;
import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.elementmodel.Manager; 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)); res = new org.hl7.fhir.dstu3.utils.StructureMapUtilities(null).parse(new String(content));
else else
throw new FHIRException("Unsupported format for " + fn); 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")) { } else if (fhirVersion.startsWith("4.0")) {
org.hl7.fhir.r4.model.Resource res; org.hl7.fhir.r4.model.Resource res;
if (fn.endsWith(".xml") && !fn.endsWith("template.xml")) 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)); res = new org.hl7.fhir.dstu2.formats.JsonParser().parse(new ByteArrayInputStream(content));
else else
throw new FHIRException("Unsupported format for " + fn); throw new FHIRException("Unsupported format for " + fn);
VersionConvertorAdvisor50 advisor = new org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor5(); r = VersionConvertor_10_50.convertResource(res, new org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor5());
r = VersionConvertor_10_50.convertResource(res, advisor);
} else if (fhirVersion.equals(Constants.VERSION) || "current".equals(fhirVersion)) { } else if (fhirVersion.equals(Constants.VERSION) || "current".equals(fhirVersion)) {
if (fn.endsWith(".xml") && !fn.endsWith("template.xml")) if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
r = new XmlParser().parse(new ByteArrayInputStream(content)); 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_14_50;
import org.hl7.fhir.convertors.VersionConvertor_30_50; import org.hl7.fhir.convertors.VersionConvertor_30_50;
import org.hl7.fhir.convertors.VersionConvertor_40_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; import org.hl7.fhir.exceptions.FHIRException;
/** /**
@ -101,22 +101,14 @@ The interface is optimised for JNI.
*/ */
public class NativeHostServices { public class NativeHostServices {
private class NH_10_50_Advisor implements VersionConvertorAdvisor50 { private class NH_10_50_Advisor extends BaseAdvisor_10_50 {
@Override @Override
public boolean ignoreEntry(BundleEntryComponent src, FhirPublication publication) { public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException {}
return false;
}
@Override
public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException {
}
@Override @Override
public CodeSystem getCodeSystem(ValueSet src) throws FHIRException { 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? throw new FHIRException("Code systems cannot be handled at this time"); // what to do? need thread local storage?
} }
} }
private ValidationEngine validator; private ValidationEngine validator;
@ -129,7 +121,7 @@ public class NativeHostServices {
private String lastException = null; private String lastException = null;
private Object lock = new Object(); 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 * Create an instance of the service
@ -347,7 +339,7 @@ public class NativeHostServices {
if (VersionUtilities.isR3Ver(version)) { if (VersionUtilities.isR3Ver(version)) {
org.hl7.fhir.dstu3.formats.ParserBase p3 = org.hl7.fhir.dstu3.formats.FormatUtilities.makeParser(fmt); 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); 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); org.hl7.fhir.r5.formats.ParserBase p4 = org.hl7.fhir.r5.formats.FormatUtilities.makeParser(fmt);
convertCount++; convertCount++;
return p4.composeBytes(res4); return p4.composeBytes(res4);
@ -398,7 +390,7 @@ public class NativeHostServices {
if ("3.0".equals(version) || "3.0.1".equals(version) || "r3".equals(version)) { 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.formats.ParserBase p4 = org.hl7.fhir.r5.formats.FormatUtilities.makeParser(fmt);
org.hl7.fhir.r5.model.Resource res4 = p4.parse(r); 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); org.hl7.fhir.dstu3.formats.ParserBase p3 = org.hl7.fhir.dstu3.formats.FormatUtilities.makeParser(fmt);
unConvertCount++; unConvertCount++;
return p3.composeBytes(res3); return p3.composeBytes(res3);

View File

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

View File

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

View File

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

View File

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

View File

@ -389,7 +389,7 @@ public class StructureDefinitionValidator extends BaseValidator {
} }
if (VersionUtilities.isR3Ver(context.getVersion())) { if (VersionUtilities.isR3Ver(context.getVersion())) {
org.hl7.fhir.dstu3.model.Resource r3 = new org.hl7.fhir.dstu3.formats.JsonParser().parse(bs.toByteArray()); 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())) { if (VersionUtilities.isR4Ver(context.getVersion())) {
org.hl7.fhir.r4.model.Resource r4 = new org.hl7.fhir.r4.formats.JsonParser().parse(bs.toByteArray()); 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)) if (Constants.VERSION.equals(ver) || "5.0".equals(ver))
return new JsonParser().parse(inputStream); return new JsonParser().parse(inputStream);
else if (VersionUtilities.isR3Ver(ver)) 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)) else if (VersionUtilities.isR2BVer(ver))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(inputStream)); return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(inputStream));
else if (VersionUtilities.isR2Ver(ver)) else if (VersionUtilities.isR2Ver(ver))
@ -217,7 +217,7 @@ public class ComparisonTests {
if (Constants.VERSION.equals(ver) || "5.0".equals(ver)) if (Constants.VERSION.equals(ver) || "5.0".equals(ver))
return new XmlParser().parse(inputStream); return new XmlParser().parse(inputStream);
else if (VersionUtilities.isR3Ver(ver)) 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)) else if (VersionUtilities.isR2BVer(ver))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(inputStream)); return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(inputStream));
else if (VersionUtilities.isR2Ver(ver)) 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)) if (Constants.VERSION.equals(version) || "5.0".equals(version))
return new JsonParser().parse(inputStream); return new JsonParser().parse(inputStream);
else if (org.hl7.fhir.dstu3.model.Constants.VERSION.equals(version) || "3.0".equals(version)) 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)) 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)); 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)) 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)) if (Constants.VERSION.equals(version) || "5.0".equals(version))
return new XmlParser().parse(inputStream); return new XmlParser().parse(inputStream);
else if (org.hl7.fhir.dstu3.model.Constants.VERSION.equals(version) || "3.0".equals(version)) 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)) 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)); 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)) 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