Search in sources :

Example 1 with VersionConvertor_30_50

use of org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50 in project cqf-ruler by DBCG.

the class DataRequirements method getModuleDefinitionLibraryDstu3.

public static org.hl7.fhir.dstu3.model.Library getModuleDefinitionLibraryDstu3(LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) {
    org.hl7.fhir.r5.model.Library libraryR5 = getModuleDefinitionLibraryR5(libraryManager, translatedLibrary, options);
    BaseAdvisor_30_50 baseAdvisor_30_50 = new BaseAdvisor_30_50();
    VersionConvertor_30_50 versionConvertor_30_50 = new VersionConvertor_30_50(baseAdvisor_30_50);
    org.hl7.fhir.dstu3.model.Library libraryDstu3 = null;
    libraryDstu3 = (org.hl7.fhir.dstu3.model.Library) versionConvertor_30_50.convertResource(libraryR5);
    // There is no DSTU3 extension to support FHIRQueryPattern representation on a DataRequirement
    return libraryDstu3;
}
Also used : BaseAdvisor_30_50(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50) VersionConvertor_30_50(org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50)

Example 2 with VersionConvertor_30_50

use of org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50 in project org.hl7.fhir.core by hapifhir.

the class ElementDefinition30_50 method convertElementDefinitionBindingComponent.

public static ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException {
    if (src == null)
        return null;
    ElementDefinition.ElementDefinitionBindingComponent tgt = new ElementDefinition.ElementDefinitionBindingComponent();
    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, VersionConvertor_30_50.EXT_SRC_TYPE);
    if (src.hasStrength())
        tgt.setStrengthElement(Enumerations30_50.convertBindingStrength(src.getStrengthElement()));
    if (src.hasDescription())
        tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
    if (src.hasValueSet()) {
        DataType t = ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValueSet());
        if (t instanceof org.hl7.fhir.r5.model.Reference) {
            tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference());
            tgt.getValueSetElement().addExtension(VersionConvertor_30_50.EXT_SRC_TYPE, new org.hl7.fhir.r5.model.UrlType("Reference"));
        } else {
            tgt.setValueSet(t.primitiveValue());
            tgt.getValueSetElement().addExtension(VersionConvertor_30_50.EXT_SRC_TYPE, new org.hl7.fhir.r5.model.UrlType("uri"));
        }
        tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
    }
    return tgt;
}
Also used : DataType(org.hl7.fhir.r5.model.DataType) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Example 3 with VersionConvertor_30_50

use of org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50 in project org.hl7.fhir.core by hapifhir.

the class DocumentReference30_50 method convertDocumentReference.

public static org.hl7.fhir.dstu3.model.DocumentReference convertDocumentReference(org.hl7.fhir.r5.model.DocumentReference src) throws FHIRException {
    if (src == null)
        return null;
    org.hl7.fhir.dstu3.model.DocumentReference tgt = new org.hl7.fhir.dstu3.model.DocumentReference();
    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
    // tgt.setMasterIdentifier(VersionConvertor_30_50.convertIdentifier(src.getMasterIdentifier()));
    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
    if (src.hasStatus())
        tgt.setStatusElement(convertDocumentReferenceStatus(src.getStatusElement()));
    if (src.hasDocStatus())
        tgt.setDocStatusElement(convertReferredDocumentStatus(src.getDocStatusElement()));
    if (src.hasType())
        tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
    if (src.hasCategory())
        tgt.setClass_(CodeableConcept30_50.convertCodeableConcept(src.getCategoryFirstRep()));
    if (src.hasSubject())
        tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
    if (src.hasDate())
        tgt.setCreated(src.getDate());
    for (DocumentReferenceAttesterComponent t : src.getAttester()) {
        if (t.getMode() == DocumentAttestationMode.OFFICIAL)
            tgt.setAuthenticator(Reference30_50.convertReference(t.getParty()));
    }
    if (src.hasCustodian())
        tgt.setCustodian(Reference30_50.convertReference(src.getCustodian()));
    for (org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceRelatesToComponent t : src.getRelatesTo()) tgt.addRelatesTo(convertDocumentReferenceRelatesToComponent(t));
    if (src.hasDescription())
        tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSecurityLabel()) tgt.addSecurityLabel(CodeableConcept30_50.convertCodeableConcept(t));
    for (org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceContentComponent t : src.getContent()) tgt.addContent(convertDocumentReferenceContentComponent(t));
    convertDocumentReferenceContextComponent(src, tgt.getContext());
    return tgt;
}
Also used : DocumentReferenceAttesterComponent(org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceAttesterComponent)

Example 4 with VersionConvertor_30_50

use of org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50 in project cqf-ruler by DBCG.

the class DataRequirements method getModuleDefinitionLibraryDstu3.

public static org.hl7.fhir.dstu3.model.Library getModuleDefinitionLibraryDstu3(org.hl7.fhir.dstu3.model.Measure measureToUse, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) {
    VersionConvertor_30_50 versionConvertor_30_50 = new VersionConvertor_30_50(new BaseAdvisor_30_50());
    org.hl7.fhir.r5.model.Measure r5Measure = (org.hl7.fhir.r5.model.Measure) versionConvertor_30_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.dstu3.model.Library stu3EffectiveDataRequirements = (org.hl7.fhir.dstu3.model.Library) versionConvertor_30_50.convertResource(effectiveDataRequirements);
    // TODO: Support dataRequirementFhirQueries in STU3
    return stu3EffectiveDataRequirements;
}
Also used : Measure(org.hl7.fhir.r5.model.Measure) BaseAdvisor_30_50(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50) VersionConvertor_30_50(org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50) Measure(org.hl7.fhir.r5.model.Measure) DataRequirementsProcessor(org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor) TranslatedLibrary(org.cqframework.cql.cql2elm.model.TranslatedLibrary)

Example 5 with VersionConvertor_30_50

use of org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_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_30_50 (org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50)3 BaseAdvisor_30_50 (org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50)2 Method (java.lang.reflect.Method)1 TranslatedLibrary (org.cqframework.cql.cql2elm.model.TranslatedLibrary)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_40_50 (org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50)1 DataType (org.hl7.fhir.r5.model.DataType)1 DocumentReferenceAttesterComponent (org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceAttesterComponent)1 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)1 Measure (org.hl7.fhir.r5.model.Measure)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1