use of org.hl7.fhir.dstu2.model.BooleanType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcContains.
private List<Base> funcContains(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
List<Base> result = new ArrayList<Base>();
String sw = convertToString(execute(context, baseToList(context.thisItem), exp.getParameters().get(0), true));
if (focus.size() != 1) {
result.add(new BooleanType(false).noExtensions());
} else if (Utilities.noString(sw)) {
result.add(new BooleanType(true).noExtensions());
} else {
String st = convertToString(focus.get(0));
if (Utilities.noString(st)) {
result.add(new BooleanType(false).noExtensions());
} else {
result.add(new BooleanType(st.contains(sw)).noExtensions());
}
}
return result;
}
use of org.hl7.fhir.dstu2.model.BooleanType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcExists.
private List<Base> funcExists(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
List<Base> result = new ArrayList<Base>();
boolean empty = true;
List<Base> pc = new ArrayList<Base>();
for (Base f : focus) {
if (exp.getParameters().size() == 1) {
pc.clear();
pc.add(f);
Equality v = asBool(execute(changeThis(context, f), pc, exp.getParameters().get(0), true), exp);
if (v == Equality.True) {
empty = false;
}
} else if (!f.isEmpty()) {
empty = false;
}
}
result.add(new BooleanType(!empty).noExtensions());
return result;
}
use of org.hl7.fhir.dstu2.model.BooleanType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcEndsWith.
private List<Base> funcEndsWith(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
List<Base> result = new ArrayList<Base>();
String sw = convertToString(execute(context, focus, exp.getParameters().get(0), true));
if (focus.size() == 0) {
result.add(new BooleanType(false).noExtensions());
} else if (Utilities.noString(sw)) {
result.add(new BooleanType(true).noExtensions());
} else {
if (focus.size() == 1 && !Utilities.noString(sw)) {
result.add(new BooleanType(convertToString(focus.get(0)).endsWith(sw)).noExtensions());
} else {
result.add(new BooleanType(false).noExtensions());
}
}
return result;
}
use of org.hl7.fhir.dstu2.model.BooleanType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method funcAllTrue.
private List<Base> funcAllTrue(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
List<Base> result = new ArrayList<Base>();
if (exp.getParameters().size() == 1) {
boolean all = true;
List<Base> pc = new ArrayList<Base>();
for (Base item : focus) {
pc.clear();
pc.add(item);
List<Base> res = execute(context, pc, exp.getParameters().get(0), true);
Equality v = asBool(res, exp);
if (v != Equality.True) {
all = false;
break;
}
}
result.add(new BooleanType(all).noExtensions());
} else {
boolean all = true;
for (Base item : focus) {
if (!canConvertToBoolean(item)) {
throw new FHIRException("Unable to convert '" + convertToString(item) + "' to a boolean");
}
Equality v = asBool(item, true);
if (v != Equality.True) {
all = false;
break;
}
}
result.add(new BooleanType(all).noExtensions());
}
return result;
}
use of org.hl7.fhir.dstu2.model.BooleanType in project org.hl7.fhir.core by hapifhir.
the class CodeSystemUtilities method setNotSelectable.
public static void setNotSelectable(CodeSystem cs, ConceptDefinitionComponent concept) throws FHIRFormatError {
defineNotSelectableProperty(cs);
ConceptPropertyComponent p = getProperty(concept, "notSelectable");
if (p != null)
p.setValue(new BooleanType(true));
else
concept.addProperty().setCode("notSelectable").setValue(new BooleanType(true));
}
Aggregations