Execute stored AQL (POST)
Execute a stored query, identified by the supplied qualified_query_name (at latest version).
See also details on usage of query parameters.
Queries can be stored or, once stored, their definition can be retrieved using the definition endpoint.
- Type: string · QueryName
qualified _query _name requiredThe (fully qualified) name of the query to be executed, in a format of
[{namespace}::]{query-name}.
Specifications for a stored AQL query execution.
- Type: integer · FetchFormat: int32
fetch requiredNumber of rows to fetch (the default depends on the implementation).
- Type: integer · OffsetFormat: int32
offset requiredThe row number in result-set to start result-set from (
0-based), default is0. - Type: object · QueryParameters
query _parameters requiredA set of query parameters.
- application/json
400 400 Bad Requestis returned when the server was unable to execute the query due to invalid input, e.g. a required parameter is missing, or at least one of the parameters has an invalid syntax.404 404 Not Foundis returned when a stored query withqualified_query_namedoes not exist.408 408 Request Timeoutis returned when there is a query execution timeout (i.e. maximum query execution time reached, therefore the server aborted the execution of the query).
curl https://openEHRSys.example.com/v1/query/org.openehr::compositions \
--request POST \
--header 'Content-Type: application/json' \
--data '{
"offset": 10,
"fetch": 10,
"query_parameters": {
"ehr_id": "7d44b88c-4199-4bad-97dc-d78268e01398",
"systolic_bp": 140
}
}'
{
"meta": {
"_href": "https://openEHRSys.example.com/v1/query/org.openehr::compositions",
"_type": "RESULTSET",
"_schema_version": "1.0.0",
"_created": "2017-08-19T00:25:47.568+02:00",
"_generator": "openEHRSys.ResultSets.Serialization.Json.ResultSetJsonWriter (5.0.0.0)",
"_executed_aql": "SELECT e/ehr_id/value, c/context/start_time/value as startTime, obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude AS systolic, c/uid/value AS cid, c/name FROM EHR e CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] CONTAINS OBSERVATION obs[openEHR-EHR-OBSERVATION.blood_pressure.v1] WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= 50"
},
"name": "org.openehr::compositions",
"q": "SELECT e/ehr_id/value, c/context/start_time/value as startTime, obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude AS systolic, c/uid/value AS cid, c/name FROM EHR e CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] CONTAINS OBSERVATION obs[openEHR-EHR-OBSERVATION.blood_pressure.v1] WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= $systolic_bp",
"columns": [
{
"name": "#0",
"path": "/ehr_id/value"
},
{
"name": "startTime",
"path": "/context/start_time/value"
},
{
"name": "systolic",
"path": "/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude"
},
{
"name": "cid",
"path": "/uid/value"
},
{
"name": "#4",
"path": "/name"
}
],
"rows": [
[
"81433066-c417-4813-9b29-79783e7bed23",
"2017-02-16T13:50:11.308+01:00",
140,
"90910cf0-66a0-4382-b1f8-c0f27e81b42d::openEHRSys.example.com::1",
{
"_type": "DV_TEXT",
"value": "Labs"
}
]
]
}