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’sprotocolFieldId 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 ontext,email,boolean,select, andmultiselectfields (notnumberorjson, whichem buildrejects). Protocol logic reads that value withgetValueByProtocolFieldId. - When two forms declare the same
protocolFieldId, the later form in the array wins.
Implementation
Install
Connect a protocol
Connect a ready-made one from the catalog with the Embeddables CLI: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:- React
- JavaScript
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.
