All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.linuxforhealth.hl7.expression.JEXLExpression Maven / Gradle / Ivy

Go to download

FHIR converter is a Java based library that enables converting Hl7v2 messages to FHIR resources

There is a newer version: 1.0.19
Show newest version
/*
 * (C) Copyright IBM Corp. 2020
 *
 * SPDX-License-Identifier: Apache-2.0
 */
package io.github.linuxforhealth.hl7.expression;

import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.github.linuxforhealth.api.EvaluationResult;
import io.github.linuxforhealth.api.InputDataExtractor;
import io.github.linuxforhealth.api.Variable;
import io.github.linuxforhealth.core.expression.EmptyEvaluationResult;


@JsonIgnoreProperties(ignoreUnknown = true)
public class JEXLExpression extends AbstractExpression {
  private static final Logger LOGGER = LoggerFactory.getLogger(JEXLExpression.class);

  @JsonCreator
  public JEXLExpression(ExpressionAttributes expAttr) {
    super(expAttr);

  }



  @Override
  public EvaluationResult evaluateExpression(InputDataExtractor dataSource,
      Map contextValues, EvaluationResult baseValue) {
    Map localContextValues = new HashMap<>(contextValues);
    for (Variable v : this.getVariables()) {
      if (!localContextValues.containsKey(v.getVariableName())) {
        localContextValues.put(v.getVariableName(), new EmptyEvaluationResult());
      }
    }
    LOGGER.info("Evaluating expression");
    
    return dataSource.evaluateJexlExpression(this.getExpressionAttr().getValueOf(), contextValues);
  }



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy