@oystehr/sdk 4.3.4 → 4.3.6

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.
Files changed (49) hide show
  1. package/dist/cjs/index.min.cjs +1 -1
  2. package/dist/cjs/index.min.cjs.map +1 -1
  3. package/dist/cjs/resources/classes/erx.cjs +1 -1
  4. package/dist/cjs/resources/classes/erx.cjs.map +1 -1
  5. package/dist/cjs/resources/classes/erx.d.ts +1 -1
  6. package/dist/cjs/resources/classes/fhir-ext.cjs +4 -0
  7. package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
  8. package/dist/cjs/resources/classes/fhir-ext.d.ts +2 -1
  9. package/dist/cjs/resources/classes/fhir.cjs +1 -0
  10. package/dist/cjs/resources/classes/fhir.cjs.map +1 -1
  11. package/dist/cjs/resources/classes/fhir.d.ts +1 -0
  12. package/dist/cjs/resources/classes/rcm-ext.cjs +23 -0
  13. package/dist/cjs/resources/classes/rcm-ext.cjs.map +1 -0
  14. package/dist/cjs/resources/classes/rcm-ext.d.ts +8 -0
  15. package/dist/cjs/resources/classes/rcm.cjs +3 -0
  16. package/dist/cjs/resources/classes/rcm.cjs.map +1 -1
  17. package/dist/cjs/resources/classes/rcm.d.ts +3 -0
  18. package/dist/cjs/resources/types/RcmListPayersParams.d.ts +2 -2
  19. package/dist/cjs/resources/types/TelemedCreateMeetingParams.d.ts +4 -0
  20. package/dist/cjs/resources/types/fhir.d.ts +3 -0
  21. package/dist/esm/index.min.js +1 -1
  22. package/dist/esm/index.min.js.map +1 -1
  23. package/dist/esm/resources/classes/erx.d.ts +1 -1
  24. package/dist/esm/resources/classes/erx.js +1 -1
  25. package/dist/esm/resources/classes/erx.js.map +1 -1
  26. package/dist/esm/resources/classes/fhir-ext.d.ts +2 -1
  27. package/dist/esm/resources/classes/fhir-ext.js +4 -1
  28. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  29. package/dist/esm/resources/classes/fhir.d.ts +1 -0
  30. package/dist/esm/resources/classes/fhir.js +2 -1
  31. package/dist/esm/resources/classes/fhir.js.map +1 -1
  32. package/dist/esm/resources/classes/rcm-ext.d.ts +8 -0
  33. package/dist/esm/resources/classes/rcm-ext.js +20 -0
  34. package/dist/esm/resources/classes/rcm-ext.js.map +1 -0
  35. package/dist/esm/resources/classes/rcm.d.ts +3 -0
  36. package/dist/esm/resources/classes/rcm.js +3 -0
  37. package/dist/esm/resources/classes/rcm.js.map +1 -1
  38. package/dist/esm/resources/types/RcmListPayersParams.d.ts +2 -2
  39. package/dist/esm/resources/types/TelemedCreateMeetingParams.d.ts +4 -0
  40. package/dist/esm/resources/types/fhir.d.ts +3 -0
  41. package/package.json +1 -1
  42. package/src/resources/classes/erx.ts +1 -1
  43. package/src/resources/classes/fhir-ext.ts +9 -0
  44. package/src/resources/classes/fhir.ts +1 -0
  45. package/src/resources/classes/rcm-ext.ts +32 -0
  46. package/src/resources/classes/rcm.ts +3 -0
  47. package/src/resources/types/RcmListPayersParams.ts +2 -2
  48. package/src/resources/types/TelemedCreateMeetingParams.ts +4 -0
  49. package/src/resources/types/fhir.ts +4 -0
