Stream: questionnaire
Topic: initialExpression & repeats
Paul Lynch (Jan 21 2022 at 16:18):
If initialExpression is set on a question with repeats=true, and the user adds a new instance, does it make sense to run the initialExpression on the new instance? Presumably, that value was already in the first instance.
Brian Postlethwaite (Jan 21 2022 at 18:41):
I don't think so.
Brian Postlethwaite (Jan 21 2022 at 18:41):
As you say, if there were multiple values, they should already ha e been included.
Paul Lynch (Jan 21 2022 at 20:37):
Brian Postlethwaite said:
As you say, if there were multiple values, they should already ha e been included.
I was actually thinking of a case where a single value was returned, but then the user adds another repetition of the question.
Lloyd McKenzie (Jan 21 2022 at 23:06):
I would expect the population process to add repetitions for all candidate answers found. If the user adds another one, that wouldn't invalidate the previous population or create any need to re-run.
Brian Postlethwaite (Jan 21 2022 at 23:41):
If you had Candidate expressions to select extra content, and picked one of them I would expect it to do initial expressions on that (but nothing else)
I haven't looked into it in any real detail yet.
Paul Lynch (Apr 08 2022 at 23:52):
If repeats is false, and initialExpression returns more than one value, is that an error?
Brian Postlethwaite (Apr 09 2022 at 00:01):
My implementation(s) just take the first entry. My new one might include an information message, but I don't remember.
Paul Lynch (Apr 09 2022 at 00:02):
I think LHC-Forms does that too.
Lloyd McKenzie (Apr 09 2022 at 00:49):
I think it should be an error
Brian Postlethwaite (Apr 09 2022 at 04:25):
I don't think an error in fill time for an issue from design time there.
Maybe something I'll try a design time validation check.
Lloyd McKenzie (Apr 09 2022 at 15:13):
How do you safely choose 1 when there are many? Yes, it's a design-time issue, but there are other design-time issues that can manifest at runtime.
Brian Postlethwaite (Apr 10 2022 at 23:42):
Would it be safer to not pre-fill anything? And make the user key in everything?
The pre-pop routine may not have any ability to interact with the user (such as when done on a server side)
But there could be a warning indicating that this occurred. But then how to return that, include it in the QR as contained?
Lloyd McKenzie (Apr 11 2022 at 01:55):
You could treat an initialExpression that returns too many elements as a candidateExpression. That might be the most useful thing to do.
Brian Postlethwaite (Apr 11 2022 at 02:20):
That would require the renderer to know that the populate failed and to do an in memory conversion.
Lloyd McKenzie (Apr 11 2022 at 02:22):
Correct
Lloyd McKenzie (Apr 11 2022 at 02:23):
More specifically, to know that the list of candidates for the populate was more than the max for the item
Brian Postlethwaite (Apr 11 2022 at 02:36):
Maybe we need to define how the populate operation can return warnings.
Brian Postlethwaite (Apr 11 2022 at 02:37):
Via a parameters object with both the outcome and result?
Must check if that's what's already documented.
Lloyd McKenzie (Apr 11 2022 at 03:08):
Warnings wouldn't be helpful to the end user
Brian Postlethwaite (Apr 11 2022 at 04:07):
This one would...?
Lloyd McKenzie (Apr 11 2022 at 04:36):
How? The user just needs to fill out the form. "There's data, but it's too much, so I did nothing" isn't super useful...
Brian Postlethwaite (Apr 11 2022 at 05:07):
The message could be indicate that there were other responses for this question too (maybe even include a toString form of that) so that the user could then go checkout the clinical record to see which was more appropriate (and if the renderer knew what was going on, could convert it to the candidate expression like you suggested)
Brian Postlethwaite (Apr 11 2022 at 05:07):
(and the issue would be tagged to the specific question/answer so the context is clear)
Brian Postlethwaite (Apr 11 2022 at 05:08):
Not convinced this is the right thing to do here though.
Lloyd McKenzie (Apr 11 2022 at 05:37):
toString could be butt ugly, depending on the data type. My leaning is to just either provide a candidateExpression or indicate that there was an issue with population with the form overall (i.e. there may be data that could have been populated but wasn't due to logic issues with the form) and let the user fill it in normally.
Brian Postlethwaite (Apr 11 2022 at 06:19):
A generic message that was just indicating that there were multiple entries for this answer, and it picked the first one would be ok as a minimum I think?
CandidateExpression is a non starter for me as can't feedback that data from the $populate operation, unless we come-up with some way to do that.
Lloyd McKenzie (Apr 11 2022 at 15:05):
Knowing it picked the first one isn't great because "first" is random and you don't know if it got the right one or not. I don't think "pick at random" is ever appropriate for populate.
Last updated: Apr 12 2022 at 19:14 UTC