Thanks Pablo!
I think you have understood the problem. The real problem is how to interpret 
the clinical intention of the query, and then how to apply that on the openEHR 
RM to produce the correct output.

I have been thinking about adding different “implementation” of the problem. 
One “implementation” could be a ER (enitity relationship) model with tables and 
references. And then to apply this to SQL. Another “implementation” would be 
XPATH.

In this problem you need to define how to repeat:

. History.Origin by all child EVENTS
. Observation.Protocol joined by data from events.

It would be nice if you could contribute with some ER models to show how this 
would work in your model. Put another way; how would such a query look like and 
what would the output be form your system?


Vennlig hilsen
Bjørn Næss
Produktansvarlig
DIPS ASA

Mobil +47 93 43 29 10<tel:+47%2093%2043%2029%2010>

From: openEHR-implementers 
[mailto:openehr-implementers-boun...@lists.openehr.org] On Behalf Of Pablo Pazos
Sent: tirsdag 25. april 2017 06.54
To: For openEHR implementation discussions 
<openehr-implementers@lists.openehr.org>
Subject: Re: AQL: Expected result with repeating structures

Trying to understand the problem, I modeled the database schema in my head.
origin is like a column from the container and magnitude/units are columns for 
the contained node. So it is like having two tables, one for history and one 
for the events with the data (might be N tables in the middle but this is a 
simplification), so it is a one to many relationship, getting one field from 
the *one* side and two from the *many* side. For me the result would repeat the 
origin for every magnitude/units pair, and each result in the result set will 
be that triplet (o, m, u), repeating the o for every triplet, and m,n be values 
contained in the same event/cluster/element/datavalue, since the parent paths 
until the datavalue are the same, the only difference is the reference to the 
datavalue attributes.
But that is what I think it should return, maybe the semantics are different in 
AQL and the results should be the permutations of data between siblings, but I 
don't see much sense on doing that. Also, something like a group by might be 
needed, but instead of having that for aggregations like in SQL, have that to 
group data by container.
Sorry if this doesn't make much sens, I might not understand the whole problem 
:)


On Mon, Apr 24, 2017 at 7:01 PM, Bjørn Næss <b...@dips.no<mailto:b...@dips.no>> 
wrote:
Hi
We have created a GIT repo with some issues from our experiences with AQL.
The repo was created to expose one issue with repeating items. You will find it 
here – and some feedback is welcome:

Folder with all files: 
https://github.com/bjornna/openehr-conformance/tree/master/aql/case1-permutations

README with the problem: 
https://github.com/bjornna/openehr-conformance/blob/master/aql/case1-permutations/index.adoc

The initial problem was this:

One simple example may be openEHR-EHR-OBSERVATION.body_weight.v1 which have an 
optional and repeating 'any_event'. Below is a straigt forward AQL on this 
archetype. We are asking for the origin from the HISTORY attribute, and then 
for each repeating event we want the weight magnitude and unit.
As you see from the AQL there is an additional WHERE clausul telling that we 
only want weight with magnitude less than 45.
The question is: What do you expect as result from this query?
select
        o/data[at0002]/origin/value as time,
        
o/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value/magnitude as 
Weight,
        o/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value/units as 
Unit
    from
        composition c
    contains
        observation o[openEHR-EHR-OBSERVATION.body_weight.v1]
    where
        
o/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value/magnitude < 45
    order by
        o/data[at0002]/origin/value desc


Vennlig hilsen
Bjørn Næss
Produktansvarlig
DIPS ASA

Mobil +47 93 43 29 10<tel:+47%2093%2043%2029%2010>


_______________________________________________
openEHR-implementers mailing list
openEHR-implementers@lists.openehr.org<mailto:openEHR-implementers@lists.openehr.org>
http://lists.openehr.org/mailman/listinfo/openehr-implementers_lists.openehr.org



--
Ing. Pablo Pazos Gutiérrez
Cel:(00598) 99 043 145
Skype: cabolabs

[https://docs.google.com/uc?export=download&id=0B27lX-sxkymfdEdPLVI5UTZuZlU&revid=0B27lX-sxkymfcUwzT0N2RUs3bGU2UUovakc4VXBxWFZ6OXNnPQ]<http://cabolabs.com/>
http://www.cabolabs.com<http://www.cabolabs.com/>
pablo.pa...@cabolabs.com<mailto:pablo.pa...@cabolabs.com>
Subscribe to our newsletter<http://eepurl.com/b_w_tj>


_______________________________________________
openEHR-implementers mailing list
openEHR-implementers@lists.openehr.org
http://lists.openehr.org/mailman/listinfo/openehr-implementers_lists.openehr.org

Reply via email to