Search in sources :

Example 1 with VersionConvertor_40_50

use of org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50 in project cqf-ruler by DBCG.

the class DataRequirements method getModuleDefinitionLibraryR4.

public static org.hl7.fhir.r4.model.Library getModuleDefinitionLibraryR4(LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options, SearchParameterResolver searchParameterResolver, TerminologyProvider terminologyProvider, ModelResolver modelResolver, IBaseConformance capStatement) {
    org.hl7.fhir.r5.model.Library libraryR5 = getModuleDefinitionLibraryR5(libraryManager, translatedLibrary, options);
    VersionConvertor_40_50 versionConvertor_40_50 = new VersionConvertor_40_50(new BaseAdvisor_40_50());
    org.hl7.fhir.r4.model.Library libraryR4 = (org.hl7.fhir.r4.model.Library) versionConvertor_40_50.convertResource(libraryR5);
    libraryR4 = addDataRequirementFhirQueries(libraryR4, searchParameterResolver, terminologyProvider, modelResolver, capStatement);
    return libraryR4;
}
Also used : BaseAdvisor_40_50(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50) VersionConvertor_40_50(org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50) TranslatedLibrary(org.cqframework.cql.cql2elm.model.TranslatedLibrary)

Example 2 with VersionConvertor_40_50

use of org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50 in project cqf-ruler by DBCG.

the class DataRequirements method getModuleDefinitionLibraryR4.

public static org.hl7.fhir.r4.model.Library getModuleDefinitionLibraryR4(org.hl7.fhir.r4.model.Measure measureToUse, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options, SearchParameterResolver searchParameterResolver, TerminologyProvider terminologyProvider, ModelResolver modelResolver, IBaseConformance capStatement) {
    VersionConvertor_40_50 versionConvertor_40_50 = new VersionConvertor_40_50(new BaseAdvisor_40_50());
    org.hl7.fhir.r5.model.Measure r5Measure = (org.hl7.fhir.r5.model.Measure) versionConvertor_40_50.convertResource(measureToUse);
    Set<String> expressionList = getExpressions(r5Measure);
    DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
    org.hl7.fhir.r5.model.Library effectiveDataRequirements = dqReqTrans.gatherDataRequirements(libraryManager, translatedLibrary, options, expressionList, true);
    org.hl7.fhir.r4.model.Library r4EffectiveDataRequirements = (org.hl7.fhir.r4.model.Library) versionConvertor_40_50.convertResource(effectiveDataRequirements);
    r4EffectiveDataRequirements = addDataRequirementFhirQueries(r4EffectiveDataRequirements, searchParameterResolver, terminologyProvider, modelResolver, capStatement);
    return r4EffectiveDataRequirements;
}
Also used : BaseAdvisor_40_50(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50) VersionConvertor_40_50(org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50) Measure(org.hl7.fhir.r5.model.Measure) Measure(org.hl7.fhir.r5.model.Measure) DataRequirementsProcessor(org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor) TranslatedLibrary(org.cqframework.cql.cql2elm.model.TranslatedLibrary)

Example 3 with VersionConvertor_40_50

use of org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50 in project org.hl7.fhir.core by hapifhir.

the class VersionConvertorPrimitiveTypeTests method testDirectConversion.

@ParameterizedTest(name = "Test index: {index} Source Class={1} First Value={3} Second Class={4} Second Value={6}")
@MethodSource("getDirectConversionParams")
public <K, L> void testDirectConversion(Class<K> srcTypeClazz, Class<L> tgtTypeClazz, Function<K, L> convertFunction, String[] srcStrings, String[] tgtStrings) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
    ConversionContext10_30.INSTANCE.init(mock(VersionConvertor_10_30.class), CONTEXT_PATH);
    ConversionContext10_40.INSTANCE.init(mock(VersionConvertor_10_40.class), CONTEXT_PATH);
    ConversionContext10_50.INSTANCE.init(mock(VersionConvertor_10_50.class), CONTEXT_PATH);
    ConversionContext14_50.INSTANCE.init(mock(VersionConvertor_14_50.class), CONTEXT_PATH);
    ConversionContext30_50.INSTANCE.init(mock(VersionConvertor_30_50.class), CONTEXT_PATH);
    ConversionContext40_50.INSTANCE.init(mock(VersionConvertor_40_50.class), CONTEXT_PATH);
    Method srcSetValueAsStringMethod = srcTypeClazz.getMethod("setValueAsString", String.class);
    Method srcGetValueAsString = srcTypeClazz.getMethod("getValueAsString");
    Method srcHasValue = srcTypeClazz.getMethod("hasValue");
    for (int i = 0; i < srcStrings.length; i++) {
        K srcInstance = srcTypeClazz.getDeclaredConstructor().newInstance();
        srcSetValueAsStringMethod.invoke(srcInstance, srcStrings[i]);
        String srcValueAsString = (String) srcGetValueAsString.invoke(srcInstance);
        Assertions.assertEquals(srcStrings[i], srcValueAsString);
        boolean srcHasValueReturn = (boolean) srcHasValue.invoke(srcInstance);
        L tgtInstance = convertFunction.apply(srcInstance);
        Method tgtGetValueAsString = tgtTypeClazz.getMethod("getValueAsString");
        Method tgtHasValue = tgtTypeClazz.getMethod("hasValue");
        if (srcHasValueReturn) {
            String tgtValueAsString = (String) tgtGetValueAsString.invoke(tgtInstance);
            Assertions.assertEquals(tgtStrings[i], tgtValueAsString);
        } else {
            boolean tgtHasValueReturn = (boolean) tgtHasValue.invoke(tgtInstance);
            Assertions.assertFalse(tgtHasValueReturn);
        }
    }
    ConversionContext10_30.INSTANCE.close(CONTEXT_PATH);
    ConversionContext10_40.INSTANCE.close(CONTEXT_PATH);
    ConversionContext10_50.INSTANCE.close(CONTEXT_PATH);
    ConversionContext14_50.INSTANCE.close(CONTEXT_PATH);
    ConversionContext30_50.INSTANCE.close(CONTEXT_PATH);
    ConversionContext40_50.INSTANCE.close(CONTEXT_PATH);
}
Also used : VersionConvertor_30_50(org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50) VersionConvertor_14_50(org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50) VersionConvertor_40_50(org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50) VersionConvertor_10_40(org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40) VersionConvertor_10_50(org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50) Method(java.lang.reflect.Method) VersionConvertor_10_30(org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

VersionConvertor_40_50 (org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50)3 TranslatedLibrary (org.cqframework.cql.cql2elm.model.TranslatedLibrary)2 BaseAdvisor_40_50 (org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50)2 Method (java.lang.reflect.Method)1 DataRequirementsProcessor (org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor)1 VersionConvertor_10_30 (org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30)1 VersionConvertor_10_40 (org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40)1 VersionConvertor_10_50 (org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50)1 VersionConvertor_14_50 (org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50)1 VersionConvertor_30_50 (org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50)1 Measure (org.hl7.fhir.r5.model.Measure)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1