@oystehr/sdk 4.0.0-alpha.3 → 4.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cjs/index.cjs +14 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.min.cjs +1 -1
  4. package/dist/cjs/index.min.cjs.map +1 -1
  5. package/dist/cjs/resources/classes/erx.d.ts +11 -3
  6. package/dist/cjs/resources/classes/fhir-ext.d.ts +1 -1
  7. package/dist/cjs/resources/types/ErxEnrollPractitionerParams.d.ts +3 -0
  8. package/dist/cjs/resources/types/ErxUnenrollPractitionerParams.d.ts +3 -0
  9. package/dist/cjs/resources/types/ZambdaCreateParams.d.ts +8 -0
  10. package/dist/cjs/resources/types/ZambdaFunction.d.ts +8 -0
  11. package/dist/cjs/resources/types/ZambdaUpdateParams.d.ts +8 -0
  12. package/dist/cjs/resources/types/fhir.d.ts +12 -12
  13. package/dist/cjs/resources/types/index.d.ts +2 -0
  14. package/dist/esm/index.min.js +1 -1
  15. package/dist/esm/index.min.js.map +1 -1
  16. package/dist/esm/resources/classes/erx.d.ts +11 -3
  17. package/dist/esm/resources/classes/erx.js +14 -2
  18. package/dist/esm/resources/classes/erx.js.map +1 -1
  19. package/dist/esm/resources/classes/fhir-ext.d.ts +1 -1
  20. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  21. package/dist/esm/resources/types/ErxEnrollPractitionerParams.d.ts +3 -0
  22. package/dist/esm/resources/types/ErxUnenrollPractitionerParams.d.ts +3 -0
  23. package/dist/esm/resources/types/ZambdaCreateParams.d.ts +8 -0
  24. package/dist/esm/resources/types/ZambdaFunction.d.ts +8 -0
  25. package/dist/esm/resources/types/ZambdaUpdateParams.d.ts +8 -0
  26. package/dist/esm/resources/types/fhir.d.ts +12 -12
  27. package/dist/esm/resources/types/index.d.ts +2 -0
  28. package/package.json +1 -1
  29. package/src/resources/classes/erx.ts +16 -2
  30. package/src/resources/classes/fhir-ext.ts +1 -1
  31. package/src/resources/types/ErxEnrollPractitionerParams.ts +5 -0
  32. package/src/resources/types/ErxUnenrollPractitionerParams.ts +5 -0
  33. package/src/resources/types/ZambdaCreateParams.ts +8 -0
  34. package/src/resources/types/ZambdaFunction.ts +8 -0
  35. package/src/resources/types/ZambdaUpdateParams.ts +8 -0
  36. package/src/resources/types/fhir.ts +12 -12
  37. package/src/resources/types/index.ts +2 -0
  38. package/dist/esm/node_modules/tslib/package.json +0 -1
  39. package/dist/esm/node_modules/tslib/tslib.es6.js +0 -40
  40. package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
@@ -1,15 +1,15 @@
1
- import { ErxCancelPrescriptionParams, ErxCheckAllergyInteractionsParams, ErxCheckAllergyInteractionsResponse, ErxCheckMedicationInteractionsParams, ErxCheckMedicationInteractionsResponse, ErxCheckPractitionerEnrollmentParams, ErxCheckPractitionerEnrollmentResponse, ErxCheckPrecheckInteractionsParams, ErxCheckPrecheckInteractionsResponse, ErxConnectPractitionerParams, ErxConnectPractitionerResponse, ErxSearchAllergensParams, ErxSearchAllergensResponse, ErxSearchMedicationsParams, ErxSearchMedicationsResponse, ErxSyncPatientParams, OystehrClientRequest } from '../..';
1
+ import { ErxCancelPrescriptionParams, ErxCheckAllergyInteractionsParams, ErxCheckAllergyInteractionsResponse, ErxCheckMedicationInteractionsParams, ErxCheckMedicationInteractionsResponse, ErxCheckPractitionerEnrollmentParams, ErxCheckPractitionerEnrollmentResponse, ErxCheckPrecheckInteractionsParams, ErxCheckPrecheckInteractionsResponse, ErxConnectPractitionerParams, ErxConnectPractitionerResponse, ErxEnrollPractitionerParams, ErxSearchAllergensParams, ErxSearchAllergensResponse, ErxSearchMedicationsParams, ErxSearchMedicationsResponse, ErxSyncPatientParams, ErxUnenrollPractitionerParams, OystehrClientRequest } from '../..';
2
2
  import { SDKResource } from '../../client/client';
