Search in sources :

Example 66 with Base

use of org.hl7.fhir.dstu2.model.Base in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method funcDescendants.

private List<Base> funcDescendants(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
    List<Base> result = new ArrayList<Base>();
    List<Base> current = new ArrayList<Base>();
    current.addAll(focus);
    List<Base> added = new ArrayList<Base>();
    boolean more = true;
    while (more) {
        added.clear();
        for (Base item : current) {
            getChildrenByName(item, "*", added);
        }
        more = !added.isEmpty();
        result.addAll(added);
        current.clear();
        current.addAll(added);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Base(org.hl7.fhir.dstu2.model.Base)

Example 67 with Base

use of org.hl7.fhir.dstu2.model.Base in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method log.

private void log(String name, List<Base> contents) {
    if (hostServices == null || !hostServices.Log(name, contents)) {
        if (log.length() > 0)
            log.append("; ");
        log.append(name);
        log.append(": ");
        boolean first = true;
        for (Base b : contents) {
            if (first)
                first = false;
            else
                log.append(",");
            log.append(convertToString(b));
        }
    }
}
Also used : Base(org.hl7.fhir.dstu2.model.Base)

Example 68 with Base

use of org.hl7.fhir.dstu2.model.Base in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method opConcatenate.

private List<Base> opConcatenate(List<Base> left, List<Base> right) {
    List<Base> result = new ArrayList<Base>();
    result.add(new StringType(convertToString(left) + convertToString((right))));
    return result;
}
Also used : StringType(org.hl7.fhir.dstu2.model.StringType) ArrayList(java.util.ArrayList) Base(org.hl7.fhir.dstu2.model.Base)

Example 69 with Base

use of org.hl7.fhir.dstu2.model.Base 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>();
    // R2 - can't use ElementUtil
    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)

Example 70 with Base

use of org.hl7.fhir.dstu2.model.Base in project org.hl7.fhir.core by hapifhir.

the class FHIRPathEngine method funcSubsetOf.

private List<Base> funcSubsetOf(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws PathEngineException {
    List<Base> target = execute(context, focus, exp.getParameters().get(0), true);
    boolean valid = true;
    for (Base item : focus) {
        boolean found = false;
        for (Base t : target) {
            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));
    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)324 FHIRException (org.hl7.fhir.exceptions.FHIRException)177 Base (org.hl7.fhir.r4b.model.Base)87 Base (org.hl7.fhir.r5.model.Base)87 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)76 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)70 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)66 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)64 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)55 NotImplementedException (org.apache.commons.lang3.NotImplementedException)47 Base (org.hl7.fhir.dstu2016may.model.Base)47 UcumException (org.fhir.ucum.UcumException)43 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)41 Base (org.hl7.fhir.dstu2.model.Base)40 BigDecimal (java.math.BigDecimal)39 IOException (java.io.IOException)37 ParserBase (org.hl7.fhir.dstu2016may.metamodel.ParserBase)34 FileOutputStream (java.io.FileOutputStream)29 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)28 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)28