Search in sources :

Example 1 with Specification

use of io.github.linuxforhealth.api.Specification in project hl7v2-fhir-converter by LinuxForHealth.

the class ExpressionAttributes method getSpecList.

public static List<Specification> getSpecList(String inputString, boolean useGroup, boolean generateMultiple) {
    ExpressionModifiers exp = extractExpressionModifiers(inputString, generateMultiple);
    List<Specification> specs = new ArrayList<>();
    if (StringUtils.isNotBlank(exp.expression)) {
        StringTokenizer st = new StringTokenizer(exp.expression, "|").setIgnoreEmptyTokens(true).setTrimmerMatcher(StringMatcherFactory.INSTANCE.spaceMatcher());
        st.getTokenList().forEach(s -> specs.add(SpecificationParser.parse(s, exp.extractMultiple, useGroup, exp.retainEmpty)));
    }
    return specs;
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) ArrayList(java.util.ArrayList) Specification(io.github.linuxforhealth.api.Specification)

Example 2 with Specification

use of io.github.linuxforhealth.api.Specification in project hl7v2-fhir-converter by LinuxForHealth.

the class SimpleVariable method getValuesFromSpecs.

protected List<EvaluationResult> getValuesFromSpecs(Map<String, EvaluationResult> contextValues, InputDataExtractor dataSource, boolean fetchAll) {
    List<EvaluationResult> combineValue = new ArrayList<>();
    for (String specValue : this.spec) {
        EvaluationResult fetchedValue = null;
        if (VariableUtils.isVar(specValue)) {
            boolean fuzzyMatch = VariableUtils.isFuzzyMatch(specValue);
            fetchedValue = ContextValueUtils.getVariableValuesFromVariableContextMap(specValue, ImmutableMap.copyOf(contextValues), false, fuzzyMatch);
        } else {
            EvaluationResult gen;
            Specification spec = SpecificationParser.parse(specValue, this.extractMultiple, false, this.retainEmpty);
            gen = spec.extractValueForSpec(dataSource, contextValues);
            if (gen != null && !gen.isEmpty()) {
                fetchedValue = gen;
            }
        }
        // break the loop and return
        if (fetchedValue != null) {
            combineValue.add(fetchedValue);
            if (!fetchAll) {
                return combineValue;
            }
        }
    }
    return combineValue;
}
Also used : ArrayList(java.util.ArrayList) Specification(io.github.linuxforhealth.api.Specification) EvaluationResult(io.github.linuxforhealth.api.EvaluationResult)

Aggregations

Specification (io.github.linuxforhealth.api.Specification)2 ArrayList (java.util.ArrayList)2 EvaluationResult (io.github.linuxforhealth.api.EvaluationResult)1 StringTokenizer (org.apache.commons.text.StringTokenizer)1