use of org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor 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.misc.IGR2ConvertorAdvisor in project org.hl7.fhir.core by hapifhir.
the class Procedure10_40Test method testProcedureConversion.
@Test
@DisplayName("Test 10_40 Procedure conversion")
public void testProcedureConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_procedure_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_procedure_40.json");
org.hl7.fhir.dstu2.model.Procedure dstu2 = (org.hl7.fhir.dstu2.model.Procedure) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertorFactory_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
use of org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor in project org.hl7.fhir.core by hapifhir.
the class ValueSet10_40Test method testValueSetConversion.
@Test
@DisplayName("Test 10_40 ValueSet conversion")
public void testValueSetConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_valueset_vision_base_codes_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_valueset_vision_base_codes_40.json");
org.hl7.fhir.dstu2.model.ValueSet dstu2 = (org.hl7.fhir.dstu2.model.ValueSet) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertorFactory_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
JsonParser parser = new JsonParser();
String composeString = parser.composeString(r4_actual);
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
use of org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor in project org.hl7.fhir.core by hapifhir.
the class AllergyIntolerance10_40Test method testMedicationRequestConversion.
@ParameterizedTest
@MethodSource("filesPaths")
@DisplayName("Test 10_40 AllergyIntolerance conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_path);
org.hl7.fhir.dstu2.model.AllergyIntolerance dstu2 = (org.hl7.fhir.dstu2.model.AllergyIntolerance) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertorFactory_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
if (!r4_expected.equalsDeep(r4_actual)) {
System.out.println("Expected");
System.out.println(r4_parser.composeString(r4_expected));
System.out.println();
System.out.println("Actual");
System.out.println(r4_parser.composeString(r4_actual));
}
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
use of org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor in project org.hl7.fhir.core by hapifhir.
the class Medication10_40Test method testMedicationConversion.
@Test
@DisplayName("Test 10_40 Medication conversion")
public void testMedicationConversion() throws IOException {
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_medication_10.json");
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_medication_40.json");
org.hl7.fhir.dstu2.model.Medication dstu2 = (org.hl7.fhir.dstu2.model.Medication) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertorFactory_10_40.convertResource(dstu2, advisor);
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
}
Aggregations