@oystehr/sdk 3.0.16 → 4.0.0-alpha.0

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 (127) hide show
  1. package/dist/cjs/config.d.ts +2 -1
  2. package/dist/cjs/index.cjs +82 -12
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.min.cjs +1 -1
  5. package/dist/cjs/index.min.cjs.map +1 -1
  6. package/dist/cjs/resources/classes/developer.d.ts +2 -2
  7. package/dist/cjs/resources/classes/erx.d.ts +17 -17
  8. package/dist/cjs/resources/classes/erxV1.d.ts +31 -0
  9. package/dist/cjs/resources/classes/erxV2.d.ts +15 -0
  10. package/dist/cjs/resources/classes/index.d.ts +5 -1
  11. package/dist/cjs/resources/classes/m2m.d.ts +2 -2
  12. package/dist/cjs/resources/classes/user.d.ts +2 -2
  13. package/dist/cjs/resources/types/ErxCheckAllergyInteractionsParams.d.ts +3 -0
  14. package/dist/cjs/resources/types/ErxCheckAllergyInteractionsResponse.d.ts +9 -0
  15. package/dist/cjs/resources/types/ErxCheckMedicationInteractionsParams.d.ts +3 -0
  16. package/dist/cjs/resources/types/ErxCheckMedicationInteractionsResponse.d.ts +21 -0
  17. package/dist/cjs/resources/types/ErxCheckPrecheckInteractionsParams.d.ts +4 -0
  18. package/dist/cjs/resources/types/ErxCheckPrecheckInteractionsResponse.d.ts +29 -0
  19. package/dist/cjs/resources/types/ErxConnectPractitionerParams.d.ts +4 -0
  20. package/dist/cjs/resources/types/ErxConnectPractitionerResponse.d.ts +9 -0
  21. package/dist/cjs/resources/types/ErxSearchAllergensParams.d.ts +3 -0
  22. package/dist/cjs/resources/types/ErxSearchAllergensResponse.d.ts +21 -0
  23. package/dist/cjs/resources/types/ErxSearchMedicationsParams.d.ts +3 -0
  24. package/dist/cjs/resources/types/ErxSearchMedicationsResponse.d.ts +27 -0
  25. package/dist/cjs/resources/types/ErxV1AllergySearchParams.d.ts +3 -0
  26. package/dist/{esm/resources/types/ErxAllergySearchResponse.d.ts → cjs/resources/types/ErxV1AllergySearchResponse.d.ts} +1 -1
  27. package/dist/{esm/resources/types/ErxCancelOrderParams.d.ts → cjs/resources/types/ErxV1CancelOrderParams.d.ts} +1 -1
  28. package/dist/{esm/resources/types/ErxCancelOrderResponse.d.ts → cjs/resources/types/ErxV1CancelOrderResponse.d.ts} +1 -1
  29. package/dist/cjs/resources/types/{ErxCancelPrescriptionParams.d.ts → ErxV1CancelPrescriptionParams.d.ts} +1 -1
  30. package/dist/cjs/resources/types/{ErxCancelPrescriptionResponse.d.ts → ErxV1CancelPrescriptionResponse.d.ts} +1 -1
  31. package/dist/cjs/resources/types/{ErxMedicationSearchParams.d.ts → ErxV1MedicationSearchParams.d.ts} +1 -1
  32. package/dist/cjs/resources/types/{ErxMedicationSearchResponse.d.ts → ErxV1MedicationSearchResponse.d.ts} +1 -1
  33. package/dist/cjs/resources/types/ErxV1SyncPatientParams.d.ts +3 -0
  34. package/dist/{esm/resources/types/ErxSyncPatientResponse.d.ts → cjs/resources/types/ErxV1SyncPatientResponse.d.ts} +1 -1
  35. package/dist/cjs/resources/types/ErxV2MedicationSearchParams.d.ts +4 -0
  36. package/dist/cjs/resources/types/{ErxMedicationSearchV2Response.d.ts → ErxV2MedicationSearchResponse.d.ts} +1 -1
  37. package/dist/cjs/resources/types/index.d.ts +25 -12
  38. package/dist/esm/config.d.ts +2 -1
  39. package/dist/esm/index.min.js +1 -1
  40. package/dist/esm/index.min.js.map +1 -1
  41. package/dist/esm/resources/classes/developer.d.ts +2 -2
  42. package/dist/esm/resources/classes/developer.js +1 -1
  43. package/dist/esm/resources/classes/developer.js.map +1 -1
  44. package/dist/esm/resources/classes/erx.d.ts +17 -17
  45. package/dist/esm/resources/classes/erx.js +25 -19
  46. package/dist/esm/resources/classes/erx.js.map +1 -1
  47. package/dist/esm/resources/classes/erxV1.d.ts +31 -0
  48. package/dist/esm/resources/classes/erxV1.js +48 -0
  49. package/dist/esm/resources/classes/erxV1.js.map +1 -0
  50. package/dist/esm/resources/classes/erxV2.d.ts +15 -0
  51. package/dist/esm/resources/classes/erxV2.js +24 -0
  52. package/dist/esm/resources/classes/erxV2.js.map +1 -0
  53. package/dist/esm/resources/classes/index.d.ts +5 -1
  54. package/dist/esm/resources/classes/index.js +5 -1
  55. package/dist/esm/resources/classes/index.js.map +1 -1
  56. package/dist/esm/resources/classes/m2m.d.ts +2 -2
  57. package/dist/esm/resources/classes/m2m.js +1 -1
  58. package/dist/esm/resources/classes/m2m.js.map +1 -1
  59. package/dist/esm/resources/classes/user.d.ts +2 -2
  60. package/dist/esm/resources/classes/user.js +1 -1
  61. package/dist/esm/resources/classes/user.js.map +1 -1
  62. package/dist/esm/resources/types/ErxCheckAllergyInteractionsParams.d.ts +3 -0
  63. package/dist/esm/resources/types/ErxCheckAllergyInteractionsResponse.d.ts +9 -0
  64. package/dist/esm/resources/types/ErxCheckMedicationInteractionsParams.d.ts +3 -0
  65. package/dist/esm/resources/types/ErxCheckMedicationInteractionsResponse.d.ts +21 -0
  66. package/dist/esm/resources/types/ErxCheckPrecheckInteractionsParams.d.ts +4 -0
  67. package/dist/esm/resources/types/ErxCheckPrecheckInteractionsResponse.d.ts +29 -0
  68. package/dist/esm/resources/types/ErxConnectPractitionerParams.d.ts +4 -0
  69. package/dist/esm/resources/types/ErxConnectPractitionerResponse.d.ts +9 -0
  70. package/dist/esm/resources/types/ErxSearchAllergensParams.d.ts +3 -0
  71. package/dist/esm/resources/types/ErxSearchAllergensResponse.d.ts +21 -0
  72. package/dist/esm/resources/types/ErxSearchMedicationsParams.d.ts +3 -0
  73. package/dist/esm/resources/types/ErxSearchMedicationsResponse.d.ts +27 -0
  74. package/dist/esm/resources/types/ErxV1AllergySearchParams.d.ts +3 -0
  75. package/dist/{cjs/resources/types/ErxAllergySearchResponse.d.ts → esm/resources/types/ErxV1AllergySearchResponse.d.ts} +1 -1
  76. package/dist/{cjs/resources/types/ErxCancelOrderParams.d.ts → esm/resources/types/ErxV1CancelOrderParams.d.ts} +1 -1
  77. package/dist/{cjs/resources/types/ErxCancelOrderResponse.d.ts → esm/resources/types/ErxV1CancelOrderResponse.d.ts} +1 -1
  78. package/dist/esm/resources/types/{ErxCancelPrescriptionParams.d.ts → ErxV1CancelPrescriptionParams.d.ts} +1 -1
  79. package/dist/esm/resources/types/{ErxCancelPrescriptionResponse.d.ts → ErxV1CancelPrescriptionResponse.d.ts} +1 -1
  80. package/dist/esm/resources/types/{ErxMedicationSearchParams.d.ts → ErxV1MedicationSearchParams.d.ts} +1 -1
  81. package/dist/esm/resources/types/{ErxMedicationSearchResponse.d.ts → ErxV1MedicationSearchResponse.d.ts} +1 -1
  82. package/dist/esm/resources/types/ErxV1SyncPatientParams.d.ts +3 -0
  83. package/dist/{cjs/resources/types/ErxSyncPatientResponse.d.ts → esm/resources/types/ErxV1SyncPatientResponse.d.ts} +1 -1
  84. package/dist/esm/resources/types/ErxV2MedicationSearchParams.d.ts +4 -0
  85. package/dist/esm/resources/types/{ErxMedicationSearchV2Response.d.ts → ErxV2MedicationSearchResponse.d.ts} +1 -1
  86. package/dist/esm/resources/types/index.d.ts +25 -12
  87. package/package.json +3 -3
  88. package/src/config.ts +2 -1
  89. package/src/resources/classes/developer.ts +3 -3
  90. package/src/resources/classes/erx.ts +68 -51
  91. package/src/resources/classes/erxV1.ts +73 -0
  92. package/src/resources/classes/erxV2.ts +34 -0
  93. package/src/resources/classes/index.ts +8 -2
  94. package/src/resources/classes/m2m.ts +3 -3
  95. package/src/resources/classes/user.ts +3 -3
  96. package/src/resources/types/ErxCheckAllergyInteractionsParams.ts +5 -0
  97. package/src/resources/types/ErxCheckAllergyInteractionsResponse.ts +11 -0
  98. package/src/resources/types/ErxCheckMedicationInteractionsParams.ts +5 -0
  99. package/src/resources/types/ErxCheckMedicationInteractionsResponse.ts +23 -0
  100. package/src/resources/types/ErxCheckPrecheckInteractionsParams.ts +6 -0
  101. package/src/resources/types/ErxCheckPrecheckInteractionsResponse.ts +31 -0
  102. package/src/resources/types/ErxConnectPractitionerParams.ts +6 -0
  103. package/src/resources/types/ErxConnectPractitionerResponse.ts +11 -0
  104. package/src/resources/types/{ErxAllergySearchParams.ts → ErxSearchAllergensParams.ts} +1 -1
  105. package/src/resources/types/ErxSearchAllergensResponse.ts +28 -0
  106. package/src/resources/types/ErxSearchMedicationsParams.ts +5 -0
  107. package/src/resources/types/ErxSearchMedicationsResponse.ts +29 -0
  108. package/src/resources/types/ErxV1AllergySearchParams.ts +5 -0
  109. package/src/resources/types/{ErxAllergySearchResponse.ts → ErxV1AllergySearchResponse.ts} +1 -1
  110. package/src/resources/types/{ErxCancelOrderParams.ts → ErxV1CancelOrderParams.ts} +1 -1
  111. package/src/resources/types/{ErxCancelOrderResponse.ts → ErxV1CancelOrderResponse.ts} +1 -1
  112. package/src/resources/types/{ErxCancelPrescriptionParams.ts → ErxV1CancelPrescriptionParams.ts} +1 -1
  113. package/src/resources/types/{ErxCancelPrescriptionResponse.ts → ErxV1CancelPrescriptionResponse.ts} +1 -1
  114. package/src/resources/types/{ErxMedicationSearchParams.ts → ErxV1MedicationSearchParams.ts} +1 -1
  115. package/src/resources/types/{ErxMedicationSearchResponse.ts → ErxV1MedicationSearchResponse.ts} +1 -1
  116. package/src/resources/types/ErxV1SyncPatientParams.ts +5 -0
  117. package/src/resources/types/{ErxSyncPatientResponse.ts → ErxV1SyncPatientResponse.ts} +1 -1
  118. package/src/resources/types/{ErxMedicationSearchV2Params.ts → ErxV2MedicationSearchParams.ts} +1 -1
  119. package/src/resources/types/{ErxMedicationSearchV2Response.ts → ErxV2MedicationSearchResponse.ts} +1 -1
  120. package/src/resources/types/index.ts +25 -12
  121. package/dist/cjs/resources/types/ErxAllergySearchParams.d.ts +0 -3
  122. package/dist/cjs/resources/types/ErxMedicationSearchV2Params.d.ts +0 -4
  123. package/dist/esm/node_modules/tslib/package.json +0 -1
  124. package/dist/esm/node_modules/tslib/tslib.es6.js +0 -40
  125. package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
  126. package/dist/esm/resources/types/ErxAllergySearchParams.d.ts +0 -3
  127. package/dist/esm/resources/types/ErxMedicationSearchV2Params.d.ts +0 -4
