Closed johngrimes closed 8 months ago
Hi @johngrimes This PR is related to the discussion: https://chat.fhir.org/#narrow/stream/179219-analytics-on-FHIR/topic/Constraints.20on.20.60ViewDefinition.2Ewhere.2Epath.60.20expression
I think we should add clarification to the related paragraphs in the spec. Possible change to the spec that describes the change from this PR:
A series of zero or more FHIRPath constraints to filter resources for the view. Every constraint must evaluate to true for the resource to be included in the view.
A FHIRPath expression that defines a filter that must evaluate to true for a resource to be included in the output. The input context is the collection of resources of the type specified in the resource element. Constants defined in Reference({constant}) can be referenced as %[name]. The result of the expression must of type Boolean.
A FHIRPath expression that defines a filter that must evaluate to true for a resource to be included in the output. The input context is the collection of resources of the type specified in the resource element. Constants defined in Reference({constant}) can be referenced as %[name]. The expression must evaluate to a single item of type Boolean or be empty. Implementations SHALL report an error for any other types of results.
The current behavior (before the PR) is described by this definition.
A FHIRPath expression that defines a filter that must evaluate to true for a resource to be included in the output. The input context is the collection of resources of the type specified in the resource element. Constants defined in Reference({constant}) can be referenced as %[name]. The expression must evaluate to a single item of type Boolean. Implementations SHALL report an error for any other types of results.
What do you think? I also prepared tests for corner cases like multiple values in the result, but didn't commit them before we agreed on the behavior. I also think it's a good idea to move all cases related to the "where" expression into a separate test.
Hi @mput, thanks for taking a look at this!
Yes, we may as well roll in the spec change to this PR.
My feeling is that we don't need to be quite a strict as you suggested, as we have already said that only a result of true
will be included.
How about this:
A FHIRPath expression that defines a filter that must evaluate to true for a resource to be included in the output. The input context is the collection of resources of the type specified in the resource element. Constants defined in Reference({constant}) can be referenced as %[name].
The result of the expression must of type Boolean.
It looks like the change to the test expectation was already made on the master branch? 🤷
Fixes #218 and #198.