📄 Protocol Definition Schema
All our problem goal's protocols are described in a json file. This json has an structured definition that all protocols must follow. This is what powers the protocol's states and transitions. This document describes the structure and constraints of the protocol_definition_schema.json file.
The schema is custom designed, but it follows the general conventions of JSON Schema. It uses defs, type, properties, items, required, additionalProperties, etc. If you want to expand on the schema, please keep that in mind, and try to adhere as much as possible to the JSON Schema conventions.
Overview
The schema defines a protocol with the following main components:
- States: Represents the various states that the problem goal could have. For each state, contains some state information and the interventions that should be created when transitioning into the state.
- Transitions: Defines how the protocol transitions between states.
Top-Level Properties
states
(Required)
- Type: Array of objects
- Description: Defines the states in the protocol.
State Object Properties
Property | Type | Description | Required |
---|
name | string | The unique name of the state. | Yes |
display_name | string | The human-readable name of the state. This is the value that will be displayed in the front end state dropdown. | Yes |
severity | string | The severity level of the state. When a problem goal is in a state with stable severity, it will be sorted to the bottom of the problems list. | No |
initial | boolean | Indicates whether this is the initial state. When evaluating a problem goal, if no rule is matched, it defaults to the initial state. | No |
manual_transition_disabled | boolean | Indicates whether manual transitions are disabled for this state. | No |
interventions | array | A list of interventions associated with this state. | No |
Interventions Object Properties
Property | Type | Description | Required |
---|
type | string | The type of the intervention class without the module (e.g. CompleteForms ). | Yes |
role | string | The role of the user that will be assigned to the intervention. | Yes |
deduplication_key | string | A unique key to deduplicate interventions. When transitioning to a new state, if there is another intervention opened for that problem with the same deduplication_key , we skip creating it. | No |
due_date | string | The due date for the intervention. Could be either a dynamic value (from the supported ones), or a date in unit.unit_type format (e.g. 1.month) | Yes |
custom_fields | object | Additional custom fields for the intervention. | No |
deduplication_params | array | Parameters used for deduplication. This works as another deduplication method besides the deduplication_key. More details below. | No |
Deduplication Parameters Object Properties
Property | Type | Description | Required |
---|
fields | array | A list of fields used for deduplication. Can include strings or objects with custom_field . | Yes |
states | array | A list of states relevant for deduplication. Could be scoped states (active , completed , canceled ) or scoped (e.g. awaiting_results for a CompleteForms intervention) | No |
transitions
(Required)
- Type: Array of objects
- Description: Defines the transitions between states.
Transition Object Properties
Property | Type | Description | Required |
---|
from | array | A list of states from which the transition can occur. | No |
to | string | The target state of the transition. | Yes |
rule | object | A condition or group of conditions that must be satisfied for the transition to occur. Can be either a group , or a condition . | No |
reason | string | The reason for the transition. This will be displayed in the problem goal's timeline in the front end. | Yes |
Rule object options definitions
group
- Type: Object
- Description: Represents a group of conditions combined with a logical operator.
Properties
Property | Type | Description | Required |
---|
type | string | Must be "group" . | Yes |
operator | string | The logical operator for the group. Possible values: and , or . | Yes |
conditions | array | A list of conditions or nested groups. | Yes |
condition
- Type: Object
- Description: Represents a single condition that must be satisfied.
Properties
Property | Type | Description | Required |
---|
type | string | Must be "condition" . | Yes |
parameter | object | The parameter to evaluate. Described below. | Yes |
operator | string | The operator to use for evaluation. Currently supported values: eq , neq , gt , lt , gte , lte , btw , lbtw , rbtw , in , nin , includes , all_lt and all_gt . | Yes |
value | any | The value to compare the parameter result against. | Yes |
Parameter Object Properties
Property | Type | Description | Required |
---|
key | string | The data fetcher's query key. E.g. most_recent_form_score | Yes |
args | object | Arguments for the data fetcher. E.g. "form_type": "PHQ9" | Yes |
Example JSON
Real examples can be found in the protocol_definitions directory