Skip to main content

📄 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

PropertyTypeDescriptionRequired
namestringThe unique name of the state.Yes
display_namestringThe human-readable name of the state. This is the value that will be displayed in the front end state dropdown.Yes
severitystringThe 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
initialbooleanIndicates 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_disabledbooleanIndicates whether manual transitions are disabled for this state.No
interventionsarrayA list of interventions associated with this state.No

Interventions Object Properties

PropertyTypeDescriptionRequired
typestringThe type of the intervention class without the module (e.g. CompleteForms).Yes
rolestringThe role of the user that will be assigned to the intervention.Yes
deduplication_keystringA 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_datestringThe 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_fieldsobjectAdditional custom fields for the intervention.No
deduplication_paramsarrayParameters used for deduplication. This works as another deduplication method besides the deduplication_key. More details below.No

Deduplication Parameters Object Properties

PropertyTypeDescriptionRequired
fieldsarrayA list of fields used for deduplication. Can include strings or objects with custom_field.Yes
statesarrayA 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

PropertyTypeDescriptionRequired
fromarrayA list of states from which the transition can occur.No
tostringThe target state of the transition.Yes
ruleobjectA condition or group of conditions that must be satisfied for the transition to occur. Can be either a group, or a condition.No
reasonstringThe 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

PropertyTypeDescriptionRequired
typestringMust be "group".Yes
operatorstringThe logical operator for the group. Possible values: and, or.Yes
conditionsarrayA list of conditions or nested groups.Yes

condition

  • Type: Object
  • Description: Represents a single condition that must be satisfied.

Properties

PropertyTypeDescriptionRequired
typestringMust be "condition".Yes
parameterobjectThe parameter to evaluate. Described below.Yes
operatorstringThe 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
valueanyThe value to compare the parameter result against.Yes

Parameter Object Properties

PropertyTypeDescriptionRequired
keystringThe data fetcher's query key. E.g. most_recent_form_scoreYes
argsobjectArguments for the data fetcher. E.g. "form_type": "PHQ9"Yes

Example JSON

Real examples can be found in the protocol_definitions directory