3
3
  import { OystehrConfig } from '../../config';
4
4
  export declare class Erx extends SDKResource {
5
5
  #private;
6
6
  constructor(config: OystehrConfig);
7
7
  /**
8
- * Search for allergens
8
+ * Search for allergens.
9
9
  */
10
10
  searchAllergens(params: ErxSearchAllergensParams, request?: OystehrClientRequest): Promise<ErxSearchAllergensResponse>;
11
11
  /**
12
- * Search for medications. Provide at least one of code or name filters
12
+ * Search for medications.
13
13
  */
14
14
  searchMedications(params: ErxSearchMedicationsParams, request?: OystehrClientRequest): Promise<ErxSearchMedicationsResponse>;
15
15
  /**
@@ -44,4 +44,12 @@ export declare class Erx extends SDKResource {
44
44
  * Check eRx enrollment for a practitioner.
45
45
  */
46
46
  checkPractitionerEnrollment(params: ErxCheckPractitionerEnrollmentParams, request?: OystehrClientRequest): Promise<ErxCheckPractitionerEnrollmentResponse>;
47
+ /**
48
+ * Enroll a practitioner in the eRx service.
49
+ */
50
+ enrollPractitioner(params: ErxEnrollPractitionerParams, request?: OystehrClientRequest): Promise<void>;
51
+ /**
52
+ * Unenroll a practitioner from the eRx service.
53
+ */
54
+ unenrollPractitioner(params: ErxUnenrollPractitionerParams, request?: OystehrClientRequest): Promise<void>;
47
55
  }
