/** * Parse a path for later use using execute * * @param path * @return * @throws PathEngineException * @throws Exception */ public ExpressionNode parse(String path) throws FHIRLexerException { return parse(path, null); }
@Override public void evaluate(StringBuilder b, Resource resource, LiquidEngineContext ctxt) throws FHIRException { if (compiled == null) compiled = engine.parse(statement); b.append(engine.evaluateToString(ctxt, resource, resource, compiled)); } }
public TypeDetails check(Object appContext, String resourceType, String context, String expr) throws FHIRLexerException, PathEngineException, DefinitionException { return check(appContext, resourceType, context, parse(expr)); }
/** * evaluate a path and return the matching elements * * @param base - the object against which the path is being evaluated * @param path - the FHIR Path statement to use * @return * @throws FHIRException * @ */ public List<Base> evaluate(Object appContext, Resource resource, Base base, String path) throws FHIRException { ExpressionNode exp = parse(path); List<Base> list = new ArrayList<Base>(); if (base != null) list.add(base); log = new StringBuilder(); return execute(new ExecutionContext(appContext, resource, base, null, base), list, exp, true); }
@Override public void evaluate(StringBuilder b, Resource resource, LiquidEngineContext ctxt) throws FHIRException { if (compiled == null) compiled = engine.parse(condition); boolean ok = engine.evaluateToBoolean(ctxt, resource, resource, compiled); List<LiquidNode> list = ok ? thenBody : elseBody; for (LiquidNode n : list) { n.evaluate(b, resource, ctxt); } } }
private List<Resource> filterResources(Argument fhirpath, List<Resource> list) throws EGraphQLException, FHIRException { List<Resource> result = new ArrayList<Resource>(); if (list.size() > 0) { if ((fhirpath == null)) for (Resource v : list) result.add(v); else { FHIRPathEngine fpe = new FHIRPathEngine(context); ExpressionNode node = fpe.parse(getSingleValue(fhirpath)); for (Resource v : list) if (fpe.evaluateToBoolean(null, v, v, node)) result.add(v); } } return result; }
/** * evaluate a path and return the matching elements * * @param base - the object against which the path is being evaluated * @param path - the FHIR Path statement to use * @return * @throws FHIRException * @ */ public List<Base> evaluate(Base base, String path) throws FHIRException { ExpressionNode exp = parse(path); List<Base> list = new ArrayList<Base>(); if (base != null) list.add(base); log = new StringBuilder(); return execute(new ExecutionContext(null, base.isResource() ? base : null, base, null, base), list, exp, true); }
@Override public void evaluate(StringBuilder b, Resource resource, LiquidEngineContext ctxt) throws FHIRException { if (compiled == null) compiled = engine.parse(condition); List<Base> list = engine.evaluate(ctxt, resource, resource, compiled); LiquidEngineContext lctxt = new LiquidEngineContext(ctxt); for (Base o : list) { lctxt.vars.put(varName, o); for (LiquidNode n : body) { n.evaluate(b, resource, lctxt); } } } }
ExpressionNode node = fpe.parse(fp.toString().substring(5)); for (Base v : values) { if ((i >= offset) && passesExtensionMode(v, extensionMode) && fpe.evaluateToBoolean(null, context, v, node)) {
private List<Resource> filterResources(Argument fhirpath, Bundle bnd) throws EGraphQLException, FHIRException { List<Resource> result = new ArrayList<Resource>(); if (bnd.getEntry().size() > 0) { if ((fhirpath == null)) for (BundleEntryComponent be : bnd.getEntry()) result.add(be.getResource()); else { FHIRPathEngine fpe = new FHIRPathEngine(context); ExpressionNode node = fpe.parse(getSingleValue(fhirpath)); for (BundleEntryComponent be : bnd.getEntry()) if (fpe.evaluateToBoolean(null, be.getResource(), be.getResource(), node)) result.add(be.getResource()); } } return result; }
ExpressionNode expr = fpe.parse(discriminator); long t2 = System.nanoTime(); ElementDefinition ed = fpe.evaluateDefinition(expr, profile, element);
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_SEARCH_EXPRESSION); if (expr == null) { expr = fpe.parse(src.getElement()); src.setUserData(MAP_SEARCH_EXPRESSION, expr); ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_EXPRESSION); if (expr == null) { expr = fpe.parse(src.getCondition()); ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_CHECK); if (expr == null) { expr = fpe.parse(src.getCheck()); ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_LOG); if (expr == null) { expr = fpe.parse(src.getLogMessage());
n = fpe.parse(expression.toString()); } catch (FHIRLexerException e) { throw new FHIRException("Problem processing expression "+expression +" in profile " + profile.getUrl() + " path " + path + ": " + e.getMessage());
fhirPathEngine.parse(theExpression); } catch (FHIRLexer.FHIRLexerException e) { throw new UnprocessableEntityException("Invalid SearchParameter.expression value \"" + theExpression + "\": " + e.getMessage());
ExpressionNode expr = (ExpressionNode) tgt.getUserData(MAP_EXPRESSION); if (expr == null) { expr = fpe.parse(getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString())); tgt.setUserData(MAP_WHERE_EXPRESSION, expr);
public void checkAllInvariants(){ for (StructureDefinition sd : context.allStructures()) { if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) { for (ElementDefinition ed : sd.getSnapshot().getElement()) { for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) { if (inv.hasExpression()) { try { ExpressionNode n = (ExpressionNode) inv.getUserData("validator.expression.cache"); if (n == null) { n = fpe.parse(inv.getExpression()); inv.setUserData("validator.expression.cache", n); } fpe.check(null, sd.getKind() == StructureDefinitionKind.RESOURCE ? sd.getType() : "DomainResource", ed.getPath(), n); } catch (Exception e) { System.out.println("Error processing structure ["+sd.getId()+"] path "+ed.getPath()+":"+inv.getKey()+" (\""+inv.getExpression()+"\"): "+e.getMessage()); } } } } } } }
long t = System.nanoTime(); try { n = fpe.parse(inv.getExpression()); } catch (FHIRLexerException e) { throw new FHIRException("Problem processing expression "+inv.getExpression() +" in profile " + profile.getUrl() + " path " + path + ": " + e.getMessage());
source.setContext("@search"); lexer.take(); ExpressionNode node = fpe.parse(lexer); source.setUserData(MAP_SEARCH_EXPRESSION, node); source.setElement(node.toString()); ExpressionNode node = fpe.parse(lexer); source.setUserData(MAP_WHERE_EXPRESSION, node); source.setCondition(node.toString()); ExpressionNode node = fpe.parse(lexer); source.setUserData(MAP_WHERE_CHECK, node); source.setCheck(node.toString()); ExpressionNode node = fpe.parse(lexer); source.setUserData(MAP_WHERE_CHECK, node); source.setLogMessage(node.toString());
expression = magicExpression; else expression = fpe.parse(s);
ExpressionNode node = fpe.parse(lexer); target.setUserData(MAP_EXPRESSION, node); target.addParameter().setValue(new StringType(node.toString())); parseParameter(target, lexer); lexer.token(","); ExpressionNode node = fpe.parse(lexer); target.setUserData(MAP_EXPRESSION, node); target.addParameter().setValue(new StringType(node.toString()));