Stream: questionnaire
Topic: Conditional / parametrized text
Jose Costa Teixeira (Sep 12 2021 at 19:16):
Is there a best way to show a text depending on variables, or make it parametrized?
I have a questionnaire that calculates a risk score. Now I want the questionnaire to display at the end:
- If score < X, display text " risk is low, probability of 1% of..."
- If X < score < Y, display text "risk is moderate, probability of 17% of..."
- If score > Y, display text "risk is high, probability of 25% of..."
Jose Costa Teixeira (Sep 12 2021 at 19:17):
I'm using different enableWhenExpressions to show the text. Is there a more compact way?
Tilo Christ (Sep 12 2021 at 19:20):
I think what you are doing is the "official" way. Danish sundhet.dk has defined a local extension (http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-questionnaire-feedback), but that doesn't make it much more compact either, I think enableWhenExpression simply didn't exist yet, when they defined it.
Jose Costa Teixeira (Dec 16 2021 at 08:15):
back to this, I'm not happy with what I have so far:
Jose Costa Teixeira (Dec 16 2021 at 08:23):
I have a questionnaire for risk score calculation.
Depending on the answers, I will get a score, and an interpretation of that score. e.g. if score = 8, interpretation is "risk of 10-year diabetes is estimated at 1 in 25"
Tilo Christ (Dec 16 2021 at 10:39):
So where is the unhappiness coming from? Isn't what you got now the thing that you asked for?
Jose Costa Teixeira (Dec 16 2021 at 13:58):
(sorry, I was distracted).
Jose Costa Teixeira (Dec 16 2021 at 13:59):
The issue I have is where to put the interpretation. If I have 5 possible interpretations, i have 5 questionnaire items (and I only show one of them)
Jose Costa Teixeira (Dec 16 2021 at 14:01):
In terms of mapping, I have 5 items to map to 1, but I don't know which of these items. I cannot concatenate as I wanted, and I do not want to reproduce the calculation logic in the extraction...
Brian Postlethwaite (Dec 17 2021 at 02:16):
Here's an example of that type of scoring...
https://sqlonfhir-r4.azurewebsites.net/fhir/Questionnaire/abbey-pain-scale/_history/5?_format=html
Brian Postlethwaite (Dec 17 2021 at 02:17):
First 5 radios get scores based on ordinal and then another field with the rating based on that score.
Works with our renderer, must try it with the lhc forms.
Jose Costa Teixeira (Dec 18 2021 at 22:06):
@Brian Postlethwaite does this contain a single answer item where the text depends on the calculated score?
Brian Postlethwaite (Dec 18 2021 at 22:10):
If you mean you wanted to display a different text label (display item) you could have each of the options in there and enable them to display the appropriate one based on the score answer.
Jose Costa Teixeira (Dec 19 2021 at 20:25):
Right, that is what I have but that is what I am not what I'm happy with
Jose Costa Teixeira (Dec 19 2021 at 20:25):
(if I understand what you mean)
Jose Costa Teixeira (Dec 19 2021 at 20:25):
oh wait, perhaps you mean having a rather long fhirpath expression that contains the different text values?
Jose Costa Teixeira (Dec 19 2021 at 20:29):
if I have different questions each with one possible text and then do the enableWhen, it gets messy:
image.png
Jose Costa Teixeira (Dec 19 2021 at 20:30):
(i cannot do concatenate because all of the questions will have text. And to select only the right one, I'd have to replicate the logic in my mapping, while the logic is already in the questionnaire)
Brian Postlethwaite (Dec 19 2021 at 20:35):
I'm lost.
If you only want 1 value for the interpretation, just have the 1 read only choice question, with the expression to process the score into the interpretation result, and that feeds nicely into your observation.
Brian Postlethwaite (Dec 19 2021 at 20:36):
(that's precisely what my example abbey pain scale score does)
Jose Costa Teixeira (Dec 19 2021 at 20:51):
at this moment I have 5 items with enablewhen, each for a given range of the score. From what I'm reading, that's not what you are saying, right?
Brian Postlethwaite (Dec 19 2021 at 20:54):
Yup. Just 1 coded interpretation, and that's even more relevant given your diagram going to one obs as the interpretation field.
Jose Costa Teixeira (Dec 19 2021 at 22:39):
But then the interpretation has to have all those if
s, right? 'if score < X, "this is one text" else if score < y, "this is another risk"...'
Jose Costa Teixeira (Dec 19 2021 at 22:39):
(if so, I'll figure out the syntax later)
Brian Postlethwaite (Dec 20 2021 at 00:59):
Syntax is in my example.
Brian Postlethwaite (Dec 20 2021 at 00:59):
Amn since you want it coded in the observation anyway.
Jose Costa Teixeira (Dec 20 2021 at 12:44):
i don't see it. I see syntax for calculating the score as a string...
what I need is an item that has the text - not "the pain is 5" nor "the pain is excruciating/mild/...", but
"the pain is not bearable and the patient has to be on meds" vs "the patient does not need any further medication"
Jose Costa Teixeira (Dec 20 2021 at 12:44):
I _could_ make a valueset for that...
Lloyd McKenzie (Dec 20 2021 at 15:19):
You can use expressions to set the text of the item or the answers, so presumably that should cover your use-case?
Brian Postlethwaite (Dec 20 2021 at 22:00):
I do think should be stored as an answer in the QR if you're planning to copy into observation.
And if you just want the string, use a text item, and output the entire description rather than code.
Jose Costa Teixeira (Dec 21 2021 at 07:10):
Right. The struggle is: How do I define the possible text values outside of the FHIRpath expression, and in the FHIRpath expression I would just use them?
In other words, how can I avoid having a FHIRpath expression that contains things like iif((result<X,"the pain is not bearable and the patient has to be on meds",iif(result<Y,"the patient does not need any further medication"...)
Brian Postlethwaite (Dec 21 2021 at 13:08):
You could put the descriptions into variables...
Brian Postlethwaite (Dec 21 2021 at 13:10):
Possible places; variable, coded options, inline in the fhirpath expression. Or other display labels (though that doesn't help extraction - it's not in the saved data)
Lloyd McKenzie (Dec 21 2021 at 14:32):
If it's outside the FHIRPath expression, where do you want it to be?
Tilo Christ (Dec 21 2021 at 16:27):
Would it maybe be an option to place them into display items and then use something along the lines of %questionnaire.item.where(linkId='pain-level-1').text
to access their text description?
David Winters (Dec 21 2021 at 19:14):
Right. The struggle is: How do I define the possible text values outside of the FHIRpath expression, and in the FHIRpath expression I would just use them?
In other words, how can I avoid having a FHIRpath expression that contains things like iif((result<X,"the pain is not bearable and the patient has to be on meds",iif(result<Y,"the patient does not need any further medication"...)
Could also define this in a CQL library.
Jose Costa Teixeira (Dec 22 2021 at 21:13):
The one I feel more comfortable with is a valueset. I think this means:
- Right after calculating the score, get a code (1-3 = "low", 4-5="med"...)
- Use FHIRPath to get the display for that code ("low" : "the pain is low and the patient just needs to get some distraction"
Jose Costa Teixeira (Dec 22 2021 at 21:13):
How would I do this?
Jose Costa Teixeira (Dec 22 2021 at 21:14):
I think @Brian Postlethwaite your code is about populating the answer with the expression. Can I use FHIRPath to get the display for a code?
Brian Postlethwaite (Dec 22 2021 at 22:44):
at which point? During the extraction into the obs?
just use the answer.coding.display
Brian Postlethwaite (Dec 22 2021 at 22:45):
For the answer that is the calculated risk choice field, just select the appropriate code (as in my demo above)
Grey Faulkenberry (Jan 15 2022 at 01:10):
@Brian Postlethwaite I was struggling a bit with this as well but it was for a MeasureReport. As in the example I mentioned during the Hackathon (https://mayjuun.com/fhirfli/7-sdc-workflow-example/), I have multiple Questionnaires and I use a single Measure -> MeasureReport to calculate all of the scores/subscores. This is at least partly because some of the scores involve questions from multiple questionnaires. Currently I'm representing the scores calculations as shown above, each with 3 pieces of information generated from the expression, a score, a code of low/medium/high (to represent risk), and then an annotation. For instance, I may have something like this unrealistic example:
0-5;low;No follow-up necessary
6-10;medium;Schedule a doctor appointment
11-15;high;Call 911 right now
Currently I have this built into the expression
.iif($this > 10, $this.toString() + ';high;Call 911 right now', iif($this < 6, $this.toString() + ';low;No follow-up necessary', $this.toString() + ';medium;Schedule a doctor appointment')
// Or maybe using .select as recommended to Tilo by Bryn
.select(iif($this > 10, $this.toString() + ';high;Call 911 right now', iif($this < 6, $this.toString() + ';low;No follow-up necessary', $this.toString() + ';medium;Schedule a doctor appointment'))
But then I have to use some idiosyncratic code to tell it how to parse out the result of the expression, and I'd like to be able to define the entire thing within FHIR. Any suggestions for this? (I'm also happy to clarify if my explanation wasn't clear).
Brian Postlethwaite (Jan 15 2022 at 01:46):
Got the current definitions on a server somewhere I can look at?
Last updated: Apr 12 2022 at 19:14 UTC