cqframework / atom_cql_support

Apache License 2.0
4 stars 3 forks source link

Inconsistency between CQL Translation and Evaluation for FHIR Types #42

Open gansoper opened 2 years ago

gansoper commented 2 years ago

Hello,

I use cql-language 2.11.1

I found that during translation(and during the writing the code in IDE) it uses FHIR types for DSTU 2. These classes are included in Java library along with classes for r4 (org.hl7.fhir.r4.model)

return OperationOutcome { id:id{value:'xxx'}, issue: List<FHIR.OperationOutcome.OperationOutcomeIssueComponent >{ FHIR.OperationOutcome.OperationOutcomeIssueComponent { severity: FHIR.IssueSeverity {value:'error'}, code: FHIR.IssueType {value: 'sdfs'} } } }

such a code (that contain r4 model) highlights errors in IDE and produces

org.opencds.cqf.cql.engine.exception.CqlException: Translation of library CHF failed with the following message: A named type is required in this context. 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)

But if I use DSTU2 model

return OperationOutcome { id:id{value:'xxx'}, issue: List<FHIR.OperationOutcome.Issue >{ FHIR.OperationOutcome.Issue { severity: FHIR.IssueSeverity {value:'error'}, code: FHIR.IssueType {value: 'sdfs'} } } }

It does not highlights it in IDE (seems like it believes that this type is correct one), but during the running following exception occurs

org.opencds.cqf.cql.engine.fhir.exception.UnknownType: Could not resolve type OperationOutcome.Issue. Primary package(s) for this resolver are org.hl7.fhir.r4.model at org.opencds.cqf.cql.engine.fhir.model.FhirModelResolver.resolveType(FhirModelResolver.java:269) at org.opencds.cqf.cql.engine.fhir.model.R4FhirModelResolver.resolveType(R4FhirModelResolver.java:190) at org.opencds.cqf.cql.engine.fhir.model.FhirModelResolver.createInstance(FhirModelResolver.java:182) at org.opencds.cqf.cql.evaluator.engine.model.CachingModelResolverDecorator.createInstance(CachingModelResolverDecorator.java:88) at org.opencds.cqf.cql.engine.data.CompositeDataProvider.createInstance(CompositeDataProvider.java:74) at org.opencds.cqf.cql.engine.execution.Context.createInstance(Context.java:434) at org.opencds.cqf.cql.engine.elm.execution.InstanceEvaluator.internalEvaluate(InstanceEvaluator.java:9) at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18) at org.opencds.cqf.cql.engine.elm.execution.ListEvaluator.internalEvaluate(ListEvaluator.java:13) at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18) at org.opencds.cqf.cql.engine.elm.execution.InstanceEvaluator.internalEvaluate(InstanceEvaluator.java:11) at org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18) at org.opencds.cqf.cql.engine.elm.execution.QueryEvaluator.evaluateReturn(QueryEvaluator.java:85) at org.opencds.cqf.cql.engine.elm.execution.QueryEvaluator.internalEvaluate(QueryEvaluator.java:202) 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)