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

CQL Library fails to execute in questionnaires #3683

Open
sharon2719 opened this issue Jan 15, 2025 · 5 comments
Open

CQL Library fails to execute in questionnaires #3683

sharon2719 opened this issue Jan 15, 2025 · 5 comments
Labels

Comments

@sharon2719
Copy link
Contributor

Currently, fhirPath expressions do not pass validation when running questionnaires. The next option that should work is to create a Common CQL library that can handle the expressions and pass the m as strings to solve this error.

EFSITY: :: ERROR :: Questionnaire.item[1].extension[0].value.ofType(date).extension[0] - The Extension 'http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue' definition allows for the types [string] but found type Expression EFSITY: :: ERROR :: Questionnaire.item[1].extension[0].value.ofType(date).extension[0].value.ofType(Expression).language - This element is not allowed by the profile http://hl7.org/fhir/StructureDefinition/string|4.0.1 EFSITY: :: ERROR :: Questionnaire.item[1].extension[0].value.ofType(date).extension[0].value.ofType(Expression).expression - This element is not allowed by the profile http://hl7.org/fhir/StructureDefinition/string|4.0.1 EFSITY: :: ERROR :: Questionnaire.item[1].extension[1].value.ofType(date).extension[0] - The Extension 'http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue' definition allows for the types [string] but found type Expression EFSITY: :: ERROR :: Questionnaire.item[1].extension[1].value.ofType(date).extension[0].value.ofType(Expression).language - This element is not allowed by the profile http://hl7.org/fhir/StructureDefinition/string|4.0.1 EFSITY: :: ERROR :: Questionnaire.item[1].extension[1].value.ofType(date).extension[0].value.ofType(Expression).expression - This element is not allowed by the profile http://hl7.org/fhir/StructureDefinition/string|4.0.1

When the CQL library is created it passes validation however when this is loaded into the app this does not work.

Acceptance Criteria

  • CQL library should be able to work as expected
@sharon2719
Copy link
Contributor Author

sharon2719 commented Jan 15, 2025

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Jan 15, 2025

The Extension 'http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue' definition allows for the types [string] but found type Expression EFSITY: :: ERROR ::

This error suggests an issue with the processing of the FHIRPath expression and not specifically CQL. FHIRPath Expressions are generally handled by SDC Lib but we may need to dig deeper

CC @dubdabasoduba @Wambere @ndegwamartin

@pld
Copy link
Member

pld commented Jan 15, 2025

agree w/ @f-odhiambo , this looks like a problem in the expression

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Jan 16, 2025

So it seems like in the following examples below

      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/minValue",
          "_valueDate": {
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue",
                "valueExpression": {
                  "language": "text/fhirpath",
                  "expression": "today() - 60 days"
                }
              }
            ]
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/maxValue",
          "_valueDate": {
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue",
                "valueExpression": {
                  "language": "text/fhirpath",
                  "expression": "today()"
                }
              }
            ]
          }
        }
      ],

the expression needs an explicit value with a valid datatype for the desired expression i.e.

    "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/maxValue",
          "valueDate": "2025-01-16"
        }
      ]

which passes but we need a calculate the value and not hardcode it and then maybe pass it in the correct format which am not sure what that is for now ... still doing some RnD

@dubdabasoduba
Copy link
Member

dubdabasoduba commented Jan 16, 2025

@sharon2719 Correct me if I am wrong. The error you added above was what you got when you ran validation earlier, right? At this point, the questionnaire looked something like this.

Screenshot 2025-01-16 at 11 13 18

You then updated the questionnaire to add the CQL library and tried to use the functions defined in the CQL library, right? The questionnaire became something like this.

https://github.com/onaio/fhir-resources/blob/ed810a9623045aa3862b33d1f6b086a0da7f76f8/eusm/fhir_content/questionnaires/register_filters.json#L187-L197

So, the second version passes validation, but it doesn't work correctly on the app, at least not according to my testing.

If the assumption above is correct, then I would say we have 2 issues at hand.

  1. The reason we are getting the above error The Extension 'http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue' definition allows for the types [string] but found type Expression EFSITY: :: ERROR :: . This is because we are using the "http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue extension but then giving it an expression for the value. That extension expects the value to be a string.
  2. We move the expression to the CQL file and then give the "http://hl7.org/fhir/StructureDefinition/cqf-calculatedValue extension a value of string but then the execution doesn't work on the app. The issue with execution might be caused by 2 reasons that we need to investigate
    • The issue with CQL evaluation on the SDK.
    • We are doing the referencing the wrong way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants