# AQL query to archetype and it's specializations in slot **Category:** [Clinical (archive)](https://discourse.openehr.org/c/clinical-archive/153) **Created:** 2010-06-28 03:59 UTC **Views:** 1 **Replies:** 1 **URL:** https://discourse.openehr.org/t/aql-query-to-archetype-and-its-specializations-in-slot/14581 --- ## Post #1 by @user3 Hi! I have an archetype 'A' with slot named 'Slot In A'. There is constraint for possible archetypes for this slot: "B and specializations of B". I know that in archetype B (and in all of it's specializations) there is field 'at0003' named 'Field In B' I know only about B and particular clients has their own independent specializations 'B-spec'. Now I want to build a query like this: ...[openEHR-EHR-CLUSTER.a.v1] /items[openEHR-EHR-CLUSTER.b.v1] / items[at0003]/value And I want something like "Archetype of this type and it's specializations" instead of just this "items[openEHR-EHR-CLUSTER.b.v1]". The question is: how :-) --- ## Post #2 by @system Hi Igor, AQL allows string RegEx pattern in an archetype predicate. RegEx pattern needs to be enclosed by ‘{/’ RegEx ‘/}’. For your scenario, the AQL may include something like: ...[openEHR-EHR-CLUSTER.a.v1] /items[{/openEHR-EHR-CLUSTER\.b(-[a-zA-Z0-9])*\.v1/}] / items[at0003]/value Or something like the one below. The expression below is for retrieving both element [at0003] instance value and the specialization of this element if the specialized archetype has specialization of element at0003 (such as at0003.1): ...[openEHR-EHR-CLUSTER.a.v1] /items[{/openEHR-EHR-CLUSTER\.b(-[a-zA-Z0-9])*\.v1/}] / items[{/at0003([0-9.]+)*/}]/value Hope this helps. Please let me know if you have more questions. Regards, Chunlan --- **Canonical:** https://discourse.openehr.org/t/aql-query-to-archetype-and-its-specializations-in-slot/14581 **Original content:** https://discourse.openehr.org/t/aql-query-to-archetype-and-its-specializations-in-slot/14581