-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression language: no specification on what to do on multiply valued attributes #3
Comments
There are probably a few solutions. One approach might be to limit expressions to only being able to use variables, where those variables already have their types declared. So instead of the first snippet above, you would have to have something like
Since $var1 and $var2 are declared, then the expression If we assume that the RM is available during artefact parsing & validation (it is in tools like the ADL WB and adl-designer) then statements like A less strict approach would be to still allow expressions like A more runtime oriented approach would be to fail expression evaluation if types could not be matched, but this isn't safe, and it doesn't seem useful to me. |
The XPath specs have a different approach:
Although the not allowing to compare and operate on multiply valued attributes approach has some benefits in preventing mistakes - I'd say there's quite a benefit to not reinventing the wheel on this! |
I'm not sure how those Xpath rules would apply to multiple-valued attributes in the openEHR reference model. Do you have an example of an RM attribute in mind? It might make the clearer (at least for me!) |
Of course. It's not just an RM attribute, it's everything below specific attributes that can have more than one value. For example, part of the blood pressure archetype from the clinical knowledge manager
Say we write:
Of course, you should write Say we add two blood pressure measurements to the history, 120/80 and 150/121. That would mean when evaluating rules:
There are lots of ways to do this. Whatever we choose is fine, but we should choose something and I think following existing standards would be fine here. |
Following the spec, the expression (the last
entails a comparison of two Reals which is fine. If we write:
I think the meaning is clear - each time around the loop, a Real comparison is being tested. Is the Xquery interpretation of the above a comparison of Real vectors? |
If the observation has two events, the aql queries from the paths to the magnitudes would each have two real results, not one. Unless you define a way where you have to loop over every event and apply the rules in a loop. Then the rules simply have to be evaluated twice in my example. That's also possible, but then this would have to be clearly defined in the spec. This could also make rule evaluation more complicated to implement. Also when you have an archetype containing two observations with a rule: ''' What should happen? Or: ''' It's not clear in the specs what to do. The xpath variant, where paths can evaluate to node sets is one way to do it. |
You are right - my mistake, I was forgetting that id7 is the code of any EVENT in that archetype, so they are all matched. So it probably makes sense to state:
I think that's compatible with the Xquery rules. |
For the relative operators: That's a bit different than the Xpath/XQuery approach, where it's true if and only if you can find a pair of values, one from each set, where the operator evaluate to true. Regardless of size. But i think it could be a good way to define it for the relative operators (<, >, !=, ==, >= and <=) For the arithmetic operators in xpath, the types are first converted to numbers, conversion being defined for quite a lot of types including node sets, then the operator is applied. They seem to have changed their mind halfway, because in xpath version 1, only the first element of a node set is used. In xpath 2, applying an arithmetic operator to a sequence of length > 1 results in an error. Then you can run xpath 2 in xpath 1 compatibility mode to revert this behaviour to the old way... Because I implemented the prototype version in Archie before reading the xpath-specs and I had to choose something, I currently do:
evaluated as I have no idea what the best approach is. The 'what should we do with empty value lists/node sets/whatever we call them' is also a discussion i guess. For some things, what i do is a good match. For some score calculations with ordinals, we would need to find a way to express 'use the value of this ordinal, or if it does not exist, use value X'. Where X sometimes is 0, sometimes 1 or sometimes something else. Or we could define functions that do such a thing, or a function to sum a number of nodes, or some other way. |
Take the following snippet:
When /path/to/value and /path/to/another/value both have a single value in the object, that's quite easy. But often these can result in multiply valued results. So what to do in the following cases:
One solution would be to use the xpath-defined evaluation rules in https://www.w3.org/TR/xpath/ or https://www.w3.org/TR/xpath20/ or https://www.w3.org/TR/xpath-30/ . note that xpath 2 and 3 have not reached widespread adoption. See also issue #4
The text was updated successfully, but these errors were encountered: