These pages describe the IM Query grammar conventions and meanding. The formal IMQ Grammar can be accessed in ABNF form at https://github.com/endeavourhealth-discovery/IMDirectory/blob/develop/im_library/src/antlr4/grammars/ECL.g4
Symbol conventions
A small set of symbols are used to represent meaningful language tokens. These are:
- '{' and '}' Used for clauses to differentiate the content from other similar clauses, as well as to indicate graph traversal. It is used in the same way as { } is used in Json to represent and object. For example 'where {age >75 units : years} encloses a where clause
- ',' comma used to indicate a list entry number 2 or more. the language does not require brackets to show a list. For example
where { :concept in sct:29857009,sct:25064002 } means that the in predicate is looking at a list of two concepts
- '@' used as an identifier qualifier to indicate a type. @im:Concept indicates that this refers to instances of type im:concept .For example:
from { @:Patient} means that the query is looking for all instances of type patient.
- '^' used as an identifier qualifier to indicate a set. For example:
from { ^ex:RegisteredPatients} means the set of registered patients, used mostly in referencing base populations or value /reference sets
- << subsumption qualifier used to indicate descendants or Self of against an identifier for example
where { :concept in <<sct:29857009} means the Snomed-CT concept identifier of 29857009 and any of its subtypes.
- '<' used to indicate 'descendants of but not including self' against an identifier. For example
where { :concept in <sct:29857009} would mean its subtypes but not itself
- '>>' used to indicate 'Ancestors of including self; against an identifier . For example
where { :concept in >>sct:29857009} would mean all concepts that are ancestors of chest pain
- '|' '|' used as a short cut to indicate the name of a concept or entity sct:29857009|Chest pain |
Identifiers
Query definitions include reference to a data model types, properties, concepts or sets. Identifiers are represented as RDF IRIs in both the full or prefixed form. For example:
http://snomed.info/sct# and sct: 29857009 may be equivalent where the query contains a prefix list
Boolean operators
The boolean operators 'and' , 'or' and 'not' can operate in either the from or where clause, using a "bool" predicate. 'and' is the same as an intersection (all must be true), or is a union (at least one true) and 'not' is a union of negation (any one must be false). Further nesting can resolve boolean combinations (e.g. not/and) Example boolean operators:
Plain | Json |
---|---|
where {
{: age>- 18 units: years} and {:statedGender is :905031000252103|Male|} } |
{"where" : {
"bool" : "and",
"where" : [ { "id" : "age",
"operator" : ">=",
"value" : 18,
"unit" : "year"},
{"id" : "statedGender",
"in" : [ {"@id" : "im:905031000252103",
"name" : "Male (stated gender)" } ] } ] }
|