Skip to content

Latest commit

 

History

History
474 lines (357 loc) · 20.4 KB

Resume.js.md

File metadata and controls

474 lines (357 loc) · 20.4 KB

Resume.js

Client-sided Javascript for recorder and Socket.IO Client management

Classes

IDENTIFIER

IDENTIFIER class for implementation as patient, healthcare team. Its format can be customized by each hospital. This class is default format for Resume.

RESUME_DEFAULT_OPTION

RESUME_DEFAULT_OPTION class for implementation as object of Resume Option

AbstractResumeRESUME_DEFAULT_OPTION

Abstract class for any Resume

ResumeChildAbstractResume

ResumeChild class - manage the socket.io and session ID

ResumeRecorder

Class handling microphone and media recorder for Resume

ResumeOneResumeChild

ResumeOne is a class to manage microphone and sound chunk streaming via socket.io

Constants

EVENT_CLIENT_INIT : string

when Socket.IO client start to record

EVENT_SERVER_SESSION_ID : string

when Socket.IO server response session ID

STREAM_ERROR : string

when Socket.IO error occurs in server

SS_AUDIO_STREAM : string

when client streams sound to server

SS_RESP_TRNSCR : string

when server send transcript result back to client

REC_PAUSED : string

REC_PAUSED = "paused"; when recorder is paused.

REC_STOP : string

REC_STOP = "stopped"; when recorder is stopped.

REC_INACTIVE : string

REC_INACTIVE = "inactive"; when recorder is inactive.

REC_RECORDING : string

REC_RECORDING = "recording"; when recorder is recording.

REC_NULL : string

REC_NULL = null; when recorder object is null or undefined.

Functions

isFunc(obj)Boolean

check if given object is function

Typedefs

SoundHistory : Object

History object argument of onRecorderStop

getIntermediateUserTranscriptResume-REST-API-Connect~GroupText

Callback to get intermediate user transcript in object, called when client send sound chunk to server.

onReceiveTranscript : function

Callback to recieved intermediate and final result from server.

onReceiveFinalTranscript : function

Callback to recieved final result from server.

onRecorderStop : function

Callback to received record history when the voice recorder stopped

onError : function

Callback to be called when error occurs

IDENTIFIER

IDENTIFIER class for implementation as patient, healthcare team. Its format can be customized by each hospital. This class is default format for Resume.

Kind: global class

new IDENTIFIER(TXN, [HN], [Location], [Practioner], [extraDetail])

Param Type Description
TXN string | int Transaction number of action (e.g. Visit number , Admission number)
[HN] string | int Hospital number of patient
[Location] string | int that action is performed (e.g. OPD, IPD, Ward, Room)
[Practioner] string | int Identification information of main practioner (e.g. doctor, surgeon)
[extraDetail] string Extra detail of identifier e.g. note.

RESUME_DEFAULT_OPTION

RESUME_DEFAULT_OPTION class for implementation as object of Resume Option

Kind: global class

new RESUME_DEFAULT_OPTION([sioOnConnectionCallback], [sioOnConnectionCallback], [langSuggest], [multiSpeaker], [defaultSectionID], [defaultDocFormat], [msSoundChuck], [alertError], [getIntermediateUserTranscript], [onReceiveTranscript], [onReceiveFinalTranscript], [onRecorderStop], [onError])

Param Type Default Description
[sioOnConnectionCallback] callable Callback when Socket.IO connects to server successfully.
[sioOnConnectionCallback] callable Callback when Socket.IO disconnects from server.
[langSuggest] Array.<string> | string ['th-TH'] list of suggest voice language
[multiSpeaker] Boolean enable multispeaker mode (conversation mode) for API, set to false for dictation mode
[defaultSectionID] string | int 0 default section of client's organization for billing and statistics
[defaultDocFormat] String default document format for transcriptor to summary response data
[msSoundChuck] float 8000 size of sound chunk for sent to server in millisecond
[alertError] Boolean false alert if error
[getIntermediateUserTranscript] getIntermediateUserTranscript callback get intermediate user transcript in object
[onReceiveTranscript] onReceiveTranscript callback to recieved intermediate (and final) result from server.
[onReceiveFinalTranscript] onReceiveFinalTranscript callback to recieved final result from server.
[onRecorderStop] onRecorderStop callback to received record history when the voice recorder stopped
[onError] onError callback to handle error object or error message string, consist of err argument that can be error object or error message string.

