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 FHIRPathEngine method funcSupersetOf.
private List<Base> funcSupersetOf(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
List<Base> target = execute(context, focus, exp.getParameters().get(0), true);
boolean valid = true;
for (Base item : target) {
boolean found = false;
for (Base t : focus) {
if (Base.compareDeep(item, t, false)) {
found = true;
break;
}
}
if (!found) {
valid = false;
break;
}
}
List<Base> result = new ArrayList<Base>();
result.add(new BooleanType(valid).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 BooleanTypeNullTest method testToString.
@Test
@DisplayName("Test null value toString()")
void testToString() {
BooleanType nullBoolean = new BooleanType();
System.out.println("Value -> " + nullBoolean);
}
use of org.hl7.fhir.dstu2.model.BooleanType in project org.hl7.fhir.core by hapifhir.
the class BooleanTypeNullTest method equalsDeep.
@Test
@DisplayName("Test null value equalsDeep()")
void equalsDeep() {
BooleanType nullBoolean = new BooleanType();
BooleanType validBoolean = new BooleanType("false");
Assertions.assertFalse(nullBoolean.equalsDeep(validBoolean));
}
Aggregations