cqframework / vscode-cql

VS Code Clinical Quality Language Extension
Apache License 2.0
8 stars 5 forks source link

Getting a Stack Error when running Execute CQL for QICore library #11

Closed JSRankins closed 10 months ago

JSRankins commented 2 years ago

I created a primary library HFACEIorARBorARNIforLVSDQICore4.cql, and I received the following stack error when running 'Execute CQL':

The following errors were encountered during evaluation: org.opencds.cqf.cql.engine.exception.InvalidOperatorArgument: Expected a list with at most one element, but found a list with multiple elements. at org.opencds.cqf.cql.engine.elm.execution.SingletonFromEvaluator.singletonFrom(SingletonFromEvaluator.java:32) at org.opencds.cqf.cql.engine.elm.execution.SingletonFromEvaluator.internalEvaluate(SingletonFromEvaluator.java:47) 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:163) at org.opencds.cqf.cql.evaluator.cli.command.CqlCommand.call(CqlCommand.java:34) 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.ls.DebugCqlCommandContribution.executeCql(DebugCqlCommandContribution.java:37) at org.opencds.cqf.cql.ls.DebugCqlCommandContribution.executeCommand(DebugCqlCommandContribution.java:65) at org.opencds.cqf.cql.ls.service.CqlWorkspaceService.executeCommandFromContributions(CqlWorkspaceService.java:173) at org.opencds.cqf.cql.ls.service.CqlWorkspaceService.executeCommand(CqlWorkspaceService.java:121) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65) at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120) at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261) at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94) at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) elapsed: 0.1 seconds

Setup follows the structure of ecqm-content-qicore-2022.

The primary library is at HFACEIorARBorARNIforLVSDQICore4.cql.

The test case bundle is at tests-ip-neg-HFACEIorARBorARNIforLVSDQICore4-bundle.json

JPercival commented 2 years ago

Hi @JSRankins!

I've seen that error before when there is more than one Patient resource on the test-case path. I see only one in your Bundle, but I'm assuming this is the source test folder?

https://github.com/JSRankins/ecqm-content-qicore-2022/tree/master/input/tests/measure/HFACEIorARBorARNIforLVSDQICore4/ip-neg-HFACEIorARBorARNIforLVSDQICore4

If so, you need to move the tests-ip-neg-HFACEIorARBorARNIforLVSDQICore4-bundle.json up a level to be in the HFACEIorARBorARNIforLVSDQICore4 folder. The CQL evaluation will import everything in the ip-neg-HFACEIorARBorARNIforLVSDQICore4 folder for test evaluation, including Bundles, which causes two instances of the same Patient resource. We're looking at how to best improve that behavior in the future.

JSRankins commented 2 years ago

Hi @JPercival. Looks like there is an assumption baked into the execution code that Encounter.period will have time information as well as date. The test bundle where this occurred had an Encounter with a period where start and end are same and date based - not offset by any difference in date or time. When providing a start and end that have a different date (start = 2022-01-01, end = 2022-01-03), issue still occurs, but when providing time with date (even when start = end), I receive expected outcome:

Patient=Patient(id=ip-neg-HFACEIorARBorARNIforLVSDQICore4) SDE Ethnicity=Concept { Code { code: 2135-2, system: urn:oid:2.16.840.1.113883.6.238, version: null, display: Hispanic or Latino } } SDE Payer=[] SDE Race=Concept { Code { code: 2028-9, system: urn:oid:2.16.840.1.113883.6.238, version: null, display: Asian } } SDE Sex=Code { code: F, system: http://hl7.org/fhir/v3/AdministrativeGender, version: null, display: Female } Qualifying Encounter During Measurement Period=[] Heart Failure Outpatient Encounter=[] Initial Population=false Moderate or Severe LVSD Findings=[] Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD=[] Denominator=false Has Heart Transplant=false Has Heart Transplant Related Diagnosis=false Has Left Ventricular Assist Device=false Has Left Ventricular Assist Device Related Diagnosis=false Denominator Exclusions=false Has ACEI or ARB or ARNI Ordered=false Is Currently Taking ACEI or ARB or ARNI=false Numerator=false Has Medical or Patient Reason for Not Ordering ACEI or ARB or ARNI=false Has Allergy or Intolerance to ACEI or ARB or ARNI Ingredient=false Has Diagnosis of Allergy or Intolerance to ACEI or ARB=false Has Diagnosis of Pregnancy=false Has Diagnosis of Renal Failure Due to ACEI=false Denominator Exceptions=false Face to Face Encounter During Measurement Period=[]

JPercival commented 2 years ago

Are you saying that the stack trace error is related to the timings of the Encounter resource or is this a new, distinct issue?

JSRankins commented 2 years ago

@JPercival , stack error goes away when providing time (in addition to date) for Encounter.period start and end. So probably two issues. More graceful handling of errors surfacing from execution would be great. But it looks like there may be an issue with execution itself. Thoughts?

brynrhodes commented 1 year ago

Trying to confirm that this is addressed by the 0.4.0 release, but the links to the repro give 404?

@JSRankins , can you confirm whether you are still seeing this issue with the 0.4.0 plugin release?

JSRankins commented 1 year ago

Hi @brynrhodes. My apologies. I forgot about this ticket and had changed the name of the file - EXM135v11QICore4.cql. At any rate, I'm not able to recreate the issue, so it appears to be resolved.