firely-net-sdk icon indicating copy to clipboard operation
firely-net-sdk copied to clipboard

FHIRPath: Improve error message for string functions invocations on different data types

Open alexzautke opened this issue 3 years ago • 4 comments

Invoking a string function on a different datatype (without trying to cast it) fails with a correct but unclear error message. Real life example: A profile on Observation defined an invariant on valueInteger with a constraint using the "matches" function. This fails with the following error message: Invocation of 'matches' failed: Cannot cast from 'Int32' to 'String'. For a regular user this seems like an internal error. It would be helpful if the FP engine could report that matches cannot be executed on an integer and that an explicit cast is needed.

alexzautke avatar Jan 10 '22 08:01 alexzautke

See also https://jira.hl7.org/browse/FHIR-37521

alexzautke avatar Jun 02 '22 11:06 alexzautke

It would be helpful yes, but it is really hard, since this is all handled automatically in the interpreter infra (that's why it sounds like an internal error). It would amount to quite a big rewrite of the engine. To be perfectly honest, I don't think I'll undertake this now.

ewoutkramer avatar Jun 02 '22 12:06 ewoutkramer

I am looking at rewriting the FP engine (in my spare time), it's good to focus on readable error messages while I do.

ewoutkramer avatar Jun 02 '22 12:06 ewoutkramer

My static fhirpath validator has good messages for things like this - I think

brianpos avatar Apr 04 '24 04:04 brianpos

We will not plan this, due to the complexity of the issue.

mmsmits avatar May 01 '24 13:05 mmsmits

If anyone wants to have more user friendly messages they can use the static validator project at https://github.com/brianpos/Hl7.Fhir.FhirPath.Validator Which validates a parsed Expression.

brianpos avatar May 01 '24 20:05 brianpos