Comparison Rule Sets

Summary

Comparison Rule Sets allow for the construction of complex business rules such as (Rule1 AND Rule2) OR (Rule3 AND Rule4).

Overview

Rule Sets are constructed by creating one or more Comparison Rules and then joining them together as a complex boolean expression.

When you click the link next to a property that is a Comparison Rule set, the following editor is opened:


A rule set has the following properties:

  • Description - this is an English name used to describe the rule.  It only appears in the configuration and is not viewable by practitioners.
  • Rules - this is the JSON string that defines the rule set.  
    • The rule set is represented as an expression tree in JSON syntax. Each node of the tree is either a
      • Single comparison rule
      • Conjunction [multiple rules ANDed together] or a disjunction [multiple rules ORed together]
      • Disjunction [multiple rules ORed together]
    • Nodes can be combined to create complex combinations of ANDs and ORs.
    • See the table below for examples.

  • Comparison Rules in use - At the bottom of the rule set you can manage the Comparison Rules.  
    • There is:
      • A list of Comparison Rules used in this rule set with their Rule Id followed by
      • The option to Add a new Rule.  
    • Clicking the [Add a new Rule] link creates a new rule with a temporary negative number as its Rule Id and the name "undefined value."
    • Clicking the name of the rule opens the Comparison Rules editor to add or update the rule.  
    • When creating the JSON for the Rules replace the actual Rule Id for the "<Rule Id>" shown in the examples below.
    • When the Rule Set is saved, the new Comparison Rules which were assigned a negative number will be reassigned a positive number.

Syntax Examples

ScenarioSyntax Example
Always evaluate as TRUE(leave the JSON field blank)
Single comparison rule
{ "nodeType": "Single", "ruleId": <RuleId> }
Multiple rules, all of which must match ("AND")
{ "nodeType": "And", "rules": [
{ "nodeType": "Single", "ruleId": <Rule1> },
{ "nodeType": "Single", "ruleId": <Rule2> },
{ "nodeType": "Single", "ruleId": <Rule3> }
]}
Multiple rules, any of which must match ("OR")
{ "nodeType": "Or", "rules": [
{ "nodeType": "Single", "ruleId": <Rule1> },
{ "nodeType": "Single", "ruleId": <Rule2> },
{ "nodeType": "Single", "ruleId": <Rule3> }
]}

Complex expression

e.g., (Rule1 OR Rule2) AND (Rule3 OR Rule4)

{ "nodeType": "And", "rules": [
{ "nodeType": "Or", "rules": [
{ "nodeType": "Single", "ruleId": <Rule1> },
{ "nodeType": "Single", "ruleId": <Rule2> }
]},
{ "nodeType": "Or", "rules": [
{ "nodeType": "Single", "ruleId": <Rule3> },
{ "nodeType": "Single", "ruleId": <Rule4> }
]}
]}

Complex expression

e.g., (Rule1) AND (Rule2 OR Rule3)

{ "nodeType": "And", "rules": [
   { "nodeType": "Single", "ruleId": <Rule1> },
{ "nodeType": "Or", "rules": [
   { "nodeType": "Single", "ruleId": <Rule2> },
   { "nodeType": "Single", "ruleId": <Rule3>}
  ]}
]}