AQL questions

Georg Fette georg.fette at uni-wuerzburg.de
Thu Apr 25 08:17:53 EDT 2019


Hello,
I have some problems concerning the formulation of an AQL query.
I would like to check a laboratory analyte within a laboratory test. The 
analyte should have "Calcium" as analyte name and I would like to 
receive all EHRs that contain the analyte as the query result.
The SELECT part seems easy, as I just want the EHRs, so this looks like 
this:

SELECT e

A problem I now have is about the nesting of the Archetypes. As the test 
is an OBSERVATION and an EHR contains only COMPOSITIONs, I wonder if I 
have to include a COMPOSITION in order to reach the tests. This would 
lead to a FROM part looking like this:

FROM EHR e
     CONTAINS COMPOSITION
         CONTAINS OBSERVATION 
b[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]

The next problem I have is about the definition of the containment of 
the analyte in the FROM part or better in the WHERE part. The FROM part 
would require me to define the actual nesting structure of the 
test-OBSERVATION up to the analyte-CLUSTER. This would look like this:

FROM EHR e
     CONTAINS COMPOSITION
         CONTAINS OBSERVATION 
b[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]
             CONTAINS HISTORY
                 CONTAINS EVENT
                     CONTAINS ITEM_TREE
                         CONTAINS CLUSTER 
c[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1]

This looks a bit bloated, so I think this should rather be moved to the 
WHERE part, which would look like this:

FROM EHR e
     CONTAINS COMPOSITION
         CONTAINS OBSERVATION 
b[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]
WHERE 
b/data[at0001]/events[at0002]/data[at0003]/items[at0097]/items[at0024].value 
= 'Calcium'

In this WHERE path I am wondering about the necessity of the path part 
predicates (i.e. the [at...] parts). Are these predicates always 
necessary for every path part ? Or are they only necessary when the path 
part object would be ambiguous without the predicate (e.g. in the items 
of CLUSTERs or ITEM_LISTs) ?
Furthermore I wonder about the namespace from which the predicates are 
taken from. For the first part of the WHERE until the archetype slot is 
reached (i.e. b/data[at0001]/events[at0002]/data[at0003]/items[at0097]) 
the predicates are from the laboratory_test_result archetype. For the 
rest of the path (i.e. /items[at0024].value) the predicates are taken 
from the laboratory_test_analyte archetype. This switching of namespaces 
seems wrong, so I think I still have some misunderstanding of AQL 
concerning the predicates.

How would the correct query/queries look like ? Are there multiple valid 
alternatives to express my query using combinations of the approaches 
scetched above ?
Greetings
Georg

-- 
---------------------------------------------------------------------
Dipl.-Inf. Georg Fette      Raum: B001
Universität Würzburg        Tel.: +49-(0)931-31-85516
Am Hubland                  Fax.: +49-(0)931-31-86732
97074 Würzburg              mail: georg.fette at uni-wuerzburg.de
---------------------------------------------------------------------




More information about the openEHR-technical mailing list