cqframework / cqf-ruler

FHIR Clinical Reasoning Module Server
Apache License 2.0
63 stars 49 forks source link

Error attempting to evaluate measure with a patient that has more than 19 resources of any type #489

Closed brynrhodes closed 2 years ago

brynrhodes commented 2 years ago

Attempting to evaluate a measure with a patient that has more than 19 resources of any type results in the following error:

Failed to call access method: org.opencds.cqf.cql.engine.exception.CqlException: Unexpected exception caught during execution: ca.uhn.fhir.context.ConfigurationException: Attempt to request all resources from an asynchronous search result.  The SearchParameterMap for this search probably should have been synchronous.
brynrhodes commented 2 years ago

The following patient will reproduce the error with the BCSEHEDISMY2022 error from the ecqm-content-r4-2021 repository:

{
    "resourceType": "Bundle",
    "id": "Bundle-65",
    "entry": [
        {
            "resource": {
                "resourceType": "Patient",
                "id": "Patient-65",
                "name": [
                    {
                        "given": [
                            "MammographyStartofParticipationPeriod"
                        ],
                        "family": "NumPass"
                    }
                ],
                "birthDate": "1970-12-31",
                "gender": "female"
            },
            "request": {
                "method": "PUT",
                "url": "Patient/Patient-65"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-93",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-93"
            }
        },
        {
            "resource": {
                "resourceType": "Observation",
                "id": "Observation-65-94",
                "subject": {
                    "reference": "Patient/Patient-65"
                },
                "code": {
                    "coding": [
                        {
                            "system": "http://www.ama-assn.org/go/cpt",
                            "version": "2021.5.21AA",
                            "code": "77065",
                            "display": "Diagnostic mammography, including computer-aided detection (CAD) when performed; unilateral"
                        }
                    ]
                },
                "effectiveDateTime": "2020-10-01T00:00:00.000Z"
            },
            "request": {
                "method": "PUT",
                "url": "Observation/Observation-65-94"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-95",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-95"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-96",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-96"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-97",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-97"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-98",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-98"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-99",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-99"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-100",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-100"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-101",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-101"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-102",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-102"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-103",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-103"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-104",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-104"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-105",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-105"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-106",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-106"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-107",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-107"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-108",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-108"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-109",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-109"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-110",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-110"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-111",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-111"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-112",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-112"
            }
        },
        {
            "resource": {
                "resourceType": "Coverage",
                "id": "Coverage-65-115",
                "policyHolder": {
                    "reference": "Patient/Patient-65"
                },
                "period": {
                    "start": "2020-10-01T00:00:00.000Z",
                    "end": "2022-12-31T23:59:59.000Z"
                },
                "type": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                            "code": "MCPOL"
                        }
                    ]
                }
            },
            "request": {
                "method": "PUT",
                "url": "Coverage/Coverage-65-115"
            }
        },
        {
            "resource": {
                "resourceType": "Observation",
                "id": "Observation-65-94",
                "subject": {
                    "reference": "Patient/Patient-65"
                },
                "code": {
                    "coding": [
                        {
                            "system": "http://www.ama-assn.org/go/cpt",
                            "version": "2021.5.21AA",
                            "code": "77065",
                            "display": "Diagnostic mammography, including computer-aided detection (CAD) when performed; unilateral"
                        }
                    ]
                },
                "effectiveDateTime": "2020-10-01T00:00:00.000Z"
            },
            "request": {
                "method": "PUT",
                "url": "Observation/Observation-65-94"
            }
        }
     ]
}
JPercival commented 2 years ago

This is most likely a bug somewhere in the JpaFhirRetrieveProvider. All the SearchMaps it creates should be synchronous.

JPercival commented 2 years ago

Resolved on master by changing resource counts to ACTUAL instead of ESTIMATED for CQL code paths.