Business Rules Getting Started Guide

Overview

The Business Rules API allows users to create rules which generate notifications when a user meets certain criteria.

❗️

DEPRECATED FEATURE

At this time, this feature has been disabled and no longer available for beta access. The availability of this feature may change in the future.

Creating a Rule

To create a rule you'll need to POST the following request to the Validic RESTful API. You will need to do this for each user you wish to monitor.

POST https://api.v2.validic.com/organizations/59b02bbdfSAMPLE001e13e75/users/vpt12345sp/rules?token=6f46dbSAMPLEd2b82d91698fcd0896

{
  "message": "VEvJrt5G3KD4nKvl",
  "type": "user/missing_data",
  "window": "P7D",
  "metric": {
    "type": "blood_glucose",
    "unit": "mg/dl",
    "origin": null
  },
  "threshold": {
    "value": 5,
    "comparator": "less_than"
  }
}

API Request Parameters

FieldDescriptionRequiredAccepted Value
typeDefines the rule type.YesOnly adherence rules are currently supported, and require the type to be set as "user/missing_data"
windowSets the sliding window of time over which incoming values should be evaluated as an ISO 8601 Duration value.For adherence rules:
Yes
An ISO 8601 Duration value.
messageA message that will be returned when the user rule is triggered.YesThis field will store string values of any size.
metric > typeA valid metric type. Please review the supported metric types.YesA valid metric type
metric > unitMost metric types standardize to one value, however, some may support multiple standard units (blood glucose for instance). Use this field to further refine the metric data that should be evaluated by the rule.NoReview list of supported metric types and their units
metric > originRefine the metric data that should be evaluated by the rule based upon the origin.Nodevice, manual, unknown
threshold > valueDefines, in combination with the threshold comparator, when a user rule is triggered.YesInteger, Float
threshold > comparatorDefines, in combination with the threshold value, when a user rule is triggered.Yesless_than, greather_than, equal_to

API Response

Once the rule is created, users can expect the following response. Please retain the "id" you used to create this rule. You'll use this to manage updates to your rule.

{
  "id": 123VentureMedWestTrigger1,
  "message": "VEvJrt5G3KD4nKvl",
  "type": "user/missing_data",
  "window": "P7D",
  "metric": {
    "type": "blood_glucose",
    "unit": "mg/dl",
    "origin": null
  },
  "threshold": {
    "value": 5,
    "comparator": "less_than"
  }
}

Triggered Rule Response

The rule event occurs when a specified user rule criteria are met. The rule will contain information about the user, the rule, and any associated data (when applicable). A triggered event will only be published to our Streaming API . You cannot receive triggered event in the RESTful API. Here is an example of rule event when a rule has been triggered.
The following example shows a triggered rule event:

event: rule
data: {
   "user":{
      "uid":"24174455a00c7aa60ace295bd7e06b73065578d3d6db4c90065e8ea0fd775025",
      "user_id":"598b934b8a5da50001ea87c4",
      "organization_id":"58c7fe748a5da50001a310fb"
   },
   "rule":{
      "id":118,
      "type":"user/missing_data",
      "window": "PT604800S",
      "message": "Too few Blood Glucose readings received.",
      "metric": {
        "type": "post_meal_blood_glucose",
        "sub_type": null,
        "unit": null,
        "origin": null
      },
      "threshold":{
        "value":5,
        "comparator":"less_than"
      }
   },
   "data":[
      {
         "type":"user/missing_data",
         "data":{
            "count":0
         }
      }
   ],
   "created_at":"2017-08-31T00:25:50Z"
}

Response Fields

📘

Note

When consumed by a client, the JSON for the event data field would be on one line. It is formatted here for readability.

FieldDescription
user > uidCustomer's unique user identifier.
user > user_idValidic's unique user identifier.
user > organizaiton_idValidic's unique organization identifier.
rule > idUnique user rule identifier.
rule > typeDefines the rule type.
rule > windowIndicates the sliding window of time over which incoming values were evaluated. ISO 8601 Duration string format.
rule > messageA message that will be returned for the triggered rule.
rule > metric > typeThe metric type.
rule > metric > sub_typeNot currently in use.
rule > metric > unitThe metric unit.
rule > metric > originThe metric origin.
rule > threshold > valueDefines, in combination with the threshold combinator, when a user rule is triggered.
rule > threshold > comparatorDefines, in combination with the threshold value, when a user rule is triggered.
data > typeThe rule type.
data > dataInformation about received data that led to the user rule triggering.
created_atThe time the user rule triggered. ISO 8601 string format.

📘

Note

All rules associated with a user are deleted if the user is suspended.

Updating Rules

You may update an existing rule by submitting a PUT request. This request must include the rule_id found in the API response when the rule was created.

PUT https://api.v2.validic.com/organizations/59b02bbdfSAMPLE001e13e75/users/vpt12345sp/rules/123VentureMedWestTrigger1?token=6f46dbSAMPLEd2b82d91698fcd0896

{
  "message": "VEvJrt5G3KD4nKvl",
  "type": "user/missing_data",
  "window": "P5D",
  "metric": {
    "type": "blood_glucose",
    "unit": "mg/dl",
    "origin": "device"
  },
  "threshold": {
    "value": 5,
    "comparator": "less_than"
  }
}
{
  "id": 123VentureMedWestTrigger1,
  "message": "VEvJrt5G3KD4nKvl",
  "type": "user/missing_data",
  "window": "P5D",
  "metric": {
    "type": "blood_glucose",
    "unit": "mg/dl",
    "origin": "device"
  },
  "threshold": {
    "value": 5,
    "comparator": "less_than"
  }
}

Delete a Rule

Deletes a user rule.

DELETE https://api.v2.validic.com/organizations/59b02bbdfSAMPLE001e13e75/users/vpt12345sp/rules/123VentureMedWestTrigger1?token=6f46dbSAMPLEd2b82d91698fcd0896
{
  "id": 123VentureMedWestTrigger1,
  "message": "VEvJrt5G3KD4nKvl",
  "type": "user/missing_data",
  "window": "P5D",
  "metric": {
    "type": "blood_glucose",
    "unit": "mg/dl",
    "origin": "device"
  },
  "threshold": {
    "value": 5,
    "comparator": "less_than"
  }
}