Skip to main content

Overview

Protocols drives medical intake navigation: it walks the visitor through a protocol’s questions, decides which one to show next, and evaluates whether they can continue or are eligible. It reads answers from Forms — set up Forms first, then Protocols uses those answers as the visitor moves through the flow. Protocols also needs Core, like every other SDK. Answers are linked by each field’s protocolFieldId in your form setup. The walkthrough below covers install and wiring. When you need the full instance API, the React hook, or the protocol contract, open the reference.

How it fits together

  • Core initializes once, as it does for every SDK.
  • Forms must be set up before Protocols — Protocols reads form answers; it does not create forms.
  • A form field opts into protocol reads by declaring a protocolFieldId — supported on text, email, boolean, select, and multiselect fields (not number or json, which em build rejects). Protocol logic reads that value with getValueByProtocolFieldId.
  • When two forms declare the same protocolFieldId, the later form in the array wins.
In React, list Forms before Protocols in your modules setup (as in the example below). If Forms is missing, Protocols cannot start.

Implementation

Install

Install Core and Forms first, then add Protocols.

Connect a protocol

Connect a ready-made one from the catalog with the Embeddables CLI:
This downloads the protocol into your project and builds it into embeddables/_dist. Import it from there and pass it to initProtocol (JavaScript) or protocols({ protocols }) (React).

Set up

With the protocol connected and Forms set up, pick your setup:
Follow the example below: enable Forms, then Protocols, in the same modules list. Form schemas live on config.forms from embeddables/_dist. Import your protocol from _dist after em protocol connect — the CLI does not plug it in automatically.
formIds: Object.keys(config.forms) composes every generated form; pass a narrower list if only some forms carry protocolFieldIds the protocol reads.useProtocol tracks the current question and whether the visitor can continue. See the reference for the full hook and navigation helpers.
After you connect a protocol, you still pass it explicitly in protocols({ protocols: [...] }), as in the example — em build does not choose the protocol for you.
Need the full instance API, the React hook, protocol-agnostic helpers, or the Protocol contract? See the reference.