AbstractResume ⇐ RESUME_DEFAULT_OPTION

Abstract class for any Resume

Kind: global class Extends: RESUME_DEFAULT_OPTION

ResumeChild ⇐ AbstractResume

ResumeChild class - manage the socket.io and session ID

Kind: global class Extends: AbstractResume Properties

Name Type Description
[tag] string | int for marking the time position (second) of sound chunk which let the API to return the text position. It is important in
dictation mode - to tell which part of form is correlated with sent sound.
[sentBlobSize] Array.<float> size (byte) of sent sound chunk
SessionId string ID of active session of sound listening
sectionId string | int ID of active section
transcript Resume-REST-API-Connect~Transcript Transcripted result from the API
isFinalTranscript Boolean true if the transcript response is final (ended).

resumeChild.getRecordTime() ⇒ float

getRecordTime() get recorded time of actual session

Kind: instance method of ResumeChild Returns: float - recorded time in seconds

resumeChild.getActiveSessionID() ⇒ string

getActiveSessionID() get active session ID

Kind: instance method of ResumeChild Returns: string - active session ID

ResumeRecorder

Class handling microphone and media recorder for Resume

Kind: global class Properties

Name Type Default Description
[recorder] RecordRTC RecordRTC variable
[microphone] MediaStream Microphone variable
[alertError] Boolean call alert() if error
[msSoundChuck] float 1000 time interval to send sound chunk to Socket.IO

resumeRecorder.getStatus() ⇒ string | null

Get status of recoder can be one of REC_PAUSED = "paused", REC_STOP = "stopped", REC_INACTIVE = "inactive", REC_RECORDING = "recording", REC_NULL = null

Kind: instance method of ResumeRecorder Summary: get status of recoder Returns: string | null - recorder status null, "recording", "paused", "stopped" or "inactive".

resumeRecorder.pause()

pause the recorder

Kind: instance method of ResumeRecorder

ResumeOne ⇐ ResumeChild

ResumeOne is a class to manage microphone and sound chunk streaming via socket.io

Kind: global class Extends: ResumeChild Properties

Name Type Description
recorder ResumeRecorder object of resume recorder to manage microphone.

new ResumeOne(socket, [resumeOption])

class constructor and set the event listener of socket.io

Param Type Description
socket Socket.IO Socket.IO client object, e.g. create from io(url,option)
[resumeOption] RESUME_DEFAULT_OPTION | Object option for ResumeBase Class

resumeOne.getStatus() ⇒ string

getStatus() get status of recorder

Kind: instance method of ResumeOne Returns: string - recorder status as the const REC_PAUSED = "paused", REC_STOP = "stopped", REC_INACTIVE = "inactive", REC_RECORDING = "recording", REC_NULL = null;

resumeOne.newSession([hint], identifier, sectionID, docFormat, [langSuggest])

newSession - tell the speech API to create new session ID and create recording object. Then the API will response to sessionID property

Kind: instance method of ResumeOne Summary: create new session ID which will be stored in sessionID property.

