Open allan-on opened 1 week ago
thanks @allan-on can you share your questionnaire?
thanks @allan-on can you share your questionnaire?
Hi @jingtang10 This is the Questionnaire I used in the demo above:
{
"resourceType": "Questionnaire",
"item": [
{
"linkId": "1",
"type": "group",
"text": "Repeated Group",
"repeats": true,
"item": [
{
"linkId": "1-2",
"type": "choice",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "drop-down",
"display": "Drop down"
}
],
"text": "Drop down"
}
}
],
"text": "Sample dropdown question",
"answerOption": [
{
"valueCoding": {
"code": "answer-a",
"display": "A"
}
},
{
"valueCoding": {
"code": "answer-b",
"display": "B"
}
},
{
"valueCoding": {
"code": "answer-c",
"display": "C"
}
},
{
"valueCoding": {
"code": "answer-other",
"display": "Other"
}
}
],
"item": [
{
"linkId": "1-3-1",
"text": "Dropdown question helper text",
"type": "display",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "flyover",
"display": "Fly-over"
}
],
"text": "Flyover"
}
}
]
}
]
},
{
"linkId": "1-1",
"text": "Sample date question",
"type": "date",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/entryFormat",
"valueString": "yyyy-mm-dd"
},
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression",
"valueExpression": {
"language": "text/fhirpath",
"expression": "%resource.descendants().where(linkId='1-2').answer.value.code = 'answer-a'"
}
}
]
}
]
}
]
}
thanks @allan-on can you share your questionnaire?
Hi @jingtang10 This is the Questionnaire I used in the demo above:
{ "resourceType": "Questionnaire", "item": [ { "linkId": "1", "type": "group", "text": "Repeated Group", "repeats": true, "item": [ { "linkId": "1-1", "text": "Sample date question", "type": "date", "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/entryFormat", "valueString": "yyyy-mm-dd" } ] }, { "linkId": "1-2", "type": "choice", "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl", "valueCodeableConcept": { "coding": [ { "system": "http://hl7.org/fhir/questionnaire-item-control", "code": "drop-down", "display": "Drop down" } ], "text": "Drop down" } } ], "text": "Sample dropdown question", "answerOption": [ { "valueCoding": { "code": "answer-a", "display": "A" } }, { "valueCoding": { "code": "answer-b", "display": "B" } }, { "valueCoding": { "code": "answer-c", "display": "C" } }, { "valueCoding": { "code": "answer-other", "display": "Other" } } ], "item": [ { "linkId": "1-3-1", "text": "Dropdown question helper text", "type": "display", "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl", "valueCodeableConcept": { "coding": [ { "system": "http://hl7.org/fhir/questionnaire-item-control", "code": "flyover", "display": "Fly-over" } ], "text": "Flyover" } } ] } ] } ] } ] }
@allan-on Can you please check whether posted questionnaire has the enable-when expression?
Hi @santosh-pingle. I'm sorry about that. I've updated the sample I shared earlier.
Hey @allan-on i'm not sure i agree with the use of %resource
in the enable when expression I think you end up losing the context of your answer inside the repeated group.
I think the best way to handle this is actually use enable when element defined in the questionnaire base spec.
Take a look at the comemnts section of this element: https://build.fhir.org/questionnaire-definitions.html#Questionnaire.item.enableWhen.question it very clearly defines the order or traversal so I think the behaviour is more predictable.
Describe the bug The
enableWhen
expression condition cascades to other group items below or above the trigger group item.Component SDC library
To Reproduce Steps to reproduce the behaviour:
Expected behaviour For an enableWhen expression condition that affects a single field should not cascade to other fields.
Screenshots
https://github.com/google/android-fhir/assets/16164649/cef11fa5-2769-4207-b875-53e62e129fe8
Smartphone (please complete the following information):
Additional context In the video shared above, there are two fields, a choice option, and a date field. The date field only shows if the choice is option A. Selecting option A shows all date fields and selecting any other option hides it.
Would you like to work on the issue? Please state if this issue should be assigned to you or who you think could help to solve this issue.