@oystehr/sdk 4.1.2 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/cjs/index.min.cjs +1 -1
  2. package/dist/cjs/index.min.cjs.map +1 -1
  3. package/dist/cjs/resources/classes/fax.cjs.map +1 -1
  4. package/dist/cjs/resources/classes/fax.d.ts +2 -2
  5. package/dist/cjs/resources/classes/fhir-ext.cjs +15 -2
  6. package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
  7. package/dist/cjs/resources/classes/lab.cjs +1 -1
  8. package/dist/cjs/resources/classes/lab.cjs.map +1 -1
  9. package/dist/cjs/resources/classes/lab.d.ts +4 -4
  10. package/dist/cjs/resources/classes/m2m.cjs +9 -0
  11. package/dist/cjs/resources/classes/m2m.cjs.map +1 -1
  12. package/dist/cjs/resources/classes/m2m.d.ts +8 -1
  13. package/dist/cjs/resources/types/ErxCheckPractitionerEnrollmentResponse.d.ts +4 -0
  14. package/dist/cjs/resources/types/ErxEnrollPractitionerParams.d.ts +1 -0
  15. package/dist/cjs/resources/types/FaxOnboardResponse.d.ts +9 -0
  16. package/dist/cjs/resources/types/LabOrderSubmitParams.d.ts +6 -2
  17. package/dist/cjs/resources/types/LabOrderSubmitResponse.d.ts +14 -0
  18. package/dist/cjs/resources/types/LabRouteCreateResponse.d.ts +9 -0
  19. package/dist/cjs/resources/types/LabRouteDeleteParams.d.ts +8 -0
  20. package/dist/cjs/resources/types/M2mMeResponse.d.ts +5 -0
  21. package/dist/cjs/resources/types/M2mUpdateParams.d.ts +4 -0
  22. package/dist/cjs/resources/types/UserUpdateParams.d.ts +5 -1
  23. package/dist/cjs/resources/types/ZambdaCreateParams.d.ts +2 -2
  24. package/dist/cjs/resources/types/ZambdaFunction.d.ts +1 -1
  25. package/dist/cjs/resources/types/ZambdaUpdateParams.d.ts +1 -1
  26. package/dist/cjs/resources/types/fhir.d.ts +3 -0
  27. package/dist/cjs/resources/types/index.d.ts +4 -0
  28. package/dist/esm/index.min.js +1 -1
  29. package/dist/esm/index.min.js.map +1 -1
  30. package/dist/esm/resources/classes/fax.d.ts +2 -2
  31. package/dist/esm/resources/classes/fax.js.map +1 -1
  32. package/dist/esm/resources/classes/fhir-ext.js +15 -2
  33. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  34. package/dist/esm/resources/classes/lab.d.ts +4 -4
  35. package/dist/esm/resources/classes/lab.js +1 -1
  36. package/dist/esm/resources/classes/lab.js.map +1 -1
  37. package/dist/esm/resources/classes/m2m.d.ts +8 -1
  38. package/dist/esm/resources/classes/m2m.js +9 -0
  39. package/dist/esm/resources/classes/m2m.js.map +1 -1
  40. package/dist/esm/resources/types/ErxCheckPractitionerEnrollmentResponse.d.ts +4 -0
  41. package/dist/esm/resources/types/ErxEnrollPractitionerParams.d.ts +1 -0
  42. package/dist/esm/resources/types/FaxOnboardResponse.d.ts +9 -0
  43. package/dist/esm/resources/types/LabOrderSubmitParams.d.ts +6 -2
  44. package/dist/esm/resources/types/LabOrderSubmitResponse.d.ts +14 -0
  45. package/dist/esm/resources/types/LabRouteCreateResponse.d.ts +9 -0
  46. package/dist/esm/resources/types/LabRouteDeleteParams.d.ts +8 -0
  47. package/dist/esm/resources/types/M2mMeResponse.d.ts +5 -0
  48. package/dist/esm/resources/types/M2mUpdateParams.d.ts +4 -0
  49. package/dist/esm/resources/types/UserUpdateParams.d.ts +5 -1
  50. package/dist/esm/resources/types/ZambdaCreateParams.d.ts +2 -2
  51. package/dist/esm/resources/types/ZambdaFunction.d.ts +1 -1
  52. package/dist/esm/resources/types/ZambdaUpdateParams.d.ts +1 -1
  53. package/dist/esm/resources/types/fhir.d.ts +3 -0
  54. package/dist/esm/resources/types/index.d.ts +4 -0
  55. package/package.json +2 -2
  56. package/src/resources/classes/fax.ts +2 -2
  57. package/src/resources/classes/fhir-ext.ts +17 -2
  58. package/src/resources/classes/lab.ts +5 -3
  59. package/src/resources/classes/m2m.ts +10 -0
  60. package/src/resources/types/ErxCheckPractitionerEnrollmentResponse.ts +4 -0
  61. package/src/resources/types/ErxEnrollPractitionerParams.ts +1 -0
  62. package/src/resources/types/FaxOnboardResponse.ts +11 -0
  63. package/src/resources/types/LabOrderSubmitParams.ts +6 -2
  64. package/src/resources/types/LabOrderSubmitResponse.ts +16 -0
  65. package/src/resources/types/LabRouteCreateResponse.ts +11 -0
  66. package/src/resources/types/LabRouteDeleteParams.ts +8 -0
  67. package/src/resources/types/M2mMeResponse.ts +7 -0
  68. package/src/resources/types/M2mUpdateParams.ts +4 -0
  69. package/src/resources/types/UserUpdateParams.ts +5 -1
  70. package/src/resources/types/ZambdaCreateParams.ts +2 -2
  71. package/src/resources/types/ZambdaFunction.ts +1 -1
  72. package/src/resources/types/ZambdaUpdateParams.ts +1 -1
  73. package/src/resources/types/fhir.ts +3 -0
  74. package/src/resources/types/index.ts +4 -0
  75. package/dist/esm/node_modules/tslib/package.json +0 -1