Param Type Default Description
[hint] Array.<string> | string hint for the voice-to-text transcripter
identifier * the object of identification data of patients (Transaction number, Visit number, Admission number, Hospital number) and healthcare workers (for researching or other purposes of each organization). This data will store (in local not sent outside private network.
sectionID string | int e.g. department number, section of organization name
docFormat string Format of document to let the speech-to-text API to generate returned data - reference the name from "C-CDA 1.1.0 on FHIR" otherwise
will be "Default". Please read README.md and http://hl7.org/fhir/us/ccda/artifacts.html
[langSuggest] Array.<string> | string BCP-47 language code in string type or array of string type ordered by highest priority to suggest the speech-to-text API - the default is located in ./public/lang.json . See more detail of BCP-47

resumeOne.endSession([userTranscript], [callback])

endSession(userTranscript, callback) - end the listening session, send user-filled form to the speech API (for R&D). Then the API will response to onReceiveFinalTranscript and onReceiveTranscript callable.

Kind: instance method of ResumeOne Summary: end the session, send form data to the API

Param Type Description
[userTranscript] Object User-filled form data, should be followed the field name in "C-CDA 1.1.0 on FHIR" otherwise will be "other" - http://hl7.org/fhir/us/ccda/artifacts.html
[callback] callable to be called when the recorder javascript already stopped (already terminated microphone) and it do not wait for API response.

resumeOne.pause()

pause() - Pause the recording session if allowPause is true.

Kind: instance method of ResumeOne

resumeOne.resume()

resume() - Resume the paused session if allowPause is true.

Kind: instance method of ResumeOne

resumeOne.getRecordTime() ⇒ float

getRecordTime() get recorded time of actual session

Kind: instance method of ResumeOne Overrides: getRecordTime Returns: float - recorded time in seconds

resumeOne.getActiveSessionID() ⇒ string

getActiveSessionID() get active session ID

Kind: instance method of ResumeOne Overrides: getActiveSessionID Returns: string - active session ID

ResumeOne.loadSectionList(urlSectionJSON) ⇒ Promise

static loadSectionList(urlSectionJSON) - load preset section information in json file.

Kind: static method of ResumeOne Returns: Promise - Promise(response) from jQuery.get method - containing section information JSON data

Param Type Description
urlSectionJSON string | URL URL to preset section information

EVENT_CLIENT_INIT : string

when Socket.IO client start to record

Kind: global constant

EVENT_SERVER_SESSION_ID : string

when Socket.IO server response session ID

Kind: global constant

STREAM_ERROR : string

when Socket.IO error occurs in server

Kind: global constant

SS_AUDIO_STREAM : string

when client streams sound to server

Kind: global constant

SS_RESP_TRNSCR : string

when server send transcript result back to client

Kind: global constant

REC_PAUSED : string

REC_PAUSED = "paused"; when recorder is paused.

Kind: global constant

REC_STOP : string

REC_STOP = "stopped"; when recorder is stopped.

Kind: global constant

REC_INACTIVE : string

REC_INACTIVE = "inactive"; when recorder is inactive.

Kind: global constant

REC_RECORDING : string

REC_RECORDING = "recording"; when recorder is recording.

Kind: global constant

REC_NULL : string

REC_NULL = null; when recorder object is null or undefined.

Kind: global constant

isFunc(obj) ⇒ Boolean

check if given object is function

Kind: global function Returns: Boolean - true if obj is function, otherwise false.

Param Type Description
obj * object to be check

SoundHistory : Object

History object argument of onRecorderStop

Kind: global typedef Properties

Name Type Description
session_id string session ID.
identifier * identification data for location, patients and practitioner
url URL Blob URL of total sound
blobsize int size of Blob
user_transcript object user-filled form data

getIntermediateUserTranscript ⇒ Resume-REST-API-Connect~GroupText

Callback to get intermediate user transcript in object, called when client send sound chunk to server.

Kind: global typedef Returns: Resume-REST-API-Connect~GroupText - Object of user transcript

onReceiveTranscript : function

Callback to recieved intermediate and final result from server.

Kind: global typedef

Param Type Description
transcript Resume-REST-API-Connect~Transcript object of transcript text from server in document format that set when client create new session ID.
isEnd Boolean true if this transcript is final and session close completely.

onReceiveFinalTranscript : function

Callback to recieved final result from server.

Kind: global typedef

Param Type Description
transcript Resume-REST-API-Connect~Transcript object of transcript text from server in document format that set when client create new session ID.

onRecorderStop : function

Callback to received record history when the voice recorder stopped

Kind: global typedef

Param Type Description
history SoundHistory Object of history

onError : function

Callback to be called when error occurs

Kind: global typedef

Param Type Description
error Object | string error object or error message string.

© 2021 - copyright by Tanapat Kahabodeekanokkul - the founder of RESUME.