FHIR Chat · ExpressionNode.toString() fails on constant = {} · fhirpath

Stream: fhirpath

Topic: ExpressionNode.toString() fails on constant = {}


view this post on Zulip Keith Boone (May 18 2021 at 04:53):

This case in ExpressionNode.toString() doesn't handle the case when node is the constant representing the empty list (which should print {})

    case Constant:
      if (constant instanceof StringType)
      b.append("'"+Utilities.escapeJson(constant.primitiveValue())+"'");
      else if (constant instanceof Quantity) {
        Quantity q = (Quantity) constant;
    b.append(Utilities.escapeJson(q.getValue().toPlainString()));
    b.append(" '");
    b.append(Utilities.escapeJson(q.getUnit()));
    b.append("'");
      } else if (constant.primitiveValue() != null)
        b.append(Utilities.escapeJson(constant.primitiveValue()));
      else 
    b.append(Utilities.escapeJson(constant.toString()));
        break;

The code should start with:
if (constant == null) {
b.append("{}");
} else ...

See https://github.com/hapifhir/org.hl7.fhir.core/issues/499


Last updated: Apr 12 2022 at 19:14 UTC