# Top and Bottom

In this section we illustrate how a set of concepts can be filtered, using the top or bottom operators, to find the concepts that are the highest or lowest in the hierarchy within the set.

## Top of set <img src="https://3640641338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FII4UamWvktPWCBllaB8T%2Fuploads%2FJfpNqGUnAT2xlyNipAjt%2FScreenshot%202025-09-24%20at%2017.38.47.png?alt=media&#x26;token=af8d521d-387c-4d78-9814-e5e3a4f1eee7" alt="Included in ECL Core" data-size="line">

Two consecutive exclamation marks followed by a 'greater than' sign (i.e. "!!>") indicates that the expression constraint is satisfied by the concepts from the results of the subexpression that have the highest position in the hierarchy, relative to one another. In other words the set of concepts, that is the result of the subexpression, will be filtered by concepts that have no ancestors within that set.

For example the following expression constraint represents the highest, or most general, concepts in the hierarchy within the set of [363698007 | Finding sites|](http://snomed.info/id/363698007) from the subtypes of [386617003 | Digestive system finding|](http://snomed.info/id/386617003) .

{% tabs %}
{% tab title="Brief syntax" %}
{% code overflow="wrap" %}

```
!!> ( < 386617003 |Digestive system finding| . 363698007 |Finding site| )
```

{% endcode %}
{% endtab %}

{% tab title="Long syntax" %}
{% code overflow="wrap" %}

```
top ( < 386617003 |Digestive system finding| . 363698007 |Finding site| )
```

{% endcode %}
{% endtab %}
{% endtabs %}

An equivalent expression constraint without using the top operator can be written:

```
( < 386617003 |Digestive system finding| . 363698007 |Finding site| )
MINUS < ( < 386617003 |Digestive system finding| . 363698007 |Finding site| )
```

## Bottom of set <img src="https://3640641338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FII4UamWvktPWCBllaB8T%2Fuploads%2FJfpNqGUnAT2xlyNipAjt%2FScreenshot%202025-09-24%20at%2017.38.47.png?alt=media&#x26;token=af8d521d-387c-4d78-9814-e5e3a4f1eee7" alt="Included in ECL Core" data-size="line">

Two consecutive exclamation marks followed by a 'less than' sign (i.e. "!!<") indicates that the expression constraint is satisfied by all concepts from the results of the subexpression that have the lowest position in the hierarchy, relative to one another. In other words the set of concepts, that is the result of the subexpression, will be filtered by concepts that have no descendants within that set.

For example, the following expression constraint represents the lowest, or most specific, concepts in the hierarchy within the set of concepts that are both ancestor-and-self of [427089005 | Diabetes mellitus due to cystic fibrosis|](http://snomed.info/id/427089005) and also within the [816080008 | International Patient Summary|](http://snomed.info/id/816080008) reference set:

{% tabs %}
{% tab title="Brief syntax" %}
{% code overflow="wrap" %}

```
!!< ( >> 427089005 |Diabetes mellitus due to cystic fibrosis| AND ^ 816080008 |International Patient Summary| )
```

{% endcode %}
{% endtab %}

{% tab title="Long syntax" %}
{% code overflow="wrap" %}

```
bottom ( >> 427089005 |Diabetes mellitus due to cystic fibrosis| AND ^ 816080008 |International Patient Summary| )
```

{% endcode %}
{% endtab %}
{% endtabs %}

An equivalent expression constraint without using the bottom operator would be:

{% code overflow="wrap" %}

```
( >> 427089005 |Diabetes mellitus due to cystic fibrosis| AND ^ 816080008 |International Patient Summary| ) MINUS > ( >> 427089005 |Diabetes mellitus due to cystic fibrosis| AND ^ 816080008 |International Patient Summary| )
```

{% endcode %}

## Use Case Examples

Here are use cases that illustrate how the top and bottom operators may be used in practice:

### Use Cases for Bottom

Not all clinical information systems use the same set of SNOMED CT concepts, for various reasons; many countries use their own national editions, countries without a national license may use a SNOMED CT freeset, national guidelines may dictate information model bindings that constrain the set of concepts used.

There are scenarios where it may be necessary to transform clinical records from one information system to another. For example a cross-border research project. If the source system has a broader or different set of concepts than the target system can use then a common strategy is to walk up the hierarchy to find the first common ancestor that is shared by both systems.

One example is development and use of value sets for cross-border sharing, as in MyHealth\@EU, where not all participants have a SNOMED CT Affiliate License. The countries who are a member would like to use and share full-SNOMED value sets whereas non-members should only use concepts from the SNOMED CT free-set.

Another example is the NHS Emergency Care Data Set. This is a collection of UK nationally defined subsets for use in a specific context. The bottom operator could be used to transform a specific concept like [45133009 | Neurotoxic shellfish poisoning|](http://snomed.info/id/45133009) into a less specific concept that is within the [991411000000109 | Emergency care diagnosis simple reference set|](http://snomed.info/id/991411000000109) :

{% code overflow="wrap" %}

```
!!< ( >> 45133009 |Neurotoxic shellfish poisoning| AND ^ 991411000000109 |Emergency care diagnosis simple reference set| )
```

{% endcode %}

This would result in the set of concepts: [118940003 | Disorder of nervous system|](http://snomed.info/id/118940003) and [75258004 | Food poisoning|](http://snomed.info/id/75258004) .

***

<a href="https://docs.google.com/forms/d/e/1FAIpQLScTmbZIf0UEQwYDkY27EEWBkaiYkHSbR0_9DmFrMLXoQLyL7Q/viewform?usp=pp_url&#x26;entry.1767247133=ECL+Specification&#x26;entry.670899847=Top%20and%20Bottom" class="button primary">Provide Feedback</a>
