use of au.csiro.pathling.fhirpath.ResourcePath in project pathling by aehrc.
the class PathTraversalOperator method getValueField.
@Nonnull
private static Column getValueField(@Nonnull final NonLiteralPath path, @Nonnull final String fieldName) {
// If the input path is a ResourcePath, we look for a bare column. Otherwise, we will need to
// extract it from a struct.
final Column field;
if (path instanceof ResourcePath) {
final ResourcePath resourcePath = (ResourcePath) path;
// When the value column of the ResourcePath is null, the path traversal results in null. This
// can happen when attempting to do a path traversal on the result of a function like when.
field = when(resourcePath.getValueColumn().isNull(), lit(null)).otherwise(resourcePath.getElementColumn(fieldName));
} else {
field = path.getValueColumn().getField(fieldName);
}
return field;
}
Aggregations