FHIR Chat · EnableWhen Expressions · questionnaire

Stream: questionnaire

Topic: EnableWhen Expressions


view this post on Zulip Grahame Grieve (May 20 2020 at 08:42):

http://community.fhir.org/t/how-do-i-use-enablewhenexpression/1983

view this post on Zulip Lloyd McKenzie (May 20 2020 at 15:03):

@Joee Garcia Do we have one for this yet?

view this post on Zulip Joee Garcia (May 20 2020 at 18:12):

Hi @Lloyd McKenzie , I've just added the demo questionnaire I'm working on for advanced form behavior here: http://build.fhir.org/ig/HL7/sdc/behavior.html#example . It has an example on how to use enableWhenExpression.

view this post on Zulip Bas Harmsen (Jul 15 2020 at 09:26):

When looking at the example (I think the url is now: http://build.fhir.org/ig/HL7/sdc/examples.html#using-enablewhen-enablebehavior-and-enablewhenexpression) I noticed that it uses %resource.repeats(item).where(...). As I understand %resource is the same for all items in the Questionnaire and when items can repeat this may be a problem. I think I found a nice solution and posted it in the mentioned thread (this reply: http://community.fhir.org/t/how-do-i-use-enablewhenexpression/1983/8) Since there has not yet been a reply to this post, I would like to ask if there are people here who could look at it.

view this post on Zulip Paul Lynch (Jul 15 2020 at 15:40):

That example should be "repeat(item)" not "repeats(item)". It is using the repeat function in FHIRPath: http://hl7.org/fhirpath/#repeatprojection-expression-collection, not item.repeats.

view this post on Zulip Bas Harmsen (Jul 15 2020 at 16:47):

Reading my message again I see that it's a little bit confusing. I'm aware of the repeat function but I forgot that it's called repeat and not repeats. So the first repeats in my message refers to the FHIRpath repeat-function and the second one to the repeats-element in a Questionnaire.

The problem I see is that there is no context when using %resource.repeat(item).where(...) and the repeats element is set to true for some group-item. When a group can repeat and one of the items should only be enabled in the case that a given item in the same group meets some condition then the expression should be evaluated in a certain context. It seems to me that'%resource.repeat(item).where(...) refers 'globally' to all elements that meet the condition and not just to the item relative to the item for which enableWhenExpression is evaluated.
Edit: I’m aware that in the example in the implementation guide the item cannot repeat but I’d like to know if my solution for the case that it may repeat is correct.

view this post on Zulip Lloyd McKenzie (Jul 15 2020 at 22:20):

Yes, using variables is the appropriate solution when using enableWhen inside repeating groups.

view this post on Zulip Bas Harmsen (Jul 16 2020 at 08:56):

Thanks for your answer.

view this post on Zulip Brian Postlethwaite (Sep 15 2021 at 18:34):

The tracker #33295 - Having discussed and reviewed this with Paul, looks like the description is actually now different to invariants - which I don't think was intended.

view this post on Zulip Brian Postlethwaite (Sep 15 2021 at 18:35):

https://github.com/FirelyTeam/firely-net-common/blob/d652305916bcc7fdc32337e5cb71bf8a763c91c3/src/Hl7.FhirPath/FhirPath/CompiledExpression.cs#L28


Last updated: Apr 12 2022 at 19:14 UTC