# AQL queries

**URL:** https://discourse.openehr.org/t/aql-queries/14829
**Category:** Technical (archive)
**Created:** [1 October 2008 12:31 UTC](https://discourse.openehr.org/t/aql-queries/14829 "2008-10-01T12:31:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Greg\_Caulton](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/g/f14d63/32.png) [@Greg\_Caulton](https://discourse.openehr.org/u/Greg_Caulton)
#### Post date: [1 October 2008 12:31 UTC](https://discourse.openehr.org/t/aql-queries/14829/1 "2008-10-01T12:31:23Z")

</div>

I still think it is unfortunate that none of the existing tools nor  
the web based CKM show the appropriate AQL path for each data element.

It is near impossible to manually build

...  
WHERE openEHR-EHR-OBSERVATION.blood\_pressure.v1/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/value

> = 140

the only way I can do it is to write code to parse the ADL and build  
the path but I have nothing to validate that my implementation was  
correct

it would be nice to have a set of illustrative AQL queries that one  
could validate against.

---

<div class="post-metadata">

### Author: ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)
#### Post date: [1 October 2008 14:25 UTC](https://discourse.openehr.org/t/aql-queries/14829/2 "2008-10-01T14:25:41Z")

</div>

Greg Caulton wrote:

> I still think it is unfortunate that none of the existing tools nor  
> the web based CKM show the appropriate AQL path for each data element.
> 
> It is near impossible to manually build
> 
> ...  
> WHERE openEHR-EHR-OBSERVATION.blood\_pressure.v1/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/value  
> &nbsp;&nbsp;  
> Currently you can get the paths from the Archetype workbench - path  
> view. See  
> [http://www.openehr.org/svn/ref\_impl\_eiffel/TRUNK/apps/doc/adl\_workbench\_help.htm](http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/apps/doc/adl_workbench_help.htm)

- thomas beale

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [1 October 2008 16:32 UTC](https://discourse.openehr.org/t/aql-queries/14829/3 "2008-10-01T16:32:24Z")

</div>

Hi Greg,

Thank you for raising your issue.

Sorry that I don't really understand what you want to do? Do you want a path  
for an archetype node or do you want to use AQL to retrieve EHR data?

The AQL where clause stated in your previous email is not quite correct. It  
should always starts with a variable which is defined in the AQL from  
clause, such as:

Select bp

> From EHR e CONTAINS Composition anyComposition CONTAINS Observation

bp[openEHR-EHR-OBSERVATION.blood\_pressure.v1]  
Where  
bp/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude\>=1  
40

In this query, anyComposition and bp are variables.  
This path "/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value"  
points to the systolic element.value - DV\_QUANTITY  
This path  
"/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude"  
points to the systolic element value magnitude - double.

In future, we do need AQL validations, I agree.

Ocean Template Designer has AQL builder prototype. However, it is only a  
prototype, only about three weeks work. However, it can be used to create  
simple AQL queries. We are in the process of building a new AQL builder.

AQL specifications is on openEHR wiki. Any comments or criticisms are  
welcome.

Cheers,  
Chunlan
