diff --git a/fhir-path/src/main/java/com/ibm/fhir/path/function/FHIRPathStringAbstractFunction.java b/fhir-path/src/main/java/com/ibm/fhir/path/function/FHIRPathStringAbstractFunction.java index cd361b5458e..5386edc7bfe 100644 --- a/fhir-path/src/main/java/com/ibm/fhir/path/function/FHIRPathStringAbstractFunction.java +++ b/fhir-path/src/main/java/com/ibm/fhir/path/function/FHIRPathStringAbstractFunction.java @@ -10,6 +10,7 @@ import static com.ibm.fhir.path.util.FHIRPathUtil.getSingleton; import static com.ibm.fhir.path.util.FHIRPathUtil.hasStringValue; import static com.ibm.fhir.path.util.FHIRPathUtil.isSingleton; +import static com.ibm.fhir.path.util.FHIRPathUtil.isStringSubType; import java.util.Collection; import java.util.List; @@ -40,14 +41,8 @@ public Collection apply(EvaluationContext evaluationContext, Colle } else if (!hasStringValue(context)) { FHIRPathNode node = getSingleton(context); - FHIRPathType nodeChildType = - node.children() != null && !node.children().isEmpty() - && node.children().iterator().hasNext() && node.children().iterator().next().type() != null ? node.children().iterator().next().type() : FHIRPathType.FHIR_ANY; - - if (nodeChildType == FHIRPathType.FHIR_EXTENSION) { - if( logger.isLoggable(Level.FINE) ) { - logger.fine(String.format("collection item is of extension type %s", node.type().getName())); - } + if (isStringSubType(node)) { + logger.fine("collection item does not have a value, returning empty"); return empty(); } throw new IllegalArgumentException("Input collection item must be of type String, but found '"+node.type().getName()+ "'"); diff --git a/fhir-path/src/main/java/com/ibm/fhir/path/util/FHIRPathUtil.java b/fhir-path/src/main/java/com/ibm/fhir/path/util/FHIRPathUtil.java index e9d3f2ed74f..d3c4c9da587 100644 --- a/fhir-path/src/main/java/com/ibm/fhir/path/util/FHIRPathUtil.java +++ b/fhir-path/src/main/java/com/ibm/fhir/path/util/FHIRPathUtil.java @@ -1238,4 +1238,21 @@ public static com.ibm.fhir.model.type.String getDisplay(FHIRPathTree tree, FHIRP } return null; } + + /** + * returns true if the node is a String or if FHIR element can be automatically converted to System.String + * https://www.hl7.org/fhir/fhirpath.html#types + * @param node + * @return boolean + */ + public static boolean isStringSubType(FHIRPathNode node) { + return node.type() == FHIRPathType.FHIR_STRING + || node.type() == FHIRPathType.FHIR_URI + || node.type() == FHIRPathType.FHIR_CODE + || node.type() == FHIRPathType.FHIR_OID + || node.type() == FHIRPathType.FHIR_ID // included for consistency with spec + || node.type() == FHIRPathType.FHIR_UUID + || node.type() == FHIRPathType.FHIR_MARKDOWN + || node.type() == FHIRPathType.FHIR_BASE64BINARY; + } } \ No newline at end of file