Re: AQL questions

2019-04-30 Thread Georg Fette

Ah, thanks for the clarifications.
Greetings
Georg

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


___
openEHR-technical mailing list
openEHR-technical@lists.openehr.org
http://lists.openehr.org/mailman/listinfo/openehr-technical_lists.openehr.org


RE: AQL questions

2019-04-26 Thread Bjørn Næss
Thomas answered the CONTAINS operator. 

I am not sure how to best answer your second question. I will try the following 
:-) 

The node predicates as below: 

*c2/items[at0002]/items[at0001]/value/magnitude
*o/data[at0001]/events[at0002]/time

Here the "c2" and "o" is a reference to a path in the Composition, and the 
reference is defined in the FROM part of the AQL. The "c2" is synonymous with 
the following path: 

"c2" == 
"/content[openEHR-EHR-OBSERVATION.laboratory_test.v1]/data[at0001]/events[at0002]/data[at0003]/items[openEHR-EHR-CLUSTER.laboratory_test_panel.v1]"

Which gives "c2" + "path" to be: 

"/content[openEHR-EHR-OBSERVATION.laboratory_test.v1]/data[at0001]/events[at0002]/data[at0003]/items[openEHR-EHR-CLUSTER.laboratory_test_panel.v1]/
 /items[at0002]/items[at0001]/value/magnitude"


Vennlig hilsen
Bjørn Næss
Produktansvarlig 
DIPS ASA

Mobil +47 93 43 29 10

-Original Message-
From: openEHR-technical  On Behalf 
Of Georg Fette
Sent: torsdag 25. april 2019 19:30
To: openehr-technical@lists.openehr.org
Subject: Re: AQL questions

Hi Bjørn,
Thank you for your answers. They make me assume that the CONTAINS-operator is 
recursive because in your second query you ommited the part with "CONTAINS 
OBSERVATION o[openEHR-EHR-OBSERVATION.laboratory_test.v1]". Is this assumption 
correct ? This would make writing AQL a lot simpler.
Another assumption I have is that the predicate namespaces always relate to the 
aliased archetype the path they are used within starts with. In your first 
query you use at0001 and at0002 each two times but they seem to have different 
meanings.
Greetings
Georg

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


___
openEHR-technical mailing list
openEHR-technical@lists.openehr.org
http://lists.openehr.org/mailman/listinfo/openehr-technical_lists.openehr.org
___
openEHR-technical mailing list
openEHR-technical@lists.openehr.org
http://lists.openehr.org/mailman/listinfo/openehr-technical_lists.openehr.org


Re: AQL questions

2019-04-25 Thread Georg Fette

Hi Bjørn,
Thank you for your answers. They make me assume that the 
CONTAINS-operator is recursive because in your second query you ommited 
the part with "CONTAINS OBSERVATION 
o[openEHR-EHR-OBSERVATION.laboratory_test.v1]". Is this assumption 
correct ? This would make writing AQL a lot simpler.
Another assumption I have is that the predicate namespaces always relate 
to the aliased archetype the path they are used within starts with. In 
your first query you use at0001 and at0002 each two times but they seem 
to have different meanings.

Greetings
Georg

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


___
openEHR-technical mailing list
openEHR-technical@lists.openehr.org
http://lists.openehr.org/mailman/listinfo/openehr-technical_lists.openehr.org


RE: AQL questions

2019-04-25 Thread Bjørn Næss
Hi - great question. 
The answer is as always; it depends. The query below (similar to yours) will 
work also. 
What you have to consider when building AQLs is repeatable structures to make 
sure you hit the right instance. For this use-case I guess you would like any 
EHR which has a Calcium result. Thus you don’t care about which result is 
Calcium. But if you wanted to get the excact CLUSTER with Calcium combined with 
i.e. HISTORY.time you have to be a bit careful. 

SELECT
e
FROM
EHR e
CONTAINS COMPOSITION c
CONTAINS OBSERVATION o[openEHR-EHR-OBSERVATION.laboratory_test.v1]
CONTAINS CLUSTER 
c2[openEHR-EHR-CLUSTER.laboratory_test_panel.v1]
WHERE
c2/items[at0002]/items[at0001]/value/magnitude > 123
ORDER BY
o/data[at0001]/events[at0002]/time DESC
LIMIT 10


An even simpler AQL if you want any CLUSTER of a specific type is to only query 
for Composition with the CLUSTER. Like this: 

SELECT
e
FROM
EHR e
CONTAINS COMPOSITION c
CONTAINS CLUSTER c2[openEHR-EHR-CLUSTER.laboratory_test_panel.v1]
LIMIT 10

Vennlig hilsen
Bjørn Næss
Produktansvarlig 
DIPS ASA

Mobil +47 93 43 29 10


-Original Message-
From: openEHR-technical  On Behalf 
Of Georg Fette
Sent: torsdag 25. april 2019 14:18
To: For openEHR technical discussions 
Subject: AQL questions

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ürzburgTel.: +49-(0)931-31-85516
Am Hubland  Fax.: +49-(0)931-31-86732
97074 Würzburg  mail: georg.fe...@uni-wuerzburg.de
-


___
openEHR-technical mailing list
openEHR-technical@lists.openehr.org
http://lists.openehr.org/mailman/listinfo/openehr-technical_lists.openehr.org
___
openEHR-technical mailing list
openEHR-technical@lists.openehr.org
http://lists.openehr.org/mailman/listinfo/openehr-technical_lists.openehr.org