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;
}
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;
}
Aggregations