@oystehr/sdk 4.3.11 → 4.3.12
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/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/erx.cjs +8 -0
- package/dist/cjs/resources/classes/erx.cjs.map +1 -1
- package/dist/cjs/resources/classes/erx.d.ts +7 -1
- package/dist/cjs/resources/classes/fhir.cjs +31 -0
- package/dist/cjs/resources/classes/fhir.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir.d.ts +31 -0
- package/dist/cjs/resources/classes/rcm.cjs +9 -0
- package/dist/cjs/resources/classes/rcm.cjs.map +1 -1
- package/dist/cjs/resources/classes/rcm.d.ts +8 -1
- package/dist/cjs/resources/classes/terminology.cjs +9 -0
- package/dist/cjs/resources/classes/terminology.cjs.map +1 -1
- package/dist/cjs/resources/classes/terminology.d.ts +8 -1
- package/dist/cjs/resources/classes/z3.cjs +9 -0
- package/dist/cjs/resources/classes/z3.cjs.map +1 -1
- package/dist/cjs/resources/classes/z3.d.ts +8 -1
- package/dist/cjs/resources/types/ErxGetMedicationHistoryResponse.d.ts +1 -1
- package/dist/cjs/resources/types/ErxGetPharmacyParams.d.ts +3 -0
- package/dist/cjs/resources/types/ErxGetPharmacyResponse.d.ts +16 -0
- package/dist/cjs/resources/types/ErxSearchPharmaciesResponse.d.ts +2 -2
- package/dist/cjs/resources/types/LabOrderSubmitParams.d.ts +4 -0
- package/dist/cjs/resources/types/RcmProcessEraParams.d.ts +6 -0
- package/dist/cjs/resources/types/RcmProcessEraResponse.d.ts +5 -0
- package/dist/cjs/resources/types/TerminologySearchIcd10Params.d.ts +9 -0
- package/dist/cjs/resources/types/TerminologySearchIcd10Response.d.ts +27 -0
- package/dist/cjs/resources/types/Z3EmptyBucketParams.d.ts +3 -0
- package/dist/cjs/resources/types/Z3EmptyBucketResponse.d.ts +9 -0
- package/dist/cjs/resources/types/index.d.ts +8 -0
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/erx.d.ts +7 -1
- package/dist/esm/resources/classes/erx.js +8 -0
- package/dist/esm/resources/classes/erx.js.map +1 -1
- package/dist/esm/resources/classes/fhir.d.ts +31 -0
- package/dist/esm/resources/classes/fhir.js +31 -0
- package/dist/esm/resources/classes/fhir.js.map +1 -1
- package/dist/esm/resources/classes/rcm.d.ts +8 -1
- package/dist/esm/resources/classes/rcm.js +9 -0
- package/dist/esm/resources/classes/rcm.js.map +1 -1
- package/dist/esm/resources/classes/terminology.d.ts +8 -1
- package/dist/esm/resources/classes/terminology.js +9 -0
- package/dist/esm/resources/classes/terminology.js.map +1 -1
- package/dist/esm/resources/classes/z3.d.ts +8 -1
- package/dist/esm/resources/classes/z3.js +9 -0
- package/dist/esm/resources/classes/z3.js.map +1 -1
- package/dist/esm/resources/types/ErxGetMedicationHistoryResponse.d.ts +1 -1
- package/dist/esm/resources/types/ErxGetPharmacyParams.d.ts +3 -0
- package/dist/esm/resources/types/ErxGetPharmacyResponse.d.ts +16 -0
- package/dist/esm/resources/types/ErxSearchPharmaciesResponse.d.ts +2 -2
- package/dist/esm/resources/types/LabOrderSubmitParams.d.ts +4 -0
- package/dist/esm/resources/types/RcmProcessEraParams.d.ts +6 -0
- package/dist/esm/resources/types/RcmProcessEraResponse.d.ts +5 -0
- package/dist/esm/resources/types/TerminologySearchIcd10Params.d.ts +9 -0
- package/dist/esm/resources/types/TerminologySearchIcd10Response.d.ts +27 -0
- package/dist/esm/resources/types/Z3EmptyBucketParams.d.ts +3 -0
- package/dist/esm/resources/types/Z3EmptyBucketResponse.d.ts +9 -0
- package/dist/esm/resources/types/index.d.ts +8 -0
- package/package.json +1 -1
- package/src/resources/classes/erx.ts +10 -0
- package/src/resources/classes/fhir.ts +31 -0
- package/src/resources/classes/rcm.ts +11 -0
- package/src/resources/classes/terminology.ts +14 -0
- package/src/resources/classes/z3.ts +11 -0
- package/src/resources/types/ErxGetMedicationHistoryResponse.ts +1 -1
- package/src/resources/types/ErxGetPharmacyParams.ts +5 -0
- package/src/resources/types/ErxGetPharmacyResponse.ts +18 -0
- package/src/resources/types/ErxSearchPharmaciesResponse.ts +2 -2
- package/src/resources/types/LabOrderSubmitParams.ts +4 -0
- package/src/resources/types/RcmProcessEraParams.ts +8 -0
- package/src/resources/types/RcmProcessEraResponse.ts +7 -0
- package/src/resources/types/TerminologySearchIcd10Params.ts +11 -0
- package/src/resources/types/TerminologySearchIcd10Response.ts +29 -0
- package/src/resources/types/Z3EmptyBucketParams.ts +5 -0
- package/src/resources/types/Z3EmptyBucketResponse.ts +11 -0
- package/src/resources/types/index.ts +8 -0
package/dist/cjs/index.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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(n,r){function o(t){try{a(s.next(t))}catch(e){r(e)}}function u(t){try{a(s.throw(t))}catch(e){r(e)}}function a(t){var e;t.done?n(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 n(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 r=/^(?:[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 Oe=0;Oe<256;++Oe)o.push((Oe+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: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 d({level:this.config.logLevel})}request(e,i,n){return(r,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config,u=()=>this.logger;try{return yield v(n,s,u,e,i)(r,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,n){return(r,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 v(t,i,s,e,n)(r,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,n,r,o){return s(this,void 0,void 0,(function*(){const s="async-bulk"===r?"bulk":"bundle",u="async-bulk"===r?this.appendBulkOutputFormat(e):e,a=yield this.fhirRequest(u,i)(n,Object.assign(Object.assign({},o),{rawResponse:!0}),r);if(202!==a.status)throw new t({message:`Expected start async job to return 202 Accepted, received ${a.status}`,code:a.status});const c=this.readHeader(a.headers,"content-location");if(!c)throw new t({message:"Start Async job response missing Content-Location header",code:500});const d=this.parseAsyncJobId(c);if(!d)throw new t({message:`Could not parse async job id from Content-Location: ${c}`,code:500});return{jobId:d,contentLocation:c,mode:s}}))}fetchAsyncJobStatus(t,e){return s(this,void 0,void 0,(function*(){var i,s,n;const r=yield this.fhirRequest(`/async-job/${t}`,"GET")({},Object.assign(Object.assign({},e),{rawResponse:!0}));if(202===r.status)return{status:202,xProgress:this.readHeader(r.headers,"x-progress"),retryAfter:this.readHeader(r.headers,"retry-after")};if(410===r.status)return{status:410};if(404===r.status)return{status:404};if(200===r.status){if(this.isBulkManifest(r.body))return{status:200,mode:"bulk",manifest:r.body};const t=r.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===(n=null==e?void 0:e.response)||void 0===n?void 0:n.outcome}}return{status:200,body:r.body}}return{status:r.status,body:r.body}}))}readHeader(t,e){const i=t[e];if(null!=i)return i;const s=e.toLowerCase(),n=Object.keys(t).find((t=>t.toLowerCase()===s));return n?t[n]: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(e,i,n,d,p){return(v,m,g)=>s(this,void 0,void 0,(function*(){var b,y,q,w,j,O,T,k,S,A,E,x,I,U;let[P,$]=function(t,e){var i;const s=!!t&&!e&&!Array.isArray(t)&&function(t){var e,i;return"accessToken"in t||"projectId"in t&&"string"==typeof(i=t.projectId)&&r.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/"')||"ifNoneExist"in t||"mode"in t||"rawResponse"in t}(t)&&!function(t){return"string"==typeof t.resourceType&&t.resourceType.length>0}(t);return[s?{}:null!==(i=t)&&void 0!==i?i:{},s?t:e]}(v,m);null!=$||($={}),null!==(b=$.requestId)&&void 0!==b||($.requestId=function(t){if(c.randomUUID&&!t)return c.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 z=i(),R=n(),N=p.toLowerCase();R.debug("Beginning fetch",{method:N,path:d,requestId:null==$?void 0:$.requestId});const _=null!==(y=z.fetch)&&void 0!==y?y:fetch,M=null!==(q=null==$?void 0:$.accessToken)&&void 0!==q?q:z.accessToken,C=null!==(w=null==$?void 0:$.projectId)&&void 0!==w?w:z.projectId;let J=d,D=P;if(!Array.isArray(P)){const[e,i]=function(e,i){const s=Object.assign({},i),n=e.replace(/\{([^}]+)\}/g,((e,n)=>{if(delete s[n],n.match(/^.*\+$/))return i[n]+"";if(!i[n]||""===i[n])throw new t({message:`Required path parameter is an empty string: ${n}`,code:400});return i[n]?encodeURIComponent(i[n]+""):""})),r=Object.keys(s);return[n,r.length?r.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{}]}(d,P);J=e,D=i}R.debug("Substituted parameters in path",{method:N,path:d,requestId:null==$?void 0:$.requestId}),J=J.replace(/^\//,"");const W=e(),L=W.endsWith("/")?W:W+"/",B=new URL(J,L);let F;if(Array.isArray(D))F=JSON.stringify(D);else if(Object.keys(D).length)if("get"===N)f(D,B.searchParams);else if("application/x-www-form-urlencoded"===(null==$?void 0:$.contentType)){const t=new URLSearchParams;f(D,t),F=t.toString()}else F=JSON.stringify(D);else"application/x-www-form-urlencoded"!==(null==$?void 0:$.contentType)&&"post"===N&&(F="{}");R.debug("Prepared request body",{method:N,path:d,requestId:null==$?void 0:$.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==$?void 0:$.contentType)&&void 0!==j?j:"application/json"},G?{Prefer:G}:{},M?{Authorization:`Bearer ${M}`}:{},(null==$?void 0:$.ifMatch)?{"If-Match":$.ifMatch}:{},(null==$?void 0:$.ifNoneExist)?{"If-None-Exist":$.ifNoneExist}:{},{"x-oystehr-request-id":null==$?void 0:$.requestId}),V={retries:null!==(T=null===(O=z.retry)||void 0===O?void 0:O.retries)&&void 0!==T?T:3,jitter:null!==(S=null===(k=z.retry)||void 0===k?void 0:k.jitter)&&void 0!==S?S:20,delay:null!==(E=null===(A=z.retry)||void 0===A?void 0:A.delay)&&void 0!==E?E:100,onRetry:null===(x=z.retry)||void 0===x?void 0:x.onRetry,retryOn:[...null!==(U=null===(I=z.retry)||void 0===I?void 0:I.retryOn)&&void 0!==U?U:[],...l]};return V.retryOn.push(...l),function(t,e){return s(this,void 0,void 0,(function*(){var i,s;let n;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(r){let t=!1;if("response"in r){const i=r;t=e.retryOn.includes(i.code),n={message:r.message,code:r.code}}else if(n=r,"code"in r&&"string"==typeof r.code){const e=r;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 n}))}((()=>s(this,void 0,void 0,(function*(){var t,e,i,s,n,r,o,u;R.info("Request start",{method:N,url:B,requestId:null==$?void 0:$.requestId});const a=Date.now(),c=yield _(new Request(B,{method:N.toUpperCase(),body:F,headers:H}));R.info("Request end",{method:N,url:B,duration:Date.now()-a,requestId:null==$?void 0:$.requestId});const d=c.body?yield c.text():null;let l;const h=c.headers.get("content-type");try{d&&((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:B,requestId:null==$?void 0:$.requestId}),l=JSON.parse(d),R.timeEnd("Deserialized JSON response",{method:N,url:B,requestId:null==$?void 0:$.requestId})):d&&((null==h?void 0:h.includes("application/xml"))||(null==h?void 0:h.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:B,requestId:null==$?void 0:$.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>/),n=s?s[1]:null;return null===i||null===n?null:{status:i,output:n}}catch(e){return null}}(d),R.timeEnd("Deserialized XML response",{method:N,url:B,requestId:null==$?void 0:$.requestId})):l=null}catch(p){l=null}if(R.debug("Deserialized response",{method:N,url:B,requestId:null==$?void 0:$.requestId}),null==$?void 0:$.rawResponse){const t={};return c.headers.forEach(((e,i)=>{t[i]=e})),{status:c.status,headers:t,body:null!=l?l:d}}if(!c.ok||c.status>=400)throw{message:null!==(n=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:d)&&void 0!==n?n:c.statusText,code:null!==(u=null!==(o=null===(r=null==l?void 0:l.output)||void 0===r?void 0:r.code)&&void 0!==o?o:null==l?void 0:l.code)&&void 0!==u?u:c.status,response:c};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 m,g,b,y;class q extends p{constructor(t){super(t),m.add(this)}list(t){return this.request("/application","get",n(this,m,"m",g).bind(this))(t)}create(t,e){return this.request("/application","post",n(this,m,"m",g).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",n(this,m,"m",g).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",n(this,m,"m",g).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",n(this,m,"m",g).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",n(this,m,"m",g).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",n(this,m,"m",g).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",n(this,m,"m",g).bind(this))(t,e)}}m=new WeakSet,g=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class w extends p{constructor(t){super(t),b.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",n(this,b,"m",y).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",n(this,b,"m",y).bind(this))(t,e)}}b=new WeakSet,y=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};const j="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",O="addressString";function T(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 n=t.extension.find((t=>t.url===j));return(null==n?void 0:n.extension)?null===(s=null===(i=n.extension)||void 0===i?void 0:i.find((t=>t.url===O)))||void 0===s?void 0:s.valueString:void 0}var k,S,A,E,x,I,U,P;class $ extends p{constructor(t){super(t),k.add(this),this.ENCOUNTER_VS_EXTENSION_URL=j,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=O,this.getConversationIdFromEncounter=T}create(t,e){return this.request("/messaging/conversation","post",n(this,k,"m",S).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",n(this,k,"m",S).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",n(this,k,"m",S).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",n(this,k,"m",S).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",n(this,k,"m",S).bind(this))(t,e)}}k=new WeakSet,S=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 z extends p{constructor(t){super(t),A.add(this)}get(t,e){return this.request("/developer/{id}","get",n(this,A,"m",E).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",n(this,A,"m",E).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",n(this,A,"m",E).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",n(this,A,"m",E).bind(this))(t,e)}list(t){return this.request("/developer","get",n(this,A,"m",E).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",n(this,A,"m",E).bind(this))(t,e)}}A=new WeakSet,E=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),x.add(this)}searchAllergens(t,e){return this.request("/allergen","get",n(this,x,"m",I).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",n(this,x,"m",I).bind(this))(t,e)}getMedication(t,e){return this.request("/medication/details","get",n(this,x,"m",I).bind(this))(t,e)}getConfiguration(t){return this.request("/config","get",n(this,x,"m",I).bind(this))(t)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",n(this,x,"m",I).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",n(this,x,"m",I).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",n(this,x,"m",I).bind(this))(t,e)}getMedicationHistory(t,e){return this.request("/patient/{patientId}/medication-history","get",n(this,x,"m",I).bind(this))(t,e)}addPatientPharmacy(t,e){return this.request("/patient/{patientId}/pharmacies","post",n(this,x,"m",I).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",n(this,x,"m",I).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",n(this,x,"m",I).bind(this))(t,e)}searchPharmacies(t,e){return this.request("/pharmacy","get",n(this,x,"m",I).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",n(this,x,"m",I).bind(this))(t,e)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",n(this,x,"m",I).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",n(this,x,"m",I).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",n(this,x,"m",I).bind(this))(t,e)}}x=new WeakSet,I=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 N extends p{constructor(t){super(t),U.add(this)}offboard(t){return this.request("/offboard","post",n(this,U,"m",P).bind(this))(t)}onboard(t){return this.request("/onboard","post",n(this,U,"m",P).bind(this))(t)}getConfiguration(t){return this.request("/config","get",n(this,U,"m",P).bind(this))(t)}send(t,e){return this.request("/send","post",n(this,U,"m",P).bind(this))(t,e)}}U=new WeakSet,P=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 _=65535;function M(t){const e=(new globalThis.TextEncoder).encode(t);let i="";for(let s=0;s<e.length;s+=_){const t=e.subarray(s,s+_);i+=globalThis.btoa(String.fromCodePoint.apply(void 0,t))}return i}function C(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 J(t,e){var i,s,n,r;return(null!==(i=t.system)&&void 0!==i?i:"")===(null!==(s=e.system)&&void 0!==s?s:"")&&(null!==(n=t.code)&&void 0!==n?n:"")===(null!==(r=e.code)&&void 0!==r?r:"")}function D(e,i){var s,n,r,o,u,a,c;const d=i;if(null===(s=e.ignoreTags)||void 0===s?void 0:s.length){const s=null!==(r=null===(n=d.meta)||void 0===n?void 0:n.tag)&&void 0!==r?r:[];for(const i of e.ignoreTags)if(s.some((t=>J(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!==(c=null===(a=d.meta)||void 0===a?void 0:a.tag)&&void 0!==c?c:[];if(!s.some((e=>J(e,t))))return Object.assign(Object.assign({},i),{meta:Object.assign(Object.assign({},d.meta),{tag:[...s,t]})})}return i}function W(e,i){var s,n,r;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(J(s,i))throw new t({message:`Patch operation contains an ignored tag (system: "${null!==(n=i.system)&&void 0!==n?n:""}", code: "${null!==(r=i.code)&&void 0!==r?r:""}") 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=>J(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 n=null!=i.value&&"object"==typeof i.value?i.value:{},r=null!==(s=n.tag)&&void 0!==s?s:[];return r.some((e=>J(e,t)))?e.push(i):e.push(Object.assign(Object.assign({},i),{value:Object.assign(Object.assign({},n),{tag:[...r,t]})})),e}return e.push(i),e}),[])}return i}function L(t,e){var s,n,r;const o=null!==(n=null===(s=e.meta)||void 0===s?void 0:s.tag)&&void 0!==n?n:[];if(t.workspaceTag){const e=t.workspaceTag;if(!o.some((t=>J(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===(r=t.ignoreTags)||void 0===r?void 0:r.length)for(const u of t.ignoreTags)if(o.some((t=>J(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){if("string"==typeof t)return t;const e=new URLSearchParams;for(const i of t)e.append(i.name,String(i.value));return e.toString()}function F(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:C(t.workspaceTag)});else if(null===(i=t.ignoreTags)||void 0===i?void 0:i.length)for(const n of t.ignoreTags)s.push({name:"_tag:not",value:C(n)});return s}(this.config,t.params);let n;s.length&&(n=s.reduce(((t,e)=>(t[e.name]||(t[e.name]=[]),t[e.name].push(e.value),t)),{}));const r=null==e?void 0:e.mode;if(F(r))return yield this.startAsyncJob(`/${i}/_search`,"POST",null!=n?n:{},r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));const o=yield this.fhirRequest(`/${i}/_search`,"POST")(n,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*(){var i,s,n,r,o;const{pageSize:u}=t,a=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i}(t,["pageSize"]);let c=a;if(u){const t=null!==(s=(null!==(i=a.params)&&void 0!==i?i:[]).filter((t=>"_count"!==t.name)))&&void 0!==s?s:[];c=Object.assign(Object.assign({},a),{params:[...t,{name:"_count",value:u}]})}const d=[],l=G;let h=yield l.call(this,c,e);const p=Object.assign(Object.assign({},h),{link:null===(n=h.link)||void 0===n?void 0:n.filter((t=>"next"!==t.relation))});for(;;){const t=h.entry;t&&d.push(...t);const i=null===(o=null===(r=h.link)||void 0===r?void 0:r.find((t=>"next"===t.relation)))||void 0===o?void 0:o.url;if(!i)break;h=yield this.fhirRequest(i,"GET")({},e)}return Object.assign(Object.assign({},p),{entry:d.length?d:void 0,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 V(t,e){return s(this,void 0,void 0,(function*(){const i=D(this.config,t),{resourceType:s}=i,n=null==e?void 0:e.mode,r=Object.assign(Object.assign({},e),{ifNoneExist:void 0!==(null==e?void 0:e.ifNoneExist)?B(e.ifNoneExist):void 0});return F(n)?yield this.startAsyncJob(`/${s}`,"POST",i,n,r):yield this.fhirRequest(`/${s}`,"POST")(i,r)}))}function X(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){const s=null==i?void 0:i.mode;if(F(s))return yield this.startAsyncJob(`/${t}/${e}`,"GET",{},s,i);const n=yield this.fhirRequest(`/${t}/${e}`,"GET")({},i);return L(this.config,n),n}))}function Z(t,e){return s(this,void 0,void 0,(function*(){const i=D(this.config,t),{id:s,resourceType:n}=i,r=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 F(r)?yield this.startAsyncJob(`/${n}/${s}`,"PUT",i,r,o):yield this.fhirRequest(`/${n}/${s}`,"PUT")(i,o)}))}function K(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,operations:i},s){const n=W(this.config,i),r=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 F(r)?yield this.startAsyncJob(`/${t}/${e}`,"PATCH",n,r,Object.assign(Object.assign({},o),{contentType:"application/json-patch+json"})):this.fhirRequest(`/${t}/${e}`,"PATCH")(n,Object.assign(Object.assign({},o),{contentType:"application/json-patch+json"}))}))}function Q(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){const s=null==i?void 0:i.mode;return F(s)?yield this.startAsyncJob(`/${t}/${e}`,"DELETE",{},s,i):yield this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function Y(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 tt(t,e){return s(this,void 0,void 0,(function*(){return yield this.fetchAsyncJobStatus(t,e)}))}function et(e,i,n){return s(this,void 0,void 0,(function*(){var s,r;const o=null!==(s=null==i?void 0:i.pollIntervalMs)&&void 0!==s?s:5e3,u=null!==(r=null==i?void 0:i.timeoutMs)&&void 0!==r?r:9e5,a=Math.max(1,Math.ceil(u/o));for(let t=0;t<a;t++){const i=yield this.fetchAsyncJobStatus(e,n);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,Y(t,o))))}}throw new t({message:`Async job ${e} did not complete within ${u} ms`,code:408})}))}function it(e,i){const s=[],n=e.split("\n");for(let o=0;o<n.length;o++){const e=n[o].trim();if(0!==e.length)try{s.push(JSON.parse(e))}catch(r){throw new t({message:`Failed to parse NDJSON line ${o+1} from ${i}`,code:500,cause:r})}}return s}function st(e,i,n){return s(this,void 0,void 0,(function*(){var r,o,u;const a=yield et.call(this,e,i,n);if(404===a.status)throw new t({message:`Async job ${e} not found`,code:404});if(410===a.status)throw new t({message:`Async job ${e} expired`,code:410});if(200!==a.status||!("mode"in a)||"bulk"!==a.mode)throw new t({message:`Async job ${e} did not complete in bulk mode`,code:a.status});const c=null!==(r=null==n?void 0:n.accessToken)&&void 0!==r?r:this.config.accessToken,d=null!==(o=null==n?void 0:n.projectId)&&void 0!==o?o:this.config.projectId;if(a.manifest.requiresAccessToken&&!c)throw new t({message:`Bulk output for async job ${e} requires an access token`,code:401});const l=null!==(u=this.config.fetch)&&void 0!==u?u:fetch,h={};d&&(h["x-zapehr-project-id"]=d,h["x-oystehr-project-id"]=d),a.manifest.requiresAccessToken&&c&&(h.Authorization=`Bearer ${c}`);const p=Object.keys(h).length>0?h:void 0,v=yield Promise.all(a.manifest.output.map((e=>s(this,void 0,void 0,(function*(){const i=yield l(new Request(e.url,{method:"GET",headers:p}));if(!i.ok)throw new t({message:`Failed to download bulk output (${e.type}): HTTP ${i.status}`,code:i.status});const s=yield i.text();return Object.assign(Object.assign({},e),{resources:it(s,e.url)})})))));return{manifest:a.manifest,output:v}}))}function nt(t,e,i){return s(this,void 0,void 0,(function*(){return{resourceType:"Bundle",type:"collection",entry:(yield st.call(this,t,e,i)).output.flatMap((t=>t.resources)).map((t=>({resource:t}))),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 rt(t,e){return s(this,void 0,void 0,(function*(){yield this.fhirRequest(`/async-job/${t}`,"DELETE")({},e)}))}function ot(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,versionId:i,count:s,offset:n},r){const o=null==r?void 0:r.mode;return F(o)?i?yield this.startAsyncJob(`/${t}/${e}/_history/${i}`,"GET",{},o,r):yield this.startAsyncJob(`/${t}/${e}/_history`,"GET",{},o,r):i?this.fhirRequest(`/${t}/${e}/_history/${i}`,"GET")({},r):s?this.fhirRequest(`/${t}/${e}/_history?_total=accurate&_count=${s}\n ${n?`&_offset=${n}`:""}`,"GET")({},r):this.fhirRequest(`/${t}/${e}/_history?_total=accurate`,"GET")({},r)}))}function ut(t){const e=t.split("?")[0].split("/").filter(Boolean);return e.length<=1||e[1].startsWith("_")}function at(t){return t.split("?")[0].endsWith("/_search")}function ct(t,e){var i;const{method:s}=t;let n=t.url;if((("GET"===s||"HEAD"===s)&&ut(n)||"POST"===s&&at(n))&&(e.workspaceTag&&(n+=(n.includes("?")?"&":"?")+`_tag=${C(e.workspaceTag)}`),null===(i=e.ignoreTags)||void 0===i?void 0:i.length))for(const o of e.ignoreTags)n+=(n.includes("?")?"&":"?")+`_tag:not=${C(o)}`;const r={request:{method:s,url:n}};if(n.split("?").length>1){const[t,e]=n.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),r.request.url=`${t}?${s.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return r;if("PUT"===s){const i=D(e,t.resource);return{request:Object.assign(Object.assign({},r.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=W(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:M(JSON.stringify(t))})}return{request:Object.assign(Object.assign({},r.request),{ifMatch:t.ifMatch}),resource:i}}const i=W(e,t.operations),s=M(JSON.stringify(i));return Object.assign(Object.assign({},r),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:s}})}if("POST"===s&&at(n))return r;if("POST"===s&&"resource"in t){const i=D(e,t.resource),{fullUrl:s,ifNoneExist:n}=t;return{request:Object.assign(Object.assign({},r.request),{ifNoneExist:void 0!==n?B(n):void 0}),resource:i,fullUrl:s}}throw new Error("Unrecognized method")}function dt(t,e){return s(this,void 0,void 0,(function*(){var s;const n={resourceType:"Bundle",type:"batch",entry:t.requests.map((t=>ct(t,this.config)))},r=null==e?void 0:e.mode;if(F(r))return yield this.startAsyncJob("/","POST",n,r,e);const o=yield this.fhirRequest("/","POST")(n,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 n=t.requests[s];if(!n||!(null==e?void 0:e.resource))return e;if(("GET"===n.method||"HEAD"===n.method)&&!ut(n.url))try{L(this.config,e.resource)}catch(r){if(!(r instanceof i))throw r;return{request:e.request,response:{status:"404",outcome:r.cause}}}return e})):u,c=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,n;return(null===(i=null===(e=t.response)||void 0===e?void 0:e.status)||void 0===i?void 0:i.startsWith("4"))||(null===(n=null===(s=t.response)||void 0===s?void 0:s.status)||void 0===n?void 0:n.startsWith("5"))})).map((t=>{var e;return null===(e=t.response)||void 0===e?void 0:e.outcome})).filter((t=>void 0!==t))}});return c}))}function lt(t,e){return s(this,void 0,void 0,(function*(){var i,s;const n={resourceType:"Bundle",type:"transaction",entry:t.requests.map((t=>ct(t,this.config)))},r=null==e?void 0:e.mode;if(F(r))return yield this.startAsyncJob("/","POST",n,r,e);const o=yield this.fhirRequest("/","POST")(n,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||ut(s.url)||L(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 ht(t,e){return s(this,arguments,void 0,(function*({id:t},e){return this.fhirRequest(`/Patient/${t}/$generate-friendly-patient-id`,"POST")({},e)}))}function pt(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 vt(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 ft,mt,gt,bt,yt,qt,wt,jt,Ot,Tt,kt,St,At,Et,xt,It,Ut,Pt,$t,zt,Rt,Nt,_t,Mt,Ct,Jt,Dt,Wt,Lt,Bt,Ft,Gt,Ht;class Vt extends p{constructor(t){super(t),ft.add(this),this.search=G,this.searchAndGetAllPages=H,this.create=V,this.get=X,this.update=Z,this.patch=K,this.delete=Q,this.getAsyncJob=tt,this.waitForAsyncJob=et,this.waitForAsyncBulkOutput=st,this.waitForAsyncBulkBundle=nt,this.cancelAsyncJob=rt,this.history=ot,this.batch=dt,this.transaction=lt,this.generateFriendlyPatientId=ht,this.formatAddress=pt,this.formatHumanName=vt}}ft=new WeakSet;class Xt extends p{constructor(t){super(t),mt.add(this)}routeList(t){return this.request("/route","get",n(this,mt,"m",gt).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",n(this,mt,"m",gt).bind(this))(t,e)}routeGet(t,e){return this.request("/route/{routeGuid}","get",n(this,mt,"m",gt).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",n(this,mt,"m",gt).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",n(this,mt,"m",gt).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",n(this,mt,"m",gt).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",n(this,mt,"m",gt).bind(this))(t,e)}}mt=new WeakSet,gt=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 Zt extends p{constructor(t){super(t),bt.add(this)}list(t){return this.request("/m2m","get",n(this,bt,"m",yt).bind(this))(t)}create(t,e){return this.request("/m2m","post",n(this,bt,"m",yt).bind(this))(t,e)}me(t){return this.request("/m2m/me","get",n(this,bt,"m",yt).bind(this))(t)}get(t,e){return this.request("/m2m/{id}","get",n(this,bt,"m",yt).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",n(this,bt,"m",yt).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",n(this,bt,"m",yt).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",n(this,bt,"m",yt).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",n(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 Kt extends p{constructor(t){super(t),qt.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",n(this,qt,"m",wt).bind(this))(t)}}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 Qt extends p{constructor(t){super(t),jt.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",n(this,jt,"m",Ot).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",n(this,jt,"m",Ot).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",n(this,jt,"m",Ot).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",n(this,jt,"m",Ot).bind(this))(t,e)}}jt=new WeakSet,Ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Yt extends p{constructor(t){super(t),Tt.add(this)}get(t){return this.request("/project","get",n(this,Tt,"m",kt).bind(this))(t)}update(t,e){return this.request("/project","patch",n(this,Tt,"m",kt).bind(this))(t,e)}}function te(){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 ee({id:t}){return`${te.call(this)}/payer/${t}`}function ie(e,i){return s(this,arguments,void 0,(function*({url:e},i){if(!e.startsWith(ee.call(this,{id:""})))throw new t({code:400,message:"Invalid payer URL."});const s=new URL(e).pathname.split("/").filter(Boolean),n=s[s.length-1];return this.request("/payer/{id}","get",te.bind(this))({id:n},i)}))}Tt=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 se extends p{constructor(t){super(t),St.add(this),this.constructPayerUrl=ee,this.getPayerByUrl=ie}eligibilityCheck(t,e){return this.request("/eligibility-check","post",n(this,St,"m",At).bind(this))(t,e)}submitClaim(t,e){return this.request("/claim/{claimId}/submit","post",n(this,St,"m",At).bind(this))(t,e)}setClaimStatus(t,e){return this.request("/claim/{claimId}/status","post",n(this,St,"m",At).bind(this))(t,e)}listPayers(t,e){return this.request("/payer","get",n(this,St,"m",At).bind(this))(t,e)}getPayer(t,e){return this.request("/payer/{id}","get",n(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.rcmApiUrl)&&void 0!==e?e:"https://rcm-api.zapehr.com/v1"};class ne extends p{constructor(t){super(t),Et.add(this)}list(t){return this.request("/iam/role","get",n(this,Et,"m",xt).bind(this))(t)}create(t,e){return this.request("/iam/role","post",n(this,Et,"m",xt).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",n(this,Et,"m",xt).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",n(this,Et,"m",xt).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",n(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.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class re extends p{constructor(t){super(t),It.add(this)}list(t){return this.request("/secret","get",n(this,It,"m",Ut).bind(this))(t)}set(t,e){return this.request("/secret","post",n(this,It,"m",Ut).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",n(this,It,"m",Ut).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",n(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 oe extends p{constructor(t){super(t),Pt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",n(this,Pt,"m",$t).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",n(this,Pt,"m",$t).bind(this))(t,e)}}Pt=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 ue extends p{constructor(t){super(t),zt.add(this)}searchCpt(t,e){return this.request("/cpt/search","get",n(this,zt,"m",Rt).bind(this))(t,e)}searchHcpcs(t,e){return this.request("/hcpcs/search","get",n(this,zt,"m",Rt).bind(this))(t,e)}}zt=new WeakSet,Rt=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 ae extends p{constructor(t){super(t),Nt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",n(this,Nt,"m",_t).bind(this))(t,e)}}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 ce extends p{constructor(t){super(t),Mt.add(this)}me(t){return this.request("/user/me","get",n(this,Mt,"m",Ct).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",n(this,Mt,"m",Ct).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",n(this,Mt,"m",Ct).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",n(this,Mt,"m",Ct).bind(this))(t,e)}resetMfa(t,e){return this.request("/user/{id}/reset-mfa","post",n(this,Mt,"m",Ct).bind(this))(t,e)}resetPasswordLink(t,e){return this.request("/user/{id}/reset-password-link","post",n(this,Mt,"m",Ct).bind(this))(t,e)}changePassword(t,e){return this.request("/user/{id}/change-password","post",n(this,Mt,"m",Ct).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",n(this,Mt,"m",Ct).bind(this))(t,e)}list(t){return this.request("/user","get",n(this,Mt,"m",Ct).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",n(this,Mt,"m",Ct).bind(this))(t,e)}}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 de extends p{constructor(t){super(t),Jt.add(this)}get(t){return this.request("/version","get",n(this,Jt,"m",Dt).bind(this))(t)}}function le(){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 he(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",le.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function pe(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",le.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 ve(e){return s(this,void 0,void 0,(function*(){var i,s;let n,r;const o=new URL(e.url);if("z3:"===o.protocol){const t=o.pathname.split("/").slice(1);n=o.hostname,r=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);n=t[0],r=t.slice(1).join("/")}}const u={action:"upload",bucketName:n,"objectPath+":r};return this.request("/z3/{bucketName}/{objectPath+}","post",le.bind(this))(u)}))}Jt=new WeakSet,Dt=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 fe extends p{constructor(t){super(t),Wt.add(this),this.uploadFile=he,this.downloadFile=pe,this.getPresignedUrlForZ3Url=ve}listBuckets(t){return this.request("/z3","get",n(this,Wt,"m",Lt).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",n(this,Wt,"m",Lt).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",n(this,Wt,"m",Lt).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",n(this,Wt,"m",Lt).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",n(this,Wt,"m",Lt).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",n(this,Wt,"m",Lt).bind(this))(t,e)}}function me(){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 ge(e){return s(this,arguments,void 0,(function*({id:e,file:i,filename:s}){const n=yield this.request("/zambda/{id}/presigned-url","post",me.bind(this))({id:e,action:"upload",filename:s}),r=yield fetch(n.signedUrl,{method:"PUT",body:i});if(!r.ok)throw new t({message:"Failed to upload file",code:r.status,cause:r.statusText})}))}function be(e){return s(this,arguments,void 0,(function*({id:e}){const i=yield this.request("/zambda/{id}/presigned-url","post",me.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()}))}Wt=new WeakSet,Lt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class ye extends p{constructor(t){super(t),Bt.add(this),this.uploadFile=ge,this.downloadFile=be}list(t){return this.request("/zambda","get",n(this,Bt,"m",Ft).bind(this))(t)}create(t,e){return this.request("/zambda","post",n(this,Bt,"m",Ft).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",n(this,Bt,"m",Ft).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",n(this,Bt,"m",Ft).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",n(this,Bt,"m",Ft).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",n(this,Bt,"m",Ft).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",n(this,Bt,"m",Ft).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",n(this,Bt,"m",Ft).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/zambda/{id}/presigned-url","post",n(this,Bt,"m",Ft).bind(this))(t,e)}}Bt=new WeakSet,Ft=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 qe extends p{constructor(t){super(t),Gt.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",n(this,Gt,"m",Ht).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",n(this,Gt,"m",Ht).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",n(this,Gt,"m",Ht).bind(this))(t,e)}}Gt=new WeakSet,Ht=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 we=class{constructor(e){var i,s,n,r,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=(r=this.config).services)&&void 0!==i||(r.services={}),null!==(s=(o=this.config.services).projectApiUrl)&&void 0!==s||(o.projectApiUrl=e.projectApiUrl),null!==(n=(u=this.config.services).fhirApiUrl)&&void 0!==n||(u.fhirApiUrl=e.fhirApiUrl),this.application=new q(e),this.developer=new z(e),this.m2m=new Zt(e),this.messaging=new Kt(e),this.conversation=new $(e),this.transactionalSMS=new ae(e),this.paymentMethod=new Qt(e),this.charge=new w(e),this.project=new Yt(e),this.role=new ne(e),this.secret=new re(e),this.telemed=new oe(e),this.user=new ce(e),this.version=new de(e),this.z3=new fe(e),this.fax=new N(e),this.lab=new Xt(e),this.erx=new R(e),this.terminology=new ue(e),this.zambda=new ye(e),this.zambdaLogStream=new qe(e),this.rcm=new se(e),this.fhir=new Vt(e)}};class je extends we{}je.OystehrFHIRError=i,je.OystehrSdkError=t,exports.default=je;
|
|
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(n,r){function o(t){try{a(s.next(t))}catch(e){r(e)}}function u(t){try{a(s.throw(t))}catch(e){r(e)}}function a(t){var e;t.done?n(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 n(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 r=/^(?:[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 Oe=0;Oe<256;++Oe)o.push((Oe+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: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 d({level:this.config.logLevel})}request(e,i,n){return(r,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config,u=()=>this.logger;try{return yield v(n,s,u,e,i)(r,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,n){return(r,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 v(t,i,s,e,n)(r,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,n,r,o){return s(this,void 0,void 0,(function*(){const s="async-bulk"===r?"bulk":"bundle",u="async-bulk"===r?this.appendBulkOutputFormat(e):e,a=yield this.fhirRequest(u,i)(n,Object.assign(Object.assign({},o),{rawResponse:!0}),r);if(202!==a.status)throw new t({message:`Expected start async job to return 202 Accepted, received ${a.status}`,code:a.status});const c=this.readHeader(a.headers,"content-location");if(!c)throw new t({message:"Start Async job response missing Content-Location header",code:500});const d=this.parseAsyncJobId(c);if(!d)throw new t({message:`Could not parse async job id from Content-Location: ${c}`,code:500});return{jobId:d,contentLocation:c,mode:s}}))}fetchAsyncJobStatus(t,e){return s(this,void 0,void 0,(function*(){var i,s,n;const r=yield this.fhirRequest(`/async-job/${t}`,"GET")({},Object.assign(Object.assign({},e),{rawResponse:!0}));if(202===r.status)return{status:202,xProgress:this.readHeader(r.headers,"x-progress"),retryAfter:this.readHeader(r.headers,"retry-after")};if(410===r.status)return{status:410};if(404===r.status)return{status:404};if(200===r.status){if(this.isBulkManifest(r.body))return{status:200,mode:"bulk",manifest:r.body};const t=r.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===(n=null==e?void 0:e.response)||void 0===n?void 0:n.outcome}}return{status:200,body:r.body}}return{status:r.status,body:r.body}}))}readHeader(t,e){const i=t[e];if(null!=i)return i;const s=e.toLowerCase(),n=Object.keys(t).find((t=>t.toLowerCase()===s));return n?t[n]: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(e,i,n,d,p){return(v,m,g)=>s(this,void 0,void 0,(function*(){var b,y,q,w,j,O,T,k,S,A,E,x,I,U;let[P,$]=function(t,e){var i;const s=!!t&&!e&&!Array.isArray(t)&&function(t){var e,i;return"accessToken"in t||"projectId"in t&&"string"==typeof(i=t.projectId)&&r.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/"')||"ifNoneExist"in t||"mode"in t||"rawResponse"in t}(t)&&!function(t){return"string"==typeof t.resourceType&&t.resourceType.length>0}(t);return[s?{}:null!==(i=t)&&void 0!==i?i:{},s?t:e]}(v,m);null!=$||($={}),null!==(b=$.requestId)&&void 0!==b||($.requestId=function(t){if(c.randomUUID&&!t)return c.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 z=i(),R=n(),N=p.toLowerCase();R.debug("Beginning fetch",{method:N,path:d,requestId:null==$?void 0:$.requestId});const _=null!==(y=z.fetch)&&void 0!==y?y:fetch,M=null!==(q=null==$?void 0:$.accessToken)&&void 0!==q?q:z.accessToken,C=null!==(w=null==$?void 0:$.projectId)&&void 0!==w?w:z.projectId;let J=d,D=P;if(!Array.isArray(P)){const[e,i]=function(e,i){const s=Object.assign({},i),n=e.replace(/\{([^}]+)\}/g,((e,n)=>{if(delete s[n],n.match(/^.*\+$/))return i[n]+"";if(!i[n]||""===i[n])throw new t({message:`Required path parameter is an empty string: ${n}`,code:400});return i[n]?encodeURIComponent(i[n]+""):""})),r=Object.keys(s);return[n,r.length?r.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{}]}(d,P);J=e,D=i}R.debug("Substituted parameters in path",{method:N,path:d,requestId:null==$?void 0:$.requestId}),J=J.replace(/^\//,"");const W=e(),L=W.endsWith("/")?W:W+"/",B=new URL(J,L);let F;if(Array.isArray(D))F=JSON.stringify(D);else if(Object.keys(D).length)if("get"===N)f(D,B.searchParams);else if("application/x-www-form-urlencoded"===(null==$?void 0:$.contentType)){const t=new URLSearchParams;f(D,t),F=t.toString()}else F=JSON.stringify(D);else"application/x-www-form-urlencoded"!==(null==$?void 0:$.contentType)&&"post"===N&&(F="{}");R.debug("Prepared request body",{method:N,path:d,requestId:null==$?void 0:$.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==$?void 0:$.contentType)&&void 0!==j?j:"application/json"},G?{Prefer:G}:{},M?{Authorization:`Bearer ${M}`}:{},(null==$?void 0:$.ifMatch)?{"If-Match":$.ifMatch}:{},(null==$?void 0:$.ifNoneExist)?{"If-None-Exist":$.ifNoneExist}:{},{"x-oystehr-request-id":null==$?void 0:$.requestId}),V={retries:null!==(T=null===(O=z.retry)||void 0===O?void 0:O.retries)&&void 0!==T?T:3,jitter:null!==(S=null===(k=z.retry)||void 0===k?void 0:k.jitter)&&void 0!==S?S:20,delay:null!==(E=null===(A=z.retry)||void 0===A?void 0:A.delay)&&void 0!==E?E:100,onRetry:null===(x=z.retry)||void 0===x?void 0:x.onRetry,retryOn:[...null!==(U=null===(I=z.retry)||void 0===I?void 0:I.retryOn)&&void 0!==U?U:[],...l]};return V.retryOn.push(...l),function(t,e){return s(this,void 0,void 0,(function*(){var i,s;let n;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(r){let t=!1;if("response"in r){const i=r;t=e.retryOn.includes(i.code),n={message:r.message,code:r.code}}else if(n=r,"code"in r&&"string"==typeof r.code){const e=r;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 n}))}((()=>s(this,void 0,void 0,(function*(){var t,e,i,s,n,r,o,u;R.info("Request start",{method:N,url:B,requestId:null==$?void 0:$.requestId});const a=Date.now(),c=yield _(new Request(B,{method:N.toUpperCase(),body:F,headers:H}));R.info("Request end",{method:N,url:B,duration:Date.now()-a,requestId:null==$?void 0:$.requestId});const d=c.body?yield c.text():null;let l;const h=c.headers.get("content-type");try{d&&((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:B,requestId:null==$?void 0:$.requestId}),l=JSON.parse(d),R.timeEnd("Deserialized JSON response",{method:N,url:B,requestId:null==$?void 0:$.requestId})):d&&((null==h?void 0:h.includes("application/xml"))||(null==h?void 0:h.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:B,requestId:null==$?void 0:$.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>/),n=s?s[1]:null;return null===i||null===n?null:{status:i,output:n}}catch(e){return null}}(d),R.timeEnd("Deserialized XML response",{method:N,url:B,requestId:null==$?void 0:$.requestId})):l=null}catch(p){l=null}if(R.debug("Deserialized response",{method:N,url:B,requestId:null==$?void 0:$.requestId}),null==$?void 0:$.rawResponse){const t={};return c.headers.forEach(((e,i)=>{t[i]=e})),{status:c.status,headers:t,body:null!=l?l:d}}if(!c.ok||c.status>=400)throw{message:null!==(n=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:d)&&void 0!==n?n:c.statusText,code:null!==(u=null!==(o=null===(r=null==l?void 0:l.output)||void 0===r?void 0:r.code)&&void 0!==o?o:null==l?void 0:l.code)&&void 0!==u?u:c.status,response:c};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 m,g,b,y;class q extends p{constructor(t){super(t),m.add(this)}list(t){return this.request("/application","get",n(this,m,"m",g).bind(this))(t)}create(t,e){return this.request("/application","post",n(this,m,"m",g).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",n(this,m,"m",g).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",n(this,m,"m",g).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",n(this,m,"m",g).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",n(this,m,"m",g).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",n(this,m,"m",g).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",n(this,m,"m",g).bind(this))(t,e)}}m=new WeakSet,g=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class w extends p{constructor(t){super(t),b.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",n(this,b,"m",y).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",n(this,b,"m",y).bind(this))(t,e)}}b=new WeakSet,y=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};const j="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",O="addressString";function T(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 n=t.extension.find((t=>t.url===j));return(null==n?void 0:n.extension)?null===(s=null===(i=n.extension)||void 0===i?void 0:i.find((t=>t.url===O)))||void 0===s?void 0:s.valueString:void 0}var k,S,A,E,x,I,U,P;class $ extends p{constructor(t){super(t),k.add(this),this.ENCOUNTER_VS_EXTENSION_URL=j,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=O,this.getConversationIdFromEncounter=T}create(t,e){return this.request("/messaging/conversation","post",n(this,k,"m",S).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",n(this,k,"m",S).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",n(this,k,"m",S).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",n(this,k,"m",S).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",n(this,k,"m",S).bind(this))(t,e)}}k=new WeakSet,S=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 z extends p{constructor(t){super(t),A.add(this)}get(t,e){return this.request("/developer/{id}","get",n(this,A,"m",E).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",n(this,A,"m",E).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",n(this,A,"m",E).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",n(this,A,"m",E).bind(this))(t,e)}list(t){return this.request("/developer","get",n(this,A,"m",E).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",n(this,A,"m",E).bind(this))(t,e)}}A=new WeakSet,E=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),x.add(this)}searchAllergens(t,e){return this.request("/allergen","get",n(this,x,"m",I).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",n(this,x,"m",I).bind(this))(t,e)}getMedication(t,e){return this.request("/medication/details","get",n(this,x,"m",I).bind(this))(t,e)}getConfiguration(t){return this.request("/config","get",n(this,x,"m",I).bind(this))(t)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",n(this,x,"m",I).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",n(this,x,"m",I).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",n(this,x,"m",I).bind(this))(t,e)}getMedicationHistory(t,e){return this.request("/patient/{patientId}/medication-history","get",n(this,x,"m",I).bind(this))(t,e)}addPatientPharmacy(t,e){return this.request("/patient/{patientId}/pharmacies","post",n(this,x,"m",I).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",n(this,x,"m",I).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",n(this,x,"m",I).bind(this))(t,e)}searchPharmacies(t,e){return this.request("/pharmacy","get",n(this,x,"m",I).bind(this))(t,e)}getPharmacy(t,e){return this.request("/pharmacy/{pharmacyId}","get",n(this,x,"m",I).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",n(this,x,"m",I).bind(this))(t,e)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",n(this,x,"m",I).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",n(this,x,"m",I).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",n(this,x,"m",I).bind(this))(t,e)}}x=new WeakSet,I=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 N extends p{constructor(t){super(t),U.add(this)}offboard(t){return this.request("/offboard","post",n(this,U,"m",P).bind(this))(t)}onboard(t){return this.request("/onboard","post",n(this,U,"m",P).bind(this))(t)}getConfiguration(t){return this.request("/config","get",n(this,U,"m",P).bind(this))(t)}send(t,e){return this.request("/send","post",n(this,U,"m",P).bind(this))(t,e)}}U=new WeakSet,P=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 _=65535;function M(t){const e=(new globalThis.TextEncoder).encode(t);let i="";for(let s=0;s<e.length;s+=_){const t=e.subarray(s,s+_);i+=globalThis.btoa(String.fromCodePoint.apply(void 0,t))}return i}function C(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 J(t,e){var i,s,n,r;return(null!==(i=t.system)&&void 0!==i?i:"")===(null!==(s=e.system)&&void 0!==s?s:"")&&(null!==(n=t.code)&&void 0!==n?n:"")===(null!==(r=e.code)&&void 0!==r?r:"")}function D(e,i){var s,n,r,o,u,a,c;const d=i;if(null===(s=e.ignoreTags)||void 0===s?void 0:s.length){const s=null!==(r=null===(n=d.meta)||void 0===n?void 0:n.tag)&&void 0!==r?r:[];for(const i of e.ignoreTags)if(s.some((t=>J(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!==(c=null===(a=d.meta)||void 0===a?void 0:a.tag)&&void 0!==c?c:[];if(!s.some((e=>J(e,t))))return Object.assign(Object.assign({},i),{meta:Object.assign(Object.assign({},d.meta),{tag:[...s,t]})})}return i}function W(e,i){var s,n,r;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(J(s,i))throw new t({message:`Patch operation contains an ignored tag (system: "${null!==(n=i.system)&&void 0!==n?n:""}", code: "${null!==(r=i.code)&&void 0!==r?r:""}") 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=>J(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 n=null!=i.value&&"object"==typeof i.value?i.value:{},r=null!==(s=n.tag)&&void 0!==s?s:[];return r.some((e=>J(e,t)))?e.push(i):e.push(Object.assign(Object.assign({},i),{value:Object.assign(Object.assign({},n),{tag:[...r,t]})})),e}return e.push(i),e}),[])}return i}function L(t,e){var s,n,r;const o=null!==(n=null===(s=e.meta)||void 0===s?void 0:s.tag)&&void 0!==n?n:[];if(t.workspaceTag){const e=t.workspaceTag;if(!o.some((t=>J(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===(r=t.ignoreTags)||void 0===r?void 0:r.length)for(const u of t.ignoreTags)if(o.some((t=>J(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){if("string"==typeof t)return t;const e=new URLSearchParams;for(const i of t)e.append(i.name,String(i.value));return e.toString()}function F(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:C(t.workspaceTag)});else if(null===(i=t.ignoreTags)||void 0===i?void 0:i.length)for(const n of t.ignoreTags)s.push({name:"_tag:not",value:C(n)});return s}(this.config,t.params);let n;s.length&&(n=s.reduce(((t,e)=>(t[e.name]||(t[e.name]=[]),t[e.name].push(e.value),t)),{}));const r=null==e?void 0:e.mode;if(F(r))return yield this.startAsyncJob(`/${i}/_search`,"POST",null!=n?n:{},r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));const o=yield this.fhirRequest(`/${i}/_search`,"POST")(n,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*(){var i,s,n,r,o;const{pageSize:u}=t,a=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i}(t,["pageSize"]);let c=a;if(u){const t=null!==(s=(null!==(i=a.params)&&void 0!==i?i:[]).filter((t=>"_count"!==t.name)))&&void 0!==s?s:[];c=Object.assign(Object.assign({},a),{params:[...t,{name:"_count",value:u}]})}const d=[],l=G;let h=yield l.call(this,c,e);const p=Object.assign(Object.assign({},h),{link:null===(n=h.link)||void 0===n?void 0:n.filter((t=>"next"!==t.relation))});for(;;){const t=h.entry;t&&d.push(...t);const i=null===(o=null===(r=h.link)||void 0===r?void 0:r.find((t=>"next"===t.relation)))||void 0===o?void 0:o.url;if(!i)break;h=yield this.fhirRequest(i,"GET")({},e)}return Object.assign(Object.assign({},p),{entry:d.length?d:void 0,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 V(t,e){return s(this,void 0,void 0,(function*(){const i=D(this.config,t),{resourceType:s}=i,n=null==e?void 0:e.mode,r=Object.assign(Object.assign({},e),{ifNoneExist:void 0!==(null==e?void 0:e.ifNoneExist)?B(e.ifNoneExist):void 0});return F(n)?yield this.startAsyncJob(`/${s}`,"POST",i,n,r):yield this.fhirRequest(`/${s}`,"POST")(i,r)}))}function X(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){const s=null==i?void 0:i.mode;if(F(s))return yield this.startAsyncJob(`/${t}/${e}`,"GET",{},s,i);const n=yield this.fhirRequest(`/${t}/${e}`,"GET")({},i);return L(this.config,n),n}))}function Z(t,e){return s(this,void 0,void 0,(function*(){const i=D(this.config,t),{id:s,resourceType:n}=i,r=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 F(r)?yield this.startAsyncJob(`/${n}/${s}`,"PUT",i,r,o):yield this.fhirRequest(`/${n}/${s}`,"PUT")(i,o)}))}function K(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,operations:i},s){const n=W(this.config,i),r=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 F(r)?yield this.startAsyncJob(`/${t}/${e}`,"PATCH",n,r,Object.assign(Object.assign({},o),{contentType:"application/json-patch+json"})):this.fhirRequest(`/${t}/${e}`,"PATCH")(n,Object.assign(Object.assign({},o),{contentType:"application/json-patch+json"}))}))}function Q(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){const s=null==i?void 0:i.mode;return F(s)?yield this.startAsyncJob(`/${t}/${e}`,"DELETE",{},s,i):yield this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function Y(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 tt(t,e){return s(this,void 0,void 0,(function*(){return yield this.fetchAsyncJobStatus(t,e)}))}function et(e,i,n){return s(this,void 0,void 0,(function*(){var s,r;const o=null!==(s=null==i?void 0:i.pollIntervalMs)&&void 0!==s?s:5e3,u=null!==(r=null==i?void 0:i.timeoutMs)&&void 0!==r?r:9e5,a=Math.max(1,Math.ceil(u/o));for(let t=0;t<a;t++){const i=yield this.fetchAsyncJobStatus(e,n);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,Y(t,o))))}}throw new t({message:`Async job ${e} did not complete within ${u} ms`,code:408})}))}function it(e,i){const s=[],n=e.split("\n");for(let o=0;o<n.length;o++){const e=n[o].trim();if(0!==e.length)try{s.push(JSON.parse(e))}catch(r){throw new t({message:`Failed to parse NDJSON line ${o+1} from ${i}`,code:500,cause:r})}}return s}function st(e,i,n){return s(this,void 0,void 0,(function*(){var r,o,u;const a=yield et.call(this,e,i,n);if(404===a.status)throw new t({message:`Async job ${e} not found`,code:404});if(410===a.status)throw new t({message:`Async job ${e} expired`,code:410});if(200!==a.status||!("mode"in a)||"bulk"!==a.mode)throw new t({message:`Async job ${e} did not complete in bulk mode`,code:a.status});const c=null!==(r=null==n?void 0:n.accessToken)&&void 0!==r?r:this.config.accessToken,d=null!==(o=null==n?void 0:n.projectId)&&void 0!==o?o:this.config.projectId;if(a.manifest.requiresAccessToken&&!c)throw new t({message:`Bulk output for async job ${e} requires an access token`,code:401});const l=null!==(u=this.config.fetch)&&void 0!==u?u:fetch,h={};d&&(h["x-zapehr-project-id"]=d,h["x-oystehr-project-id"]=d),a.manifest.requiresAccessToken&&c&&(h.Authorization=`Bearer ${c}`);const p=Object.keys(h).length>0?h:void 0,v=yield Promise.all(a.manifest.output.map((e=>s(this,void 0,void 0,(function*(){const i=yield l(new Request(e.url,{method:"GET",headers:p}));if(!i.ok)throw new t({message:`Failed to download bulk output (${e.type}): HTTP ${i.status}`,code:i.status});const s=yield i.text();return Object.assign(Object.assign({},e),{resources:it(s,e.url)})})))));return{manifest:a.manifest,output:v}}))}function nt(t,e,i){return s(this,void 0,void 0,(function*(){return{resourceType:"Bundle",type:"collection",entry:(yield st.call(this,t,e,i)).output.flatMap((t=>t.resources)).map((t=>({resource:t}))),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 rt(t,e){return s(this,void 0,void 0,(function*(){yield this.fhirRequest(`/async-job/${t}`,"DELETE")({},e)}))}function ot(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,versionId:i,count:s,offset:n},r){const o=null==r?void 0:r.mode;return F(o)?i?yield this.startAsyncJob(`/${t}/${e}/_history/${i}`,"GET",{},o,r):yield this.startAsyncJob(`/${t}/${e}/_history`,"GET",{},o,r):i?this.fhirRequest(`/${t}/${e}/_history/${i}`,"GET")({},r):s?this.fhirRequest(`/${t}/${e}/_history?_total=accurate&_count=${s}\n ${n?`&_offset=${n}`:""}`,"GET")({},r):this.fhirRequest(`/${t}/${e}/_history?_total=accurate`,"GET")({},r)}))}function ut(t){const e=t.split("?")[0].split("/").filter(Boolean);return e.length<=1||e[1].startsWith("_")}function at(t){return t.split("?")[0].endsWith("/_search")}function ct(t,e){var i;const{method:s}=t;let n=t.url;if((("GET"===s||"HEAD"===s)&&ut(n)||"POST"===s&&at(n))&&(e.workspaceTag&&(n+=(n.includes("?")?"&":"?")+`_tag=${C(e.workspaceTag)}`),null===(i=e.ignoreTags)||void 0===i?void 0:i.length))for(const o of e.ignoreTags)n+=(n.includes("?")?"&":"?")+`_tag:not=${C(o)}`;const r={request:{method:s,url:n}};if(n.split("?").length>1){const[t,e]=n.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),r.request.url=`${t}?${s.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return r;if("PUT"===s){const i=D(e,t.resource);return{request:Object.assign(Object.assign({},r.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=W(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:M(JSON.stringify(t))})}return{request:Object.assign(Object.assign({},r.request),{ifMatch:t.ifMatch}),resource:i}}const i=W(e,t.operations),s=M(JSON.stringify(i));return Object.assign(Object.assign({},r),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:s}})}if("POST"===s&&at(n))return r;if("POST"===s&&"resource"in t){const i=D(e,t.resource),{fullUrl:s,ifNoneExist:n}=t;return{request:Object.assign(Object.assign({},r.request),{ifNoneExist:void 0!==n?B(n):void 0}),resource:i,fullUrl:s}}throw new Error("Unrecognized method")}function dt(t,e){return s(this,void 0,void 0,(function*(){var s;const n={resourceType:"Bundle",type:"batch",entry:t.requests.map((t=>ct(t,this.config)))},r=null==e?void 0:e.mode;if(F(r))return yield this.startAsyncJob("/","POST",n,r,e);const o=yield this.fhirRequest("/","POST")(n,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 n=t.requests[s];if(!n||!(null==e?void 0:e.resource))return e;if(("GET"===n.method||"HEAD"===n.method)&&!ut(n.url))try{L(this.config,e.resource)}catch(r){if(!(r instanceof i))throw r;return{request:e.request,response:{status:"404",outcome:r.cause}}}return e})):u,c=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,n;return(null===(i=null===(e=t.response)||void 0===e?void 0:e.status)||void 0===i?void 0:i.startsWith("4"))||(null===(n=null===(s=t.response)||void 0===s?void 0:s.status)||void 0===n?void 0:n.startsWith("5"))})).map((t=>{var e;return null===(e=t.response)||void 0===e?void 0:e.outcome})).filter((t=>void 0!==t))}});return c}))}function lt(t,e){return s(this,void 0,void 0,(function*(){var i,s;const n={resourceType:"Bundle",type:"transaction",entry:t.requests.map((t=>ct(t,this.config)))},r=null==e?void 0:e.mode;if(F(r))return yield this.startAsyncJob("/","POST",n,r,e);const o=yield this.fhirRequest("/","POST")(n,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||ut(s.url)||L(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 ht(t,e){return s(this,arguments,void 0,(function*({id:t},e){return this.fhirRequest(`/Patient/${t}/$generate-friendly-patient-id`,"POST")({},e)}))}function pt(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 vt(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 ft,mt,gt,bt,yt,qt,wt,jt,Ot,Tt,kt,St,At,Et,xt,It,Ut,Pt,$t,zt,Rt,Nt,_t,Mt,Ct,Jt,Dt,Wt,Lt,Bt,Ft,Gt,Ht;class Vt extends p{constructor(t){super(t),ft.add(this),this.search=G,this.searchAndGetAllPages=H,this.create=V,this.get=X,this.update=Z,this.patch=K,this.delete=Q,this.getAsyncJob=tt,this.waitForAsyncJob=et,this.waitForAsyncBulkOutput=st,this.waitForAsyncBulkBundle=nt,this.cancelAsyncJob=rt,this.history=ot,this.batch=dt,this.transaction=lt,this.generateFriendlyPatientId=ht,this.formatAddress=pt,this.formatHumanName=vt}}ft=new WeakSet;class Xt extends p{constructor(t){super(t),mt.add(this)}routeList(t){return this.request("/route","get",n(this,mt,"m",gt).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",n(this,mt,"m",gt).bind(this))(t,e)}routeGet(t,e){return this.request("/route/{routeGuid}","get",n(this,mt,"m",gt).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",n(this,mt,"m",gt).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",n(this,mt,"m",gt).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",n(this,mt,"m",gt).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",n(this,mt,"m",gt).bind(this))(t,e)}}mt=new WeakSet,gt=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 Zt extends p{constructor(t){super(t),bt.add(this)}list(t){return this.request("/m2m","get",n(this,bt,"m",yt).bind(this))(t)}create(t,e){return this.request("/m2m","post",n(this,bt,"m",yt).bind(this))(t,e)}me(t){return this.request("/m2m/me","get",n(this,bt,"m",yt).bind(this))(t)}get(t,e){return this.request("/m2m/{id}","get",n(this,bt,"m",yt).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",n(this,bt,"m",yt).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",n(this,bt,"m",yt).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",n(this,bt,"m",yt).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",n(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 Kt extends p{constructor(t){super(t),qt.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",n(this,qt,"m",wt).bind(this))(t)}}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 Qt extends p{constructor(t){super(t),jt.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",n(this,jt,"m",Ot).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",n(this,jt,"m",Ot).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",n(this,jt,"m",Ot).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",n(this,jt,"m",Ot).bind(this))(t,e)}}jt=new WeakSet,Ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Yt extends p{constructor(t){super(t),Tt.add(this)}get(t){return this.request("/project","get",n(this,Tt,"m",kt).bind(this))(t)}update(t,e){return this.request("/project","patch",n(this,Tt,"m",kt).bind(this))(t,e)}}function te(){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 ee({id:t}){return`${te.call(this)}/payer/${t}`}function ie(e,i){return s(this,arguments,void 0,(function*({url:e},i){if(!e.startsWith(ee.call(this,{id:""})))throw new t({code:400,message:"Invalid payer URL."});const s=new URL(e).pathname.split("/").filter(Boolean),n=s[s.length-1];return this.request("/payer/{id}","get",te.bind(this))({id:n},i)}))}Tt=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 se extends p{constructor(t){super(t),St.add(this),this.constructPayerUrl=ee,this.getPayerByUrl=ie}eligibilityCheck(t,e){return this.request("/eligibility-check","post",n(this,St,"m",At).bind(this))(t,e)}submitClaim(t,e){return this.request("/claim/{claimId}/submit","post",n(this,St,"m",At).bind(this))(t,e)}setClaimStatus(t,e){return this.request("/claim/{claimId}/status","post",n(this,St,"m",At).bind(this))(t,e)}listPayers(t,e){return this.request("/payer","get",n(this,St,"m",At).bind(this))(t,e)}getPayer(t,e){return this.request("/payer/{id}","get",n(this,St,"m",At).bind(this))(t,e)}processEra(t,e){return this.request("/process-era","post",n(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.rcmApiUrl)&&void 0!==e?e:"https://rcm-api.zapehr.com/v1"};class ne extends p{constructor(t){super(t),Et.add(this)}list(t){return this.request("/iam/role","get",n(this,Et,"m",xt).bind(this))(t)}create(t,e){return this.request("/iam/role","post",n(this,Et,"m",xt).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",n(this,Et,"m",xt).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",n(this,Et,"m",xt).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",n(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.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class re extends p{constructor(t){super(t),It.add(this)}list(t){return this.request("/secret","get",n(this,It,"m",Ut).bind(this))(t)}set(t,e){return this.request("/secret","post",n(this,It,"m",Ut).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",n(this,It,"m",Ut).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",n(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 oe extends p{constructor(t){super(t),Pt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",n(this,Pt,"m",$t).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",n(this,Pt,"m",$t).bind(this))(t,e)}}Pt=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 ue extends p{constructor(t){super(t),zt.add(this)}searchCpt(t,e){return this.request("/cpt/search","get",n(this,zt,"m",Rt).bind(this))(t,e)}searchHcpcs(t,e){return this.request("/hcpcs/search","get",n(this,zt,"m",Rt).bind(this))(t,e)}searchIcd10(t,e){return this.request("/icd10/search","get",n(this,zt,"m",Rt).bind(this))(t,e)}}zt=new WeakSet,Rt=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 ae extends p{constructor(t){super(t),Nt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",n(this,Nt,"m",_t).bind(this))(t,e)}}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 ce extends p{constructor(t){super(t),Mt.add(this)}me(t){return this.request("/user/me","get",n(this,Mt,"m",Ct).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",n(this,Mt,"m",Ct).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",n(this,Mt,"m",Ct).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",n(this,Mt,"m",Ct).bind(this))(t,e)}resetMfa(t,e){return this.request("/user/{id}/reset-mfa","post",n(this,Mt,"m",Ct).bind(this))(t,e)}resetPasswordLink(t,e){return this.request("/user/{id}/reset-password-link","post",n(this,Mt,"m",Ct).bind(this))(t,e)}changePassword(t,e){return this.request("/user/{id}/change-password","post",n(this,Mt,"m",Ct).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",n(this,Mt,"m",Ct).bind(this))(t,e)}list(t){return this.request("/user","get",n(this,Mt,"m",Ct).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",n(this,Mt,"m",Ct).bind(this))(t,e)}}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 de extends p{constructor(t){super(t),Jt.add(this)}get(t){return this.request("/version","get",n(this,Jt,"m",Dt).bind(this))(t)}}function le(){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 he(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",le.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function pe(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",le.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 ve(e){return s(this,void 0,void 0,(function*(){var i,s;let n,r;const o=new URL(e.url);if("z3:"===o.protocol){const t=o.pathname.split("/").slice(1);n=o.hostname,r=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);n=t[0],r=t.slice(1).join("/")}}const u={action:"upload",bucketName:n,"objectPath+":r};return this.request("/z3/{bucketName}/{objectPath+}","post",le.bind(this))(u)}))}Jt=new WeakSet,Dt=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 fe extends p{constructor(t){super(t),Wt.add(this),this.uploadFile=he,this.downloadFile=pe,this.getPresignedUrlForZ3Url=ve}listBuckets(t){return this.request("/z3","get",n(this,Wt,"m",Lt).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",n(this,Wt,"m",Lt).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",n(this,Wt,"m",Lt).bind(this))(t,e)}emptyBucket(t,e){return this.request("/z3/{bucketName}/objects","delete",n(this,Wt,"m",Lt).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",n(this,Wt,"m",Lt).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",n(this,Wt,"m",Lt).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",n(this,Wt,"m",Lt).bind(this))(t,e)}}function me(){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 ge(e){return s(this,arguments,void 0,(function*({id:e,file:i,filename:s}){const n=yield this.request("/zambda/{id}/presigned-url","post",me.bind(this))({id:e,action:"upload",filename:s}),r=yield fetch(n.signedUrl,{method:"PUT",body:i});if(!r.ok)throw new t({message:"Failed to upload file",code:r.status,cause:r.statusText})}))}function be(e){return s(this,arguments,void 0,(function*({id:e}){const i=yield this.request("/zambda/{id}/presigned-url","post",me.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()}))}Wt=new WeakSet,Lt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class ye extends p{constructor(t){super(t),Bt.add(this),this.uploadFile=ge,this.downloadFile=be}list(t){return this.request("/zambda","get",n(this,Bt,"m",Ft).bind(this))(t)}create(t,e){return this.request("/zambda","post",n(this,Bt,"m",Ft).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",n(this,Bt,"m",Ft).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",n(this,Bt,"m",Ft).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",n(this,Bt,"m",Ft).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",n(this,Bt,"m",Ft).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",n(this,Bt,"m",Ft).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",n(this,Bt,"m",Ft).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/zambda/{id}/presigned-url","post",n(this,Bt,"m",Ft).bind(this))(t,e)}}Bt=new WeakSet,Ft=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 qe extends p{constructor(t){super(t),Gt.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",n(this,Gt,"m",Ht).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",n(this,Gt,"m",Ht).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",n(this,Gt,"m",Ht).bind(this))(t,e)}}Gt=new WeakSet,Ht=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 we=class{constructor(e){var i,s,n,r,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=(r=this.config).services)&&void 0!==i||(r.services={}),null!==(s=(o=this.config.services).projectApiUrl)&&void 0!==s||(o.projectApiUrl=e.projectApiUrl),null!==(n=(u=this.config.services).fhirApiUrl)&&void 0!==n||(u.fhirApiUrl=e.fhirApiUrl),this.application=new q(e),this.developer=new z(e),this.m2m=new Zt(e),this.messaging=new Kt(e),this.conversation=new $(e),this.transactionalSMS=new ae(e),this.paymentMethod=new Qt(e),this.charge=new w(e),this.project=new Yt(e),this.role=new ne(e),this.secret=new re(e),this.telemed=new oe(e),this.user=new ce(e),this.version=new de(e),this.z3=new fe(e),this.fax=new N(e),this.lab=new Xt(e),this.erx=new R(e),this.terminology=new ue(e),this.zambda=new ye(e),this.zambdaLogStream=new qe(e),this.rcm=new se(e),this.fhir=new Vt(e)}};class je extends we{}je.OystehrFHIRError=i,je.OystehrSdkError=t,exports.default=je;
|
|
2
2
|
//# sourceMappingURL=index.min.cjs.map
|