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

CQL: $evaluate-measure leads to HAPI-0389 error if the server contains more than 20 resources #4065

Closed
wetret opened this issue Sep 23, 2022 · 8 comments

Comments

@wetret
Copy link

wetret commented Sep 23, 2022

Describe the bug:

Executing CQL on a server containing more then 20 resources using a Library and a Measure resource as well as the $evalutate-measure operation leads to the error:

HAPI-0389: Failed to call access method: ca.uhn.fhir.context.ConfigurationException: HAPI-0464: Attempt to request all resources from an asynchronous search result.  The SearchParameterMap for this search probably should have been synchronous.

To Reproduce:

  1. Start HAPI FHIR server using the following docker-compose:
version: '3.8'
services:
  app:
    image: hapiproject/hapi:v6.1.0
    ports:
      - 8080:8080
    environment:
      TZ: Europe/Berlin
      HAPI_FHIR_CQL_ENABLED: "true"
      SPRING_DATASOURCE_URL: jdbc:postgresql://db/fhir
      SPRING_DATASOURCE_USERNAME: hapi
      SPRING_DATASOURCE_PASSWORD: password
      SPRING_DATASOURCE_DRIVERCLASSNAME: org.postgresql.Driver
      spring.jpa.properties.hibernate.dialect: ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect
    networks:
      backend:
    depends_on:
      - db
  db:
    image: postgres:14
    restart: on-failure
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U hapi -d fhir"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - type: volume
        source: db-hapi
        target: /var/lib/postgresql/data
    environment:
      TZ: Europe/Berlin
      POSTGRES_DB: fhir
      POSTGRES_USER: hapi
      POSTGRES_PASSWORD: password
    networks:
      backend:

volumes:
  db-hapi:
    name: db-hapi

networks:
  backend:
  1. Load 20 Patient resources like:
<Patient xmlns="http://hl7.org/fhir">
    <active value="true"/>
    <name>
        <use value="official"/>
        <family value="Chalmers"/>
        <given value="Peter"/>
        <given value="James"/>
    </name>
    <gender value="male"/>
    <birthDate value="1974-12-25"/>
    <deceasedBoolean value="false"/>
</Patient>
  1. Store Library and Measure resources using the following Transaction-Bundle:
<Bundle xmlns="http://hl7.org/fhir">
    <type value="transaction"/>
    <entry>
        <fullUrl value="urn:uuid:00000000-0000-0000-0000-library00001"/>
        <resource>
            <Library xmlns="http://hl7.org/fhir">
                <url value="urn:uuid:00000000-0000-0000-0000-library00001"/>
                <name value="Retrieve"/>
                <version value="1.0.0"/>
                <status value="active"/>
                <type>
                    <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/library-type"/>
                        <code value="logic-library"/>
                    </coding>
                </type>
                <content>
                    <contentType value="text/cql"/>
                    <data value="bGlicmFyeSBSZXRyaWV2ZSB2ZXJzaW9uICcxLjAuMCcKdXNpbmcgRkhJUiB2ZXJzaW9uICc0LjAuMCcKaW5jbHVkZSBGSElSSGVscGVycyB2ZXJzaW9uICc0LjAuMCcKCmNvbnRleHQgUGF0aWVudAoKZGVmaW5lIEluSW5pdGlhbFBvcHVsYXRpb246CiAgUGF0aWVudC5nZW5kZXIgPSAnbWFsZSc="/>
                </content>
            </Library>
        </resource>
        <request>
            <method value="POST"/>
            <url value="Library"/>
        </request>
    </entry>
    <entry>
        <fullUrl value="urn:uuid:00000000-0000-0000-0000-measure00001"/>
        <resource>
            <Measure xmlns="http://hl7.org/fhir">
                <status value="active"/>
                <library value="urn:uuid:00000000-0000-0000-0000-library00001"/>
                <scoring>
                    <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"/>
                        <code value="cohort"/>
                    </coding>
                </scoring>
                <group>
                    <population>
                        <code>
                            <coding>
                                <system value="http://terminology.hl7.org/CodeSystem/measure-population"/>
                                <code value="initial-population"/>
                            </coding>
                        </code>
                        <criteria>
                            <language value="text/cql"/>
                            <expression value="InInitialPopulation"/>
                        </criteria>
                    </population>
                </group>
            </Measure>
        </resource>
        <request>
            <method value="POST"/>
            <url value="Measure"/>
        </request>
    </entry>
</Bundle>
  1. Evaluate the Measure resource using http://localhost:8080/fhir/Measure/{id}/$evaluate-measure.

Expected behavior:

The Result should be a MeasureReport resource like (depending on the number of male patients on the server):

{
    "resourceType": "MeasureReport",
    "status": "complete",
    "type": "summary",
    "measure": "Measure/3",
    "group": [
        {
            "population": [
                {
                    "code": {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/measure-population",
                                "code": "initial-population"
                            }
                        ]
                    },
                    "count": 1
                }
            ]
        }
    ],
    "evaluatedResource": [
        {
            "reference": "#Patient/1"
        }
    ]
}

Environment:

  • HAPI FHIR Version: 6.1.0 from DockerHub --> hapiproject/hapi:v6.1.0
  • OS: MacOS 12.6
@JohannesOehm
Copy link

This issue is probably related: #4025

@DWay17
Copy link

DWay17 commented Nov 9, 2022

+1

1 similar comment
@tonyashm
Copy link

tonyashm commented Jan 6, 2023

+1

@JPercival
Copy link
Collaborator

Should be resolved with #4347. Feel free to reopen if the issue re-occurs.

@wetret
Copy link
Author

wetret commented Mar 2, 2023

I tried running CQL on the new Docker image hapiproject/hapi:v6.4.0. I added the new HAPI_FHIR_CR_ENABLED: "true" environment variable to the docker-compose file. But it seems that CQL is not enabled, because I get the following response evaluating a Measure resource with http://localhost:8080/fhir/Measure/3/$evaluate-measure:

{
  "resourceType": "OperationOutcome",
  "issue": [ {
    "severity": "error",
    "code": "not-supported",
    "diagnostics": "Invalid request: The FHIR endpoint on this server does not know how to handle GET operation[Measure/3/$evaluate-measure] with parameters [[]]"
  } ]
}

What am I missing?

Unfortunately I do not have the privileges to reopen the issue. Could you do that for me @JPercival ?

@alackerbauer
Copy link
Contributor

This seems like a problem that has been reported here: hapifhir/hapi-fhir-jpaserver-starter#501

Likely, when you run a request to inspect the server's metadata, the CQL operations are unknown to the server and therefore none of them can be used, including $evaluate-measure.

@wilson-tyler
Copy link

Is there any movement on this? We are experiencing the same responses as @wetret when attempting to evaluate a measure with $evaluate-measure. We are on hapi:v6.4.4 with cr_enabled = true. Also successfully seeing the service log of Registering CQL Provider.

@jadeite1000
Copy link

Hi All, I am using smilecdr202308r02, I am getting the following error in postman when I submit a bundle transaction questionnaire request but get the below error:

{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "HAPI-0389: Failed to call access method: java.lang.RuntimeException: java.net.ConnectException: Connection refused"
}
]
}

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

8 participants