SDK: EHR Integration

  1. Overview

This guide will get you all set up and ready to use the Autoscriber Javascript SDK. The SDK is a type safe Typescript Library that allows you to make recordings in any major browser, as well as acting as an interface to the Autoscriber API.

  1. Architecture Diagram

The below steps in red represent the Autoscriber SDK Integration.

  1. Set up the Autoscriber SDK

Getting Started:

Steps a - d below will get to starting in using the Autoscriber SDK and provide you with an API response, to be used when initialising the SDK in future steps.

a. Request an API Key

You can request an API key by emailing autoscriber at integrations@autoscriber.com

We will provide you with an API key via a secure 1password link.

b. Create a scribe via the /scribe endpoint

Call the below endpoint through a POST request:

https://io.autoscriber.com/v1/scribe

Headers

The headers are as follows:

  • api-key
    • Type: string
    • Value: Your api-key provided in Step a.
  • Content-Type
    • Type: string
    • Value: application/json

Body

The body attributes are as follows:

Name

Description

Type

Required/Optional

priority Value between 1-9, you can prioritise certain requests within your bandwidth. Integer
billingReference

This is the value (between 0 and 40 characters) Autoscriber uses to distinguish between EHRs, environments and customers. Therefore, please use the following guidelines:

EHR Test Environment:

"EHRName_Test"

EHR Prod Environment:

"EHRName_Prod"

Once a customer starts using the integration, please use the following guidelines:

"EHRName_CustomerName_Test" or "EHRName_CustomerName_Prod"

String Required
userId An optional userId that enables the api to personalise the response. Value must between 0 and 40 characters. String Optional
communication

Configuring the communication methods.

See attributes below.

Object Required
in

The language and audio type of the audio being received over the API.

See attributes below.

Object Required
out

The types of outputs required.

See attributes below.

Object Required

The above nested communication attributes are as follows:

Name

Description

Type

Required/Optional

method See SDK Communication Methods. Options include get|socketio|sse|webhook Boolean Required
webhook

Required if method===webhook

See attributes below.

Object Optional

The above nested webhook attributes are as follows:

Name

Description

Type

Required/Optional

url The url Autoscriber should call String Required
headers Optional headers Autoscriber will use when posting to your url (e.g. auth headers) String Optional

The above nested in attributes are as follows:

Name

Description

Type

Required/Optional

type This needs to have the value conversation . String Required
language The language of the input. Must be one of the supported languages en|nl|de . String Required
audioType The format of the audio. Options include mp3webmwavflacoggm4a . Required if type  includes audio . String Required

The above nested out attributes are as follows:

Name

Description

Type

Required/Optional

type

type refers to the templates that you want to make available for selection.

See here for Dutch templates

See here for English templates

String Optional
toggleCodes To indicate if you want to receive medical coding with the note. Boolean Optional
coding_systems

Whether SNOMED_CT or ICD10 medical codes are generated.

If coding is needed, then either "SNOMED_CT" or "ICD10" must be included

String

If toggleCodes is set as true , then this is required.

If toggleCodes is false , this line must be left out.

Example request body

An example of the body is as follows:

{
"priority": 1,
"billingReference": "EHRName_Test",
"userId": "user123",
"communication": [{"method":"socketio"}],
"in": [{"type":"conversation", "language":"en", "audioType":"mp3"}],
"out": [{"type":"standard_en", "togglecodes":true, "coding_systems":SNOMED_CT}]
} 

JSON Example Response:

{
"id": "<ID>",
"location": "https://io.autoscriber.com/v1/scribe/<ID>",
"chunkLocation": "https://io.autoscriber.com/v1/scribe/<ID>"
}

JSON Posting chunks to chunkLocation:

{
  "index": 0,
  "base64": "<STRING>",
  "final": false
}

You must then use the API response from /scribe (above) when initialising the SDK.

c. Installation via npm

Install the Autoscriber  package via npm or yarn.

npm:
npm install autoscriber
yarn:
yarn install autoscriber

Import the Autoscriber package. If you are using Typescript you can access the exported Types for strict typing.

Javascript:
  import Scribe, { SPECIALTIES } from "autoscriber";
  // For typescript strict typing
  import type {
    ConnectionConfig,
    RecordingDevice,
    StateType,
    RecordingDeviceList
  } from "autoscriber";

d. Initialise the SDK

Now that you have imported the SDK into your working directory, add the following code to initialise the Autoscriber JavaScript SDK. ConnectionConfig can be directly assigned to the response you get from the /scribe api endpoint.

Javascript

//Callback function that will be used to listen to state updates
function myCallback(state: StateType): void {
    // State can be saved here every time its updated
}


let response: ConnectionConfig = await doCreateScribeAPICall(); // response from /scribe api call can be injected into config directly


// Initialize the sdk with required configs
let scribe = new Scribe(response, myCallback);


// Connect the sdk to server
await scribe.connect().then(async (connection) => {
    // SDK successfully connected, proceed with next steps
});

Set up the recording:

Steps e - j will explain how you can set the recording of audio through the Autoscriber SDK.

e. Setting up a Recording Device

Before we can start with a new recording, we first have to establish a Recording Device . Recording devices can be any input device currently connected to the host.


Using the Autoscriber SDK to get Recording devices:

.getAvailableRecordingDevices()

Javascript
await scribe
	.getAvailableRecordingDevices()
	.then((res: RecordingDeviceList) => {
          // List of available devices will be in the response.availableMicrophones
	        let microphones = res.availableMicrophones;
	})
	.catch((err) => {
		console.log(err);
	});

