Skip to main content

Encounter state

The client reports the encounter as a NablaConnectState snapshot. Use it to enable or disable your controls and to decide when it is safe to leave.

The state object​

Every stateChanged event and getCurrentState() give a snapshot with these fields:

FieldTypeMeaning
stateEncounterStateWhere the encounter is. See States.
availableActionsarray of AvailableActionCommands the iframe accepts right now.
canBeClosedbooleantrue when closing or navigating away loses nothing.
reasonCOMMAND, NOTE_GENERATION_FAILED, or nullWhy this snapshot was emitted: COMMAND when it followed a command you sent, NOTE_GENERATION_FAILED when the note generation failed (see failureReason), null when the change came from the iframe or the provider.
failureReasonTRANSCRIPT_TOO_SHORT, NO_MEDICAL_DATA, RATE_LIMITED, UNKNOWN, or nullSet when reason is NOTE_GENERATION_FAILED.

States​

stateMeaning
NOT_STARTEDNo recording yet. availableActions is empty while the provider finishes the Nabla onboarding.
RECORDING_STARTINGStart in progress.
RECORDING_STARTEDLive capture.
RECORDING_STOPPINGStop in progress, audio being uploaded.
PAUSEDRecording stopped, transcript present.
NOTE_GENERATINGNote generation in progress.
NOTE_READYNote generated, export allowed.

Commands move the encounter between states:

exportNote does not change the state.

Available actions​

availableActions is a subset of START_RECORDING, STOP_RECORDING, GENERATE_NOTE and EXPORT_NOTE. Hide or disable the controls that are not listed.

Closing safely​

canBeClosed does not depend on the state. It is false while audio is recording or being uploaded, and while note edits are not saved yet. Generating a note does not change it: the generation runs on Nabla's servers. Any state can have either value, so read it from the snapshot, or await client.waitUntilClosable(), to decide whether teardown is safe. See Leave and switch encounters.

Failed note generation​

There is no failed state. A failed generation sends a snapshot with reason set to NOTE_GENERATION_FAILED and failureReason set, on the state the encounter falls back to, usually PAUSED.

Listening to changes​

stateChanged fires on load, every time state, availableActions, or canBeClosed changes, when a note generation fails, and after a command the iframe rejected (with the current state).

Events are not replayed. A stateChanged listener added before ready receives the first state. One added later only receives future changes. Use await client.ready or getCurrentState() to bootstrap. getCurrentState() returns null until the first state, and after the client ended.

Exceptions in your listeners do not stop the SDK.