@@ -25,7 +25,7 @@ export interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {
25
25
  */
26
26
  export declare function search<T extends FhirResource>(this: SDKResource, params: FhirSearchParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
27
27
  export declare function create<T extends FhirResource>(this: SDKResource, params: FhirCreateParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
28
- export declare function get<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirGetParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
28
+ export declare function get<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirGetParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
29
29
  export declare function update<T extends FhirResource>(this: SDKResource, params: FhirUpdateParams<T>, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<T>>;
30
30
  export declare function patch<T extends FhirResource>(this: SDKResource, { resourceType, id, operations }: FhirPatchParams, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<T>>;
31
31
  declare function del<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirDeleteParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
@@ -0,0 +1,3 @@
1
+ export interface ErxEnrollPractitionerParams {
2
+ practitionerId: string;
3
+ }
@@ -0,0 +1,3 @@
1
+ export interface ErxUnenrollPractitionerParams {
2
+ practitionerId: string;
3
+ }
@@ -9,4 +9,12 @@ export interface ZambdaCreateParams {
9
9
  */
10
10
  triggerMethod?: 'http_auth' | 'http_open' | 'subscription' | 'cron';
11
11
  schedule?: ZambdaSchedule;
12
+ /**
13
+ * The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
14
+ */
15
+ memorySize?: number;
16
+ /**
17
+ * The timeout for the Zambda Function in seconds. If not specified, a system default (27 seconds) will be used. Min: 1s, Max: 900s (15 minutes). Note: For 'http_auth' and 'http_open' trigger methods, the timeout cannot exceed 29 seconds due to API Gateway limitations.
18
+ */
19
+ timeoutInSeconds?: number;
12
20
  }
@@ -35,4 +35,12 @@ export interface ZambdaFunction {
35
35
  */
36
36
  lastModified?: string;
37
37
  };
38
+ /**
39
+ * The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
40
+ */
41
+ memorySize?: number;
42
+ /**
43
+ * The timeout for the Zambda Function in seconds. If not specified, a system default (27 seconds) will be used. Min: 1s, Max: 900s (15 minutes). Note: For 'http_auth' and 'http_open' trigger methods, the timeout cannot exceed 29 seconds due to API Gateway limitations.
44
+ */
45
+ timeoutInSeconds?: number;
38
46
  }
@@ -13,5 +13,13 @@ export interface ZambdaUpdateParams {
13
13
  * The runtime to use for the Zambda Function. This property is optional and defaults to "nodejs20.x".
14
14
  */
15
15
  runtime?: 'nodejs18.x' | 'nodejs20.x' | 'nodejs22.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet9' | 'ruby3.3';
16
+ /**
17
+ * The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
18
+ */
19
+ memorySize?: number;
20
+ /**
21
+ * The timeout for the Zambda Function in seconds. If not specified, a system default (27 seconds) will be used. Min: 1s, Max: 900s (15 minutes). Note: For 'http_auth' and 'http_open' trigger methods, the timeout cannot exceed 29 seconds due to API Gateway limitations.
22
+ */
23
+ timeoutInSeconds?: number;
16
24
  id: string;
17
25
  }
@@ -17,31 +17,31 @@ export type SearchParam = {
17
17
  name: string;
18
18
  value: string | number;
19
19
  };
20
- export interface FhirSearchParams {
21
- resourceType: string;
20
+ export interface FhirSearchParams<T extends FhirResource> {
21
+ resourceType: T['resourceType'];
22
22
  params?: SearchParam[];
23
23
  }
24
- export interface FhirGetParams {
25
- resourceType: string;
24
+ export interface FhirGetParams<T extends FhirResource> {
25
+ resourceType: T['resourceType'];
26
26
  id: string;
27
27
  }
28
28
  export type FhirCreateParams<T extends FhirResource> = T;
29
29
  export type FhirUpdateParams<T extends FhirResource> = T;
30
- export interface FhirPatchParams {
31
- resourceType: string;
30
+ export interface FhirPatchParams<T extends FhirResource> {
31
+ resourceType: T['resourceType'];
32
32
  id: string;
33
33
  operations: Operation[];
34
34
  }
35
- export interface FhirDeleteParams {
36
- resourceType: string;
35
+ export interface FhirDeleteParams<T extends FhirResource> {
36
+ resourceType: T['resourceType'];
37
37
  id: string;
38
38
  }
39
- export interface FhirHistorySearchParams {
40
- resourceType: string;
39
+ export interface FhirHistorySearchParams<T extends FhirResource> {
40
+ resourceType: T['resourceType'];
41
41
  id: string;
42
42
  }
43
- export interface FhirHistoryGetParams {
44
- resourceType: string;
43
+ export interface FhirHistoryGetParams<T extends FhirResource> {
44
+ resourceType: T['resourceType'];
45
45
  id: string;
46
46
  versionId: string;
47
47
  }
@@ -188,3 +188,5 @@ export * from './ErxConnectPractitionerParams';
188
188
  export * from './ErxConnectPractitionerResponse';
189
189
  export * from './ErxCheckPractitionerEnrollmentParams';
190
190
  export * from './ErxCheckPractitionerEnrollmentResponse';
191
+ export * from './ErxEnrollPractitionerParams';
192
+ export * from './ErxUnenrollPractitionerParams';
@@ -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 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 E=a&&!l&&!Array.isArray(a)&&h(a)?{}:null!==(p=a)&&void 0!==p?p:{},T=a&&!l&&!Array.isArray(a)&&h(a)?a:l,z=c.toLowerCase(),A=s(),I=null!==(v=A.fetch)&&void 0!==v?v:fetch,P=null!==(m=null==T?void 0:T.accessToken)&&void 0!==m?m:A.accessToken,R=null!==(f=null==T?void 0:T.projectId)&&void 0!==f?f:s().projectId;let N=n,W=E;if(!Array.isArray(E)){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,E);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"===z)d(W,_.searchParams);else if("application/x-www-form-urlencoded"===(null==T?void 0:T.contentType)){const t=new URLSearchParams;d(W,t),L=t.toString()}else L=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==T?void 0:T.contentType)&&"post"===z&&(L="{}");const M=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: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 I(new Request(_,{method:z.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,E,T,z,A,I;class P 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)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",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)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","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",E).bind(this))(t,e)}allergySearch(t,e){return this.request("/erx/allergy/search","get",n(this,O,"m",E).bind(this))(t,e)}cancelOrder(t,e){return this.request("/erx/cancel-order","post",n(this,O,"m",E).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/erx/cancel-prescription","post",n(this,O,"m",E).bind(this))(t,e)}medicationSearch(t,e){return this.request("/erx/medication/search","get",n(this,O,"m",E).bind(this))(t,e)}}O=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 $ extends c{constructor(t){super(t),T.add(this)}medicationSearch(t,e){return this.request("/erx/v2/medication/search","get",n(this,T,"m",z).bind(this))(t,e)}}T=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 C extends c{constructor(t){super(t),A.add(this)}offboard(t){return this.request("/offboard","post",n(this,A,"m",I).bind(this))(t)}onboard(t){return this.request("/onboard","post",n(this,A,"m",I).bind(this))(t)}send(t,e){return this.request("/send","post",n(this,A,"m",I).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,I=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,Et;class Tt 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 zt 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 It 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 Pt 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",Et).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",n(this,Ot,"m",Et).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",n(this,Ot,"m",Et).bind(this))(t,e)}}Ot=new WeakSet,Et=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 It(t),this.conversation=new P(t),this.transactionalSMS=new _t(t),this.paymentMethod=new Pt(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 zt(t),this.erx=new N(t),this.fhir=new Tt(t)}};class Qt extends Kt{}Qt.OystehrFHIRError=s,Qt.OystehrSdkError=e;export{Qt 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 E=a&&!l&&!Array.isArray(a)&&h(a)?{}:null!==(p=a)&&void 0!==p?p:{},T=a&&!l&&!Array.isArray(a)&&h(a)?a:l,z=c.toLowerCase(),A=s(),I=null!==(v=A.fetch)&&void 0!==v?v:fetch,P=null!==(m=null==T?void 0:T.accessToken)&&void 0!==m?m:A.accessToken,R=null!==(f=null==T?void 0:T.projectId)&&void 0!==f?f:s().projectId;let N=n,W=E;if(!Array.isArray(E)){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,E);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"===z)d(W,_.searchParams);else if("application/x-www-form-urlencoded"===(null==T?void 0:T.contentType)){const t=new URLSearchParams;d(W,t),L=t.toString()}else L=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==T?void 0:T.contentType)&&"post"===z&&(L="{}");const M=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: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 I(new Request(_,{method:z.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,E,T,z,A,I;class P 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)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",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)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",n(this,x,"m",U).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",n(this,x,"m",U).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",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",E).bind(this))(t,e)}allergySearch(t,e){return this.request("/erx/allergy/search","get",n(this,O,"m",E).bind(this))(t,e)}cancelOrder(t,e){return this.request("/erx/cancel-order","post",n(this,O,"m",E).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/erx/cancel-prescription","post",n(this,O,"m",E).bind(this))(t,e)}medicationSearch(t,e){return this.request("/erx/medication/search","get",n(this,O,"m",E).bind(this))(t,e)}}O=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 $ extends c{constructor(t){super(t),T.add(this)}medicationSearch(t,e){return this.request("/erx/v2/medication/search","get",n(this,T,"m",z).bind(this))(t,e)}}T=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 C extends c{constructor(t){super(t),A.add(this)}offboard(t){return this.request("/offboard","post",n(this,A,"m",I).bind(this))(t)}onboard(t){return this.request("/onboard","post",n(this,A,"m",I).bind(this))(t)}send(t,e){return this.request("/send","post",n(this,A,"m",I).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,I=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,Et;class Tt 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 zt 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 It 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 Pt 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",Et).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",n(this,Ot,"m",Et).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",n(this,Ot,"m",Et).bind(this))(t,e)}}Ot=new WeakSet,Et=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 It(t),this.conversation=new P(t),this.transactionalSMS=new _t(t),this.paymentMethod=new Pt(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 zt(t),this.erx=new N(t),this.fhir=new Tt(t)}};class Qt extends Kt{}Qt.OystehrFHIRError=s,Qt.OystehrSdkError=e;export{Qt as default};
2
2
  //# sourceMappingURL=index.min.js.map