@@ -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(r,n){function o(t){try{c(s.next(t))}catch(e){n(e)}}function u(t){try{c(s.throw(t))}catch(e){n(e)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,u)}c((s=s.apply(t,e||[])).next())}))}function r(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;const n=[];for(let re=0;re<256;++re)n.push((re+256).toString(16).slice(1));let o;const u=new Uint8Array(16);function c(){if(!o){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");o=crypto.getRandomValues.bind(crypto)}return o(u)}var a={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function h(t,e,i){if(a.randomUUID&&!e&&!t)return a.randomUUID();const s=(t=t||{}).random||(t.rng||c)();return s[6]=15&s[6]|64,s[8]=63&s[8]|128,function(t,e=0){return(n[t[e+0]]+n[t[e+1]]+n[t[e+2]]+n[t[e+3]]+"-"+n[t[e+4]]+n[t[e+5]]+"-"+n[t[e+6]]+n[t[e+7]]+"-"+n[t[e+8]]+n[t[e+9]]+"-"+n[t[e+10]]+n[t[e+11]]+n[t[e+12]]+n[t[e+13]]+n[t[e+14]]+n[t[e+15]]).toLowerCase()}(s)}const d=[408,429,500,502,503,504],l=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class p{constructor(t){this.config=t}request(e,i,r){return(n,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config;try{return yield v(r,s,e,i)(n,o)}catch(u){const e=u;throw new t({message:e.message,code:e.code,cause:e.cause})}}))}fhirRequest(e,r){return(n,o)=>s(this,void 0,void 0,(function*(){try{const t=()=>{var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.fhirApiUrl)&&void 0!==e?e:"https://fhir-api.zapehr.com"},i=()=>this.config;return yield v(t,i,e,r)(n,o)}catch(s){const e=s;if("string"==typeof e.message)throw new t({message:e.message,code:e.code,cause:e.cause});throw new i({error:e.message,code:e.code})}}))}}function m(t){return"accessToken"in t}function v(e,i,r,n){return(o,u)=>s(this,void 0,void 0,(function*(){var c,a,p,v,g,b,y,q,j,w,U,S,k,x,O;const E=o&&!u&&!Array.isArray(o)&&m(o)?{}:null!==(c=o)&&void 0!==c?c:{},T=o&&!u&&!Array.isArray(o)&&m(o)?o:u,z=n.toLowerCase(),A=i(),I=null!==(a=A.fetch)&&void 0!==a?a:fetch,P=null!==(p=null==T?void 0:T.accessToken)&&void 0!==p?p:A.accessToken,R=null!==(v=null==T?void 0:T.projectId)&&void 0!==v?v:i().projectId;let N=r,W=E;if(!Array.isArray(E)){const[e,i]=function(e,i){const s=Object.assign({},i),r=e.replace(/\{([^}]+)\}/g,((e,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new t({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s);return[r,n.length?n.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{}]}(r,E);N=e,W=i}N=N.replace(/^\//,"");const C=e(),$=C.endsWith("/")?C:C+"/",_=new URL(N,$);let M;if(Array.isArray(W))M=JSON.stringify(W);else if(Object.keys(W).length)if("get"===z)f(W,_.searchParams);else if("application/x-www-form-urlencoded"===(null==T?void 0:T.contentType)){const t=new URLSearchParams;f(W,t),M=t.toString()}else M=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==T?void 0:T.contentType)&&"post"===z&&(M="{}");const L=Object.assign(R?{"x-zapehr-project-id":R,"x-oystehr-project-id":R}:{},{"content-type":null!==(g=null==T?void 0:T.contentType)&&void 0!==g?g:"application/json"},P?{Authorization:`Bearer ${P}`}:{},(null==T?void 0:T.ifMatch)?{"If-Match":T.ifMatch}:{},{"x-oystehr-request-id":null!==(b=null==T?void 0:T.requestId)&&void 0!==b?b:h()}),D={retries:null!==(q=null===(y=A.retry)||void 0===y?void 0:y.retries)&&void 0!==q?q:3,jitter:null!==(w=null===(j=A.retry)||void 0===j?void 0:j.jitter)&&void 0!==w?w:20,delay:null!==(S=null===(U=A.retry)||void 0===U?void 0:U.delay)&&void 0!==S?S:100,onRetry:null===(k=A.retry)||void 0===k?void 0:k.onRetry,retryOn:[...null!==(O=null===(x=A.retry)||void 0===x?void 0:x.retryOn)&&void 0!==O?O:[],...d]};return D.retryOn.push(...d),function(t,e){return s(this,void 0,void 0,(function*(){var i,s;let r;for(const o of Array.from({length:(null!==(i=e.retries)&&void 0!==i?i:0)+1},((t,e)=>e)))try{return yield t()}catch(n){let t=!1;if("response"in n){const i=n;t=e.retryOn.includes(i.code),r={message:n.message,code:n.code}}else if(r=n,"code"in n&&"string"==typeof n.code){const e=n;t=l.includes(e.code)}if(!t)break;const i=Math.floor(Math.random()*(e.jitter+1));yield new Promise((t=>setTimeout(t,e.delay+i))),e.onRetry&&o!==(null!==(s=e.retries)&&void 0!==s?s:0)&&e.onRetry(o+1)}throw r}))}((()=>s(this,void 0,void 0,(function*(){var t,e,i,s,r,n,o,u,c,a;const h=yield I(new Request(_,{method:z.toUpperCase(),body:M,headers:L})),d=h.body?yield h.text():null;let l;try{l=d&&((null===(t=h.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))||(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/fhir+json")))?JSON.parse(d):null}catch(p){l=null}if(!h.ok||h.status>=400)throw{message:null!==(o=null!==(n=null!==(r=null!==(s=null===(i=null==l?void 0:l.output)||void 0===i?void 0:i.message)&&void 0!==s?s:null==l?void 0:l.message)&&void 0!==r?r:l)&&void 0!==n?n:d)&&void 0!==o?o:h.statusText,code:null!==(a=null!==(c=null===(u=null==l?void 0:l.output)||void 0===u?void 0:u.code)&&void 0!==c?c:null==l?void 0:l.code)&&void 0!==a?a:h.status,response:h};return l}))),D)}))}function f(t,e){for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>e.append(i,t))):e.append(i,s)}var g,b,y,q;class j extends p{constructor(t){super(t),g.add(this)}list(t){return this.request("/application","get",r(this,g,"m",b).bind(this))(t)}create(t,e){return this.request("/application","post",r(this,g,"m",b).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",r(this,g,"m",b).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",r(this,g,"m",b).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",r(this,g,"m",b).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",r(this,g,"m",b).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",r(this,g,"m",b).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",r(this,g,"m",b).bind(this))(t,e)}}g=new WeakSet,b=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class w extends p{constructor(t){super(t),y.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",r(this,y,"m",q).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",r(this,y,"m",q).bind(this))(t,e)}}y=new WeakSet,q=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};const U="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",S="addressString";function k(t){var e,i,s;if(function(t){return Object.hasOwn(t,"virtualService")}(t)){const i=null===(e=t.virtualService)||void 0===e?void 0:e.find((t=>{var e;return"https://fhir.zapehr.com/virtual-service-type"===(null===(e=t.channelType)||void 0===e?void 0:e.system)}));return null==i?void 0:i.addressString}if(!t.extension)return;const r=t.extension.find((t=>t.url===U));return(null==r?void 0:r.extension)?null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===S)))||void 0===s?void 0:s.valueString:void 0}var x,O,E,T,z,A,I,P,R,N,W,C;class $ extends p{constructor(t){super(t),x.add(this),this.ENCOUNTER_VS_EXTENSION_URL=U,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=S,this.getConversationIdFromEncounter=k}create(t,e){return this.request("/messaging/conversation","post",r(this,x,"m",O).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",r(this,x,"m",O).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,x,"m",O).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,x,"m",O).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,x,"m",O).bind(this))(t,e)}}x=new WeakSet,O=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class _ extends p{constructor(t){super(t),E.add(this)}get(t,e){return this.request("/developer/{id}","get",r(this,E,"m",T).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",r(this,E,"m",T).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",r(this,E,"m",T).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",r(this,E,"m",T).bind(this))(t,e)}list(t){return this.request("/developer","get",r(this,E,"m",T).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",r(this,E,"m",T).bind(this))(t,e)}}E=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 M extends p{constructor(t){super(t),z.add(this)}searchAllergens(t,e){return this.request("/allergen","get",r(this,z,"m",A).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",r(this,z,"m",A).bind(this))(t,e)}getConfiguration(t){return this.request("/config","get",r(this,z,"m",A).bind(this))(t)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",r(this,z,"m",A).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",r(this,z,"m",A).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",r(this,z,"m",A).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",r(this,z,"m",A).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",r(this,z,"m",A).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",r(this,z,"m",A).bind(this))(t,e)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",r(this,z,"m",A).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",r(this,z,"m",A).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",r(this,z,"m",A).bind(this))(t,e)}}z=new WeakSet,A=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 L extends p{constructor(t){super(t),I.add(this)}syncPatient(t,e){return this.request("/erx/sync-patient/{patientId}","post",r(this,I,"m",P).bind(this))(t,e)}allergySearch(t,e){return this.request("/erx/allergy/search","get",r(this,I,"m",P).bind(this))(t,e)}cancelOrder(t,e){return this.request("/erx/cancel-order","post",r(this,I,"m",P).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/erx/cancel-prescription","post",r(this,I,"m",P).bind(this))(t,e)}medicationSearch(t,e){return this.request("/erx/medication/search","get",r(this,I,"m",P).bind(this))(t,e)}}I=new WeakSet,P=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 D extends p{constructor(t){super(t),R.add(this)}medicationSearch(t,e){return this.request("/erx/v2/medication/search","get",r(this,R,"m",N).bind(this))(t,e)}}R=new WeakSet,N=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 V extends p{constructor(t){super(t),W.add(this)}offboard(t){return this.request("/offboard","post",r(this,W,"m",C).bind(this))(t)}onboard(t){return this.request("/onboard","post",r(this,W,"m",C).bind(this))(t)}send(t,e){return this.request("/send","post",r(this,W,"m",C).bind(this))(t,e)}}function F(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i,params:s}=t;let r;s&&(r=Object.entries(s).reduce(((t,[e,i])=>(t[i.name]||(t[i.name]=[]),t[i.name].push(i.value),t)),{}));const n=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var t,e;return null!==(e=null===(t=this.entry)||void 0===t?void 0:t.map((t=>t.resource)).filter((t=>void 0!==t)))&&void 0!==e?e:[]}})}))}function H(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i}=t;return this.fhirRequest(`/${i}`,"POST")(t,e)}))}function B(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"GET")({},i)}))}function G(t,e){return s(this,void 0,void 0,(function*(){const{id:i,resourceType:s}=t;return this.fhirRequest(`/${s}/${i}`,"PUT")(t,Object.assign(Object.assign({},e),{ifMatch:(null==e?void 0:e.optimisticLockingVersionId)?`W/"${e.optimisticLockingVersionId}"`:void 0}))}))}function J(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,operations:i},s){return this.fhirRequest(`/${t}/${e}`,"PATCH")(i,Object.assign(Object.assign({},s),{contentType:"application/json-patch+json",ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0}))}))}function X(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function Z(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,versionId:i},s){return this.fhirRequest(`/${t}/${e}/_history${i?`/${i}`:""}`,"GET")({},s)}))}function K(t){const{method:e,url:i}=t,s={request:{method:e,url:i}};if(i.split("?").length>1){const[t,e]=i.split("?"),r=e.split("&").map((t=>{const[e,i]=t.split("=");return{name:e,value:i}})).reduce(((t,{name:e,value:i})=>e?(t[e]||(t[e]=[]),t[e].push(i),t):t),{}),n=new URLSearchParams;f(r,n),s.request.url=`${t}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(e))return s;if("PUT"===e){const{resource:e}=t;return Object.assign(Object.assign({},s),{resource:e})}if("PATCH"===e)return"resource"in t?Object.assign(Object.assign({},s),{resource:t.resource}):Object.assign(Object.assign({},s),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:Buffer.from(JSON.stringify(t.operations),"utf8").toString("base64")}});if("POST"===e){const{resource:e,fullUrl:i}=t;return Object.assign(Object.assign({},s),{resource:e,fullUrl:i})}throw new Error("Unrecognized method")}function Q(t){return function(e,i){return s(this,void 0,void 0,(function*(){return this.fhirRequest("/","POST")({resourceType:"Bundle",type:t,entry:e.requests.map(K)},i)}))}}W=new WeakSet,C=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 Y=Q("batch"),tt=Q("transaction");function et(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 it(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 st,rt,nt,ot,ut,ct,at,ht,dt,lt,pt,mt,vt,ft,gt,bt,yt,qt,jt,wt,Ut,St,kt,xt,Ot,Et,Tt,zt,At,It,Pt;class Rt extends p{constructor(t){super(t),st.add(this),this.search=F,this.create=H,this.get=B,this.update=G,this.patch=J,this.delete=X,this.history=Z,this.batch=Y,this.transaction=tt,this.formatAddress=et,this.formatHumanName=it}}st=new WeakSet;class Nt extends p{constructor(t){super(t),rt.add(this)}routeList(t){return this.request("/route","get",r(this,rt,"m",nt).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",r(this,rt,"m",nt).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",r(this,rt,"m",nt).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",r(this,rt,"m",nt).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,rt,"m",nt).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",r(this,rt,"m",nt).bind(this))(t,e)}}rt=new WeakSet,nt=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 Wt extends p{constructor(t){super(t),ot.add(this)}list(t){return this.request("/m2m","get",r(this,ot,"m",ut).bind(this))(t)}create(t,e){return this.request("/m2m","post",r(this,ot,"m",ut).bind(this))(t,e)}get(t,e){return this.request("/m2m/{id}","get",r(this,ot,"m",ut).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",r(this,ot,"m",ut).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",r(this,ot,"m",ut).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",r(this,ot,"m",ut).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",r(this,ot,"m",ut).bind(this))(t,e)}}ot=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 Ct extends p{constructor(t){super(t),ct.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",r(this,ct,"m",at).bind(this))(t)}}ct=new WeakSet,at=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class $t extends p{constructor(t){super(t),ht.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",r(this,ht,"m",dt).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",r(this,ht,"m",dt).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",r(this,ht,"m",dt).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",r(this,ht,"m",dt).bind(this))(t,e)}}ht=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 _t extends p{constructor(t){super(t),lt.add(this)}get(t){return this.request("/project","get",r(this,lt,"m",pt).bind(this))(t)}update(t,e){return this.request("/project","patch",r(this,lt,"m",pt).bind(this))(t,e)}}lt=new WeakSet,pt=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 Mt extends p{constructor(t){super(t),mt.add(this)}eligibilityCheck(t,e){return this.request("/rcm/eligibility-check","post",r(this,mt,"m",vt).bind(this))(t,e)}validateProfessionalClaim(t,e){return this.request("/rcm/professional-claim/validate","post",r(this,mt,"m",vt).bind(this))(t,e)}submitProfessionalClaim(t,e){return this.request("/rcm/professional-claim/submit","post",r(this,mt,"m",vt).bind(this))(t,e)}}mt=new WeakSet,vt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Lt extends p{constructor(t){super(t),ft.add(this)}list(t){return this.request("/iam/role","get",r(this,ft,"m",gt).bind(this))(t)}create(t,e){return this.request("/iam/role","post",r(this,ft,"m",gt).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",r(this,ft,"m",gt).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",r(this,ft,"m",gt).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",r(this,ft,"m",gt).bind(this))(t,e)}}ft=new WeakSet,gt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Dt extends p{constructor(t){super(t),bt.add(this)}list(t){return this.request("/secret","get",r(this,bt,"m",yt).bind(this))(t)}set(t,e){return this.request("/secret","post",r(this,bt,"m",yt).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",r(this,bt,"m",yt).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",r(this,bt,"m",yt).bind(this))(t,e)}}bt=new WeakSet,yt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Vt extends p{constructor(t){super(t),qt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",r(this,qt,"m",jt).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,qt,"m",jt).bind(this))(t,e)}}qt=new WeakSet,jt=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 Ft extends p{constructor(t){super(t),wt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",r(this,wt,"m",Ut).bind(this))(t,e)}}wt=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 Ht extends p{constructor(t){super(t),St.add(this)}me(t){return this.request("/user/me","get",r(this,St,"m",kt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",r(this,St,"m",kt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",r(this,St,"m",kt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",r(this,St,"m",kt).bind(this))(t,e)}resetMfa(t,e){return this.request("/user/{id}/reset-mfa","post",r(this,St,"m",kt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",r(this,St,"m",kt).bind(this))(t,e)}list(t){return this.request("/user","get",r(this,St,"m",kt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",r(this,St,"m",kt).bind(this))(t,e)}}St=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 Bt extends p{constructor(t){super(t),xt.add(this)}get(t){return this.request("/version","get",r(this,xt,"m",Ot).bind(this))(t)}}function Gt(){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 Jt(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Gt.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function Xt(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Gt.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 Zt(e){return s(this,void 0,void 0,(function*(){var i,s;let r,n;const o=new URL(e.url);if("z3:"===o.protocol){const t=o.pathname.split("/").slice(1);r=o.hostname,n=t.join("/")}else{if(!o.href.startsWith(null!==(s=null===(i=this.config.services)||void 0===i?void 0:i.projectApiUrl)&&void 0!==s?s:"https://project-api.zapehr.com/v1"))throw new t({message:"Invalid Z3 URL",code:400});{const t=o.pathname.split("/").slice(3);r=t[0],n=t.slice(1).join("/")}}const u={action:"upload",bucketName:r,"objectPath+":n};return this.request("/z3/{bucketName}/{objectPath+}","post",Gt.bind(this))(u)}))}xt=new WeakSet,Ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Kt extends p{constructor(t){super(t),Et.add(this),this.uploadFile=Jt,this.downloadFile=Xt,this.getPresignedUrlForZ3Url=Zt}listBuckets(t){return this.request("/z3","get",r(this,Et,"m",Tt).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",r(this,Et,"m",Tt).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",r(this,Et,"m",Tt).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,Et,"m",Tt).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,Et,"m",Tt).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,Et,"m",Tt).bind(this))(t,e)}}function Qt(){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 Yt(t){return s(this,arguments,void 0,(function*({id:t,file:e,filename:i}){const s=yield this.request("/zambda/{id}/s3-upload","post",Qt.bind(this))({id:t,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:e})}))}Et=new WeakSet,Tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class te extends p{constructor(t){super(t),zt.add(this),this.uploadFile=Yt}list(t){return this.request("/zambda","get",r(this,zt,"m",At).bind(this))(t)}create(t,e){return this.request("/zambda","post",r(this,zt,"m",At).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",r(this,zt,"m",At).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",r(this,zt,"m",At).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",r(this,zt,"m",At).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",r(this,zt,"m",At).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",r(this,zt,"m",At).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",r(this,zt,"m",At).bind(this))(t,e)}}zt=new WeakSet,At=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class ee extends p{constructor(t){super(t),It.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",r(this,It,"m",Pt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",r(this,It,"m",Pt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",r(this,It,"m",Pt).bind(this))(t,e)}}It=new WeakSet,Pt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};let ie=class{constructor(t){var e,i,s,r,n,o;this.config=t,null!==(e=(r=this.config).services)&&void 0!==e||(r.services={}),null!==(i=(n=this.config.services).projectApiUrl)&&void 0!==i||(n.projectApiUrl=t.projectApiUrl),null!==(s=(o=this.config.services).fhirApiUrl)&&void 0!==s||(o.fhirApiUrl=t.fhirApiUrl),this.application=new j(t),this.developer=new _(t),this.m2m=new Wt(t),this.messaging=new Ct(t),this.conversation=new $(t),this.transactionalSMS=new Ft(t),this.paymentMethod=new $t(t),this.charge=new w(t),this.project=new _t(t),this.rcm=new Mt(t),this.erxV1=new L(t),this.erxV2=new D(t),this.role=new Lt(t),this.secret=new Dt(t),this.telemed=new Vt(t),this.user=new Ht(t),this.version=new Bt(t),this.z3=new Kt(t),this.zambda=new te(t),this.zambdaLogStream=new ee(t),this.fax=new V(t),this.lab=new Nt(t),this.erx=new M(t),this.fhir=new Rt(t)}};class se extends ie{}se.OystehrFHIRError=i,se.OystehrSdkError=t,exports.default=se;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t extends Error{constructor({message:e,code:i,cause:s}){super(e,{cause:s}),Object.setPrototypeOf(this,t.prototype),this.code=i,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function e(t){var e;const i=[];for(const s of null!==(e=t.issue)&&void 0!==e?e:[])s.details&&s.details.text&&i.push(s.details.text);return i.length||i.push("Unknown FHIR error"),i.join(",")}class i extends t{constructor({error:t,code:s}){super({message:e(t),code:s}),Object.setPrototypeOf(this,i.prototype),this.cause=t,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function s(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{c(s.next(t))}catch(e){n(e)}}function u(t){try{c(s.throw(t))}catch(e){n(e)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,u)}c((s=s.apply(t,e||[])).next())}))}function r(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;const n=[];for(let re=0;re<256;++re)n.push((re+256).toString(16).slice(1));let o;const u=new Uint8Array(16);function c(){if(!o){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");o=crypto.getRandomValues.bind(crypto)}return o(u)}var a={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function h(t,e,i){if(a.randomUUID&&!e&&!t)return a.randomUUID();const s=(t=t||{}).random||(t.rng||c)();return s[6]=15&s[6]|64,s[8]=63&s[8]|128,function(t,e=0){return(n[t[e+0]]+n[t[e+1]]+n[t[e+2]]+n[t[e+3]]+"-"+n[t[e+4]]+n[t[e+5]]+"-"+n[t[e+6]]+n[t[e+7]]+"-"+n[t[e+8]]+n[t[e+9]]+"-"+n[t[e+10]]+n[t[e+11]]+n[t[e+12]]+n[t[e+13]]+n[t[e+14]]+n[t[e+15]]).toLowerCase()}(s)}const d=[408,429,500,502,503,504],l=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class p{constructor(t){this.config=t}request(e,i,r){return(n,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config;try{return yield v(r,s,e,i)(n,o)}catch(u){const e=u;throw new t({message:e.message,code:e.code,cause:e.cause})}}))}fhirRequest(e,r){return(n,o)=>s(this,void 0,void 0,(function*(){try{const t=()=>{var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.fhirApiUrl)&&void 0!==e?e:"https://fhir-api.zapehr.com"},i=()=>this.config;return yield v(t,i,e,r)(n,o)}catch(s){const e=s;if("string"==typeof e.message)throw new t({message:e.message,code:e.code,cause:e.cause});throw new i({error:e.message,code:e.code})}}))}}function m(t){return"accessToken"in t}function v(e,i,r,n){return(o,u)=>s(this,void 0,void 0,(function*(){var c,a,p,v,g,b,y,q,j,w,U,S,k,x,O;const E=o&&!u&&!Array.isArray(o)&&m(o)?{}:null!==(c=o)&&void 0!==c?c:{},T=o&&!u&&!Array.isArray(o)&&m(o)?o:u,z=n.toLowerCase(),A=i(),I=null!==(a=A.fetch)&&void 0!==a?a:fetch,P=null!==(p=null==T?void 0:T.accessToken)&&void 0!==p?p:A.accessToken,R=null!==(v=null==T?void 0:T.projectId)&&void 0!==v?v:i().projectId;let N=r,W=E;if(!Array.isArray(E)){const[e,i]=function(e,i){const s=Object.assign({},i),r=e.replace(/\{([^}]+)\}/g,((e,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new t({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s);return[r,n.length?n.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{}]}(r,E);N=e,W=i}N=N.replace(/^\//,"");const C=e(),M=C.endsWith("/")?C:C+"/",$=new URL(N,M);let _;if(Array.isArray(W))_=JSON.stringify(W);else if(Object.keys(W).length)if("get"===z)f(W,$.searchParams);else if("application/x-www-form-urlencoded"===(null==T?void 0:T.contentType)){const t=new URLSearchParams;f(W,t),_=t.toString()}else _=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==T?void 0:T.contentType)&&"post"===z&&(_="{}");const L=Object.assign(R?{"x-zapehr-project-id":R,"x-oystehr-project-id":R}:{},{"content-type":null!==(g=null==T?void 0:T.contentType)&&void 0!==g?g:"application/json"},P?{Authorization:`Bearer ${P}`}:{},(null==T?void 0:T.ifMatch)?{"If-Match":T.ifMatch}:{},{"x-oystehr-request-id":null!==(b=null==T?void 0:T.requestId)&&void 0!==b?b:h()}),D={retries:null!==(q=null===(y=A.retry)||void 0===y?void 0:y.retries)&&void 0!==q?q:3,jitter:null!==(w=null===(j=A.retry)||void 0===j?void 0:j.jitter)&&void 0!==w?w:20,delay:null!==(S=null===(U=A.retry)||void 0===U?void 0:U.delay)&&void 0!==S?S:100,onRetry:null===(k=A.retry)||void 0===k?void 0:k.onRetry,retryOn:[...null!==(O=null===(x=A.retry)||void 0===x?void 0:x.retryOn)&&void 0!==O?O:[],...d]};return D.retryOn.push(...d),function(t,e){return s(this,void 0,void 0,(function*(){var i,s;let r;for(const o of Array.from({length:(null!==(i=e.retries)&&void 0!==i?i:0)+1},((t,e)=>e)))try{return yield t()}catch(n){let t=!1;if("response"in n){const i=n;t=e.retryOn.includes(i.code),r={message:n.message,code:n.code}}else if(r=n,"code"in n&&"string"==typeof n.code){const e=n;t=l.includes(e.code)}if(!t)break;const i=Math.floor(Math.random()*(e.jitter+1));yield new Promise((t=>setTimeout(t,e.delay+i))),e.onRetry&&o!==(null!==(s=e.retries)&&void 0!==s?s:0)&&e.onRetry(o+1)}throw r}))}((()=>s(this,void 0,void 0,(function*(){var t,e,i,s,r,n,o,u,c,a;const h=yield I(new Request($,{method:z.toUpperCase(),body:_,headers:L})),d=h.body?yield h.text():null;let l;try{l=d&&((null===(t=h.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))||(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/fhir+json")))?JSON.parse(d):null}catch(p){l=null}if(!h.ok||h.status>=400)throw{message:null!==(o=null!==(n=null!==(r=null!==(s=null===(i=null==l?void 0:l.output)||void 0===i?void 0:i.message)&&void 0!==s?s:null==l?void 0:l.message)&&void 0!==r?r:l)&&void 0!==n?n:d)&&void 0!==o?o:h.statusText,code:null!==(a=null!==(c=null===(u=null==l?void 0:l.output)||void 0===u?void 0:u.code)&&void 0!==c?c:null==l?void 0:l.code)&&void 0!==a?a:h.status,response:h};return l}))),D)}))}function f(t,e){for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>e.append(i,t))):e.append(i,s)}var g,b,y,q;class j extends p{constructor(t){super(t),g.add(this)}list(t){return this.request("/application","get",r(this,g,"m",b).bind(this))(t)}create(t,e){return this.request("/application","post",r(this,g,"m",b).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",r(this,g,"m",b).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",r(this,g,"m",b).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",r(this,g,"m",b).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",r(this,g,"m",b).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",r(this,g,"m",b).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",r(this,g,"m",b).bind(this))(t,e)}}g=new WeakSet,b=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class w extends p{constructor(t){super(t),y.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",r(this,y,"m",q).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",r(this,y,"m",q).bind(this))(t,e)}}y=new WeakSet,q=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};const U="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",S="addressString";function k(t){var e,i,s;if(function(t){return Object.hasOwn(t,"virtualService")}(t)){const i=null===(e=t.virtualService)||void 0===e?void 0:e.find((t=>{var e;return"https://fhir.zapehr.com/virtual-service-type"===(null===(e=t.channelType)||void 0===e?void 0:e.system)}));return null==i?void 0:i.addressString}if(!t.extension)return;const r=t.extension.find((t=>t.url===U));return(null==r?void 0:r.extension)?null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===S)))||void 0===s?void 0:s.valueString:void 0}var x,O,E,T,z,A,I,P,R,N,W,C;class M extends p{constructor(t){super(t),x.add(this),this.ENCOUNTER_VS_EXTENSION_URL=U,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=S,this.getConversationIdFromEncounter=k}create(t,e){return this.request("/messaging/conversation","post",r(this,x,"m",O).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",r(this,x,"m",O).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,x,"m",O).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,x,"m",O).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,x,"m",O).bind(this))(t,e)}}x=new WeakSet,O=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class $ extends p{constructor(t){super(t),E.add(this)}get(t,e){return this.request("/developer/{id}","get",r(this,E,"m",T).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",r(this,E,"m",T).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",r(this,E,"m",T).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",r(this,E,"m",T).bind(this))(t,e)}list(t){return this.request("/developer","get",r(this,E,"m",T).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",r(this,E,"m",T).bind(this))(t,e)}}E=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 _ extends p{constructor(t){super(t),z.add(this)}searchAllergens(t,e){return this.request("/allergen","get",r(this,z,"m",A).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",r(this,z,"m",A).bind(this))(t,e)}getConfiguration(t){return this.request("/config","get",r(this,z,"m",A).bind(this))(t)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",r(this,z,"m",A).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",r(this,z,"m",A).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",r(this,z,"m",A).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",r(this,z,"m",A).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",r(this,z,"m",A).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",r(this,z,"m",A).bind(this))(t,e)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",r(this,z,"m",A).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",r(this,z,"m",A).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",r(this,z,"m",A).bind(this))(t,e)}}z=new WeakSet,A=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 L extends p{constructor(t){super(t),I.add(this)}syncPatient(t,e){return this.request("/erx/sync-patient/{patientId}","post",r(this,I,"m",P).bind(this))(t,e)}allergySearch(t,e){return this.request("/erx/allergy/search","get",r(this,I,"m",P).bind(this))(t,e)}cancelOrder(t,e){return this.request("/erx/cancel-order","post",r(this,I,"m",P).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/erx/cancel-prescription","post",r(this,I,"m",P).bind(this))(t,e)}medicationSearch(t,e){return this.request("/erx/medication/search","get",r(this,I,"m",P).bind(this))(t,e)}}I=new WeakSet,P=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 D extends p{constructor(t){super(t),R.add(this)}medicationSearch(t,e){return this.request("/erx/v2/medication/search","get",r(this,R,"m",N).bind(this))(t,e)}}R=new WeakSet,N=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 V extends p{constructor(t){super(t),W.add(this)}offboard(t){return this.request("/offboard","post",r(this,W,"m",C).bind(this))(t)}onboard(t){return this.request("/onboard","post",r(this,W,"m",C).bind(this))(t)}send(t,e){return this.request("/send","post",r(this,W,"m",C).bind(this))(t,e)}}function F(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i,params:s}=t;let r;s&&(r=Object.entries(s).reduce(((t,[e,i])=>(t[i.name]||(t[i.name]=[]),t[i.name].push(i.value),t)),{}));const n=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var t,e;return null!==(e=null===(t=this.entry)||void 0===t?void 0:t.map((t=>t.resource)).filter((t=>void 0!==t)))&&void 0!==e?e:[]}})}))}function H(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i}=t;return this.fhirRequest(`/${i}`,"POST")(t,e)}))}function B(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"GET")({},i)}))}function G(t,e){return s(this,void 0,void 0,(function*(){const{id:i,resourceType:s}=t;return this.fhirRequest(`/${s}/${i}`,"PUT")(t,Object.assign(Object.assign({},e),{ifMatch:(null==e?void 0:e.optimisticLockingVersionId)?`W/"${e.optimisticLockingVersionId}"`:void 0}))}))}function J(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,operations:i},s){return this.fhirRequest(`/${t}/${e}`,"PATCH")(i,Object.assign(Object.assign({},s),{contentType:"application/json-patch+json",ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0}))}))}function X(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function Z(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,versionId:i},s){return this.fhirRequest(`/${t}/${e}/_history${i?`/${i}`:""}`,"GET")({},s)}))}function K(t){const{method:e,url:i}=t,s={request:{method:e,url:i}};if(i.split("?").length>1){const[t,e]=i.split("?"),r=e.split("&").map((t=>{const[e,i]=t.split("=");return{name:e,value:i}})).reduce(((t,{name:e,value:i})=>e?(t[e]||(t[e]=[]),t[e].push(i),t):t),{}),n=new URLSearchParams;f(r,n),s.request.url=`${t}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(e))return s;if("PUT"===e){const{resource:e}=t;return{request:Object.assign(Object.assign({},s.request),{ifMatch:t.ifMatch}),resource:e}}if("PATCH"===e)return"resource"in t?{request:Object.assign(Object.assign({},s.request),{ifMatch:t.ifMatch}),resource:t.resource}:Object.assign(Object.assign({},s),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:Buffer.from(JSON.stringify(t.operations),"utf8").toString("base64")}});if("POST"===e){const{resource:e,fullUrl:i}=t;return Object.assign(Object.assign({},s),{resource:e,fullUrl:i})}throw new Error("Unrecognized method")}function Q(t){return function(e,i){return s(this,void 0,void 0,(function*(){return this.fhirRequest("/","POST")({resourceType:"Bundle",type:t,entry:e.requests.map(K)},i)}))}}W=new WeakSet,C=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 Y=Q("batch"),tt=Q("transaction");function et(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 it(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 st,rt,nt,ot,ut,ct,at,ht,dt,lt,pt,mt,vt,ft,gt,bt,yt,qt,jt,wt,Ut,St,kt,xt,Ot,Et,Tt,zt,At,It,Pt;class Rt extends p{constructor(t){super(t),st.add(this),this.search=F,this.create=H,this.get=B,this.update=G,this.patch=J,this.delete=X,this.history=Z,this.batch=Y,this.transaction=tt,this.formatAddress=et,this.formatHumanName=it}}st=new WeakSet;class Nt extends p{constructor(t){super(t),rt.add(this)}routeList(t){return this.request("/route","get",r(this,rt,"m",nt).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",r(this,rt,"m",nt).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",r(this,rt,"m",nt).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",r(this,rt,"m",nt).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,rt,"m",nt).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",r(this,rt,"m",nt).bind(this))(t,e)}}rt=new WeakSet,nt=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 Wt extends p{constructor(t){super(t),ot.add(this)}list(t){return this.request("/m2m","get",r(this,ot,"m",ut).bind(this))(t)}create(t,e){return this.request("/m2m","post",r(this,ot,"m",ut).bind(this))(t,e)}me(t){return this.request("/m2m/me","get",r(this,ot,"m",ut).bind(this))(t)}get(t,e){return this.request("/m2m/{id}","get",r(this,ot,"m",ut).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",r(this,ot,"m",ut).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",r(this,ot,"m",ut).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",r(this,ot,"m",ut).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",r(this,ot,"m",ut).bind(this))(t,e)}}ot=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 Ct extends p{constructor(t){super(t),ct.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",r(this,ct,"m",at).bind(this))(t)}}ct=new WeakSet,at=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Mt extends p{constructor(t){super(t),ht.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",r(this,ht,"m",dt).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",r(this,ht,"m",dt).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",r(this,ht,"m",dt).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",r(this,ht,"m",dt).bind(this))(t,e)}}ht=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 $t extends p{constructor(t){super(t),lt.add(this)}get(t){return this.request("/project","get",r(this,lt,"m",pt).bind(this))(t)}update(t,e){return this.request("/project","patch",r(this,lt,"m",pt).bind(this))(t,e)}}lt=new WeakSet,pt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class _t extends p{constructor(t){super(t),mt.add(this)}eligibilityCheck(t,e){return this.request("/rcm/eligibility-check","post",r(this,mt,"m",vt).bind(this))(t,e)}validateProfessionalClaim(t,e){return this.request("/rcm/professional-claim/validate","post",r(this,mt,"m",vt).bind(this))(t,e)}submitProfessionalClaim(t,e){return this.request("/rcm/professional-claim/submit","post",r(this,mt,"m",vt).bind(this))(t,e)}}mt=new WeakSet,vt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Lt extends p{constructor(t){super(t),ft.add(this)}list(t){return this.request("/iam/role","get",r(this,ft,"m",gt).bind(this))(t)}create(t,e){return this.request("/iam/role","post",r(this,ft,"m",gt).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",r(this,ft,"m",gt).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",r(this,ft,"m",gt).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",r(this,ft,"m",gt).bind(this))(t,e)}}ft=new WeakSet,gt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Dt extends p{constructor(t){super(t),bt.add(this)}list(t){return this.request("/secret","get",r(this,bt,"m",yt).bind(this))(t)}set(t,e){return this.request("/secret","post",r(this,bt,"m",yt).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",r(this,bt,"m",yt).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",r(this,bt,"m",yt).bind(this))(t,e)}}bt=new WeakSet,yt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Vt extends p{constructor(t){super(t),qt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",r(this,qt,"m",jt).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,qt,"m",jt).bind(this))(t,e)}}qt=new WeakSet,jt=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 Ft extends p{constructor(t){super(t),wt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",r(this,wt,"m",Ut).bind(this))(t,e)}}wt=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 Ht extends p{constructor(t){super(t),St.add(this)}me(t){return this.request("/user/me","get",r(this,St,"m",kt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",r(this,St,"m",kt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",r(this,St,"m",kt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",r(this,St,"m",kt).bind(this))(t,e)}resetMfa(t,e){return this.request("/user/{id}/reset-mfa","post",r(this,St,"m",kt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",r(this,St,"m",kt).bind(this))(t,e)}list(t){return this.request("/user","get",r(this,St,"m",kt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",r(this,St,"m",kt).bind(this))(t,e)}}St=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 Bt extends p{constructor(t){super(t),xt.add(this)}get(t){return this.request("/version","get",r(this,xt,"m",Ot).bind(this))(t)}}function Gt(){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 Jt(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Gt.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function Xt(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Gt.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 Zt(e){return s(this,void 0,void 0,(function*(){var i,s;let r,n;const o=new URL(e.url);if("z3:"===o.protocol){const t=o.pathname.split("/").slice(1);r=o.hostname,n=t.join("/")}else{if(!o.href.startsWith(null!==(s=null===(i=this.config.services)||void 0===i?void 0:i.projectApiUrl)&&void 0!==s?s:"https://project-api.zapehr.com/v1"))throw new t({message:"Invalid Z3 URL",code:400});{const t=o.pathname.split("/").slice(3);r=t[0],n=t.slice(1).join("/")}}const u={action:"upload",bucketName:r,"objectPath+":n};return this.request("/z3/{bucketName}/{objectPath+}","post",Gt.bind(this))(u)}))}xt=new WeakSet,Ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Kt extends p{constructor(t){super(t),Et.add(this),this.uploadFile=Jt,this.downloadFile=Xt,this.getPresignedUrlForZ3Url=Zt}listBuckets(t){return this.request("/z3","get",r(this,Et,"m",Tt).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",r(this,Et,"m",Tt).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",r(this,Et,"m",Tt).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,Et,"m",Tt).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,Et,"m",Tt).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,Et,"m",Tt).bind(this))(t,e)}}function Qt(){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 Yt(t){return s(this,arguments,void 0,(function*({id:t,file:e,filename:i}){const s=yield this.request("/zambda/{id}/s3-upload","post",Qt.bind(this))({id:t,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:e})}))}Et=new WeakSet,Tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class te extends p{constructor(t){super(t),zt.add(this),this.uploadFile=Yt}list(t){return this.request("/zambda","get",r(this,zt,"m",At).bind(this))(t)}create(t,e){return this.request("/zambda","post",r(this,zt,"m",At).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",r(this,zt,"m",At).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",r(this,zt,"m",At).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",r(this,zt,"m",At).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",r(this,zt,"m",At).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",r(this,zt,"m",At).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",r(this,zt,"m",At).bind(this))(t,e)}}zt=new WeakSet,At=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class ee extends p{constructor(t){super(t),It.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",r(this,It,"m",Pt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",r(this,It,"m",Pt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",r(this,It,"m",Pt).bind(this))(t,e)}}It=new WeakSet,Pt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};let ie=class{constructor(t){var e,i,s,r,n,o;this.config=t,null!==(e=(r=this.config).services)&&void 0!==e||(r.services={}),null!==(i=(n=this.config.services).projectApiUrl)&&void 0!==i||(n.projectApiUrl=t.projectApiUrl),null!==(s=(o=this.config.services).fhirApiUrl)&&void 0!==s||(o.fhirApiUrl=t.fhirApiUrl),this.application=new j(t),this.developer=new $(t),this.m2m=new Wt(t),this.messaging=new Ct(t),this.conversation=new M(t),this.transactionalSMS=new Ft(t),this.paymentMethod=new Mt(t),this.charge=new w(t),this.project=new $t(t),this.rcm=new _t(t),this.erxV1=new L(t),this.erxV2=new D(t),this.role=new Lt(t),this.secret=new Dt(t),this.telemed=new Vt(t),this.user=new Ht(t),this.version=new Bt(t),this.z3=new Kt(t),this.zambda=new te(t),this.zambdaLogStream=new ee(t),this.fax=new V(t),this.lab=new Nt(t),this.erx=new _(t),this.fhir=new Rt(t)}};class se extends ie{}se.OystehrFHIRError=i,se.OystehrSdkError=t,exports.default=se;
2
2
  //# sourceMappingURL=index.min.cjs.map