@oystehr/sdk
Version:
Oystehr SDK
3 lines (2 loc) • 31.4 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});class t extends Error{constructor({message:e,code:i,cause:s}){super(e,{cause:s}),Object.setPrototypeOf(this,t.prototype),this.code=i,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function e(t){var e;const i=[];for(const s of null!==(e=t.issue)&&void 0!==e?e:[])s.details&&s.details.text&&i.push(s.details.text);return i.length||i.push("Unknown FHIR error"),i.join(",")}class i extends t{constructor({error:t,code:s}){super({message:e(t),code:s}),Object.setPrototypeOf(this,i.prototype),this.cause=t,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function s(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{c(s.next(t))}catch(e){n(e)}}function u(t){try{c(s.throw(t))}catch(e){n(e)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,u)}c((s=s.apply(t,e||[])).next())}))}function r(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;const n=[];for(let te=0;te<256;++te)n.push((te+256).toString(16).slice(1));let o;const u=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function a(t,e,i){if(c.randomUUID&&!t)return c.randomUUID();const s=(t=t||{}).random??t.rng?.()??function(){if(!o){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");o=crypto.getRandomValues.bind(crypto)}return o(u)}();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=15&s[6]|64,s[8]=63&s[8]|128,function(t,e=0){return(n[t[e+0]]+n[t[e+1]]+n[t[e+2]]+n[t[e+3]]+"-"+n[t[e+4]]+n[t[e+5]]+"-"+n[t[e+6]]+n[t[e+7]]+"-"+n[t[e+8]]+n[t[e+9]]+"-"+n[t[e+10]]+n[t[e+11]]+n[t[e+12]]+n[t[e+13]]+n[t[e+14]]+n[t[e+15]]).toLowerCase()}(s)}const h=[408,429,500,502,503,504],d=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class l{constructor(t){this.config=t}request(e,i,r){return(n,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config;try{return yield m(r,s,e,i)(n,o)}catch(u){const e=u;throw new t({message:e.message,code:e.code,cause:e.cause})}}))}fhirRequest(e,r){return(n,o)=>s(this,void 0,void 0,(function*(){try{const t=()=>{var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.fhirApiUrl)&&void 0!==e?e:"https://fhir-api.zapehr.com"},i=()=>this.config;return yield m(t,i,e,r)(n,o)}catch(s){const e=s;if("string"==typeof e.message)throw new t({message:e.message,code:e.code,cause:e.cause});throw new i({error:e.message,code:e.code})}}))}}function p(t){return"accessToken"in t}function m(e,i,r,n){return(o,u)=>s(this,void 0,void 0,(function*(){var c,l,m,f,g,b,y,q,j,w,U,k,S,O,x;const T=o&&!u&&!Array.isArray(o)&&p(o)?{}:null!==(c=o)&&void 0!==c?c:{},E=o&&!u&&!Array.isArray(o)&&p(o)?o:u,z=n.toLowerCase(),A=i(),I=null!==(l=A.fetch)&&void 0!==l?l:fetch,P=null!==(m=null==E?void 0:E.accessToken)&&void 0!==m?m:A.accessToken,R=null!==(f=null==E?void 0:E.projectId)&&void 0!==f?f:i().projectId;let N=r,$=T;if(!Array.isArray(T)){const[e,i]=function(e,i){const s=Object.assign({},i),r=e.replace(/\{([^}]+)\}/g,((e,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new t({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s);return[r,n.length?n.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{}]}(r,T);N=e,$=i}N=N.replace(/^\//,"");const W=e(),C=W.endsWith("/")?W:W+"/",_=new URL(N,C);let M;if(Array.isArray($))M=JSON.stringify($);else if(Object.keys($).length)if("get"===z)v($,_.searchParams);else if("application/x-www-form-urlencoded"===(null==E?void 0:E.contentType)){const t=new URLSearchParams;v($,t),M=t.toString()}else M=JSON.stringify($);else"application/x-www-form-urlencoded"!==(null==E?void 0:E.contentType)&&"post"===z&&(M="{}");const L=Object.assign(R?{"x-zapehr-project-id":R,"x-oystehr-project-id":R}:{},{"content-type":null!==(g=null==E?void 0:E.contentType)&&void 0!==g?g:"application/json"},P?{Authorization:`Bearer ${P}`}:{},(null==E?void 0:E.ifMatch)?{"If-Match":E.ifMatch}:{},{"x-oystehr-request-id":null!==(b=null==E?void 0:E.requestId)&&void 0!==b?b:a()}),D={retries:null!==(q=null===(y=A.retry)||void 0===y?void 0:y.retries)&&void 0!==q?q:3,jitter:null!==(w=null===(j=A.retry)||void 0===j?void 0:j.jitter)&&void 0!==w?w:20,delay:null!==(k=null===(U=A.retry)||void 0===U?void 0:U.delay)&&void 0!==k?k:100,onRetry:null===(S=A.retry)||void 0===S?void 0:S.onRetry,retryOn:[...null!==(x=null===(O=A.retry)||void 0===O?void 0:O.retryOn)&&void 0!==x?x:[],...h]};return D.retryOn.push(...h),function(t,e){return s(this,void 0,void 0,(function*(){var i,s;let r;for(const o of Array.from({length:(null!==(i=e.retries)&&void 0!==i?i:0)+1},((t,e)=>e)))try{return yield t()}catch(n){let t=!1;if("response"in n){const i=n;t=e.retryOn.includes(i.code),r={message:n.message,code:n.code}}else if(r=n,"code"in n&&"string"==typeof n.code){const e=n;t=d.includes(e.code)}if(!t)break;const i=Math.floor(Math.random()*(e.jitter+1));yield new Promise((t=>setTimeout(t,e.delay+i))),e.onRetry&&o!==(null!==(s=e.retries)&&void 0!==s?s:0)&&e.onRetry(o+1)}throw r}))}((()=>s(this,void 0,void 0,(function*(){var t,e,i,s,r,n,o,u;const c=yield I(new Request(_,{method:z.toUpperCase(),body:M,headers:L})),a=c.body?yield c.text():null;let h;const d=c.headers.get("content-type");try{h=a&&((null==d?void 0:d.includes("application/json"))||(null==d?void 0:d.includes("application/fhir+json")))?JSON.parse(a):a&&((null==d?void 0:d.includes("application/xml"))||(null==d?void 0:d.includes("text/xml")))?function(t){try{const e=t.match(/<status>(\d+)<\/status>/),i=e?parseInt(e[1],10):null,s=t.match(/<output>([\s\S]*?)<\/output>/),r=s?s[1]:null;return null===i||null===r?null:{status:i,output:r}}catch(e){return null}}(a):null}catch(l){h=null}if(!c.ok||c.status>=400)throw{message:null!==(r=null!==(s=null!==(i=null!==(e="string"==typeof(null==h?void 0:h.output)?h.output:null===(t=null==h?void 0:h.output)||void 0===t?void 0:t.message)&&void 0!==e?e:null==h?void 0:h.message)&&void 0!==i?i:h)&&void 0!==s?s:a)&&void 0!==r?r:c.statusText,code:null!==(u=null!==(o=null===(n=null==h?void 0:h.output)||void 0===n?void 0:n.code)&&void 0!==o?o:null==h?void 0:h.code)&&void 0!==u?u:c.status,response:c};return h}))),D)}))}function v(t,e){for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>e.append(i,t))):e.append(i,s)}var f,g,b,y;class q extends l{constructor(t){super(t),f.add(this)}list(t){return this.request("/application","get",r(this,f,"m",g).bind(this))(t)}create(t,e){return this.request("/application","post",r(this,f,"m",g).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",r(this,f,"m",g).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",r(this,f,"m",g).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",r(this,f,"m",g).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",r(this,f,"m",g).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",r(this,f,"m",g).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",r(this,f,"m",g).bind(this))(t,e)}}f=new WeakSet,g=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class j extends l{constructor(t){super(t),b.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",r(this,b,"m",y).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",r(this,b,"m",y).bind(this))(t,e)}}b=new WeakSet,y=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};const w="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",U="addressString";function k(t){var e,i,s;if(function(t){return Object.hasOwn(t,"virtualService")}(t)){const i=null===(e=t.virtualService)||void 0===e?void 0:e.find((t=>{var e;return"https://fhir.zapehr.com/virtual-service-type"===(null===(e=t.channelType)||void 0===e?void 0:e.system)}));return null==i?void 0:i.addressString}if(!t.extension)return;const r=t.extension.find((t=>t.url===w));return(null==r?void 0:r.extension)?null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===U)))||void 0===s?void 0:s.valueString:void 0}var S,O,x,T,E,z,A,I;class P extends l{constructor(t){super(t),S.add(this),this.ENCOUNTER_VS_EXTENSION_URL=w,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=U,this.getConversationIdFromEncounter=k}create(t,e){return this.request("/messaging/conversation","post",r(this,S,"m",O).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",r(this,S,"m",O).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,S,"m",O).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,S,"m",O).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,S,"m",O).bind(this))(t,e)}}S=new WeakSet,O=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class R extends l{constructor(t){super(t),x.add(this)}get(t,e){return this.request("/developer/{id}","get",r(this,x,"m",T).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",r(this,x,"m",T).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",r(this,x,"m",T).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",r(this,x,"m",T).bind(this))(t,e)}list(t){return this.request("/developer","get",r(this,x,"m",T).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",r(this,x,"m",T).bind(this))(t,e)}}x=new WeakSet,T=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class N extends l{constructor(t){super(t),E.add(this)}searchAllergens(t,e){return this.request("/allergen","get",r(this,E,"m",z).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",r(this,E,"m",z).bind(this))(t,e)}getMedication(t,e){return this.request("/medication/details","get",r(this,E,"m",z).bind(this))(t,e)}getConfiguration(t){return this.request("/config","get",r(this,E,"m",z).bind(this))(t)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",r(this,E,"m",z).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",r(this,E,"m",z).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",r(this,E,"m",z).bind(this))(t,e)}addPatientPharmacy(t,e){return this.request("/patient/{patientId}/pharmacies","post",r(this,E,"m",z).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",r(this,E,"m",z).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",r(this,E,"m",z).bind(this))(t,e)}searchPharmacies(t,e){return this.request("/pharmacy","get",r(this,E,"m",z).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",r(this,E,"m",z).bind(this))(t,e)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",r(this,E,"m",z).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",r(this,E,"m",z).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",r(this,E,"m",z).bind(this))(t,e)}}E=new WeakSet,z=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.erxApiUrl)&&void 0!==e?e:"https://erx-api.zapehr.com/v3"};class $ extends l{constructor(t){super(t),A.add(this)}offboard(t){return this.request("/offboard","post",r(this,A,"m",I).bind(this))(t)}onboard(t){return this.request("/onboard","post",r(this,A,"m",I).bind(this))(t)}getConfiguration(t){return this.request("/config","get",r(this,A,"m",I).bind(this))(t)}send(t,e){return this.request("/send","post",r(this,A,"m",I).bind(this))(t,e)}}A=new WeakSet,I=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.faxApiUrl)&&void 0!==e?e:"https://fax-api.zapehr.com/v1"};const W=65535;function C(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i,params:s}=t;let r;s&&(r=Object.entries(s).reduce(((t,[e,i])=>(t[i.name]||(t[i.name]=[]),t[i.name].push(i.value),t)),{}));const n=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var t,e;return null!==(e=null===(t=this.entry)||void 0===t?void 0:t.map((t=>t.resource)).filter((t=>void 0!==t)))&&void 0!==e?e:[]}})}))}function _(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i}=t;return this.fhirRequest(`/${i}`,"POST")(t,e)}))}function M(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"GET")({},i)}))}function L(t,e){return s(this,void 0,void 0,(function*(){const{id:i,resourceType:s}=t;return this.fhirRequest(`/${s}/${i}`,"PUT")(t,Object.assign(Object.assign({},e),{ifMatch:(null==e?void 0:e.optimisticLockingVersionId)?`W/"${e.optimisticLockingVersionId}"`:void 0}))}))}function D(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,operations:i},s){return this.fhirRequest(`/${t}/${e}`,"PATCH")(i,Object.assign(Object.assign({},s),{contentType:"application/json-patch+json",ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0}))}))}function V(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function G(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,versionId:i,count:s,offset:r},n){return i?this.fhirRequest(`/${t}/${e}/_history/${i}`,"GET")({},n):s?this.fhirRequest(`/${t}/${e}/_history?_total=accurate&_count=${s}\n ${r?`&_offset=${r}`:""}`,"GET")({},n):this.fhirRequest(`/${t}/${e}/_history?_total=accurate`,"GET")({},n)}))}function F(t){const{method:e,url:i}=t,s={request:{method:e,url:i}};if(i.split("?").length>1){const[t,e]=i.split("?"),r=e.split("&").map((t=>{const[e,i]=t.split("=");return{name:e,value:i}})).reduce(((t,{name:e,value:i})=>e?(t[e]||(t[e]=[]),t[e].push(i),t):t),{}),n=new URLSearchParams;v(r,n),s.request.url=`${t}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(e))return s;if("PUT"===e){const{resource:e}=t;return{request:Object.assign(Object.assign({},s.request),{ifMatch:t.ifMatch}),resource:e}}if("PATCH"===e){if("resource"in t)return{request:Object.assign(Object.assign({},s.request),{ifMatch:t.ifMatch}),resource:t.resource};const e=function(t){const e=(new globalThis.TextEncoder).encode(t);let i="";for(let s=0;s<e.length;s+=W){const t=e.subarray(s,s+W);i+=globalThis.btoa(String.fromCodePoint.apply(void 0,t))}return i}(JSON.stringify(t.operations));return Object.assign(Object.assign({},s),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:e}})}if("POST"===e){const{resource:e,fullUrl:i}=t;return Object.assign(Object.assign({},s),{resource:e,fullUrl:i})}throw new Error("Unrecognized method")}function H(t,e){return s(this,void 0,void 0,(function*(){const i=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:t.requests.map(F)},e);return Object.assign(Object.assign({},i),{entry:i.entry,unbundle:function(){var t,e;return null!==(e=null===(t=this.entry)||void 0===t?void 0:t.map((t=>t.resource)).filter((t=>void 0!==t)))&&void 0!==e?e:[]},errors:function(){var t;return null===(t=this.entry)||void 0===t?void 0:t.filter((t=>{var e,i,s,r;return(null===(i=null===(e=t.response)||void 0===e?void 0:e.status)||void 0===i?void 0:i.startsWith("4"))||(null===(r=null===(s=t.response)||void 0===s?void 0:s.status)||void 0===r?void 0:r.startsWith("5"))})).map((t=>{var e;return null===(e=t.response)||void 0===e?void 0:e.outcome})).filter((t=>void 0!==t))}})}))}function B(t,e){return s(this,void 0,void 0,(function*(){const i=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:t.requests.map(F)},e);return Object.assign(Object.assign({},i),{entry:i.entry,unbundle:function(){var t,e;return null!==(e=null===(t=this.entry)||void 0===t?void 0:t.map((t=>t.resource)).filter((t=>void 0!==t)))&&void 0!==e?e:[]}})}))}function J(t,e){const i=[];if(t.line&&i.push(...t.line),t.city||t.state||t.postalCode){const e=[];t.city&&e.push(t.city),t.state&&e.push(t.state),t.postalCode&&e.push(t.postalCode),i.push(e.join(", "))}return t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&i.push("["+t.use+"]"),i.join((null==e?void 0:e.lineSeparator)||", ").trim()}function X(t,e){const i=[];return t.prefix&&!1!==(null==e?void 0:e.prefix)&&i.push(...t.prefix),t.given&&i.push(...t.given),t.family&&i.push(t.family),t.suffix&&!1!==(null==e?void 0:e.suffix)&&i.push(...t.suffix),t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&i.push("["+t.use+"]"),i.join(" ").trim()}var Z,K,Q,Y,tt,et,it,st,rt,nt,ot,ut,ct,at,ht,dt,lt,pt,mt,vt,ft,gt,bt,yt,qt,jt,wt,Ut,kt,St,Ot,xt,Tt;class Et extends l{constructor(t){super(t),Z.add(this),this.search=C,this.create=_,this.get=M,this.update=L,this.patch=D,this.delete=V,this.history=G,this.batch=H,this.transaction=B,this.formatAddress=J,this.formatHumanName=X}}Z=new WeakSet;class zt extends l{constructor(t){super(t),K.add(this)}routeList(t){return this.request("/route","get",r(this,K,"m",Q).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",r(this,K,"m",Q).bind(this))(t,e)}routeGet(t,e){return this.request("/route/{routeGuid}","get",r(this,K,"m",Q).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",r(this,K,"m",Q).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",r(this,K,"m",Q).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,K,"m",Q).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",r(this,K,"m",Q).bind(this))(t,e)}}K=new WeakSet,Q=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.labApiUrl)&&void 0!==e?e:"https://labs-api.zapehr.com/v1"};class At extends l{constructor(t){super(t),Y.add(this)}list(t){return this.request("/m2m","get",r(this,Y,"m",tt).bind(this))(t)}create(t,e){return this.request("/m2m","post",r(this,Y,"m",tt).bind(this))(t,e)}me(t){return this.request("/m2m/me","get",r(this,Y,"m",tt).bind(this))(t)}get(t,e){return this.request("/m2m/{id}","get",r(this,Y,"m",tt).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",r(this,Y,"m",tt).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",r(this,Y,"m",tt).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",r(this,Y,"m",tt).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",r(this,Y,"m",tt).bind(this))(t,e)}}Y=new WeakSet,tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class It extends l{constructor(t){super(t),et.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",r(this,et,"m",it).bind(this))(t)}}et=new WeakSet,it=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Pt extends l{constructor(t){super(t),st.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",r(this,st,"m",rt).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",r(this,st,"m",rt).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",r(this,st,"m",rt).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",r(this,st,"m",rt).bind(this))(t,e)}}st=new WeakSet,rt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Rt extends l{constructor(t){super(t),nt.add(this)}get(t){return this.request("/project","get",r(this,nt,"m",ot).bind(this))(t)}update(t,e){return this.request("/project","patch",r(this,nt,"m",ot).bind(this))(t,e)}}nt=new WeakSet,ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Nt extends l{constructor(t){super(t),ut.add(this)}eligibilityCheck(t,e){return this.request("/rcm/eligibility-check","post",r(this,ut,"m",ct).bind(this))(t,e)}validateProfessionalClaim(t,e){return this.request("/rcm/professional-claim/validate","post",r(this,ut,"m",ct).bind(this))(t,e)}submitProfessionalClaim(t,e){return this.request("/rcm/professional-claim/submit","post",r(this,ut,"m",ct).bind(this))(t,e)}}ut=new WeakSet,ct=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class $t extends l{constructor(t){super(t),at.add(this)}list(t){return this.request("/iam/role","get",r(this,at,"m",ht).bind(this))(t)}create(t,e){return this.request("/iam/role","post",r(this,at,"m",ht).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",r(this,at,"m",ht).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",r(this,at,"m",ht).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",r(this,at,"m",ht).bind(this))(t,e)}}at=new WeakSet,ht=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Wt extends l{constructor(t){super(t),dt.add(this)}list(t){return this.request("/secret","get",r(this,dt,"m",lt).bind(this))(t)}set(t,e){return this.request("/secret","post",r(this,dt,"m",lt).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",r(this,dt,"m",lt).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",r(this,dt,"m",lt).bind(this))(t,e)}}dt=new WeakSet,lt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Ct extends l{constructor(t){super(t),pt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",r(this,pt,"m",mt).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,pt,"m",mt).bind(this))(t,e)}}pt=new WeakSet,mt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class _t extends l{constructor(t){super(t),vt.add(this)}searchCpt(t,e){return this.request("/cpt/search","get",r(this,vt,"m",ft).bind(this))(t,e)}searchHcpcs(t,e){return this.request("/hcpcs/search","get",r(this,vt,"m",ft).bind(this))(t,e)}}vt=new WeakSet,ft=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.terminologyApiUrl)&&void 0!==e?e:"https://terminology-api.zapehr.com/v1"};class Mt extends l{constructor(t){super(t),gt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",r(this,gt,"m",bt).bind(this))(t,e)}}gt=new WeakSet,bt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Lt extends l{constructor(t){super(t),yt.add(this)}me(t){return this.request("/user/me","get",r(this,yt,"m",qt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",r(this,yt,"m",qt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",r(this,yt,"m",qt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",r(this,yt,"m",qt).bind(this))(t,e)}resetMfa(t,e){return this.request("/user/{id}/reset-mfa","post",r(this,yt,"m",qt).bind(this))(t,e)}resetPasswordLink(t,e){return this.request("/user/{id}/reset-password-link","post",r(this,yt,"m",qt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",r(this,yt,"m",qt).bind(this))(t,e)}list(t){return this.request("/user","get",r(this,yt,"m",qt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",r(this,yt,"m",qt).bind(this))(t,e)}}yt=new WeakSet,qt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Dt extends l{constructor(t){super(t),jt.add(this)}get(t){return this.request("/version","get",r(this,jt,"m",wt).bind(this))(t)}}function Vt(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"}function Gt(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Vt.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function Ft(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Vt.bind(this))({action:"download",bucketName:t,"objectPath+":e}),s=yield fetch(i.signedUrl,{method:"GET"});if(!s.ok)throw new Error("Failed to download file");return s.arrayBuffer()}))}function Ht(e){return s(this,void 0,void 0,(function*(){var i,s;let r,n;const o=new URL(e.url);if("z3:"===o.protocol){const t=o.pathname.split("/").slice(1);r=o.hostname,n=t.join("/")}else{if(!o.href.startsWith(null!==(s=null===(i=this.config.services)||void 0===i?void 0:i.projectApiUrl)&&void 0!==s?s:"https://project-api.zapehr.com/v1"))throw new t({message:"Invalid Z3 URL",code:400});{const t=o.pathname.split("/").slice(3);r=t[0],n=t.slice(1).join("/")}}const u={action:"upload",bucketName:r,"objectPath+":n};return this.request("/z3/{bucketName}/{objectPath+}","post",Vt.bind(this))(u)}))}jt=new WeakSet,wt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Bt extends l{constructor(t){super(t),Ut.add(this),this.uploadFile=Gt,this.downloadFile=Ft,this.getPresignedUrlForZ3Url=Ht}listBuckets(t){return this.request("/z3","get",r(this,Ut,"m",kt).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",r(this,Ut,"m",kt).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",r(this,Ut,"m",kt).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,Ut,"m",kt).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,Ut,"m",kt).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,Ut,"m",kt).bind(this))(t,e)}}function Jt(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"}function Xt(t){return s(this,arguments,void 0,(function*({id:t,file:e,filename:i}){const s=yield this.request("/zambda/{id}/s3-upload","post",Jt.bind(this))({id:t,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:e})}))}Ut=new WeakSet,kt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Zt extends l{constructor(t){super(t),St.add(this),this.uploadFile=Xt}list(t){return this.request("/zambda","get",r(this,St,"m",Ot).bind(this))(t)}create(t,e){return this.request("/zambda","post",r(this,St,"m",Ot).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",r(this,St,"m",Ot).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",r(this,St,"m",Ot).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",r(this,St,"m",Ot).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",r(this,St,"m",Ot).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",r(this,St,"m",Ot).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",r(this,St,"m",Ot).bind(this))(t,e)}}St=new WeakSet,Ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Kt extends l{constructor(t){super(t),xt.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",r(this,xt,"m",Tt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",r(this,xt,"m",Tt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",r(this,xt,"m",Tt).bind(this))(t,e)}}xt=new WeakSet,Tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};let Qt=class{constructor(t){var e,i,s,r,n,o;this.config=t,null!==(e=(r=this.config).services)&&void 0!==e||(r.services={}),null!==(i=(n=this.config.services).projectApiUrl)&&void 0!==i||(n.projectApiUrl=t.projectApiUrl),null!==(s=(o=this.config.services).fhirApiUrl)&&void 0!==s||(o.fhirApiUrl=t.fhirApiUrl),this.application=new q(t),this.developer=new R(t),this.m2m=new At(t),this.messaging=new It(t),this.conversation=new P(t),this.transactionalSMS=new Mt(t),this.paymentMethod=new Pt(t),this.charge=new j(t),this.project=new Rt(t),this.rcm=new Nt(t),this.role=new $t(t),this.secret=new Wt(t),this.telemed=new Ct(t),this.user=new Lt(t),this.version=new Dt(t),this.z3=new Bt(t),this.zambda=new Zt(t),this.zambdaLogStream=new Kt(t),this.fax=new $(t),this.lab=new zt(t),this.erx=new N(t),this.terminology=new _t(t),this.fhir=new Et(t)}};class Yt extends Qt{}Yt.OystehrFHIRError=i,Yt.OystehrSdkError=t,exports.default=Yt;
//# sourceMappingURL=index.min.cjs.map