Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate %context into variable expression evaluation #2609

Open
jingtang10 opened this issue Jul 9, 2024 · 0 comments
Open

Incorporate %context into variable expression evaluation #2609

jingtang10 opened this issue Jul 9, 2024 · 0 comments

Comments

@jingtang10
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
In trying to resolve #2590, I started a discussion on fhir chat https://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/parent.28.29.20or.20siblings.28.29.3F and was pointed to a solution where %context is used in variable expressions which are then used by enable when expressions to evaluate the enabled status of nested questions.

I authored a questionnaire that follows this approach:

{
  "resourceType": "Questionnaire",
  "item": [
    {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/variable",
          "valueExpression": {
            "name": "answer",
            "language": "text/fhirpath",
            "expression": "%context.descendants().where(linkId='1-2').answer.value.code = 'answer-a'"
          }
        }
      ],
      "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": "%answer"
              }
            }
          ]
        }
      ]
    }
  ]
}

However, in our variable expression calculation, we don't incorporate the questionnaire response item.... this means we cannot pass the questionnarie response item to the fhir path engine as the %context fhir path supplement.

Describe the solution you'd like
questionnaire response item needs to be added as a parameter in the evaluateVariable function.

Describe alternatives you've considered
There's no alternative really

Additional context
The issue #2590 is resolved using a different approach using just enable when elements instead of expressions. Please refer to the issue itself.

Would you like to work on the issue?
Sure but happen to guide someone else to do this too. @f-odhiambo @f-odhiambo @allan-on if you guys are interested lmk ☺️

@jingtang10 jingtang10 changed the title Incorporate @context into variable expression evaluation Incorporate %context into variable expression evaluation Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

No branches or pull requests

1 participant