@oystehr/sdk 4.3.8 → 4.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -41
- package/dist/cjs/client/client.cjs +137 -5
- package/dist/cjs/client/client.cjs.map +1 -1
- package/dist/cjs/client/client.d.ts +28 -3
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.cjs +108 -17
- package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.d.ts +67 -12
- package/dist/cjs/resources/classes/fhir.cjs +3 -0
- package/dist/cjs/resources/classes/fhir.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir.d.ts +3 -0
- package/dist/cjs/resources/types/fhir.d.ts +67 -0
- package/dist/esm/client/client.d.ts +28 -3
- package/dist/esm/client/client.js +137 -5
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/fhir-ext.d.ts +67 -12
- package/dist/esm/resources/classes/fhir-ext.js +107 -19
- package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
- package/dist/esm/resources/classes/fhir.d.ts +3 -0
- package/dist/esm/resources/classes/fhir.js +4 -1
- package/dist/esm/resources/classes/fhir.js.map +1 -1
- package/dist/esm/resources/types/fhir.d.ts +67 -0
- package/package.json +1 -1
- package/src/client/client.ts +214 -7
- package/src/resources/classes/fhir-ext.ts +278 -38
- package/src/resources/classes/fhir.ts +3 -0
- package/src/resources/types/fhir.ts +88 -0
package/dist/cjs/index.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class e extends Error{constructor({message:t,code:i,cause:s}){super(t,{cause:s}),Object.setPrototypeOf(this,e.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 t(e){var t;const i=[];for(const s of null!==(t=e.issue)&&void 0!==t?t:[])s.details&&s.details.text&&i.push(s.details.text);return i.length||i.push("Unknown FHIR error"),i.join(",")}class i extends e{constructor({error:e,code:s}){super({message:t(e),code:s}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function s(e,t,i,s){return new(i||(i=Promise))((function(r,n){function o(e){try{a(s.next(e))}catch(t){n(t)}}function u(e){try{a(s.throw(e))}catch(t){n(t)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,u)}a((s=s.apply(e,t||[])).next())}))}function r(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;const o=[];for(let vt=0;vt<256;++vt)o.push((vt+256).toString(16).slice(1));let u;const a=new Uint8Array(16);var d={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};class c{constructor({level:e}){this._level=e}error(e,t={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify(Object.assign({message:e},t)))}info(e,t={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify(Object.assign({message:e},t)))}debug(e,t={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify(Object.assign({message:e},t)))}time(e,t={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify(Object.assign({message:e},t)))}timeEnd(e,t={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify(Object.assign({message:e},t)))}}const h=[408,429,500,502,503,504],l=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class p{constructor(e){this.config=e,this.logger=new c({level:this.config.logLevel})}request(t,i,r){return(n,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config,u=()=>this.logger;try{return yield m(r,s,u,t,i)(n,o)}catch(a){const t=a;throw this.logger.error(t.message,{code:t.code,cause:t.cause}),new e({message:t.message,code:t.code,cause:t.cause})}}))}fhirRequest(t,r){return(n,o)=>s(this,void 0,void 0,(function*(){try{const e=()=>{var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.fhirApiUrl)&&void 0!==t?t:"https://fhir-api.zapehr.com"},i=()=>this.config,s=()=>this.logger;return yield m(e,i,s,t,r)(n,o)}catch(s){const t=s;if("string"==typeof t.message)throw new e({message:t.message,code:t.code,cause:t.cause});throw new i({error:t.message,code:t.code})}}))}}function v(e){var t,i;return"accessToken"in e||"projectId"in e&&"string"==typeof(i=e.projectId)&&n.test(i)||"contentType"in e&&2===(null===(t=e.contentType)||void 0===t?void 0:t.split("/").length)||"requestId"in e||"ifMatch"in e&&e.ifMatch.startsWith('W/"')}function m(t,i,r,n,c){return(p,m)=>s(this,void 0,void 0,(function*(){var g,b,y,q,w,j,T,O,k,U,S,I,E,x;let[z,A]=function(e,t){var i;return[e&&!t&&!Array.isArray(e)&&v(e)?{}:null!==(i=e)&&void 0!==i?i:{},e&&!t&&!Array.isArray(e)&&v(e)?e:t]}(p,m);null!=A||(A={}),null!==(g=A.requestId)&&void 0!==g||(A.requestId=function(e){if(d.randomUUID&&!e)return d.randomUUID();const t=(e=e||{}).random??e.rng?.()??function(){if(!u){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");u=crypto.getRandomValues.bind(crypto)}return u(a)}();if(t.length<16)throw new Error("Random bytes length must be >= 16");return t[6]=15&t[6]|64,t[8]=63&t[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(t)}());const P=i(),R=r(),N=c.toLowerCase();R.debug("Beginning fetch",{method:N,path:n,requestId:null==A?void 0:A.requestId});const _=null!==(b=P.fetch)&&void 0!==b?b:fetch,$=null!==(y=null==A?void 0:A.accessToken)&&void 0!==y?y:P.accessToken,W=null!==(q=null==A?void 0:A.projectId)&&void 0!==q?q:P.projectId;let M=n,C=z;if(!Array.isArray(z)){const[t,i]=function(t,i){const s=Object.assign({},i),r=t.replace(/\{([^}]+)\}/g,((t,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new e({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(((e,t)=>Object.assign(Object.assign({},e),{[t]:s[t]})),{}):{}]}(n,z);M=t,C=i}R.debug("Substituted parameters in path",{method:N,path:n,requestId:null==A?void 0:A.requestId}),M=M.replace(/^\//,"");const D=t(),L=D.endsWith("/")?D:D+"/",G=new URL(M,L);let J;if(Array.isArray(C))J=JSON.stringify(C);else if(Object.keys(C).length)if("get"===N)f(C,G.searchParams);else if("application/x-www-form-urlencoded"===(null==A?void 0:A.contentType)){const e=new URLSearchParams;f(C,e),J=e.toString()}else J=JSON.stringify(C);else"application/x-www-form-urlencoded"!==(null==A?void 0:A.contentType)&&"post"===N&&(J="{}");R.debug("Prepared request body",{method:N,path:n,requestId:null==A?void 0:A.requestId});const F=Object.assign(W?{"x-zapehr-project-id":W,"x-oystehr-project-id":W}:{},{"content-type":null!==(w=null==A?void 0:A.contentType)&&void 0!==w?w:"application/json"},$?{Authorization:`Bearer ${$}`}:{},(null==A?void 0:A.ifMatch)?{"If-Match":A.ifMatch}:{},{"x-oystehr-request-id":null==A?void 0:A.requestId}),H={retries:null!==(T=null===(j=P.retry)||void 0===j?void 0:j.retries)&&void 0!==T?T:3,jitter:null!==(k=null===(O=P.retry)||void 0===O?void 0:O.jitter)&&void 0!==k?k:20,delay:null!==(S=null===(U=P.retry)||void 0===U?void 0:U.delay)&&void 0!==S?S:100,onRetry:null===(I=P.retry)||void 0===I?void 0:I.onRetry,retryOn:[...null!==(x=null===(E=P.retry)||void 0===E?void 0:E.retryOn)&&void 0!==x?x:[],...h]};return H.retryOn.push(...h),function(e,t){return s(this,void 0,void 0,(function*(){var i,s;let r;for(const o of Array.from({length:(null!==(i=t.retries)&&void 0!==i?i:0)+1},((e,t)=>t)))try{return yield e()}catch(n){let e=!1;if("response"in n){const i=n;e=t.retryOn.includes(i.code),r={message:n.message,code:n.code}}else if(r=n,"code"in n&&"string"==typeof n.code){const t=n;e=l.includes(t.code)}if(!e)break;const i=Math.floor(Math.random()*(t.jitter+1));yield new Promise((e=>setTimeout(e,t.delay+i))),t.onRetry&&o!==(null!==(s=t.retries)&&void 0!==s?s:0)&&t.onRetry(o+1)}throw r}))}((()=>s(this,void 0,void 0,(function*(){var e,t,i,s,r,n,o,u;R.info("Request start",{method:N,url:G,requestId:null==A?void 0:A.requestId});const a=Date.now(),d=yield _(new Request(G,{method:N.toUpperCase(),body:J,headers:F}));R.info("Request end",{method:N,url:G,duration:Date.now()-a,requestId:null==A?void 0:A.requestId});const c=d.body?yield d.text():null;let h;const l=d.headers.get("content-type");try{c&&((null==l?void 0:l.includes("application/json"))||(null==l?void 0:l.includes("application/fhir+json")))?(R.time("Deserialized JSON response",{method:N,url:G,requestId:null==A?void 0:A.requestId}),h=JSON.parse(c),R.timeEnd("Deserialized JSON response",{method:N,url:G,requestId:null==A?void 0:A.requestId})):c&&((null==l?void 0:l.includes("application/xml"))||(null==l?void 0:l.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:G,requestId:null==A?void 0:A.requestId}),h=function(e){try{const t=e.match(/<status>(\d+)<\/status>/),i=t?parseInt(t[1],10):null,s=e.match(/<output>([\s\S]*?)<\/output>/),r=s?s[1]:null;return null===i||null===r?null:{status:i,output:r}}catch(t){return null}}(c),R.timeEnd("Deserialized XML response",{method:N,url:G,requestId:null==A?void 0:A.requestId})):h=null}catch(p){h=null}if(R.debug("Deserialized response",{method:N,url:G,requestId:null==A?void 0:A.requestId}),!d.ok||d.status>=400)throw{message:null!==(r=null!==(s=null!==(i=null!==(t="string"==typeof(null==h?void 0:h.output)?h.output:null===(e=null==h?void 0:h.output)||void 0===e?void 0:e.message)&&void 0!==t?t:null==h?void 0:h.message)&&void 0!==i?i:h)&&void 0!==s?s:c)&&void 0!==r?r:d.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:d.status,response:d};return h}))),H)}))}function f(e,t){for(const[i,s]of Object.entries(e))Array.isArray(s)?s.forEach((e=>null!=e&&t.append(i,e))):null!=s&&t.append(i,s)}var g,b,y,q;class w extends p{constructor(e){super(e),g.add(this)}list(e){return this.request("/application","get",r(this,g,"m",b).bind(this))(e)}create(e,t){return this.request("/application","post",r(this,g,"m",b).bind(this))(e,t)}get(e,t){return this.request("/application/{id}","get",r(this,g,"m",b).bind(this))(e,t)}update(e,t){return this.request("/application/{id}","patch",r(this,g,"m",b).bind(this))(e,t)}delete(e,t){return this.request("/application/{id}","delete",r(this,g,"m",b).bind(this))(e,t)}rotateSecret(e,t){return this.request("/application/{id}/rotate-secret","post",r(this,g,"m",b).bind(this))(e,t)}revokeRefreshToken(e,t){return this.request("/application/{id}/revoke-refresh-token","post",r(this,g,"m",b).bind(this))(e,t)}revokeAccessToken(e,t){return this.request("/application/{id}/revoke-access-token","post",r(this,g,"m",b).bind(this))(e,t)}}g=new WeakSet,b=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class j extends p{constructor(e){super(e),y.add(this)}issue(e,t){return this.request("/payment/charge/issue","post",r(this,y,"m",q).bind(this))(e,t)}status(e,t){return this.request("/payment/charge/status","post",r(this,y,"m",q).bind(this))(e,t)}}y=new WeakSet,q=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};const T="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",O="addressString";function k(e){var t,i,s;if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const i=null===(t=e.virtualService)||void 0===t?void 0:t.find((e=>{var t;return"https://fhir.zapehr.com/virtual-service-type"===(null===(t=e.channelType)||void 0===t?void 0:t.system)}));return null==i?void 0:i.addressString}if(!e.extension)return;const r=e.extension.find((e=>e.url===T));return(null==r?void 0:r.extension)?null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((e=>e.url===O)))||void 0===s?void 0:s.valueString:void 0}var U,S,I,E,x,z,A,P;class R extends p{constructor(e){super(e),U.add(this),this.ENCOUNTER_VS_EXTENSION_URL=T,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=O,this.getConversationIdFromEncounter=k}create(e,t){return this.request("/messaging/conversation","post",r(this,U,"m",S).bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",r(this,U,"m",S).bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,U,"m",S).bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,U,"m",S).bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,U,"m",S).bind(this))(e,t)}}U=new WeakSet,S=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class N extends p{constructor(e){super(e),I.add(this)}get(e,t){return this.request("/developer/{id}","get",r(this,I,"m",E).bind(this))(e,t)}update(e,t){return this.request("/developer/{id}","patch",r(this,I,"m",E).bind(this))(e,t)}delete(e,t){return this.request("/developer/{id}","delete",r(this,I,"m",E).bind(this))(e,t)}invite(e,t){return this.request("/developer/invite","post",r(this,I,"m",E).bind(this))(e,t)}list(e){return this.request("/developer","get",r(this,I,"m",E).bind(this))(e)}listV2(e,t){return this.request("/developer/v2/list","get",r(this,I,"m",E).bind(this))(e,t)}}I=new WeakSet,E=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class _ extends p{constructor(e){super(e),x.add(this)}searchAllergens(e,t){return this.request("/allergen","get",r(this,x,"m",z).bind(this))(e,t)}searchMedications(e,t){return this.request("/medication","get",r(this,x,"m",z).bind(this))(e,t)}getMedication(e,t){return this.request("/medication/details","get",r(this,x,"m",z).bind(this))(e,t)}getConfiguration(e){return this.request("/config","get",r(this,x,"m",z).bind(this))(e)}checkAllergyInteractions(e,t){return this.request("/patient/{patientId}/interactions/allergy","get",r(this,x,"m",z).bind(this))(e,t)}checkMedicationInteractions(e,t){return this.request("/patient/{patientId}/interactions/medication","get",r(this,x,"m",z).bind(this))(e,t)}checkPrecheckInteractions(e,t){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",r(this,x,"m",z).bind(this))(e,t)}getMedicationHistory(e,t){return this.request("/patient/{patientId}/medication-history","get",r(this,x,"m",z).bind(this))(e,t)}addPatientPharmacy(e,t){return this.request("/patient/{patientId}/pharmacies","post",r(this,x,"m",z).bind(this))(e,t)}cancelPrescription(e,t){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",r(this,x,"m",z).bind(this))(e,t)}syncPatient(e,t){return this.request("/patient/{patientId}/sync","post",r(this,x,"m",z).bind(this))(e,t)}searchPharmacies(e,t){return this.request("/pharmacy","get",r(this,x,"m",z).bind(this))(e,t)}connectPractitioner(e,t){return this.request("/practitioner/connect","get",r(this,x,"m",z).bind(this))(e,t)}checkPractitionerEnrollment(e,t){return this.request("/practitioner/{practitionerId}","get",r(this,x,"m",z).bind(this))(e,t)}enrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","post",r(this,x,"m",z).bind(this))(e,t)}unenrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","delete",r(this,x,"m",z).bind(this))(e,t)}}x=new WeakSet,z=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.erxApiUrl)&&void 0!==t?t:"https://erx-api.zapehr.com/v3"};class $ extends p{constructor(e){super(e),A.add(this)}offboard(e){return this.request("/offboard","post",r(this,A,"m",P).bind(this))(e)}onboard(e){return this.request("/onboard","post",r(this,A,"m",P).bind(this))(e)}getConfiguration(e){return this.request("/config","get",r(this,A,"m",P).bind(this))(e)}send(e,t){return this.request("/send","post",r(this,A,"m",P).bind(this))(e,t)}}A=new WeakSet,P=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.faxApiUrl)&&void 0!==t?t:"https://fax-api.zapehr.com/v1"};const W=65535;function M(e){const t=(new globalThis.TextEncoder).encode(e);let i="";for(let s=0;s<t.length;s+=W){const e=t.subarray(s,s+W);i+=globalThis.btoa(String.fromCodePoint.apply(void 0,e))}return i}function C(e){var t,i;return e.system?`${e.system}|${null!==(t=e.code)&&void 0!==t?t:""}`:null!==(i=e.code)&&void 0!==i?i:""}function D(e,t){var i,s,r,n;return(null!==(i=e.system)&&void 0!==i?i:"")===(null!==(s=t.system)&&void 0!==s?s:"")&&(null!==(r=e.code)&&void 0!==r?r:"")===(null!==(n=t.code)&&void 0!==n?n:"")}function L(t,i){var s,r,n,o,u,a,d;const c=i;if(null===(s=t.ignoreTags)||void 0===s?void 0:s.length){const s=null!==(n=null===(r=c.meta)||void 0===r?void 0:r.tag)&&void 0!==n?n:[];for(const i of t.ignoreTags)if(s.some((e=>D(e,i))))throw new e({message:`Resource has an ignored tag (system: "${null!==(o=i.system)&&void 0!==o?o:""}", code: "${null!==(u=i.code)&&void 0!==u?u:""}") and cannot be mutated in ignoreTags mode`,code:400});return i}if(t.workspaceTag){const e=t.workspaceTag,s=null!==(d=null===(a=c.meta)||void 0===a?void 0:a.tag)&&void 0!==d?d:[];if(!s.some((t=>D(t,e))))return Object.assign(Object.assign({},i),{meta:Object.assign(Object.assign({},c.meta),{tag:[...s,e]})})}return i}function G(t,i){var s,r,n;if(null===(s=t.ignoreTags)||void 0===s?void 0:s.length){for(const s of i)if("add"===s.op||"replace"===s.op||"test"===s.op){const i=s.value;if(null!=i&&"object"==typeof i){const s=i;if(void 0!==s.code)for(const i of t.ignoreTags)if(D(s,i))throw new e({message:`Patch operation contains an ignored tag (system: "${null!==(r=i.system)&&void 0!==r?r:""}", code: "${null!==(n=i.code)&&void 0!==n?n:""}") and cannot be applied in ignoreTags mode`,code:400})}}return i}if(t.workspaceTag){const e=t.workspaceTag;return i.reduce(((t,i)=>{var s;if("remove"===i.op&&"/meta/tag"===i.path)return t.push(i),t.push({op:"add",path:"/meta/tag",value:[e]}),t;if("remove"===i.op&&"/meta"===i.path)return t.push(i),t.push({op:"add",path:"/meta",value:{tag:[e]}}),t;if(("add"===i.op||"replace"===i.op)&&"/meta/tag"===i.path){const s=Array.isArray(i.value)?i.value:[];return s.some((t=>D(t,e)))?t.push(i):t.push(Object.assign(Object.assign({},i),{value:[...s,e]})),t}if(("add"===i.op||"replace"===i.op)&&"/meta"===i.path){const r=null!=i.value&&"object"==typeof i.value?i.value:{},n=null!==(s=r.tag)&&void 0!==s?s:[];return n.some((t=>D(t,e)))?t.push(i):t.push(Object.assign(Object.assign({},i),{value:Object.assign(Object.assign({},r),{tag:[...n,e]})})),t}return t.push(i),t}),[])}return i}function J(e,t){var s,r,n;const o=null!==(r=null===(s=t.meta)||void 0===s?void 0:s.tag)&&void 0!==r?r:[];if(e.workspaceTag){const t=e.workspaceTag;if(!o.some((e=>D(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}else if(null===(n=e.ignoreTags)||void 0===n?void 0:n.length)for(const u of e.ignoreTags)if(o.some((e=>D(e,u))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}function F(e,t){return s(this,void 0,void 0,(function*(){const{resourceType:i}=e,s=function(e,t){var i;const s=t?[...t]:[];if(e.workspaceTag)s.push({name:"_tag",value:C(e.workspaceTag)});else if(null===(i=e.ignoreTags)||void 0===i?void 0:i.length)for(const r of e.ignoreTags)s.push({name:"_tag:not",value:C(r)});return s}(this.config,e.params);let r;s.length&&(r=s.reduce(((e,t)=>(e[t.name]||(e[t.name]=[]),e[t.name].push(t.value),e)),{}));const n=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},t),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]}})}))}function H(e,t){return s(this,void 0,void 0,(function*(){const i=L(this.config,e),{resourceType:s}=i;return this.fhirRequest(`/${s}`,"POST")(i,t)}))}function V(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t},i){const s=yield this.fhirRequest(`/${e}/${t}`,"GET")({},i);return J(this.config,s),s}))}function B(e,t){return s(this,void 0,void 0,(function*(){const i=L(this.config,e),{id:s,resourceType:r}=i;return this.fhirRequest(`/${r}/${s}`,"PUT")(i,Object.assign(Object.assign({},t),{ifMatch:(null==t?void 0:t.optimisticLockingVersionId)?`W/"${t.optimisticLockingVersionId}"`:void 0}))}))}function X(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t,operations:i},s){const r=G(this.config,i);return this.fhirRequest(`/${e}/${t}`,"PATCH")(r,Object.assign(Object.assign({},s),{contentType:"application/json-patch+json",ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0}))}))}function Z(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t},i){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},i)}))}function K(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t,versionId:i,count:s,offset:r},n){return i?this.fhirRequest(`/${e}/${t}/_history/${i}`,"GET")({},n):s?this.fhirRequest(`/${e}/${t}/_history?_total=accurate&_count=${s}\n ${r?`&_offset=${r}`:""}`,"GET")({},n):this.fhirRequest(`/${e}/${t}/_history?_total=accurate`,"GET")({},n)}))}function Q(e){const t=e.split("?")[0].split("/").filter(Boolean);return t.length<=1||t[1].startsWith("_")}function Y(e){return e.split("?")[0].endsWith("/_search")}function ee(e,t){var i;const{method:s}=e;let r=e.url;if((("GET"===s||"HEAD"===s)&&Q(r)||"POST"===s&&Y(r))&&(t.workspaceTag&&(r+=(r.includes("?")?"&":"?")+`_tag=${C(t.workspaceTag)}`),null===(i=t.ignoreTags)||void 0===i?void 0:i.length))for(const o of t.ignoreTags)r+=(r.includes("?")?"&":"?")+`_tag:not=${C(o)}`;const n={request:{method:s,url:r}};if(r.split("?").length>1){const[e,t]=r.split("?"),i=t.split("&").map((e=>{const[t,i]=e.split("=");return{name:t,value:i}})).reduce(((e,{name:t,value:i})=>t?(e[t]||(e[t]=[]),e[t].push(i),e):e),{}),s=new URLSearchParams;f(i,s),n.request.url=`${e}?${s.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return n;if("PUT"===s){const i=L(t,e.resource);return{request:Object.assign(Object.assign({},n.request),{ifMatch:e.ifMatch}),resource:i}}if("PATCH"===s){if("resource"in e){let i=e.resource;const s=i.data;if(s){const e=G(t,JSON.parse(function(e){const t=globalThis.atob(e),i=new Uint8Array(t.length);for(let s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return(new globalThis.TextDecoder).decode(i)}(s)));i=Object.assign(Object.assign({},i),{data:M(JSON.stringify(e))})}return{request:Object.assign(Object.assign({},n.request),{ifMatch:e.ifMatch}),resource:i}}const i=G(t,e.operations),s=M(JSON.stringify(i));return Object.assign(Object.assign({},n),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:s}})}if("POST"===s&&Y(r))return n;if("POST"===s&&"resource"in e){const i=L(t,e.resource),{fullUrl:s}=e;return Object.assign(Object.assign({},n),{resource:i,fullUrl:s})}throw new Error("Unrecognized method")}function te(e,t){return s(this,void 0,void 0,(function*(){var s;const r=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:e.requests.map((e=>ee(e,this.config)))},t),n=r.entry,o=this.config.workspaceTag||(null===(s=this.config.ignoreTags)||void 0===s?void 0:s.length)?null==n?void 0:n.map(((t,s)=>{const r=e.requests[s];if(!r||!(null==t?void 0:t.resource))return t;if(("GET"===r.method||"HEAD"===r.method)&&!Q(r.url))try{J(this.config,t.resource)}catch(n){if(!(n instanceof i))throw n;return{request:t.request,response:{status:"404",outcome:n.cause}}}return t})):n,u=Object.assign(Object.assign({},r),{entry:o,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]},errors:function(){var e;return null===(e=this.entry)||void 0===e?void 0:e.filter((e=>{var t,i,s,r;return(null===(i=null===(t=e.response)||void 0===t?void 0:t.status)||void 0===i?void 0:i.startsWith("4"))||(null===(r=null===(s=e.response)||void 0===s?void 0:s.status)||void 0===r?void 0:r.startsWith("5"))})).map((e=>{var t;return null===(t=e.response)||void 0===t?void 0:t.outcome})).filter((e=>void 0!==e))}});return u}))}function ie(e,t){return s(this,void 0,void 0,(function*(){var i,s;const r=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:e.requests.map((e=>ee(e,this.config)))},t);(this.config.workspaceTag||(null===(i=this.config.ignoreTags)||void 0===i?void 0:i.length))&&(null===(s=r.entry)||void 0===s||s.forEach(((t,i)=>{const s=e.requests[i];s&&(null==t?void 0:t.resource)&&("GET"!==s.method&&"HEAD"!==s.method||Q(s.url)||J(this.config,t.resource))})));const n=Object.assign(Object.assign({},r),{entry:r.entry,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]}});return n}))}function se(e,t){return s(this,arguments,void 0,(function*({id:e},t){return this.fhirRequest(`/Patient/${e}/$generate-friendly-patient-id`,"POST")({},t)}))}function re(e,t){const i=[];if(e.line&&i.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),i.push(t.join(", "))}return e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join((null==t?void 0:t.lineSeparator)||", ").trim()}function ne(e,t){const i=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&i.push(...e.prefix),e.given&&i.push(...e.given),e.family&&i.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&i.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(" ").trim()}var oe,ue,ae,de,ce,he,le,pe,ve,me,fe,ge,be,ye,qe,we,je,Te,Oe,ke,Ue,Se,Ie,Ee,xe,ze,Ae,Pe,Re,Ne,_e,$e,We;class Me extends p{constructor(e){super(e),oe.add(this),this.search=F,this.create=H,this.get=V,this.update=B,this.patch=X,this.delete=Z,this.history=K,this.batch=te,this.transaction=ie,this.generateFriendlyPatientId=se,this.formatAddress=re,this.formatHumanName=ne}}oe=new WeakSet;class Ce extends p{constructor(e){super(e),ue.add(this)}routeList(e){return this.request("/route","get",r(this,ue,"m",ae).bind(this))(e)}routeCreate(e,t){return this.request("/route","post",r(this,ue,"m",ae).bind(this))(e,t)}routeGet(e,t){return this.request("/route/{routeGuid}","get",r(this,ue,"m",ae).bind(this))(e,t)}routeDelete(e,t){return this.request("/route/{routeGuid}","delete",r(this,ue,"m",ae).bind(this))(e,t)}orderableItemList(e,t){return this.request("/orderableItem","get",r(this,ue,"m",ae).bind(this))(e,t)}orderableItemQuestionnaireGet(e,t){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,ue,"m",ae).bind(this))(e,t)}orderSubmit(e,t){return this.request("/submit","post",r(this,ue,"m",ae).bind(this))(e,t)}}ue=new WeakSet,ae=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.labApiUrl)&&void 0!==t?t:"https://labs-api.zapehr.com/v1"};class De extends p{constructor(e){super(e),de.add(this)}list(e){return this.request("/m2m","get",r(this,de,"m",ce).bind(this))(e)}create(e,t){return this.request("/m2m","post",r(this,de,"m",ce).bind(this))(e,t)}me(e){return this.request("/m2m/me","get",r(this,de,"m",ce).bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",r(this,de,"m",ce).bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",r(this,de,"m",ce).bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",r(this,de,"m",ce).bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",r(this,de,"m",ce).bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",r(this,de,"m",ce).bind(this))(e,t)}}de=new WeakSet,ce=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Le extends p{constructor(e){super(e),he.add(this)}getMessagingConfig(e){return this.request("/messaging/config","get",r(this,he,"m",le).bind(this))(e)}}he=new WeakSet,le=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Ge extends p{constructor(e){super(e),pe.add(this)}setUp(e,t){return this.request("/payment/payment-method/setup","post",r(this,pe,"m",ve).bind(this))(e,t)}setDefault(e,t){return this.request("/payment/payment-method/set-default","post",r(this,pe,"m",ve).bind(this))(e,t)}delete(e,t){return this.request("/payment/payment-method","delete",r(this,pe,"m",ve).bind(this))(e,t)}list(e,t){return this.request("/payment/payment-method/list","post",r(this,pe,"m",ve).bind(this))(e,t)}}pe=new WeakSet,ve=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Je extends p{constructor(e){super(e),me.add(this)}get(e){return this.request("/project","get",r(this,me,"m",fe).bind(this))(e)}update(e,t){return this.request("/project","patch",r(this,me,"m",fe).bind(this))(e,t)}}function Fe(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.rcmApiUrl)&&void 0!==t?t:"https://rcm-api.zapehr.com/v1"}function He({id:e}){return`${Fe.call(this)}/payer/${e}`}function Ve(t,i){return s(this,arguments,void 0,(function*({url:t},i){if(!t.startsWith(He.call(this,{id:""})))throw new e({code:400,message:"Invalid payer URL."});const s=new URL(t).pathname.split("/").filter(Boolean),r=s[s.length-1];return this.request("/payer/{id}","get",Fe.bind(this))({id:r},i)}))}me=new WeakSet,fe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Be extends p{constructor(e){super(e),ge.add(this),this.constructPayerUrl=He,this.getPayerByUrl=Ve}eligibilityCheck(e,t){return this.request("/eligibility-check","post",r(this,ge,"m",be).bind(this))(e,t)}submitClaim(e,t){return this.request("/claim/{claimId}/submit","post",r(this,ge,"m",be).bind(this))(e,t)}setClaimStatus(e,t){return this.request("/claim/{claimId}/status","post",r(this,ge,"m",be).bind(this))(e,t)}listPayers(e,t){return this.request("/payer","get",r(this,ge,"m",be).bind(this))(e,t)}getPayer(e,t){return this.request("/payer/{id}","get",r(this,ge,"m",be).bind(this))(e,t)}}ge=new WeakSet,be=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.rcmApiUrl)&&void 0!==t?t:"https://rcm-api.zapehr.com/v1"};class Xe extends p{constructor(e){super(e),ye.add(this)}list(e){return this.request("/iam/role","get",r(this,ye,"m",qe).bind(this))(e)}create(e,t){return this.request("/iam/role","post",r(this,ye,"m",qe).bind(this))(e,t)}get(e,t){return this.request("/iam/role/{roleId}","get",r(this,ye,"m",qe).bind(this))(e,t)}update(e,t){return this.request("/iam/role/{roleId}","patch",r(this,ye,"m",qe).bind(this))(e,t)}delete(e,t){return this.request("/iam/role/{roleId}","delete",r(this,ye,"m",qe).bind(this))(e,t)}}ye=new WeakSet,qe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Ze extends p{constructor(e){super(e),we.add(this)}list(e){return this.request("/secret","get",r(this,we,"m",je).bind(this))(e)}set(e,t){return this.request("/secret","post",r(this,we,"m",je).bind(this))(e,t)}get(e,t){return this.request("/secret/{name}","get",r(this,we,"m",je).bind(this))(e,t)}delete(e,t){return this.request("/secret/{name}","delete",r(this,we,"m",je).bind(this))(e,t)}}we=new WeakSet,je=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Ke extends p{constructor(e){super(e),Te.add(this)}createMeeting(e,t){return this.request("/telemed/v2/meeting","post",r(this,Te,"m",Oe).bind(this))(e,t)}joinMeeting(e,t){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,Te,"m",Oe).bind(this))(e,t)}}Te=new WeakSet,Oe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Qe extends p{constructor(e){super(e),ke.add(this)}searchCpt(e,t){return this.request("/cpt/search","get",r(this,ke,"m",Ue).bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",r(this,ke,"m",Ue).bind(this))(e,t)}}ke=new WeakSet,Ue=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.terminologyApiUrl)&&void 0!==t?t:"https://terminology-api.zapehr.com/v1"};class Ye extends p{constructor(e){super(e),Se.add(this)}send(e,t){return this.request("/messaging/transactional-sms/send","post",r(this,Se,"m",Ie).bind(this))(e,t)}}Se=new WeakSet,Ie=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class et extends p{constructor(e){super(e),Ee.add(this)}me(e){return this.request("/user/me","get",r(this,Ee,"m",xe).bind(this))(e)}get(e,t){return this.request("/user/{id}","get",r(this,Ee,"m",xe).bind(this))(e,t)}update(e,t){return this.request("/user/{id}","patch",r(this,Ee,"m",xe).bind(this))(e,t)}delete(e,t){return this.request("/user/{id}","delete",r(this,Ee,"m",xe).bind(this))(e,t)}resetMfa(e,t){return this.request("/user/{id}/reset-mfa","post",r(this,Ee,"m",xe).bind(this))(e,t)}resetPasswordLink(e,t){return this.request("/user/{id}/reset-password-link","post",r(this,Ee,"m",xe).bind(this))(e,t)}changePassword(e,t){return this.request("/user/{id}/change-password","post",r(this,Ee,"m",xe).bind(this))(e,t)}invite(e,t){return this.request("/user/invite","post",r(this,Ee,"m",xe).bind(this))(e,t)}list(e){return this.request("/user","get",r(this,Ee,"m",xe).bind(this))(e)}listV2(e,t){return this.request("/user/v2/list","get",r(this,Ee,"m",xe).bind(this))(e,t)}}Ee=new WeakSet,xe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class tt extends p{constructor(e){super(e),ze.add(this)}get(e){return this.request("/version","get",r(this,ze,"m",Ae).bind(this))(e)}}function it(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"}function st(e){return s(this,arguments,void 0,(function*({bucketName:e,"objectPath+":t,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",it.bind(this))({action:"upload",bucketName:e,"objectPath+":t});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function rt(e){return s(this,arguments,void 0,(function*({bucketName:e,"objectPath+":t}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",it.bind(this))({action:"download",bucketName:e,"objectPath+":t}),s=yield fetch(i.signedUrl,{method:"GET"});if(!s.ok)throw new Error("Failed to download file");return s.arrayBuffer()}))}function nt(t){return s(this,void 0,void 0,(function*(){var i,s;let r,n;const o=new URL(t.url);if("z3:"===o.protocol){const e=o.pathname.split("/").slice(1);r=o.hostname,n=e.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 e({message:"Invalid Z3 URL",code:400});{const e=o.pathname.split("/").slice(3);r=e[0],n=e.slice(1).join("/")}}const u={action:"upload",bucketName:r,"objectPath+":n};return this.request("/z3/{bucketName}/{objectPath+}","post",it.bind(this))(u)}))}ze=new WeakSet,Ae=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class ot extends p{constructor(e){super(e),Pe.add(this),this.uploadFile=st,this.downloadFile=rt,this.getPresignedUrlForZ3Url=nt}listBuckets(e){return this.request("/z3","get",r(this,Pe,"m",Re).bind(this))(e)}createBucket(e,t){return this.request("/z3/{bucketName}","put",r(this,Pe,"m",Re).bind(this))(e,t)}deleteBucket(e,t){return this.request("/z3/{bucketName}","delete",r(this,Pe,"m",Re).bind(this))(e,t)}listObjects(e,t){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,Pe,"m",Re).bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,Pe,"m",Re).bind(this))(e,t)}deleteObject(e,t){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,Pe,"m",Re).bind(this))(e,t)}}function ut(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.zambdaApiUrl)&&void 0!==t?t:"https://zambda-api.zapehr.com/v1"}function at(t){return s(this,arguments,void 0,(function*({id:t,file:i,filename:s}){const r=yield this.request("/zambda/{id}/presigned-url","post",ut.bind(this))({id:t,action:"upload",filename:s}),n=yield fetch(r.signedUrl,{method:"PUT",body:i});if(!n.ok)throw new e({message:"Failed to upload file",code:n.status,cause:n.statusText})}))}function dt(t){return s(this,arguments,void 0,(function*({id:t}){const i=yield this.request("/zambda/{id}/presigned-url","post",ut.bind(this))({id:t,action:"download"}),s=yield fetch(i.signedUrl,{method:"GET"});if(!s.ok)throw new e({message:"Failed to download file",code:s.status,cause:s.statusText});return s.arrayBuffer()}))}Pe=new WeakSet,Re=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class ct extends p{constructor(e){super(e),Ne.add(this),this.uploadFile=at,this.downloadFile=dt}list(e){return this.request("/zambda","get",r(this,Ne,"m",_e).bind(this))(e)}create(e,t){return this.request("/zambda","post",r(this,Ne,"m",_e).bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}","get",r(this,Ne,"m",_e).bind(this))(e,t)}update(e,t){return this.request("/zambda/{id}","patch",r(this,Ne,"m",_e).bind(this))(e,t)}delete(e,t){return this.request("/zambda/{id}","delete",r(this,Ne,"m",_e).bind(this))(e,t)}execute(e,t){return this.request("/zambda/{id}/execute","post",r(this,Ne,"m",_e).bind(this))(e,t)}executePublic(e,t){return this.request("/zambda/{id}/execute-public","post",r(this,Ne,"m",_e).bind(this))(e,t)}s3Upload(e,t){return this.request("/zambda/{id}/s3-upload","post",r(this,Ne,"m",_e).bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/zambda/{id}/presigned-url","post",r(this,Ne,"m",_e).bind(this))(e,t)}}Ne=new WeakSet,_e=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.zambdaApiUrl)&&void 0!==t?t:"https://zambda-api.zapehr.com/v1"};class ht extends p{constructor(e){super(e),$e.add(this)}list(e,t){return this.request("/zambda/{id}/logStream","post",r(this,$e,"m",We).bind(this))(e,t)}search(e,t){return this.request("/zambda/{id}/logStream/search","post",r(this,$e,"m",We).bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}/logStream/{logStreamName}","post",r(this,$e,"m",We).bind(this))(e,t)}}$e=new WeakSet,We=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.zambdaApiUrl)&&void 0!==t?t:"https://zambda-api.zapehr.com/v1"};let lt=class{constructor(t){var i,s,r,n,o,u;if(t.workspaceTag&&t.ignoreTags)throw new e({message:"workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config",code:400});this.config=t,null!==(i=(n=this.config).services)&&void 0!==i||(n.services={}),null!==(s=(o=this.config.services).projectApiUrl)&&void 0!==s||(o.projectApiUrl=t.projectApiUrl),null!==(r=(u=this.config.services).fhirApiUrl)&&void 0!==r||(u.fhirApiUrl=t.fhirApiUrl),this.application=new w(t),this.developer=new N(t),this.m2m=new De(t),this.messaging=new Le(t),this.conversation=new R(t),this.transactionalSMS=new Ye(t),this.paymentMethod=new Ge(t),this.charge=new j(t),this.project=new Je(t),this.role=new Xe(t),this.secret=new Ze(t),this.telemed=new Ke(t),this.user=new et(t),this.version=new tt(t),this.z3=new ot(t),this.fax=new $(t),this.lab=new Ce(t),this.erx=new _(t),this.terminology=new Qe(t),this.zambda=new ct(t),this.zambdaLogStream=new ht(t),this.rcm=new Be(t),this.fhir=new Me(t)}};class pt extends lt{}pt.OystehrFHIRError=i,pt.OystehrSdkError=e,exports.default=pt;
|
|
1
|
+
"use strict";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{a(s.next(t))}catch(e){n(e)}}function u(t){try{a(s.throw(t))}catch(e){n(e)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,u)}a((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;var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;const o=[];for(let ye=0;ye<256;++ye)o.push((ye+256).toString(16).slice(1));let u;const a=new Uint8Array(16);var d={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};class c{constructor({level:t}){this._level=t}error(t,e={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify(Object.assign({message:t},e)))}info(t,e={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify(Object.assign({message:t},e)))}debug(t,e={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify(Object.assign({message:t},e)))}time(t,e={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify(Object.assign({message:t},e)))}timeEnd(t,e={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify(Object.assign({message:t},e)))}}const l=[408,429,500,502,503,504],h=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class p{constructor(t){this.config=t,this.logger=new c({level:this.config.logLevel})}request(e,i,r){return(n,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config,u=()=>this.logger;try{return yield m(r,s,u,e,i)(n,o)}catch(a){const e=a;throw this.logger.error(e.message,{code:e.code,cause:e.cause}),new t({message:e.message,code:e.code,cause:e.cause})}}))}fhirRequest(e,r){return(n,o,u)=>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,s=()=>this.logger;return yield m(t,i,s,e,r)(n,o,u)}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})}}))}startAsyncJob(e,i,r,n,o){return s(this,void 0,void 0,(function*(){const s="async-bulk"===n?"bulk":"bundle",u="async-bulk"===n?this.appendBulkOutputFormat(e):e,a=yield this.fhirRequest(u,i)(r,Object.assign(Object.assign({},o),{rawResponse:!0}),n);if(202!==a.status)throw new t({message:`Expected start async job to return 202 Accepted, received ${a.status}`,code:a.status});const d=this.readHeader(a.headers,"content-location");if(!d)throw new t({message:"Start Async job response missing Content-Location header",code:500});const c=this.parseAsyncJobId(d);if(!c)throw new t({message:`Could not parse async job id from Content-Location: ${d}`,code:500});return{jobId:c,contentLocation:d,mode:s}}))}fetchAsyncJobStatus(t,e){return s(this,void 0,void 0,(function*(){var i,s,r;const n=yield this.fhirRequest(`/async-job/${t}`,"GET")({},Object.assign(Object.assign({},e),{rawResponse:!0}));if(202===n.status)return{status:202,xProgress:this.readHeader(n.headers,"x-progress"),retryAfter:this.readHeader(n.headers,"retry-after")};if(410===n.status)return{status:410};if(404===n.status)return{status:404};if(200===n.status){if(this.isBulkManifest(n.body))return{status:200,mode:"bulk",manifest:n.body};const t=n.body;if("Bundle"===(null==t?void 0:t.resourceType)&&"batch-response"===(null==t?void 0:t.type)){const e=null===(i=t.entry)||void 0===i?void 0:i[0];return{status:200,mode:"bundle",bundle:t,interactionStatus:null===(s=null==e?void 0:e.response)||void 0===s?void 0:s.status,resource:null==e?void 0:e.resource,outcome:null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.outcome}}return{status:200,body:n.body}}return{status:n.status,body:n.body}}))}readHeader(t,e){const i=t[e];if(null!=i)return i;const s=e.toLowerCase(),r=Object.keys(t).find((t=>t.toLowerCase()===s));return r?t[r]:void 0}parseAsyncJobId(t){const e=t.split("/").filter(Boolean),i=e.lastIndexOf("async-job");if(!(i<0||i+1>=e.length))return e[i+1]}appendBulkOutputFormat(t){const e=t.includes("?")?"&":"?";return`${t}${e}_outputFormat=${encodeURIComponent("application/fhir+ndjson")}`}isBulkManifest(t){if(null==t||"object"!=typeof t)return!1;const e=t;return"string"==typeof e.transactionTime&&"string"==typeof e.request&&"boolean"==typeof e.requiresAccessToken&&Array.isArray(e.output)&&Array.isArray(e.error)}}function v(t){var e,i;return"accessToken"in t||"projectId"in t&&"string"==typeof(i=t.projectId)&&n.test(i)||"contentType"in t&&2===(null===(e=t.contentType)||void 0===e?void 0:e.split("/").length)||"requestId"in t||"ifMatch"in t&&t.ifMatch.startsWith('W/"')||"mode"in t||"rawResponse"in t}function m(e,i,r,n,c){return(p,m,g)=>s(this,void 0,void 0,(function*(){var b,y,q,w,j,T,O,k,S,A,I,U,E,x;let[P,z]=function(t,e){var i;return[t&&!e&&!Array.isArray(t)&&v(t)?{}:null!==(i=t)&&void 0!==i?i:{},t&&!e&&!Array.isArray(t)&&v(t)?t:e]}(p,m);null!=z||(z={}),null!==(b=z.requestId)&&void 0!==b||(z.requestId=function(t){if(d.randomUUID&&!t)return d.randomUUID();const e=(t=t||{}).random??t.rng?.()??function(){if(!u){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");u=crypto.getRandomValues.bind(crypto)}return u(a)}();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(t,e=0){return(o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]).toLowerCase()}(e)}());const $=i(),R=r(),N=c.toLowerCase();R.debug("Beginning fetch",{method:N,path:n,requestId:null==z?void 0:z.requestId});const _=null!==(y=$.fetch)&&void 0!==y?y:fetch,M=null!==(q=null==z?void 0:z.accessToken)&&void 0!==q?q:$.accessToken,C=null!==(w=null==z?void 0:z.projectId)&&void 0!==w?w:$.projectId;let J=n,W=P;if(!Array.isArray(P)){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]})),{}):{}]}(n,P);J=e,W=i}R.debug("Substituted parameters in path",{method:N,path:n,requestId:null==z?void 0:z.requestId}),J=J.replace(/^\//,"");const D=e(),L=D.endsWith("/")?D:D+"/",F=new URL(J,L);let B;if(Array.isArray(W))B=JSON.stringify(W);else if(Object.keys(W).length)if("get"===N)f(W,F.searchParams);else if("application/x-www-form-urlencoded"===(null==z?void 0:z.contentType)){const t=new URLSearchParams;f(W,t),B=t.toString()}else B=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==z?void 0:z.contentType)&&"post"===N&&(B="{}");R.debug("Prepared request body",{method:N,path:n,requestId:null==z?void 0:z.requestId});const G=function(t){if("async-bundle"===t||"async-bulk"===t)return"respond-async"}(g),H=Object.assign(C?{"x-zapehr-project-id":C,"x-oystehr-project-id":C}:{},{"content-type":null!==(j=null==z?void 0:z.contentType)&&void 0!==j?j:"application/json"},G?{Prefer:G}:{},M?{Authorization:`Bearer ${M}`}:{},(null==z?void 0:z.ifMatch)?{"If-Match":z.ifMatch}:{},{"x-oystehr-request-id":null==z?void 0:z.requestId}),V={retries:null!==(O=null===(T=$.retry)||void 0===T?void 0:T.retries)&&void 0!==O?O:3,jitter:null!==(S=null===(k=$.retry)||void 0===k?void 0:k.jitter)&&void 0!==S?S:20,delay:null!==(I=null===(A=$.retry)||void 0===A?void 0:A.delay)&&void 0!==I?I:100,onRetry:null===(U=$.retry)||void 0===U?void 0:U.onRetry,retryOn:[...null!==(x=null===(E=$.retry)||void 0===E?void 0:E.retryOn)&&void 0!==x?x:[],...l]};return V.retryOn.push(...l),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=h.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;R.info("Request start",{method:N,url:F,requestId:null==z?void 0:z.requestId});const a=Date.now(),d=yield _(new Request(F,{method:N.toUpperCase(),body:B,headers:H}));R.info("Request end",{method:N,url:F,duration:Date.now()-a,requestId:null==z?void 0:z.requestId});const c=d.body?yield d.text():null;let l;const h=d.headers.get("content-type");try{c&&((null==h?void 0:h.includes("application/json"))||(null==h?void 0:h.includes("application/fhir+json")))?(R.time("Deserialized JSON response",{method:N,url:F,requestId:null==z?void 0:z.requestId}),l=JSON.parse(c),R.timeEnd("Deserialized JSON response",{method:N,url:F,requestId:null==z?void 0:z.requestId})):c&&((null==h?void 0:h.includes("application/xml"))||(null==h?void 0:h.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:F,requestId:null==z?void 0:z.requestId}),l=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}}(c),R.timeEnd("Deserialized XML response",{method:N,url:F,requestId:null==z?void 0:z.requestId})):l=null}catch(p){l=null}if(R.debug("Deserialized response",{method:N,url:F,requestId:null==z?void 0:z.requestId}),null==z?void 0:z.rawResponse){const t={};return d.headers.forEach(((e,i)=>{t[i]=e})),{status:d.status,headers:t,body:null!=l?l:c}}if(!d.ok||d.status>=400)throw{message:null!==(r=null!==(s=null!==(i=null!==(e="string"==typeof(null==l?void 0:l.output)?l.output:null===(t=null==l?void 0:l.output)||void 0===t?void 0:t.message)&&void 0!==e?e:null==l?void 0:l.message)&&void 0!==i?i:l)&&void 0!==s?s:c)&&void 0!==r?r:d.statusText,code:null!==(u=null!==(o=null===(n=null==l?void 0:l.output)||void 0===n?void 0:n.code)&&void 0!==o?o:null==l?void 0:l.code)&&void 0!==u?u:d.status,response:d};return l}))),V)}))}function f(t,e){for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>null!=t&&e.append(i,t))):null!=s&&e.append(i,s)}var g,b,y,q;class w extends p{constructor(t){super(t),g.add(this)}list(t){return this.request("/application","get",r(this,g,"m",b).bind(this))(t)}create(t,e){return this.request("/application","post",r(this,g,"m",b).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",r(this,g,"m",b).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",r(this,g,"m",b).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",r(this,g,"m",b).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",r(this,g,"m",b).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",r(this,g,"m",b).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",r(this,g,"m",b).bind(this))(t,e)}}g=new WeakSet,b=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 p{constructor(t){super(t),y.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",r(this,y,"m",q).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",r(this,y,"m",q).bind(this))(t,e)}}y=new WeakSet,q=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 T="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",O="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===T));return(null==r?void 0:r.extension)?null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===O)))||void 0===s?void 0:s.valueString:void 0}var S,A,I,U,E,x,P,z;class $ extends p{constructor(t){super(t),S.add(this),this.ENCOUNTER_VS_EXTENSION_URL=T,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=O,this.getConversationIdFromEncounter=k}create(t,e){return this.request("/messaging/conversation","post",r(this,S,"m",A).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",r(this,S,"m",A).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,S,"m",A).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,S,"m",A).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,S,"m",A).bind(this))(t,e)}}S=new WeakSet,A=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 p{constructor(t){super(t),I.add(this)}get(t,e){return this.request("/developer/{id}","get",r(this,I,"m",U).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",r(this,I,"m",U).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",r(this,I,"m",U).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",r(this,I,"m",U).bind(this))(t,e)}list(t){return this.request("/developer","get",r(this,I,"m",U).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",r(this,I,"m",U).bind(this))(t,e)}}I=new WeakSet,U=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 p{constructor(t){super(t),E.add(this)}searchAllergens(t,e){return this.request("/allergen","get",r(this,E,"m",x).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",r(this,E,"m",x).bind(this))(t,e)}getMedication(t,e){return this.request("/medication/details","get",r(this,E,"m",x).bind(this))(t,e)}getConfiguration(t){return this.request("/config","get",r(this,E,"m",x).bind(this))(t)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",r(this,E,"m",x).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",r(this,E,"m",x).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",r(this,E,"m",x).bind(this))(t,e)}getMedicationHistory(t,e){return this.request("/patient/{patientId}/medication-history","get",r(this,E,"m",x).bind(this))(t,e)}addPatientPharmacy(t,e){return this.request("/patient/{patientId}/pharmacies","post",r(this,E,"m",x).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",r(this,E,"m",x).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",r(this,E,"m",x).bind(this))(t,e)}searchPharmacies(t,e){return this.request("/pharmacy","get",r(this,E,"m",x).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",r(this,E,"m",x).bind(this))(t,e)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",r(this,E,"m",x).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",r(this,E,"m",x).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",r(this,E,"m",x).bind(this))(t,e)}}E=new WeakSet,x=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 p{constructor(t){super(t),P.add(this)}offboard(t){return this.request("/offboard","post",r(this,P,"m",z).bind(this))(t)}onboard(t){return this.request("/onboard","post",r(this,P,"m",z).bind(this))(t)}getConfiguration(t){return this.request("/config","get",r(this,P,"m",z).bind(this))(t)}send(t,e){return this.request("/send","post",r(this,P,"m",z).bind(this))(t,e)}}P=new WeakSet,z=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 M=65535;function C(t){const e=(new globalThis.TextEncoder).encode(t);let i="";for(let s=0;s<e.length;s+=M){const t=e.subarray(s,s+M);i+=globalThis.btoa(String.fromCodePoint.apply(void 0,t))}return i}function J(t){var e,i;return t.system?`${t.system}|${null!==(e=t.code)&&void 0!==e?e:""}`:null!==(i=t.code)&&void 0!==i?i:""}function W(t,e){var i,s,r,n;return(null!==(i=t.system)&&void 0!==i?i:"")===(null!==(s=e.system)&&void 0!==s?s:"")&&(null!==(r=t.code)&&void 0!==r?r:"")===(null!==(n=e.code)&&void 0!==n?n:"")}function D(e,i){var s,r,n,o,u,a,d;const c=i;if(null===(s=e.ignoreTags)||void 0===s?void 0:s.length){const s=null!==(n=null===(r=c.meta)||void 0===r?void 0:r.tag)&&void 0!==n?n:[];for(const i of e.ignoreTags)if(s.some((t=>W(t,i))))throw new t({message:`Resource has an ignored tag (system: "${null!==(o=i.system)&&void 0!==o?o:""}", code: "${null!==(u=i.code)&&void 0!==u?u:""}") and cannot be mutated in ignoreTags mode`,code:400});return i}if(e.workspaceTag){const t=e.workspaceTag,s=null!==(d=null===(a=c.meta)||void 0===a?void 0:a.tag)&&void 0!==d?d:[];if(!s.some((e=>W(e,t))))return Object.assign(Object.assign({},i),{meta:Object.assign(Object.assign({},c.meta),{tag:[...s,t]})})}return i}function L(e,i){var s,r,n;if(null===(s=e.ignoreTags)||void 0===s?void 0:s.length){for(const s of i)if("add"===s.op||"replace"===s.op||"test"===s.op){const i=s.value;if(null!=i&&"object"==typeof i){const s=i;if(void 0!==s.code)for(const i of e.ignoreTags)if(W(s,i))throw new t({message:`Patch operation contains an ignored tag (system: "${null!==(r=i.system)&&void 0!==r?r:""}", code: "${null!==(n=i.code)&&void 0!==n?n:""}") and cannot be applied in ignoreTags mode`,code:400})}}return i}if(e.workspaceTag){const t=e.workspaceTag;return i.reduce(((e,i)=>{var s;if("remove"===i.op&&"/meta/tag"===i.path)return e.push(i),e.push({op:"add",path:"/meta/tag",value:[t]}),e;if("remove"===i.op&&"/meta"===i.path)return e.push(i),e.push({op:"add",path:"/meta",value:{tag:[t]}}),e;if(("add"===i.op||"replace"===i.op)&&"/meta/tag"===i.path){const s=Array.isArray(i.value)?i.value:[];return s.some((e=>W(e,t)))?e.push(i):e.push(Object.assign(Object.assign({},i),{value:[...s,t]})),e}if(("add"===i.op||"replace"===i.op)&&"/meta"===i.path){const r=null!=i.value&&"object"==typeof i.value?i.value:{},n=null!==(s=r.tag)&&void 0!==s?s:[];return n.some((e=>W(e,t)))?e.push(i):e.push(Object.assign(Object.assign({},i),{value:Object.assign(Object.assign({},r),{tag:[...n,t]})})),e}return e.push(i),e}),[])}return i}function F(t,e){var s,r,n;const o=null!==(r=null===(s=e.meta)||void 0===s?void 0:s.tag)&&void 0!==r?r:[];if(t.workspaceTag){const e=t.workspaceTag;if(!o.some((t=>W(t,e))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}else if(null===(n=t.ignoreTags)||void 0===n?void 0:n.length)for(const u of t.ignoreTags)if(o.some((t=>W(t,u))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}function B(t){return"async-bundle"===t||"async-bulk"===t}function G(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i}=t,s=function(t,e){var i;const s=e?[...e]:[];if(t.workspaceTag)s.push({name:"_tag",value:J(t.workspaceTag)});else if(null===(i=t.ignoreTags)||void 0===i?void 0:i.length)for(const r of t.ignoreTags)s.push({name:"_tag:not",value:J(r)});return s}(this.config,t.params);let r;s.length&&(r=s.reduce(((t,e)=>(t[e.name]||(t[e.name]=[]),t[e.name].push(e.value),t)),{}));const n=null==e?void 0:e.mode;if(B(n))return yield this.startAsyncJob(`/${i}/_search`,"POST",null!=r?r:{},n,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));const o=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},o),{entry:o.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 H(t,e){return s(this,void 0,void 0,(function*(){const i=D(this.config,t),{resourceType:s}=i,r=null==e?void 0:e.mode;return B(r)?yield this.startAsyncJob(`/${s}`,"POST",i,r,e):yield this.fhirRequest(`/${s}`,"POST")(i,e)}))}function V(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){const s=null==i?void 0:i.mode;if(B(s))return yield this.startAsyncJob(`/${t}/${e}`,"GET",{},s,i);const r=yield this.fhirRequest(`/${t}/${e}`,"GET")({},i);return F(this.config,r),r}))}function X(t,e){return s(this,void 0,void 0,(function*(){const i=D(this.config,t),{id:s,resourceType:r}=i,n=null==e?void 0:e.mode,o=Object.assign(Object.assign({},e),{ifMatch:(null==e?void 0:e.optimisticLockingVersionId)?`W/"${e.optimisticLockingVersionId}"`:void 0});return B(n)?yield this.startAsyncJob(`/${r}/${s}`,"PUT",i,n,o):yield this.fhirRequest(`/${r}/${s}`,"PUT")(i,o)}))}function Z(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,operations:i},s){const r=L(this.config,i),n=null==s?void 0:s.mode,o=Object.assign(Object.assign({},s),{ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0});return B(n)?yield this.startAsyncJob(`/${t}/${e}`,"PATCH",r,n,Object.assign(Object.assign({},o),{contentType:"application/json-patch+json"})):this.fhirRequest(`/${t}/${e}`,"PATCH")(r,Object.assign(Object.assign({},o),{contentType:"application/json-patch+json"}))}))}function K(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){const s=null==i?void 0:i.mode;return B(s)?yield this.startAsyncJob(`/${t}/${e}`,"DELETE",{},s,i):yield this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function Q(t,e){if(!t)return e;const i=Number(t);if(Number.isFinite(i)&&i>=0)return Math.max(0,Math.floor(1e3*i));const s=Date.parse(t);return Number.isFinite(s)?Math.max(0,s-Date.now()):e}function Y(t,e){return s(this,void 0,void 0,(function*(){return yield this.fetchAsyncJobStatus(t,e)}))}function tt(e,i,r){return s(this,void 0,void 0,(function*(){var s,n;const o=null!==(s=null==i?void 0:i.pollIntervalMs)&&void 0!==s?s:5e3,u=null!==(n=null==i?void 0:i.timeoutMs)&&void 0!==n?n:9e5,a=Math.max(1,Math.ceil(u/o));for(let t=0;t<a;t++){const i=yield this.fetchAsyncJobStatus(e,r);if(202!==i.status)return i;if(t<a-1){const t="retryAfter"in i?i.retryAfter:void 0;yield new Promise((e=>setTimeout(e,Q(t,o))))}}throw new t({message:`Async job ${e} did not complete within ${u} ms`,code:408})}))}function et(t,e){return s(this,void 0,void 0,(function*(){yield this.fhirRequest(`/async-job/${t}`,"DELETE")({},e)}))}function it(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,versionId:i,count:s,offset:r},n){const o=null==n?void 0:n.mode;return B(o)?i?yield this.startAsyncJob(`/${t}/${e}/_history/${i}`,"GET",{},o,n):yield this.startAsyncJob(`/${t}/${e}/_history`,"GET",{},o,n):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 st(t){const e=t.split("?")[0].split("/").filter(Boolean);return e.length<=1||e[1].startsWith("_")}function rt(t){return t.split("?")[0].endsWith("/_search")}function nt(t,e){var i;const{method:s}=t;let r=t.url;if((("GET"===s||"HEAD"===s)&&st(r)||"POST"===s&&rt(r))&&(e.workspaceTag&&(r+=(r.includes("?")?"&":"?")+`_tag=${J(e.workspaceTag)}`),null===(i=e.ignoreTags)||void 0===i?void 0:i.length))for(const o of e.ignoreTags)r+=(r.includes("?")?"&":"?")+`_tag:not=${J(o)}`;const n={request:{method:s,url:r}};if(r.split("?").length>1){const[t,e]=r.split("?"),i=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),{}),s=new URLSearchParams;f(i,s),n.request.url=`${t}?${s.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return n;if("PUT"===s){const i=D(e,t.resource);return{request:Object.assign(Object.assign({},n.request),{ifMatch:t.ifMatch}),resource:i}}if("PATCH"===s){if("resource"in t){let i=t.resource;const s=i.data;if(s){const t=L(e,JSON.parse(function(t){const e=globalThis.atob(t),i=new Uint8Array(e.length);for(let s=0;s<e.length;s++)i[s]=e.charCodeAt(s);return(new globalThis.TextDecoder).decode(i)}(s)));i=Object.assign(Object.assign({},i),{data:C(JSON.stringify(t))})}return{request:Object.assign(Object.assign({},n.request),{ifMatch:t.ifMatch}),resource:i}}const i=L(e,t.operations),s=C(JSON.stringify(i));return Object.assign(Object.assign({},n),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:s}})}if("POST"===s&&rt(r))return n;if("POST"===s&&"resource"in t){const i=D(e,t.resource),{fullUrl:s}=t;return Object.assign(Object.assign({},n),{resource:i,fullUrl:s})}throw new Error("Unrecognized method")}function ot(t,e){return s(this,void 0,void 0,(function*(){var s;const r={resourceType:"Bundle",type:"batch",entry:t.requests.map((t=>nt(t,this.config)))},n=null==e?void 0:e.mode;if(B(n))return yield this.startAsyncJob("/","POST",r,n,e);const o=yield this.fhirRequest("/","POST")(r,e),u=o.entry,a=this.config.workspaceTag||(null===(s=this.config.ignoreTags)||void 0===s?void 0:s.length)?null==u?void 0:u.map(((e,s)=>{const r=t.requests[s];if(!r||!(null==e?void 0:e.resource))return e;if(("GET"===r.method||"HEAD"===r.method)&&!st(r.url))try{F(this.config,e.resource)}catch(n){if(!(n instanceof i))throw n;return{request:e.request,response:{status:"404",outcome:n.cause}}}return e})):u,d=Object.assign(Object.assign({},o),{entry:a,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))}});return d}))}function ut(t,e){return s(this,void 0,void 0,(function*(){var i,s;const r={resourceType:"Bundle",type:"transaction",entry:t.requests.map((t=>nt(t,this.config)))},n=null==e?void 0:e.mode;if(B(n))return yield this.startAsyncJob("/","POST",r,n,e);const o=yield this.fhirRequest("/","POST")(r,e);(this.config.workspaceTag||(null===(i=this.config.ignoreTags)||void 0===i?void 0:i.length))&&(null===(s=o.entry)||void 0===s||s.forEach(((e,i)=>{const s=t.requests[i];s&&(null==e?void 0:e.resource)&&("GET"!==s.method&&"HEAD"!==s.method||st(s.url)||F(this.config,e.resource))})));const u=Object.assign(Object.assign({},o),{entry:o.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:[]}});return u}))}function at(t,e){return s(this,arguments,void 0,(function*({id:t},e){return this.fhirRequest(`/Patient/${t}/$generate-friendly-patient-id`,"POST")({},e)}))}function dt(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 ct(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 lt,ht,pt,vt,mt,ft,gt,bt,yt,qt,wt,jt,Tt,Ot,kt,St,At,It,Ut,Et,xt,Pt,zt,$t,Rt,Nt,_t,Mt,Ct,Jt,Wt,Dt,Lt;class Ft extends p{constructor(t){super(t),lt.add(this),this.search=G,this.create=H,this.get=V,this.getAsyncJob=Y,this.waitForAsyncJob=tt,this.cancelAsyncJob=et,this.update=X,this.patch=Z,this.delete=K,this.history=it,this.batch=ot,this.transaction=ut,this.generateFriendlyPatientId=at,this.formatAddress=dt,this.formatHumanName=ct}}lt=new WeakSet;class Bt extends p{constructor(t){super(t),ht.add(this)}routeList(t){return this.request("/route","get",r(this,ht,"m",pt).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",r(this,ht,"m",pt).bind(this))(t,e)}routeGet(t,e){return this.request("/route/{routeGuid}","get",r(this,ht,"m",pt).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",r(this,ht,"m",pt).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",r(this,ht,"m",pt).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,ht,"m",pt).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",r(this,ht,"m",pt).bind(this))(t,e)}}ht=new WeakSet,pt=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 Gt extends p{constructor(t){super(t),vt.add(this)}list(t){return this.request("/m2m","get",r(this,vt,"m",mt).bind(this))(t)}create(t,e){return this.request("/m2m","post",r(this,vt,"m",mt).bind(this))(t,e)}me(t){return this.request("/m2m/me","get",r(this,vt,"m",mt).bind(this))(t)}get(t,e){return this.request("/m2m/{id}","get",r(this,vt,"m",mt).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",r(this,vt,"m",mt).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",r(this,vt,"m",mt).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",r(this,vt,"m",mt).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",r(this,vt,"m",mt).bind(this))(t,e)}}vt=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 Ht extends p{constructor(t){super(t),ft.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",r(this,ft,"m",gt).bind(this))(t)}}ft=new WeakSet,gt=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 Vt extends p{constructor(t){super(t),bt.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",r(this,bt,"m",yt).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",r(this,bt,"m",yt).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",r(this,bt,"m",yt).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",r(this,bt,"m",yt).bind(this))(t,e)}}bt=new WeakSet,yt=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 Xt extends p{constructor(t){super(t),qt.add(this)}get(t){return this.request("/project","get",r(this,qt,"m",wt).bind(this))(t)}update(t,e){return this.request("/project","patch",r(this,qt,"m",wt).bind(this))(t,e)}}function Zt(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.rcmApiUrl)&&void 0!==e?e:"https://rcm-api.zapehr.com/v1"}function Kt({id:t}){return`${Zt.call(this)}/payer/${t}`}function Qt(e,i){return s(this,arguments,void 0,(function*({url:e},i){if(!e.startsWith(Kt.call(this,{id:""})))throw new t({code:400,message:"Invalid payer URL."});const s=new URL(e).pathname.split("/").filter(Boolean),r=s[s.length-1];return this.request("/payer/{id}","get",Zt.bind(this))({id:r},i)}))}qt=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 Yt extends p{constructor(t){super(t),jt.add(this),this.constructPayerUrl=Kt,this.getPayerByUrl=Qt}eligibilityCheck(t,e){return this.request("/eligibility-check","post",r(this,jt,"m",Tt).bind(this))(t,e)}submitClaim(t,e){return this.request("/claim/{claimId}/submit","post",r(this,jt,"m",Tt).bind(this))(t,e)}setClaimStatus(t,e){return this.request("/claim/{claimId}/status","post",r(this,jt,"m",Tt).bind(this))(t,e)}listPayers(t,e){return this.request("/payer","get",r(this,jt,"m",Tt).bind(this))(t,e)}getPayer(t,e){return this.request("/payer/{id}","get",r(this,jt,"m",Tt).bind(this))(t,e)}}jt=new WeakSet,Tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.rcmApiUrl)&&void 0!==e?e:"https://rcm-api.zapehr.com/v1"};class te extends p{constructor(t){super(t),Ot.add(this)}list(t){return this.request("/iam/role","get",r(this,Ot,"m",kt).bind(this))(t)}create(t,e){return this.request("/iam/role","post",r(this,Ot,"m",kt).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",r(this,Ot,"m",kt).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",r(this,Ot,"m",kt).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",r(this,Ot,"m",kt).bind(this))(t,e)}}Ot=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 ee extends p{constructor(t){super(t),St.add(this)}list(t){return this.request("/secret","get",r(this,St,"m",At).bind(this))(t)}set(t,e){return this.request("/secret","post",r(this,St,"m",At).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",r(this,St,"m",At).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",r(this,St,"m",At).bind(this))(t,e)}}St=new WeakSet,At=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 ie extends p{constructor(t){super(t),It.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",r(this,It,"m",Ut).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,It,"m",Ut).bind(this))(t,e)}}It=new WeakSet,Ut=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 se extends p{constructor(t){super(t),Et.add(this)}searchCpt(t,e){return this.request("/cpt/search","get",r(this,Et,"m",xt).bind(this))(t,e)}searchHcpcs(t,e){return this.request("/hcpcs/search","get",r(this,Et,"m",xt).bind(this))(t,e)}}Et=new WeakSet,xt=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 re extends p{constructor(t){super(t),Pt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",r(this,Pt,"m",zt).bind(this))(t,e)}}Pt=new WeakSet,zt=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 ne extends p{constructor(t){super(t),$t.add(this)}me(t){return this.request("/user/me","get",r(this,$t,"m",Rt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",r(this,$t,"m",Rt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",r(this,$t,"m",Rt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",r(this,$t,"m",Rt).bind(this))(t,e)}resetMfa(t,e){return this.request("/user/{id}/reset-mfa","post",r(this,$t,"m",Rt).bind(this))(t,e)}resetPasswordLink(t,e){return this.request("/user/{id}/reset-password-link","post",r(this,$t,"m",Rt).bind(this))(t,e)}changePassword(t,e){return this.request("/user/{id}/change-password","post",r(this,$t,"m",Rt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",r(this,$t,"m",Rt).bind(this))(t,e)}list(t){return this.request("/user","get",r(this,$t,"m",Rt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",r(this,$t,"m",Rt).bind(this))(t,e)}}$t=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 oe extends p{constructor(t){super(t),Nt.add(this)}get(t){return this.request("/version","get",r(this,Nt,"m",_t).bind(this))(t)}}function ue(){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 ae(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",ue.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function de(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",ue.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 ce(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",ue.bind(this))(u)}))}Nt=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 le extends p{constructor(t){super(t),Mt.add(this),this.uploadFile=ae,this.downloadFile=de,this.getPresignedUrlForZ3Url=ce}listBuckets(t){return this.request("/z3","get",r(this,Mt,"m",Ct).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",r(this,Mt,"m",Ct).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",r(this,Mt,"m",Ct).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,Mt,"m",Ct).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,Mt,"m",Ct).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,Mt,"m",Ct).bind(this))(t,e)}}function he(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.zambdaApiUrl)&&void 0!==e?e:"https://zambda-api.zapehr.com/v1"}function pe(e){return s(this,arguments,void 0,(function*({id:e,file:i,filename:s}){const r=yield this.request("/zambda/{id}/presigned-url","post",he.bind(this))({id:e,action:"upload",filename:s}),n=yield fetch(r.signedUrl,{method:"PUT",body:i});if(!n.ok)throw new t({message:"Failed to upload file",code:n.status,cause:n.statusText})}))}function ve(e){return s(this,arguments,void 0,(function*({id:e}){const i=yield this.request("/zambda/{id}/presigned-url","post",he.bind(this))({id:e,action:"download"}),s=yield fetch(i.signedUrl,{method:"GET"});if(!s.ok)throw new t({message:"Failed to download file",code:s.status,cause:s.statusText});return s.arrayBuffer()}))}Mt=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 me extends p{constructor(t){super(t),Jt.add(this),this.uploadFile=pe,this.downloadFile=ve}list(t){return this.request("/zambda","get",r(this,Jt,"m",Wt).bind(this))(t)}create(t,e){return this.request("/zambda","post",r(this,Jt,"m",Wt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",r(this,Jt,"m",Wt).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",r(this,Jt,"m",Wt).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",r(this,Jt,"m",Wt).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",r(this,Jt,"m",Wt).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",r(this,Jt,"m",Wt).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",r(this,Jt,"m",Wt).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/zambda/{id}/presigned-url","post",r(this,Jt,"m",Wt).bind(this))(t,e)}}Jt=new WeakSet,Wt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.zambdaApiUrl)&&void 0!==e?e:"https://zambda-api.zapehr.com/v1"};class fe extends p{constructor(t){super(t),Dt.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",r(this,Dt,"m",Lt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",r(this,Dt,"m",Lt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",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.zambdaApiUrl)&&void 0!==e?e:"https://zambda-api.zapehr.com/v1"};let ge=class{constructor(e){var i,s,r,n,o,u;if(e.workspaceTag&&e.ignoreTags)throw new t({message:"workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config",code:400});this.config=e,null!==(i=(n=this.config).services)&&void 0!==i||(n.services={}),null!==(s=(o=this.config.services).projectApiUrl)&&void 0!==s||(o.projectApiUrl=e.projectApiUrl),null!==(r=(u=this.config.services).fhirApiUrl)&&void 0!==r||(u.fhirApiUrl=e.fhirApiUrl),this.application=new w(e),this.developer=new R(e),this.m2m=new Gt(e),this.messaging=new Ht(e),this.conversation=new $(e),this.transactionalSMS=new re(e),this.paymentMethod=new Vt(e),this.charge=new j(e),this.project=new Xt(e),this.role=new te(e),this.secret=new ee(e),this.telemed=new ie(e),this.user=new ne(e),this.version=new oe(e),this.z3=new le(e),this.fax=new _(e),this.lab=new Bt(e),this.erx=new N(e),this.terminology=new se(e),this.zambda=new me(e),this.zambdaLogStream=new fe(e),this.rcm=new Yt(e),this.fhir=new Ft(e)}};class be extends ge{}be.OystehrFHIRError=i,be.OystehrSdkError=t,exports.default=be;
|
|
2
2
|
//# sourceMappingURL=index.min.cjs.map
|