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