Search in sources :

Example 11 with BaseAdvisor_10_40

use of org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40 in project org.hl7.fhir.core by hapifhir.

the class Observation10_40Test method testObservationConversion.

@Test
@DisplayName("Test 10_40 Observation conversion")
public void testObservationConversion() throws IOException {
    InputStream dstu2_input = this.getClass().getResourceAsStream("/0_observation_10.json");
    InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_observation_40.json");
    org.hl7.fhir.dstu2.model.Observation dstu2 = (org.hl7.fhir.dstu2.model.Observation) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
    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));
}
Also used : InputStream(java.io.InputStream) IGR2ConvertorAdvisor(org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor) BaseAdvisor_10_40(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with BaseAdvisor_10_40

use of org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40 in project org.hl7.fhir.core by hapifhir.

the class MedicationRequest10_40Test method testMedicationRequestConversion.

@ParameterizedTest
@MethodSource("filesPaths")
@DisplayName("Test 10_40 MedicationRequest conversion")
public void testMedicationRequestConversion(String dstu2_path, String r4_path) throws IOException {
    InputStream dstu2_input = this.getClass().getResourceAsStream(dstu2_path);
    InputStream r4_exepected_input = this.getClass().getResourceAsStream(r4_path);
    org.hl7.fhir.dstu2.model.MedicationOrder dstu2 = (org.hl7.fhir.dstu2.model.MedicationOrder) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
    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));
}
Also used : InputStream(java.io.InputStream) IGR2ConvertorAdvisor(org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor) BaseAdvisor_10_40(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Example 13 with BaseAdvisor_10_40

use of org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_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);
}
Also used : Resource(org.hl7.fhir.r4.model.Resource) IGR2ConvertorAdvisor(org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor) BaseAdvisor_10_40(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40) BaseAdvisor_30_40(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40) JsonParser(org.hl7.fhir.r4.formats.JsonParser)

Aggregations

BaseAdvisor_10_40 (org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40)9 IGR2ConvertorAdvisor (org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor)8 DisplayName (org.junit.jupiter.api.DisplayName)7 InputStream (java.io.InputStream)6 Test (org.junit.jupiter.api.Test)5 JsonParser (org.hl7.fhir.r4.formats.JsonParser)3 BaseAdvisor_30_40 (org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40)2 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)2 BooleanType (org.hl7.fhir.r4.model.BooleanType)2 CodeSystem (org.hl7.fhir.r4.model.CodeSystem)2 Resource (org.hl7.fhir.r4.model.Resource)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 CapabilityStatementRestComponent (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent)1 CapabilityStatementRestResourceComponent (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent)1 ConceptDefinitionComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent)1 ContactDetail (org.hl7.fhir.r4.model.ContactDetail)1 Expression (org.hl7.fhir.r4.model.Expression)1 Extension (org.hl7.fhir.r4.model.Extension)1