Heidi widget
Methods & callbacks

Recommended use

// open the widget
document.getElementById('heidi-button').addEventListener('click', () => {
  Heidi.open({
    patient: {
      id: '123',
      name: 'John Doe',
      gender: 'Male',
      dob: '1990-01-01',
    },
  });
});
 
// open the widget with a custom template
document.getElementById('heidi-button').addEventListener('click', () => {
  Heidi.open({
    template: templateData, //templateData is your custom template object
    patient: {
      id: '123',
      name: 'John Doe',
      gender: 'Male',
      dob: '1990-01-01',
    },
  });
});

All methods and callbacks

Heidi.open(params?)

AttributeValue
ParamsOpen parameters described below.
DescriptionOpens Heidi and starts a new session.
- If a sessionId is specified, the widget will open that session.
- If startNewSession is set to true, the widget will create a new session, regardless of whether a sessionId is provided.

Heidi.close(params?)

AttributeValue
Paramsparams?:{ keepSession?: boolean, force?: boolean }: set params.force to close Heidi skipping the confirmation step. If params.keepSession is true and params.force is used, then Heidi will keep the current session open.
DescriptionClose Heidi, showing a confirmation modal unless params.force is set to true.

Heidi.onPushData(callback)

AttributeValue
Paramscallback(data): a function called when the user chooses to push notes from the Heidi library to your EHR. data.notesData contains the note data as a string, if a template was not provided, or following the Template interface.
DescriptionTriggered when a user clicks Push Note in the Heidi widget. If this callback is not set, the Push Note button will not be available on the UI.

Heidi.onPushDocument(callback)

AttributeValue
Paramscallback(data): a function called when the user chooses to push document from the Heidi library to your EHR. data.title and data.content contain the document title and content.
DescriptionTriggered when a user clicks Push Document in the Heidi widget. If this callback is not set, the Push Document button will not be available on the UI.

Heidi.onSessionStarted(callback)

AttributeValue
Paramscallback(sessionId): a function called when a new Heidi Session is created. sessionId is a string containing the current Heidi Session Id
DescriptionReturns the sessionId of the current Heidi session.

Heidi.onTokenExpired(callback)

AttributeValue
Paramscallback(): a function called when the current Heidi token expires.
DescriptionWhen called, use this callback to generate a new token and provide it to the widget via Heidi.setToken (see below).

Heidi.setToken(token)

AttributeValue
ParamssetToken: a valid Heidi JWT token.
DescriptionUpdate the current token used by Heidi.

Heidi.onOpen(callback)

AttributeValue
Paramscallback: called when Heidi is opened.
DescriptionCalled when the Heidi widget is opened.

Heidi.onClose(callback)

AttributeValue
Paramscallback: called when Heidi is closed.
DescriptionCalled when the Heidi widget is closed.

Heidi.setPatient(patientInfo)

AttributeValue
ParamspatientInfo: PatientInfo: patient information for the current patient in your EMR. See below for more info on the data type.
DescriptionUpdate the patient information for the current session.

Heidi.setContext(context)

AttributeValue
Paramscontext: HeidiContext: an object containing a context information string, {context: string}.
DescriptionSet context information for the session, if no context was set before. This can be used to set Medications, Allergies and any other patient info to enrich Heidi's notes.

Heidi.onResize(callback)

AttributeValue
Paramscallback(expanded: boolean): a function called when the user resizes the Heidi widget. expanded is a boolean indicating whether the widget is expanded or not.
DescriptionCalled when the user resizes(expands or collapses) the Heidi widget.

Heidi.onRecordingStarted(callback)

AttributeValue
Paramscallback(): a function called when the user starts a recording in the Heidi widget
DescriptionCalled when the user starts a recording.

Heidi.onRecordingStopped(callback)

AttributeValue
Paramscallback(): a function called when the user stops a recording in the Heidi widget
DescriptionCalled when the user stops a recording.

Widget open parameters

The Heidi.open() method accepts an optional params object with the following properties:

AttributeTypeValue
patientPatientInfoPatient information as defined in Patient Information
sessionIdstringA valid Heidi Session ID, obtained from Heidi.onSessionStarted
templateTemplateCustom template to use for the session. See Custom Templates for more info on the data structure.
startNewSessionbooleanWhether to start a new session, regardless of whether a sessionId is provided.
contextstringSet context information for the session, if no context was set before. This can be used to set Medications, Allergies and any other patient info to enrich Heidi's notes.

Typescript Interface

interface HeidiOpenParams {
  template?: Template,
  patient?: PatientInfo,
  sessionId?: string,
  startNewSession?: boolean
}