Search in sources :

Example 6 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 Expression40Test method testBaseAdvisorExpressionIgore.

@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));
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Expression(org.hl7.fhir.r4.model.Expression) 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 7 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 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));
}
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) JsonParser(org.hl7.fhir.r4.formats.JsonParser) JsonParser(org.hl7.fhir.r4.formats.JsonParser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 8 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 Questionnaire10_40 method convertQuestionnaire.

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())
        return null;
    org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire();
    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_40.convertString(src.getVersionElement()));
    if (src.hasStatus())
        tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
    if (src.hasDate())
        tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement()));
    if (src.hasPublisherElement())
        tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement()));
    for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(ContactPoint10_40.convertContactPoint(t1));
    org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup();
    root.setTitle(src.getTitle());
    for (org.hl7.fhir.r4.model.Coding t : src.getCode()) {
        root.addConcept(Coding10_40.convertCoding(t));
    }
    for (org.hl7.fhir.r4.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) if (t.getType() == org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP)
        root.addGroup(convertQuestionnaireGroupComponent(t));
    else
        root.addQuestion(convertQuestionnaireQuestionComponent(t));
    return tgt;
}
Also used : ContactDetail(org.hl7.fhir.r4.model.ContactDetail)

Example 9 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 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));
}
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 10 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 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));
}
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)

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