# AQL type predicate **Category:** [AQL](https://discourse.openehr.org/c/aql/43) **Created:** 2020-03-19 06:03 UTC **Views:** 421 **Replies:** 3 **URL:** https://discourse.openehr.org/t/aql-type-predicate/487 --- ## Post #1 by @matijap Our EHR Server end-user consultants report that sometimes filtering by object type would be useful in AQL. As an example they point out laboratory results where archetypes and templates allow for many data-value types at the leaf level, and sometimes a query might want to only include DV_QUANTITYs and DV_SCALEs. They propose a solution in a sense of adding an implicit attribute `@class` which could be used like this: `myResult/@class MATCHES {"DV_QUANTITY","DV_SCALE"}`. I must say I prefer a solution that was mentioned in passing in the https://discourse.openehr.org/t/safety-features-in-aql-subject/137 topic, which is a function that would also take inheritance into account: `is_type(myResult, "DV_QUANTITY") OR is_type(myResult, "DV_SCALE")`. We have a habit of "move fast and break standardisation" due to market forces, so at this point I'm not pushing for any de-iure solution; I'd just like to check with other implementors, particularly @bna, if anyone already has such a functionality and what their syntax is; and if nobody has this, what syntax do others prefer. --- ## Post #2 by @sebastian.iancu I generally prefer functions over language construct, so better is_type(). --- ## Post #3 by @ian.mcnicoll I hate to complicate this discussion but there possibly is a reverse use-case around 'casting' when commiting data (or in expressions) particularly with stringified / falt data formats. e.g. where there is a choice of datatypes that can be committed how can we make sure the correct datatype is populated - I guess this is 'casting' - Better's flat format supports this but a litlle clunky IMO (sorry @Matija!1). I guess just to bear in mind that there are 2 sides to the issue of datatype choices - might be good to be coherent in our approach. --- ## Post #4 by @matijap BTW, we had this in the spec already, but it is in process of being removed, because no-one implemented it: https://openehr.atlassian.net/wiki/spaces/spec/pages/429129741/AQL%2Busing%2Bmatches%2Bto%2Bmatch%2BRM%2Bclasses%2Bdiscussion We must re-discuss whether to use that syntax or any other. --- **Canonical:** https://discourse.openehr.org/t/aql-type-predicate/487 **Original content:** https://discourse.openehr.org/t/aql-type-predicate/487