Execute stored AQL version

Execute a stored query, identified by the supplied qualified_query_name (at specified version), fetching fetch numbers of rows from offset and passing query_parameters to the underlying query engine.

See also details on usage of query parameters.

Queries can be stored or, once stored, their definition can be retrieved using the definition endpoint.

Path Parameters
  • qualified_query_name
    Type: string · QueryName
    required

    The (fully qualified) name of the query to be executed, in a format of [{namespace}::]{query-name}.

  • version
    Type: string
    required

    A SEMVER version number. This can be a an exact version (e.g. 1.7.1), or a pattern as partial prefix, in a form of {major} or {major}.{minor} (e.g. 1 or 1.0), in which case the highest (latest) version matching the prefix will be considered.

Query Parameters
  • ehr_id
    Type: string

    An optional parameter to execute the query within an EHR context.

  • offset
    Type: integer · OffsetFormat: int32

    The row number in result-set to start result-set from (0-based), default is 0.

  • fetch
    Type: integer · FetchFormat: int32

    Number of rows to fetch (the default depends on the implementation).

  • query_parameters
    Type: object · QueryParameters

    Query parameters (can appear multiple times).

    • propertyName
      Type: anything
Responses
  • application/json
  • 400

    400 Bad Request is 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 Found is returned when a stored query with qualified_query_name and version does not exist.

  • 408

    408 Request Timeout is returned when there is a query execution timeout (i.e. maximum query execution time reached, therefore the server aborted the execution of the query).

Request Example for get/query/{qualified_query_name}/{version}
curl 'https://openEHRSys.example.com/v1/query/org.openehr::compositions/1.0?ehr_id=7d44b88c-4199-4bad-97dc-d78268e01398&offset=10&fetch=10&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"
      }
    ]
  ]
}