Skip to content

Evaluate one rule

This operation evaluates a single NotificationRule against the model, dispatching to an int, bool, or string evaluation path based on the rule's TypeName metadata, including the conditional recursion that lets a bool rule resolve to a derived property value.

Field Value
Operation ID OP-CIA-02
Trigger Step 3 of Calculate notifications for a model, or a recursive call for an out-property child rule.
Inputs rule (NotificationRule); model (T).
Outputs A string value, or null.
Primary components NotificationRuleEngine.CalculateNotification<T> (private)
Entry point Services/SAIF.Services.ClaimInfoApi.Core/NotificationRuleEngine.cs (lines 34–71)

Steps

  1. Resolve rule.Type, which is Type.GetType(rule.TypeName) (CIA-BR-002).
  2. If unresolvable, rule.Type is null and the rule falls through to the string branch (step 4).
  3. When rule.Type is int: compile the rule as Func<T,int> via Compile a rule into a delegate, invoke it on the model, and return .ToString() of the result (CIA-BR-003).
  4. When rule.Type is bool: compile the rule as Func<T,bool> and invoke it.
  5. If the result is true and OutProperty is set: build a child rule with NotificationRule.PropertyRule(rule.Position, rule.OutPropertyTypeName, rule.Name, rule.OutProperty), copy the parent Id into the child's _id, and recursively evaluate it via this same operation. The child's value is returned (CIA-BR-005).
  6. Else, if the result is true and OutValue is set: return OutValue (CIA-BR-006).
  7. If the result is true but neither OutProperty nor OutValue is set: return null.
  8. If the result is false: return null (CIA-BR-004).
  9. Otherwise (any other resolved type, or an unresolvable TypeName): compile the rule as Func<T,string>, invoke it, and return its value (CIA-BR-003).

Process flow

The following diagram visualizes this operation's type-dispatch control flow.

flowchart TD
    Start([Trigger]) --> Resolve["Resolve rule.Type<br>from TypeName"]
    Resolve --> D{"Resolved type?"}
    D -->|int| IntPath["Compile Func&lt;T,int&gt;<br>return .ToString()"]
    D -->|bool| BoolPath["Compile Func&lt;T,bool&gt;<br>invoke delegate"]
    D -->|other / unresolvable| StrPath["Compile Func&lt;T,string&gt;<br>return value"]
    BoolPath --> BD{"Result true?"}
    BD -->|Yes, OutProperty set| Child["Recurse into child<br>PropertyRule (this operation)"]
    BD -->|Yes, OutValue only| OutVal(["Return OutValue"])
    BD -->|Yes, neither set| NullOut(["Return null"])
    BD -->|No| NullOut
    IntPath --> Done([Return string or null])
    StrPath --> Done
    Child --> Done
    OutVal --> Done

Failure and edge-case behavior

  • An unresolvable TypeName is not an error; the rule silently falls through to the string branch (step 4).
  • A bool rule that is true with neither OutProperty nor OutValue set produces null, with no diagnostic.
  • Compilation and invocation failures propagate from Compile a rule into a delegate with no local try/catch.

Sources

  • Services/SAIF.Services.ClaimInfoApi.Core/NotificationRuleEngine.cs
  • Services/SAIF.Services.ClaimInfoApi.Core/NotificationRule.cs