@oystehr/sdk 4.0.0-alpha.2 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +26 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/erx.d.ts +19 -3
- package/dist/cjs/resources/types/ErxCancelPrescriptionParams.d.ts +4 -0
- package/dist/cjs/resources/types/ErxCheckPractitionerEnrollmentParams.d.ts +3 -0
- package/dist/cjs/resources/types/ErxCheckPractitionerEnrollmentResponse.d.ts +17 -0
- package/dist/cjs/resources/types/ErxEnrollPractitionerParams.d.ts +3 -0
- package/dist/cjs/resources/types/ErxUnenrollPractitionerParams.d.ts +3 -0
- package/dist/cjs/resources/types/index.d.ts +5 -0
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/erx.d.ts +19 -3
- package/dist/esm/resources/classes/erx.js +26 -2
- package/dist/esm/resources/classes/erx.js.map +1 -1
- package/dist/esm/resources/types/ErxCancelPrescriptionParams.d.ts +4 -0
- package/dist/esm/resources/types/ErxCheckPractitionerEnrollmentParams.d.ts +3 -0
- package/dist/esm/resources/types/ErxCheckPractitionerEnrollmentResponse.d.ts +17 -0
- package/dist/esm/resources/types/ErxEnrollPractitionerParams.d.ts +3 -0
- package/dist/esm/resources/types/ErxUnenrollPractitionerParams.d.ts +3 -0
- package/dist/esm/resources/types/index.d.ts +5 -0
- package/package.json +1 -1
- package/src/resources/classes/erx.ts +38 -2
- package/src/resources/types/ErxCancelPrescriptionParams.ts +6 -0
- package/src/resources/types/ErxCheckPractitionerEnrollmentParams.ts +5 -0
- package/src/resources/types/ErxCheckPractitionerEnrollmentResponse.ts +19 -0
- package/src/resources/types/ErxEnrollPractitionerParams.ts +5 -0
- package/src/resources/types/ErxUnenrollPractitionerParams.ts +5 -0
- package/src/resources/types/index.ts +5 -0
package/dist/cjs/index.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("uuid");class e extends Error{constructor({message:t,code:i,cause:s}){super(t,{cause:s}),Object.setPrototypeOf(this,e.prototype),this.code=i,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function i(t){var e;const i=[];for(const s of null!==(e=t.issue)&&void 0!==e?e:[])s.details&&s.details.text&&i.push(s.details.text);return i.length||i.push("Unknown FHIR error"),i.join(",")}class s extends e{constructor({error:t,code:e}){super({message:i(t),code:e}),Object.setPrototypeOf(this,s.prototype),this.cause=t,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function r(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{c(s.next(t))}catch(t){n(t)}}function u(t){try{c(s.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,u)}c((s=s.apply(t,e||[])).next())}))}function n(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;const o=[408,429,500,502,503,504],u=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class c{constructor(t){this.config=t}request(t,i,s){return(n,o)=>r(this,void 0,void 0,(function*(){const r=()=>this.config;try{return yield a(s,r,t,i)(n,o)}catch(t){const i=t;throw new e({message:i.message,code:i.code,cause:i.cause})}}))}fhirRequest(t,i){return(n,o)=>r(this,void 0,void 0,(function*(){try{const e=()=>{var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.fhirApiUrl)&&void 0!==e?e:"https://fhir-api.zapehr.com"},s=()=>this.config;return yield a(e,s,t,i)(n,o)}catch(t){const i=t;if("string"==typeof i.message)throw new e({message:i.message,code:i.code,cause:i.cause});throw new s({error:i.message,code:i.code})}}))}}function h(t){return"accessToken"in t}function a(i,s,n,c){return(a,l)=>r(this,void 0,void 0,(function*(){var p,v,m,f,g,b,y,q,j,w,k,S,x,U,O;const T=a&&!l&&!Array.isArray(a)&&h(a)?{}:null!==(p=a)&&void 0!==p?p:{},z=a&&!l&&!Array.isArray(a)&&h(a)?a:l,E=c.toLowerCase(),A=s(),P=null!==(v=A.fetch)&&void 0!==v?v:fetch,I=null!==(m=null==z?void 0:z.accessToken)&&void 0!==m?m:A.accessToken,R=null!==(f=null==z?void 0:z.projectId)&&void 0!==f?f:s().projectId;let N=n,W=T;if(!Array.isArray(T)){const[t,i]=function(t,i){const s=Object.assign({},i),r=t.replace(/\{([^}]+)\}/g,((t,r)=>{if(delete s[r],r.match(/^.*\+$/))return i[r]+"";if(!i[r]||""===i[r])throw new e({message:`Required path parameter is an empty string: ${r}`,code:400});return i[r]?encodeURIComponent(i[r]+""):""})),n=Object.keys(s),o=n.length?n.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:s[e]})),{}):{};return[r,o]}(n,T);N=t,W=i}N=N.replace(/^\//,"");const $=i(),C=$.endsWith("/")?$:$+"/",_=new URL(N,C);let L;if(Array.isArray(W))L=JSON.stringify(W);else if(Object.keys(W).length)if("get"===E)d(W,_.searchParams);else if("application/x-www-form-urlencoded"===(null==z?void 0:z.contentType)){const t=new URLSearchParams;d(W,t),L=t.toString()}else L=JSON.stringify(W);else"application/x-www-form-urlencoded"!==(null==z?void 0:z.contentType)&&"post"===E&&(L="{}");const M=Object.assign(R?{"x-zapehr-project-id":R,"x-oystehr-project-id":R}:{},{"content-type":null!==(g=null==z?void 0:z.contentType)&&void 0!==g?g:"application/json"},I?{Authorization:`Bearer ${I}`}:{},(null==z?void 0:z.ifMatch)?{"If-Match":z.ifMatch}:{},{"x-oystehr-request-id":null!==(b=null==z?void 0:z.requestId)&&void 0!==b?b:t.v4()}),D={retries:null!==(q=null===(y=A.retry)||void 0===y?void 0:y.retries)&&void 0!==q?q:3,jitter:null!==(w=null===(j=A.retry)||void 0===j?void 0:j.jitter)&&void 0!==w?w:20,delay:null!==(S=null===(k=A.retry)||void 0===k?void 0:k.delay)&&void 0!==S?S:100,onRetry:null===(x=A.retry)||void 0===x?void 0:x.onRetry,retryOn:[...null!==(O=null===(U=A.retry)||void 0===U?void 0:U.retryOn)&&void 0!==O?O:[],...o]};return D.retryOn.push(...o),function(t,e){var i,s;return r(this,void 0,void 0,(function*(){let r;for(const n of Array.from({length:(null!==(i=e.retries)&&void 0!==i?i:0)+1},((t,e)=>e)))try{return yield t(n)}catch(t){let i=!1;if("response"in t){const s=t;i=e.retryOn.includes(s.code),r={message:t.message,code:t.code}}else if(r=t,"code"in t&&"string"==typeof t.code){const e=t;i=u.includes(e.code)}if(!i)break;const o=Math.floor(Math.random()*(e.jitter+1));yield new Promise((t=>setTimeout(t,e.delay+o))),e.onRetry&&n!==(null!==(s=e.retries)&&void 0!==s?s:0)&&e.onRetry(n+1)}throw r}))}((()=>r(this,void 0,void 0,(function*(){var t,e,i,s,r,n,o,u,c,h;const a=yield P(new Request(_,{method:E.toUpperCase(),body:L,headers:M})),d=a.body?yield a.text():null;let l;try{l=d&&((null===(t=a.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))||(null===(e=a.headers.get("content-type"))||void 0===e?void 0:e.includes("application/fhir+json")))?JSON.parse(d):null}catch(t){l=null}if(!a.ok||a.status>=400){throw{message:null!==(o=null!==(n=null!==(r=null!==(s=null===(i=null==l?void 0:l.output)||void 0===i?void 0:i.message)&&void 0!==s?s:null==l?void 0:l.message)&&void 0!==r?r:l)&&void 0!==n?n:d)&&void 0!==o?o:a.statusText,code:null!==(h=null!==(c=null===(u=null==l?void 0:l.output)||void 0===u?void 0:u.code)&&void 0!==c?c:null==l?void 0:l.code)&&void 0!==h?h:a.status,response:a}}return l}))),D)}))}function d(t,e){for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>e.append(i,t))):e.append(i,s)}var l,p,v,m;class f extends c{constructor(t){super(t),l.add(this)}list(t){return this.request("/application","get",n(this,l,"m",p).bind(this))(t)}create(t,e){return this.request("/application","post",n(this,l,"m",p).bind(this))(t,e)}get(t,e){return this.request("/application/{id}","get",n(this,l,"m",p).bind(this))(t,e)}update(t,e){return this.request("/application/{id}","patch",n(this,l,"m",p).bind(this))(t,e)}delete(t,e){return this.request("/application/{id}","delete",n(this,l,"m",p).bind(this))(t,e)}rotateSecret(t,e){return this.request("/application/{id}/rotate-secret","post",n(this,l,"m",p).bind(this))(t,e)}revokeRefreshToken(t,e){return this.request("/application/{id}/revoke-refresh-token","post",n(this,l,"m",p).bind(this))(t,e)}revokeAccessToken(t,e){return this.request("/application/{id}/revoke-access-token","post",n(this,l,"m",p).bind(this))(t,e)}}l=new WeakSet,p=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class g extends c{constructor(t){super(t),v.add(this)}issue(t,e){return this.request("/payment/charge/issue","post",n(this,v,"m",m).bind(this))(t,e)}status(t,e){return this.request("/payment/charge/status","post",n(this,v,"m",m).bind(this))(t,e)}}v=new WeakSet,m=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};const b="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",y="addressString";function q(t){var e,i,s;if(function(t){return Object.hasOwn(t,"virtualService")}(t)){const i=null===(e=t.virtualService)||void 0===e?void 0:e.find((t=>{var e;return"https://fhir.zapehr.com/virtual-service-type"===(null===(e=t.channelType)||void 0===e?void 0:e.system)}));return null==i?void 0:i.addressString}if(!t.extension)return;const r=t.extension.find((t=>t.url===b));if(!(null==r?void 0:r.extension))return;return null===(s=null===(i=r.extension)||void 0===i?void 0:i.find((t=>t.url===y)))||void 0===s?void 0:s.valueString}var j,w,k,S,x,U,O,T,z,E,A,P;class I extends c{constructor(t){super(t),j.add(this),this.ENCOUNTER_VS_EXTENSION_URL=b,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=y,this.getConversationIdFromEncounter=q}create(t,e){return this.request("/messaging/conversation","post",n(this,j,"m",w).bind(this))(t,e)}getToken(t){return this.request("/messaging/conversation/token","get",n(this,j,"m",w).bind(this))(t)}addParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","post",n(this,j,"m",w).bind(this))(t,e)}removeParticipant(t,e){return this.request("/messaging/conversation/{conversationId}/participant","delete",n(this,j,"m",w).bind(this))(t,e)}message(t,e){return this.request("/messaging/conversation/{conversationId}/message","post",n(this,j,"m",w).bind(this))(t,e)}}j=new WeakSet,w=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class R extends c{constructor(t){super(t),k.add(this)}get(t,e){return this.request("/developer/{id}","get",n(this,k,"m",S).bind(this))(t,e)}update(t,e){return this.request("/developer/{id}","patch",n(this,k,"m",S).bind(this))(t,e)}delete(t,e){return this.request("/developer/{id}","delete",n(this,k,"m",S).bind(this))(t,e)}invite(t,e){return this.request("/developer/invite","post",n(this,k,"m",S).bind(this))(t,e)}list(t){return this.request("/developer","get",n(this,k,"m",S).bind(this))(t)}listV2(t,e){return this.request("/developer/v2/list","get",n(this,k,"m",S).bind(this))(t,e)}}k=new WeakSet,S=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class N extends c{constructor(t){super(t),x.add(this)}searchAllergens(t,e){return this.request("/allergen","get",n(this,x,"m",U).bind(this))(t,e)}searchMedications(t,e){return this.request("/medication","get",n(this,x,"m",U).bind(this))(t,e)}checkAllergyInteractions(t,e){return this.request("/patient/{patientId}/interactions/allergy","get",n(this,x,"m",U).bind(this))(t,e)}checkMedicationInteractions(t,e){return this.request("/patient/{patientId}/interactions/medication","get",n(this,x,"m",U).bind(this))(t,e)}checkPrecheckInteractions(t,e){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",n(this,x,"m",U).bind(this))(t,e)}syncPatient(t,e){return this.request("/patient/{patientId}/sync","post",n(this,x,"m",U).bind(this))(t,e)}connectPractitioner(t,e){return this.request("/practitioner/connect","get",n(this,x,"m",U).bind(this))(t,e)}}x=new WeakSet,U=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.erxApiUrl)&&void 0!==e?e:"https://erx-api.zapehr.com/v3"};class W extends c{constructor(t){super(t),O.add(this)}syncPatient(t,e){return this.request("/erx/sync-patient/{patientId}","post",n(this,O,"m",T).bind(this))(t,e)}allergySearch(t,e){return this.request("/erx/allergy/search","get",n(this,O,"m",T).bind(this))(t,e)}cancelOrder(t,e){return this.request("/erx/cancel-order","post",n(this,O,"m",T).bind(this))(t,e)}cancelPrescription(t,e){return this.request("/erx/cancel-prescription","post",n(this,O,"m",T).bind(this))(t,e)}medicationSearch(t,e){return this.request("/erx/medication/search","get",n(this,O,"m",T).bind(this))(t,e)}}O=new WeakSet,T=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class $ extends c{constructor(t){super(t),z.add(this)}medicationSearch(t,e){return this.request("/erx/v2/medication/search","get",n(this,z,"m",E).bind(this))(t,e)}}z=new WeakSet,E=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class C extends c{constructor(t){super(t),A.add(this)}offboard(t){return this.request("/offboard","post",n(this,A,"m",P).bind(this))(t)}onboard(t){return this.request("/onboard","post",n(this,A,"m",P).bind(this))(t)}send(t,e){return this.request("/send","post",n(this,A,"m",P).bind(this))(t,e)}}function _(t,e){return r(this,void 0,void 0,(function*(){const{resourceType:i,params:s}=t;let r;s&&(r=Object.entries(s).reduce(((t,[e,i])=>(t[i.name]||(t[i.name]=[]),t[i.name].push(i.value),t)),{}));const n=yield this.fhirRequest(`/${i}/_search`,"POST")(r,Object.assign(Object.assign({},e),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var t,e;return null!==(e=null===(t=this.entry)||void 0===t?void 0:t.map((t=>t.resource)).filter((t=>void 0!==t)))&&void 0!==e?e:[]}})}))}function L(t,e){return r(this,void 0,void 0,(function*(){const{resourceType:i}=t;return this.fhirRequest(`/${i}`,"POST")(t,e)}))}function M({resourceType:t,id:e},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}`,"GET")({},i)}))}function D(t,e){return r(this,void 0,void 0,(function*(){const{id:i,resourceType:s}=t;return this.fhirRequest(`/${s}/${i}`,"PUT")(t,Object.assign(Object.assign({},e),{ifMatch:(null==e?void 0:e.optimisticLockingVersionId)?`W/"${e.optimisticLockingVersionId}"`:void 0}))}))}function V({resourceType:t,id:e,operations:i},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}`,"PATCH")(i,Object.assign(Object.assign({},s),{contentType:"application/json-patch+json",ifMatch:(null==s?void 0:s.optimisticLockingVersionId)?`W/"${s.optimisticLockingVersionId}"`:void 0}))}))}function F({resourceType:t,id:e},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}`,"DELETE")({},i)}))}function H({resourceType:t,id:e,versionId:i},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${t}/${e}/_history${i?`/${i}`:""}`,"GET")({},s)}))}function B(t){const{method:e,url:i}=t,s={request:{method:e,url:i}};if(i.split("?").length>1){const[t,e]=i.split("?"),r=e.split("&").map((t=>{const[e,i]=t.split("=");return{name:e,value:i}})).reduce(((t,{name:e,value:i})=>e?(t[e]||(t[e]=[]),t[e].push(i),t):t),{}),n=new URLSearchParams;d(r,n),s.request.url=`${t}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(e))return s;if("PUT"===e){const{resource:e}=t;return Object.assign(Object.assign({},s),{resource:e})}if("PATCH"===e)return"resource"in t?Object.assign(Object.assign({},s),{resource:t.resource}):Object.assign(Object.assign({},s),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:Buffer.from(JSON.stringify(t.operations),"utf8").toString("base64")}});if("POST"===e){const{resource:e,fullUrl:i}=t;return Object.assign(Object.assign({},s),{resource:e,fullUrl:i})}throw new Error("Unrecognized method")}function G(t){return function(e,i){return r(this,void 0,void 0,(function*(){return this.fhirRequest("/","POST")({resourceType:"Bundle",type:t,entry:e.requests.map(B)},i)}))}}A=new WeakSet,P=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.faxApiUrl)&&void 0!==e?e:"https://fax-api.zapehr.com/v1"};const J=G("batch"),X=G("transaction");function Z(t,e){const i=[];if(t.line&&i.push(...t.line),t.city||t.state||t.postalCode){const e=[];t.city&&e.push(t.city),t.state&&e.push(t.state),t.postalCode&&e.push(t.postalCode),i.push(e.join(", "))}return t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&i.push("["+t.use+"]"),i.join((null==e?void 0:e.lineSeparator)||", ").trim()}function K(t,e){const i=[];return t.prefix&&!1!==(null==e?void 0:e.prefix)&&i.push(...t.prefix),t.given&&i.push(...t.given),t.family&&i.push(t.family),t.suffix&&!1!==(null==e?void 0:e.suffix)&&i.push(...t.suffix),t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&i.push("["+t.use+"]"),i.join(" ").trim()}var Q,Y,tt,et,it,st,rt,nt,ot,ut,ct,ht,at,dt,lt,pt,vt,mt,ft,gt,bt,yt,qt,jt,wt,kt,St,xt,Ut,Ot,Tt;class zt extends c{constructor(t){super(t),Q.add(this),this.search=_,this.create=L,this.get=M,this.update=D,this.patch=V,this.delete=F,this.history=H,this.batch=J,this.transaction=X,this.formatAddress=Z,this.formatHumanName=K}}Q=new WeakSet;class Et extends c{constructor(t){super(t),Y.add(this)}routeList(t){return this.request("/route","get",n(this,Y,"m",tt).bind(this))(t)}routeCreate(t,e){return this.request("/route","post",n(this,Y,"m",tt).bind(this))(t,e)}routeDelete(t,e){return this.request("/route/{routeGuid}","delete",n(this,Y,"m",tt).bind(this))(t,e)}orderableItemList(t,e){return this.request("/orderableItem","get",n(this,Y,"m",tt).bind(this))(t,e)}orderableItemQuestionnaireGet(t,e){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",n(this,Y,"m",tt).bind(this))(t,e)}orderSubmit(t,e){return this.request("/submit","post",n(this,Y,"m",tt).bind(this))(t,e)}}Y=new WeakSet,tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.labApiUrl)&&void 0!==e?e:"https://labs-api.zapehr.com/v1"};class At extends c{constructor(t){super(t),et.add(this)}list(t){return this.request("/m2m","get",n(this,et,"m",it).bind(this))(t)}create(t,e){return this.request("/m2m","post",n(this,et,"m",it).bind(this))(t,e)}get(t,e){return this.request("/m2m/{id}","get",n(this,et,"m",it).bind(this))(t,e)}update(t,e){return this.request("/m2m/{id}","patch",n(this,et,"m",it).bind(this))(t,e)}delete(t,e){return this.request("/m2m/{id}","delete",n(this,et,"m",it).bind(this))(t,e)}rotateSecret(t,e){return this.request("/m2m/{id}/rotate-secret","post",n(this,et,"m",it).bind(this))(t,e)}listV2(t,e){return this.request("/m2m/v2/list","get",n(this,et,"m",it).bind(this))(t,e)}}et=new WeakSet,it=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Pt extends c{constructor(t){super(t),st.add(this)}getMessagingConfig(t){return this.request("/messaging/config","get",n(this,st,"m",rt).bind(this))(t)}}st=new WeakSet,rt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class It extends c{constructor(t){super(t),nt.add(this)}setUp(t,e){return this.request("/payment/payment-method/setup","post",n(this,nt,"m",ot).bind(this))(t,e)}setDefault(t,e){return this.request("/payment/payment-method/set-default","post",n(this,nt,"m",ot).bind(this))(t,e)}delete(t,e){return this.request("/payment/payment-method","delete",n(this,nt,"m",ot).bind(this))(t,e)}list(t,e){return this.request("/payment/payment-method/list","post",n(this,nt,"m",ot).bind(this))(t,e)}}nt=new WeakSet,ot=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Rt extends c{constructor(t){super(t),ut.add(this)}get(t){return this.request("/project","get",n(this,ut,"m",ct).bind(this))(t)}update(t,e){return this.request("/project","patch",n(this,ut,"m",ct).bind(this))(t,e)}}ut=new WeakSet,ct=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Nt extends c{constructor(t){super(t),ht.add(this)}eligibilityCheck(t,e){return this.request("/rcm/eligibility-check","post",n(this,ht,"m",at).bind(this))(t,e)}validateProfessionalClaim(t,e){return this.request("/rcm/professional-claim/validate","post",n(this,ht,"m",at).bind(this))(t,e)}submitProfessionalClaim(t,e){return this.request("/rcm/professional-claim/submit","post",n(this,ht,"m",at).bind(this))(t,e)}}ht=new WeakSet,at=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Wt extends c{constructor(t){super(t),dt.add(this)}list(t){return this.request("/iam/role","get",n(this,dt,"m",lt).bind(this))(t)}create(t,e){return this.request("/iam/role","post",n(this,dt,"m",lt).bind(this))(t,e)}get(t,e){return this.request("/iam/role/{roleId}","get",n(this,dt,"m",lt).bind(this))(t,e)}update(t,e){return this.request("/iam/role/{roleId}","patch",n(this,dt,"m",lt).bind(this))(t,e)}delete(t,e){return this.request("/iam/role/{roleId}","delete",n(this,dt,"m",lt).bind(this))(t,e)}}dt=new WeakSet,lt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class $t extends c{constructor(t){super(t),pt.add(this)}list(t){return this.request("/secret","get",n(this,pt,"m",vt).bind(this))(t)}set(t,e){return this.request("/secret","post",n(this,pt,"m",vt).bind(this))(t,e)}get(t,e){return this.request("/secret/{name}","get",n(this,pt,"m",vt).bind(this))(t,e)}delete(t,e){return this.request("/secret/{name}","delete",n(this,pt,"m",vt).bind(this))(t,e)}}pt=new WeakSet,vt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Ct extends c{constructor(t){super(t),mt.add(this)}createMeeting(t,e){return this.request("/telemed/v2/meeting","post",n(this,mt,"m",ft).bind(this))(t,e)}joinMeeting(t,e){return this.request("/telemed/v2/meeting/{encounterId}/join","get",n(this,mt,"m",ft).bind(this))(t,e)}}mt=new WeakSet,ft=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class _t extends c{constructor(t){super(t),gt.add(this)}send(t,e){return this.request("/messaging/transactional-sms/send","post",n(this,gt,"m",bt).bind(this))(t,e)}}gt=new WeakSet,bt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Lt extends c{constructor(t){super(t),yt.add(this)}me(t){return this.request("/user/me","get",n(this,yt,"m",qt).bind(this))(t)}get(t,e){return this.request("/user/{id}","get",n(this,yt,"m",qt).bind(this))(t,e)}update(t,e){return this.request("/user/{id}","patch",n(this,yt,"m",qt).bind(this))(t,e)}delete(t,e){return this.request("/user/{id}","delete",n(this,yt,"m",qt).bind(this))(t,e)}invite(t,e){return this.request("/user/invite","post",n(this,yt,"m",qt).bind(this))(t,e)}list(t){return this.request("/user","get",n(this,yt,"m",qt).bind(this))(t)}listV2(t,e){return this.request("/user/v2/list","get",n(this,yt,"m",qt).bind(this))(t,e)}}yt=new WeakSet,qt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Mt extends c{constructor(t){super(t),jt.add(this)}get(t){return this.request("/version","get",n(this,jt,"m",wt).bind(this))(t)}}function Dt(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"}function Vt({bucketName:t,"objectPath+":e,file:i}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post",Dt.bind(this))({action:"upload",bucketName:t,"objectPath+":e});yield fetch(s.signedUrl,{method:"PUT",body:i})}))}function Ft({bucketName:t,"objectPath+":e}){return r(this,void 0,void 0,(function*(){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post",Dt.bind(this))({action:"download",bucketName:t,"objectPath+":e}),s=yield fetch(i.signedUrl,{method:"GET"});if(!s.ok)throw new Error("Failed to download file");return s.arrayBuffer()}))}function Ht(t){var i,s;return r(this,void 0,void 0,(function*(){let r,n;const o=new URL(t.url);if("z3:"===o.protocol){const t=o.pathname.split("/").slice(1);r=o.hostname,n=t.join("/")}else{if(!o.href.startsWith(null!==(s=null===(i=this.config.services)||void 0===i?void 0:i.projectApiUrl)&&void 0!==s?s:"https://project-api.zapehr.com/v1"))throw new e({message:"Invalid Z3 URL",code:400});{const t=o.pathname.split("/").slice(3);r=t[0],n=t.slice(1).join("/")}}const u={action:"upload",bucketName:r,"objectPath+":n};return this.request("/z3/{bucketName}/{objectPath+}","post",Dt.bind(this))(u)}))}jt=new WeakSet,wt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Bt extends c{constructor(t){super(t),kt.add(this),this.uploadFile=Vt,this.downloadFile=Ft,this.getPresignedUrlForZ3Url=Ht}listBuckets(t){return this.request("/z3","get",n(this,kt,"m",St).bind(this))(t)}createBucket(t,e){return this.request("/z3/{bucketName}","put",n(this,kt,"m",St).bind(this))(t,e)}deleteBucket(t,e){return this.request("/z3/{bucketName}","delete",n(this,kt,"m",St).bind(this))(t,e)}listObjects(t,e){return this.request("/z3/{bucketName}/{objectPath+}","get",n(this,kt,"m",St).bind(this))(t,e)}getPresignedUrl(t,e){return this.request("/z3/{bucketName}/{objectPath+}","post",n(this,kt,"m",St).bind(this))(t,e)}deleteObject(t,e){return this.request("/z3/{bucketName}/{objectPath+}","delete",n(this,kt,"m",St).bind(this))(t,e)}}function Gt(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"}function Jt({id:t,file:e,filename:i}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/zambda/{id}/s3-upload","post",Gt.bind(this))({id:t,filename:i});yield fetch(s.signedUrl,{method:"PUT",body:e})}))}kt=new WeakSet,St=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Xt extends c{constructor(t){super(t),xt.add(this),this.uploadFile=Jt}list(t){return this.request("/zambda","get",n(this,xt,"m",Ut).bind(this))(t)}create(t,e){return this.request("/zambda","post",n(this,xt,"m",Ut).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}","get",n(this,xt,"m",Ut).bind(this))(t,e)}update(t,e){return this.request("/zambda/{id}","patch",n(this,xt,"m",Ut).bind(this))(t,e)}delete(t,e){return this.request("/zambda/{id}","delete",n(this,xt,"m",Ut).bind(this))(t,e)}execute(t,e){return this.request("/zambda/{id}/execute","post",n(this,xt,"m",Ut).bind(this))(t,e)}executePublic(t,e){return this.request("/zambda/{id}/execute-public","post",n(this,xt,"m",Ut).bind(this))(t,e)}s3Upload(t,e){return this.request("/zambda/{id}/s3-upload","post",n(this,xt,"m",Ut).bind(this))(t,e)}}xt=new WeakSet,Ut=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};class Zt extends c{constructor(t){super(t),Ot.add(this)}list(t,e){return this.request("/zambda/{id}/logStream","post",n(this,Ot,"m",Tt).bind(this))(t,e)}search(t,e){return this.request("/zambda/{id}/logStream/search","post",n(this,Ot,"m",Tt).bind(this))(t,e)}get(t,e){return this.request("/zambda/{id}/logStream/{logStreamName}","post",n(this,Ot,"m",Tt).bind(this))(t,e)}}Ot=new WeakSet,Tt=function(){var t,e;return null!==(e=null===(t=this.config.services)||void 0===t?void 0:t.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"};let Kt=class{constructor(t){var e,i,s,r,n,o;this.config=t,null!==(e=(r=this.config).services)&&void 0!==e||(r.services={}),null!==(i=(n=this.config.services).projectApiUrl)&&void 0!==i||(n.projectApiUrl=t.projectApiUrl),null!==(s=(o=this.config.services).fhirApiUrl)&&void 0!==s||(o.fhirApiUrl=t.fhirApiUrl),this.application=new f(t),this.developer=new R(t),this.m2m=new At(t),this.messaging=new Pt(t),this.conversation=new I(t),this.transactionalSMS=new _t(t),this.paymentMethod=new It(t),this.charge=new g(t),this.project=new Rt(t),this.rcm=new Nt(t),this.erxV1=new W(t),this.erxV2=new $(t),this.role=new Wt(t),this.secret=new $t(t),this.telemed=new Ct(t),this.user=new Lt(t),this.version=new Mt(t),this.z3=new Bt(t),this.zambda=new Xt(t),this.zambdaLogStream=new Zt(t),this.fax=new C(t),this.lab=new Et(t),this.erx=new N(t),this.fhir=new zt(t)}};class Qt extends Kt{}Qt.OystehrFHIRError=s,Qt.OystehrSdkError=e,module.exports=Qt;
|
|
1
|
+
"use strict";var t=require("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.v4()}),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,module.exports=Qt;
|
|
2
2
|
//# sourceMappingURL=index.min.cjs.map
|