UNPKG

@story-health/fhirclient

Version:

JavaScript client for Fast Healthcare Interoperability Resources

2 lines 42.9 kB
(()=>{var e={946:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(458),o=r(612),s=r(628),{Response:i}=window,a=n.debug.extend("client");function c(e,t,r,o,s){let i=(0,n.makeArray)(t.resolveReferences).filter(Boolean).map((e=>String(e).trim())).filter(Boolean);if(i=i.filter(((e,t)=>!(i.indexOf(e,t+1)>-1&&(a('Duplicated reference path "%s"',e),1)))),!i.length)return Promise.resolve();const c={};i.forEach((e=>{const t=e.split(".").length;c[t]||(c[t]=[]),c[t].push(e)}));let u=Promise.resolve();return Object.keys(c).sort().forEach((i=>{const a=c[i];u=u.then((()=>Promise.all(a.map((i=>function(e,t,r,o,s,i){const a=(0,n.getPath)(e,t);if(a){const c=Array.isArray(a);return Promise.all((0,n.makeArray)(a).filter(Boolean).map(((a,u)=>{const l=a.reference;if(l)return function(e,t,r,n){return t[e]||(t[e]=r.request({url:e,signal:n}).then((r=>(t[e]=r,r)),(r=>{throw delete t[e],r}))),Promise.resolve(t[e])}(l,o,s,i).then((o=>{r&&(c?t.indexOf("..")>-1?(0,n.setPath)(e,`${t.replace("..",`.${u}.`)}`,o):(0,n.setPath)(e,`${t}.${u}`,o):(0,n.setPath)(e,t,o))})).catch((e=>{if(404!==e.status)throw e}))})))}}(e,i,!!t.graph,r,o,s))))))})),u}t.default=class{constructor(e,t){this.units=n.units;const r="string"==typeof t?{serverUrl:t}:t;(0,n.assert)(r.serverUrl&&r.serverUrl.match(/https?:\/\/.+/),'A "serverUrl" option is required and must begin with "http(s)"'),this.state=r,this.environment=e,this._refreshTask=null;const o=this;this.patient={get id(){return o.getPatientId()},read:e=>{const t=this.patient.id;return t?this.request({...e,url:`Patient/${t}`}):Promise.reject(new Error("Patient is not available"))},request:(e,t={})=>this.patient.id?(async()=>{const r=await async function(e,t){const r=(0,n.absolute)("/",t.state.serverUrl);async function o(e){const r=e.pathname.split("/").pop();(0,n.assert)(r,`Invalid url "${e}"`),(0,n.assert)(s.patientCompartment.indexOf(r)>-1,`Cannot filter "${r}" resources by patient`);const o=await(0,n.fetchConformanceStatement)(t.state.serverUrl),i=(0,n.getPatientParam)(o,r);return e.searchParams.set(i,t.patient.id),e.href}return"string"==typeof e||e instanceof URL?{url:await o(new URL(e+"",r))}:(e.url=await o(new URL(e.url+"",r)),e)}(e,this);return this.request(r,t)})():Promise.reject(new Error("Patient is not available"))},this.encounter={get id(){return o.getEncounterId()},read:e=>{const t=this.encounter.id;return t?this.request({...e,url:`Encounter/${t}`}):Promise.reject(new Error("Encounter is not available"))}},this.user={get fhirUser(){return o.getFhirUser()},get id(){return o.getUserId()},get resourceType(){return o.getUserType()},read:e=>{const t=this.user.fhirUser;return t?this.request({...e,url:t}):Promise.reject(new Error("User is not available"))}},this.connect(e.fhir)}connect(e){if("function"==typeof e){const t={baseUrl:this.state.serverUrl.replace(/\/$/,"")},r=this.getState("tokenResponse.access_token");if(r)t.auth={token:r};else{const{username:e,password:r}=this.state;e&&r&&(t.auth={user:e,pass:r})}this.api=e(t);const n=this.getState("tokenResponse.patient");n&&(this.patient.api=e({...t,patient:n}))}return this}getPatientId(){const e=this.state.tokenResponse;return e?e.patient?e.patient:((this.state.scope||"").match(/\blaunch(\/patient)?\b/)?a("The ID of the selected patient is not available. Please check if your server supports that."):a(o.default.noScopeForId,"patient","patient"),null):(this.state.authorizeUri?a(o.default.noIfNoAuth,"the ID of the selected patient"):a(o.default.noFreeContext,"selected patient"),null)}getEncounterId(){const e=this.state.tokenResponse;return e?e.encounter?e.encounter:((this.state.scope||"").match(/\blaunch(\/encounter)?\b/)?a("The ID of the selected encounter is not available. Please check if your server supports that, and that the selected patient has any recorded encounters."):a(o.default.noScopeForId,"encounter","encounter"),null):(this.state.authorizeUri?a(o.default.noIfNoAuth,"the ID of the selected encounter"):a(o.default.noFreeContext,"selected encounter"),null)}getIdToken(){const e=this.state.tokenResponse;if(e){const t=e.id_token,r=this.state.scope||"";if(!t){const e=r.match(/\bopenid\b/),t=r.match(/\bprofile\b/),n=r.match(/\bfhirUser\b/);return a(e&&(n||t)?"The id_token is not available. Please check if your server supports that.":"You are trying to get the id_token but you are not using the right scopes. Please add 'openid' and 'fhirUser' or 'profile' to the scopes you are requesting."),null}return(0,n.jwtDecode)(t,this.environment)}return this.state.authorizeUri?a(o.default.noIfNoAuth,"the id_token"):a(o.default.noFreeContext,"id_token"),null}getFhirUser(){const e=this.getIdToken();return e?e.fhirUser?e.fhirUser.split("/").slice(-2).join("/"):e.profile:null}getUserId(){const e=this.getFhirUser();return e?e.split("/")[1]:null}getUserType(){const e=this.getFhirUser();return e?e.split("/")[0]:null}getAuthorizationHeader(){const e=this.getState("tokenResponse.access_token");if(e)return"Bearer "+e;const{username:t,password:r}=this.state;return t&&r?"Basic "+this.environment.btoa(t+":"+r):null}async _clearState(){const e=this.environment.getStorage(),t=await e.get(s.SMART_KEY);t&&await e.unset(t),await e.unset(s.SMART_KEY),this.state.tokenResponse={}}create(e,t){return this.request({...t,url:`${e.resourceType}`,method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json",...(t||{}).headers}})}update(e,t){return this.request({...t,url:`${e.resourceType}/${e.id}`,method:"PUT",body:JSON.stringify(e),headers:{"content-type":"application/json",...(t||{}).headers}})}delete(e,t={}){return this.request({...t,url:e,method:"DELETE"})}async patch(e,t,r={}){return(0,n.assertJsonPatch)(t),this.request({...r,url:e,method:"PATCH",body:JSON.stringify(t),headers:{prefer:"return=presentation","content-type":"application/json-patch+json; charset=UTF-8",...r.headers}})}async request(e,t={},r={}){var s;const a=n.debug.extend("client:request");let u;(0,n.assert)(e,"request requires an url or request options as argument"),"string"==typeof e||e instanceof URL?(u=String(e),e={}):u=String(e.url),u=(0,n.absolute)(u,this.state.serverUrl);const l={graph:!1!==t.graph,flat:!!t.flat,pageLimit:null!==(s=t.pageLimit)&&void 0!==s?s:1,resolveReferences:t.resolveReferences||[],useRefreshToken:!1!==t.useRefreshToken,onPage:"function"==typeof t.onPage?t.onPage:void 0},h=e.signal||void 0;let d;return(l.useRefreshToken?this.refreshIfNeeded({signal:h}).then((()=>e)):Promise.resolve(e)).then((e=>{const t=this.getAuthorizationHeader();return t&&(e.headers={...e.headers,authorization:t}),e})).then((e=>(a("%s, options: %O, fhirOptions: %O",u,e,l),(0,n.request)(u,e).then((t=>e.includeResponse?(d=t.response,t.body):t))))).catch((async e=>{if(401==e.status){if(!this.getState("tokenResponse.access_token"))throw e.message+="\nThis app cannot be accessed directly. Please launch it as SMART app!",e;if(!l.useRefreshToken)throw a("Your session has expired and the useRefreshToken option is set to false. Please re-launch the app."),await this._clearState(),e.message+="\n"+o.default.expired,e;throw a("Auto-refresh failed! Please re-launch the app."),await this._clearState(),e.message+="\n"+o.default.expired,e}throw e})).catch((e=>{throw 403==e.status&&a("Permission denied! Please make sure that you have requested the proper scopes."),e})).then((t=>t?"string"==typeof t||t instanceof i?t:(async e=>("Bundle"==e.resourceType?await Promise.all((e.entry||[]).map((e=>c(e.resource,l,r,this,h)))):await c(e,l,r,this,h),e))(t).then((async e=>{if(e&&"Bundle"==e.resourceType){const t=e.link||[];if(l.flat&&(e=(e.entry||[]).map((e=>e.resource))),l.onPage&&await l.onPage(e,{...r}),--l.pageLimit){const o=t.find((e=>"next"==e.relation));if(e=(0,n.makeArray)(e),o&&o.url){const t=await this.request({url:o.url,signal:h},l,r);return l.onPage?null:l.resolveReferences.length?(Object.assign(r,t.references),e.concat((0,n.makeArray)(t.data||t))):e.concat((0,n.makeArray)(t))}}}return e})).then((e=>{if(l.graph)r={};else if(!l.onPage&&l.resolveReferences.length)return{data:e,references:r};return e})).then((t=>e.includeResponse?{body:t,response:d}:t)):t))}refreshIfNeeded(e={}){const t=this.getState("tokenResponse.access_token"),r=this.getState("tokenResponse.refresh_token"),n=this.state.expiresAt||0;return t&&r&&n-10<Date.now()/1e3?this.refresh(e):Promise.resolve(this.state)}refresh(e={}){var t,r;const o=n.debug.extend("client:refresh");o("Attempting to refresh with refresh_token...");const s=null===(r=null===(t=this.state)||void 0===t?void 0:t.tokenResponse)||void 0===r?void 0:r.refresh_token;(0,n.assert)(s,"Unable to refresh. No refresh_token found.");const i=this.state.tokenUri;(0,n.assert)(i,"Unable to refresh. No tokenUri found.");const a=this.getState("tokenResponse.scope")||"",c=a.search(/\boffline_access\b/)>-1,u=a.search(/\bonline_access\b/)>-1;if((0,n.assert)(c||u,"Unable to refresh. No offline_access or online_access scope found."),!this._refreshTask){const t={credentials:this.environment.options.refreshTokenWithCredentials||"same-origin",...e,method:"POST",mode:"cors",headers:{...e.headers||{},"content-type":"application/x-www-form-urlencoded"},body:`grant_type=refresh_token&refresh_token=${encodeURIComponent(s)}`};if(!("authorization"in t.headers)){const{clientSecret:e,clientId:r}=this.state;e&&(t.headers.authorization="Basic "+this.environment.btoa(r+":"+e))}this._refreshTask=(0,n.request)(i,t).then((e=>((0,n.assert)(e.access_token,"No access token received"),o("Received new access token response %O",e),this.state.tokenResponse={...this.state.tokenResponse,...e},this.state.expiresAt=(0,n.getAccessTokenExpiration)(e,this.environment),this.state))).catch((e=>{var t,r;throw(null===(r=null===(t=this.state)||void 0===t?void 0:t.tokenResponse)||void 0===r?void 0:r.refresh_token)&&(o("Deleting the expired or invalid refresh token."),delete this.state.tokenResponse.refresh_token),e})).finally((()=>{this._refreshTask=null;const e=this.state.key;e?this.environment.getStorage().set(e,this.state):o("No 'key' found in Clint.state. Cannot persist the instance.")}))}return this._refreshTask}byCode(e,t){return(0,n.byCode)(e,t)}byCodes(e,t){return(0,n.byCodes)(e,t)}getPath(e,t=""){return(0,n.getPath)(e,t)}getState(e=""){return(0,n.getPath)({...this.state},e)}getFhirVersion(){return(0,n.fetchConformanceStatement)(this.state.serverUrl).then((e=>e.fhirVersion))}getFhirRelease(){return this.getFhirVersion().then((e=>{var t;return null!==(t=s.fhirVersions[e])&&void 0!==t?t:0}))}}},685:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r extends Error{constructor(e){super(`${e.status} ${e.statusText}\nURL: ${e.url}`),this.name="HttpError",this.response=e,this.statusCode=e.status,this.status=e.status,this.statusText=e.statusText}async parse(){if(!this.response.bodyUsed)try{const e=this.response.headers.get("content-type")||"text/plain";if(e.match(/\bjson\b/i)){let e=await this.response.json();e.error?(this.message+="\n"+e.error,e.error_description&&(this.message+=": "+e.error_description)):this.message+="\n\n"+JSON.stringify(e,null,4)}else if(e.match(/^text\//i)){let e=await this.response.text();e&&(this.message+="\n\n"+e)}}catch{}return this}toJSON(){return{name:this.name,statusCode:this.statusCode,status:this.status,statusText:this.statusText,message:this.message}}}t.default=r},254:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(349),o=r(946),s=r(424),i=r(913),a=r(575);t.default=class{constructor(e={}){this._url=null,this._storage=null,this.security=i,this.options={replaceBrowserHistory:!0,fullSessionStorageSupport:!0,refreshTokenWithCredentials:"same-origin",...e}}relative(e){return new URL(e,this.getUrl().href).href}get fhir(){return"function"==typeof fhir?fhir:null}getUrl(){return this._url||(this._url=new URL(location+"")),this._url}redirect(e){location.href=e}getStorage(){return this._storage||(this._storage=new s.default),this._storage}getAbortController(){return AbortController}atob(e){return window.atob(e)}btoa(e){return window.btoa(e)}base64urlencode(e){return"string"==typeof e?(0,a.encodeURL)(e):(0,a.fromUint8Array)(e,!0)}base64urldecode(e){return(0,a.decode)(e)}getSmartApi(){return{ready:(...e)=>(0,n.ready)(this,...e),authorize:e=>(0,n.authorize)(this,e),init:e=>(0,n.init)(this,e),client:e=>new o.default(this,e),options:this.options,utils:{security:i}}}}},769:(e,t,r)=>{"use strict";const n=new(r(254).default),{ready:o,authorize:s,init:i,client:a,options:c,utils:u}=n.getSmartApi(),l={AbortController:window.AbortController,client:a,utils:u,oauth2:{settings:c,ready:o,authorize:s,init:i}};e.exports=l},458:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertJsonPatch=t.assert=t.getTargetWindow=t.getPatientParam=t.byCodes=t.byCode=t.getAccessTokenExpiration=t.getTimeInFuture=t.jwtDecode=t.randomString=t.absolute=t.makeArray=t.setPath=t.getPath=t.fetchConformanceStatement=t.getAndCache=t.request=t.loweCaseKeys=t.responseToJSON=t.checkResponse=t.units=t.debug=void 0;const n=r(685),o=r(628),s=r(227),{fetch:i}=window,a=s("FHIR");t.debug=a;const c={};function u({value:e,code:t}){if("number"!=typeof e)throw new Error("Found a non-numerical unit: "+e+" "+t)}async function l(e){if(!e.ok){const t=new n.default(e);throw await t.parse(),t}return e}function h(e){return e.text().then((e=>e.length?JSON.parse(e):""))}function d(e){if(!e)return e;if(Array.isArray(e))return e.map((e=>e&&"object"==typeof e?d(e):e));let t={};return Object.keys(e).forEach((r=>{const n=r.toLowerCase(),o=e[r];t[n]=o&&"object"==typeof o?d(o):o})),t}function f(e,t={}){const{includeResponse:r,...n}=t;return i(e,{mode:"cors",...n,headers:{accept:"application/json",...d(n.headers)}}).then(l).then((e=>{const t=e.headers.get("content-type")+"";return t.match(/\bjson\b/i)?h(e).then((t=>({res:e,body:t}))):t.match(/^text\//i)?e.text().then((t=>({res:e,body:t}))):{res:e}})).then((({res:e,body:t})=>{if(!t&&201==e.status){const t=e.headers.get("location");if(t)return f(t,{...n,method:"GET",body:null,includeResponse:r})}return r?{body:t,response:e}:void 0===t?e:t}))}function p(e,t,r=!1){return r||!c[e]?(c[e]=f(e,t),c[e]):Promise.resolve(c[e])}function g(e,t=""){if(!(t=t.trim()))return e;let r=t.split("."),n=e;for(;n&&r.length;){const e=r.shift();if(!e&&Array.isArray(n))return n.map((e=>g(e,r.join("."))));n=n[e]}return n}function m(e){return Array.isArray(e)?e:[e]}function y(e,t){const r=e.split(".")[1];return r?JSON.parse(t.atob(r)):null}function w(e,t){const r={};function n(e,t){e&&Array.isArray(e.coding)&&e.coding.forEach((({code:e})=>{e&&(r[e]=r[e]||[],r[e].push(t))}))}return m(e).forEach((e=>{"Observation"===e.resourceType&&e[t]&&(Array.isArray(e[t])?e[t].forEach((t=>n(t,e))):n(e[t],e))})),r}function b(e,t){if(!e)throw new Error(t)}t.units={cm({code:e,value:t}){if(u({code:e,value:t}),"cm"==e)return t;if("m"==e)return 100*t;if("in"==e)return 2.54*t;if("[in_us]"==e)return 2.54*t;if("[in_i]"==e)return 2.54*t;if("ft"==e)return 30.48*t;if("[ft_us]"==e)return 30.48*t;throw new Error("Unrecognized length unit: "+e)},kg({code:e,value:t}){if(u({code:e,value:t}),"kg"==e)return t;if("g"==e)return t/1e3;if(e.match(/lb/))return t/2.20462;if(e.match(/oz/))return t/35.274;throw new Error("Unrecognized weight unit: "+e)},any:e=>(u(e),e.value)},t.checkResponse=l,t.responseToJSON=h,t.loweCaseKeys=d,t.request=f,t.getAndCache=p,t.fetchConformanceStatement=function(e="/",t){const r=String(e).replace(/\/*$/,"/")+"metadata";return p(r,t).catch((e=>{throw new Error(`Failed to fetch the conformance statement from "${r}". ${e}`)}))},t.getPath=g,t.setPath=function(e,t,r,n=!1){return t.trim().split(".").reduce(((e,t,o,s)=>{if(!e||o!==s.length-1)return e&&void 0===e[t]&&n&&(e[t]=s[o+1].match(/^[0-9]+$/)?[]:{}),e?e[t]:void 0;e[t]=r}),e),e},t.makeArray=m,t.absolute=function(e,t){return e.match(/^http/)||e.match(/^urn/)?e:String(t||"").replace(/\/+$/,"")+"/"+e.replace(/^\/+/,"")},t.randomString=function(e=8,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){const r=[],n=t.length;for(;e--;)r.push(t.charAt(Math.floor(Math.random()*n)));return r.join("")},t.jwtDecode=y,t.getTimeInFuture=function(e=120,t){return Math.floor(+(t||new Date)/1e3+e)},t.getAccessTokenExpiration=function(e,t){const r=Math.floor(Date.now()/1e3);if(e.expires_in)return r+e.expires_in;if(e.access_token){let r=y(e.access_token,t);if(r&&r.exp)return r.exp}return r+300},t.byCode=w,t.byCodes=function(e,t){const r=w(e,t);return(...e)=>e.filter((e=>e+""in r)).reduce(((e,t)=>e.concat(r[t+""])),[])},t.getPatientParam=function(e,t){const r=(g(e,"rest.0.resource")||[]).find((e=>e.type===t));if(!r)throw new Error(`Resource "${t}" is not supported by this FHIR server`);if(!Array.isArray(r.searchParam))throw new Error(`No search parameters supported for "${t}" on this FHIR server`);if("Patient"==t&&r.searchParam.find((e=>"_id"==e.name)))return"_id";const n=o.patientParams.find((e=>r.searchParam.find((t=>t.name==e))));if(!n)throw new Error("I don't know what param to use for "+t);return n},t.getTargetWindow=async function(e,t=800,r=720){if("function"==typeof e&&(e=await e()),e&&"object"==typeof e)return e;if("string"!=typeof e)return a("Invalid target type '%s'. Failing back to '_self'.",typeof e),self;if("_self"==e)return self;if("_parent"==e)return parent;if("_top"==e)return top||self;if("_blank"==e){let e,t=null;try{if(t=window.open("","SMARTAuthPopup"),!t)throw new Error("Perhaps window.open was blocked")}catch(t){e=t}return t||(a("Cannot open window. Failing back to '_self'. %s",e),self)}if("popup"==e){let e,n=null;try{if(n=window.open("","SMARTAuthPopup",["height="+r,"width="+t,"menubar=0","resizable=1","status=0","top="+(screen.height-r)/2,"left="+(screen.width-t)/2].join(",")),!n)throw new Error("Perhaps the popup window was blocked")}catch(t){e=t}return n||(a("Cannot open window. Failing back to '_self'. %s",e),self)}return frames[e]||(a("Unknown target '%s'. Failing back to '_self'.",e),self)},t.assert=b,t.assertJsonPatch=function(e){b(Array.isArray(e),"The JSON patch must be an array"),b(e.length>0,"The JSON patch array should not be empty"),e.forEach((e=>{b(["add","replace","test","move","copy","remove"].indexOf(e.op)>-1,'Each patch operation must have an "op" property which must be one of: "add", "replace", "test", "move", "copy", "remove"'),b(e.path&&typeof e.path,`Invalid "${e.op}" operation. Missing "path" property`),"add"==e.op||"replace"==e.op||"test"==e.op?(b("value"in e,`Invalid "${e.op}" operation. Missing "value" property`),b(3==Object.keys(e).length,`Invalid "${e.op}" operation. Contains unknown properties`)):"move"==e.op||"copy"==e.op?(b("string"==typeof e.from,`Invalid "${e.op}" operation. Requires a string "from" property`),b(3==Object.keys(e).length,`Invalid "${e.op}" operation. Contains unknown properties`)):b(2==Object.keys(e).length,`Invalid "${e.op}" operation. Contains unknown properties`)}))}},913:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signCompactJws=t.importJWK=t.generatePKCEChallenge=t.digestSha256=t.randomBytes=void 0;const n=r(575),o=(()=>{if("object"==typeof globalThis&&globalThis.crypto)return globalThis.crypto;throw new Error("window.crypto does not exist in this browser")})(),s=o.subtle,i={ES384:{name:"ECDSA",namedCurve:"P-384"},RS384:{name:"RSASSA-PKCS1-v1_5",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-384"}}};function a(e){return o.getRandomValues(new Uint8Array(e))}async function c(e){const t=(new TextEncoder).encode(e),r=await s.digest("SHA-256",t);return new Uint8Array(r)}t.randomBytes=a,t.digestSha256=c,t.generatePKCEChallenge=async(e=96)=>{const t=a(e),r=(0,n.fromUint8Array)(t,!0);return{codeChallenge:(0,n.fromUint8Array)(await c(r),!0),codeVerifier:r}},t.importJWK=async function(e){if(!e.alg)throw new Error('The "alg" property of the JWK must be set to "ES384" or "RS384"');if(Array.isArray(e.key_ops)||(e.key_ops=["sign"]),!e.key_ops.includes("sign"))throw new Error('The "key_ops" property of the JWK does not contain "sign"');try{return await s.importKey("jwk",e,i[e.alg],!0===e.ext,e.key_ops)}catch(t){throw new Error(`The ${e.alg} is not supported by this browser: ${t}`)}},t.signCompactJws=async function(e,t,r,o){const i=JSON.stringify({...r,alg:e}),a=JSON.stringify(o),c=`${(0,n.encodeURL)(i)}.${(0,n.encodeURL)(a)}`,u=await s.sign({...t.algorithm,hash:"SHA-384"},t,(new TextEncoder).encode(c));return`${c}.${(0,n.fromUint8Array)(new Uint8Array(u),!0)}`}},628:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SMART_KEY=t.patientParams=t.fhirVersions=t.patientCompartment=void 0,t.patientCompartment=["Account","AdverseEvent","AllergyIntolerance","Appointment","AppointmentResponse","AuditEvent","Basic","BodySite","BodyStructure","CarePlan","CareTeam","ChargeItem","Claim","ClaimResponse","ClinicalImpression","Communication","CommunicationRequest","Composition","Condition","Consent","Coverage","CoverageEligibilityRequest","CoverageEligibilityResponse","DetectedIssue","DeviceRequest","DeviceUseRequest","DeviceUseStatement","DiagnosticOrder","DiagnosticReport","DocumentManifest","DocumentReference","EligibilityRequest","Encounter","EnrollmentRequest","EpisodeOfCare","ExplanationOfBenefit","FamilyMemberHistory","Flag","Goal","Group","ImagingManifest","ImagingObjectSelection","ImagingStudy","Immunization","ImmunizationEvaluation","ImmunizationRecommendation","Invoice","List","MeasureReport","Media","MedicationAdministration","MedicationDispense","MedicationOrder","MedicationRequest","MedicationStatement","MolecularSequence","NutritionOrder","Observation","Order","Patient","Person","Procedure","ProcedureRequest","Provenance","QuestionnaireResponse","ReferralRequest","RelatedPerson","RequestGroup","ResearchSubject","RiskAssessment","Schedule","ServiceRequest","Specimen","SupplyDelivery","SupplyRequest","VisionPrescription"],t.fhirVersions={"0.4.0":2,"0.5.0":2,"1.0.0":2,"1.0.1":2,"1.0.2":2,"1.1.0":3,"1.4.0":3,"1.6.0":3,"1.8.0":3,"3.0.0":3,"3.0.1":3,"3.3.0":4,"3.5.0":4,"4.0.0":4,"4.0.1":4},t.patientParams=["patient","subject","requester","member","actor","beneficiary"],t.SMART_KEY="SMART_KEY"},349:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=t.buildTokenRequest=t.ready=t.onMessage=t.isInPopUp=t.isInFrame=t.authorize=t.getSecurityExtensions=t.fetchWellKnownJson=t.KEY=void 0;const n=r(458),o=r(946),s=r(628);Object.defineProperty(t,"KEY",{enumerable:!0,get:function(){return s.SMART_KEY}});const i=n.debug.extend("oauth2");function a(){return"object"==typeof window}function c(e="/",t){const r=String(e).replace(/\/*$/,"/")+".well-known/smart-configuration";return(0,n.getAndCache)(r,t).catch((e=>{throw new Error(`Failed to fetch the well-known json "${r}". ${e.message}`)}))}function u(e="/"){return function(e="/",t){return c(e,void 0).then((e=>{if(!e.authorization_endpoint||!e.token_endpoint)throw new Error("Invalid wellKnownJson");return{registrationUri:e.registration_endpoint||"",authorizeUri:e.authorization_endpoint,tokenUri:e.token_endpoint,codeChallengeMethods:e.code_challenge_methods_supported||[]}}))}(e).catch((()=>function(e="/",t){return(0,n.fetchConformanceStatement)(e,t).then((e=>{const t=((0,n.getPath)(e||{},"rest.0.security.extension")||[]).filter((e=>"http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris"===e.url)).map((e=>e.extension))[0],r={registrationUri:"",authorizeUri:"",tokenUri:"",codeChallengeMethods:[]};return t&&t.forEach((e=>{"register"===e.url&&(r.registrationUri=e.valueUri),"authorize"===e.url&&(r.authorizeUri=e.valueUri),"token"===e.url&&(r.tokenUri=e.valueUri)})),r}))}(e)))}async function l(e,t={}){const r=e.getUrl();if(Array.isArray(t)){const o=r.searchParams.get("iss")||r.searchParams.get("fhirServiceUrl");if(!o)throw new Error('Passing in an "iss" url parameter is required if authorize uses multiple configurations');const s=t.find((e=>{if(e.issMatch){if("function"==typeof e.issMatch)return!!e.issMatch(o);if("string"==typeof e.issMatch)return e.issMatch===o;if(e.issMatch instanceof RegExp)return e.issMatch.test(o)}return!1}));return(0,n.assert)(s,`No configuration found matching the current "iss" parameter "${o}"`),await l(e,s)}const{redirect_uri:o,clientSecret:c,fakeTokenResponse:p,patientId:g,encounterId:m,client_id:y,target:w,width:b,height:C,pkceMode:v,clientPublicKeySetUrl:k}=t;let{iss:S,launch:A,fhirServiceUrl:P,redirectUri:R,noRedirect:U,scope:F="",clientId:_,completeInTarget:E,clientPrivateJwk:x,stateKey:T}=t;const I=e.getStorage();S=r.searchParams.get("iss")||S,P=r.searchParams.get("fhirServiceUrl")||P,A=r.searchParams.get("launch")||A,_||(_=y),R||(R=o),R?R.match(/^https?\:\/\//)||(R=e.relative(R)):R=e.relative(".");const O=String(S||P||"");if(!O)throw new Error("No server url found. It must be specified as `iss` or as `fhirServiceUrl` parameter");if(S&&i("Making %s launch...",A?"EHR":"standalone"),A&&!F.match(/launch/)&&(F+=" launch"),a()){const e=h(),t=d();(e||t)&&!0!==E&&!1!==E&&(E=e,console.warn('Your app is being authorized from within an iframe or popup window. Please be explicit and provide a "completeInTarget" option. Use "true" to complete the authorization in the same window, or "false" to try to complete it in the parent or the opener window. See http://docs.smarthealthit.org/client-js/api.html'))}const j=await I.get(s.SMART_KEY);await I.unset(j),T=null!=T?T:(0,n.randomString)(16);const M={clientId:_,scope:F,redirectUri:R,serverUrl:O,clientSecret:c,clientPrivateJwk:x,tokenResponse:{},key:T,completeInTarget:E,clientPublicKeySetUrl:k};(!a()||(0,n.getPath)(e,"options.fullSessionStorageSupport"))&&await I.set(s.SMART_KEY,T),p&&Object.assign(M.tokenResponse,p),g&&Object.assign(M.tokenResponse,{patient:g}),m&&Object.assign(M.tokenResponse,{encounter:m});let z=R+"?state="+encodeURIComponent(T);if(P&&!S)return i("Making fake launch..."),await I.set(T,M),U?z:await e.redirect(z);const $=await u(O);if(Object.assign(M,$),await I.set(T,M),!M.authorizeUri)return U?z:await e.redirect(z);const q=["response_type=code","client_id="+encodeURIComponent(_||""),"scope="+encodeURIComponent(F),"redirect_uri="+encodeURIComponent(R),"aud="+encodeURIComponent(O),"state="+encodeURIComponent(T)];if(A&&q.push("launch="+encodeURIComponent(A)),function(e,t){if("disabled"===t)return!1;if("unsafeV1"===t)return!0;if("required"===t){if(!e)throw new Error("Required PKCE code challenge method (`S256`) was not found.");return!0}return e}($.codeChallengeMethods.includes("S256"),v)){let t=await e.security.generatePKCEChallenge();Object.assign(M,t),await I.set(T,M),q.push("code_challenge="+M.codeChallenge),q.push("code_challenge_method=S256")}if(z=M.authorizeUri+"?"+q.join("&"),U)return z;if(!w||!a())return await e.redirect(z);{let e;if(e=await(0,n.getTargetWindow)(w,b,C),e!==self)try{e.sessionStorage.removeItem(j),e.sessionStorage.setItem(T,JSON.stringify(M))}catch(t){(0,n.debug)('Failed to modify window.sessionStorage. Perhaps it is from different origin?. Failing back to "_self". %s',t),e=self}if(e!==self)try{e.location.href=z,self.addEventListener("message",f)}catch(e){(0,n.debug)('Failed to modify window.location. Perhaps it is from different origin?. Failing back to "_self". %s',e),self.location.href=z}else self.location.href=z}}function h(){try{return self!==top&&parent!==self}catch(e){return!0}}function d(){try{return self===top&&!!opener&&opener!==self&&!!window.name}catch(e){return!1}}function f(e){"completeAuth"==e.data.type&&e.origin===new URL(self.location.href).origin&&(window.removeEventListener("message",f),window.location.href=e.data.url)}async function p(e,t={}){var r,c;const u=e.getUrl(),l=e.getStorage(),f=u.searchParams;let p=f.get("state");const m=f.get("code"),y=f.get("error"),w=f.get("error_description");if(p||(p=await l.get(s.SMART_KEY)),y||w)throw new Error([y,w].filter(Boolean).join(": "));i("key: %s, code: %s",p,m),(0,n.assert)(p,"No 'state' parameter found. Please (re)launch the app.");let b=await l.get(p);const C=!a()||(0,n.getPath)(e,"options.fullSessionStorageSupport");if(a()&&b&&!b.completeInTarget){const e=h(),t=d();if((e||t)&&!u.searchParams.get("complete")){u.searchParams.set("complete","1");const{href:r,origin:n}=u;return e&&parent.postMessage({type:"completeAuth",url:r},n),t&&(opener.postMessage({type:"completeAuth",url:r},n),window.close()),new Promise((()=>{}))}}u.searchParams.delete("complete");const v=f.has("state");if(a()&&(0,n.getPath)(e,"options.replaceBrowserHistory")&&(m||v)&&(m&&(f.delete("code"),i("Removed code parameter from the url.")),v&&C&&(f.delete("state"),i("Removed state parameter from the url.")),window.history.replaceState&&window.history.replaceState({},"",u.href)),(0,n.assert)(b,"No state found! Please (re)launch the app."),m&&!(null===(r=b.tokenResponse)||void 0===r?void 0:r.access_token)&&b.tokenUri){(0,n.assert)(m,"'code' url parameter is required"),i("Preparing to exchange the code for access token...");const r=await g(e,{code:m,state:b,clientPublicKeySetUrl:t.clientPublicKeySetUrl,privateKey:t.privateKey||b.clientPrivateJwk});i("Token request options: %O",r);const o=await(0,n.request)(b.tokenUri,r);i("Token response: %O",o),(0,n.assert)(o.access_token,"Failed to obtain access token."),b.expiresAt=(0,n.getAccessTokenExpiration)(o,e),b={...b,tokenResponse:o},await l.set(p,b),i("Authorization successful!")}else i((null===(c=b.tokenResponse)||void 0===c?void 0:c.access_token)?"Already authorized":"No authorization needed");C&&await l.set(s.SMART_KEY,p);const k=new o.default(e,b);return i("Created client instance: %O",k),k}async function g(e,{code:t,state:r,clientPublicKeySetUrl:o,privateKey:s}){const{redirectUri:a,clientSecret:c,tokenUri:u,clientId:l,codeVerifier:h}=r;(0,n.assert)(a,"Missing state.redirectUri"),(0,n.assert)(u,"Missing state.tokenUri"),(0,n.assert)(l,"Missing state.clientId");const d={method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:`code=${t}&grant_type=authorization_code&redirect_uri=${encodeURIComponent(a)}`};if(c)d.headers.authorization="Basic "+e.btoa(l+":"+c),i("Using state.clientSecret to construct the authorization header: %s",d.headers.authorization);else if(s){const t="key"in s?s.key:await e.security.importJWK(s),a={typ:"JWT",kid:s.kid,jku:o||r.clientPublicKeySetUrl},c={iss:l,sub:l,aud:u,jti:e.base64urlencode(e.security.randomBytes(32)),exp:(0,n.getTimeInFuture)(120)},h=await e.security.signCompactJws(s.alg,t,a,c);d.body+=`&client_assertion_type=${encodeURIComponent("urn:ietf:params:oauth:client-assertion-type:jwt-bearer")}`,d.body+=`&client_assertion=${encodeURIComponent(h)}`,i("Using state.clientPrivateJwk to add a client_assertion to the POST body")}else i("Public client detected; adding state.clientId to the POST body"),d.body+=`&client_id=${encodeURIComponent(l)}`;return h&&(i("Found state.codeVerifier, adding to the POST body"),d.body+="&code_verifier="+h),d}t.fetchWellKnownJson=c,t.getSecurityExtensions=u,t.authorize=l,t.isInFrame=h,t.isInPopUp=d,t.onMessage=f,t.ready=p,t.buildTokenRequest=g,t.init=async function(e,t,r){const n=e.getUrl(),i=n.searchParams.get("code"),a=n.searchParams.get("state");if(i&&a)return p(e,r);const c=e.getStorage(),u=a||await c.get(s.SMART_KEY),h=await c.get(u);return h?new o.default(e,h):l(e,t).then((()=>new Promise((()=>{}))))}},424:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{async get(e){const t=sessionStorage[e];return t?JSON.parse(t):null}async set(e,t){return sessionStorage[e]=JSON.stringify(t),t}async unset(e){return e in sessionStorage&&(delete sessionStorage[e],!0)}}},612:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={expired:"Session expired! Please re-launch the app",noScopeForId:"Trying to get the ID of the selected %s. Please add 'launch' or 'launch/%s' to the requested scopes and try again.",noIfNoAuth:"You are trying to get %s but the app is not authorized yet.",noFreeContext:"Please don't use open fhir servers if you need to access launch context items like the %S."}},227:(e,t,r)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(447)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:(e,t,r)=>{e.exports=function(e){function t(e){let r,o,s,i=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),s=o-(r||o);n.diff=s,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];r=s.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},575:function(e,t,r){"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==r.g&&r.g,e.exports=function(){"use strict";var e,t="3.7.2",r="function"==typeof atob,n="function"==typeof btoa,o="function"==typeof Buffer,s="function"==typeof TextDecoder?new TextDecoder:void 0,i="function"==typeof TextEncoder?new TextEncoder:void 0,a=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),c=(e={},a.forEach((function(t,r){return e[t]=r})),e),u=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,l=String.fromCharCode.bind(String),h="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(e,t){return void 0===t&&(t=function(e){return e}),new Uint8Array(Array.prototype.slice.call(e,0).map(t))},d=function(e){return e.replace(/=/g,"").replace(/[+\/]/g,(function(e){return"+"==e?"-":"_"}))},f=function(e){return e.replace(/[^A-Za-z0-9\+\/]/g,"")},p=function(e){for(var t,r,n,o,s="",i=e.length%3,c=0;c<e.length;){if((r=e.charCodeAt(c++))>255||(n=e.charCodeAt(c++))>255||(o=e.charCodeAt(c++))>255)throw new TypeError("invalid character found");s+=a[(t=r<<16|n<<8|o)>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}return i?s.slice(0,i-3)+"===".substring(i):s},g=n?function(e){return btoa(e)}:o?function(e){return Buffer.from(e,"binary").toString("base64")}:p,m=o?function(e){return Buffer.from(e).toString("base64")}:function(e){for(var t=[],r=0,n=e.length;r<n;r+=4096)t.push(l.apply(null,e.subarray(r,r+4096)));return g(t.join(""))},y=function(e,t){return void 0===t&&(t=!1),t?d(m(e)):m(e)},w=function(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?l(192|t>>>6)+l(128|63&t):l(224|t>>>12&15)+l(128|t>>>6&63)+l(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return l(240|t>>>18&7)+l(128|t>>>12&63)+l(128|t>>>6&63)+l(128|63&t)},b=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,C=function(e){return e.replace(b,w)},v=o?function(e){return Buffer.from(e,"utf8").toString("base64")}:i?function(e){return m(i.encode(e))}:function(e){return g(C(e))},k=function(e,t){return void 0===t&&(t=!1),t?d(v(e)):v(e)},S=function(e){return k(e,!0)},A=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,P=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return l(55296+(t>>>10))+l(56320+(1023&t));case 3:return l((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return l((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},R=function(e){return e.replace(A,P)},U=function(e){if(e=e.replace(/\s+/g,""),!u.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));for(var t,r,n,o="",s=0;s<e.length;)t=c[e.charAt(s++)]<<18|c[e.charAt(s++)]<<12|(r=c[e.charAt(s++)])<<6|(n=c[e.charAt(s++)]),o+=64===r?l(t>>16&255):64===n?l(t>>16&255,t>>8&255):l(t>>16&255,t>>8&255,255&t);return o},F=r?function(e){return atob(f(e))}:o?function(e){return Buffer.from(e,"base64").toString("binary")}:U,_=o?function(e){return h(Buffer.from(e,"base64"))}:function(e){return h(F(e),(function(e){return e.charCodeAt(0)}))},E=function(e){return _(T(e))},x=o?function(e){return Buffer.from(e,"base64").toString("utf8")}:s?function(e){return s.decode(_(e))}:function(e){return R(F(e))},T=function(e){return f(e.replace(/[-_]/g,(function(e){return"-"==e?"+":"/"})))},I=function(e){return x(T(e))},O=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}},j=function(){var e=function(e,t){return Object.defineProperty(String.prototype,e,O(t))};e("fromBase64",(function(){return I(this)})),e("toBase64",(function(e){return k(this,e)})),e("toBase64URI",(function(){return k(this,!0)})),e("toBase64URL",(function(){return k(this,!0)})),e("toUint8Array",(function(){return E(this)}))},M=function(){var e=function(e,t){return Object.defineProperty(Uint8Array.prototype,e,O(t))};e("toBase64",(function(e){return y(this,e)})),e("toBase64URI",(function(){return y(this,!0)})),e("toBase64URL",(function(){return y(this,!0)}))},z={version:t,VERSION:"3.7.2",atob:F,atobPolyfill:U,btoa:g,btoaPolyfill:p,fromBase64:I,toBase64:k,encode:k,encodeURI:S,encodeURL:S,utob:C,btou:R,decode:I,isValid:function(e){if("string"!=typeof e)return!1;var t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},fromUint8Array:y,toUint8Array:E,extendString:j,extendUint8Array:M,extendBuiltins:function(){j(),M()},Base64:{}};return Object.keys(z).forEach((function(e){return z.Base64[e]=z[e]})),z}()},824:e=>{var t=1e3,r=60*t,n=60*r,o=24*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}e.exports=function(e,i){i=i||{};var a,c,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(s){var i=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*i;case"weeks":case"week":case"w":return 6048e5*i;case"days":case"day":case"d":return i*o;case"hours":case"hour":case"hrs":case"hr":case"h":return i*n;case"minutes":case"minute":case"mins":case"min":case"m":return i*r;case"seconds":case"second":case"secs":case"sec":case"s":return i*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}}}(e);if("number"===u&&isFinite(e))return i.long?(a=e,(c=Math.abs(a))>=o?s(a,c,o,"day"):c>=n?s(a,c,n,"hour"):c>=r?s(a,c,r,"minute"):c>=t?s(a,c,t,"second"):a+" ms"):function(e){var s=Math.abs(e);return s>=o?Math.round(e/o)+"d":s>=n?Math.round(e/n)+"h":s>=r?Math.round(e/r)+"m":s>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var n=r(769);window.FHIR=n})(); //# sourceMappingURL=fhir-client.pure.min.js.map