cql-engine icon indicating copy to clipboard operation
cql-engine copied to clipboard

Attempting to perform inValueSet operation on value sets passed into a function throws an exception in the engine

Open frankadrian314159 opened this issue 3 years ago • 4 comments

Any of the following code snippets including value set parameters passed to functions: library Test version '1' using FHIR version '4.0.1' valueset "VS": '20785' context Unfiltered /* define testC: test3("VS") define function test3(vs System.ValueSet): [Procedure: vs] */ /* define testD: test4() define function test4(): [Procedure: "VS"] */ /* define testE: test5("VS") define function test5(vs System.ValueSet): Code{code: 'A', system: 'foo'} in vs */

throws an exception in the engine with the following stack trace:

org.opencds.cqf.cql.engine.exception.CqlException: java.lang.IllegalArgumentException: Unable to locate ValueSet 20785 at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:37) at org.opencds.cqf.cql.engine.elm.execution.FunctionRefEvaluator.internalEvaluate(FunctionRefEvaluator.java:33) at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18) at org.opencds.cqf.cql.engine.elm.execution.ExpressionDefEvaluator.internalEvaluate(ExpressionDefEvaluator.java:19) at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18) at org.opencds.cqf.cql.engine.execution.CqlEngine.evaluateExpressions(CqlEngine.java:186) at org.opencds.cqf.cql.engine.execution.CqlEngine.evaluate(CqlEngine.java:164) at org.opencds.cqf.cql.evaluator.CqlEvaluator.evaluate(CqlEvaluator.java:89) at org.opencds.cqf.cql.evaluator.CqlEvaluator.evaluate(CqlEvaluator.java:76) at org.opencds.cqf.cql.evaluator.cli.command.CqlCommand.call(CqlCommand.java:159) at org.opencds.cqf.cql.evaluator.cli.command.CqlCommand.call(CqlCommand.java:33) at picocli.CommandLine.executeUserObject(CommandLine.java:1953) at picocli.CommandLine.access$1300(CommandLine.java:145) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352) at picocli.CommandLine$RunLast.handle(CommandLine.java:2346) at picocli.CommandLine$RunLast.handle(CommandLine.java:2311) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) at picocli.CommandLine.execute(CommandLine.java:2078) at org.opencds.cqf.cql.evaluator.cli.Main.run(Main.java:19) at org.opencds.cqf.cql.evaluator.cli.Main.main(Main.java:12) Caused by: java.lang.IllegalArgumentException: Unable to locate ValueSet 20785 at org.opencds.cqf.cql.evaluator.engine.terminology.BundleTerminologyProvider.expand(BundleTerminologyProvider.java:87) at org.opencds.cqf.cql.evaluator.engine.terminology.PrivateCachingTerminologyProviderDecorator.expand(PrivateCachingTerminologyProviderDecorator.java:47) at org.opencds.cqf.cql.evaluator.engine.terminology.PrivateCachingTerminologyProviderDecorator.in(PrivateCachingTerminologyProviderDecorator.java:25) at org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider.anyCodeInValueSet(BundleRetrieveProvider.java:89) at org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider.filterByTerminology(BundleRetrieveProvider.java:151) at org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider.retrieve(BundleRetrieveProvider.java:56) at org.opencds.cqf.cql.evaluator.engine.retrieve.PriorityRetrieveProvider.retrieve(PriorityRetrieveProvider.java:28) at org.opencds.cqf.cql.engine.data.CompositeDataProvider.retrieve(CompositeDataProvider.java:96) at org.opencds.cqf.cql.engine.elm.execution.RetrieveEvaluator.internalEvaluate(RetrieveEvaluator.java:57) at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18) ... 19 more

Basically, it looks as though whenever an InValueSet evaluation is done against a value set which has been passed to a function as a parameter, the terminology provider cannot find the target value set.

frankadrian314159 avatar Aug 31 '22 19:08 frankadrian314159

Interesting use case.

I was able to successfully run the following in VSCode:

valueset "Marital Status": 'http://hl7.org/fhir/ValueSet/marital-status'

define "Call VSTestIn function":
    VSTestIn("Marital Status")

define function VSTestIn(vs System.ValueSet):
    Code { code: 'L', system: 'http://terminology.hl7.org/CodeSystem/v3-MaritalStatus' } in vs

Not sure how you're testing this, but is the ValueSet available in the terminology server/provider?

c-schuler avatar Aug 31 '22 19:08 c-schuler

Yes, the ValueSet is available - it's being returned as the result of a previous test, which I removed to shorten the test file. I am running the code in the jar of cql-evaluator which I built from scratch yesterday. I heard that you folks had released a new version of the engine this morning. Could that have fixed the issue? I am wondering if it's something as simple as a versioning issue now.

Frank Adrian

On Wed, Aug 31, 2022 at 12:43 PM c-schuler @.***> wrote:

Interesting use case.

I was able to successfully run the following in VSCode:

valueset "Marital Status": 'http://hl7.org/fhir/ValueSet/marital-status'

define "Call VSTestIn function": VSTestIn("Marital Status")

define function VSTestIn(vs System.ValueSet): Code { code: 'L', system: 'http://terminology.hl7.org/CodeSystem/v3-MaritalStatus' } in vs

Not sure how you're testing this, but is the ValueSet available in the terminology server/provider?

— Reply to this email directly, view it on GitHub https://github.com/DBCG/cql_engine/issues/609#issuecomment-1233349138, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJKAKO7J7BPJEL5ZYBO2ILV36YVBANCNFSM6AAAAAAQBVN5DM . You are receiving this because you authored the thread.Message ID: @.***>

frankadrian314159 avatar Aug 31 '22 20:08 frankadrian314159

Given that the exception is being thrown in the BundleTerminologyProvider, which is part of the evaluator, not the engine, I will shift my queries over to that component. You may close this issue.

frankadrian314159 avatar Sep 01 '22 19:09 frankadrian314159

In case you wanted to see it, I've attached the entire test file...

Frank Adrian

On Wed, Aug 31, 2022 at 1:35 PM Frank Adrian @.***> wrote:

Yes, the ValueSet is available - it's being returned as the result of a previous test, which I removed to shorten the test file. I am running the code in the jar of cql-evaluator which I built from scratch yesterday. I heard that you folks had released a new version of the engine this morning. Could that have fixed the issue? I am wondering if it's something as simple as a versioning issue now.

Frank Adrian

On Wed, Aug 31, 2022 at 12:43 PM c-schuler @.***> wrote:

Interesting use case.

I was able to successfully run the following in VSCode:

valueset "Marital Status": 'http://hl7.org/fhir/ValueSet/marital-status'

define "Call VSTestIn function": VSTestIn("Marital Status")

define function VSTestIn(vs System.ValueSet): Code { code: 'L', system: 'http://terminology.hl7.org/CodeSystem/v3-MaritalStatus' } in vs

Not sure how you're testing this, but is the ValueSet available in the terminology server/provider?

— Reply to this email directly, view it on GitHub https://github.com/DBCG/cql_engine/issues/609#issuecomment-1233349138, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJKAKO7J7BPJEL5ZYBO2ILV36YVBANCNFSM6AAAAAAQBVN5DM . You are receiving this because you authored the thread.Message ID: @.***>

frankadrian314159 avatar Oct 11 '22 07:10 frankadrian314159