Merge pull request #519 from hapifhir/conversion_update_II

Conversion update ii
This commit is contained in:
Grahame Grieve 2021-05-31 07:56:17 +10:00 committed by GitHub
commit c5009f377c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
101 changed files with 3046 additions and 1444 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)) {//TODO add path
Extension convertExtension = new Extension();
advisor.handleExtension("", ext, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", ext) && !Arrays.asList(extensionsToIgnore).contains(ext.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(ext));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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)) {//TODO add path
org.hl7.fhir.dstu2.model.Extension convertExtension = new org.hl7.fhir.dstu2.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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)) {//TODO add path
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();//TODO add path
advisor.handleExtension("", extension, convertExtension);
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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)) {//TODO add path
Extension convertExtension = new Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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);
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType()); 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);
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType()); 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)) {//TODO add path
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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)) {//TODO add path
org.hl7.fhir.dstu2016may.model.Extension convertExtension = new org.hl7.fhir.dstu2016may.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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);
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType()); 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);
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType()); 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)) {//TODO add path
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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)) {//TODO add path
org.hl7.fhir.dstu2016may.model.Extension convertExtension = new org.hl7.fhir.dstu2016may.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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);
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType()); 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);
if (advisor.failFastOnNullOrUnknownEntry()) {
throw new FHIRException("Unknown resource " + src.fhirType()); 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,54 @@ 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)) {//TODO add path
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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)) {//TODO add path
org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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 +4369,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 +4540,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 +4713,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 -> {
if (advisor.useAdvisorForExtension("", extension)) {//TODO add path
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
tgt.addExtension(convertExtension(extension));
} }
for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) { });
if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3)); src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl()))//TODO add path
.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)) {//TODO add path
org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension) && !Arrays.asList(extensionsToIgnore).contains(extension.getUrl())) {//TODO add path
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)) {//TODO add path
org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension)) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension))//TODO add path
.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)) {//TODO add path
org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension();
advisor.handleExtension("", extension, convertExtension);//TODO add path
tgt.addExtension(convertExtension);
} else if (!advisor.ignoreExtension("", extension)) {//TODO add path
tgt.addExtension(convertExtension(extension));
}
});
src.getModifierExtension().stream()
.filter(extension -> !advisor.ignoreExtension("", extension))//TODO add path
.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);
if (advisor.failFastOnNullOrUnknownEntry()){
throw new FHIRException("Unknown resource " + src.fhirType()); 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);
if (advisor.failFastOnNullOrUnknownEntry()){
throw new FHIRException("Unknown resource " + src.fhirType()); 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,7 +54,7 @@ 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();

View File

@ -1,18 +1,20 @@
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())
tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasVersionElement()) if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement())); tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement()));
if (src.hasStatus()) if (src.hasStatus())
@ -21,14 +23,17 @@ public class Questionnaire10_40 {
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement())); tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement()));
if (src.hasPublisherElement()) if (src.hasPublisherElement())
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement())); tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement()));
for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(t1)); for (ContactDetail t : src.getContact())
for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom())
tgt.addTelecom(VersionConvertor_10_40.convertContactPoint(t1));
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup(); org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup();
root.setTitle(src.getTitle()); root.setTitle(src.getTitle());
for (org.hl7.fhir.r4.model.Coding t : src.getCode()) { for (org.hl7.fhir.r4.model.Coding t : src.getCode()) {
root.addConcept(VersionConvertor_10_40.convertCoding(t)); 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.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) 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)); root.addGroup(convertQuestionnaireGroupComponent(t));
else else
root.addQuestion(convertQuestionnaireQuestionComponent(t)); root.addQuestion(convertQuestionnaireQuestionComponent(t));
@ -36,11 +41,16 @@ public class Questionnaire10_40 {
} }
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 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()) 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 tgt = new org.hl7.fhir.r4.model.Questionnaire();
VersionConvertor_10_40.copyDomainResource(src, tgt); VersionConvertor_10_40.copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t)); for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
if (src.hasVersionElement()) if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement())); tgt.setVersionElement(VersionConvertor_10_40.convertString(src.getVersionElement()));
if (src.hasStatus()) if (src.hasStatus())
@ -49,7 +59,8 @@ public class Questionnaire10_40 {
tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement())); tgt.setDateElement(VersionConvertor_10_40.convertDateTime(src.getDateElement()));
if (src.hasPublisherElement()) if (src.hasPublisherElement())
tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement())); tgt.setPublisherElement(VersionConvertor_10_40.convertString(src.getPublisherElement()));
for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) tgt.addContact(convertQuestionnaireContactComponent(t)); for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
tgt.addContact(convertQuestionnaireContactComponent(t));
org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = src.getGroup(); org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = src.getGroup();
tgt.setTitle(root.getTitle()); 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.Coding t : root.getConcept()) tgt.addCode(VersionConvertor_10_40.convertCoding(t));
@ -81,7 +92,8 @@ public class Questionnaire10_40 {
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement())); tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement()) if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement())); 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) 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)); tgt.addGroup(convertQuestionnaireGroupComponent(t));
else else
tgt.addQuestion(convertQuestionnaireQuestionComponent(t)); tgt.addQuestion(convertQuestionnaireQuestionComponent(t));
@ -103,8 +115,10 @@ public class Questionnaire10_40 {
tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement())); tgt.setRequiredElement(VersionConvertor_10_40.convertBoolean(src.getRequiredElement()));
if (src.hasRepeatsElement()) if (src.hasRepeatsElement())
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement())); 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.GroupComponent t : src.getGroup())
for (org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent t : src.getQuestion()) tgt.addItem(convertQuestionnaireQuestionComponent(t)); tgt.addItem(convertQuestionnaireGroupComponent(t));
for (org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent t : src.getQuestion())
tgt.addItem(convertQuestionnaireQuestionComponent(t));
return tgt; return tgt;
} }
@ -181,13 +195,15 @@ public class Questionnaire10_40 {
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement())); tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
if (src.hasAnswerValueSetElement()) if (src.hasAnswerValueSetElement())
tgt.setOptions(VersionConvertor_10_40.convertCanonicalToReference(src.getAnswerValueSetElement())); tgt.setOptions(VersionConvertor_10_40.convertCanonicalToReference(src.getAnswerValueSetElement()));
for (QuestionnaireItemAnswerOptionComponent t : src.getAnswerOption()) if (t.hasValueCoding()) for (QuestionnaireItemAnswerOptionComponent t : src.getAnswerOption())
if (t.hasValueCoding())
try { try {
tgt.addOption(VersionConvertor_10_40.convertCoding(t.getValueCoding())); tgt.addOption(VersionConvertor_10_40.convertCoding(t.getValueCoding()));
} catch (org.hl7.fhir.exceptions.FHIRException e) { } catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e); throw new FHIRException(e);
} }
for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) tgt.addGroup(convertQuestionnaireGroupComponent(t)); for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
tgt.addGroup(convertQuestionnaireGroupComponent(t));
return tgt; return tgt;
} }
@ -209,8 +225,10 @@ public class Questionnaire10_40 {
tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement())); tgt.setRepeatsElement(VersionConvertor_10_40.convertBoolean(src.getRepeatsElement()));
if (src.hasOptions()) if (src.hasOptions())
tgt.setAnswerValueSetElement(VersionConvertor_10_40.convertReferenceToCanonical(src.getOptions())); 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.Coding t : src.getOption())
for (org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent t : src.getGroup()) tgt.addItem(convertQuestionnaireGroupComponent(t)); 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; 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,6 +55,10 @@ 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();

