cqframework / clinical_quality_language

Clinical Quality Language (CQL) is an HL7 specification for the expression of clinical knowledge that can be used within both the Clinical Decision Support (CDS) and Clinical Quality Measurement (CQM) domains. This repository contains complementary tooling in support of that specification.
https://confluence.hl7.org/display/CDS/Clinical+Quality+Language
Apache License 2.0
251 stars 121 forks source link

R4FhirTerminologyProvider.in Exception when "result" parameter is not first #1350

Open justin-A6 opened 3 months ago

justin-A6 commented 3 months ago

Seeing an exception at R4FhirTerminologyProvider.in when the terminology server returns another parameter other than "result" first. I was not sure if there was a required order or not honestly when it came to the parameters returned by the $validate-code operation so this issue might not be with the engine-fhir subproject.

This occurred when running cms190 though I can try to mock up something simpler if needed.

Example request to a terminology server where this is happening:

curl --location 'https://tx.fhir.org/r4/ValueSet/2.16.840.1.113883.3.464.1003.106.12.1001/$validate-code?code=G43.B0&system=http%3A%2F%2Fhl7.org%2Ffhir%2Fsid%2Ficd-10-cm' \
--header 'Accept: application/json'

The result from above request:

{
    "resourceType": "Parameters",
    "parameter": [
        {
            "name": "version",
            "valueString": "2024"
        },
        {
            "name": "result",
            "valueBoolean": false
        },
        {
            "name": "system",
            "valueUri": "http://hl7.org/fhir/sid/icd-10-cm"
        },
        {
            "name": "code",
            "valueCode": "G43.B0"
        },
        {
            "name": "display",
            "valueString": "Ophthalmoplegic migraine, not intractable"
        }
...

The exception:

Caused by: java.lang.ClassCastException: class org.hl7.fhir.r4.model.StringType cannot be cast to class org.hl7.fhir.r4.model.BooleanType (org.hl7.fhir.r4.model.StringType and org.hl7.fhir.r4.model.BooleanType are in unnamed module of loader 'app')
    at org.opencds.cqf.cql.engine.fhir.terminology.R4FhirTerminologyProvider.in(R4FhirTerminologyProvider.java:70) ~[engine-fhir-3.9.0.jar:3.9.0]
    at org.opencds.cqf.cql.engine.elm.executing.InValueSetEvaluator.inValueSet(InValueSetEvaluator.java:48) ~[engine-3.9.0.jar:3.9.0]
    at org.opencds.cqf.cql.engine.execution.EvaluationVisitor.visitInValueSet(EvaluationVisitor.java:123) ~[engine-3.9.0.jar:3.9.0]
    at org.opencds.cqf.cql.engine.execution.EvaluationVisitor.visitInValueSet(EvaluationVisitor.java:14) ~[engine-3.9.0.jar:3.9.0]
    at org.cqframework.cql.elm.visiting.BaseElmClinicalVisitor.visitOperatorExpression(BaseElmClinicalVisitor.java:64) ~[elm-3.9.0.jar:3.9.0]
    at org.cqframework.cql.elm.visiting.BaseElmVisitor.visitExpression(BaseElmVisitor.java:267) ~[elm-3.9.0.jar:3.9.0]
    at org.cqframework.cql.elm.visiting.BaseElmClinicalVisitor.visitExpression(BaseElmClinicalVisitor.java:49) ~[elm-3.9.0.jar:3.9.0]
    at org.opencds.cqf.cql.engine.execution.EvaluationVisitor.visitOr(EvaluationVisitor.java:1189) ~[engine-3.9.0.jar:3.9.0]
    at org.opencds.cqf.cql.engine.execution.EvaluationVisitor.visitOr(EvaluationVisitor.java:14) ~[engine-3.9.0.jar:3.9.0]
...