use of org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40 in project org.hl7.fhir.core by hapifhir.
the class ExtensionDefinitionGenerator method loadResource.
private Resource loadResource(InputStream inputStream, FHIRVersion v) throws IOException, FHIRException {
if (v == FHIRVersion._3_0_1) {
org.hl7.fhir.dstu3.model.Resource res = new org.hl7.fhir.dstu3.formats.JsonParser().parse(inputStream);
return VersionConvertorFactory_30_40.convertResource(res, new BaseAdvisor_30_40(false));
} else if (v == FHIRVersion._1_4_0) {
org.hl7.fhir.dstu2016may.model.Resource res = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(inputStream);
return VersionConvertorFactory_14_40.convertResource(res);
} else if (v == FHIRVersion._1_0_2) {
org.hl7.fhir.dstu2.model.Resource res = new org.hl7.fhir.dstu2.formats.JsonParser().parse(inputStream);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
return VersionConvertorFactory_10_40.convertResource(res, advisor);
} else if (v == FHIRVersion._4_0_0) {
return new JsonParser().parse(inputStream);
} else
throw new Error("Unsupported version " + v);
}
use of org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40 in project org.hl7.fhir.core by hapifhir.
the class Device30_40Test method test1.
@Test
@DisplayName("Test r4 -> dstu3 device conversion.")
public void test1() throws IOException {
InputStream r4_input = this.getClass().getResourceAsStream("/0_device_40.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.dstu3.model.Resource dstu3_conv = VersionConvertorFactory_30_40.convertResource(r4_actual, new BaseAdvisor_30_40(false));
org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
Assertions.assertTrue(dstu3_expected.equalsDeep(dstu3_conv), "Failed comparing\n" + dstu3_parser.composeString(dstu3_expected) + "\nand\n" + dstu3_parser.composeString(dstu3_conv));
}
use of org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40 in project org.hl7.fhir.core by hapifhir.
the class Device30_40Test method test2.
@Test
@DisplayName("Test r4 -> dstu3 device conversion, part 2.")
public void test2() throws IOException {
InputStream r4_input = this.getClass().getResourceAsStream("/1_device_40.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.dstu3.model.Resource dstu3_conv = VersionConvertorFactory_30_40.convertResource(r4_actual, new BaseAdvisor_30_40(false));
org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
Assertions.assertTrue(dstu3_expected.equalsDeep(dstu3_conv), "Failed comparing\n" + dstu3_parser.composeString(dstu3_expected) + "\nand\n" + dstu3_parser.composeString(dstu3_expected));
}
use of org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40 in project org.hl7.fhir.core by hapifhir.
the class ExtensionDefinitionGenerator method saveResource.
private byte[] saveResource(Resource resource, FHIRVersion v) throws IOException, FHIRException {
if (v == FHIRVersion._3_0_1) {
org.hl7.fhir.dstu3.model.Resource res = VersionConvertorFactory_30_40.convertResource(resource, new BaseAdvisor_30_40(false));
return new org.hl7.fhir.dstu3.formats.JsonParser().composeBytes(res);
} else if (v == FHIRVersion._1_4_0) {
org.hl7.fhir.dstu2016may.model.Resource res = VersionConvertorFactory_14_40.convertResource(resource);
return new org.hl7.fhir.dstu2016may.formats.JsonParser().composeBytes(res);
} else if (v == FHIRVersion._1_0_2) {
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.dstu2.model.Resource res = VersionConvertorFactory_10_40.convertResource(resource, advisor);
return new org.hl7.fhir.dstu2.formats.JsonParser().composeBytes(res);
} else if (v == FHIRVersion._4_0_0) {
return new JsonParser().composeBytes(resource);
} else
throw new Error("Unsupported version " + v);
}
Aggregations