Stream: questionnaire
Topic: Problem with prohibiting variable overlap
Lloyd McKenzie (Nov 07 2021 at 21:17):
Based on one of the tracker items, we've now added the following language to the Using Expressions page:
Collisions between names that are defined more than once within the same scope will be treated as an error. I.e. If there is a launchContext extension called 'patient' and then on the same item or any item nested beneath it there's also a variable extension also named 'patient', that would be an error.
However, when we were talking about modular questionnaires and using the linkIdPrefix mechanism in this document, we explicitly contemplated having a variable on a child with the same name as that on the parent (look at how 'E' and 'F' result in a linkIdPrefix of 'foobar'.
For now, my plan is to carve out a narrow exception that says that variables can be overridden on child elements, but can't have conflicting declarations on siblings. Shout if anyone thinks that's unreasonable.
Brian Postlethwaite (Nov 07 2021 at 22:12):
I don't think I'd support that in my implementation. Sibblings isn't the problem, as they aren't in each other's scope. parent child is the problem.
Lloyd McKenzie (Nov 09 2021 at 01:11):
Siblings on the same element would be a problem. How can the prefix approach work if we *don't * allow this?
Brian Postlethwaite (Nov 09 2021 at 01:58):
Siblings don't see each other. There for not a problem.
Paul Lynch (Nov 09 2021 at 14:40):
I don't see the need for the restriction at all. LHC-Forms allows child nodes to declare variables that override the definition in the parent node.
Lloyd McKenzie (Nov 09 2021 at 17:44):
If you have two variables with the same name on the same item, they'll see each other. That's what we need to prevent. I don't see a way to support link prefix unless descendants override.
Brian Postlethwaite (Nov 09 2021 at 20:49):
Maybe thin is a topic for our call next week (since none this week)
Paul Lynch (Nov 10 2021 at 01:16):
I am fine with disallowing the same item to declare two variables with the same name. I think descendants should just override the ancestor definitions where there is matching variable name-- not that I need that behavior, but I don't see the need for a restriction on that, and it is a little more work to restrict it.
Last updated: Apr 12 2022 at 19:14 UTC