AQL on folder

The latest develop of ehrbase (PR CDR-1580 Add Basic AQL on FOLDER support by alexlehn · Pull Request #1401 · ehrbase/ehrbase · GitHub) now supports AQL on folder (which are in the directory of the ehr).

Thus Queries of the form

SELECT 
  e/ehr_id/value,
  f/uid/value,
  f/name/value,
  c/uid/value 
FROM EHR e 
    CONTAINS FOLDER f[openEHR-EHR-FOLDER.generic.v1] 
      CONTAINS COMPOSITION c

now work.

Note since this is an experimental feature this is beyond a feature flag :

ehrbase:
  rest:
    experimental:
      aql-on-folder:
        enabled: true
EHRBASE_REST_EXPERIMENTAL_AQLONFOLDER_ENABLED=true

For the full set of capabilities see conformance-testing-documentation/FOLDER.md at main · ehrbase/conformance-testing-documentation · GitHub

6 Likes

This is a nice addition! I would suggest promoting it to an AQL jira ticket, so that we can consider standardizing it (work for AQL WG).
Further question(s):

  • can you have nested contains folder ?
  • Can you also use the name of the folder as predicate?
  • Can you retrieve as column folder data (from other details)?
  • Have you already adjusted the aql grammar for this?
1 Like

Small correction, it’s now ehrbase.aql.experimental.aql-on-folder.enabled.

ehrbase:
  aql:
    experimental:
      aql-on-folder:
        enabled: true
EHRBASE_AQL_EXPERIMENTAL_AQLONFOLDER_ENABLED=true

@sebastian.iancu the conformance testing maybe answers some of your questions

1 Like

@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]