@@ -1,2 +1,2 @@
1
- import{v4 as t}from"uuid";class e extends Error{constructor({message:t,code:i,cause:s}){super(t,{cause:s}),Object.setPrototypeOf(this,e.prototype),this.code=i,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function i(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 s extends e{constructor({error:t,code:e}){super({message:i(t),code:e}),Object.setPrototypeOf(this,s.prototype),this.cause=t,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function r(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{c(s.next(t))}catch(t){n(t)}}function u(t){try{c(s.throw(t))}catch(t){n(t)}}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 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;const o=[408,429,500,502,503,504],u=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class c{constructor(t){this.config=t}request(t,i,s){return(n,o)=>r(this,void 0,void 0,(function*(){const r=()=>this.config;try{return yield h(s,r,t,i)(n,o)}catch(t){const i=t;throw new e({message:i.message,code:i.code,cause:i.cause})}}))}fhirRequest(t,i){return(n,o)=>r(this,void 0,void 0,(function*(){try{const e=()=>{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"},s=()=>this.config;return yield h(e,s,t,i)(n,o)}catch(t){const i=t;if("string"==typeof i.message)throw new e({message:i.message,code:i.code,cause:i.cause});throw new s({error:i.message,code:i.code})}}))}}function a(t){return"accessToken"in t}function h(i,s,n,c){return(h,l)=>r(this,void 0,void 0,(function*(){var p,v,m,f,g,b,y,j,q,w,S,U,k,x,O;const T=h&&!l&&!Array.isArray(h)&&a(h)?{}:null!==(p=h)&&void 0!==p?p:{},E=h&&!l&&!Array.isArray(h)&&a(h)?h:l,z=c.toLowerCase(),A=s(),R=null!==(v=A.fetch)&&void 0!==v?v:fetch,P=null!==(m=null==E?void 0:E.accessToken)&&void 0!==m?m:A.accessToken,N=null!==(f=null==E?void 0:E.projectId)&&void 0!==f?f:s().projectId;let I=n,W=T;if(!Array.isArray(T)){const[t,i]=function(t,i){const s=Object.assign({},i),r=t.replace(/\{([^}]+)\}/g,((t,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new e({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s),o=n.length?n.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{};return[r,o]}(n,T);I=t,W=i}I=I.replace(/^\//,"");const $=i(),C=$.endsWith("/")?$:$+"/",_=new URL(I,C);let L;if(Array.isArray(W))L=JSON.stringify(W);else if(Object.keys(W).length)if("get"===z)d(W,_.searchParams);else if("application/x-www-form-urlencoded"===(null==E?void 0:E.contentType)){const t=new URLSearchParams;d(W,t),L=t.toString()}else L=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==E?void 0:E.contentType)&&"post"===z&&(L="{}");const M=Object.assign(N?{"x-zapehr-project-id":N,"x-oystehr-project-id":N}:{},{"content-type":null!==(g=null==E?void 0:E.contentType)&&void 0!==g?g:"application/json"},P?{Authorization:`Bearer ${P}`}:{},(null==E?void 0:E.ifMatch)?{"If-Match":E.ifMatch}:{},{"x-oystehr-request-id":null!==(b=null==E?void 0:E.requestId)&&void 0!==b?b:t()}),D={retries:null!==(j=null===(y=A.retry)||void 0===y?void 0:y.retries)&&void 0!==j?j:3,jitter:null!==(w=null===(q=A.retry)||void 0===q?void 0:q.jitter)&&void 0!==w?w:20,delay:null!==(U=null===(S=A.retry)||void 0===S?void 0:S.delay)&&void 0!==U?U: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:[],...o]};return D.retryOn.push(...o),function(t,e){var i,s;return r(this,void 0,void 0,(function*(){let r;for(const n of Array.from({length:(null!==(i=e.retries)&&void 0!==i?i:0)+1},((t,e)=>e)))try{return yield t(n)}catch(t){let i=!1;if("response"in t){const s=t;i=e.retryOn.includes(s.code),r={message:t.message,code:t.code}}else if(r=t,"code"in t&&"string"==typeof t.code){const e=t;i=u.includes(e.code)}if(!i)break;const o=Math.floor(Math.random()*(e.jitter+1));yield new Promise((t=>setTimeout(t,e.delay+o))),e.onRetry&&n!==(null!==(s=e.retries)&&void 0!==s?s:0)&&e.onRetry(n+1)}throw r}))}((()=>r(this,void 0,void 0,(function*(){var t,e,i,s,r,n,o,u,c,a;const h=yield R(new Request(_,{method:z.toUpperCase(),body:L,headers:M})),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(t){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 d(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 l,p,v,m;class f extends c{constructor(t){super(t),l.add(this)}list(t){return this.request("/application","get",n(this,l,"m",p).bind(this))(t)}create(t,e){return this.request("/application","post",n(this,l,"m",p).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",n(this,l,"m",p).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",n(this,l,"m",p).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",n(this,l,"m",p).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",n(this,l,"m",p).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",n(this,l,"m",p).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",n(this,l,"m",p).bind(this))(t,e)}}l=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 g extends c{constructor(t){super(t),v.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",n(this,v,"m",m).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",n(this,v,"m",m).bind(this))(t,e)}}v=new WeakSet,m=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 b="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",y="addressString";function j(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===b));if(!(null==r?void 0:r.extension))return;return null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===y)))||void 0===s?void 0:s.valueString}var q,w,S,U,k,x,O,T;class E extends c{constructor(t){super(t),q.add(this),this.ENCOUNTER_VS_EXTENSION_URL=b,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=y,this.getConversationIdFromEncounter=j}create(t,e){return this.request("/messaging/conversation","post",n(this,q,"m",w).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",n(this,q,"m",w).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",n(this,q,"m",w).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",n(this,q,"m",w).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",n(this,q,"m",w).bind(this))(t,e)}}q=new WeakSet,w=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 c{constructor(t){super(t),S.add(this)}get(t,e){return this.request("/developer/{id}","get",n(this,S,"m",U).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",n(this,S,"m",U).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",n(this,S,"m",U).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",n(this,S,"m",U).bind(this))(t,e)}list(t){return this.request("/developer","get",n(this,S,"m",U).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",n(this,S,"m",U).bind(this))(t,e)}}S=new WeakSet,U=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class A extends c{constructor(t){super(t),k.add(this)}syncPatient(t,e){return this.request("/erx/sync-patient/{patientId}","post",n(this,k,"m",x).bind(this))(t,e)}allergySearch(t,e){return this.request("/erx/allergy/search","get",n(this,k,"m",x).bind(this))(t,e)}cancelOrder(t,e){return this.request("/erx/cancel-order","post",n(this,k,"m",x).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/erx/cancel-prescription","post",n(this,k,"m",x).bind(this))(t,e)}medicationSearch(t,e){return this.request("/erx/medication/search","get",n(this,k,"m",x).bind(this))(t,e)}medicationSearchV2(t,e){return this.request("/erx/v2/medication/search","get",n(this,k,"m",x).bind(this))(t,e)}}k=new WeakSet,x=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 c{constructor(t){super(t),O.add(this)}offboard(t){return this.request("/offboard","post",n(this,O,"m",T).bind(this))(t)}onboard(t){return this.request("/onboard","post",n(this,O,"m",T).bind(this))(t)}send(t,e){return this.request("/send","post",n(this,O,"m",T).bind(this))(t,e)}}function P(t,e){return r(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 N(t,e){return r(this,void 0,void 0,(function*(){const{resourceType:i}=t;return this.fhirRequest(`/${i}`,"POST")(t,e)}))}function I({resourceType:t,id:e},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}`,"GET")({},i)}))}function W(t,e){return r(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 $({resourceType:t,id:e,operations:i},s){return r(this,void 0,void 0,(function*(){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 C({resourceType:t,id:e},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function _({resourceType:t,id:e,versionId:i},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}/_history${i?`/${i}`:""}`,"GET")({},s)}))}function L(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;d(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 M(t){return function(e,i){return r(this,void 0,void 0,(function*(){return this.fhirRequest("/","POST")({resourceType:"Bundle",type:t,entry:e.requests.map(L)},i)}))}}O=new WeakSet,T=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 D=M("batch"),V=M("transaction");function F(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 H(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 B,G,J,X,Z,K,Q,Y,tt,et,it,st,rt,nt,ot,ut,ct,at,ht,dt,lt,pt,vt,mt,ft,gt,bt,yt,jt,qt,wt;class St extends c{constructor(t){super(t),B.add(this),this.search=P,this.create=N,this.get=I,this.update=W,this.patch=$,this.delete=C,this.history=_,this.batch=D,this.transaction=V,this.formatAddress=F,this.formatHumanName=H}}B=new WeakSet;class Ut extends c{constructor(t){super(t),G.add(this)}routeList(t){return this.request("/route","get",n(this,G,"m",J).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",n(this,G,"m",J).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",n(this,G,"m",J).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",n(this,G,"m",J).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",n(this,G,"m",J).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",n(this,G,"m",J).bind(this))(t,e)}}G=new WeakSet,J=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 kt extends c{constructor(t){super(t),X.add(this)}list(t){return this.request("/m2m","get",n(this,X,"m",Z).bind(this))(t)}create(t,e){return this.request("/m2m","post",n(this,X,"m",Z).bind(this))(t,e)}get(t,e){return this.request("/m2m/{id}","get",n(this,X,"m",Z).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",n(this,X,"m",Z).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",n(this,X,"m",Z).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",n(this,X,"m",Z).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",n(this,X,"m",Z).bind(this))(t,e)}}X=new WeakSet,Z=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class xt extends c{constructor(t){super(t),K.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",n(this,K,"m",Q).bind(this))(t)}}K=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"};class Ot extends c{constructor(t){super(t),Y.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",n(this,Y,"m",tt).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",n(this,Y,"m",tt).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",n(this,Y,"m",tt).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",n(this,Y,"m",tt).bind(this))(t,e)}}Y=new WeakSet,tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Tt extends c{constructor(t){super(t),et.add(this)}get(t){return this.request("/project","get",n(this,et,"m",it).bind(this))(t)}update(t,e){return this.request("/project","patch",n(this,et,"m",it).bind(this))(t,e)}}et=new WeakSet,it=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Et extends c{constructor(t){super(t),st.add(this)}eligibilityCheck(t,e){return this.request("/rcm/eligibility-check","post",n(this,st,"m",rt).bind(this))(t,e)}validateProfessionalClaim(t,e){return this.request("/rcm/professional-claim/validate","post",n(this,st,"m",rt).bind(this))(t,e)}submitProfessionalClaim(t,e){return this.request("/rcm/professional-claim/submit","post",n(this,st,"m",rt).bind(this))(t,e)}}st=new WeakSet,rt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class zt extends c{constructor(t){super(t),nt.add(this)}list(t){return this.request("/iam/role","get",n(this,nt,"m",ot).bind(this))(t)}create(t,e){return this.request("/iam/role","post",n(this,nt,"m",ot).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",n(this,nt,"m",ot).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",n(this,nt,"m",ot).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",n(this,nt,"m",ot).bind(this))(t,e)}}nt=new WeakSet,ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class At extends c{constructor(t){super(t),ut.add(this)}list(t){return this.request("/secret","get",n(this,ut,"m",ct).bind(this))(t)}set(t,e){return this.request("/secret","post",n(this,ut,"m",ct).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",n(this,ut,"m",ct).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",n(this,ut,"m",ct).bind(this))(t,e)}}ut=new WeakSet,ct=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Rt extends c{constructor(t){super(t),at.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",n(this,at,"m",ht).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",n(this,at,"m",ht).bind(this))(t,e)}}at=new WeakSet,ht=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Pt extends c{constructor(t){super(t),dt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",n(this,dt,"m",lt).bind(this))(t,e)}}dt=new WeakSet,lt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Nt extends c{constructor(t){super(t),pt.add(this)}me(t){return this.request("/user/me","get",n(this,pt,"m",vt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",n(this,pt,"m",vt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",n(this,pt,"m",vt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",n(this,pt,"m",vt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",n(this,pt,"m",vt).bind(this))(t,e)}list(t){return this.request("/user","get",n(this,pt,"m",vt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",n(this,pt,"m",vt).bind(this))(t,e)}}pt=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 It extends c{constructor(t){super(t),mt.add(this)}get(t){return this.request("/version","get",n(this,mt,"m",ft).bind(this))(t)}}function Wt(){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 $t({bucketName:t,"objectPath+":e,file:i}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Wt.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function Ct({bucketName:t,"objectPath+":e}){return r(this,void 0,void 0,(function*(){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Wt.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 _t(t){var i,s;return r(this,void 0,void 0,(function*(){let r,n;const o=new URL(t.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 e({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",Wt.bind(this))(u)}))}mt=new WeakSet,ft=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 c{constructor(t){super(t),gt.add(this),this.uploadFile=$t,this.downloadFile=Ct,this.getPresignedUrlForZ3Url=_t}listBuckets(t){return this.request("/z3","get",n(this,gt,"m",bt).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",n(this,gt,"m",bt).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",n(this,gt,"m",bt).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",n(this,gt,"m",bt).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",n(this,gt,"m",bt).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",n(this,gt,"m",bt).bind(this))(t,e)}}function Mt(){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 Dt({id:t,file:e,filename:i}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/zambda/{id}/s3-upload","post",Mt.bind(this))({id:t,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:e})}))}gt=new WeakSet,bt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Vt extends c{constructor(t){super(t),yt.add(this),this.uploadFile=Dt}list(t){return this.request("/zambda","get",n(this,yt,"m",jt).bind(this))(t)}create(t,e){return this.request("/zambda","post",n(this,yt,"m",jt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",n(this,yt,"m",jt).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",n(this,yt,"m",jt).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",n(this,yt,"m",jt).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",n(this,yt,"m",jt).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",n(this,yt,"m",jt).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",n(this,yt,"m",jt).bind(this))(t,e)}}yt=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 c{constructor(t){super(t),qt.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",n(this,qt,"m",wt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",n(this,qt,"m",wt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",n(this,qt,"m",wt).bind(this))(t,e)}}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"};let Ht=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 f(t),this.developer=new z(t),this.m2m=new kt(t),this.messaging=new xt(t),this.conversation=new E(t),this.transactionalSMS=new Pt(t),this.paymentMethod=new Ot(t),this.charge=new g(t),this.project=new Tt(t),this.rcm=new Et(t),this.erx=new A(t),this.role=new zt(t),this.secret=new At(t),this.telemed=new Rt(t),this.user=new Nt(t),this.version=new It(t),this.z3=new Lt(t),this.zambda=new Vt(t),this.zambdaLogStream=new Ft(t),this.fax=new R(t),this.lab=new Ut(t),this.fhir=new St(t)}};class Bt extends Ht{}Bt.OystehrFHIRError=s,Bt.OystehrSdkError=e;export{Bt as default};
1
+ import{v4 as t}from"uuid";class e extends Error{constructor({message:t,code:i,cause:s}){super(t,{cause:s}),Object.setPrototypeOf(this,e.prototype),this.code=i,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function i(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 s extends e{constructor({error:t,code:e}){super({message:i(t),code:e}),Object.setPrototypeOf(this,s.prototype),this.cause=t,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function r(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{c(s.next(t))}catch(t){n(t)}}function u(t){try{c(s.throw(t))}catch(t){n(t)}}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 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;const o=[408,429,500,502,503,504],u=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class c{constructor(t){this.config=t}request(t,i,s){return(n,o)=>r(this,void 0,void 0,(function*(){const r=()=>this.config;try{return yield a(s,r,t,i)(n,o)}catch(t){const i=t;throw new e({message:i.message,code:i.code,cause:i.cause})}}))}fhirRequest(t,i){return(n,o)=>r(this,void 0,void 0,(function*(){try{const e=()=>{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"},s=()=>this.config;return yield a(e,s,t,i)(n,o)}catch(t){const i=t;if("string"==typeof i.message)throw new e({message:i.message,code:i.code,cause:i.cause});throw new s({error:i.message,code:i.code})}}))}}function h(t){return"accessToken"in t}function a(i,s,n,c){return(a,l)=>r(this,void 0,void 0,(function*(){var p,v,m,f,g,b,y,q,j,w,k,S,x,U,O;const T=a&&!l&&!Array.isArray(a)&&h(a)?{}:null!==(p=a)&&void 0!==p?p:{},z=a&&!l&&!Array.isArray(a)&&h(a)?a:l,E=c.toLowerCase(),A=s(),P=null!==(v=A.fetch)&&void 0!==v?v:fetch,I=null!==(m=null==z?void 0:z.accessToken)&&void 0!==m?m:A.accessToken,R=null!==(f=null==z?void 0:z.projectId)&&void 0!==f?f:s().projectId;let N=n,W=T;if(!Array.isArray(T)){const[t,i]=function(t,i){const s=Object.assign({},i),r=t.replace(/\{([^}]+)\}/g,((t,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new e({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s),o=n.length?n.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{};return[r,o]}(n,T);N=t,W=i}N=N.replace(/^\//,"");const $=i(),C=$.endsWith("/")?$:$+"/",_=new URL(N,C);let L;if(Array.isArray(W))L=JSON.stringify(W);else if(Object.keys(W).length)if("get"===E)d(W,_.searchParams);else if("application/x-www-form-urlencoded"===(null==z?void 0:z.contentType)){const t=new URLSearchParams;d(W,t),L=t.toString()}else L=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==z?void 0:z.contentType)&&"post"===E&&(L="{}");const M=Object.assign(R?{"x-zapehr-project-id":R,"x-oystehr-project-id":R}:{},{"content-type":null!==(g=null==z?void 0:z.contentType)&&void 0!==g?g:"application/json"},I?{Authorization:`Bearer ${I}`}:{},(null==z?void 0:z.ifMatch)?{"If-Match":z.ifMatch}:{},{"x-oystehr-request-id":null!==(b=null==z?void 0:z.requestId)&&void 0!==b?b:t()}),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===(k=A.retry)||void 0===k?void 0:k.delay)&&void 0!==S?S:100,onRetry:null===(x=A.retry)||void 0===x?void 0:x.onRetry,retryOn:[...null!==(O=null===(U=A.retry)||void 0===U?void 0:U.retryOn)&&void 0!==O?O:[],...o]};return D.retryOn.push(...o),function(t,e){var i,s;return r(this,void 0,void 0,(function*(){let r;for(const n of Array.from({length:(null!==(i=e.retries)&&void 0!==i?i:0)+1},((t,e)=>e)))try{return yield t(n)}catch(t){let i=!1;if("response"in t){const s=t;i=e.retryOn.includes(s.code),r={message:t.message,code:t.code}}else if(r=t,"code"in t&&"string"==typeof t.code){const e=t;i=u.includes(e.code)}if(!i)break;const o=Math.floor(Math.random()*(e.jitter+1));yield new Promise((t=>setTimeout(t,e.delay+o))),e.onRetry&&n!==(null!==(s=e.retries)&&void 0!==s?s:0)&&e.onRetry(n+1)}throw r}))}((()=>r(this,void 0,void 0,(function*(){var t,e,i,s,r,n,o,u,c,h;const a=yield P(new Request(_,{method:E.toUpperCase(),body:L,headers:M})),d=a.body?yield a.text():null;let l;try{l=d&&((null===(t=a.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))||(null===(e=a.headers.get("content-type"))||void 0===e?void 0:e.includes("application/fhir+json")))?JSON.parse(d):null}catch(t){l=null}if(!a.ok||a.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:a.statusText,code:null!==(h=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!==h?h:a.status,response:a}}return l}))),D)}))}function d(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 l,p,v,m;class f extends c{constructor(t){super(t),l.add(this)}list(t){return this.request("/application","get",n(this,l,"m",p).bind(this))(t)}create(t,e){return this.request("/application","post",n(this,l,"m",p).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",n(this,l,"m",p).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",n(this,l,"m",p).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",n(this,l,"m",p).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",n(this,l,"m",p).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",n(this,l,"m",p).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",n(this,l,"m",p).bind(this))(t,e)}}l=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 g extends c{constructor(t){super(t),v.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",n(this,v,"m",m).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",n(this,v,"m",m).bind(this))(t,e)}}v=new WeakSet,m=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 b="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",y="addressString";function q(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===b));if(!(null==r?void 0:r.extension))return;return null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===y)))||void 0===s?void 0:s.valueString}var j,w,k,S,x,U,O,T,z,E,A,P;class I extends c{constructor(t){super(t),j.add(this),this.ENCOUNTER_VS_EXTENSION_URL=b,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=y,this.getConversationIdFromEncounter=q}create(t,e){return this.request("/messaging/conversation","post",n(this,j,"m",w).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",n(this,j,"m",w).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",n(this,j,"m",w).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",n(this,j,"m",w).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",n(this,j,"m",w).bind(this))(t,e)}}j=new WeakSet,w=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 c{constructor(t){super(t),k.add(this)}get(t,e){return this.request("/developer/{id}","get",n(this,k,"m",S).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",n(this,k,"m",S).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",n(this,k,"m",S).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",n(this,k,"m",S).bind(this))(t,e)}list(t){return this.request("/developer","get",n(this,k,"m",S).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",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 N extends c{constructor(t){super(t),x.add(this)}searchAllergens(t,e){return this.request("/allergen","get",n(this,x,"m",U).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",n(this,x,"m",U).bind(this))(t,e)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",n(this,x,"m",U).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",n(this,x,"m",U).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",n(this,x,"m",U).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",n(this,x,"m",U).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",n(this,x,"m",U).bind(this))(t,e)}}x=new WeakSet,U=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 W extends c{constructor(t){super(t),O.add(this)}syncPatient(t,e){return this.request("/erx/sync-patient/{patientId}","post",n(this,O,"m",T).bind(this))(t,e)}allergySearch(t,e){return this.request("/erx/allergy/search","get",n(this,O,"m",T).bind(this))(t,e)}cancelOrder(t,e){return this.request("/erx/cancel-order","post",n(this,O,"m",T).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/erx/cancel-prescription","post",n(this,O,"m",T).bind(this))(t,e)}medicationSearch(t,e){return this.request("/erx/medication/search","get",n(this,O,"m",T).bind(this))(t,e)}}O=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 c{constructor(t){super(t),z.add(this)}medicationSearch(t,e){return this.request("/erx/v2/medication/search","get",n(this,z,"m",E).bind(this))(t,e)}}z=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 C extends c{constructor(t){super(t),A.add(this)}offboard(t){return this.request("/offboard","post",n(this,A,"m",P).bind(this))(t)}onboard(t){return this.request("/onboard","post",n(this,A,"m",P).bind(this))(t)}send(t,e){return this.request("/send","post",n(this,A,"m",P).bind(this))(t,e)}}function _(t,e){return r(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 L(t,e){return r(this,void 0,void 0,(function*(){const{resourceType:i}=t;return this.fhirRequest(`/${i}`,"POST")(t,e)}))}function M({resourceType:t,id:e},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}`,"GET")({},i)}))}function D(t,e){return r(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 V({resourceType:t,id:e,operations:i},s){return r(this,void 0,void 0,(function*(){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 F({resourceType:t,id:e},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function H({resourceType:t,id:e,versionId:i},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}/_history${i?`/${i}`:""}`,"GET")({},s)}))}function B(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;d(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 G(t){return function(e,i){return r(this,void 0,void 0,(function*(){return this.fhirRequest("/","POST")({resourceType:"Bundle",type:t,entry:e.requests.map(B)},i)}))}}A=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 J=G("batch"),X=G("transaction");function Z(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 K(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 Q,Y,tt,et,it,st,rt,nt,ot,ut,ct,ht,at,dt,lt,pt,vt,mt,ft,gt,bt,yt,qt,jt,wt,kt,St,xt,Ut,Ot,Tt;class zt extends c{constructor(t){super(t),Q.add(this),this.search=_,this.create=L,this.get=M,this.update=D,this.patch=V,this.delete=F,this.history=H,this.batch=J,this.transaction=X,this.formatAddress=Z,this.formatHumanName=K}}Q=new WeakSet;class Et extends c{constructor(t){super(t),Y.add(this)}routeList(t){return this.request("/route","get",n(this,Y,"m",tt).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",n(this,Y,"m",tt).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",n(this,Y,"m",tt).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",n(this,Y,"m",tt).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",n(this,Y,"m",tt).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",n(this,Y,"m",tt).bind(this))(t,e)}}Y=new WeakSet,tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.labApiUrl)&&void 0!==e?e:"https://labs-api.zapehr.com/v1"};class At extends c{constructor(t){super(t),et.add(this)}list(t){return this.request("/m2m","get",n(this,et,"m",it).bind(this))(t)}create(t,e){return this.request("/m2m","post",n(this,et,"m",it).bind(this))(t,e)}get(t,e){return this.request("/m2m/{id}","get",n(this,et,"m",it).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",n(this,et,"m",it).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",n(this,et,"m",it).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",n(this,et,"m",it).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",n(this,et,"m",it).bind(this))(t,e)}}et=new WeakSet,it=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Pt extends c{constructor(t){super(t),st.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",n(this,st,"m",rt).bind(this))(t)}}st=new WeakSet,rt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class It extends c{constructor(t){super(t),nt.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",n(this,nt,"m",ot).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",n(this,nt,"m",ot).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",n(this,nt,"m",ot).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",n(this,nt,"m",ot).bind(this))(t,e)}}nt=new WeakSet,ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Rt extends c{constructor(t){super(t),ut.add(this)}get(t){return this.request("/project","get",n(this,ut,"m",ct).bind(this))(t)}update(t,e){return this.request("/project","patch",n(this,ut,"m",ct).bind(this))(t,e)}}ut=new WeakSet,ct=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Nt extends c{constructor(t){super(t),ht.add(this)}eligibilityCheck(t,e){return this.request("/rcm/eligibility-check","post",n(this,ht,"m",at).bind(this))(t,e)}validateProfessionalClaim(t,e){return this.request("/rcm/professional-claim/validate","post",n(this,ht,"m",at).bind(this))(t,e)}submitProfessionalClaim(t,e){return this.request("/rcm/professional-claim/submit","post",n(this,ht,"m",at).bind(this))(t,e)}}ht=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 Wt extends c{constructor(t){super(t),dt.add(this)}list(t){return this.request("/iam/role","get",n(this,dt,"m",lt).bind(this))(t)}create(t,e){return this.request("/iam/role","post",n(this,dt,"m",lt).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",n(this,dt,"m",lt).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",n(this,dt,"m",lt).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",n(this,dt,"m",lt).bind(this))(t,e)}}dt=new WeakSet,lt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class $t extends c{constructor(t){super(t),pt.add(this)}list(t){return this.request("/secret","get",n(this,pt,"m",vt).bind(this))(t)}set(t,e){return this.request("/secret","post",n(this,pt,"m",vt).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",n(this,pt,"m",vt).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",n(this,pt,"m",vt).bind(this))(t,e)}}pt=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 Ct extends c{constructor(t){super(t),mt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",n(this,mt,"m",ft).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",n(this,mt,"m",ft).bind(this))(t,e)}}mt=new WeakSet,ft=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 c{constructor(t){super(t),gt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",n(this,gt,"m",bt).bind(this))(t,e)}}gt=new WeakSet,bt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Lt extends c{constructor(t){super(t),yt.add(this)}me(t){return this.request("/user/me","get",n(this,yt,"m",qt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",n(this,yt,"m",qt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",n(this,yt,"m",qt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",n(this,yt,"m",qt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",n(this,yt,"m",qt).bind(this))(t,e)}list(t){return this.request("/user","get",n(this,yt,"m",qt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",n(this,yt,"m",qt).bind(this))(t,e)}}yt=new WeakSet,qt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Mt extends c{constructor(t){super(t),jt.add(this)}get(t){return this.request("/version","get",n(this,jt,"m",wt).bind(this))(t)}}function Dt(){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 Vt({bucketName:t,"objectPath+":e,file:i}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Dt.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function Ft({bucketName:t,"objectPath+":e}){return r(this,void 0,void 0,(function*(){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Dt.bind(this))({action:"download",bucketName:t,"objectPath+":e}),s=yield fetch(i.signedUrl,{method:"GET"});if(!s.ok)throw new Error("Failed to download file");return s.arrayBuffer()}))}function Ht(t){var i,s;return r(this,void 0,void 0,(function*(){let r,n;const o=new URL(t.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 e({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",Dt.bind(this))(u)}))}jt=new WeakSet,wt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Bt extends c{constructor(t){super(t),kt.add(this),this.uploadFile=Vt,this.downloadFile=Ft,this.getPresignedUrlForZ3Url=Ht}listBuckets(t){return this.request("/z3","get",n(this,kt,"m",St).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",n(this,kt,"m",St).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",n(this,kt,"m",St).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",n(this,kt,"m",St).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",n(this,kt,"m",St).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",n(this,kt,"m",St).bind(this))(t,e)}}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({id:t,file:e,filename:i}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/zambda/{id}/s3-upload","post",Gt.bind(this))({id:t,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:e})}))}kt=new WeakSet,St=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Xt extends c{constructor(t){super(t),xt.add(this),this.uploadFile=Jt}list(t){return this.request("/zambda","get",n(this,xt,"m",Ut).bind(this))(t)}create(t,e){return this.request("/zambda","post",n(this,xt,"m",Ut).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",n(this,xt,"m",Ut).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",n(this,xt,"m",Ut).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",n(this,xt,"m",Ut).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",n(this,xt,"m",Ut).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",n(this,xt,"m",Ut).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",n(this,xt,"m",Ut).bind(this))(t,e)}}xt=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 Zt extends c{constructor(t){super(t),Ot.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",n(this,Ot,"m",Tt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",n(this,Ot,"m",Tt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",n(this,Ot,"m",Tt).bind(this))(t,e)}}Ot=new WeakSet,Tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};let Kt=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 f(t),this.developer=new R(t),this.m2m=new At(t),this.messaging=new Pt(t),this.conversation=new I(t),this.transactionalSMS=new _t(t),this.paymentMethod=new It(t),this.charge=new g(t),this.project=new Rt(t),this.rcm=new Nt(t),this.erxV1=new W(t),this.erxV2=new $(t),this.role=new Wt(t),this.secret=new $t(t),this.telemed=new Ct(t),this.user=new Lt(t),this.version=new Mt(t),this.z3=new Bt(t),this.zambda=new Xt(t),this.zambdaLogStream=new Zt(t),this.fax=new C(t),this.lab=new Et(t),this.erx=new N(t),this.fhir=new zt(t)}};class Qt extends Kt{}Qt.OystehrFHIRError=s,Qt.OystehrSdkError=e;export{Qt as default};
2
2
  //# sourceMappingURL=index.min.js.map