# Authoring

{% hint style="info" %}
To enter editing mode and access functionalities related to authoring, click on the![](https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/a4sNkyE83ywWOkbyTvsS/edit_button.png) button in the upper right corner of the selected Value Set's content page.
{% endhint %}

## Add a New Clause

New clauses can be added by constructing a query expression supported by the domain Code System after clicking on the area surrounded by an intermittent line under the *Inclusions* and *Exclusions* sections.

{% hint style="info" %}
Most of the terminologies support Expression Constraint Language to a certain extent, e.g. selecting a hierarchy via < or << or filter by attribute refinements. If such support is not available for the given Code System, then single ID inclusions/exclusions can be created forming an extensional Value Set at the end.
{% endhint %}

![Create a New Clause](https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/dG3hRvZdmU6ngotaUnU5/value_set_add_new_clause.gif)

{% hint style="info" %}
While authoring, clauses highlight parts of the hierarchy with colors. These help identify which part of the hierarchy is included (green and/or normal gray), excluded (red), suggested (purple), or just displayed (light gray) for contextual information.

If selecting a concept from the terminology tree the clause that involves the concept will be highlighted.
{% endhint %}

![Highlight Clauses](https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/3nkSug7bF9gQml7f1KNP/value_set_highlight_clauses.gif)

There are different ways to add clauses to a Value Set. For more information visit the following pages:

{% content-ref url="authoring/dnd" %}
[dnd](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/authoring/dnd)
{% endcontent-ref %}

{% content-ref url="authoring/editor" %}
[editor](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/authoring/editor)
{% endcontent-ref %}

{% content-ref url="authoring/copypaste" %}
[copypaste](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/authoring/copypaste)
{% endcontent-ref %}

{% content-ref url="authoring/import" %}
[import](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/authoring/import)
{% endcontent-ref %}

{% content-ref url="authoring/advancededitor" %}
[advancededitor](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/authoring/advancededitor)
{% endcontent-ref %}

{% content-ref url="authoring/update-operators" %}
[update-operators](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/authoring/update-operators)
{% endcontent-ref %}

{% content-ref url="authoring/revert" %}
[revert](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/authoring/revert)
{% endcontent-ref %}

## Edit Clause

Hovering over an existing clause reveals the <img src="https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/PRSte2viDKImCy7Sbuk1/edit_icon.svg" alt="" data-size="line"> icon, which enables editing the selected clause. Changes can be persisted by clicking on the <img src="https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/f6fGA7K5VeDjcvoq1foB/green_checkmark_icon.svg" alt="" data-size="line"> sign.

![Edit a Value Set Clause](https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/QE30WaUuLpyOIktT7FyM/value_set_edit_clause.gif)

{% hint style="info" %}
Hovering over a clause also reveals the <img src="https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/Xhb95WfZfCdrLSfvUsqw/pin_icon.svg" alt="" data-size="line"> icon, which enables pinning the selected clause to the top of the list.&#x20;
{% endhint %}

## Optimize

As part of the authoring process, users also have the option to optimize their Value Sets. This feature simplifies Value Sets by replacing individual members with [ECL ](https://confluence.ihtsdotools.org/display/DOCECL)expressions. For example, if all the children of a [concept](https://docs.b2ihealthcare.com/snowray/v2.12/reference/codesystems#concepts) are added, it will reduce the clauses to a single clause using the following format: `< parentId | FSN |`.

{% hint style="info" %}
To use this option, navigate to the specific Value Set and start [editing](https://docs.b2ihealthcare.com/snowray/v2.12/reference/resources/valuesets/..#editing). Press the ![](https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/Xc1Q7Boqkq2ktLEYRpG2/actions_button.png) button in the upper right corner and select the *Optimize* context menu option.
{% endhint %}

<figure><img src="https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/degT9cFE0DmkFgjMHBA5/value_set_optimize.png" alt=""><figcaption><p>Value Set Optimize Plan</p></figcaption></figure>

{% hint style="info" %}
To confirm the proposed plan, press the <img src="https://content.gitbook.com/content/mtqpPjWCd58lq3KcPQAE/blobs/83tXXR1Ku4lmlOWgJXsa/accept_button.png" alt="" data-size="original"> button.
{% endhint %}
