Config Triggers

🚧

Roles

manager

The call to this method updates alert configuration for multiple patients at once.

Alert Triggers Management Rules

The alert triggers is a collection of trigger rules assigned to a patient. Triggers are uniquely identified by the code field. So a patient can have only one trigger with the particular code

 "triggers": [
        {
            "code":"29463-7",            
        },
        {
            "code": "8310-5",
            ...
        } ,
        {
            "code": "8310-5",
            ...
        },
        {
            "code":"8462-4",
             ...
        }
    ],

When a patient is assigned a trigger with the code which already exists in the patient configuration then the new trigger definition will overwrite the old trigger.

Specifying "delete": true in a trigger definition will remove the trigger with this code.

 {
   "code":"8462-4",
   "delete":true
 }

Triggers logic

Trigger logic uses a JSONLogic schema. See JsonLogic. The logic is executed on each incoming observation's value with the matching code . When the condition is evaluated to true a trigger alert is created.

Example of trigger logic that will trigger an alert when a patient's observation with code="8462-4" ("Diastolic blood pressure") is higher than 100.0

{
  "code" : "8462-4", 
  "display" : "Diastolic blood pressure", 
  "logic" : { ">" : [ { "var" : "valueQuantity.value" },100 ]
}

Pay attention that the logic checks observation's {valueQuantity:{value:100}} field. Other FHIR types of observation filed like valueInteger, valueDate, valueString are supported.

The system however is able to detect all types of observations and evaluate the logic expression with a simple value key instead:

{
  "code" : "8462-4", 
  "display" : "Diastolic blood pressure",   
  "logic" : { ">" : [ { "var" : "value" },100 ]
}

The List of supported types:

valueInteger, valueQuantity, valueString, valueBoolean, valueDateTime

The valueKey property allows changing the name of the value key for convenience.

{
  "code" : "8462-4", 
  "valueKey":"pressure",
  "logic" : { ">" : [ { "var" : "pressure" },100 ]
}

The constant key allows removing constants from JsonLogic code. In the following snippet, the value 100 was replaced with "critical"

{
  "code" : "8462-4", 
  "constants" : {"critical":100},   
  "logic" : { ">" : [ { "var" : "value" },{"var":"critical"} ]
}

Advanced Conditional Logic and Alert Customization (New)

For more complex scenarios, you can use JsonLogic's if operator. This allows you to define multiple conditions and corresponding outcomes. Importantly, the outcome object can now specify not only if an alert should be triggered but also a custom value and message to be included in the webhook event.

The structure for such an outcome is:

{
  "alert": <boolean>,  // true to send an alert, false to not send for this condition
  "value": "<string|number>",   // A custom string representing the outcome/status
  "message": "<string>"  // A descriptive message for this outcome
}

Example of Advanced Trigger Logic:

Let's consider the "R Rate" (Respiratory Rate) trigger with code 9279-1. This trigger defines different states (Bradypnea, Normal, Tachypnea) based on the respiratory rate.

{
    "code": "9279-1",
    "display": "R Rate",
    "valueKey": "valueQuantity.value", // Or simply "value" if preferred
    "unit": "breaths/minute",
    "notes": "Adult Respiratory Rate (RR) categories:\n • Bradypnea: < 12 breaths/minute\n • Normal: 12–20 breaths/minute\n • Tachypnea: > 20 breaths/minute\n...",
    "logic":{
        "if": [
            // Condition 1: RR < 12 (Bradypnea)
            { "<": [{ "var": "valueQuantity.value" }, 12] },
            {
                "alert": true, // Send an alert
                "value": "Bradypnea",
                "message": "RR < 12 breaths/minute (Bradypnea)"
            },
            // Condition 2: RR <= 20 (Normal) - evaluated if Condition 1 is false
            { "<=": [{ "var": "valueQuantity.value" }, 20] },
            {
                "alert": false, // Do not send an alert for normal state
                "value": "Normal",
                "message": "RR 12–20 breaths/minute (Normal)"
            },
            // Else (default if other conditions are false): RR > 20 (Tachypnea)
            {
                "alert": true, // Send an alert
                "value": "Tachypnea",
                "message": "RR > 20 breaths/minute (Tachypnea)"
            }
        ]
    }
}

Another Example: Apnea-Hypopnea Index (AHI)

This example demonstrates multiple conditions for AHI categories.

{
    "code": "69990-0",
    "display": "Apnea-Hypopnea Index",
    "valueKey": "value", // Simplified value access
    "notes": "valueQuantity.value ≥ 0 (non-negative)\n\nAdult AHI categories:\n...",
    "logic": {
        "if": [
            { "<": [{ "var": "valueQuantity.value" }, 5] },
            {
                "alert": false,
                "value": "Normal",
                "message": "AHI < 5 events/hour (Normal)"
            },
            {
                "and": [
                    { ">=": [{ "var": "valueQuantity.value" }, 5] },
                    { "<=": [{ "var": "valueQuantity.value" }, 14] } // Note: original logic had < 15
                ]
            },
            {
                "alert": true,
                "value": "Mild",
                "message": "AHI 5–14 events/hour (Mild Sleep Apnea)"
            },
            {
                "and": [
                    { ">=": [{ "var": "valueQuantity.value" }, 15] },
                    { "<=": [{ "var": "valueQuantity.value" }, 29] } // Note: original logic had < 30
                ]
            },
            {
                "alert": true,
                "value": "Moderate",
                "message": "AHI 15–29 events/hour (Moderate Sleep Apnea)"
            },
            { ">=": [{ "var": "valueQuantity.value" }, 30] },
            {
                "alert": true,
                "value": "Severe",
                "message": "AHI ≥ 30 events/hour (Severe Sleep Apnea)"
            },
            // Default outcome if none of the above conditions are met
            // (e.g., if value is negative, though notes say non-negative)
            { 
                "alert": false, // Or true if an alert is desired for unexpected values
                "value": "Undefined", 
                "message": "AHI value out of expected range or invalid."
            } 
        ]
    }
}

Did this page help you?