# Manage Rules

## Introduction

Define one or more rules for a specific nutrition program. Each program contains a ruleset that determines the foods to avoid, increase or decrease for that program.

{% hint style="info" %}
Rules can be added to either active or inactive programs.
{% endhint %}

## Rule Components

A rule has the following components:

### Action Type

There are three types of actions within a rule:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FqekPSuO5H4Q625oTMnZb%2Fimage.png?alt=media\&token=3c849170-4e3a-4675-a1b6-20b4230f07b5)

* **Avoid:** Use this rule to indicate that it is necessary to avoid the intake of certain ingredients in a nutrition program. In the following example, avoid the sugar foods selected within the Ingredient Groups:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FccyhfziJehbCe59p1vZd%2Fimage.png?alt=media\&token=600ae4a2-2d77-4e67-b2d3-0ce207506d86)

* **Decrease:**  Use this rule to indicate that it is necessary to decrease the intake of certain ingredients in a nutrition program. In the following example, decrease the salt intake within the Ingredient Groups:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FQIT550pqrG1zZs0FlJCw%2Fimage.png?alt=media\&token=0ddb576b-c4ac-4e48-ac91-1476f218cdde)

* **Increase:** Use this rule to indicate that it is necessary to increase the intake of certain ingredients in a nutrition program. In the following example, increase the omega-3 intake foods selected within the Ingredient Groups:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FD0UWyAvexyJKMtIzAXBY%2Fimage.png?alt=media\&token=044b99cc-97c7-4481-a281-46961203bf09)

### Ingredient group&#x20;

Choose one or more ingredient groups to be targeted within the rule.

To add ingredient groups, click on the down arrow. Two ingredient sections are displayed:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MbNfvAh4JOurMsovv7p%2F-Mf-E0rc4XDtR0LxLLMK%2F-Mf-EHh03GeRZtS0ewSK%2Fimage.png?alt=media\&token=645a0848-592c-4d56-9870-d42170029ed4)

* **Your ingredient groups** section lists all the custom ingredient groups [created by a user](https://docs.suggestic.com/console/access-the-main-menu/access-the-main-menu/programs/ingredient-groups/create-ingredient-groups).
* **Ingredient groups by Suggestic** section list all the predefined ingredient groups [created by Suggestic](https://docs.suggestic.com/console/access-the-main-menu/access-the-main-menu/programs/ingredient-groups#created-by-suggestic).

Search for an ingredient by entering its name. For instance, introduce milk as an ingredient, and all the ingredients that contain milk will be displayed:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MbNfvAh4JOurMsovv7p%2F-Mf-dk1CleF03AdYZSYX%2F-Mf-gDtMCnljngzb9rwd%2Fimage.png?alt=media\&token=2c55fc13-b62c-4492-8ea4-5030564fc3f3)

As in the example below and depending on the rule, one or more ingredient groups can be added:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MbNfvAh4JOurMsovv7p%2F-Mf-HLpMu455NehfnNHQ%2F-Mf-KVZGU7Bf6R804fNI%2Fingredientrule.gif?alt=media\&token=cb54385e-c147-4e69-871b-e21bcf6e7a7c)

### Order

The order in which the rule will appear in the API.

### Rule Priority

The rule priority is the weight of the rule. The more priority number selected, the more priority the rule has.&#x20;

For instance, if there are the following rules defined:

&#x20;**Rule #1**

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FwNyPafADXyCXwWQFpH6d%2Fimage.png?alt=media\&token=ea63afb9-5490-4250-82f9-5461587b70f8)

**Rule #2**

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FjLOm1nXNUEeQzGVLXM3Q%2Fimage.png?alt=media\&token=0b8ded05-3c42-42ce-9d3a-342f06877353)

Even though both action rules are defined as **Avoid,** **Rule #2** will be prioritized because its priority is defined as 8. Therefore, it will be more important to avoid alcoholic beverages on the nutrition program than avoid sugary **foods**.

### User Segment

Select the user segment the rule is applied. [User Segments](https://docs.suggestic.com/console/access-the-main-menu/access-the-main-menu/programs/user-segments/create-a-segment) are created by users.

Click on the down arrow to list all the available user segments&#x20;

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MbNfvAh4JOurMsovv7p%2F-Mf-Ox1RapkRbvm_jFEh%2F-Mf-QpGVybc5txNqunm2%2Fimage.png?alt=media\&token=40b432be-bec9-48cf-8f61-dd24a897f533)

If you cannot find a user segment that fits the rule, click on the **Edit user segments** option to open the Segments editor:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MbNfvAh4JOurMsovv7p%2F-Mf-Ox1RapkRbvm_jFEh%2F-Mf-RV0FfkhJdE6APySl%2Fimage.png?alt=media\&token=c788778f-7a17-4b85-9021-311c15da45f0)

### **Rule** Information

At the right side of the screen, the information of the rule must be filled in:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FurflMkqcexiViTlkRyls%2Fimage.png?alt=media\&token=30b4f1f0-19a4-482b-be83-0fbe4dcaf460)

## Create a Rule

As follows find an example of how to create a rule.

1. Go to the **Programs** section and choose a program from the list of active or inactive programs:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FqmvUenludUFr6GLz2S21%2Fimage.png?alt=media\&token=e4692ebb-94c2-4714-922d-d75780738e9d)

&#x20;   2\. Click on the **Add Rule** option:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2F157knoe414MrlFpzjEEG%2Fimage.png?alt=media\&token=47998ce9-a5e7-4fd2-9fc0-b5ffb35c6c37)

Fill in the information as in the example below where a rule that avoids milk is created and add the program information. Finally, click on the **Create** button:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2Fn7O1AEIgl5CWzXwW2O62%2FCreateARule.gif?alt=media\&token=6a5318a0-5761-4bc6-9761-4cbf010227c6)

Create as many rules as needed.

## Edit a rule

{% hint style="info" %}
Rules can be edited either on active or inactive programs
{% endhint %}

To edit a rule, select the program and click on the  <img src="https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2Fzl1mGNbYnQ7clQS5sfiF%2Fimage.png?alt=media&#x26;token=e482378a-3b85-478d-b917-379e32210786" alt="" data-size="line">icon, the rule information is displayed:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FjYequGWeAn4LGytl5ZC8%2FEditRule2.gif?alt=media\&token=c60d4fea-2814-4036-b0c0-df9df2b51622)

Modify the information and then click on the **Save Changes** button.

## Delete a Rule

To delete a rule, select the program and click on the ![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2Fe4N0kWGI9YY2Zu8Y77qw%2Fimage.png?alt=media\&token=2613efb0-6422-49f4-81a9-14f5cc6eff82) icon.&#x20;

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FbFP5yP7kQiyG5RlSeCk8%2Fimage.png?alt=media\&token=549badbf-2083-4809-82af-faf3f4ec07c7)

The following message is displayed:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FI3ACy9Zoq1FbAOLqKdD1%2Fimage.png?alt=media\&token=b0443cf0-d7bb-46f8-a714-1534f2feea32)

A message indicating that the rule has been deleted is displayed at the bottom right side of the screen:

![](https://3642424792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbNfvAh4JOurMsovv7p%2Fuploads%2FLbvJCSpipP1yp0WZe2Mc%2Fimage.png?alt=media\&token=19219f5a-d6e0-4e26-8fde-9b429c822c0d)

{% hint style="info" %}
Once a rule is deleted, it cannot be recovered.
{% endhint %}