View File

@ -1,20 +1,27 @@
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;
public class Questionnaire10_50 { public class Questionnaire10_50 {
public static org.hl7.fhir.r5.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu2.model.Questionnaire src) throws FHIRException { public static org.hl7.fhir.r5.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu2.model.Questionnaire src) throws FHIRException {
return convertQuestionnaire(src, new BaseAdvisor_10_50());
}
public static org.hl7.fhir.r5.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu2.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.r5.model.Questionnaire tgt = new org.hl7.fhir.r5.model.Questionnaire(); org.hl7.fhir.r5.model.Questionnaire tgt = new org.hl7.fhir.r5.model.Questionnaire();
VersionConvertor_10_50.copyDomainResource(src, tgt); VersionConvertor_10_50.copyDomainResource(src, tgt, advisor);
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_50.convertIdentifier(t)); for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_50.convertIdentifier(t));
if (src.hasVersionElement()) if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_50.convertString(src.getVersionElement())); tgt.setVersionElement(VersionConvertor_10_50.convertString(src.getVersionElement()));
@ -34,10 +41,14 @@ 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();
VersionConvertor_10_50.copyDomainResource(src, tgt); VersionConvertor_10_50.copyDomainResource(src, tgt, advisor);
for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_50.convertIdentifier(t)); for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_50.convertIdentifier(t));
if (src.hasVersionElement()) if (src.hasVersionElement())
tgt.setVersionElement(VersionConvertor_10_50.convertString(src.getVersionElement())); tgt.setVersionElement(VersionConvertor_10_50.convertString(src.getVersionElement()));

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;
@ -114,6 +108,4 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
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())
.forEach(sd -> {
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2)); sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE)); 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())
.forEach(sd -> {
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2)); sd.setUrl(sd.getUrl().replace(URL_BASE, URL_DSTU2));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE)); 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,33 @@
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.*
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,50 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor40
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.*
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(path: String, url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun ignoreType(path: String, 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,43 @@
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.ExtensionAdvisor50
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.*
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(path: String, url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun ignoreType(path: String, 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.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.*
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,44 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor40
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.*
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(path: String, url: String): Boolean {
return ignoredUrls.contains(url)
}
override fun ignoreType(path: String, 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,25 @@
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.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>()
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,25 @@
package org.hl7.fhir.convertors.advisors.impl
import org.hl7.fhir.convertors.advisors.interfaces.BaseAdvisor
import org.hl7.fhir.convertors.advisors.interfaces.bundle.BundleAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.codesystem.CodeSystemAdvisor40
import org.hl7.fhir.convertors.advisors.interfaces.extension.ExtensionAdvisor40
import org.hl7.fhir.r4.model.CodeSystem
import org.hl7.fhir.r4.model.ValueSet
import java.util.*
open class BaseAdvisor_30_40(val failFast: Boolean = true) : BaseAdvisor, BundleAdvisor40, CodeSystemAdvisor40,
ExtensionAdvisor40<org.hl7.fhir.dstu3.model.Extension> {
val cslist = ArrayList<CodeSystem>()
override fun failFastOnNullOrUnknownEntry(): Boolean {
return failFast
}
override fun handleCodeSystem(tgtcs: CodeSystem, srcvs: ValueSet) {
tgtcs.id = srcvs.id
tgtcs.valueSet = srcvs.url
cslist.add(tgtcs)
}
}

View File

@ -0,0 +1,25 @@
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.ExtensionAdvisor50
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.ValueSet
import java.util.*
open class BaseAdvisor_30_50(val failFast: Boolean = true) : BaseAdvisor, BundleAdvisor50, CodeSystemAdvisor50,
ExtensionAdvisor50<org.hl7.fhir.dstu3.model.Extension> {
val cslist = ArrayList<CodeSystem>()
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,25 @@
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.ExtensionAdvisor50
import org.hl7.fhir.r5.model.CodeSystem
import org.hl7.fhir.r5.model.ValueSet
import java.util.*
open class BaseAdvisor_40_50(val failFast: Boolean = true) : BaseAdvisor, BundleAdvisor50, CodeSystemAdvisor50,
ExtensionAdvisor50<org.hl7.fhir.r4.model.Extension> {
val cslist = ArrayList<CodeSystem>()
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(path: String, ext: Extension): Boolean {
return ext.url?.let { ignoreExtension(path, ext.url) } ?: false || ext.value?.let { ignoreType(path, ext.value) } ?: false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(path: String, ext: T): Boolean {
return ext.url?.let { ignoreExtension(path, ext.url) } ?: false || ext.value?.let { ignoreType(path, ext.value) } ?: false
}
@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.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(path: String, ext: Extension): Boolean {
return ext.url?.let { ignoreExtension(path, ext.url) } ?: false || ext.value?.let { ignoreType(path, ext.value) } ?: false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(path: String, ext: T): Boolean {
return ext.url?.let { ignoreExtension(path, ext.url) } ?: false || ext.value?.let { ignoreType(path, ext.value) } ?: false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreExtension(path: String, url: String): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(path: String, type: DataType): Boolean {
return false
}
@JvmDefault
@Throws(FHIRException::class)
fun ignoreType(path: String, type: Any): 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,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(path: String, ext: Extension): Boolean {
return ext.hasValue() && ext.value is Expression
}
@Throws(FHIRException::class)
override fun handleExtension(path:String, 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,31 @@
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(path: String, ext: org.hl7.fhir.dstu2.model.Extension): Boolean {
return super.useAdvisorForExtension(path, ext)
}
override fun useAdvisorForExtension(path: String, ext: Extension): Boolean {
return ext.hasValue() && ext.value is Expression
}
override fun handleExtension(path: String, 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;
@ -29,7 +29,7 @@ public class AllergyIntolerance10_40Test {
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();

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;
@ -18,7 +18,7 @@ public class Medication10_40Test {
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();

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;
@ -29,7 +29,7 @@ public class MedicationRequest10_40Test {
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();

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;
@ -18,7 +18,7 @@ public class Observation10_40Test {
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();

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;
@ -18,7 +18,7 @@ public class Procedure10_40Test {
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();

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;
@ -19,7 +19,7 @@ public class ValueSet10_40Test {
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();

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",
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"
},
"substance": {
"text": "STRAWBERRY",
"coding": [
{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "892484", "code": "892484",
"display": "STRAWBERRY"}, "display": "STRAWBERRY"
{"system": "http://fdasis.nlm.nih.gov", },
{
"system": "http://fdasis.nlm.nih.gov",
"code": "4J2TY8Y81V", "code": "4J2TY8Y81V",
"display": "STRAWBERRY"}]}, "display": "STRAWBERRY"
"reaction": [{"certainty": "confirmed", }
]
},
"reaction": [
{
"certainty": "confirmed",
"onset": "2014-03-07T00:00:00Z", "onset": "2014-03-07T00:00:00Z",
"manifestation": [{"text": "Anaphylaxis"}]}]} "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,14 +33,16 @@ 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.
*/ */
@ -162,140 +164,106 @@ public class Extension extends BaseExtension implements IBaseExtension<Extension
public Base addChild(String name) throws FHIRException { public Base addChild(String name) throws FHIRException {
if (name.equals("url")) { if (name.equals("url")) {
throw new FHIRException("Cannot call addChild on a primitive type Extension.url"); throw new FHIRException("Cannot call addChild on a primitive type Extension.url");
} } else if (name.equals("valueBoolean")) {
else if (name.equals("valueBoolean")) {
this.value = new BooleanType(); this.value = new BooleanType();
return this.value; return this.value;
} } else if (name.equals("valueInteger")) {
else if (name.equals("valueInteger")) {
this.value = new IntegerType(); this.value = new IntegerType();
return this.value; return this.value;
} } else if (name.equals("valueDecimal")) {
else if (name.equals("valueDecimal")) {
this.value = new DecimalType(); this.value = new DecimalType();
return this.value; return this.value;
} } else if (name.equals("valueBase64Binary")) {
else if (name.equals("valueBase64Binary")) {
this.value = new Base64BinaryType(); this.value = new Base64BinaryType();
return this.value; return this.value;
} } else if (name.equals("valueInstant")) {
else if (name.equals("valueInstant")) {
this.value = new InstantType(); this.value = new InstantType();
return this.value; return this.value;
} } else if (name.equals("valueString")) {
else if (name.equals("valueString")) {
this.value = new StringType(); this.value = new StringType();
return this.value; return this.value;
} } else if (name.equals("valueUri")) {
else if (name.equals("valueUri")) {
this.value = new UriType(); this.value = new UriType();
return this.value; return this.value;
} } else if (name.equals("valueDate")) {
else if (name.equals("valueDate")) {
this.value = new DateType(); this.value = new DateType();
return this.value; return this.value;
} } else if (name.equals("valueDateTime")) {
else if (name.equals("valueDateTime")) {
this.value = new DateTimeType(); this.value = new DateTimeType();
return this.value; return this.value;
} } else if (name.equals("valueTime")) {
else if (name.equals("valueTime")) {
this.value = new TimeType(); this.value = new TimeType();
return this.value; return this.value;
} } else if (name.equals("valueCode")) {
else if (name.equals("valueCode")) {
this.value = new CodeType(); this.value = new CodeType();
return this.value; return this.value;
} } else if (name.equals("valueOid")) {
else if (name.equals("valueOid")) {
this.value = new OidType(); this.value = new OidType();
return this.value; return this.value;
} } else if (name.equals("valueId")) {
else if (name.equals("valueId")) {
this.value = new IdType(); this.value = new IdType();
return this.value; return this.value;
} } else if (name.equals("valueUnsignedInt")) {
else if (name.equals("valueUnsignedInt")) {
this.value = new UnsignedIntType(); this.value = new UnsignedIntType();
return this.value; return this.value;
} } else if (name.equals("valuePositiveInt")) {
else if (name.equals("valuePositiveInt")) {
this.value = new PositiveIntType(); this.value = new PositiveIntType();
return this.value; return this.value;
} } else if (name.equals("valueMarkdown")) {
else if (name.equals("valueMarkdown")) {
this.value = new MarkdownType(); this.value = new MarkdownType();
return this.value; return this.value;
} } else if (name.equals("valueAnnotation")) {
else if (name.equals("valueAnnotation")) {
this.value = new Annotation(); this.value = new Annotation();
return this.value; return this.value;
} } else if (name.equals("valueAttachment")) {
else if (name.equals("valueAttachment")) {
this.value = new Attachment(); this.value = new Attachment();
return this.value; return this.value;
} } else if (name.equals("valueIdentifier")) {
else if (name.equals("valueIdentifier")) {
this.value = new Identifier(); this.value = new Identifier();
return this.value; return this.value;
} } else if (name.equals("valueCodeableConcept")) {
else if (name.equals("valueCodeableConcept")) {
this.value = new CodeableConcept(); this.value = new CodeableConcept();
return this.value; return this.value;
} } else if (name.equals("valueCoding")) {
else if (name.equals("valueCoding")) {
this.value = new Coding(); this.value = new Coding();
return this.value; return this.value;
} } else if (name.equals("valueQuantity")) {
else if (name.equals("valueQuantity")) {
this.value = new Quantity(); this.value = new Quantity();
return this.value; return this.value;
} } else if (name.equals("valueRange")) {
else if (name.equals("valueRange")) {
this.value = new Range(); this.value = new Range();
return this.value; return this.value;
} } else if (name.equals("valuePeriod")) {
else if (name.equals("valuePeriod")) {
this.value = new Period(); this.value = new Period();
return this.value; return this.value;
} } else if (name.equals("valueRatio")) {
else if (name.equals("valueRatio")) {
this.value = new Ratio(); this.value = new Ratio();
return this.value; return this.value;
} } else if (name.equals("valueSampledData")) {
else if (name.equals("valueSampledData")) {
this.value = new SampledData(); this.value = new SampledData();
return this.value; return this.value;
} } else if (name.equals("valueSignature")) {
else if (name.equals("valueSignature")) {
this.value = new Signature(); this.value = new Signature();
return this.value; return this.value;
} } else if (name.equals("valueHumanName")) {
else if (name.equals("valueHumanName")) {
this.value = new HumanName(); this.value = new HumanName();
return this.value; return this.value;
} } else if (name.equals("valueAddress")) {
else if (name.equals("valueAddress")) {
this.value = new Address(); this.value = new Address();
return this.value; return this.value;
} } else if (name.equals("valueContactPoint")) {
else if (name.equals("valueContactPoint")) {
this.value = new ContactPoint(); this.value = new ContactPoint();
return this.value; return this.value;
} } else if (name.equals("valueTiming")) {
else if (name.equals("valueTiming")) {
this.value = new Timing(); this.value = new Timing();
return this.value; return this.value;
} } else if (name.equals("valueReference")) {
else if (name.equals("valueReference")) {
this.value = new Reference(); this.value = new Reference();
return this.value; return this.value;
} } else if (name.equals("valueMeta")) {
else if (name.equals("valueMeta")) {
this.value = new Meta(); this.value = new Meta();
return this.value; return this.value;
} } else
else
return super.addChild(name); return super.addChild(name);
} }

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;
@ -546,7 +545,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"))
@ -574,8 +573,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

@ -209,7 +209,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))
@ -222,7 +222,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