# Using matches operator in AQL **Category:** [AQL](https://discourse.openehr.org/c/aql/43) **Created:** 2022-04-25 12:10 UTC **Views:** 566 **Replies:** 1 **URL:** https://discourse.openehr.org/t/using-matches-operator-in-aql/2547 --- ## Post #1 by @thomas.beale To date, the use of the [matches operator in AQL](https://specifications.openehr.org/releases/QUERY/latest/AQL.html#_matches) has been limited to: * primitive value matching * URI matching * special functions like `TERMINOLOGY()` However, we could use AQL matching in a generalised ADL mode, which pretty much replicates what GraphQL does, but better. Here's an example that I can parse with my current EL parser. We can ignore the `val :=` at the start, it's just for testing. The `baby_weight` and `age` are assumed to be bound to archetype paths. So the part coming after `val :=` could be an AQL WHERE condition. ``` val := baby_weight ∈ { DV_QUANTITY ∈ { [units, magnitude] ∈ { [{"kg"}, {|<1.2|}], [{"g"}, {|<1200|}], [{"lb"}, {|<2.5|}], [{"oz"}, {|<40|}] } } } OR age ∈ {|<-P2M|} ``` There are some differences from strict ADL, mainly that node identifiers need to be optional. See [here for the Antlr grammar for cADL matcher objects](https://github.com/wolandscat/openEHR-antlr4/blob/master/combined/src/main/antlr/Cadl2Parser.g4#L108) (allowing optional node ids). [Here is where it connects into the EL grammar](https://github.com/wolandscat/openEHR-antlr4/blob/master/combined/src/main/antlr/ElParser.g4#L106). --- ## Post #2 by @joostholslag Cool. It makes me dream about trial inclusion and exclusion criteria expressed and published as AQL statements. --- **Canonical:** https://discourse.openehr.org/t/using-matches-operator-in-aql/2547 **Original content:** https://discourse.openehr.org/t/using-matches-operator-in-aql/2547