@oystehr/sdk 4.3.3 → 4.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/config.d.ts +15 -0
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.cjs +294 -19
- package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.d.ts +2 -1
- package/dist/cjs/resources/classes/fhir.cjs +1 -0
- package/dist/cjs/resources/classes/fhir.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir.d.ts +1 -0
- package/dist/cjs/resources/classes/index.cjs +7 -0
- package/dist/cjs/resources/classes/index.cjs.map +1 -1
- package/dist/cjs/resources/types/RcmListPayersParams.d.ts +4 -0
- package/dist/cjs/resources/types/RcmListPayersResponse.d.ts +9 -1
- package/dist/cjs/resources/types/TelemedCreateMeetingParams.d.ts +4 -0
- package/dist/cjs/resources/types/fhir.d.ts +16 -3
- package/dist/esm/config.d.ts +15 -0
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/fhir-ext.d.ts +2 -1
- package/dist/esm/resources/classes/fhir-ext.js +294 -20
- package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
- package/dist/esm/resources/classes/fhir.d.ts +1 -0
- package/dist/esm/resources/classes/fhir.js +2 -1
- package/dist/esm/resources/classes/fhir.js.map +1 -1
- package/dist/esm/resources/classes/index.js +7 -0
- package/dist/esm/resources/classes/index.js.map +1 -1
- package/dist/esm/resources/types/RcmListPayersParams.d.ts +4 -0
- package/dist/esm/resources/types/RcmListPayersResponse.d.ts +9 -1
- package/dist/esm/resources/types/TelemedCreateMeetingParams.d.ts +4 -0
- package/dist/esm/resources/types/fhir.d.ts +16 -3
- package/package.json +1 -1
- package/src/config.ts +16 -0
- package/src/resources/classes/fhir-ext.ts +331 -19
- package/src/resources/classes/fhir.ts +1 -0
- package/src/resources/classes/index.ts +7 -0
- package/src/resources/types/RcmListPayersParams.ts +4 -0
- package/src/resources/types/RcmListPayersResponse.ts +9 -1
- package/src/resources/types/TelemedCreateMeetingParams.ts +4 -0
- package/src/resources/types/fhir.ts +20 -0
package/README.md
CHANGED
|
@@ -381,4 +381,4 @@ If you have questions about migrating to a new version of the Oystehr SDK, check
|
|
|
381
381
|
|
|
382
382
|
## Contact
|
|
383
383
|
|
|
384
|
-
Questions? Join our [public Slack](https://
|
|
384
|
+
Questions? Join our [public Slack](https://oystehr.com/slack) or contact [support](mailto:support@oystehr.com).
|
package/dist/cjs/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Coding } from './resources/types/fhir';
|
|
1
2
|
/**
|
|
2
3
|
* Configuration for the Oystehr SDK client
|
|
3
4
|
*/
|
|
@@ -62,6 +63,20 @@ export interface OystehrConfig {
|
|
|
62
63
|
*/
|
|
63
64
|
retryOn?: number[];
|
|
64
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Optional workspace tag configuration. When set, all FHIR searches will be
|
|
68
|
+
* filtered to only return resources with this tag, and all FHIR mutations
|
|
69
|
+
* (create, update, patch) will have this tag injected automatically.
|
|
70
|
+
* Mutually exclusive with `ignoreTags`.
|
|
71
|
+
*/
|
|
72
|
+
workspaceTag?: Coding;
|
|
73
|
+
/**
|
|
74
|
+
* Optional list of tags to ignore. When set, all FHIR searches will be
|
|
75
|
+
* filtered to exclude resources matching any of these tags, and mutations
|
|
76
|
+
* will throw an error if the resource carries any of these tags.
|
|
77
|
+
* Mutually exclusive with `workspaceTag`.
|
|
78
|
+
*/
|
|
79
|
+
ignoreTags?: Coding[];
|
|
65
80
|
}
|
|
66
81
|
export declare function getConfig(): OystehrConfig;
|
|
67
82
|
export declare function setConfig(config: OystehrConfig): void;
|
package/dist/cjs/index.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t extends Error{constructor({message:e,code:i,cause:s}){super(e,{cause:s}),Object.setPrototypeOf(this,t.prototype),this.code=i,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function e(t){var e;const i=[];for(const s of null!==(e=t.issue)&&void 0!==e?e:[])s.details&&s.details.text&&i.push(s.details.text);return i.length||i.push("Unknown FHIR error"),i.join(",")}class i extends t{constructor({error:t,code:s}){super({message:e(t),code:s}),Object.setPrototypeOf(this,i.prototype),this.cause=t,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function s(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{d(s.next(t))}catch(e){n(e)}}function u(t){try{d(s.throw(t))}catch(e){n(e)}}function d(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,u)}d((s=s.apply(t,e||[])).next())}))}function r(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;const o=[];for(let ee=0;ee<256;++ee)o.push((ee+256).toString(16).slice(1));let u;const d=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};class a{constructor({level:t}){this._level=t}error(t,e={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify(Object.assign({message:t},e)))}info(t,e={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify(Object.assign({message:t},e)))}debug(t,e={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify(Object.assign({message:t},e)))}time(t,e={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify(Object.assign({message:t},e)))}timeEnd(t,e={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify(Object.assign({message:t},e)))}}const h=[408,429,500,502,503,504],l=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class p{constructor(t){this.config=t,this.logger=new a({level:this.config.logLevel})}request(e,i,r){return(n,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config,u=()=>this.logger;try{return yield v(r,s,u,e,i)(n,o)}catch(d){const e=d;throw this.logger.error(e.message,{code:e.code,cause:e.cause}),new t({message:e.message,code:e.code,cause:e.cause})}}))}fhirRequest(e,r){return(n,o)=>s(this,void 0,void 0,(function*(){try{const t=()=>{var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.fhirApiUrl)&&void 0!==e?e:"https://fhir-api.zapehr.com"},i=()=>this.config,s=()=>this.logger;return yield v(t,i,s,e,r)(n,o)}catch(s){const e=s;if("string"==typeof e.message)throw new t({message:e.message,code:e.code,cause:e.cause});throw new i({error:e.message,code:e.code})}}))}}function m(t){var e,i;return"accessToken"in t||"projectId"in t&&"string"==typeof(i=t.projectId)&&n.test(i)||"contentType"in t&&2===(null===(e=t.contentType)||void 0===e?void 0:e.split("/").length)||"requestId"in t||"ifMatch"in t&&t.ifMatch.startsWith('W/"')}function v(e,i,r,n,a){return(p,v)=>s(this,void 0,void 0,(function*(){var g,b,y,q,j,w,I,S,O,U,k,E,T,x;let[z,A]=function(t,e){var i;return[t&&!e&&!Array.isArray(t)&&m(t)?{}:null!==(i=t)&&void 0!==i?i:{},t&&!e&&!Array.isArray(t)&&m(t)?t:e]}(p,v);null!=A||(A={}),null!==(g=A.requestId)&&void 0!==g||(A.requestId=function(t){if(c.randomUUID&&!t)return c.randomUUID();const e=(t=t||{}).random??t.rng?.()??function(){if(!u){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");u=crypto.getRandomValues.bind(crypto)}return u(d)}();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(t,e=0){return(o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]).toLowerCase()}(e)}());const P=i(),R=r(),N=a.toLowerCase();R.debug("Beginning fetch",{method:N,path:n,requestId:null==A?void 0:A.requestId});const _=null!==(b=P.fetch)&&void 0!==b?b:fetch,W=null!==(y=null==A?void 0:A.accessToken)&&void 0!==y?y:P.accessToken,$=null!==(q=null==A?void 0:A.projectId)&&void 0!==q?q:P.projectId;let M=n,C=z;if(!Array.isArray(z)){const[e,i]=function(e,i){const s=Object.assign({},i),r=e.replace(/\{([^}]+)\}/g,((e,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new t({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s);return[r,n.length?n.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{}]}(n,z);M=e,C=i}R.debug("Substituted parameters in path",{method:N,path:n,requestId:null==A?void 0:A.requestId}),M=M.replace(/^\//,"");const D=e(),L=D.endsWith("/")?D:D+"/",V=new URL(M,L);let J;if(Array.isArray(C))J=JSON.stringify(C);else if(Object.keys(C).length)if("get"===N)f(C,V.searchParams);else if("application/x-www-form-urlencoded"===(null==A?void 0:A.contentType)){const t=new URLSearchParams;f(C,t),J=t.toString()}else J=JSON.stringify(C);else"application/x-www-form-urlencoded"!==(null==A?void 0:A.contentType)&&"post"===N&&(J="{}");R.debug("Prepared request body",{method:N,path:n,requestId:null==A?void 0:A.requestId});const G=Object.assign($?{"x-zapehr-project-id":$,"x-oystehr-project-id":$}:{},{"content-type":null!==(j=null==A?void 0:A.contentType)&&void 0!==j?j:"application/json"},W?{Authorization:`Bearer ${W}`}:{},(null==A?void 0:A.ifMatch)?{"If-Match":A.ifMatch}:{},{"x-oystehr-request-id":null==A?void 0:A.requestId}),H={retries:null!==(I=null===(w=P.retry)||void 0===w?void 0:w.retries)&&void 0!==I?I:3,jitter:null!==(O=null===(S=P.retry)||void 0===S?void 0:S.jitter)&&void 0!==O?O:20,delay:null!==(k=null===(U=P.retry)||void 0===U?void 0:U.delay)&&void 0!==k?k:100,onRetry:null===(E=P.retry)||void 0===E?void 0:E.onRetry,retryOn:[...null!==(x=null===(T=P.retry)||void 0===T?void 0:T.retryOn)&&void 0!==x?x:[],...h]};return H.retryOn.push(...h),function(t,e){return s(this,void 0,void 0,(function*(){var i,s;let r;for(const o of Array.from({length:(null!==(i=e.retries)&&void 0!==i?i:0)+1},((t,e)=>e)))try{return yield t()}catch(n){let t=!1;if("response"in n){const i=n;t=e.retryOn.includes(i.code),r={message:n.message,code:n.code}}else if(r=n,"code"in n&&"string"==typeof n.code){const e=n;t=l.includes(e.code)}if(!t)break;const i=Math.floor(Math.random()*(e.jitter+1));yield new Promise((t=>setTimeout(t,e.delay+i))),e.onRetry&&o!==(null!==(s=e.retries)&&void 0!==s?s:0)&&e.onRetry(o+1)}throw r}))}((()=>s(this,void 0,void 0,(function*(){var t,e,i,s,r,n,o,u;R.info("Request start",{method:N,url:V,requestId:null==A?void 0:A.requestId});const d=Date.now(),c=yield _(new Request(V,{method:N.toUpperCase(),body:J,headers:G}));R.info("Request end",{method:N,url:V,duration:Date.now()-d,requestId:null==A?void 0:A.requestId});const a=c.body?yield c.text():null;let h;const l=c.headers.get("content-type");try{a&&((null==l?void 0:l.includes("application/json"))||(null==l?void 0:l.includes("application/fhir+json")))?(R.time("Deserialized JSON response",{method:N,url:V,requestId:null==A?void 0:A.requestId}),h=JSON.parse(a),R.timeEnd("Deserialized JSON response",{method:N,url:V,requestId:null==A?void 0:A.requestId})):a&&((null==l?void 0:l.includes("application/xml"))||(null==l?void 0:l.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:V,requestId:null==A?void 0:A.requestId}),h=function(t){try{const e=t.match(/<status>(\d+)<\/status>/),i=e?parseInt(e[1],10):null,s=t.match(/<output>([\s\S]*?)<\/output>/),r=s?s[1]:null;return null===i||null===r?null:{status:i,output:r}}catch(e){return null}}(a),R.timeEnd("Deserialized XML response",{method:N,url:V,requestId:null==A?void 0:A.requestId})):h=null}catch(p){h=null}if(R.debug("Deserialized response",{method:N,url:V,requestId:null==A?void 0:A.requestId}),!c.ok||c.status>=400)throw{message:null!==(r=null!==(s=null!==(i=null!==(e="string"==typeof(null==h?void 0:h.output)?h.output:null===(t=null==h?void 0:h.output)||void 0===t?void 0:t.message)&&void 0!==e?e:null==h?void 0:h.message)&&void 0!==i?i:h)&&void 0!==s?s:a)&&void 0!==r?r:c.statusText,code:null!==(u=null!==(o=null===(n=null==h?void 0:h.output)||void 0===n?void 0:n.code)&&void 0!==o?o:null==h?void 0:h.code)&&void 0!==u?u:c.status,response:c};return h}))),H)}))}function f(t,e){for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>e.append(i,t))):e.append(i,s)}var g,b,y,q;class j extends p{constructor(t){super(t),g.add(this)}list(t){return this.request("/application","get",r(this,g,"m",b).bind(this))(t)}create(t,e){return this.request("/application","post",r(this,g,"m",b).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",r(this,g,"m",b).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",r(this,g,"m",b).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",r(this,g,"m",b).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",r(this,g,"m",b).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",r(this,g,"m",b).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",r(this,g,"m",b).bind(this))(t,e)}}g=new WeakSet,b=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class w extends p{constructor(t){super(t),y.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",r(this,y,"m",q).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",r(this,y,"m",q).bind(this))(t,e)}}y=new WeakSet,q=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};const I="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",S="addressString";function O(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===I));return(null==r?void 0:r.extension)?null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===S)))||void 0===s?void 0:s.valueString:void 0}var U,k,E,T,x,z,A,P;class R extends p{constructor(t){super(t),U.add(this),this.ENCOUNTER_VS_EXTENSION_URL=I,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=S,this.getConversationIdFromEncounter=O}create(t,e){return this.request("/messaging/conversation","post",r(this,U,"m",k).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",r(this,U,"m",k).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,U,"m",k).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,U,"m",k).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,U,"m",k).bind(this))(t,e)}}U=new WeakSet,k=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 p{constructor(t){super(t),E.add(this)}get(t,e){return this.request("/developer/{id}","get",r(this,E,"m",T).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",r(this,E,"m",T).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",r(this,E,"m",T).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",r(this,E,"m",T).bind(this))(t,e)}list(t){return this.request("/developer","get",r(this,E,"m",T).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",r(this,E,"m",T).bind(this))(t,e)}}E=new WeakSet,T=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class _ extends p{constructor(t){super(t),x.add(this)}searchAllergens(t,e){return this.request("/allergen","get",r(this,x,"m",z).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",r(this,x,"m",z).bind(this))(t,e)}getMedication(t,e){return this.request("/medication/details","get",r(this,x,"m",z).bind(this))(t,e)}getConfiguration(t){return this.request("/config","get",r(this,x,"m",z).bind(this))(t)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",r(this,x,"m",z).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",r(this,x,"m",z).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",r(this,x,"m",z).bind(this))(t,e)}getMedicationHistory(t,e){return this.request("/patient/{patientId}/medication-history","get",r(this,x,"m",z).bind(this))(t,e)}addPatientPharmacy(t,e){return this.request("/patient/{patientId}/pharmacies","post",r(this,x,"m",z).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",r(this,x,"m",z).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",r(this,x,"m",z).bind(this))(t,e)}searchPharmacies(t,e){return this.request("/pharmacy","get",r(this,x,"m",z).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",r(this,x,"m",z).bind(this))(t,e)}checkPractitionerEnrollment(t,e){return this.request("/practitioner/{practitionerId}","get",r(this,x,"m",z).bind(this))(t,e)}enrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","post",r(this,x,"m",z).bind(this))(t,e)}unenrollPractitioner(t,e){return this.request("/practitioner/{practitionerId}","delete",r(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.erxApiUrl)&&void 0!==e?e:"https://erx-api.zapehr.com/v3"};class W extends p{constructor(t){super(t),A.add(this)}offboard(t){return this.request("/offboard","post",r(this,A,"m",P).bind(this))(t)}onboard(t){return this.request("/onboard","post",r(this,A,"m",P).bind(this))(t)}getConfiguration(t){return this.request("/config","get",r(this,A,"m",P).bind(this))(t)}send(t,e){return this.request("/send","post",r(this,A,"m",P).bind(this))(t,e)}}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 $=65535;function M(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i,params:s}=t;let r;s&&(r=Object.entries(s).reduce(((t,[e,i])=>(t[i.name]||(t[i.name]=[]),t[i.name].push(i.value),t)),{}));const n=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var t,e;return null!==(e=null===(t=this.entry)||void 0===t?void 0:t.map((t=>t.resource)).filter((t=>void 0!==t)))&&void 0!==e?e:[]}})}))}function C(t,e){return s(this,void 0,void 0,(function*(){const{resourceType:i}=t;return this.fhirRequest(`/${i}`,"POST")(t,e)}))}function D(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"GET")({},i)}))}function L(t,e){return s(this,void 0,void 0,(function*(){const{id:i,resourceType:s}=t;return this.fhirRequest(`/${s}/${i}`,"PUT")(t,Object.assign(Object.assign({},e),{ifMatch:(null==e?void 0:e.optimisticLockingVersionId)?`W/"${e.optimisticLockingVersionId}"`:void 0}))}))}function V(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,operations:i},s){return this.fhirRequest(`/${t}/${e}`,"PATCH")(i,Object.assign(Object.assign({},s),{contentType:"application/json-patch+json",ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0}))}))}function J(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e},i){return this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function G(t,e){return s(this,arguments,void 0,(function*({resourceType:t,id:e,versionId:i,count:s,offset:r},n){return i?this.fhirRequest(`/${t}/${e}/_history/${i}`,"GET")({},n):s?this.fhirRequest(`/${t}/${e}/_history?_total=accurate&_count=${s}\n ${r?`&_offset=${r}`:""}`,"GET")({},n):this.fhirRequest(`/${t}/${e}/_history?_total=accurate`,"GET")({},n)}))}function H(t){const{method:e,url:i}=t,s={request:{method:e,url:i}};if(i.split("?").length>1){const[t,e]=i.split("?"),r=e.split("&").map((t=>{const[e,i]=t.split("=");return{name:e,value:i}})).reduce(((t,{name:e,value:i})=>e?(t[e]||(t[e]=[]),t[e].push(i),t):t),{}),n=new URLSearchParams;f(r,n),s.request.url=`${t}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(e))return s;if("PUT"===e){const{resource:e}=t;return{request:Object.assign(Object.assign({},s.request),{ifMatch:t.ifMatch}),resource:e}}if("PATCH"===e){if("resource"in t)return{request:Object.assign(Object.assign({},s.request),{ifMatch:t.ifMatch}),resource:t.resource};const e=function(t){const e=(new globalThis.TextEncoder).encode(t);let i="";for(let s=0;s<e.length;s+=$){const t=e.subarray(s,s+$);i+=globalThis.btoa(String.fromCodePoint.apply(void 0,t))}return i}(JSON.stringify(t.operations));return Object.assign(Object.assign({},s),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:e}})}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 F(t,e){return s(this,void 0,void 0,(function*(){const i=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:t.requests.map(H)},e);return Object.assign(Object.assign({},i),{entry:i.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:[]},errors:function(){var t;return null===(t=this.entry)||void 0===t?void 0:t.filter((t=>{var e,i,s,r;return(null===(i=null===(e=t.response)||void 0===e?void 0:e.status)||void 0===i?void 0:i.startsWith("4"))||(null===(r=null===(s=t.response)||void 0===s?void 0:s.status)||void 0===r?void 0:r.startsWith("5"))})).map((t=>{var e;return null===(e=t.response)||void 0===e?void 0:e.outcome})).filter((t=>void 0!==t))}})}))}function B(t,e){return s(this,void 0,void 0,(function*(){const i=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:t.requests.map(H)},e);return Object.assign(Object.assign({},i),{entry:i.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 X(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 Z(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 K,Q,Y,tt,et,it,st,rt,nt,ot,ut,dt,ct,at,ht,lt,pt,mt,vt,ft,gt,bt,yt,qt,jt,wt,It,St,Ot,Ut,kt,Et,Tt;class xt extends p{constructor(t){super(t),K.add(this),this.search=M,this.create=C,this.get=D,this.update=L,this.patch=V,this.delete=J,this.history=G,this.batch=F,this.transaction=B,this.formatAddress=X,this.formatHumanName=Z}}K=new WeakSet;class zt extends p{constructor(t){super(t),Q.add(this)}routeList(t){return this.request("/route","get",r(this,Q,"m",Y).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",r(this,Q,"m",Y).bind(this))(t,e)}routeGet(t,e){return this.request("/route/{routeGuid}","get",r(this,Q,"m",Y).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",r(this,Q,"m",Y).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",r(this,Q,"m",Y).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,Q,"m",Y).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",r(this,Q,"m",Y).bind(this))(t,e)}}Q=new WeakSet,Y=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 p{constructor(t){super(t),tt.add(this)}list(t){return this.request("/m2m","get",r(this,tt,"m",et).bind(this))(t)}create(t,e){return this.request("/m2m","post",r(this,tt,"m",et).bind(this))(t,e)}me(t){return this.request("/m2m/me","get",r(this,tt,"m",et).bind(this))(t)}get(t,e){return this.request("/m2m/{id}","get",r(this,tt,"m",et).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",r(this,tt,"m",et).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",r(this,tt,"m",et).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",r(this,tt,"m",et).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",r(this,tt,"m",et).bind(this))(t,e)}}tt=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"};class Pt extends p{constructor(t){super(t),it.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",r(this,it,"m",st).bind(this))(t)}}it=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 Rt extends p{constructor(t){super(t),rt.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",r(this,rt,"m",nt).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",r(this,rt,"m",nt).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",r(this,rt,"m",nt).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",r(this,rt,"m",nt).bind(this))(t,e)}}rt=new WeakSet,nt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Nt extends p{constructor(t){super(t),ot.add(this)}get(t){return this.request("/project","get",r(this,ot,"m",ut).bind(this))(t)}update(t,e){return this.request("/project","patch",r(this,ot,"m",ut).bind(this))(t,e)}}ot=new WeakSet,ut=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class _t extends p{constructor(t){super(t),dt.add(this)}eligibilityCheck(t,e){return this.request("/eligibility-check","post",r(this,dt,"m",ct).bind(this))(t,e)}submitClaim(t,e){return this.request("/claim/{claimId}/submit","post",r(this,dt,"m",ct).bind(this))(t,e)}setClaimStatus(t,e){return this.request("/claim/{claimId}/status","post",r(this,dt,"m",ct).bind(this))(t,e)}listPayers(t,e){return this.request("/payer","get",r(this,dt,"m",ct).bind(this))(t,e)}getPayer(t,e){return this.request("/payer/{id}","get",r(this,dt,"m",ct).bind(this))(t,e)}}dt=new WeakSet,ct=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.rcmApiUrl)&&void 0!==e?e:"https://rcm-api.zapehr.com/v1"};class Wt extends p{constructor(t){super(t),at.add(this)}list(t){return this.request("/iam/role","get",r(this,at,"m",ht).bind(this))(t)}create(t,e){return this.request("/iam/role","post",r(this,at,"m",ht).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",r(this,at,"m",ht).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",r(this,at,"m",ht).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",r(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 $t extends p{constructor(t){super(t),lt.add(this)}list(t){return this.request("/secret","get",r(this,lt,"m",pt).bind(this))(t)}set(t,e){return this.request("/secret","post",r(this,lt,"m",pt).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",r(this,lt,"m",pt).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",r(this,lt,"m",pt).bind(this))(t,e)}}lt=new WeakSet,pt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Mt extends p{constructor(t){super(t),mt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",r(this,mt,"m",vt).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,mt,"m",vt).bind(this))(t,e)}}mt=new WeakSet,vt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Ct extends p{constructor(t){super(t),ft.add(this)}searchCpt(t,e){return this.request("/cpt/search","get",r(this,ft,"m",gt).bind(this))(t,e)}searchHcpcs(t,e){return this.request("/hcpcs/search","get",r(this,ft,"m",gt).bind(this))(t,e)}}ft=new WeakSet,gt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.terminologyApiUrl)&&void 0!==e?e:"https://terminology-api.zapehr.com/v1"};class Dt extends p{constructor(t){super(t),bt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",r(this,bt,"m",yt).bind(this))(t,e)}}bt=new WeakSet,yt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Lt extends p{constructor(t){super(t),qt.add(this)}me(t){return this.request("/user/me","get",r(this,qt,"m",jt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",r(this,qt,"m",jt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",r(this,qt,"m",jt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",r(this,qt,"m",jt).bind(this))(t,e)}resetMfa(t,e){return this.request("/user/{id}/reset-mfa","post",r(this,qt,"m",jt).bind(this))(t,e)}resetPasswordLink(t,e){return this.request("/user/{id}/reset-password-link","post",r(this,qt,"m",jt).bind(this))(t,e)}changePassword(t,e){return this.request("/user/{id}/change-password","post",r(this,qt,"m",jt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",r(this,qt,"m",jt).bind(this))(t,e)}list(t){return this.request("/user","get",r(this,qt,"m",jt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",r(this,qt,"m",jt).bind(this))(t,e)}}qt=new WeakSet,jt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Vt extends p{constructor(t){super(t),wt.add(this)}get(t){return this.request("/version","get",r(this,wt,"m",It).bind(this))(t)}}function Jt(){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 Gt(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Jt.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function Ht(t){return s(this,arguments,void 0,(function*({bucketName:t,"objectPath+":e}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Jt.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 Ft(e){return s(this,void 0,void 0,(function*(){var i,s;let r,n;const o=new URL(e.url);if("z3:"===o.protocol){const t=o.pathname.split("/").slice(1);r=o.hostname,n=t.join("/")}else{if(!o.href.startsWith(null!==(s=null===(i=this.config.services)||void 0===i?void 0:i.projectApiUrl)&&void 0!==s?s:"https://project-api.zapehr.com/v1"))throw new t({message:"Invalid Z3 URL",code:400});{const t=o.pathname.split("/").slice(3);r=t[0],n=t.slice(1).join("/")}}const u={action:"upload",bucketName:r,"objectPath+":n};return this.request("/z3/{bucketName}/{objectPath+}","post",Jt.bind(this))(u)}))}wt=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 Bt extends p{constructor(t){super(t),St.add(this),this.uploadFile=Gt,this.downloadFile=Ht,this.getPresignedUrlForZ3Url=Ft}listBuckets(t){return this.request("/z3","get",r(this,St,"m",Ot).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",r(this,St,"m",Ot).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",r(this,St,"m",Ot).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,St,"m",Ot).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,St,"m",Ot).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,St,"m",Ot).bind(this))(t,e)}}function Xt(){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 Zt(t){return s(this,arguments,void 0,(function*({id:t,file:e,filename:i}){const s=yield this.request("/zambda/{id}/s3-upload","post",Xt.bind(this))({id:t,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:e})}))}St=new WeakSet,Ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Kt extends p{constructor(t){super(t),Ut.add(this),this.uploadFile=Zt}list(t){return this.request("/zambda","get",r(this,Ut,"m",kt).bind(this))(t)}create(t,e){return this.request("/zambda","post",r(this,Ut,"m",kt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",r(this,Ut,"m",kt).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",r(this,Ut,"m",kt).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",r(this,Ut,"m",kt).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",r(this,Ut,"m",kt).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",r(this,Ut,"m",kt).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",r(this,Ut,"m",kt).bind(this))(t,e)}}Ut=new WeakSet,kt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.zambdaApiUrl)&&void 0!==e?e:"https://zambda-api.zapehr.com/v1"};class Qt extends p{constructor(t){super(t),Et.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",r(this,Et,"m",Tt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",r(this,Et,"m",Tt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",r(this,Et,"m",Tt).bind(this))(t,e)}}Et=new WeakSet,Tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.zambdaApiUrl)&&void 0!==e?e:"https://zambda-api.zapehr.com/v1"};let Yt=class{constructor(t){var e,i,s,r,n,o;this.config=t,null!==(e=(r=this.config).services)&&void 0!==e||(r.services={}),null!==(i=(n=this.config.services).projectApiUrl)&&void 0!==i||(n.projectApiUrl=t.projectApiUrl),null!==(s=(o=this.config.services).fhirApiUrl)&&void 0!==s||(o.fhirApiUrl=t.fhirApiUrl),this.application=new j(t),this.developer=new N(t),this.m2m=new At(t),this.messaging=new Pt(t),this.conversation=new R(t),this.transactionalSMS=new Dt(t),this.paymentMethod=new Rt(t),this.charge=new w(t),this.project=new Nt(t),this.role=new Wt(t),this.secret=new $t(t),this.telemed=new Mt(t),this.user=new Lt(t),this.version=new Vt(t),this.z3=new Bt(t),this.fax=new W(t),this.lab=new zt(t),this.erx=new _(t),this.terminology=new Ct(t),this.zambda=new Kt(t),this.zambdaLogStream=new Qt(t),this.rcm=new _t(t),this.fhir=new xt(t)}};class te extends Yt{}te.OystehrFHIRError=i,te.OystehrSdkError=t,exports.default=te;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class e extends Error{constructor({message:t,code:i,cause:s}){super(t,{cause:s}),Object.setPrototypeOf(this,e.prototype),this.code=i,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function t(e){var t;const i=[];for(const s of null!==(t=e.issue)&&void 0!==t?t:[])s.details&&s.details.text&&i.push(s.details.text);return i.length||i.push("Unknown FHIR error"),i.join(",")}class i extends e{constructor({error:e,code:s}){super({message:t(e),code:s}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function s(e,t,i,s){return new(i||(i=Promise))((function(r,n){function o(e){try{a(s.next(e))}catch(t){n(t)}}function u(e){try{a(s.throw(e))}catch(t){n(t)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,u)}a((s=s.apply(e,t||[])).next())}))}function r(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;const o=[];for(let dt=0;dt<256;++dt)o.push((dt+256).toString(16).slice(1));let u;const a=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};class d{constructor({level:e}){this._level=e}error(e,t={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify(Object.assign({message:e},t)))}info(e,t={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify(Object.assign({message:e},t)))}debug(e,t={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify(Object.assign({message:e},t)))}time(e,t={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify(Object.assign({message:e},t)))}timeEnd(e,t={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify(Object.assign({message:e},t)))}}const h=[408,429,500,502,503,504],l=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class p{constructor(e){this.config=e,this.logger=new d({level:this.config.logLevel})}request(t,i,r){return(n,o)=>s(this,void 0,void 0,(function*(){const s=()=>this.config,u=()=>this.logger;try{return yield m(r,s,u,t,i)(n,o)}catch(a){const t=a;throw this.logger.error(t.message,{code:t.code,cause:t.cause}),new e({message:t.message,code:t.code,cause:t.cause})}}))}fhirRequest(t,r){return(n,o)=>s(this,void 0,void 0,(function*(){try{const e=()=>{var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.fhirApiUrl)&&void 0!==t?t:"https://fhir-api.zapehr.com"},i=()=>this.config,s=()=>this.logger;return yield m(e,i,s,t,r)(n,o)}catch(s){const t=s;if("string"==typeof t.message)throw new e({message:t.message,code:t.code,cause:t.cause});throw new i({error:t.message,code:t.code})}}))}}function v(e){var t,i;return"accessToken"in e||"projectId"in e&&"string"==typeof(i=e.projectId)&&n.test(i)||"contentType"in e&&2===(null===(t=e.contentType)||void 0===t?void 0:t.split("/").length)||"requestId"in e||"ifMatch"in e&&e.ifMatch.startsWith('W/"')}function m(t,i,r,n,d){return(p,m)=>s(this,void 0,void 0,(function*(){var g,b,y,q,w,j,T,O,k,S,I,U,E,x;let[z,A]=function(e,t){var i;return[e&&!t&&!Array.isArray(e)&&v(e)?{}:null!==(i=e)&&void 0!==i?i:{},e&&!t&&!Array.isArray(e)&&v(e)?e:t]}(p,m);null!=A||(A={}),null!==(g=A.requestId)&&void 0!==g||(A.requestId=function(e){if(c.randomUUID&&!e)return c.randomUUID();const t=(e=e||{}).random??e.rng?.()??function(){if(!u){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");u=crypto.getRandomValues.bind(crypto)}return u(a)}();if(t.length<16)throw new Error("Random bytes length must be >= 16");return t[6]=15&t[6]|64,t[8]=63&t[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(t)}());const P=i(),R=r(),N=d.toLowerCase();R.debug("Beginning fetch",{method:N,path:n,requestId:null==A?void 0:A.requestId});const _=null!==(b=P.fetch)&&void 0!==b?b:fetch,$=null!==(y=null==A?void 0:A.accessToken)&&void 0!==y?y:P.accessToken,W=null!==(q=null==A?void 0:A.projectId)&&void 0!==q?q:P.projectId;let M=n,C=z;if(!Array.isArray(z)){const[t,i]=function(t,i){const s=Object.assign({},i),r=t.replace(/\{([^}]+)\}/g,((t,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new e({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s);return[r,n.length?n.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:s[t]})),{}):{}]}(n,z);M=t,C=i}R.debug("Substituted parameters in path",{method:N,path:n,requestId:null==A?void 0:A.requestId}),M=M.replace(/^\//,"");const D=t(),L=D.endsWith("/")?D:D+"/",J=new URL(M,L);let G;if(Array.isArray(C))G=JSON.stringify(C);else if(Object.keys(C).length)if("get"===N)f(C,J.searchParams);else if("application/x-www-form-urlencoded"===(null==A?void 0:A.contentType)){const e=new URLSearchParams;f(C,e),G=e.toString()}else G=JSON.stringify(C);else"application/x-www-form-urlencoded"!==(null==A?void 0:A.contentType)&&"post"===N&&(G="{}");R.debug("Prepared request body",{method:N,path:n,requestId:null==A?void 0:A.requestId});const H=Object.assign(W?{"x-zapehr-project-id":W,"x-oystehr-project-id":W}:{},{"content-type":null!==(w=null==A?void 0:A.contentType)&&void 0!==w?w:"application/json"},$?{Authorization:`Bearer ${$}`}:{},(null==A?void 0:A.ifMatch)?{"If-Match":A.ifMatch}:{},{"x-oystehr-request-id":null==A?void 0:A.requestId}),V={retries:null!==(T=null===(j=P.retry)||void 0===j?void 0:j.retries)&&void 0!==T?T:3,jitter:null!==(k=null===(O=P.retry)||void 0===O?void 0:O.jitter)&&void 0!==k?k:20,delay:null!==(I=null===(S=P.retry)||void 0===S?void 0:S.delay)&&void 0!==I?I:100,onRetry:null===(U=P.retry)||void 0===U?void 0:U.onRetry,retryOn:[...null!==(x=null===(E=P.retry)||void 0===E?void 0:E.retryOn)&&void 0!==x?x:[],...h]};return V.retryOn.push(...h),function(e,t){return s(this,void 0,void 0,(function*(){var i,s;let r;for(const o of Array.from({length:(null!==(i=t.retries)&&void 0!==i?i:0)+1},((e,t)=>t)))try{return yield e()}catch(n){let e=!1;if("response"in n){const i=n;e=t.retryOn.includes(i.code),r={message:n.message,code:n.code}}else if(r=n,"code"in n&&"string"==typeof n.code){const t=n;e=l.includes(t.code)}if(!e)break;const i=Math.floor(Math.random()*(t.jitter+1));yield new Promise((e=>setTimeout(e,t.delay+i))),t.onRetry&&o!==(null!==(s=t.retries)&&void 0!==s?s:0)&&t.onRetry(o+1)}throw r}))}((()=>s(this,void 0,void 0,(function*(){var e,t,i,s,r,n,o,u;R.info("Request start",{method:N,url:J,requestId:null==A?void 0:A.requestId});const a=Date.now(),c=yield _(new Request(J,{method:N.toUpperCase(),body:G,headers:H}));R.info("Request end",{method:N,url:J,duration:Date.now()-a,requestId:null==A?void 0:A.requestId});const d=c.body?yield c.text():null;let h;const l=c.headers.get("content-type");try{d&&((null==l?void 0:l.includes("application/json"))||(null==l?void 0:l.includes("application/fhir+json")))?(R.time("Deserialized JSON response",{method:N,url:J,requestId:null==A?void 0:A.requestId}),h=JSON.parse(d),R.timeEnd("Deserialized JSON response",{method:N,url:J,requestId:null==A?void 0:A.requestId})):d&&((null==l?void 0:l.includes("application/xml"))||(null==l?void 0:l.includes("text/xml")))?(R.time("Deserialized XML response",{method:N,url:J,requestId:null==A?void 0:A.requestId}),h=function(e){try{const t=e.match(/<status>(\d+)<\/status>/),i=t?parseInt(t[1],10):null,s=e.match(/<output>([\s\S]*?)<\/output>/),r=s?s[1]:null;return null===i||null===r?null:{status:i,output:r}}catch(t){return null}}(d),R.timeEnd("Deserialized XML response",{method:N,url:J,requestId:null==A?void 0:A.requestId})):h=null}catch(p){h=null}if(R.debug("Deserialized response",{method:N,url:J,requestId:null==A?void 0:A.requestId}),!c.ok||c.status>=400)throw{message:null!==(r=null!==(s=null!==(i=null!==(t="string"==typeof(null==h?void 0:h.output)?h.output:null===(e=null==h?void 0:h.output)||void 0===e?void 0:e.message)&&void 0!==t?t:null==h?void 0:h.message)&&void 0!==i?i:h)&&void 0!==s?s:d)&&void 0!==r?r:c.statusText,code:null!==(u=null!==(o=null===(n=null==h?void 0:h.output)||void 0===n?void 0:n.code)&&void 0!==o?o:null==h?void 0:h.code)&&void 0!==u?u:c.status,response:c};return h}))),V)}))}function f(e,t){for(const[i,s]of Object.entries(e))Array.isArray(s)?s.forEach((e=>t.append(i,e))):t.append(i,s)}var g,b,y,q;class w extends p{constructor(e){super(e),g.add(this)}list(e){return this.request("/application","get",r(this,g,"m",b).bind(this))(e)}create(e,t){return this.request("/application","post",r(this,g,"m",b).bind(this))(e,t)}get(e,t){return this.request("/application/{id}","get",r(this,g,"m",b).bind(this))(e,t)}update(e,t){return this.request("/application/{id}","patch",r(this,g,"m",b).bind(this))(e,t)}delete(e,t){return this.request("/application/{id}","delete",r(this,g,"m",b).bind(this))(e,t)}rotateSecret(e,t){return this.request("/application/{id}/rotate-secret","post",r(this,g,"m",b).bind(this))(e,t)}revokeRefreshToken(e,t){return this.request("/application/{id}/revoke-refresh-token","post",r(this,g,"m",b).bind(this))(e,t)}revokeAccessToken(e,t){return this.request("/application/{id}/revoke-access-token","post",r(this,g,"m",b).bind(this))(e,t)}}g=new WeakSet,b=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class j extends p{constructor(e){super(e),y.add(this)}issue(e,t){return this.request("/payment/charge/issue","post",r(this,y,"m",q).bind(this))(e,t)}status(e,t){return this.request("/payment/charge/status","post",r(this,y,"m",q).bind(this))(e,t)}}y=new WeakSet,q=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};const T="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",O="addressString";function k(e){var t,i,s;if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const i=null===(t=e.virtualService)||void 0===t?void 0:t.find((e=>{var t;return"https://fhir.zapehr.com/virtual-service-type"===(null===(t=e.channelType)||void 0===t?void 0:t.system)}));return null==i?void 0:i.addressString}if(!e.extension)return;const r=e.extension.find((e=>e.url===T));return(null==r?void 0:r.extension)?null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((e=>e.url===O)))||void 0===s?void 0:s.valueString:void 0}var S,I,U,E,x,z,A,P;class R extends p{constructor(e){super(e),S.add(this),this.ENCOUNTER_VS_EXTENSION_URL=T,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=O,this.getConversationIdFromEncounter=k}create(e,t){return this.request("/messaging/conversation","post",r(this,S,"m",I).bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",r(this,S,"m",I).bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",r(this,S,"m",I).bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",r(this,S,"m",I).bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",r(this,S,"m",I).bind(this))(e,t)}}S=new WeakSet,I=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class N extends p{constructor(e){super(e),U.add(this)}get(e,t){return this.request("/developer/{id}","get",r(this,U,"m",E).bind(this))(e,t)}update(e,t){return this.request("/developer/{id}","patch",r(this,U,"m",E).bind(this))(e,t)}delete(e,t){return this.request("/developer/{id}","delete",r(this,U,"m",E).bind(this))(e,t)}invite(e,t){return this.request("/developer/invite","post",r(this,U,"m",E).bind(this))(e,t)}list(e){return this.request("/developer","get",r(this,U,"m",E).bind(this))(e)}listV2(e,t){return this.request("/developer/v2/list","get",r(this,U,"m",E).bind(this))(e,t)}}U=new WeakSet,E=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class _ extends p{constructor(e){super(e),x.add(this)}searchAllergens(e,t){return this.request("/allergen","get",r(this,x,"m",z).bind(this))(e,t)}searchMedications(e,t){return this.request("/medication","get",r(this,x,"m",z).bind(this))(e,t)}getMedication(e,t){return this.request("/medication/details","get",r(this,x,"m",z).bind(this))(e,t)}getConfiguration(e){return this.request("/config","get",r(this,x,"m",z).bind(this))(e)}checkAllergyInteractions(e,t){return this.request("/patient/{patientId}/interactions/allergy","get",r(this,x,"m",z).bind(this))(e,t)}checkMedicationInteractions(e,t){return this.request("/patient/{patientId}/interactions/medication","get",r(this,x,"m",z).bind(this))(e,t)}checkPrecheckInteractions(e,t){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",r(this,x,"m",z).bind(this))(e,t)}getMedicationHistory(e,t){return this.request("/patient/{patientId}/medication-history","get",r(this,x,"m",z).bind(this))(e,t)}addPatientPharmacy(e,t){return this.request("/patient/{patientId}/pharmacies","post",r(this,x,"m",z).bind(this))(e,t)}cancelPrescription(e,t){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",r(this,x,"m",z).bind(this))(e,t)}syncPatient(e,t){return this.request("/patient/{patientId}/sync","post",r(this,x,"m",z).bind(this))(e,t)}searchPharmacies(e,t){return this.request("/pharmacy","get",r(this,x,"m",z).bind(this))(e,t)}connectPractitioner(e,t){return this.request("/practitioner/connect","get",r(this,x,"m",z).bind(this))(e,t)}checkPractitionerEnrollment(e,t){return this.request("/practitioner/{practitionerId}","get",r(this,x,"m",z).bind(this))(e,t)}enrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","post",r(this,x,"m",z).bind(this))(e,t)}unenrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","delete",r(this,x,"m",z).bind(this))(e,t)}}x=new WeakSet,z=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.erxApiUrl)&&void 0!==t?t:"https://erx-api.zapehr.com/v3"};class $ extends p{constructor(e){super(e),A.add(this)}offboard(e){return this.request("/offboard","post",r(this,A,"m",P).bind(this))(e)}onboard(e){return this.request("/onboard","post",r(this,A,"m",P).bind(this))(e)}getConfiguration(e){return this.request("/config","get",r(this,A,"m",P).bind(this))(e)}send(e,t){return this.request("/send","post",r(this,A,"m",P).bind(this))(e,t)}}A=new WeakSet,P=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.faxApiUrl)&&void 0!==t?t:"https://fax-api.zapehr.com/v1"};const W=65535;function M(e){const t=(new globalThis.TextEncoder).encode(e);let i="";for(let s=0;s<t.length;s+=W){const e=t.subarray(s,s+W);i+=globalThis.btoa(String.fromCodePoint.apply(void 0,e))}return i}function C(e){var t,i;return e.system?`${e.system}|${null!==(t=e.code)&&void 0!==t?t:""}`:null!==(i=e.code)&&void 0!==i?i:""}function D(e,t){var i,s,r,n;return(null!==(i=e.system)&&void 0!==i?i:"")===(null!==(s=t.system)&&void 0!==s?s:"")&&(null!==(r=e.code)&&void 0!==r?r:"")===(null!==(n=t.code)&&void 0!==n?n:"")}function L(t,i){var s,r,n,o,u,a,c;const d=i;if(null===(s=t.ignoreTags)||void 0===s?void 0:s.length){const s=null!==(n=null===(r=d.meta)||void 0===r?void 0:r.tag)&&void 0!==n?n:[];for(const i of t.ignoreTags)if(s.some((e=>D(e,i))))throw new e({message:`Resource has an ignored tag (system: "${null!==(o=i.system)&&void 0!==o?o:""}", code: "${null!==(u=i.code)&&void 0!==u?u:""}") and cannot be mutated in ignoreTags mode`,code:400});return i}if(t.workspaceTag){const e=t.workspaceTag,s=null!==(c=null===(a=d.meta)||void 0===a?void 0:a.tag)&&void 0!==c?c:[];if(!s.some((t=>D(t,e))))return Object.assign(Object.assign({},i),{meta:Object.assign(Object.assign({},d.meta),{tag:[...s,e]})})}return i}function J(t,i){var s,r,n;if(null===(s=t.ignoreTags)||void 0===s?void 0:s.length){for(const s of i)if("add"===s.op||"replace"===s.op||"test"===s.op){const i=s.value;if(null!=i&&"object"==typeof i){const s=i;if(void 0!==s.code)for(const i of t.ignoreTags)if(D(s,i))throw new e({message:`Patch operation contains an ignored tag (system: "${null!==(r=i.system)&&void 0!==r?r:""}", code: "${null!==(n=i.code)&&void 0!==n?n:""}") and cannot be applied in ignoreTags mode`,code:400})}}return i}if(t.workspaceTag){const e=t.workspaceTag;return i.reduce(((t,i)=>{var s;if("remove"===i.op&&"/meta/tag"===i.path)return t.push(i),t.push({op:"add",path:"/meta/tag",value:[e]}),t;if("remove"===i.op&&"/meta"===i.path)return t.push(i),t.push({op:"add",path:"/meta",value:{tag:[e]}}),t;if(("add"===i.op||"replace"===i.op)&&"/meta/tag"===i.path){const s=Array.isArray(i.value)?i.value:[];return s.some((t=>D(t,e)))?t.push(i):t.push(Object.assign(Object.assign({},i),{value:[...s,e]})),t}if(("add"===i.op||"replace"===i.op)&&"/meta"===i.path){const r=null!=i.value&&"object"==typeof i.value?i.value:{},n=null!==(s=r.tag)&&void 0!==s?s:[];return n.some((t=>D(t,e)))?t.push(i):t.push(Object.assign(Object.assign({},i),{value:Object.assign(Object.assign({},r),{tag:[...n,e]})})),t}return t.push(i),t}),[])}return i}function G(e,t){var s,r,n;const o=null!==(r=null===(s=t.meta)||void 0===s?void 0:s.tag)&&void 0!==r?r:[];if(e.workspaceTag){const t=e.workspaceTag;if(!o.some((e=>D(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}else if(null===(n=e.ignoreTags)||void 0===n?void 0:n.length)for(const u of e.ignoreTags)if(o.some((e=>D(e,u))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}function H(e,t){return s(this,void 0,void 0,(function*(){const{resourceType:i}=e,s=function(e,t){var i;const s=t?[...t]:[];if(e.workspaceTag)s.push({name:"_tag",value:C(e.workspaceTag)});else if(null===(i=e.ignoreTags)||void 0===i?void 0:i.length)for(const r of e.ignoreTags)s.push({name:"_tag:not",value:C(r)});return s}(this.config,e.params);let r;s.length&&(r=s.reduce(((e,t)=>(e[t.name]||(e[t.name]=[]),e[t.name].push(t.value),e)),{}));const n=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},t),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]}})}))}function V(e,t){return s(this,void 0,void 0,(function*(){const i=L(this.config,e),{resourceType:s}=i;return this.fhirRequest(`/${s}`,"POST")(i,t)}))}function F(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t},i){const s=yield this.fhirRequest(`/${e}/${t}`,"GET")({},i);return G(this.config,s),s}))}function B(e,t){return s(this,void 0,void 0,(function*(){const i=L(this.config,e),{id:s,resourceType:r}=i;return this.fhirRequest(`/${r}/${s}`,"PUT")(i,Object.assign(Object.assign({},t),{ifMatch:(null==t?void 0:t.optimisticLockingVersionId)?`W/"${t.optimisticLockingVersionId}"`:void 0}))}))}function X(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t,operations:i},s){const r=J(this.config,i);return this.fhirRequest(`/${e}/${t}`,"PATCH")(r,Object.assign(Object.assign({},s),{contentType:"application/json-patch+json",ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0}))}))}function Z(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t},i){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},i)}))}function K(e,t){return s(this,arguments,void 0,(function*({resourceType:e,id:t,versionId:i,count:s,offset:r},n){return i?this.fhirRequest(`/${e}/${t}/_history/${i}`,"GET")({},n):s?this.fhirRequest(`/${e}/${t}/_history?_total=accurate&_count=${s}\n ${r?`&_offset=${r}`:""}`,"GET")({},n):this.fhirRequest(`/${e}/${t}/_history?_total=accurate`,"GET")({},n)}))}function Q(e){const t=e.split("?")[0].split("/").filter(Boolean);return t.length<=1||t[1].startsWith("_")}function Y(e){return e.split("?")[0].endsWith("/_search")}function ee(e,t){var i;const{method:s}=e;let r=e.url;if((("GET"===s||"HEAD"===s)&&Q(r)||"POST"===s&&Y(r))&&(t.workspaceTag&&(r+=(r.includes("?")?"&":"?")+`_tag=${C(t.workspaceTag)}`),null===(i=t.ignoreTags)||void 0===i?void 0:i.length))for(const o of t.ignoreTags)r+=(r.includes("?")?"&":"?")+`_tag:not=${C(o)}`;const n={request:{method:s,url:r}};if(r.split("?").length>1){const[e,t]=r.split("?"),i=t.split("&").map((e=>{const[t,i]=e.split("=");return{name:t,value:i}})).reduce(((e,{name:t,value:i})=>t?(e[t]||(e[t]=[]),e[t].push(i),e):e),{}),s=new URLSearchParams;f(i,s),n.request.url=`${e}?${s.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return n;if("PUT"===s){const i=L(t,e.resource);return{request:Object.assign(Object.assign({},n.request),{ifMatch:e.ifMatch}),resource:i}}if("PATCH"===s){if("resource"in e){let i=e.resource;const s=i.data;if(s){const e=J(t,JSON.parse(function(e){const t=globalThis.atob(e),i=new Uint8Array(t.length);for(let s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return(new globalThis.TextDecoder).decode(i)}(s)));i=Object.assign(Object.assign({},i),{data:M(JSON.stringify(e))})}return{request:Object.assign(Object.assign({},n.request),{ifMatch:e.ifMatch}),resource:i}}const i=J(t,e.operations),s=M(JSON.stringify(i));return Object.assign(Object.assign({},n),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:s}})}if("POST"===s&&Y(r))return n;if("POST"===s&&"resource"in e){const i=L(t,e.resource),{fullUrl:s}=e;return Object.assign(Object.assign({},n),{resource:i,fullUrl:s})}throw new Error("Unrecognized method")}function te(e,t){return s(this,void 0,void 0,(function*(){var s;const r=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:e.requests.map((e=>ee(e,this.config)))},t),n=r.entry,o=this.config.workspaceTag||(null===(s=this.config.ignoreTags)||void 0===s?void 0:s.length)?null==n?void 0:n.map(((t,s)=>{const r=e.requests[s];if(!r||!(null==t?void 0:t.resource))return t;if(("GET"===r.method||"HEAD"===r.method)&&!Q(r.url))try{G(this.config,t.resource)}catch(n){if(!(n instanceof i))throw n;return{request:t.request,response:{status:"404",outcome:n.cause}}}return t})):n,u=Object.assign(Object.assign({},r),{entry:o,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]},errors:function(){var e;return null===(e=this.entry)||void 0===e?void 0:e.filter((e=>{var t,i,s,r;return(null===(i=null===(t=e.response)||void 0===t?void 0:t.status)||void 0===i?void 0:i.startsWith("4"))||(null===(r=null===(s=e.response)||void 0===s?void 0:s.status)||void 0===r?void 0:r.startsWith("5"))})).map((e=>{var t;return null===(t=e.response)||void 0===t?void 0:t.outcome})).filter((e=>void 0!==e))}});return u}))}function ie(e,t){return s(this,void 0,void 0,(function*(){var i,s;const r=yield this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:e.requests.map((e=>ee(e,this.config)))},t);(this.config.workspaceTag||(null===(i=this.config.ignoreTags)||void 0===i?void 0:i.length))&&(null===(s=r.entry)||void 0===s||s.forEach(((t,i)=>{const s=e.requests[i];s&&(null==t?void 0:t.resource)&&("GET"!==s.method&&"HEAD"!==s.method||Q(s.url)||G(this.config,t.resource))})));const n=Object.assign(Object.assign({},r),{entry:r.entry,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]}});return n}))}function se(e,t){return s(this,arguments,void 0,(function*({id:e},t){return this.fhirRequest(`/Patient/${e}/$generate-friendly-patient-id`,"POST")({},t)}))}function re(e,t){const i=[];if(e.line&&i.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),i.push(t.join(", "))}return e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join((null==t?void 0:t.lineSeparator)||", ").trim()}function ne(e,t){const i=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&i.push(...e.prefix),e.given&&i.push(...e.given),e.family&&i.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&i.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(" ").trim()}var oe,ue,ae,ce,de,he,le,pe,ve,me,fe,ge,be,ye,qe,we,je,Te,Oe,ke,Se,Ie,Ue,Ee,xe,ze,Ae,Pe,Re,Ne,_e,$e,We;class Me extends p{constructor(e){super(e),oe.add(this),this.search=H,this.create=V,this.get=F,this.update=B,this.patch=X,this.delete=Z,this.history=K,this.batch=te,this.transaction=ie,this.generateFriendlyPatientId=se,this.formatAddress=re,this.formatHumanName=ne}}oe=new WeakSet;class Ce extends p{constructor(e){super(e),ue.add(this)}routeList(e){return this.request("/route","get",r(this,ue,"m",ae).bind(this))(e)}routeCreate(e,t){return this.request("/route","post",r(this,ue,"m",ae).bind(this))(e,t)}routeGet(e,t){return this.request("/route/{routeGuid}","get",r(this,ue,"m",ae).bind(this))(e,t)}routeDelete(e,t){return this.request("/route/{routeGuid}","delete",r(this,ue,"m",ae).bind(this))(e,t)}orderableItemList(e,t){return this.request("/orderableItem","get",r(this,ue,"m",ae).bind(this))(e,t)}orderableItemQuestionnaireGet(e,t){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",r(this,ue,"m",ae).bind(this))(e,t)}orderSubmit(e,t){return this.request("/submit","post",r(this,ue,"m",ae).bind(this))(e,t)}}ue=new WeakSet,ae=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.labApiUrl)&&void 0!==t?t:"https://labs-api.zapehr.com/v1"};class De extends p{constructor(e){super(e),ce.add(this)}list(e){return this.request("/m2m","get",r(this,ce,"m",de).bind(this))(e)}create(e,t){return this.request("/m2m","post",r(this,ce,"m",de).bind(this))(e,t)}me(e){return this.request("/m2m/me","get",r(this,ce,"m",de).bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",r(this,ce,"m",de).bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",r(this,ce,"m",de).bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",r(this,ce,"m",de).bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",r(this,ce,"m",de).bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",r(this,ce,"m",de).bind(this))(e,t)}}ce=new WeakSet,de=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Le extends p{constructor(e){super(e),he.add(this)}getMessagingConfig(e){return this.request("/messaging/config","get",r(this,he,"m",le).bind(this))(e)}}he=new WeakSet,le=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Je extends p{constructor(e){super(e),pe.add(this)}setUp(e,t){return this.request("/payment/payment-method/setup","post",r(this,pe,"m",ve).bind(this))(e,t)}setDefault(e,t){return this.request("/payment/payment-method/set-default","post",r(this,pe,"m",ve).bind(this))(e,t)}delete(e,t){return this.request("/payment/payment-method","delete",r(this,pe,"m",ve).bind(this))(e,t)}list(e,t){return this.request("/payment/payment-method/list","post",r(this,pe,"m",ve).bind(this))(e,t)}}pe=new WeakSet,ve=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Ge extends p{constructor(e){super(e),me.add(this)}get(e){return this.request("/project","get",r(this,me,"m",fe).bind(this))(e)}update(e,t){return this.request("/project","patch",r(this,me,"m",fe).bind(this))(e,t)}}me=new WeakSet,fe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class He extends p{constructor(e){super(e),ge.add(this)}eligibilityCheck(e,t){return this.request("/eligibility-check","post",r(this,ge,"m",be).bind(this))(e,t)}submitClaim(e,t){return this.request("/claim/{claimId}/submit","post",r(this,ge,"m",be).bind(this))(e,t)}setClaimStatus(e,t){return this.request("/claim/{claimId}/status","post",r(this,ge,"m",be).bind(this))(e,t)}listPayers(e,t){return this.request("/payer","get",r(this,ge,"m",be).bind(this))(e,t)}getPayer(e,t){return this.request("/payer/{id}","get",r(this,ge,"m",be).bind(this))(e,t)}}ge=new WeakSet,be=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.rcmApiUrl)&&void 0!==t?t:"https://rcm-api.zapehr.com/v1"};class Ve extends p{constructor(e){super(e),ye.add(this)}list(e){return this.request("/iam/role","get",r(this,ye,"m",qe).bind(this))(e)}create(e,t){return this.request("/iam/role","post",r(this,ye,"m",qe).bind(this))(e,t)}get(e,t){return this.request("/iam/role/{roleId}","get",r(this,ye,"m",qe).bind(this))(e,t)}update(e,t){return this.request("/iam/role/{roleId}","patch",r(this,ye,"m",qe).bind(this))(e,t)}delete(e,t){return this.request("/iam/role/{roleId}","delete",r(this,ye,"m",qe).bind(this))(e,t)}}ye=new WeakSet,qe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Fe extends p{constructor(e){super(e),we.add(this)}list(e){return this.request("/secret","get",r(this,we,"m",je).bind(this))(e)}set(e,t){return this.request("/secret","post",r(this,we,"m",je).bind(this))(e,t)}get(e,t){return this.request("/secret/{name}","get",r(this,we,"m",je).bind(this))(e,t)}delete(e,t){return this.request("/secret/{name}","delete",r(this,we,"m",je).bind(this))(e,t)}}we=new WeakSet,je=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Be extends p{constructor(e){super(e),Te.add(this)}createMeeting(e,t){return this.request("/telemed/v2/meeting","post",r(this,Te,"m",Oe).bind(this))(e,t)}joinMeeting(e,t){return this.request("/telemed/v2/meeting/{encounterId}/join","get",r(this,Te,"m",Oe).bind(this))(e,t)}}Te=new WeakSet,Oe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Xe extends p{constructor(e){super(e),ke.add(this)}searchCpt(e,t){return this.request("/cpt/search","get",r(this,ke,"m",Se).bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",r(this,ke,"m",Se).bind(this))(e,t)}}ke=new WeakSet,Se=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.terminologyApiUrl)&&void 0!==t?t:"https://terminology-api.zapehr.com/v1"};class Ze extends p{constructor(e){super(e),Ie.add(this)}send(e,t){return this.request("/messaging/transactional-sms/send","post",r(this,Ie,"m",Ue).bind(this))(e,t)}}Ie=new WeakSet,Ue=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Ke extends p{constructor(e){super(e),Ee.add(this)}me(e){return this.request("/user/me","get",r(this,Ee,"m",xe).bind(this))(e)}get(e,t){return this.request("/user/{id}","get",r(this,Ee,"m",xe).bind(this))(e,t)}update(e,t){return this.request("/user/{id}","patch",r(this,Ee,"m",xe).bind(this))(e,t)}delete(e,t){return this.request("/user/{id}","delete",r(this,Ee,"m",xe).bind(this))(e,t)}resetMfa(e,t){return this.request("/user/{id}/reset-mfa","post",r(this,Ee,"m",xe).bind(this))(e,t)}resetPasswordLink(e,t){return this.request("/user/{id}/reset-password-link","post",r(this,Ee,"m",xe).bind(this))(e,t)}changePassword(e,t){return this.request("/user/{id}/change-password","post",r(this,Ee,"m",xe).bind(this))(e,t)}invite(e,t){return this.request("/user/invite","post",r(this,Ee,"m",xe).bind(this))(e,t)}list(e){return this.request("/user","get",r(this,Ee,"m",xe).bind(this))(e)}listV2(e,t){return this.request("/user/v2/list","get",r(this,Ee,"m",xe).bind(this))(e,t)}}Ee=new WeakSet,xe=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class Qe extends p{constructor(e){super(e),ze.add(this)}get(e){return this.request("/version","get",r(this,ze,"m",Ae).bind(this))(e)}}function Ye(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"}function et(e){return s(this,arguments,void 0,(function*({bucketName:e,"objectPath+":t,file:i}){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Ye.bind(this))({action:"upload",bucketName:e,"objectPath+":t});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function tt(e){return s(this,arguments,void 0,(function*({bucketName:e,"objectPath+":t}){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Ye.bind(this))({action:"download",bucketName:e,"objectPath+":t}),s=yield fetch(i.signedUrl,{method:"GET"});if(!s.ok)throw new Error("Failed to download file");return s.arrayBuffer()}))}function it(t){return s(this,void 0,void 0,(function*(){var i,s;let r,n;const o=new URL(t.url);if("z3:"===o.protocol){const e=o.pathname.split("/").slice(1);r=o.hostname,n=e.join("/")}else{if(!o.href.startsWith(null!==(s=null===(i=this.config.services)||void 0===i?void 0:i.projectApiUrl)&&void 0!==s?s:"https://project-api.zapehr.com/v1"))throw new e({message:"Invalid Z3 URL",code:400});{const e=o.pathname.split("/").slice(3);r=e[0],n=e.slice(1).join("/")}}const u={action:"upload",bucketName:r,"objectPath+":n};return this.request("/z3/{bucketName}/{objectPath+}","post",Ye.bind(this))(u)}))}ze=new WeakSet,Ae=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class st extends p{constructor(e){super(e),Pe.add(this),this.uploadFile=et,this.downloadFile=tt,this.getPresignedUrlForZ3Url=it}listBuckets(e){return this.request("/z3","get",r(this,Pe,"m",Re).bind(this))(e)}createBucket(e,t){return this.request("/z3/{bucketName}","put",r(this,Pe,"m",Re).bind(this))(e,t)}deleteBucket(e,t){return this.request("/z3/{bucketName}","delete",r(this,Pe,"m",Re).bind(this))(e,t)}listObjects(e,t){return this.request("/z3/{bucketName}/{objectPath+}","get",r(this,Pe,"m",Re).bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/z3/{bucketName}/{objectPath+}","post",r(this,Pe,"m",Re).bind(this))(e,t)}deleteObject(e,t){return this.request("/z3/{bucketName}/{objectPath+}","delete",r(this,Pe,"m",Re).bind(this))(e,t)}}function rt(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"}function nt(e){return s(this,arguments,void 0,(function*({id:e,file:t,filename:i}){const s=yield this.request("/zambda/{id}/s3-upload","post",rt.bind(this))({id:e,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:t})}))}Pe=new WeakSet,Re=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.projectApiUrl)&&void 0!==t?t:"https://project-api.zapehr.com/v1"};class ot extends p{constructor(e){super(e),Ne.add(this),this.uploadFile=nt}list(e){return this.request("/zambda","get",r(this,Ne,"m",_e).bind(this))(e)}create(e,t){return this.request("/zambda","post",r(this,Ne,"m",_e).bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}","get",r(this,Ne,"m",_e).bind(this))(e,t)}update(e,t){return this.request("/zambda/{id}","patch",r(this,Ne,"m",_e).bind(this))(e,t)}delete(e,t){return this.request("/zambda/{id}","delete",r(this,Ne,"m",_e).bind(this))(e,t)}execute(e,t){return this.request("/zambda/{id}/execute","post",r(this,Ne,"m",_e).bind(this))(e,t)}executePublic(e,t){return this.request("/zambda/{id}/execute-public","post",r(this,Ne,"m",_e).bind(this))(e,t)}s3Upload(e,t){return this.request("/zambda/{id}/s3-upload","post",r(this,Ne,"m",_e).bind(this))(e,t)}}Ne=new WeakSet,_e=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.zambdaApiUrl)&&void 0!==t?t:"https://zambda-api.zapehr.com/v1"};class ut extends p{constructor(e){super(e),$e.add(this)}list(e,t){return this.request("/zambda/{id}/logStream","post",r(this,$e,"m",We).bind(this))(e,t)}search(e,t){return this.request("/zambda/{id}/logStream/search","post",r(this,$e,"m",We).bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}/logStream/{logStreamName}","post",r(this,$e,"m",We).bind(this))(e,t)}}$e=new WeakSet,We=function(){var e,t;return null!==(t=null===(e=this.config.services)||void 0===e?void 0:e.zambdaApiUrl)&&void 0!==t?t:"https://zambda-api.zapehr.com/v1"};let at=class{constructor(t){var i,s,r,n,o,u;if(t.workspaceTag&&t.ignoreTags)throw new e({message:"workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config",code:400});this.config=t,null!==(i=(n=this.config).services)&&void 0!==i||(n.services={}),null!==(s=(o=this.config.services).projectApiUrl)&&void 0!==s||(o.projectApiUrl=t.projectApiUrl),null!==(r=(u=this.config.services).fhirApiUrl)&&void 0!==r||(u.fhirApiUrl=t.fhirApiUrl),this.application=new w(t),this.developer=new N(t),this.m2m=new De(t),this.messaging=new Le(t),this.conversation=new R(t),this.transactionalSMS=new Ze(t),this.paymentMethod=new Je(t),this.charge=new j(t),this.project=new Ge(t),this.role=new Ve(t),this.secret=new Fe(t),this.telemed=new Be(t),this.user=new Ke(t),this.version=new Qe(t),this.z3=new st(t),this.fax=new $(t),this.lab=new Ce(t),this.erx=new _(t),this.terminology=new Xe(t),this.zambda=new ot(t),this.zambdaLogStream=new ut(t),this.rcm=new He(t),this.fhir=new Me(t)}};class ct extends at{}ct.OystehrFHIRError=i,ct.OystehrSdkError=e,exports.default=ct;
|
|
2
2
|
//# sourceMappingURL=index.min.cjs.map
|