FHIR Chat · Constraining answer date to be in the past · questionnaire

Stream: questionnaire

Topic: Constraining answer date to be in the past


view this post on Zulip Morten Ernebjerg (Aug 26 2020 at 08:09):

Hi :wave: Suppose we have a questionnaire and one question asks for a date. The date entered must not be in the future (i.e. later than the date on which the answer is collected), e.g. suppose the question is "When was your last visit?" Is there any way to capture this constraint in a Questionnaire? I see the max-value extension, but I am assuming that it only allows specifying a fixed latest allowed date.

view this post on Zulip Paul Lynch (Aug 26 2020 at 14:34):

It sounds like there is a need for a FHIRPath expression there.

view this post on Zulip Vladimir Smirnov (Aug 26 2020 at 15:02):

Ironically, we've come to this chat today to ask this very same question, only to find it had been asked in the morning! We've been considering using the questionnaire-constraint extension. It contains a FHIRPath expression, and the language has the function today(). But is it an appropriate use of the extension? Its use cases are not really documented, and it appears to be meant for expressing constraints on the resources underlying the Questionnaire, not the Questionnaire itself. It is not clear what resource or element should the FHIRPath expression be written against. The Observation? The QuestionnaireResponse? The QuestionnaireResponse.Item?

view this post on Zulip Lloyd McKenzie (Aug 26 2020 at 15:44):

http://build.fhir.org/extension-questionnaire-constraint.html would allow you to make such an assertion using FHIRPath

view this post on Zulip Vladimir Smirnov (Aug 26 2020 at 15:56):

Lloyd McKenzie said:

http://build.fhir.org/extension-questionnaire-constraint.html would allow you to make such an assertion using FHIRPath

What should the FHIRPath be written against? The root of QuestionnaireResponse?

view this post on Zulip Lloyd McKenzie (Aug 26 2020 at 17:09):

The context would be the element the extension appears on - which could be the root or could be an item with in the Questionnaire. It would be evaluated on the corresponding level of the QuestionnaireResponse

view this post on Zulip Brian Postlethwaite (Aug 26 2020 at 22:04):

We do this quite often exactly as above.

view this post on Zulip Brian Postlethwaite (Aug 26 2020 at 22:05):

It's also quite interesting in terms of later validation. It might pass now, but if updating later, what's the rule there...

view this post on Zulip Morten Ernebjerg (Aug 27 2020 at 09:02):

Good point about the validation, @Brian Postlethwaite, had not considered that . We were considering adding this information as a hint to the UI that it should not allow the user to enter a future date. But once the data is collected, the constraint is effectively defunct in the sense that we'd want (need) to ignore it if validating the QuestionnaireResponse at a later time. I suppose this is actually a generic validation issue for such "time-dependent" constraints everywhere. So maybe we can't have our cake and eat, too?

view this post on Zulip Brian Postlethwaite (Aug 27 2020 at 09:04):

For the server side, that today() validation might substitute the author or lastmod date... But just a thought.

view this post on Zulip Morten Ernebjerg (Aug 27 2020 at 12:27):

For our usecase that could probably work quite well. But I imagine it would be hard to capture/communicate that expected transformation. I suppose what we wanted to communicate to the UI is actually a notion of "context-sensitive validity" (what is valid at the point in time when the data is enteted) that is difficult to bring together with the usual FHIR validity.

So now I'm thinking the way to go might rather be to have an extension carrying a code to communicate "not in the future". The clients would have to pick that up , but the validator could ignore it. This would be along the lines of the itemControl extension that gives a code indicating how to render an item. Indeed, I suppose one could even use that ext directly by adding a code for "date picker only accepting dates in the past" :grinning:

view this post on Zulip Roeland Luykx (Oct 28 2021 at 08:42):

i have the same question and i'm think of the definition for the frontend in the questionnaire. the following proposition i defined

Instance: undefined
InstanceOf: Questionnaire
Usage: #example

sushi has a problem with the "cannot assign string value: %todaydate. Value does not match element type: date" but somehow it likes me that it could be the in the right direction.

someone an other proposition?

view this post on Zulip Lloyd McKenzie (Oct 28 2021 at 14:37):

If you're setting a date to an expression, you can't have valueDate, you need to have a valueExpression

view this post on Zulip Paul Lynch (Oct 28 2021 at 17:56):

I don't think maxValue takes an Expression. You could use cqf-expression on maxValue, but maxValue isn't one of the places the SDC IG mentions for using cqf-expression.


Last updated: Apr 12 2022 at 19:14 UTC