1. Help Center
  2. How To's
  3. Engage - Protocol Editor Videos

7. Protocol Editor: Introduction to logic and basic call flow

Logic is what allows the protocol flow to function, and is what links nodes together.

 

In its essence, a logic expression is a statement written using variable and operators, following a precise syntax. The statement will then return a true or false value. True will continue the flow, while false will not.

To connect two nodes together drag and drop from one dot to the other. Typically this will be the connection point from the preceding logic gate to the main connection point in the following node in the top left corner. To delete the connection simply select it and click delete on your keyboard.

Operators

Currently, these are the operators allowed in the logic expression field:

  • && : use the double ampersand to insert a 'AND' operator.

  • || : use the double pipe, or vertical bar, to insert a 'OR' operator.

    • The logical OR operator is an inclusive OR, meaning that it will return a false results only if both operands are false. Simple example:

      • x || t : if the call taker selects `x`, `t` or both values, the logic gate will return a true result.

  • ! : use the exclamation mark to insert a 'NOT' operator.

  • == : use the double equal to insert a 'IS EQUAL TO' operator.

  • != : use the exclamation mark equal to insert a 'IS NOT EQUAL TO' operator.

The following are not operators, but relevant characters in order to write the logic expression:

  • () : use the round brackets for grouping two or more variables.

  • $ : use the dollar sign to open up the variable list, and select one.

  • true : it is a logic expression in itself, and the most inclusive one. It returns a true value for any variable or combination of variables selected. The $ is not needed in front of true.

    • Use just true in the logic gate when you need to proceed with the flow regardless of actions taken or if no action is required of the call taker. This is most common with action buttons.

  • Depending on the outcome desired, the logic expression can be quite simple and straightforward, or more complex. As an example:

    • x && t : if x AND t are selected, the expression will return a true value. Otherwise is false.

    • (( x && t ) || Y ) : if the x AND t, or Y, or both operands are selected the expression is true. Any other selection will return a false value.

    • (( x && t ) || Y ) && B : returns a true value if (x AND t, or Y, or both operands) AND B are selected

Variables

They are used to form logic expressions, but variables are actually created in the node's blocks, according to the block selected, and the content written in them. All variables come from the blocks.

  • Select: each option added in a select block (regardless of it being a single or multi-select block) content block is a variable, usable in building the logic expression for any gate belonging to the same node.

  • Simple Text Input: this block is an input field allowing a single line of free text, which is why it constitutes a string variable. A string variable is a variable that can hold characters such as letters, numbers, spaces, commas, etc.

  • In the case of simple-text input blocks, the name of the variable will be the label text provided. If the label of the block is 'Describe option A more in detail:', the name of the variable will be that.

Logic Gates

A correctly written logic expression constitutes a logic gate.

  • A logic gate always has a binary outcome, meaning that it can only return a true or a false value depending on the input provided.

  • It is possible to create more logic gates per node, depending on the number of defined outcomes desired.

  • It is important to bear in mind that:

    • A variable is correctly inserted in a logic gate when it becomes highlighted in light red, and has red colored font.

    • The ORDER in which the logic gates are saved in the logic block will determine the priority assigned to each expression.

    • The first gate that returns a true value, will determine the flow and therefore the node to be selected next.

Text

Text from facts from your CAD system, or from text fields, can be used in logic in a number of ways.

  • Exact Comparison

    • Using == will compare the value of the field exactly (so typos will break the logic). This is mostly useful when the spelling is always consistent (e.g. region name from your CAD system). You can also test against a list of possible value (example 2).

    • Examples

      • $patient_name == "henrik" will be true if you type "henrik" but would be false if you put anything else (it's even case sensitive!)

      • $patient_name in ["henrik","magnus","andrée"] will be true if you type "henrik", "magnus", and "andrée" but would be false if you put anything else (it's also case sensitive!)

  • Text Contains

    • You can also test if a text value contains another bit of text.

    • Example

      • $telephonenumber|contains("0411") will be true if you type "+04114636521" or basically anything that contains "0411" but would be false if the search text cannot be found (it's also case sensitive!)

  • Numeric Comparison

    • Our system does its best to try to convert text input into numbers (if possible) so that you can use comparison methods such as greater than or less than. It's a little forgiving, typically ignoring extra spaces. It also understands decimals. But if you put in non-numeric character, it won't be able to interpret it as a number.

    • Example

      • $patient_age >= "45" will be true if you type "60" or any number greater-than-or-equal-to 45. but would be false if you put anything else (it's even case sensitive!).

Facts and Fact Library

Facts are inputs that are set/originate from outside of the Corti User Interface that can be utilized by administrators within logic gates in the graph to direct users to a certain outcome.

For example, Geographical/Location information from an External Application (e.g. your CAD system) can be used within a logic gate like so: `location.locality in ['Stockholm','Seattle','Boston']` to direct a call taker in the protocol graph.

Facts can only be set from External Applications and cannot be triggered from within the User Interface.

  • From within the Protocol Editor it is possible to add/ insert them to the Fact library and be able to use them in logic expressions to design the graph logic as desired.

  • Facts can be created for different data points stored by you CAD system and used within logic gates. A fact can be set as a *boolean* or *string* type:

    • Boolean means that the fact can have only a true/false state. An example of this could be gender: male, or female.

      • If you create male and female as two facts and use them in a logical expression, depending on what gender has been confirmed, one of them will be true and the other false.

    • String comprises a set of characters that can contain letters, spaces, and numbers. Therefore, string variables are generally used to represent text values.

      • Compared to the boolean facts, string facts when used in logic expressions need to be specified according to the relevant value for the protocol you are designing. As an example, age could be a string and in a logic expression, it could be set to be equal to, be ≥ , or ≤ of a specific value, let's say 40.

        • If the reported age is 45 then only the following expression `age ≥ 40` would be true.

      • Another example of a string fact could be the location.

  • When you first create a fact, the fact name will be used to generate the fact ID. After creation, it is possible to edit only the fact name, while the fact ID is set upon creation

  • A fact created is only available within the graph where it has been created, therefore it will not be available in other graphs.

  • When correctly entered in a logic expression facts are purple colored.

  • If a fact is deleted from the library, all the logic expressions using it will be affected as the reference will be severed and missing

     

Further Reading:

How To Videos - Protocol Editor: Welcome to the Editor

How To Videos - Protocol Editor: Accessing the New Menus

How To Videos - Protocol Editor: The Main Menu

How To Videos - Protocol Editor: Version History and Releases

How To Videos - Protocol Editor: Branches

How To Videos - Protocol Editor: Nodes and Blocks

How To Videos - Protocol Editor: Flow Value Collectors

How To Videos - Protocol Editor: Link Portal Nodes

How To Videos - Protocol Editor: Text Editing