Regarding Stored Query

I stored one AQL Query in OpenEHR with paramters. When I provide the values for those parameters to the stored query, I was facing the following issue

"Could not perform SQL query:org.postgresql.util.PSQLException: ERROR: operator does not exist: text < integer\n Hint: No operator matches the given name and argument types. You might need to add explicit type casts.\n Position: 1105,

Request Body :
{

“query_parameters”: {

"ehr_id": "ehrid value",

"deficit": "integer"

}

}

Any help would would be helpful.
Thanks.

Hi Sravanthi (and others),
can you please include details of the product you are connecting to (for example EhrBase), and any other details of your application, environment etc? That will help experts respond more efficiently.

HI, I am connecting to EhrBase

Hi @Sravanthi_Kovi,

my colleague is happy to check this! Would you mind opening an issue on GitHub and providing the template used, an example composition and the stored query? We will try to reproduce and fix: Issues · ehrbase/ehrbase · GitHub

Sure will do that. Thanks

1 Like

Can you share the query?

Sure.
This is the query I stored in OpenEHR.
Stored Query : {
“q”: “SELECT e/ehr_id/value, c/context/start_time/value as startTime, c/uid/value as cid, c/name FROM EHR e[ehr_id/value=$ehr_id] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] WHERE c/content[openEHR-EHR-OBSERVATION.pulse_deficit.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0004]<$deficit”
}
Thanks

This path is not for a native type /data[at0001]/events[at0002]/data[at0003]/items[at0004]

It should be something like /data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/some_dv_attribute

some_dv_attribute depends on the datatype at /data[at0001]/events[at0002]/data[at0003]/items[at0004]/value

Though the server shouldn’t fail but respond with some code like “unsupported operation” instead of throwing an internal exception.

1 Like

Yeah, that worked, I figured out the issue. I gave the parent aql path. After changing to specific data point value path it worked.
Thanks

1 Like

We should still improve the error message, though! Thanks for the feedback!

Glad to help :slight_smile: