@arrowhealth/bridge-sdk
Version:
Bridge SDK provides web applications the ability to integrate with the Bridge Platform.
4 lines (3 loc) • 4.09 kB
JavaScript
/* Bridge SDK provided by Novo Health 2021-present. All rights reserved. */
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).bridge={})}(this,function(e){"use strict";var n,t;e.PlatformKind=void 0,(n=e.PlatformKind||(e.PlatformKind={})).ADVANCEDMD="advancedmd",n.ATHELAS="athelas",n.ATHENA="Athena",n.AZALEA="azalea",n.AZARA="azara",n.CAREECO="careeco",n.CLINICIENT="clinicient",n.CROSSTX="crosstx",n.ECW="eCW",n.ELATION="Elation",n.EMPOWER="empower",n.GGASTRO="ggastro",n.HELLONOTE="hellonote",n.HENO="heno",n.IKNOWMED="iknowmed",n.MATRIXCARE="matrixcare",n.MODMED="modmed",n.NETHEALTH="nethealth",n.NETSMART="netsmart",n.NEXTGEN="nextgen",n.OFFICEALLY="Office Ally",n.ONCOEMR="oncoemr",n.POINTCLICKCARE="pointclickcare",n.PRACTICEFUSION="practicefusion",n.PROMPT="prompt",n.PTEVERYWHERE="pteverywhere",n.PTPRACTICEPRO="ptpracticepro",n.RAINTREE="raintree",n.SIRRUS="sirrus",n.STRATAEMR="strataemr",n.STRATUS="stratus",n.STRIDE="stride",n.THRIVE="thrive",n.TEBRA="tebra",n.TOUCHWORKS="touchworks",n.TURBOPT="turbopt",n.WEBPT="webpt",n.OTHER="Other",function(e){e.CAPTURE_USER_EVENTS="bridge::capture_user_events",e.CLOSE_APP="bridge::close_app",e.DISABLE_TILE="bridge::disable_tile",e.ENABLE_TILE="bridge::enable_tile",e.GET_OPEN_ENCOUNTER="bridge::get_open_encounter",e.GET_PAGE="bridge::get_page",e.GET_PATIENT_INFO="bridge::get_patient",e.GET_PLATFORM="bridge::get_platform",e.HIDE_TILE="bridge::hide_tile",e.LOGIN="bridge::login",e.LOGOUT="bridge::logout",e.SET_OPEN_ENCOUNTER="bridge::set_open_encounter",e.PUSH_NOTIFICATION="bridge::push_notification",e.RELEASE_USER_EVENTS="bridge::release_user_events",e.SET_BADGE_COUNT="bridge::set_badge_count",e.SET_PATIENT_INFO="bridge::set_patient",e.SHOW_TILE="bridge::show_tile",e.DEPRECATED_GET_AUTH_USER="bridge::get_auth_user"}(t||(t={}));let i=0;function E(e,n){0===i++&&window.addEventListener("message",r,!1);const t=e=>n(e.detail,e.detail.srcWindow);return window.addEventListener(e,t),()=>{window.removeEventListener(e,t),0===--i&&window.removeEventListener("message",r)}}const o="BRIDGE_EVENT";function r(e){if("string"!=typeof e.data)return;let n;try{n=JSON.parse(e.data)}catch{return}n.eventType===o&&(n.srcWindow=e.source,window.dispatchEvent(new CustomEvent(n.event,{detail:n})))}const a=!(!window.opener||window.opener===window),T=!a&&window.parent!==window,d=(window.name+"").includes("bridge_"),s="2.9.3";function _(e,n){let t=window.parent;window.opener&&(t=window.opener),window!==t?window.name?function(e,n,t){const i={event:n,eventType:o,...t};e.postMessage(JSON.stringify(i),"*")}(t,e,{appId:window.name,data:n,sdkVersion:s}):console.warn("No app id assigned. Cannot post request."):console.warn("Cannot post message to self. No parent window found.")}e.captureUserEvents=function(){_(t.CAPTURE_USER_EVENTS)},e.closeApp=function(){_(t.CLOSE_APP)},e.disableTile=function(){_(t.DISABLE_TILE)},e.enableTile=function(){_(t.ENABLE_TILE)},e.getOpenEncounter=function(){return new Promise(e=>{d||e(null);const n=E(t.GET_OPEN_ENCOUNTER,({data:t})=>{n(),e(t)});_(t.GET_OPEN_ENCOUNTER)})},e.getPage=function(e=!1){return new Promise(n=>{d||n(null);const i=E(t.GET_PAGE,({data:e})=>{i(),n(e)});_(t.GET_PAGE,{deep:e})})},e.getPatient=async function(){return new Promise(e=>{d||e(null);const n=E(t.GET_PATIENT_INFO,({data:t})=>{n(),e(t)});_(t.GET_PATIENT_INFO)})},e.getPlatform=async function(){return new Promise(e=>{d||e(null);const n=E(t.GET_PLATFORM,({data:t})=>{n(),e(t)});_(t.GET_PLATFORM)})},e.hideTile=function(){_(t.HIDE_TILE)},e.inBridge=d,e.inIframe=T,e.inPopout=a,e.onOpenEncounterChanged=function(e){return E(t.SET_OPEN_ENCOUNTER,n=>e(n.data))},e.onPatientChanged=function(e){return E(t.SET_PATIENT_INFO,n=>e(n.data))},e.pushNotification=function(e){_(t.PUSH_NOTIFICATION,e)},e.releaseUserEvents=function(){_(t.RELEASE_USER_EVENTS)},e.setBadgeCount=function(e=0){_(t.SET_BADGE_COUNT,e)},e.showTile=function(){_(t.SHOW_TILE)},e.version=s});
//# sourceMappingURL=bridge.min.js.map