@sebastian.iancu
The AQL grammar doesn’t restrict which Subclasses of Locatable is usable in FROM and CONTAINS and thus FOLDER is already covered from a grammar standpoint.
So you can select any json attribute via its AQL path including details and use it in SELECT,WHERE or ORDER BY
For the contains logic it works the same way as CLUSTER contains CLUSTER
So FROM EHR CONTAINS FOLDER f1[openEHR-EHR-FOLDER.generic.v1,'root1'] CONTAINS FOLDER f2 [openEHR-EHR-FOLDER.episode_of_care.v1,'subsubfolder1']
is defined and means that in the (JSON) Tree starting from EHR. directory
there exist
node with
_type = FOLDER
name/value = 'root1'
archetype_node_id = 'openEHR-EHR-FOLDER.generic.v1'
and
in the (JSON) sub-tree starting from the above node contains a node with
_type = FOLDER
name/value = 'subsubfolder1'
archetype_node_id = 'openEHR-EHR-FOLDER.episode_of_care.v1'
Also like EHR and EHR_STATUS we treat certain OBJECT_REF as being the Object itself.
So FOLDER.items
is treated as contains the COMPOSITIONS and not just Object refs concerning CONTAINS
Thus FROM EHR CONTAINS FOLDER f1[openEHR-EHR-FOLDER.generic.v1,'root1'] CONTAINS COMPOSITION CONTAINS OBSERVATION [openEHR-EHR-OBSERVATION.blood_pressure.v1]
means that in the (JSON) Tree starting from EHR. directory
there exist
node with
_type = FOLDER
name/value = 'root1'
archetype_node_id = 'openEHR-EHR-FOLDER.generic.v1'
and
the (JSON) sub-tree stating von the node above contains
(after replacing FOLDER.items with the corresponding compositions) a node of type=COMPOSITION
and the (JSON) subtree starting von this node contains a Node with
type=OBSERVATION
archetype_node_id = openEHR-EHR-OBSERVATION.blood_pressure.v1
Note that an OBSERVATION is always contained in a COMPOSITION so we could have written the above as
FROM EHR CONTAINS FOLDER f1[openEHR-EHR-FOLDER.generic.v1,'root1'] CONTAINS OBSERVATION [openEHR-EHR-OBSERVATION.blood_pressure.v1]