Stream: questionnaire
Topic: Smart question
Grahame Grieve (May 28 2019 at 06:31):
Has anyone put a question with answers like this in a questionnaire: ? https://www.painbc.ca/sites/default/files/inline-images/Pain%20Rating%20Scale.png
James Agnew (May 28 2019 at 09:47):
This app has a bunch of questions of that type and captures all its PROMs in QRs: https://play.google.com/store/apps/details?id=org.ehealthinnovation.icancope
Grahame Grieve (May 28 2019 at 12:23):
What do the questions look like in the questionnaire?
James Agnew (May 28 2019 at 12:35):
The numeric scales are captured using valuesets that have the codes "1" through "9".
It occurs to me you're probably asking about capturing that actual image in the questionnaire.. They aren't doing that, the display logic is all in the app.
Lloyd McKenzie (May 28 2019 at 12:53):
You can use the xhtml extension to specify an image to render. I don't have an example though.
Paul Lynch (Jun 21 2019 at 19:25):
So the image data would not be in the Questionnaire itself, but only linked to from an img tag in the rendering-xhtml content?
Paul Lynch (Jun 21 2019 at 19:41):
Actually, the img href could be of type data: for an embedded image (answering my own question).
Lloyd McKenzie (Jun 21 2019 at 21:34):
It could be in a contained Binary
Paul Lynch (Jun 21 2019 at 21:47):
@Lloyd McKenzie Do you mean the rendering-xhtml extension content could somehow refer to a Binary resource in Questionnaire.contained?
Eric Haas (Jun 21 2019 at 23:01):
I believe you would directly inline the image in the extension
Lloyd McKenzie (Jun 22 2019 at 02:17):
Right. So if you binary had an id of 'someimage', your HTML could have <img href="#someimage"/>
Paul Lynch (Jun 25 2019 at 15:18):
@Lloyd McKenzie I think you might mean "src" instead of href. But, the bigger question is, how would a web-browser rendering this XHTML know what to do with #someimage? By putting the image in Questionnaire.contained as a Binary, it is no longer a part of the XHTML. I suppose one could specify (which I suspect we haven't) that things like href=#someimage are markers for IDs of contained Binaries, but it seems much more straightforward to just put the image data into the href.
Lloyd McKenzie (Jun 25 2019 at 15:22):
I don't know how it would work in practice. We've just said that you could do this. @Grahame Grieve @Brian Postlethwaite ?
Grahame Grieve (Jun 25 2019 at 20:54):
example: http://www.hl7.org/fhir/list-example-familyhistory-genetics-profile-annie.json.html
Brian Postlethwaite (Jun 25 2019 at 21:44):
Do you mean the online xhtml image data, or binary contained as in Grahame example?
Paul Lynch (Jun 26 2019 at 14:18):
That example suggests that anytime there is XHTML, before it goes to the browser it should be parsed and searched for img tags with a src attribute of #something, and for each of those, if there is a contained Binary with an id of "something", replace the img tag src attribute value with a "data:" URL for the Binary's data. Is that written down somewhere? I would never have guessed that.
Lloyd McKenzie (Jun 26 2019 at 14:31):
Probably a good thing to note in the section on narrative and in the extension. Care to submit a change request? :)
Lloyd McKenzie (Jun 26 2019 at 14:31):
(Advantage of the reference to a contained Binary is that if you have multiple references to the image, you only need to include it in the instance once.
Paul Lynch (Jun 26 2019 at 14:58):
David Waters (Jul 10 2019 at 14:31):
@Grahame Grieve @Lloyd McKenzie @Paul Lynch - We have some of these image based questions in our app, and have used the following pattern to implement
{
"linkId": "41", "text": "Which colour do you prefer: red, blue, green or yellow?", "type": "string", "required": true, "initialAttachment": { "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeIAAAG9CAIAAABGU+LWAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAZcSURBVHhe7dihFQJBEAXBPTxEgIGHIRUkUV4CZIW7AMBsEH1QZeZH0GKWsW4D/sPncZwL9uMwLwBJMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpMg2QJtMAaTINkCbTAGkyDZAm0wBpM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RAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNECaTAOkyTRAmkwDpMk0QJpMA6TJNEDYGF8mbwqxIIQ3SwAAAABJRU5ErkJggg==" } }
The user clicks on the image, and the coordinate string is passed back ("answer":[{"valueString":"ImageCoordinatePosition:68,94"}]) for the Questionnaire system to map to the image
In this model, we are struggling with how the Questionnaire owner sends alt text for the image, for usability guidelines - any suggestions on how alt text for an image should be carried in a Questionnaire.item?
Paul Lynch (Jul 10 2019 at 15:23):
I think you can only use initialAttachment if the item type is "attachment".
If you use rendering-xthml, then the img tag for your image can include "alt".
Brian Postlethwaite (Jul 11 2019 at 00:41):
During the pre-population of this form, what order do you do things?
1. pre-pop launch parameter retrieval (or provided as parameters)
2. pre-pop query parameter replacement (potentially using above launch variables)
3. execution of the pre-pop query (retrieving data from the server)
(from here is where I struggle on the order of the next items as they could be interrelated)
4. evaluate all top level variable definitions (your BMI example has no values at this stage in those fields)
5. walk the items tree
a) evaluate any variable definitions
b) performing the fhirpath pre-population based on the sdc-initialExpression extension
c) evaluate any calculatedExpressions
The issues here are that there can be calculatedExpressions, variables and item answers that can all reference each other.
@Paul Lynch do you have a specific way of handling this?
Paul Lynch (Jul 15 2019 at 15:13):
I replied to Brian's question to me privately, but in case anyone else was interested in my answer, it was:
1) Loading of any known, needed resources happens first (launchContent and observationLinkPeriod), and I wait for them to finish Sometimes that takes several seconds if I am talking to a remote FHIR server. I don't handle FHIRPath in FHIR queries yet.
2) I don't distinguish between top-level variables and item-level variables. The "top-level" is just another node in the tree.
3) I process variables and field expressions (initial & calculated) in a loop, where both are processed at least once, starting with variables. initialExpressions are only done the first pass through the loop. Thereafter, the loop continues with variables being evaluated if field values have changed (due to expressions) and with field expressions being run if variables have changed. When nothing has changed the loop exits. Per the spec, it should also exit after a certain number of iterations, but I haven't updated the logic yet.
4) Variables only affect their item and sub-items, so if a variable changes I set a flag on the item so that I know whether to bother re-running the field expressions that might depend on them.
If you want to look at the code, the part of LHC-Forms that does this is the "ExpressionProcessor", and the loop that starts things off is in lines 35-45.
David Hay (Jul 15 2019 at 18:20):
sounds like the way that angularjs (v1) works..
Paul Lynch (Jul 15 2019 at 22:01):
I am familiar with AngularJS, because that is what LHC-Forms is written in. It is somewhat similar. A difference is that we don't re-run the expressions a second time to see if the results have changed. We compare the previous value to the new one.
Last updated: Apr 12 2022 at 19:14 UTC