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> 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 <+47%2093%2043%2029%2010>
>
>
>
> _______________________________________________
> openEHR-implementers mailing list
> 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
<http://cabolabs.com/>
http://www.cabolabs.com
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