LHNCBC / formbuilder-lhcforms

Build LHC-Forms and FHIR Questionnaires
Other
26 stars 22 forks source link

Conditional color formatting #86

Open annabel-uzl opened 1 month ago

annabel-uzl commented 1 month ago

Is it possible to create a form with conditional formatting using the formbuilder? For example: an answer field becomes e.g. RED if a value is bigger than 100 and green otherwise. If so, how?

plynchnlm commented 3 weeks ago

A currently supported mechanism would be to have two questions with different styles, and you use enableWhen to pick which one to show.

An approach in FHIR one could use (but which I suspect is not supported anywhere), would be use the cqf-expression extension to set the value of the rendering-style extension. The current FHIR Structured Data Capture IG indicates that cqf-expression is recommended for support on the elements minOccurs, maxOccurs, required, repeats, readOnly , answerValueSet, text. If you think it is worth adding rendering-style to that list, please make the case for it on the questionnaire stream at chat.fhir.org. The formbuilder does not yet have support for cqf-expression, nor does LHC-Forms, but it is on our list.

annabel-uzl commented 3 weeks ago

Yes good idea! The cqf-expression I'll keep in mind. Thanks!

annabel-uzl commented 3 weeks ago

About the colors: I notice the color of the question changing while I actually want to change the color of the answer depending on the answer. Is that a possibility? image

plynchnlm commented 3 weeks ago

Oh, I misunderstood. I don't think that is possible. There are minValue and maxValue extensions you can use to prevent the user from entering values outside of a range. Do you want the user to be able to enter the value outside of a range, and get a warning? (I don't think a color change is sufficient in that case.) If so, I don't think there is a way to indicate that in FHIR, but there probably should be. If that is something you want, could you post a question on the "questionnaire" stream at chat.fhir.org? There might be some way to do that I am not aware of. (There isn't a way to do it in LForms, but once there is agreement on how that might work in FHIR Questionnaire, we can add support.)