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

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

Open
rob-reynolds opened this issue Aug 17, 2022 · 1 comment

Comments

@rob-reynolds
Copy link

rob-reynolds commented Aug 17, 2022

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
Copy link
Author

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

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

@rob-reynolds rob-reynolds changed the title First operation errors if there is more than one resource sort by errors if you don't access .value of the element(s) you are sorting by Aug 17, 2022
@rob-reynolds rob-reynolds changed the title sort by errors if you don't access .value of the element(s) you are sorting by sort by errors: it requires that the element(s) that are being sorted by be accessed with .value Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant