cqframework / vscode-cql

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

Clause that didn't used to error, now errors #19

Open rob-reynolds opened 2 years ago

rob-reynolds commented 2 years ago

IS: if you run a where operator with a clause like '6 months or less on or before day of' you get the following error:

The following errors were encountered during evaluation:
org.opencds.cqf.cql.engine.exception.CqlException: Translation of library HCC189 failed with the following message: Could not resolve call to operator Subtract with signature (list<choice<FHIR.dateTime,FHIR.Period,FHIR.Timing,FHIR.instant>>,System.Quantity).
    at org.opencds.cqf.cql.evaluator.engine.execution.TranslatingLibraryLoader.translate(TranslatingLibraryLoader.java:134)
    at org.opencds.cqf.cql.evaluator.engine.execution.TranslatingLibraryLoader.load(TranslatingLibraryLoader.java:78)
    at org.opencds.cqf.cql.evaluator.engine.execution.CacheAwareLibraryLoaderDecorator.load(CacheAwareLibraryLoaderDecorator.java:49)
    at org.opencds.cqf.cql.engine.execution.CqlEngine.loadAndValidate(CqlEngine.java:254)
    at org.opencds.cqf.cql.engine.execution.CqlEngine.evaluate(CqlEngine.java:154)
    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 "FirstObservation": [Observation] O where O.id = 'UACRgt30lt6M-1'

define "SecondObservation": [Observation] O where O.id = 'UACRgt30lt6M-2'

define "FirstTest": "FirstObservation" First where First.effective 6 months or less on or before day of "SecondObservation".effective

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

Note: this did not prior, but does now also error during authoring time.

image

Workaround: define "FirstObservation": [Observation] O where O.id = 'UACRgt30lt6M-1'

define "SecondObservation": singleton from ([Observation] O where O.id = 'UACRgt30lt6M-2')

define "FirstTest": "FirstObservation" First where (First.effective as FHIR.dateTime) 6 months or less on or before day of ("SecondObservation".effective as FHIR.dateTime)

This works, but it's making a lot of assumptions.

Note, First (or something) would be a more real-world example of a way to get a single Observation from "SecondObservation", but those operations are currently broken. See https://github.com/cqframework/vscode-cql/issues/18.

JPercival commented 2 years ago

This is likely the same #18. Use effective.value.