Search in sources :

Example 11 with Expression

use of com.walmartlabs.concord.runtime.v2.model.Expression in project quality-measure-and-cohort-service by Alvearie.

the class MeasureTestBase method getCareGapMeasure.

public Measure getCareGapMeasure(String measureName, Library library, Map<MeasurePopulationType, String> expressionsByPopType, String... careGapExpressions) throws Exception {
    Measure measure = getProportionMeasure(measureName, library, expressionsByPopType);
    assertNotNull(careGapExpressions);
    for (String expression : careGapExpressions) {
        Measure.MeasureGroupPopulationComponent pop = new Measure.MeasureGroupPopulationComponent();
        pop.setId(expression);
        pop.setCode(new CodeableConcept(new Coding(CDMConstants.CDM_CODE_SYSTEM_MEASURE_POPULATION_TYPE, CDMConstants.CARE_GAP, "Care Gap")));
        pop.setCriteria(new Expression().setLanguage("text/cql+identifier").setExpression(expression));
        measure.getGroupFirstRep().addPopulation(pop);
    }
    return measure;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Expression(org.hl7.fhir.r4.model.Expression) Measure(org.hl7.fhir.r4.model.Measure) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 12 with Expression

use of com.walmartlabs.concord.runtime.v2.model.Expression in project quality-measure-and-cohort-service by Alvearie.

the class MeasureTestBase method addPopulations.

protected void addPopulations(Measure.MeasureGroupComponent group, Map<MeasurePopulationType, String> expressionsByPopType) {
    for (Map.Entry<MeasurePopulationType, String> entry : expressionsByPopType.entrySet()) {
        Measure.MeasureGroupPopulationComponent pop = new Measure.MeasureGroupPopulationComponent();
        pop.setCode(new CodeableConcept().addCoding(new Coding().setCode(entry.getKey().toCode())));
        pop.setCriteria(new Expression().setExpression(entry.getValue()));
        group.addPopulation(pop);
    }
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Expression(org.hl7.fhir.r4.model.Expression) Measure(org.hl7.fhir.r4.model.Measure) HashMap(java.util.HashMap) Map(java.util.Map) MeasurePopulationType(org.opencds.cqf.common.evaluation.MeasurePopulationType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 13 with Expression

use of com.walmartlabs.concord.runtime.v2.model.Expression in project org.hl7.fhir.core by hapifhir.

the class ExpressionAdvisor40 method handleExtension.

public void handleExtension(@Nonnull String path, @Nonnull Extension src, @Nonnull org.hl7.fhir.dstu2.model.Extension tgt) throws FHIRException {
    if (src.getValue() instanceof Expression) {
        StringType type = new StringType();
        if (src.getValue() == null) {
            throw new NullPointerException("null cannot be cast to non-null type org.hl7.fhir.r4.model.Expression");
        } else {
            type.setValueAsString(((Expression) src.getValue()).getExpression());
            tgt.setValue((org.hl7.fhir.dstu2.model.Type) type);
            if (src.hasUrlElement()) {
                tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement()));
            }
        }
    } else {
        throw new FHIRException("Unknown extension type passed in to custom convertor method.");
    }
}
Also used : Expression(org.hl7.fhir.r4.model.Expression) StringType(org.hl7.fhir.dstu2.model.StringType) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 14 with Expression

use of com.walmartlabs.concord.runtime.v2.model.Expression in project org.hl7.fhir.core by hapifhir.

the class Expression50Test 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_50 baseAdvisor50 = new BaseAdvisor_10_50();
    Assertions.assertTrue(baseAdvisor50.ignoreExtension("", ext));
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) Expression(org.hl7.fhir.r5.model.Expression) BaseAdvisor_10_50(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 15 with Expression

use of com.walmartlabs.concord.runtime.v2.model.Expression in project CRD by HL7-DaVinci.

the class QuestionnaireEmbeddedCQLProcessor method hasEmbeddedCql.

private boolean hasEmbeddedCql(QuestionnaireItemComponent item) {
    List<Extension> extensionList = item.getExtension();
    // sdc-questionnaire-initialExpression for now, could add more if needed
    if (extensionList.isEmpty())
        return false;
    for (int i = 0; i < extensionList.size(); i++) {
        Extension extension = extensionList.get(i);
        if (extension.getUrl().equals("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression")) {
            Expression expression = (Expression) extension.getValue();
            if (expression.getLanguage().equals("text/cql")) {
                String expressionString = expression.getExpression();
                // regex for \"library\".statement
                final String libraryRefRegex = "^\\\\\\\"[a-zA-Z0-9]+\\\\\\\".[a-zA-Z0-9]+$";
                final Pattern pattern = Pattern.compile(libraryRefRegex, Pattern.MULTILINE);
                // cql-execution library to throw error if it is invalid
                if (!pattern.matcher(expressionString).find()) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Pattern(java.util.regex.Pattern) Expression(org.hl7.fhir.r4.model.Expression)

Aggregations

Expression (org.hl7.fhir.r4.model.Expression)8 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)4 Coding (org.hl7.fhir.r4.model.Coding)4 Extension (org.hl7.fhir.r4.model.Extension)3 Measure (org.hl7.fhir.r4.model.Measure)3 Expression (org.hl7.fhir.r5.model.Expression)3 Expression (com.walmartlabs.concord.runtime.v2.model.Expression)2 ExpressionEvaluator (com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)2 Context (com.walmartlabs.concord.runtime.v2.sdk.Context)2 HashMap (java.util.HashMap)2 Pattern (java.util.regex.Pattern)2 StringType (org.hl7.fhir.dstu2.model.StringType)2 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 ApiException (com.walmartlabs.concord.ApiException)1 ProcessEventRequest (com.walmartlabs.concord.client.ProcessEventRequest)1 ExpressionOptions (com.walmartlabs.concord.runtime.v2.model.ExpressionOptions)1 ProcessDefinition (com.walmartlabs.concord.runtime.v2.model.ProcessDefinition)1 Step (com.walmartlabs.concord.runtime.v2.model.Step)1 SynchronizationService (com.walmartlabs.concord.runtime.v2.runner.SynchronizationService)1 CheckpointService (com.walmartlabs.concord.runtime.v2.runner.checkpoints.CheckpointService)1