Behaviour of logical operators(OR, AND, NOT) in FROM Clause

I am working on aql query to get different composition for an ehr.
Query 1 : "SELECT c1, c2 FROM EHR e[ehr_id/value=‘3fb5117e-dba9-40d1-b472-d575f0a341ae’] CONTAINS (COMPOSITION c1[openEHR-EHR-COMPOSITION.encounter.v0] AND COMPOSITION c2[openEHR-EHR-COMPOSITION.encounter.v1]) "
I want to know how this above query will execute and in place of AND operator if it is OR then what would be result.
Query 2 : “SELECT c FROM EHR e[ehr_id/value=‘3fb5117e-dba9-40d1-b472-d575f0a341ae’] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] CONTAINS OBSERVATION o[openEHR-EHR-OBSERVATION.rough.v1] WHERE o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/value=‘10’”
Query 3 : “SELECT c FROM EHR e[ehr_id/value=‘3fb5117e-dba9-40d1-b472-d575f0a341ae’] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v0] CONTAINS OBSERVATION o[openEHR-EHR-OBSERVATION.address.v0] WHERE o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/value = ‘xyz’”
Query 4 : "SELECT c1, c2 FROM EHR e[ehr_id/value=‘3fb5117e-dba9-40d1-b472-d575f0a341ae’] CONTAINS (COMPOSITION c1[openEHR-EHR-COMPOSITION.encounter.v0] CONTAINS OBSERVATION o1[openEHR-EHR-OBSERVATION.address.v0]) AND (COMPOSITION c2[openEHR-EHR-COMPOSITION.encounter.v1] CONTAINS OBSERVATION o2[openEHR-EHR-OBSERVATION.rough.v1]) "

In Query 2 and Query 3, I am getting 1 as list size of RECORD1 in both the queries but getting zero as list size of RECORD2 in Query 4 and in Query 1 getting 2 as list size How? Want to know how exactly AND, OR, () works in CONTAINS

Query 5 : "SELECT c1, c2 FROM EHR e[ehr_id/value=‘3fb5117e-dba9-40d1-b472-d575f0a341ae’] CONTAINS COMPOSITION c1[openEHR-EHR-COMPOSITION.encounter.v0] NOT CONTAINS COMPOSITION c2[openEHR-EHR-COMPOSITION.encounter.v1] "

Query 5 throws : Got: 400. Error message: {“error”:“Could not process query, reason:org.antlr.v4.runtime.misc.ParseCancellationException: AQL Parse exception: line 1: char 140 mismatched input ‘NOT’ expecting {, WHERE, ORDERBY, OFFSET, LIMIT}”,“status”:“Bad Request”}

I can only comment about Query 5: my assumption is that the AQL engine you are using did not implemented yet the newly AQL Release-1.1.0, which introduced support for NOT CONTAINS ( SPECQUERY-7 ).

Hi Roshan,

Could you perhaps post a link to the template you are using and a some sample compositions?

Also what CDR are you using? As @sebastian.iancu says the NOT CONTAINS is fairly new and may not be supported by all CDRs yet.

Looks like EHRbase, I will check with @christian about the status of this one. My guess is that we don’t support it at the moment.

Thank you for your response and i appreciate the attention you are giving to this issue.

Thanks for your response. I want to know what are the other alternatives we can use for the same NOT CONTAINS.
for this query "SELECT c1, c2 FROM EHR e[ehr_id/value=‘3fb5117e-dba9-40d1-b472-d575f0a341ae’] CONTAINS COMPOSITION c1[openEHR-EHR-COMPOSITION.encounter.v0] NOT CONTAINS COMPOSITION c2[openEHR-EHR-COMPOSITION.encounter.v1] "