AQL-parser in Java? + AQL response format (using the AS operator)

Hi!

1. Has anybody planned, or started, to create an AQL-parser in Java?

Maybe the basics from AQL to parse tree could be common for several
different persistence implementations and then the rest of the
implementation will be different for different persistence mechanisms.

Our first interest will be in transforming AQL queries to queries
against an XML-database containing versioned Compositions. (It's for
an educational system where performance isn't crucial.)

2. Are there any suggestions for standardised response formats? It
would be interesting if we could query each others' implementations
(Python and various Java based ones) and interpret the response :slight_smile:

When returning entire openEHR subtrees (an entire Composition or Entry
for example) I guess the current XML-format could be used to start
with. The response is likely to often be a list of such subtrees and
the format of that list Would need to be standardised.

Another case is when using the AS operator, how do we in a
standardised way identify the named parts.

Best regards,
Erik Sundvall
erisu@imt.liu.se http://www.imt.liu.se/~erisu/ Tel: +46-13-227579

Hi Eric,

I suggest that you read the Extract Information Model document.
Though it still needs some vetting, this should answer many of your
questions.

Regards,
Tim

Hi Tim & Erik,
Actually there are two means of querying data from an EHR, one is certainly
using EHR_EXTRACTs where the extract contains complete versioned
COMPOSITIONs. This is more intended to be used to exchange content between
EHR systems.

The other is a more interactive mode where an application associated with a
particular EHR system is making service calls to the system requesting data
at different levels in the RM. AQL allows you to retrieve content at any
level of the RM, a COMPOSITION, ENTRY, ELEMENT, DATA_VALUE or even a
primitive type such as the QUANTITY.magnitude double.

Therefore, there does need to be a container for these collection of
objects. We have implemented a RESULT_SET that contains a list of
RESULT_ROWs which contains a list items of type ANY. The RESULT_SET also
provides a list of RESULT_COLUMNs that provides details of the column name
and path.

I think this kind of class is likely to be specified as part of the service
model.

Heath

From: openehr-technical-bounces@openehr.org [mailto:openehr-technical-
bounces@openehr.org] On Behalf Of Tim Cook
Sent: Tuesday, 30 September 2008 9:31 PM
To: erisu@imt.liu.se; For openEHR technical discussions
Subject: Re: AQL-parser in Java? + AQL response format (using the AS

operator)

As to make the naming less 'relational'-centric, it sounds to me that
RESULT_ROWs could be just named RESULTs and RESULT_COLUMN something like
RESULT_METADATA.

Roger

Hi Erik,
Response to 2, the Ocean EhrGate Web Service provides a ResultSet as defined
in the following WSDAL fragment:

    <xs:complexType name="ResultSet">
        <xs:sequence>
            <xs:element minOccurs="0" name="name" type="xs:string" />
            <xs:element name="totalResults" type="xs:int" />
            <xs:element minOccurs="0" maxOccurs="unbounded" name="columns"
nillable="true">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="path"
type="xs:string" />
                        <xs:element minOccurs="0" name="name"
type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element minOccurs="0" name="rows">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" maxOccurs="unbounded"
name="row">
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:element minOccurs="0"
maxOccurs="unbounded" name="items" nillable="true" />
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

I am very interested in the idea of basing a query result class on the
ITEM_TABLE class for consistency reasons, however ITEM_TABLE cannot be used
directly because it is limited to rows of ELEMENTs. A query result class
needs to support rows of ANY items as is the case above.

In addition, it may also be necessary to have a query result class that is
based on the ITEM_TREE class to support more complex hierarchical query
results that are difficult to unambiguously represent using a traditional
table structure, which requires cross-join logic to be applied as mentioned
recently (sorry we have not had time to respond to that post, day-job
priorities).

Heath

Sorry, I didn't realise when I responded to this that it was such an old
post (having email management problems). Anyway, it seems to be current hot
topic so it probably won't go to waste.

Heath

Hi!

Response to 2, the Ocean EhrGate Web Service provides a ResultSet as defined
in the following WSDAL fragment:
<xs:complexType name="ResultSet">

...
Thanks, I know the service interface and WSDL for Ocean EhrGate [1a,b]
since we got Ocean's permission to use it in an experimental research
application [2] I created. (For those not familiar with EhrGate an
example AQL query and response is provided further down after my
"signature" in this mail.)

Sorry, I didn't realise when I responded to this that it was such an old
post

No problem, I'm glad the topic comes to life again since we still
should resolve it. I think it would be wonderful to have standardised
AQL response formats for e.g. XML and JSON. The usecase I am thinking
of is not the "EHR extract exchange" but rather the ability for e.g a
GUI implementation to be used with any future AQL-capable persistence
implementation (PatientOS, OSHIP, Zilics, Ocean, LiU and others
maybe?).

By the way, does AQL cater for querying CONTRIBUTIONS and FOLDERS too?

We (LiU) are working on a REST-based [3] service implementation that
we'll contribute as an inspiration for an official specification when
we have tested it. I guess the Ocean EhrGate implementation could be
an inspiration for an official SOAP based service specification. No
matter if an implementer wants to go for SOAP or REST the XML response
format could be the same (except that it in the SOAP response will be
wrapped in some extra SOAPy-envelope XML that a REST based response
won't need). It is the response format (without SOAP envelope) that
I'd be interested in further discussions about.

I am very interested in the idea of basing a query result class on the
ITEM_TABLE class

...

In addition, it may also be necessary to have a query result class that is
based on the ITEM_TREE class to support more complex hierarchical query
results

...

W3C has specified a response format [4] for SPARQL queries that I
think could be used as an inspiration for an AQL-response
specification. Interested readers, please have a look at it and give
some feedback.

I have not managed to figure out how to get the result of using the
"AS" operator in AQL-queries visible in the result from EhrGate, the
"variable binding" approach in [4] might be useful in AQL responses.
In the case where AS has not been used then the path expression used
(e.g. c/context/start_time) could be returned as variable name.

So let's discuss a bit an then make a draft specification for XML
based AQL-responses :slight_smile: (JSON- and YAML-based response specifications
can follow later...)

References:
[1a] http://demo.oceanehr.com/EhrBank14/EhrService.asmx
[1b] http://demo.oceanehr.com/EhrBank14/EhrService.asmx?WSDL
[2] http://www.imt.liu.se/~erisu/2008/ehrbank/EHRBankTool.html
[3] http://en.wikipedia.org/wiki/REST
[4] http://www.w3.org/TR/rdf-sparql-XMLres/

Best regards,
Erik Sundvall
erisu@imt.liu.se http://www.imt.liu.se/~erisu/ Tel: +46-13-227579

This query used in [2] connected to [1]...

SELECT c/context/start_time , c/name AS my_variable, c/composer/name,
v/uid/value FROM EHR[uid='fe619372-25ed-4549-a108-6ddbd92a96a7']
CONTAINS VERSION v CONTAINS COMPOSITION c WHERE
c/category/defining_code/code_string='433'

..will get a response like this (don't worry, this is a fake patient)...

<RetreiveResultsResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot;
xmlns="http://www.oceaninformatics.biz/OceanEhr/EhrBank/EhrService&quot;
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
  <RetreiveResultsResult>
    <TotalResults>35</TotalResults>
    <Rows>
      <ResultRow>
        <Items>
          <anyType xsi:type="q1:DV_DATE_TIME"
xmlns:q1="http://schemas.openehr.org/v1&quot;&gt;
            <q1:value>2006-12-05T13:51:55</q1:value>
          </anyType>
          <anyType xsi:type="q2:DV_TEXT"
xmlns:q2="http://schemas.openehr.org/v1&quot;&gt;
            <q2:value>Blood Glucose</q2:value>
          </anyType>
          <anyType xsi:type="xsd:string">EhrGateUnit</anyType>
          <anyType
xsi:type="xsd:string">05c0762d-2044-4ce6-a6f3-f7bb959cda63::10aec661-5458-4ff6-8e63-c2265537196d::1</anyType>
        </Items>
      </ResultRow>

[...other results removed from example...]

    </Rows>
  </RetreiveResultsResult>
</RetreiveResultsResponse>

From: openehr-technical-bounces@openehr.org
[mailto:openehr-technical-bounces@openehr.org] On Behalf Of Erik Sundvall
Sent: Tuesday, September 30, 2008 6:35 PM
To: For openEHR technical discussions
Subject: AQL-parser in Java? + AQL response format (using the AS operator)

...