ESCG queries

Overview

Snow Owl includes an editor and execution environment for Extended SNOMED Compositional Grammar (ESCG) expressions. All of the operators and grammar constructs are supported as defined in the NHS LRA specification, which is itself an extension of the HL7 TermInfo specification. Using ESCG expressions you can query concepts by their relationships, as opposed to their human readable descriptions. Please see the B2i samples (in the Project explorer) included with Snow Owl for some examples of ESCG expressions.

Project explorer view

The Project explorer view displays the contents of your local workspace folder. It is organized in projects, which in turn contain files and subfolders. Files that end with .escg are used to create semantic queries. Double-click a file to open the ESCG editor.

Project explorer with escg files

ESCG expression editor

ESCG expressions can be created and edited in a separate editor. This standalone ESCG expression editor, allows you to save queries for later reuse. You can open the editor from the project explorer view.

ESCG expression editor

Embedded ESCG editor

You can also create an expression in the ESCG Query tab of the Advanced search dialog to perform a quick lookup. The embedded editor in the Search dialog supports the same features as the standalone expression editor (as discussed in the following sections), however, it is not possible to save expressions for later reuse.

Embedded ESCG editor

Creating a project and an ESCG file

Before you can run ESCG queries, you need to create a project for your escg file:

Opening the New Project wizard

Specifying the project name

You can see the new project folder now in the project explorer view.

Once you created a project, you are ready to add escg files:

Project Explorer view with projects and files

Project Explorer view with projects and files

It's also possible to organize your files in subfolders: right-click on the project folder and select New > Folder from the context menu to create a new subfolder. You can move files by dragging them to a different location.

Writing a query

ESCG operators

For a step by step introduction about writing ESCG queries please refer to the Do you speak ESCG? section of the Getting Started Guide.

Operator Function
<< Retrieves the concept and all of its subtypes
< Retrieves all subtypes of this concept, but not the concept itself
|text| Displays Preferred term of the concept to aid readability
^ Retrieves all the members of this reference set
+ Retrieves only concepts that are results of both expressions (intersection)
UNION Combines the result set of two queries
!^ Excludes members of this reference set
!<< Excludes this concept and all of its subtypes
!< Excludes this concept's subtypes
= Defines an attribute refinement, e.g. a finding site or a causative agent
: Refines an attribute range, operator is used in combination with an attribute
AND Used to express intersections of attribute ranges
OR Used to express unions of attribute ranges

<< Retrieves the concept and all of its subtypes

<<138875005|SNOMED CT Concept|

< Retrieves all subtypes of this concept, but not the concept itself

<138875005|SNOMED CT Concept|

|text| Include preferred term or description to aid readability

|SNOMED CT Concept|

^ Retrieves all the members of this reference set

^152725851000154106|Cardiology reference set|

+ Retrieves only concepts that are results of both expressions (intersection)

<404684003|Clinical finding| + ^152725851000154106|Cardiology reference set|

UNION Combines the result set of two queries

<<64572001|Disease| UNION <<71388002|Procedure|

!^ Excludes members of this reference set

!^447564002|Non-human simple reference set|

!<< Excludes this concept and all of its subtypes

!<<64572001|Disease|

!< Excludes this concept's subtypes

!<64572001|Disease|

= Defines an attribute refinement, e.g. a finding site or a causative agent

363698007|Finding site| = <<113257007|Structure of cardiovascular system|

: Refines an attribute range, operator is used in combination with an attribute

<404684003|Clinical finding| :
    363698007|Finding site| = <<113257007|Structure of cardiovascular system|

AND Used to express intersections of attribute ranges

<<404684003|Clinical finding|:
    116676008 |Associated morphology| = <<56208002|Ulcer| AND <<23583003|Inflammation|

OR Used to express unions of attribute ranges

<<404684003|Clinical finding|:
    116676008|Associated morphology| =<< 56208002|Ulcer| OR <<118622000|Fistula|

Editing features

Quick fix

Queries are validated continuously as you enter the expression. Errors are indicated with red squiggly lines underneath the erroneous parts of the expression, as well as a red error marker on left margin of the editor. Warnings are shown with yellow squiggly lines and an exclamation mark on the left margin of the editor. By clicking on the quick-fix icon on the margin of the editor, the incorrect id can be easily fixed by picking the correct id or description from the SNOMED store.

Validation and quick fix for incorrect concept
Note: Quick fix is disabled in the embedded editor in the search dialog.

Content assist

You can enter an expression with the help of the content assist. At any point during entering a query, the content assist can be invoked by hitting Ctrl + Space. When content assist is invoked, the user can pick from different valid selections depending on the current position of the cursor. It wil also allow you to add pre-configured concepts and templates.

Content assist in the ESCG editor

Templates preference page

The content assist already contains pre-configured concepts and templates that can be edited on the templates preference page at Snow Owl > Preferences > ESCG Editor > Templates. It's also possible to create new templates there and add them to the content assist by checking the box. Unchecked templates will not be displayed in the content assist. As with other components, content assist will only display templates that are valid at the particular point of the expression where the cursor is.

ESCG editor templates preference page

Coloring, formatting and hyperlinking

The expression text is colored based on the syntax to make it more readable. These are default settings

Syntax coloring can be customized at the respective preference page with is accessible via the main menu File > Preferences > Snow Owl > ESCG Editor > Syntax Coloring.

Customizing the ESCG syntax coloring

Long strings of text can be formatted by right-clicking on the editor and selecting the Format menu item or by pressing the Ctrl-Shift-F key combination. This will break up the text in several lines making it easier to read. Sections with three lines or longer can be expanded or collapsed by clicking on the nodes at the margin of the editor.

Any concept (id and description) within the ESCG expression can act as a hyperlink if you hold down the Ctrl ( Command on Mac OS X) key and hover over a concept. Clicking on the hyperlink reveals the concept in the SNOMED CT Concepts view and opens it in an editor.

Concept drag and drop

Snow Owl concepts can now be dragged and dropped (or copied and pasted) into other documents, providing the concept ID and preferred term. If the target editor supports rich formatting, the standard ESCG color format will be included.

Dragging a concept to a PowerPoint presentation

Dropping the concept inserts the code and preferred term

Executing a query

Click on the Execute ESCG query button in the main toolbar to execute the expression in the currently active ESCG editor; the results can be reviewed in the Search view. Even for large result sets (over 100.000 results) the query evaluation returns in a fraction of a second.

ESCG editor and toolbar button to execute query

If you are using the embedded expression editor in the Advanced search dialog, click on the Search button to perform the search.

Embedded expression editor