Search in sources :

Example 16 with ExpressionNode

use of org.hl7.fhir.r4b.model.ExpressionNode in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method parse.

/**
 * Parse a path that is part of some other syntax
 *
 * @return
 * @throws PathEngineException
 * @throws Exception
 */
public ExpressionNode parse(FHIRLexer lexer) throws FHIRLexerException {
    ExpressionNode result = parseExpression(lexer, true);
    result.check();
    return result;
}
Also used : ExpressionNode(org.hl7.fhir.dstu2.model.ExpressionNode)

Example 17 with ExpressionNode

use of org.hl7.fhir.r4b.model.ExpressionNode in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method funcLength.

private List<Base> funcLength(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
    List<Base> result = new ArrayList<Base>();
    if (focus.size() == 1) {
        String s = convertToString(focus.get(0));
        result.add(new IntegerType(s.length()));
    }
    return result;
}
Also used : IntegerType(org.hl7.fhir.dstu2.model.IntegerType) ArrayList(java.util.ArrayList) Base(org.hl7.fhir.dstu2.model.Base)

Example 18 with ExpressionNode

use of org.hl7.fhir.r4b.model.ExpressionNode in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method funcAll.

private List<Base> funcAll(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws PathEngineException {
    if (exp.getParameters().size() == 1) {
        List<Base> result = new ArrayList<Base>();
        List<Base> pc = new ArrayList<Base>();
        boolean all = true;
        for (Base item : focus) {
            pc.clear();
            pc.add(item);
            if (!convertToBoolean(execute(changeThis(context, item), pc, exp.getParameters().get(0), false))) {
                all = false;
                break;
            }
        }
        result.add(new BooleanType(all));
        return result;
    } else {
        // (exp.getParameters().size() == 0) {
        List<Base> result = new ArrayList<Base>();
        boolean all = true;
        for (Base item : focus) {
            boolean v = false;
            if (item instanceof BooleanType) {
                v = ((BooleanType) item).booleanValue();
            } else
                v = item != null;
            if (!v) {
                all = false;
                break;
            }
        }
        result.add(new BooleanType(all));
        return result;
    }
}
Also used : ArrayList(java.util.ArrayList) BooleanType(org.hl7.fhir.dstu2.model.BooleanType) Base(org.hl7.fhir.dstu2.model.Base)

Example 19 with ExpressionNode

use of org.hl7.fhir.r4b.model.ExpressionNode in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method funcExtension.

private List<Base> funcExtension(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws PathEngineException {
    List<Base> result = new ArrayList<Base>();
    List<Base> nl = execute(context, focus, exp.getParameters().get(0), true);
    String url = nl.get(0).primitiveValue();
    for (Base item : focus) {
        List<Base> ext = new ArrayList<Base>();
        getChildrenByName(item, "extension", ext);
        getChildrenByName(item, "modifierExtension", ext);
        for (Base ex : ext) {
            List<Base> vl = new ArrayList<Base>();
            getChildrenByName(ex, "url", vl);
            if (convertToString(vl).equals(url))
                result.add(ex);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Base(org.hl7.fhir.dstu2.model.Base)

Example 20 with ExpressionNode

use of org.hl7.fhir.r4b.model.ExpressionNode in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method funcEmpty.

private List<Base> funcEmpty(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
    List<Base> result = new ArrayList<Base>();
    result.add(new BooleanType(focus.isEmpty()));
    return result;
}
Also used : ArrayList(java.util.ArrayList) BooleanType(org.hl7.fhir.dstu2.model.BooleanType) Base(org.hl7.fhir.dstu2.model.Base)

Aggregations

ArrayList (java.util.ArrayList)190 Base (org.hl7.fhir.r4b.model.Base)68 Base (org.hl7.fhir.r5.model.Base)67 FHIRException (org.hl7.fhir.exceptions.FHIRException)52 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)49 UcumException (org.fhir.ucum.UcumException)31 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)29 NotImplementedException (org.apache.commons.lang3.NotImplementedException)25 Base (org.hl7.fhir.dstu2016may.model.Base)25 BigDecimal (java.math.BigDecimal)23 Base (org.hl7.fhir.dstu2.model.Base)21 ExpressionNode (org.hl7.fhir.r5.model.ExpressionNode)21 ParserBase (org.hl7.fhir.dstu2016may.metamodel.ParserBase)20 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)20 ExpressionNode (org.hl7.fhir.r4b.model.ExpressionNode)19 ExpressionNode (org.hl7.fhir.dstu2016may.model.ExpressionNode)18 ExpressionNode (org.hl7.fhir.dstu3.model.ExpressionNode)16 ExpressionNode (org.hl7.fhir.r4.model.ExpressionNode)16 List (java.util.List)15 BooleanType (org.hl7.fhir.r5.model.BooleanType)15