@@ -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 ct=0;ct<256;++ct)o.push((ct+256).toString(16).slice(1));let u;const a=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};class d{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 d({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,d){return(p,m)=>s(this,void 0,void 0,(function*(){var g,b,y,q,w,j,T,O,k,S,I,U,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(c.randomUUID&&!e)return c.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=d.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+"/",J=new URL(M,L);let G;if(Array.isArray(C))G=JSON.stringify(C);else if(Object.keys(C).length)if("get"===N)f(C,J.searchParams);else if("application/x-www-form-urlencoded"===(null==A?void 0:A.contentType)){const e=new URLSearchParams;f(C,e),G=e.toString()}else G=JSON.stringify(C);else"application/x-www-form-urlencoded"!==(null==A?void 0:A.contentType)&&"post"===N&&(G="{}");R.debug("Prepared request body",{method:N,path:n,requestId:null==A?void 0:A.requestId});const H=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}),V={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!==(I=null===(S=P.retry)||void 0===S?void 0:S.delay)&&void 0!==I?I:100,onRetry:null===(U=P.retry)||void 0===U?void 0:U.onRetry,retryOn:[...null!==(x=null===(E=P.retry)||void 0===E?void 0:E.retryOn)&&void 0!==x?x:[],...h]};return V.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:J,requestId:null==A?void 0:A.requestId});const a=Date.now(),c=yield _(new Request(J,{method:N.toUpperCase(),body:G,headers:H}));R.info("Request end",{method:N,url:J,duration:Date.now()-a,requestId:null==A?void 0:A.requestId});const d=c.body?yield c.text():null;let h;const l=c.headers.get("content-type");try{d&&((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:J,requestId:null==A?void 0:A.requestId}),h=JSON.parse(d),R.timeEnd("Deserialized JSON response",{method:N,url:J,requestId:null==A?void 0:A.requestId})):d&&((null==l?void 0:l.includes("application/xml"))||(null==l?void 0:l.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:J,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}}(d),R.timeEnd("Deserialized XML response",{method:N,url:J,requestId:null==A?void 0:A.requestId})):h=null}catch(p){h=null}if(R.debug("Deserialized response",{method:N,url:J,requestId:null==A?void 0:A.requestId}),!c.ok||c.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:d)&&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}))),V)}))}function f(e,t){for(const[i,s]of Object.entries(e))Array.isArray(s)?s.forEach((e=>t.append(i,e))):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 S,I,U,E,x,z,A,P;class R extends p{constructor(e){super(e),S.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,S,"m",I).bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",r(this,S,"m",I).bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,S,"m",I).bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,S,"m",I).bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,S,"m",I).bind(this))(e,t)}}S=new WeakSet,I=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),U.add(this)}get(e,t){return this.request("/developer/{id}","get",r(this,U,"m",E).bind(this))(e,t)}update(e,t){return this.request("/developer/{id}","patch",r(this,U,"m",E).bind(this))(e,t)}delete(e,t){return this.request("/developer/{id}","delete",r(this,U,"m",E).bind(this))(e,t)}invite(e,t){return this.request("/developer/invite","post",r(this,U,"m",E).bind(this))(e,t)}list(e){return this.request("/developer","get",r(this,U,"m",E).bind(this))(e)}listV2(e,t){return this.request("/developer/v2/list","get",r(this,U,"m",E).bind(this))(e,t)}}U=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,c;const d=i;if(null===(s=t.ignoreTags)||void 0===s?void 0:s.length){const s=null!==(n=null===(r=d.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!==(c=null===(a=d.meta)||void 0===a?void 0:a.tag)&&void 0!==c?c:[];if(!s.some((t=>D(t,e))))return Object.assign(Object.assign({},i),{meta:Object.assign(Object.assign({},d.meta),{tag:[...s,e]})})}return i}function J(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 G(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 H(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 V(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 B(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t},i){const s=yield this.fhirRequest(`/${e}/${t}`,"GET")({},i);return G(this.config,s),s}))}function F(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=J(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=J(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=J(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{G(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)||G(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){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 re(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 ne,oe,ue,ae,ce,de,he,le,pe,ve,me,fe,ge,be,ye,qe,we,je,Te,Oe,ke,Se,Ie,Ue,Ee,xe,ze,Ae,Pe,Re,Ne,_e,$e;class We extends p{constructor(e){super(e),ne.add(this),this.search=H,this.create=V,this.get=B,this.update=F,this.patch=X,this.delete=Z,this.history=K,this.batch=te,this.transaction=ie,this.formatAddress=se,this.formatHumanName=re}}ne=new WeakSet;class Me extends p{constructor(e){super(e),oe.add(this)}routeList(e){return this.request("/route","get",r(this,oe,"m",ue).bind(this))(e)}routeCreate(e,t){return this.request("/route","post",r(this,oe,"m",ue).bind(this))(e,t)}routeGet(e,t){return this.request("/route/{routeGuid}","get",r(this,oe,"m",ue).bind(this))(e,t)}routeDelete(e,t){return this.request("/route/{routeGuid}","delete",r(this,oe,"m",ue).bind(this))(e,t)}orderableItemList(e,t){return this.request("/orderableItem","get",r(this,oe,"m",ue).bind(this))(e,t)}orderableItemQuestionnaireGet(e,t){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,oe,"m",ue).bind(this))(e,t)}orderSubmit(e,t){return this.request("/submit","post",r(this,oe,"m",ue).bind(this))(e,t)}}oe=new WeakSet,ue=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 Ce extends p{constructor(e){super(e),ae.add(this)}list(e){return this.request("/m2m","get",r(this,ae,"m",ce).bind(this))(e)}create(e,t){return this.request("/m2m","post",r(this,ae,"m",ce).bind(this))(e,t)}me(e){return this.request("/m2m/me","get",r(this,ae,"m",ce).bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",r(this,ae,"m",ce).bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",r(this,ae,"m",ce).bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",r(this,ae,"m",ce).bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",r(this,ae,"m",ce).bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",r(this,ae,"m",ce).bind(this))(e,t)}}ae=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 De extends p{constructor(e){super(e),de.add(this)}getMessagingConfig(e){return this.request("/messaging/config","get",r(this,de,"m",he).bind(this))(e)}}de=new WeakSet,he=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),le.add(this)}setUp(e,t){return this.request("/payment/payment-method/setup","post",r(this,le,"m",pe).bind(this))(e,t)}setDefault(e,t){return this.request("/payment/payment-method/set-default","post",r(this,le,"m",pe).bind(this))(e,t)}delete(e,t){return this.request("/payment/payment-method","delete",r(this,le,"m",pe).bind(this))(e,t)}list(e,t){return this.request("/payment/payment-method/list","post",r(this,le,"m",pe).bind(this))(e,t)}}le=new WeakSet,pe=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),ve.add(this)}get(e){return this.request("/project","get",r(this,ve,"m",me).bind(this))(e)}update(e,t){return this.request("/project","patch",r(this,ve,"m",me).bind(this))(e,t)}}ve=new WeakSet,me=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),fe.add(this)}eligibilityCheck(e,t){return this.request("/eligibility-check","post",r(this,fe,"m",ge).bind(this))(e,t)}submitClaim(e,t){return this.request("/claim/{claimId}/submit","post",r(this,fe,"m",ge).bind(this))(e,t)}setClaimStatus(e,t){return this.request("/claim/{claimId}/status","post",r(this,fe,"m",ge).bind(this))(e,t)}listPayers(e,t){return this.request("/payer","get",r(this,fe,"m",ge).bind(this))(e,t)}getPayer(e,t){return this.request("/payer/{id}","get",r(this,fe,"m",ge).bind(this))(e,t)}}fe=new WeakSet,ge=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 He extends p{constructor(e){super(e),be.add(this)}list(e){return this.request("/iam/role","get",r(this,be,"m",ye).bind(this))(e)}create(e,t){return this.request("/iam/role","post",r(this,be,"m",ye).bind(this))(e,t)}get(e,t){return this.request("/iam/role/{roleId}","get",r(this,be,"m",ye).bind(this))(e,t)}update(e,t){return this.request("/iam/role/{roleId}","patch",r(this,be,"m",ye).bind(this))(e,t)}delete(e,t){return this.request("/iam/role/{roleId}","delete",r(this,be,"m",ye).bind(this))(e,t)}}be=new WeakSet,ye=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 Ve extends p{constructor(e){super(e),qe.add(this)}list(e){return this.request("/secret","get",r(this,qe,"m",we).bind(this))(e)}set(e,t){return this.request("/secret","post",r(this,qe,"m",we).bind(this))(e,t)}get(e,t){return this.request("/secret/{name}","get",r(this,qe,"m",we).bind(this))(e,t)}delete(e,t){return this.request("/secret/{name}","delete",r(this,qe,"m",we).bind(this))(e,t)}}qe=new WeakSet,we=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),je.add(this)}createMeeting(e,t){return this.request("/telemed/v2/meeting","post",r(this,je,"m",Te).bind(this))(e,t)}joinMeeting(e,t){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,je,"m",Te).bind(this))(e,t)}}je=new WeakSet,Te=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 Fe extends p{constructor(e){super(e),Oe.add(this)}searchCpt(e,t){return this.request("/cpt/search","get",r(this,Oe,"m",ke).bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",r(this,Oe,"m",ke).bind(this))(e,t)}}Oe=new WeakSet,ke=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 Xe 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 Ze extends p{constructor(e){super(e),Ue.add(this)}me(e){return this.request("/user/me","get",r(this,Ue,"m",Ee).bind(this))(e)}get(e,t){return this.request("/user/{id}","get",r(this,Ue,"m",Ee).bind(this))(e,t)}update(e,t){return this.request("/user/{id}","patch",r(this,Ue,"m",Ee).bind(this))(e,t)}delete(e,t){return this.request("/user/{id}","delete",r(this,Ue,"m",Ee).bind(this))(e,t)}resetMfa(e,t){return this.request("/user/{id}/reset-mfa","post",r(this,Ue,"m",Ee).bind(this))(e,t)}resetPasswordLink(e,t){return this.request("/user/{id}/reset-password-link","post",r(this,Ue,"m",Ee).bind(this))(e,t)}changePassword(e,t){return this.request("/user/{id}/change-password","post",r(this,Ue,"m",Ee).bind(this))(e,t)}invite(e,t){return this.request("/user/invite","post",r(this,Ue,"m",Ee).bind(this))(e,t)}list(e){return this.request("/user","get",r(this,Ue,"m",Ee).bind(this))(e)}listV2(e,t){return this.request("/user/v2/list","get",r(this,Ue,"m",Ee).bind(this))(e,t)}}Ue=new WeakSet,Ee=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),xe.add(this)}get(e){return this.request("/version","get",r(this,xe,"m",ze).bind(this))(e)}}function Qe(){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 Ye(e){return s(this,arguments,void 0,(function*({bucketName:e,"objectPath+":t,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Qe.bind(this))({action:"upload",bucketName:e,"objectPath+":t});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function et(e){return s(this,arguments,void 0,(function*({bucketName:e,"objectPath+":t}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Qe.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 tt(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",Qe.bind(this))(u)}))}xe=new WeakSet,ze=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 it extends p{constructor(e){super(e),Ae.add(this),this.uploadFile=Ye,this.downloadFile=et,this.getPresignedUrlForZ3Url=tt}listBuckets(e){return this.request("/z3","get",r(this,Ae,"m",Pe).bind(this))(e)}createBucket(e,t){return this.request("/z3/{bucketName}","put",r(this,Ae,"m",Pe).bind(this))(e,t)}deleteBucket(e,t){return this.request("/z3/{bucketName}","delete",r(this,Ae,"m",Pe).bind(this))(e,t)}listObjects(e,t){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,Ae,"m",Pe).bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,Ae,"m",Pe).bind(this))(e,t)}deleteObject(e,t){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,Ae,"m",Pe).bind(this))(e,t)}}function st(){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 rt(e){return s(this,arguments,void 0,(function*({id:e,file:t,filename:i}){const s=yield this.request("/zambda/{id}/s3-upload","post",st.bind(this))({id:e,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:t})}))}Ae=new WeakSet,Pe=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 nt extends p{constructor(e){super(e),Re.add(this),this.uploadFile=rt}list(e){return this.request("/zambda","get",r(this,Re,"m",Ne).bind(this))(e)}create(e,t){return this.request("/zambda","post",r(this,Re,"m",Ne).bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}","get",r(this,Re,"m",Ne).bind(this))(e,t)}update(e,t){return this.request("/zambda/{id}","patch",r(this,Re,"m",Ne).bind(this))(e,t)}delete(e,t){return this.request("/zambda/{id}","delete",r(this,Re,"m",Ne).bind(this))(e,t)}execute(e,t){return this.request("/zambda/{id}/execute","post",r(this,Re,"m",Ne).bind(this))(e,t)}executePublic(e,t){return this.request("/zambda/{id}/execute-public","post",r(this,Re,"m",Ne).bind(this))(e,t)}s3Upload(e,t){return this.request("/zambda/{id}/s3-upload","post",r(this,Re,"m",Ne).bind(this))(e,t)}}Re=new WeakSet,Ne=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 ot extends p{constructor(e){super(e),_e.add(this)}list(e,t){return this.request("/zambda/{id}/logStream","post",r(this,_e,"m",$e).bind(this))(e,t)}search(e,t){return this.request("/zambda/{id}/logStream/search","post",r(this,_e,"m",$e).bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}/logStream/{logStreamName}","post",r(this,_e,"m",$e).bind(this))(e,t)}}_e=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"};let ut=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 Ce(t),this.messaging=new De(t),this.conversation=new R(t),this.transactionalSMS=new Xe(t),this.paymentMethod=new Le(t),this.charge=new j(t),this.project=new Je(t),this.role=new He(t),this.secret=new Ve(t),this.telemed=new Be(t),this.user=new Ze(t),this.version=new Ke(t),this.z3=new it(t),this.fax=new $(t),this.lab=new Me(t),this.erx=new _(t),this.terminology=new Fe(t),this.zambda=new nt(t),this.zambdaLogStream=new ot(t),this.rcm=new Ge(t),this.fhir=new We(t)}};class at extends ut{}at.OystehrFHIRError=i,at.OystehrSdkError=e,exports.default=at;
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 pt=0;pt<256;++pt)o.push((pt+256).toString(16).slice(1));let u;const a=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};class d{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 d({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,d){return(p,m)=>s(this,void 0,void 0,(function*(){var g,b,y,q,w,j,T,O,k,S,U,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(c.randomUUID&&!e)return c.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=d.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+"/",J=new URL(M,L);let G;if(Array.isArray(C))G=JSON.stringify(C);else if(Object.keys(C).length)if("get"===N)f(C,J.searchParams);else if("application/x-www-form-urlencoded"===(null==A?void 0:A.contentType)){const e=new URLSearchParams;f(C,e),G=e.toString()}else G=JSON.stringify(C);else"application/x-www-form-urlencoded"!==(null==A?void 0:A.contentType)&&"post"===N&&(G="{}");R.debug("Prepared request body",{method:N,path:n,requestId:null==A?void 0:A.requestId});const H=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}),V={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!==(U=null===(S=P.retry)||void 0===S?void 0:S.delay)&&void 0!==U?U: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 V.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:J,requestId:null==A?void 0:A.requestId});const a=Date.now(),c=yield _(new Request(J,{method:N.toUpperCase(),body:G,headers:H}));R.info("Request end",{method:N,url:J,duration:Date.now()-a,requestId:null==A?void 0:A.requestId});const d=c.body?yield c.text():null;let h;const l=c.headers.get("content-type");try{d&&((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:J,requestId:null==A?void 0:A.requestId}),h=JSON.parse(d),R.timeEnd("Deserialized JSON response",{method:N,url:J,requestId:null==A?void 0:A.requestId})):d&&((null==l?void 0:l.includes("application/xml"))||(null==l?void 0:l.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:J,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}}(d),R.timeEnd("Deserialized XML response",{method:N,url:J,requestId:null==A?void 0:A.requestId})):h=null}catch(p){h=null}if(R.debug("Deserialized response",{method:N,url:J,requestId:null==A?void 0:A.requestId}),!c.ok||c.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:d)&&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}))),V)}))}function f(e,t){for(const[i,s]of Object.entries(e))Array.isArray(s)?s.forEach((e=>t.append(i,e))):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 S,U,I,E,x,z,A,P;class R extends p{constructor(e){super(e),S.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,S,"m",U).bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",r(this,S,"m",U).bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,S,"m",U).bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,S,"m",U).bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,S,"m",U).bind(this))(e,t)}}S=new WeakSet,U=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,c;const d=i;if(null===(s=t.ignoreTags)||void 0===s?void 0:s.length){const s=null!==(n=null===(r=d.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!==(c=null===(a=d.meta)||void 0===a?void 0:a.tag)&&void 0!==c?c:[];if(!s.some((t=>D(t,e))))return Object.assign(Object.assign({},i),{meta:Object.assign(Object.assign({},d.meta),{tag:[...s,e]})})}return i}function J(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 G(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 H(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 V(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 B(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t},i){const s=yield this.fhirRequest(`/${e}/${t}`,"GET")({},i);return G(this.config,s),s}))}function F(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=J(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=J(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=J(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{G(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)||G(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,ce,de,he,le,pe,ve,me,fe,ge,be,ye,qe,we,je,Te,Oe,ke,Se,Ue,Ie,Ee,xe,ze,Ae,Pe,Re,Ne,_e,$e,We;class Me extends p{constructor(e){super(e),oe.add(this),this.search=H,this.create=V,this.get=B,this.update=F,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),ce.add(this)}list(e){return this.request("/m2m","get",r(this,ce,"m",de).bind(this))(e)}create(e,t){return this.request("/m2m","post",r(this,ce,"m",de).bind(this))(e,t)}me(e){return this.request("/m2m/me","get",r(this,ce,"m",de).bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",r(this,ce,"m",de).bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",r(this,ce,"m",de).bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",r(this,ce,"m",de).bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",r(this,ce,"m",de).bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",r(this,ce,"m",de).bind(this))(e,t)}}ce=new WeakSet,de=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 Je 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 Ge 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 He(){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 Ve({id:e}){return`${He.call(this)}/payer/${e}`}function Be(t,i){return s(this,arguments,void 0,(function*({url:t},i){if(!t.startsWith(Ve.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",He.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 Fe extends p{constructor(e){super(e),ge.add(this),this.constructPayerUrl=Ve,this.getPayerByUrl=Be}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",Se).bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",r(this,ke,"m",Se).bind(this))(e,t)}}ke=new WeakSet,Se=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),Ue.add(this)}send(e,t){return this.request("/messaging/transactional-sms/send","post",r(this,Ue,"m",Ie).bind(this))(e,t)}}Ue=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.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"}function at(e){return s(this,arguments,void 0,(function*({id:e,file:t,filename:i}){const s=yield this.request("/zambda/{id}/s3-upload","post",ut.bind(this))({id:e,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:t})}))}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}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)}}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 dt 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 ht=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 Je(t),this.charge=new j(t),this.project=new Ge(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 dt(t),this.rcm=new Fe(t),this.fhir=new Me(t)}};class lt extends ht{}lt.OystehrFHIRError=i,lt.OystehrSdkError=e,exports.default=lt;
2
2
  //# sourceMappingURL=index.min.cjs.map