LinuxForHealth / FHIR

The LinuxForHealth FHIR® Server and related projects
https://linuxforhealth.github.io/FHIR
Apache License 2.0
325 stars 157 forks source link

Error when trying to evaluate cql when us-core ig jar also loaded #3084

Closed ranum closed 2 years ago

ranum commented 2 years ago

Describe the bug Trying to create an extended fhir server by placing jar files into the userlib directory using the ibm-fhir-server services approach. Wanted to add both fhir-operation-cpg-4.10.1-shaded.jar and fhir-operation-cqf-4.10.1-shaded.jar as well as fhir-ig-us-core-4.10.1.jar. cql evaluation works without the us-core jar but breaks after it is added.

Example cql, something like

/$cql?expression = [Patient] p where p.gender = 'male' & subject= Patient/...

Environment Which version of IBM FHIR Server? 4.10.1

To Reproduce These are the steps used when deploying via health patterns helm chart. You may be able to reproduce by simply adding the three jars to your dev environment server.

Within the Alvearie health patterns, use the pom.xml below to build a new container for the fhir server that includes all three jars mentioned above

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ibm.fhir</groupId>
    <artifactId>fhir-ibmcloud</artifactId>
    <version>99-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <fhir.version>4.10.1</fhir.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>fhir-operation-cqf</artifactId>
            <version>${fhir.version}</version>
            <classifier>shaded</classifier>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>fhir-operation-cpg</artifactId>
            <version>${fhir.version}</version>
            <classifier>shaded</classifier>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>fhir-ig-us-core</artifactId>
            <version>${fhir.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.2</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>package</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <includeArtifactIds>fhir-operation-cpg,fhir-operation-cqf,fhir-ig-us-core</includeArtifactIds>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
        </plugins>
    </build>
</project>

Push the new container out to some container repo and adjust the health patterns fhir values.yaml to point the fhir repo and tag to that new container. For example

  image:
  # -- The repository to pull the IBM FHIR Server image from
    repository: dlranum/ibm-fhir-server-cql-ig
  # -- IBM FHIR Server container image tag
    tag: "0.0.1"

Deploy the pattern according to the instructions.

Once the server is up, you can load patients and evaluate inline cql

Expected behavior Expected to get a response as to whether the patient/subject was male or female

Note that this does work fine when the us-core jar file is not inluded. Also, basic cql expressions that do not involve patients also work fine (string concatenation, simple arithmetic).

Additional context The FHIR pod logs show an error

{"type":"liberty_message","host":"ingestion-fhir-56764f65c5-7s47l","ibm_userDir":"\/opt\/ol\/wlp\/usr\/","ibm_serverName":"defaultServer","message":"\tat java.base\/java.lang.Thread.run(Thread.java:866)","ibm_threadId":"00000039","ibm_datetime":"2021-12-06T14:42:10.037+0000","module":"SystemErr","level":"SystemErr","ibm_methodName":"","ibm_className":"","ibm_sequence":"1638801730037_000000000020D","ext_thread":"Default Executor-thread-6"}
{"type":"liberty_message","host":"ingestion-fhir-56764f65c5-7s47l","ibm_userDir":"\/opt\/ol\/wlp\/usr\/","ibm_serverName":"defaultServer","message":"Evaluation failed\ncom.ibm.fhir.exception.FHIROperationException: Evaluation failed [probeId=ac-11-3b-4c-b1028974-bb31-4f1f-b9f1-9a7e3f1a88e0]\n\tat com.ibm.fhir.operation.cpg.CqlOperation.doInvoke(CqlOperation.java:120)\n\tat <unknown class>.invoke(AbstractOperation.java:57)\n\tat com.ibm.fhir.server.util.FHIRRestHelper.doInvoke(FHIRRestHelper.java:1419)\n\tat <unknown class>.invoke(Operation.java:83)\n\tat com.ibm.fhir.server.resources.Operation$Proxy$_$$_WeldClientProxy.invoke(Unknown Source)\n\tat java.base\/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base\/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat java.base\/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base\/java.lang.reflect.Method.invoke(Method.java:566)\n\tat <unknown class>.serviceInvoke(JaxRsFactoryImplicitBeanCDICustomizer.java:351)\n\tat <unknown class>.performInvocation(LibertyJaxRsServerFactoryBean.java:641)\n\tat <unknown class>.performInvocation(LibertyJaxRsInvoker.java:160)\n\tat <unknown class>.invoke(AbstractInvoker.java:101)\n\tat <unknown class>.invoke(LibertyJaxRsInvoker.java:273)\n\tat <unknown class>.invoke(JAXRSInvoker.java:213)\n\tat <unknown class>.invoke(LibertyJaxRsInvoker.java:444)\n\tat <unknown class>.invoke(JAXRSInvoker.java:112)\n\tat org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)\n\tat <unknown class>.handleMessage(ServiceInvokerInterceptor.java:96)\n\tat org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)\n\tat <unknown class>.onMessage(ChainInitiationObserver.java:123)\n\tat <unknown class>.invoke(AbstractHTTPDestination.java:277)\n\tat <unknown class>.invoke(AbstractJaxRsWebEndpoint.java:137)\n\tat <unknown class>.handleRequest(IBMRestServlet.java:146)\n\tat <unknown class>.doGet(IBMRestServlet.java:112)\n\tat <unknown class>.service(HttpServlet.java:686)\n\tat <unknown class>.service(IBMRestServlet.java:96)\n\tat <unknown class>.service(ServletWrapper.java:1258)\n\tat <unknown class>.handleRequest(ServletWrapper.java:746)\n\tat <unknown class>.handleRequest(ServletWrapper.java:443)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:193)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:98)\n\tat <unknown class>.doFilter(FHIRRestServletFilter.java:155)\n\tat <unknown class>.doFilter(HttpFilter.java:127)\n\tat <unknown class>.doFilter(FilterInstanceWrapper.java:201)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)\n\tat <unknown class>.doFilter(JaspiServletFilter.java:56)\n\tat <unknown class>.doFilter(FilterInstanceWrapper.java:201)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)\n\tat <unknown class>.doFilter(WebAppFilterManager.java:1002)\n\tat <unknown class>.invokeFilters(WebAppFilterManager.java:1140)\n\tat <unknown class>.invokeFilters(WebAppFilterManager.java:1011)\n\tat <unknown class>.handleRequest(CacheServletWrapper.java:75)\n\tat <unknown class>.handleRequest(CacheServletWrapper40.java:85)\n\tat <unknown class>.handleRequest(WebContainer.java:938)\n\tat com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:279)\n\tat com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1159)\n\tat com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:428)\n\tat com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:387)\n\tat com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:566)\n\tat com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:500)\n\tat com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:360)\n\tat com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:327)\n\tat com.ibm.ws.channel.ssl.internal.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1100)\n\tat com.ibm.ws.channel.ssl.internal.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:675)\n\tat com.ibm.ws.channel.ssl.internal.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1824)\n\tat <unknown class>.requestComplete(WorkQueueManager.java:504)\n\tat <unknown class>.attemptIO(WorkQueueManager.java:574)\n\tat <unknown class>.workerRun(WorkQueueManager.java:958)\n\tat com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1047)\n\tat com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:238)\n\tat java.base\/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\/java.lang.Thread.run(Thread.java:866)\nCaused by: org.opencds.cqf.cql.engine.exception.CqlException: Unexpected exception caught during execution: java.lang.IllegalArgumentException: Could not resolve search parameter for resourceType 'Patient' and contextPath 'id'\n\tat org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:37)\n\tat org.opencds.cqf.cql.engine.elm.execution.QueryEvaluator.internalEvaluate(QueryEvaluator.java:165)\n\tat org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18)\n\tat org.opencds.cqf.cql.engine.elm.execution.ExpressionDefEvaluator.internalEvaluate(ExpressionDefEvaluator.java:19)\n\tat org.opencds.cqf.cql.engine.elm.execution.Executable.evaluate(Executable.java:18)\n\tat org.opencds.cqf.cql.engine.execution.CqlEngine.evaluateExpressions(CqlEngine.java:184)\n\tat org.opencds.cqf.cql.engine.execution.CqlEngine.evaluate(CqlEngine.java:162)\n\tat com.ibm.fhir.operation.cpg.AbstractCqlOperation.doEvaluation(AbstractCqlOperation.java:97)\n\tat com.ibm.fhir.operation.cpg.AbstractCqlOperation.doEvaluation(AbstractCqlOperation.java:63)\n\tat com.ibm.fhir.operation.cpg.CqlOperation.doInvoke(CqlOperation.java:115)\n\t... 63 more\n","ibm_threadId":"00000039","ibm_datetime":"2021-12-06T14:42:10.038+0000","module":"com.ibm.fhir.server.resources.FHIRResource","level":"SEVERE","ibm_sequence":"1638801730038_000000000020E","ext_thread":"Default Executor-thread-6"}
{"type":"liberty_message","host":"ingestion-fhir-56764f65c5-7s47l","ibm_userDir":"\/opt\/ol\/wlp\/usr\/","ibm_serverName":"defaultServer","message":"Completed request[0.371 secs]: tenantId:[default] dsId:[default] user:[fhiruser] method:[GET] uri:[https:\/\/dlr-ext-fhir.wh-health-patterns.dev.watson-health.ibm.com\/fhir-server\/api\/v4\/$cql?expression=%5BPatient%5D%20p%20where%20p.gender%20%3D%20&#39;male&#39;&amp;subject=Patient%2F17d90316fd8-80abbe06-7e38-4da9-bee7-4ee795d37ea5] status:[500]","ibm_threadId":"00000039","ibm_datetime":"2021-12-06T14:42:10.052+0000","module":"com.ibm.fhir.server.filter.rest.FHIRRestServletFilter","level":"INFO","ibm_sequence":"1638801730052_000000000020F","ext_thread":"Default Executor-thread-6"}

Root of the error seems to be:

Unexpected exception caught during execution: java.lang.IllegalArgumentException: Could not resolve search parameter for resourceType 'Patient' and contextPath 'id'\n\tat

fhirlog1206A.txt

kmbarton423 commented 2 years ago

Confirmed no longer receiving an error when USCore IG is loaded in FHIR.