Stream: fhirpath
Topic: operand errors
Michael Lawley (May 31 2018 at 01:23):
I am getting an error message like:
Problem processing expression (derivation = 'constraint') or (kind = 'logical') or (url = 'http://hl7.org/fhir/StructureDefinition/'+id) in profile http://hl7.org/fhir/StructureDefinition/StructureDefinition path StructureDefinition: Error performing +: right operand has no value
from the validation engine because there's no value for id
. But this is coming as an exception rather than a validation error. Is it valid to treat any PathEngineException
as a validation error, or should the constraint check that id
has a value before using it?
Bryn Rhodes (May 31 2018 at 01:35):
In general, an operator in FHIRPath will return empty ({ }
) if any of its arguments are empty, so I would think the concatenate there ought to return an empty, rather than throw an exception like that.
Michael Lawley (May 31 2018 at 01:43):
That's certainly not the behaviour of FHIRPathEngine.java
private List<Base> opPlus(List<Base> left, List<Base> right) throws PathEngineException { if (left.size() == 0) throw new PathEngineException("Error performing +: left operand has no value"); if (left.size() > 1) throw new PathEngineException("Error performing +: left operand has more than one value"); // ...
Grahame Grieve (May 31 2018 at 08:10):
I believe that this is the correct implementation of + as defined in the fhirpath specificatino
Grahame Grieve (May 31 2018 at 08:10):
I believe we argued about this
Michael Lawley (May 31 2018 at 08:20):
In that case the constraint needs re-writing as:
(derivation = 'constraint') or (kind = 'logical') or (exists(id) and url = 'http://hl7.org/fhir/StructureDefinition/'+id)
?
Michael Lawley (May 31 2018 at 08:23):
But 4.4.1 of fhirpath says
For functions or operators that take a single values as input, this means in general if the input is empty, then the result will be empty as well.
Grahame Grieve (May 31 2018 at 08:24):
- has a different definition, I think
Michael Lawley (May 31 2018 at 08:25):
6.6.7. & (string concatenation)
For strings, will concatenate the strings, where an empty operand is taken to be the empty string. This differs from + on two strings, which will result in an empty collection when one of the operands is empty.
http://hl7.org/fhirpath/#math
Grahame Grieve (May 31 2018 at 08:29):
guess I should change that to & not + then
Michael Lawley (May 31 2018 at 08:32):
which will create a different bug, no? It would result in url
being compared with "http://hl7.org/fhir/StructureDefinition/"
when there's no id
Michael Lawley (May 31 2018 at 22:31):
My take on the code above is that the second test is correct - more than one value is an error, but that the first case should result in the empty list.
Last updated: Apr 12 2022 at 19:14 UTC