The RecordingDeviceList  type will return a list of RecordingDevice type, which has the following properties:

Name

Description

Type

Required/Optional

deviceId The deviceId of the recording device. String Required
name The name of the recording device as configured on the device properties. String Required

f. Starting a New Recording

Starting a recording using the Autoscriber SDK will automatically update Autoscriber's stateListener with the real-time transcript. You can also make use of the Autoscriber Waveform to include microphone activity detection for User Experience, see guide below.

.startRecording()

Javascript
let selectedMicrophone = microphones[0].deviceId;// Default to first available recording device for demo, and send through deviceId to the sdk

// Without waveform
scribe.startRecording(selectedMicrophone); 

// With waveform
scribe.startRecording(selectedMicrophone, waveFormConfig); 

g. How to set up the Autoscriber Waveform using the SDK

You can also make use of the Autoscriber Waveform by passing in a config  to initialise the waveform. Example of the waveform below:

WaveSurferConfig

Javascript
// For typescript strict typing
import type { WaveSurferConfig } from "autoscriber";

const waveSurferConfig: WaveSurferConfig = {
  container: "#myContainer", // You can either pass the ID of a div that you want the wavesurfer attached to, or the HTMLElement itself
  waveColor: "#00b7f0", // The hex color value of the wave
  progressColor: "#00b7f0", // The hex color value of the progress bar
  barWidth: 5, // The width of the wave bars
  barRadius: 10, // Border radius on each of the wave bars
  barHeight: 1, // Height of the wave bars
  height: "auto", // The height of the waveform in pixels, or "auto" to fill the container height
};

WaveSurfer Div

HTML
<div id="myContainer"></div>

<!-- CSS -->
#mic {
  height: 200px; // Whatever value you want the height to be
  width: 300px; // Whatever value you want the width to be
}

WaveForm config

Name

Description

Type

Required/Optional

container An HTML element or selector where the waveform will be rendered HTMLElement | string Required
barWidth If set, the waveform will be rendered with bars like this: ▁ ▂ ▇ ▃ ▅ ▂ number Optional
barGap Spacing between bars in pixels number Optional
barRadius Rounded borders for bars number Optional
barHeight A vertical scaling factor for the waveform number Optional
height The height of the waveform in pixels, or "auto" to fill the container height number | 'auto' Optional
width The width of the waveform in pixels or any CSS value; defaults to 100% number | string Optional
waveColor The colour of the waveform string | string[] | CanvasGradient Optional
progressColor The colour of the progress mask string | string[] | CanvasGradient Optional

h. Pausing a Recording

Pause a recording using the Autoscriber SDK, this will halt all operations on the Recording Device and the API until recording has resumed.

.pauseRecording()

Javascript
scribe.pauseRecording();

i. Resuming a Recording

Resume a recording using the Autoscriber SDK, this will continue the recording from the point where it was paused.

.resumeRecording()

Javascript
scribe.resumeRecording();

j. Stopping a Recording

Stop a recording using the Autoscriber SDK, this will automatically kick off output generation once the transcript has been finalized.

.stopRecording()

Javascript
scribe.stopRecording();

Generating outputs:

Steps k - m will aid you in generating outputs after a recording has been finalised with the Autoscriber SDK, as well as allowing you to regenerate already existing outputs in hopes of a different outcome.

k. Getting Available Output Types

Firstly we need to establish which output types are still available to use in case there has been previous outputs attached to the scribe. We can use the Autoscriber SDK for this operation by calling the .getAvailableOutTypes()  method. This method will respond with a string of allowed output types for the next operation - taking into account already generated outputs and the SPECIALTY  param passed to it.

// Without SPECIALTY
let availableTemplates = scribe.getAvailableOutTypes(); // Returns a string array with available output templates

// With SPECIALTY
let availableTemplates = scribe.getAvailableOutTypes(SPECIALTY.GP); // Returns a string array with available output templates, SPECIALTY will affect this

l. Generating a New Output

When we are generating a new output we need to send the output name of the template we would like to generate to the sdk using the .generateNewOutput("myOutput")  method. Generating a new output will automatically adjust the availableOutputs  you get from the SDK, it is good practice to always refer to that method if any outputs have been generated. Assuming you have done the step above, you can continue by doing the following:

scribe.generateNewOutput(availableTemplates[0]); //For demo purposes just default to first available template

m. Regenerating an Existing Output

When you want to regenerate an existing output you will need to send the existing output name to the .regenerateOutput("myExistingOutput") method.

scribe.regenerateOutput("soap_en"); //String value of the output type that has been generated already
  1. Receiving the Summary and Transcript

After an output has been generated (e.g. see here), the summary and transcript will be sent to you via the method stipulated in the original request (see here for the description in this article, and here to get an overview of the SDK Communication Methods).

Here is an example of the resultant summary that you will receive:

{
  "standard_en": {
      "final": true,
      "data": [
        {
          "items": [
            {
              "sentences": [],
              "text": "Strong heachaches since 5 days"
            }
          ],
          "section": "Subjectief"
        },
        {
          "items": [
            {
              "sentences": [],
              "text": "Refer to neurologist"
            }
          ],
          "section": "Plan"
        }
      ],
    }
}
  1. Demo/Example App

    For a detailed demo you can visit our example application repository. This repository also includes source code that you can use to find examples of the AutoscriberSDK in practice.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us