cqframework / vscode-cql

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

sort by errors: it requires that the element(s) that are being sorted by be accessed with .value #18

Open rob-reynolds opened 1 year ago

rob-reynolds commented 1 year ago

IS: if you sort by and only provide the name of the element(s) you are sorting by (and the result is cardinality > 1) you get the following error:

The following errors were encountered during evaluation:
org.opencds.cqf.cql.engine.exception.InvalidComparison: Type org.hl7.fhir.r4.model.DateTimeType is not comparable
    at org.opencds.cqf.cql.engine.runtime.CqlList.compareTo(CqlList.java:77)
    at org.opencds.cqf.cql.engine.runtime.CqlList$2.compare(CqlList.java:64)
    at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
    at java.base/java.util.TimSort.sort(TimSort.java:220)
    at java.base/java.util.Arrays.sort(Arrays.java:1515)
    at java.base/java.util.ArrayList.sort(ArrayList.java:1750)
    at org.opencds.cqf.cql.engine.elm.execution.QueryEvaluator.sortResult(QueryEvaluator.java:114)
    at org.opencds.cqf.cql.engine.elm.execution.QueryEvaluator.internalEvaluate(QueryEvaluator.java:216)
    at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18)
    at org.opencds.cqf.cql.engine.elm.execution.FirstEvaluator.internalEvaluate(FirstEvaluator.java:34)
    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:834)

SHOULD BE: no error

REPRO:

CQL: define "FirstTest": First( [Observation] O sort by effective descending )

Data: Unzip this file to your tests/ folder: patient-1.zip

I.e. after installing the test you should have a directory structure: input/tests//patient-1/testFirst.json

rob-reynolds commented 1 year ago

Note: the workaround for this is is to use the .value:

define "FirstTest": First( [Observation] O sort by effective.value descending )