...
Here is an example of AQL statement. This statement returns all blood pressure values where systolic value is greater or equal to 140 or diastolic value is greater or equals to 90 within a specified EHR. AQL syntax is a synthesis of SQL structural syntax and openEHR path syntax.
AQL Syntax Description
Overview
AQL has SELECT, FROM, WHERE and ORDER BY clauses. openEHR path syntax is used to locate any node or data values within archetypes. The SELECT clause uses openEHR path syntax to indicate expected archetypes, elements, or data values that are need to be returned. FROM clause uses containment mechanisms indicating the scope of the query data source. WHERE clause utilises archetype path to set query criteria on archetypes or any node within the archetypes. The following sections introduce the AQL syntax in detail.
...
- outside a predicate
No Format o/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/value>$systolicCriteria
...
Predicates
AQL has three types of predicates: standard predicate, archetype predicate, and node predicate.
...
Node predicate defines criteria on fine-grained data. It is only used within an identified path.
...
Operators
Basic
...
operators
The table below shows the basic AQL operators, meaning and example.
Operator | Meaning | Example | ||
---|---|---|---|---|
= | Equal |
| ||
> | Greater than |
| ||
>= | Greater than or equal to |
| ||
< | Smaller than |
| ||
<= | Smaller than or equal to |
| ||
!= | not equals to |
|
Advanced
...
operators
matches
matches operator is used in WHERE clause. This operator needs left operand and right operand. Left operand is an AQL identified path. Right operand is enclosed within curly braces. Right operand of matches operator has three forms:
...
Code Block |
---|
matches {|3.0..5.0|} // means 3.0 <= x <=5.0 matches {|<8|} // means x<8 |
...
Query structure
Overview
AQL structure has been briefly introduced in Section 2.2. This section introduces AQL structure in detailsdescribes the syntax in more formal detail.
AQL structure has the following clauses and these clauses must be listed in the same order as the list below in an AQL statement. An AQL statement must contain SELECT and FROM clauses.
...
No Format |
---|
TIMEWINDOW P2Y/2006-01-01 |
Result structure
The result structure of an AQL query is described here as part of the EHR service definition.
How to write an AQL query statement manually
...