@medplum/core 0.9.13 → 0.9.16
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.js +184 -173
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +184 -173
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/client.d.ts +12 -0
- package/package.json +2 -2
- package/cody-pdf-test.js +0 -32
- package/wget-log +0 -6
package/dist/esm/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}l((i=i.apply(t,e||[])).next())}))}function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n}var i,r,s,o;class a{constructor(t=10){i.add(this),r.set(this,void 0),s.set(this,void 0),n(this,r,t,"f"),n(this,s,new Map,"f")}clear(){e(this,s,"f").clear()}get(t){const n=e(this,s,"f").get(t);return n&&(e(this,s,"f").delete(t),e(this,s,"f").set(t,n)),n}set(t,n){e(this,s,"f").has(t)?e(this,s,"f").delete(t):e(this,s,"f").size>=e(this,r,"f")&&e(this,s,"f").delete(e(this,i,"m",o).call(this)),e(this,s,"f").set(t,n)}delete(t){e(this,s,"f").delete(t)}keys(){return e(this,s,"f").keys()}}function l(t,e){const n=[];return t.line&&n.push(...t.line),t.city&&n.push(t.city),t.state&&n.push(t.state),t.postalCode&&n.push(t.postalCode),t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&n.push("["+t.use+"]"),n.join(", ").trim()}function c(t,e){const n=[];return t.prefix&&((null==e?void 0:e.all)||(null==e?void 0:e.prefix))&&n.push(...t.prefix),t.given&&n.push(...t.given),t.family&&n.push(t.family),t.suffix&&((null==e?void 0:e.all)||(null==e?void 0:e.suffix))&&n.push(...t.suffix),t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&n.push("["+t.use+"]"),n.join(" ").trim()}function u(t){const e=[];return t.given&&e.push(...t.given),e.join(" ").trim()}function h(t){return t.family||""}function f(t){const e=d(t),n=g(t);return n===e?{reference:e}:{reference:e,display:n}}function d(t){return t.resourceType+"/"+t.id}function v(t){var e;return null===(e=null==t?void 0:t.reference)||void 0===e?void 0:e.split("/")[1]}function p(t){return"Patient"===t.resourceType||"Practitioner"===t.resourceType||"RelatedPerson"===t.resourceType}function g(t){var e,n;if(p(t)){const e=function(t){const e=t.name;if(e&&e.length>0)return c(e[0]);return}(t);if(e)return e}if("Device"===t.resourceType){const e=function(t){const e=t.deviceName;if(e&&e.length>0)return e[0].name;return}(t);if(e)return e}return"Observation"===t.resourceType&&"code"in t&&(null===(e=t.code)||void 0===e?void 0:e.text)?null===(n=t.code)||void 0===n?void 0:n.text:"User"===t.resourceType&&t.email?t.email:"name"in t&&t.name&&"string"==typeof t.name?t.name:d(t)}function m(t){if(p(t)){const e=t.photo;if(e)for(const t of e){const e=y(t);if(e)return e}}if("Bot"===t.resourceType&&t.photo){const e=y(t.photo);if(e)return e}}function y(t){if(t.url&&t.contentType&&t.contentType.startsWith("image/"))return t.url}function w(t){return t?new Date(t):void 0}function b(t,e){const n=new Date(t);n.setUTCHours(0,0,0,0);const i=e?new Date(e):new Date;i.setUTCHours(0,0,0,0);const r=n.getUTCFullYear(),s=n.getUTCMonth(),o=n.getUTCDate(),a=i.getUTCFullYear(),l=i.getUTCMonth(),c=i.getUTCDate();let u=a-r;(l<s||l===s&&c<o)&&u--;let h=12*a+l-(12*r+s);c<o&&h--;return{years:u,months:h,days:Math.floor((i.getTime()-n.getTime())/864e5)}}function T(t,e){const{years:n,months:i,days:r}=b(t,e);return n>=2?n.toString().padStart(3,"0")+"Y":i>=1?i.toString().padStart(3,"0")+"M":r.toString().padStart(3,"0")+"D"}function E(t){const e={};return S(t.item,e),e}function S(t,e){if(t)for(const n of t)n.linkId&&n.answer&&n.answer.length>0&&(e[n.linkId]=n.answer[0]),S(n.item,e)}function A(t,e){const n=t.identifier;if(!n)return;const i=Array.isArray(n)?n:[n];for(const t of i)if(t.system===e)return t.value}function k(t,...e){var n;let i=t;for(let t=0;t<e.length&&i;t++)i=null===(n=null==i?void 0:i.extension)||void 0===n?void 0:n.find((n=>n.url===e[t]));return null==i?void 0:i.valueString}function x(t,e){return JSON.stringify(t,P,e?2:void 0)}function P(t,e){return!function(t){return!!t.match(/\d+$/)}(t)&&O(e)?void 0:e}function O(t){if(null==t)return!0;const e=typeof t;return"string"===e&&""===t||"object"===e&&0===Object.keys(t).length}function U(t,e,n){return t===e||(!(!O(t)||!O(e))||!O(t)&&!O(e)&&(Array.isArray(t)&&Array.isArray(e)?function(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!U(t[n],e[n]))return!1;return!0}(t,e):!Array.isArray(t)&&!Array.isArray(e)&&(R(t)&&R(e)?function(t,e,n){const i=new Set;Object.keys(t).forEach((t=>i.add(t))),Object.keys(e).forEach((t=>i.add(t))),"meta"===n&&(i.delete("versionId"),i.delete("lastUpdated"),i.delete("author"));for(const n of i){if(!U(t[n],e[n],n))return!1}return!0}(t,e,n):(R(t)||R(e),!1))))}function M(t){return!!t.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)}function R(t){return null!==t&&"object"==typeof t}function C(t){return t.every((t=>"string"==typeof t))}r=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(){return e(this,s,"f").keys().next().value};const L=[];for(let t=0;t<256;t++)L.push(t.toString(16).padStart(2,"0"));function D(t){const e=new Uint8Array(t),n=new Array(e.length);for(let t=0;t<e.length;t++)n[t]=L[e[t]];return n.join("")}function _(t){const e=new Uint8Array(t),n=[];for(let t=0;t<e.length;t++)n[t]=String.fromCharCode(e[t]);return window.btoa(n.join(""))}function I(t){return t.charAt(0).toUpperCase()+t.substring(1)}function j(t){return t===t.toLowerCase()}function W(t,e){var n,i;return null===(i=null===(n=null==t?void 0:t.coding)||void 0===n?void 0:n.find((t=>t.system===e)))||void 0===i?void 0:i.code}function N(t,e,n){var i,r;t.coding||(t.coding=[]);const s=null===(i=t.coding)||void 0===i?void 0:i.find((t=>t.system===e));s?s.code=n:null===(r=t.coding)||void 0===r||r.push({system:e,code:n})}function B(t,e,n,i){var r;return null===(r=t.qualifiedInterval)||void 0===r?void 0:r.find((r=>{var s;return function(t,e){return function(t,e){return!t.gender||t.gender===e.gender}(t,e)&&function(t,e){return!t.age||Q(b(e.birthDate).years,t.age)}(t,e)}(r,e)&&function(t,e,n){return!!t.range&&Q(e,t.range,n)}(r,n,null===(s=t.quantitativeDetails)||void 0===s?void 0:s.decimalPrecision)&&(void 0===i||r.category===i)}))}function Q(t,e,n){var i,r;return(void 0===(null===(i=e.low)||void 0===i?void 0:i.value)||X(t,e.low.value,n))&&(void 0===(null===(r=e.high)||void 0===r?void 0:r.value)||q(t,e.high.value,n))}function $(t,e,n){return n?Math.abs(t-e)<Math.pow(10,-n):t===e}function F(t,e,n){return n?t<e&&Math.abs(t-e)>Math.pow(10,-n):t<e}function H(t,e,n){return n?t>e&&Math.abs(t-e)>Math.pow(10,-n):t>e}function q(t,e,n){return F(t,e,n)||$(t,e,n)}function X(t,e,n){return H(t,e,n)||$(t,e,n)}function z(){const t=new Uint32Array(28);return crypto.getRandomValues(t),D(t.buffer)}var Y;function V(t){const e=function(t){if("undefined"!=typeof window)return window.atob(t);if("undefined"!=typeof Buffer)return Buffer.from(t,"base64").toString("binary");throw new Error("Unable to decode base64")}(t.replace(/-/g,"+").replace(/_/g,"/")),n=Array.from(e).reduce(((t,e)=>`${t}%${("00"+e.charCodeAt(0).toString(16)).slice(-2)}`),""),i=decodeURIComponent(n);return JSON.parse(i)}Y=new WeakMap;const G={resourceType:"OperationOutcome",id:"ok",issue:[{severity:"information",code:"information",details:{text:"All OK"}}]},K={resourceType:"OperationOutcome",id:"created",issue:[{severity:"information",code:"information",details:{text:"Created"}}]},J={resourceType:"OperationOutcome",id:"not-modified",issue:[{severity:"information",code:"information",details:{text:"Not Modified"}}]},Z={resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},tt={resourceType:"OperationOutcome",id:"gone",issue:[{severity:"error",code:"gone",details:{text:"Gone"}}]},et={resourceType:"OperationOutcome",id:"access-denied",issue:[{severity:"error",code:"access-denied",details:{text:"Access Denied"}}]};function nt(t,e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:t},expression:e?[e]:void 0}]}}function it(t){return"ok"===t.id||"created"===t.id||"not-modified"===t.id}function rt(t){return"not-found"===t.id}function st(t){return"gone"===t.id}function ot(t){return"ok"===t.id?200:"created"===t.id?201:"not-modified"===t.id?304:"access-denied"===t.id?403:"not-found"===t.id?404:"gone"===t.id?410:400}function at(t,e){if(!it(t)||void 0===e)throw new lt(t)}class lt extends Error{constructor(t){var e,n;super(null===(n=null===(e=null==t?void 0:t.issue)||void 0===e?void 0:e[0].details)||void 0===n?void 0:n.text),this.outcome=t}}var ct,ut,ht,ft,dt,vt,pt,gt,mt,yt,wt,bt,Tt,Et,St,At,kt,xt,Pt,Ot,Ut,Mt,Rt,Ct,Lt,Dt,_t,It,jt,Wt,Nt,Bt,Qt,$t,Ft,Ht,qt,Xt,zt;class Yt{constructor(t){this[dt]="ReadablePromise",ct.set(this,void 0),ut.set(this,"pending"),ht.set(this,void 0),ft.set(this,void 0),n(this,ct,t.then((t=>(n(this,ut,"success","f"),n(this,ht,t,"f"),t)),(t=>{throw n(this,ut,"error","f"),n(this,ft,t,"f"),t})),"f")}isPending(){return"pending"===e(this,ut,"f")}read(){switch(e(this,ut,"f")){case"pending":throw e(this,ct,"f");case"error":throw e(this,ft,"f");default:return e(this,ht,"f")}}then(t,n){return e(this,ct,"f").then(t,n)}catch(t){return e(this,ct,"f").catch(t)}finally(t){return e(this,ct,"f").finally(t)}}ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,ft=new WeakMap,dt=Symbol.toStringTag;class Vt{constructor(){vt.set(this,void 0),n(this,vt,"undefined"!=typeof localStorage?localStorage:new Gt,"f")}clear(){e(this,vt,"f").clear()}getString(t){return e(this,vt,"f").getItem(t)||void 0}setString(t,n){n?e(this,vt,"f").setItem(t,n):e(this,vt,"f").removeItem(t)}getObject(t){const e=this.getString(t);return e?JSON.parse(e):void 0}setObject(t,e){this.setString(t,e?x(e):void 0)}}vt=new WeakMap;class Gt{constructor(){pt.set(this,void 0),n(this,pt,new Map,"f")}get length(){return e(this,pt,"f").size}clear(){e(this,pt,"f").clear()}getItem(t){var n;return null!==(n=e(this,pt,"f").get(t))&&void 0!==n?n:null}setItem(t,n){n?e(this,pt,"f").set(t,n):e(this,pt,"f").delete(t)}removeItem(t){e(this,pt,"f").delete(t)}key(t){return Array.from(e(this,pt,"f").keys())[t]}}function Kt(){return{types:{}}}function Jt(t,e){return{display:t,description:e,properties:{},searchParams:{_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"}}}}function Zt(t,e){var n;const i=e.name;if(!i)return;t.types[i]=Jt(i,e.description);const r=null===(n=e.snapshot)||void 0===n?void 0:n.element;if(r){const e=r.filter((t=>t.path!==i&&t.path));e.forEach((e=>function(t,e){var n,i;const r=e.path,s=null===(i=null===(n=e.type)||void 0===n?void 0:n[0])||void 0===i?void 0:i.code;if("Element"!==s&&"BackboneElement"!==s)return;const o=r.split("."),a=ee(o);a in t.types||(t.types[a]=Jt(a,e.definition),t.types[a].parentType=ee(o.slice(0,o.length-1)))}(t,e))),e.forEach((e=>function(t,e){const n=e.path.split(".");if(1===n.length)return;const i=ee(n.slice(0,n.length-1)),r=t.types[i],s=n[n.length-1];r.properties[s]=e}(t,e)))}}function te(t,e){if(e.base)for(const n of e.base){const i=t.types[n];i&&(i.searchParams||(i.searchParams={}),i.searchParams[e.code]=e)}}function ee(t){return t.map(I).join("")}function ne(t){const e=t.path.replaceAll("[x]","").split(".").pop();return"id"===e?"ID":e.split(/(?=[A-Z])/).map(I).join(" ").replace("_"," ").replace(/\s+/g," ")}pt=new WeakMap,function(t){t.Address="Address",t.Age="Age",t.Annotation="Annotation",t.Attachment="Attachment",t.BackboneElement="BackboneElement",t.CodeableConcept="CodeableConcept",t.Coding="Coding",t.ContactDetail="ContactDetail",t.ContactPoint="ContactPoint",t.Contributor="Contributor",t.Count="Count",t.DataRequirement="DataRequirement",t.Distance="Distance",t.Dosage="Dosage",t.Duration="Duration",t.Expression="Expression",t.Extension="Extension",t.HumanName="HumanName",t.Identifier="Identifier",t.MarketingStatus="MarketingStatus",t.Meta="Meta",t.Money="Money",t.Narrative="Narrative",t.ParameterDefinition="ParameterDefinition",t.Period="Period",t.Population="Population",t.ProdCharacteristic="ProdCharacteristic",t.ProductShelfLife="ProductShelfLife",t.Quantity="Quantity",t.Range="Range",t.Ratio="Ratio",t.Reference="Reference",t.RelatedArtifact="RelatedArtifact",t.Resource="Resource",t.SampledData="SampledData",t.Signature="Signature",t.SubstanceAmount="SubstanceAmount",t.SystemString="http://hl7.org/fhirpath/System.String",t.Timing="Timing",t.TriggerDefinition="TriggerDefinition",t.UsageContext="UsageContext",t.base64Binary="base64Binary",t.boolean="boolean",t.canonical="canonical",t.code="code",t.date="date",t.dateTime="dateTime",t.decimal="decimal",t.id="id",t.instant="instant",t.integer="integer",t.markdown="markdown",t.oid="oid",t.positiveInt="positiveInt",t.string="string",t.time="time",t.unsignedInt="unsignedInt",t.uri="uri",t.url="url",t.uuid="uuid"}(gt||(gt={}));const ie="launch/patient openid fhirUser offline_access user/*.*";class re extends class{constructor(){Y.set(this,void 0),n(this,Y,{},"f")}addEventListener(t,n){e(this,Y,"f")[t]||(e(this,Y,"f")[t]=[]),e(this,Y,"f")[t].push(n)}removeEventListeneer(t,n){const i=e(this,Y,"f")[t];if(i)for(let t=0;t<i.length;t++)if(i[t]===n)return void i.splice(t,1)}dispatchEvent(t){const n=e(this,Y,"f")[t.type];return n&&n.forEach((e=>e.call(this,t))),!t.defaultPrevented}}{constructor(t){var i;if(super(),mt.add(this),yt.set(this,void 0),wt.set(this,void 0),bt.set(this,void 0),Tt.set(this,void 0),Et.set(this,void 0),St.set(this,void 0),At.set(this,void 0),kt.set(this,void 0),xt.set(this,void 0),Pt.set(this,void 0),Ot.set(this,void 0),Ut.set(this,void 0),Mt.set(this,void 0),Rt.set(this,void 0),Ct.set(this,void 0),Lt.set(this,void 0),Dt.set(this,void 0),null==t?void 0:t.baseUrl){if(!t.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");if(!t.baseUrl.endsWith("/"))throw new Error("Base URL must end with a trailing slash")}n(this,yt,(null==t?void 0:t.fetch)||window.fetch.bind(window),"f"),n(this,wt,null==t?void 0:t.createPdf,"f"),n(this,bt,new Vt,"f"),n(this,Tt,{types:{}},"f"),n(this,Et,new a(null!==(i=null==t?void 0:t.resourceCacheSize)&&void 0!==i?i:1e3),"f"),n(this,St,(null==t?void 0:t.baseUrl)||"https://api.medplum.com/","f"),n(this,At,(null==t?void 0:t.clientId)||"","f"),n(this,kt,(null==t?void 0:t.authorizeUrl)||e(this,St,"f")+"oauth2/authorize","f"),n(this,xt,(null==t?void 0:t.tokenUrl)||e(this,St,"f")+"oauth2/token","f"),n(this,Pt,(null==t?void 0:t.logoutUrl)||e(this,St,"f")+"oauth2/logout","f"),n(this,Ot,null==t?void 0:t.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(n(this,Ut,r.accessToken,"f"),n(this,Mt,r.refreshToken,"f"),e(this,mt,"m",It).call(this).catch(console.log)),e(this,mt,"m",zt).call(this)}getBaseUrl(){return e(this,St,"f")}clear(){e(this,bt,"f").clear(),e(this,Et,"f").clear(),n(this,Ut,void 0,"f"),n(this,Mt,void 0,"f"),n(this,Lt,void 0,"f"),n(this,Dt,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(t){t=t.toString(),e(this,Et,"f").delete(t)}invalidateSearches(t){const n="fhir/R4/"+t;for(const t of e(this,Et,"f").keys())(t.endsWith(n)||t.includes(n+"?"))&&e(this,Et,"f").delete(t)}get(t,n={}){if(t=t.toString(),!(null==n?void 0:n.cache)){const n=e(this,Et,"f").get(t);if(n)return n}const i=new Yt(e(this,mt,"m",jt).call(this,"GET",t,n));return e(this,Et,"f").set(t,i),i}post(t,n,i,r={}){return t=t.toString(),n&&e(this,mt,"m",Bt).call(this,r,n),i&&e(this,mt,"m",Nt).call(this,r,i),this.invalidateUrl(t),e(this,mt,"m",jt).call(this,"POST",t,r)}put(t,n,i,r={}){return t=t.toString(),n&&e(this,mt,"m",Bt).call(this,r,n),i&&e(this,mt,"m",Nt).call(this,r,i),this.invalidateUrl(t),e(this,mt,"m",jt).call(this,"PUT",t,r)}patch(t,n,i={}){return t=t.toString(),e(this,mt,"m",Bt).call(this,i,n),e(this,mt,"m",Nt).call(this,i,"application/json-patch+json"),this.invalidateUrl(t),e(this,mt,"m",jt).call(this,"PATCH",t,i)}delete(t,n={}){return t=t.toString(),this.invalidateUrl(t),e(this,mt,"m",jt).call(this,"DELETE",t,n)}register(e){return t(this,void 0,void 0,(function*(){const t=yield this.post("auth/register",e);yield this.setActiveLogin(t)}))}startLogin(n){return t(this,void 0,void 0,(function*(){return yield e(this,mt,"m",$t).call(this),this.post("auth/login",Object.assign(Object.assign({},n),{clientId:e(this,At,"f"),scope:ie,codeChallengeMethod:"S256",codeChallenge:e(this,bt,"f").getString("codeChallenge")}))}))}startGoogleLogin(n){return t(this,void 0,void 0,(function*(){return yield e(this,mt,"m",$t).call(this),this.post("auth/google",n)}))}signOut(){return this.clear(),Promise.resolve()}signInWithRedirect(){const t=new URLSearchParams(window.location.search).get("code");return t?this.processCode(t):void e(this,mt,"m",Ft).call(this)}signOutWithRedirect(){window.location.assign(e(this,Pt,"f"))}fhirUrl(...t){return new URL(e(this,St,"f")+"fhir/R4/"+t.join("/"))}fhirSearchUrl(t,e){const n=this.fhirUrl(t);return e&&(n.search=e.toString()),n}search(t,e,n={}){return this.get(this.fhirSearchUrl(t,e),n)}searchOne(t,n,i={}){const r=this.fhirSearchUrl(t,n);r.searchParams.set("_count","1"),r.searchParams.sort();const s=r.toString()+"-searchOne";if(!(null==i?void 0:i.cache)){const t=e(this,Et,"f").get(s);if(t)return t}const o=new Yt(this.search(t,r.searchParams,i).then((t=>{var e,n;return null===(n=null===(e=t.entry)||void 0===e?void 0:e[0])||void 0===n?void 0:n.resource})));return e(this,Et,"f").set(s,o),o}searchResources(t,n,i={}){const r=this.fhirSearchUrl(t,n).toString()+"-searchResources";if(!(null==i?void 0:i.cache)){const t=e(this,Et,"f").get(r);if(t)return t}const s=new Yt(this.search(t,n,i).then((t=>{var e,n;return null!==(n=null===(e=t.entry)||void 0===e?void 0:e.map((t=>t.resource)))&&void 0!==n?n:[]})));return e(this,Et,"f").set(r,s),s}searchValueSet(t,e,n={}){const i=this.fhirUrl("ValueSet","$expand");return i.searchParams.set("url",t),i.searchParams.set("filter",e),this.get(i.toString(),n)}getCached(t,n){const i=e(this,Et,"f").get(this.fhirUrl(t,n).toString());return i&&!i.isPending()?i.read():void 0}getCachedReference(t){const e=t.reference;if(!e)return;const[n,i]=e.split("/");return n&&i?this.getCached(n,i):void 0}readResource(t,e){return this.get(this.fhirUrl(t,e))}readReference(t){const e=null==t?void 0:t.reference;if(!e)return new Yt(Promise.reject(new Error("Missing reference")));const[n,i]=e.split("/");return n&&i?this.readResource(n,i):new Yt(Promise.reject(new Error("Invalid reference")))}getSchema(){return e(this,Tt,"f")}requestSchema(n){return t(this,void 0,void 0,(function*(){if(n in e(this,Tt,"f").types)return Promise.resolve(e(this,Tt,"f"));const t=`{\n StructureDefinitionList(name: "${n}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${n}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(t);for(const t of i.data.StructureDefinitionList)Zt(e(this,Tt,"f"),t);for(const t of i.data.SearchParameterList)te(e(this,Tt,"f"),t);return e(this,Tt,"f")}))}readHistory(t,e){return this.get(this.fhirUrl(t,e,"_history"))}readVersion(t,e,n){return this.get(this.fhirUrl(t,e,"_history",n))}readPatientEverything(t){return this.get(this.fhirUrl("Patient",t,"$everything"))}createResource(t){if(!t.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(t.resourceType),this.post(this.fhirUrl(t.resourceType),t)}createResourceIfNoneExist(e,n){var i;return t(this,void 0,void 0,(function*(){return null!==(i=yield this.searchOne(e.resourceType,n))&&void 0!==i?i:this.createResource(e)}))}createBinary(t,e,n){const i=this.fhirUrl("Binary");return e&&i.searchParams.set("_filename",e),this.post(i,t,n)}createPdf(n,i,r,s){return t(this,void 0,void 0,(function*(){if(!e(this,wt,"f"))throw new Error("PDF creation not enabled");const t=yield e(this,wt,"f").call(this,n,r,s);return this.createBinary(t,i,"application/pdf")}))}createComment(t,e){const n=this.getProfile();let i,r;return"Encounter"===t.resourceType&&(i=f(t),r=t.subject),"ServiceRequest"===t.resourceType&&(i=t.encounter,r=t.subject),"Patient"===t.resourceType&&(r=f(t)),this.createResource({resourceType:"Communication",basedOn:[f(t)],encounter:i,subject:r,sender:n?f(n):void 0,sent:(new Date).toISOString(),payload:[{contentString:e}]})}updateResource(t){if(!t.resourceType)throw new Error("Missing resourceType");if(!t.id)throw new Error("Missing id");return this.invalidateSearches(t.resourceType),this.put(this.fhirUrl(t.resourceType,t.id),t)}patchResource(t,e,n){return this.invalidateSearches(t),this.patch(this.fhirUrl(t,e),n)}deleteResource(t,e){return this.invalidateSearches(t),this.delete(this.fhirUrl(t,e))}sendEmail(t){return this.post("email/v1/send",t,"application/json")}graphql(t,e){return this.post(this.fhirUrl("$graphql"),{query:t},"application/json",e)}getActiveLogin(){return e(this,bt,"f").getObject("activeLogin")}setActiveLogin(i){return t(this,void 0,void 0,(function*(){n(this,Ut,i.accessToken,"f"),n(this,Mt,i.refreshToken,"f"),n(this,Lt,void 0,"f"),n(this,Dt,void 0,"f"),e(this,bt,"f").setObject("activeLogin",i),e(this,mt,"m",_t).call(this,i),e(this,Et,"f").clear(),n(this,Rt,void 0,"f"),yield e(this,mt,"m",It).call(this)}))}getAccessToken(){return e(this,Ut,"f")}setAccessToken(t){n(this,Ut,t,"f"),n(this,Mt,void 0,"f"),n(this,Lt,void 0,"f"),n(this,Dt,void 0,"f")}getLogins(){var t;return null!==(t=e(this,bt,"f").getObject("logins"))&&void 0!==t?t:[]}isLoading(){return!!e(this,Ct,"f")}getProfile(){return e(this,Lt,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return e(this,Ct,"f")&&(yield e(this,Ct,"f")),this.getProfile()}))}getUserConfiguration(){return e(this,Dt,"f")}download(n,i={}){return t(this,void 0,void 0,(function*(){e(this,Rt,"f")&&(yield e(this,Rt,"f")),e(this,mt,"m",Wt).call(this,i);return(yield e(this,yt,"f").call(this,n.toString(),i)).blob()}))}processCode(t){if(!e(this,bt,"f").getString("pkceState"))throw this.clear(),new Error("Invalid PCKE state");const n=e(this,bt,"f").getString("codeVerifier");if(!n)throw this.clear(),new Error("Invalid PCKE code verifier");const i=new URLSearchParams;return i.set("grant_type","authorization_code"),i.set("client_id",e(this,At,"f")),i.set("code_verifier",n),i.set("code",t),i.set("redirect_uri",se()),e(this,mt,"m",qt).call(this,i)}startClientLogin(n,i){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",n),t.set("client_secret",i),e(this,mt,"m",qt).call(this,t)}))}}function se(){return window.location.protocol+"//"+window.location.host+"/"}function oe(t){return[{type:gt.boolean,value:t}]}function ae(t){return Number.isSafeInteger(t)?{type:gt.integer,value:t}:"number"==typeof t?{type:gt.decimal,value:t}:"boolean"==typeof t?{type:gt.boolean,value:t}:"string"==typeof t?{type:gt.string,value:t}:ge(t)?{type:gt.Quantity,value:t}:{type:gt.BackboneElement,value:t}}function le(t){return 0!==t.length&&!!t[0].value}function ce(t){const e=[];for(const n of t){let t=!1;for(const i of e)if(le(fe(n,i))){t=!0;break}t||e.push(n)}return e}function ue(t){return oe(!le(t))}function he(t,e){return 0===t.length||0===e.length?[]:t.length!==e.length?oe(!1):oe(t.every(((t,n)=>le(fe(t,e[n])))))}function fe(t,e){const n=t.value,i=e.value;return"number"==typeof n&&"number"==typeof i?oe(Math.abs(n-i)<1e-8):ge(n)&&ge(i)?oe(me(n,i)):oe("object"==typeof n&&"object"==typeof i?ye(t,e):n===i)}function de(t,e){return 0===t.length&&0===e.length?oe(!0):t.length!==e.length?oe(!1):(t.sort(ve),e.sort(ve),oe(t.every(((t,n)=>le(function(t,e){const n=t.value,i=e.value;if("number"==typeof n&&"number"==typeof i)return oe(Math.abs(n-i)<.01);if(ge(n)&&ge(i))return oe(me(n,i));if("object"==typeof n&&"object"==typeof i)return oe(ye(n,i));if("string"==typeof n&&"string"==typeof i)return oe(n.toLowerCase()===i.toLowerCase());return oe(n===i)}(t,e[n]))))))}function ve(t,e){const n=t.value,i=e.value;return"number"==typeof n&&"number"==typeof i?n-i:"string"==typeof n&&"string"==typeof i?n.localeCompare(i):0}function pe(t,e){const{value:n}=t;if(null==n)return!1;switch(e){case"Boolean":return"boolean"==typeof n;case"Decimal":case"Integer":return"number"==typeof n;case"Date":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof n&&!!n.match(/^T\d/);case"Period":return!(!(i=n)||"object"!=typeof i||!("start"in i));case"Quantity":return ge(n);default:return"object"==typeof n&&(null==n?void 0:n.resourceType)===e}var i}function ge(t){return!(!t||"object"!=typeof t||!("value"in t)||"number"!=typeof t.value)}function me(t,e){return Math.abs(t.value-e.value)<.01&&(t.unit===e.unit||t.code===e.code||t.unit===e.code||t.code===e.unit)}function ye(t,e){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){const n=t[i],r=e[i];if(we(n)&&we(r)){if(!ye(n,r))return!1}else if(n!==r)return!1}return!0}function we(t){return null!==t&&"object"==typeof t}var be,Te;yt=new WeakMap,wt=new WeakMap,bt=new WeakMap,Tt=new WeakMap,Et=new WeakMap,St=new WeakMap,At=new WeakMap,kt=new WeakMap,xt=new WeakMap,Pt=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Mt=new WeakMap,Rt=new WeakMap,Ct=new WeakMap,Lt=new WeakMap,Dt=new WeakMap,mt=new WeakSet,_t=function(t){const n=this.getLogins().filter((e=>{var n,i;return(null===(n=e.profile)||void 0===n?void 0:n.reference)!==(null===(i=t.profile)||void 0===i?void 0:i.reference)}));n.push(t),e(this,bt,"f").setObject("logins",n)},It=function(){return t(this,void 0,void 0,(function*(){return n(this,Ct,new Promise(((t,i)=>{this.get("auth/me").then((i=>{n(this,Ct,void 0,"f"),n(this,Lt,i.profile,"f"),n(this,Dt,i.config,"f"),this.dispatchEvent({type:"change"}),t(e(this,Lt,"f"))})).catch(i)})),"f"),e(this,Ct,"f")}))},jt=function(n,i,r={}){return t(this,void 0,void 0,(function*(){e(this,Rt,"f")&&(yield e(this,Rt,"f")),i.startsWith("http")||(i=e(this,St,"f")+i),r.method=n,e(this,mt,"m",Wt).call(this,r);const t=yield e(this,yt,"f").call(this,i,r);if(401===t.status)return e(this,mt,"m",Qt).call(this,n,i,r);if(204===t.status||304===t.status)return;const s=yield t.json();return"OperationOutcome"!==(null==s?void 0:s.resourceType)||it(s)?s:Promise.reject(s)}))},Wt=function(t){t.headers||(t.headers={});const n=t.headers;n["Content-Type"]||(n["Content-Type"]="application/fhir+json"),e(this,Ut,"f")&&(n.Authorization="Bearer "+e(this,Ut,"f")),t.cache||(t.cache="no-cache"),t.credentials||(t.credentials="include")},Nt=function(t,e){t.headers||(t.headers={});t.headers["Content-Type"]=e},Bt=function(t,e){"string"==typeof e||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Uint8Array&&e instanceof Uint8Array?t.body=e:e&&(t.body=JSON.stringify(e))},Qt=function(n,i,r){return t(this,void 0,void 0,(function*(){return e(this,mt,"m",Ht).call(this).then((()=>e(this,mt,"m",jt).call(this,n,i,r))).catch((t=>(this.clear(),e(this,Ot,"f")&&e(this,Ot,"f").call(this),Promise.reject(t))))}))},$t=function(){return t(this,void 0,void 0,(function*(){const n=z();e(this,bt,"f").setString("pkceState",n);const i=z();e(this,bt,"f").setString("codeVerifier",i);const r=_(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(i)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");e(this,bt,"f").setString("codeChallenge",r)}))},Ft=function(){e(this,mt,"m",$t).call(this);const t=new URL(e(this,kt,"f"));t.searchParams.set("response_type","code"),t.searchParams.set("state",e(this,bt,"f").getString("pkceState")),t.searchParams.set("client_id",e(this,At,"f")),t.searchParams.set("redirect_uri",se()),t.searchParams.set("scope",ie),t.searchParams.set("code_challenge_method","S256"),t.searchParams.set("code_challenge",e(this,bt,"f").getString("codeChallenge")),window.location.assign(t.toString())},Ht=function(){return t(this,void 0,void 0,(function*(){if(e(this,Rt,"f"))return e(this,Rt,"f");if(!e(this,Mt,"f"))throw this.clear(),new Error("Invalid refresh token");const t=new URLSearchParams;t.set("grant_type","refresh_token"),t.set("client_id",e(this,At,"f")),t.set("refresh_token",e(this,Mt,"f")),n(this,Rt,e(this,mt,"m",qt).call(this,t),"f"),yield e(this,Rt,"f")}))},qt=function(n){return t(this,void 0,void 0,(function*(){return e(this,yt,"f").call(this,e(this,xt,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n}).then((t=>{if(!t.ok)throw new Error("Failed to fetch tokens");return t.json()})).then((t=>e(this,mt,"m",Xt).call(this,t))).then((()=>this.getProfile()))}))},Xt=function(n){return t(this,void 0,void 0,(function*(){const t=n.access_token,i=function(t){const[e,n,i]=t.split(".");return V(n)}(t);if(Date.now()>=1e3*i.exp)throw this.clear(),new Error("Token expired");if(e(this,At,"f")&&i.client_id!==e(this,At,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:n.refresh_token,project:n.project,profile:n.profile})}))},zt=function(){try{window.addEventListener("storage",(t=>{null!==t.key&&"activeLogin"!==t.key||window.location.reload()}))}catch(t){}};class Ee{constructor(t,e){this.original=t,this.child=e}eval(t){try{return t.length>0?t.map((t=>this.child.eval([t]))).flat():this.child.eval(t)}catch(t){throw new Error(`FhirPathError on "${this.original}": ${t}`)}}}class Se{constructor(t){this.value=t}eval(){return[this.value]}}class Ae{constructor(t){this.name=t,be.add(this)}eval(t){return"$this"===this.name?t:t.map((t=>e(this,be,"m",Te).call(this,t))).flat().filter((t=>void 0!==(null==t?void 0:t.value)))}}be=new WeakSet,Te=function(t){const e=t.value;if(!e||"object"!=typeof e)return;if("resourceType"in e&&e.resourceType===this.name)return t;let n;if(this.name in e)n=e[this.name];else{const t=Object.keys(e).find((t=>t.startsWith(this.name)));t&&(n=e[t])}return void 0!==n?Array.isArray(n)?n.map(ae):[ae(n)]:void 0};class ke{eval(){return[]}}class xe{constructor(t,e){this.child=t,this.impl=e}eval(t){return this.impl(this.child.eval(t))}}class Pe{constructor(t,e){this.left=t,this.right=e}eval(t){return this.left.eval(t)}}class Oe{constructor(t,e,n){this.left=t,this.right=e,this.impl=n}eval(t){const e=this.left.eval(t);if(1!==e.length)return[];const n=this.right.eval(t);if(1!==n.length)return[];const i=e[0].value,r=n[0].value,s=ge(i)?i.value:i,o=ge(r)?r.value:r,a=this.impl(s,o);return"boolean"==typeof a?oe(a):ge(i)?[{type:gt.Quantity,value:Object.assign(Object.assign({},i),{value:a})}]:[ae(a)]}}class Ue{constructor(t,e){this.left=t,this.right=e}eval(t){const e=[...this.left.eval(t),...this.right.eval(t)];return e.length>0&&e.every((t=>"string"==typeof t.value))?[{type:gt.string,value:e.map((t=>t.value)).join("")}]:e}}class Me{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t),n=this.right.eval(t);return oe(e.some((t=>t.value===n[0].value)))}}class Re{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t);return oe(this.right.eval(t).some((t=>t.value===e[0].value)))}}class Ce{constructor(t,e){this.left=t,this.right=e}eval(t){return this.right.eval(this.left.eval(t))}}class Le{constructor(t,e){this.left=t,this.right=e}eval(t){return ce([...this.left.eval(t),...this.right.eval(t)])}}class De{constructor(t,e){this.left=t,this.right=e}eval(t){return he(this.left.eval(t),this.right.eval(t))}}class _e{constructor(t,e){this.left=t,this.right=e}eval(t){return ue(he(this.left.eval(t),this.right.eval(t)))}}class Ie{constructor(t,e){this.left=t,this.right=e}eval(t){return de(this.left.eval(t),this.right.eval(t))}}class je{constructor(t,e){this.left=t,this.right=e}eval(t){return ue(de(this.left.eval(t),this.right.eval(t)))}}class We{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t);if(1!==e.length)return[];const n=this.right.name;return oe(pe(e[0],n))}}class Ne{constructor(t,e){this.left=t,this.right=e}eval(t){var e,n,i,r;const s=this.left.eval(t),o=this.right.eval(t);return!0===(null===(e=s[0])||void 0===e?void 0:e.value)&&!0===(null===(n=o[0])||void 0===n?void 0:n.value)?oe(!0):!1===(null===(i=s[0])||void 0===i?void 0:i.value)||!1===(null===(r=o[0])||void 0===r?void 0:r.value)?oe(!1):[]}}class Be{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t);if(le(e))return e;const n=this.right.eval(t);return le(n)?n:[]}}class Qe{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t),n=this.right.eval(t);if(0===e.length&&0===n.length)return[];const i=0===e.length?null:e[0].value,r=0===n.length?null:n[0].value;return!0===i&&!0!==r||!0!==i&&!0===r?oe(!0):!0===i&&!0===r||!1===i&&!1===r?oe(!1):[]}}class $e{constructor(t,e,n){this.name=t,this.args=e,this.impl=n}eval(t){return this.impl(t,...this.args)}}class Fe{constructor(t,e){this.left=t,this.expr=e}eval(t){const e=this.expr.eval(t);if(1!==e.length)return[];const n=e[0].value;if("number"!=typeof n)throw new Error("Invalid indexer expression: should return integer}");const i=this.left.eval(t);return n in i?[i[n]]:[]}}function He(t){if(t.startsWith("T"))return t+"T00:00:00.000Z".substring(t.length);if(t.length<=10)return t;try{return new Date(t).toISOString()}catch(e){return t}}const qe=()=>[],Xe={empty:t=>oe(0===t.length),exists:(t,e)=>oe(e?t.filter((t=>le(e.eval([t])))).length>0:t.length>0),all:(t,e)=>oe(t.every((t=>le(e.eval([t]))))),allTrue:t=>{for(const e of t)if(!e.value)return oe(!1);return oe(!0)},anyTrue:t=>{for(const e of t)if(e.value)return oe(!0);return oe(!1)},allFalse:t=>{for(const e of t)if(e.value)return oe(!1);return oe(!0)},anyFalse:t=>{for(const e of t)if(!e.value)return oe(!0);return oe(!1)},subsetOf:qe,supersetOf:qe,count:t=>[{type:gt.integer,value:t.length}],distinct:t=>{const e=[];for(const n of t)e.some((t=>t.value===n.value))||e.push(n);return e},isDistinct:t=>oe(t.length===Xe.distinct(t).length),where:(t,e)=>t.filter((t=>le(e.eval([t])))),select:(t,e)=>t.map((t=>e.eval([t]))).flat(),repeat:qe,ofType:qe,single:t=>{if(t.length>1)throw new Error("Expected input length one for single()");return 0===t.length?[]:t.slice(0,1)},first:t=>0===t.length?[]:t.slice(0,1),last:t=>0===t.length?[]:t.slice(t.length-1,t.length),tail:t=>0===t.length?[]:t.slice(1,t.length),skip:(t,e)=>{var n;const i=null===(n=e.eval([])[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for skip(num)");return i>=t.length?[]:i<=0?t:t.slice(i,t.length)},take:(t,e)=>{var n;const i=null===(n=e.eval([])[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for take(num)");return i>=t.length?t:i<=0?[]:t.slice(0,i)},intersect:(t,e)=>{if(!e)return t;const n=e.eval([]),i=[];for(const e of t)!i.some((t=>t.value===e.value))&&n.some((t=>t.value===e.value))&&i.push(e);return i},exclude:(t,e)=>{if(!e)return t;const n=e.eval([]),i=[];for(const e of t)n.some((t=>t.value===e.value))||i.push(e);return i},union:(t,e)=>{if(!e)return t;const n=e.eval([]);return ce([...t,...n])},combine:(t,e)=>{if(!e)return t;const n=e.eval([]);return[...t,...n]},iif:(t,e,n,i)=>{const r=e.eval(t);if(r.length>1||1===r.length&&"boolean"!=typeof r[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return le(r)?n.eval(t):i?i.eval(t):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);if("boolean"==typeof e)return[{type:gt.boolean,value:e}];if("number"==typeof e&&(0===e||1===e))return oe(!!e);if("string"==typeof e){const t=e.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(t))return oe(!0);if(["false","f","no","n","0","0.0"].includes(t))return oe(!1)}return[]},convertsToBoolean:t=>0===t.length?[]:oe(1===Xe.toBoolean(t).length),toInteger:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);return"number"==typeof e?[{type:gt.integer,value:e}]:"string"==typeof e&&e.match(/^[+-]?\d+$/)?[{type:gt.integer,value:parseInt(e,10)}]:"boolean"==typeof e?[{type:gt.integer,value:e?1:0}]:[]},convertsToInteger:t=>0===t.length?[]:oe(1===Xe.toInteger(t).length),toDate:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);return"string"==typeof e&&e.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:gt.date,value:He(e)}]:[]},convertsToDate:t=>0===t.length?[]:oe(1===Xe.toDate(t).length),toDateTime:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);return"string"==typeof e&&e.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:gt.dateTime,value:He(e)}]:[]},convertsToDateTime:t=>0===t.length?[]:oe(1===Xe.toDateTime(t).length),toDecimal:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);return"number"==typeof e?[{type:gt.decimal,value:e}]:"string"==typeof e&&e.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:gt.decimal,value:parseFloat(e)}]:"boolean"==typeof e?[{type:gt.decimal,value:e?1:0}]:[]},convertsToDecimal:t=>0===t.length?[]:oe(1===Xe.toDecimal(t).length),toQuantity:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);return ge(e)?[{type:gt.Quantity,value:e}]:"number"==typeof e?[{type:gt.Quantity,value:{value:e,unit:"1"}}]:"string"==typeof e&&e.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:gt.Quantity,value:{value:parseFloat(e),unit:"1"}}]:"boolean"==typeof e?[{type:gt.Quantity,value:{value:e?1:0,unit:"1"}}]:[]},convertsToQuantity:t=>0===t.length?[]:oe(1===Xe.toQuantity(t).length),toString:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);return null==e?[]:ge(e)?[{type:gt.string,value:`${e.value} '${e.unit}'`}]:[{type:gt.string,value:e.toString()}]},convertsToString:t=>0===t.length?[]:oe(1===Xe.toString(t).length),toTime:t=>{if(0===t.length)return[];const[{value:e}]=Ve(t,1);if("string"==typeof e){const t=e.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:gt.time,value:He("T"+t[1])}]}return[]},convertsToTime:t=>0===t.length?[]:oe(1===Xe.toTime(t).length),indexOf:(t,e)=>ze(((t,e)=>t.indexOf(e)),t,e),substring:(t,e,n)=>ze(((t,e,n)=>{const i=e,r=n?i+n:t.length;return i<0||i>=t.length?void 0:t.substring(i,r)}),t,e,n),startsWith:(t,e)=>ze(((t,e)=>t.startsWith(e)),t,e),endsWith:(t,e)=>ze(((t,e)=>t.endsWith(e)),t,e),contains:(t,e)=>ze(((t,e)=>t.includes(e)),t,e),upper:t=>ze((t=>t.toUpperCase()),t),lower:t=>ze((t=>t.toLowerCase()),t),replace:(t,e,n)=>ze(((t,e,n)=>t.replaceAll(e,n)),t,e,n),matches:(t,e)=>ze(((t,e)=>!!t.match(e)),t,e),replaceMatches:(t,e,n)=>ze(((t,e,n)=>t.replaceAll(e,n)),t,e,n),length:t=>ze((t=>t.length),t),toChars:t=>ze((t=>t?t.split(""):void 0),t),abs:t=>Ye(Math.abs,t),ceiling:t=>Ye(Math.ceil,t),exp:t=>Ye(Math.exp,t),floor:t=>Ye(Math.floor,t),ln:t=>Ye(Math.log,t),log:(t,e)=>Ye(((t,e)=>Math.log(t)/Math.log(e)),t,e),power:(t,e)=>Ye(Math.pow,t,e),round:t=>Ye(Math.round,t),sqrt:t=>Ye(Math.sqrt,t),truncate:t=>Ye((t=>0|t),t),children:qe,descendants:qe,trace:(t,e)=>(console.log("trace",t,e),t),now:()=>[{type:gt.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:gt.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:gt.date,value:(new Date).toISOString().substring(0,10)}],between:(t,e,n,i)=>{const r=Xe.toDateTime(e.eval(t));if(0===r.length)throw new Error("Invalid start date");const s=Xe.toDateTime(n.eval(t));if(0===s.length)throw new Error("Invalid end date");const o=i.eval(t)[0].value;if("years"!==o&&"months"!==o&&"days"!==o)throw new Error("Invalid units");const a=b(r[0].value,s[0].value);return[{type:gt.Quantity,value:{value:a[o],unit:o}}]},is:(t,e)=>{let n="";return e instanceof Ae?n=e.name:e instanceof Ce&&(n=e.left.name+"."+e.right.name),n?t.map((t=>({type:gt.boolean,value:pe(t,n)}))):[]},not:t=>Xe.toBoolean(t).map((t=>({type:gt.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const e=t.value;let n;if("string"==typeof e)n=e;else if("object"==typeof e){const t=e;if(t.resource)return{type:gt.BackboneElement,value:t.resource};n=t.reference}if(!n)return{type:gt.BackboneElement,value:null};const[i,r]=n.split("/");return{type:gt.BackboneElement,value:{resourceType:i,id:r}}})).filter((t=>!!t.value)),as:t=>t,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:gt.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:gt.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:gt.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:gt.BackboneElement,value:null})),conformsTo:(t,e)=>{const n=e.eval([])[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const i=n.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var e;return{type:gt.boolean,value:(null===(e=t.value)||void 0===e?void 0:e.resourceType)===i}}))}};function ze(t,e,...n){if(0===e.length)return[];const[{value:i}]=Ve(e,1);if("string"!=typeof i)throw new Error("String function cannot be called with non-string");const r=t(i,...n.map((t=>{var n,i;return t&&(null===(i=null===(n=t.eval(e))||void 0===n?void 0:n[0])||void 0===i?void 0:i.value)})));return void 0===r?[]:Array.isArray(r)?r.map(ae):[ae(r)]}function Ye(t,e,...n){if(0===e.length)return[];const[{value:i}]=Ve(e,1),r=ge(i),s=r?i.value:i;if("number"!=typeof s)throw new Error("Math function cannot be called with non-number");const o=t(s,...n.map((t=>{var e,n;return null===(n=null===(e=t.eval([]))||void 0===e?void 0:e[0])||void 0===n?void 0:n.value})));return[{type:r?gt.Quantity:e[0].type,value:r?Object.assign(Object.assign({},i),{value:o}):o}]}function Ve(t,e){if(t.length!==e)throw new Error(`Expected ${e} arguments`);for(const e of t)if(null==e)throw new Error("Expected non-null argument");return t}var Ge,Ke,Je,Ze,tn,en,nn,rn,sn,on,an,ln,cn,un,hn,fn,dn,vn;function pn(t){return new yn(t).tokenize()}const gn=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],mn=["!=","!~","<=",">=","{}"];class yn{constructor(t){Ge.add(this),Ke.set(this,void 0),Je.set(this,void 0),n(this,Ke,t,"f"),n(this,Je,0,"f")}tokenize(){const t=[];for(;e(this,Je,"f")<e(this,Ke,"f").length;){const n=e(this,Ge,"m",tn).call(this);n&&t.push(n)}return t}}function wn(t,e){return{id:t,value:e}}var bn,Tn,En,Sn,An,kn,xn,Pn,On;Ke=new WeakMap,Je=new WeakMap,Ge=new WeakSet,Ze=function(){const t=e(this,Je,"f"),i=e(this,Ge,"m",tn).call(this);return n(this,Je,t,"f"),i},tn=function(){e(this,Ge,"m",en).call(this);const t=e(this,Ge,"m",fn).call(this);if(!t)return;const n=e(this,Ge,"m",vn).call(this);return"/"===t&&"*"===n?e(this,Ge,"m",nn).call(this):"/"===t&&"/"===n?e(this,Ge,"m",rn).call(this):"'"===t?e(this,Ge,"m",sn).call(this):"`"===t?e(this,Ge,"m",on).call(this):"@"===t?e(this,Ge,"m",an).call(this):t.match(/\d/)?e(this,Ge,"m",ln).call(this):t.match(/\w/)||"$"===t&&n.match(/\w/)?e(this,Ge,"m",cn).call(this):e(this,Ge,"m",un).call(this)},en=function(){return wn("Whitespace",e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/\s/))))},nn=function(){const t=e(this,Je,"f");return e(this,Ge,"m",hn).call(this,(()=>"*"!==e(this,Ge,"m",fn).call(this)||"/"!==e(this,Ge,"m",vn).call(this))),n(this,Je,e(this,Je,"f")+2,"f"),wn("Comment",e(this,Ke,"f").substring(t,e(this,Je,"f")))},rn=function(){return wn("Comment",e(this,Ge,"m",hn).call(this,(()=>"\n"!==e(this,Ge,"m",fn).call(this))))},sn=function(){var t,i;n(this,Je,(t=e(this,Je,"f"),++t),"f");const r=wn("String",e(this,Ge,"m",hn).call(this,(()=>"\\"===e(this,Ge,"m",dn).call(this)||"'"!==e(this,Ge,"m",fn).call(this))));return n(this,Je,(i=e(this,Je,"f"),++i),"f"),r},on=function(){var t,i;n(this,Je,(t=e(this,Je,"f"),++t),"f");const r=wn("Symbol",e(this,Ge,"m",hn).call(this,(()=>"`"!==e(this,Ge,"m",fn).call(this))));return n(this,Je,(i=e(this,Je,"f"),++i),"f"),r},an=function(){var t,i,r,s,o;const a=e(this,Je,"f");return n(this,Je,(t=e(this,Je,"f"),++t),"f"),e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/[\d-]/))),"T"===e(this,Ge,"m",fn).call(this)&&(n(this,Je,(i=e(this,Je,"f"),++i),"f"),e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/[\d:]/))),"."===e(this,Ge,"m",fn).call(this)&&e(this,Ge,"m",vn).call(this).match(/\d/)&&(n(this,Je,(r=e(this,Je,"f"),++r),"f"),e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/[\d]/)))),"Z"===e(this,Ge,"m",fn).call(this)?n(this,Je,(s=e(this,Je,"f"),++s),"f"):"+"!==e(this,Ge,"m",fn).call(this)&&"-"!==e(this,Ge,"m",fn).call(this)||(n(this,Je,(o=e(this,Je,"f"),++o),"f"),e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/[\d:]/))))),wn("DateTime",e(this,Ke,"f").substring(a+1,e(this,Je,"f")))},ln=function(){var t;const i=e(this,Je,"f");let r="Number";return e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/\d/))),"."===e(this,Ge,"m",fn).call(this)&&e(this,Ge,"m",vn).call(this).match(/\d/)&&(n(this,Je,(t=e(this,Je,"f"),++t),"f"),e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/\d/))))," "===e(this,Ge,"m",fn).call(this)&&function(t){if(t){if("String"===t.id)return!0;if("Symbol"===t.id&&gn.includes(t.value))return!0}return!1}(e(this,Ge,"m",Ze).call(this))&&(r="Quantity",e(this,Ge,"m",tn).call(this)),wn(r,e(this,Ke,"f").substring(i,e(this,Je,"f")))},cn=function(){return wn("Symbol",e(this,Ge,"m",hn).call(this,(()=>e(this,Ge,"m",fn).call(this).match(/[$\w]/))))},un=function(){var t;const i=e(this,Ge,"m",fn).call(this),r=i+e(this,Ge,"m",vn).call(this);return mn.includes(r)?(n(this,Je,e(this,Je,"f")+2,"f"),wn(r,r)):(n(this,Je,(t=e(this,Je,"f"),++t),"f"),wn(i,i))},hn=function(t){var i;const r=e(this,Je,"f");for(;e(this,Je,"f")<e(this,Ke,"f").length&&t();)n(this,Je,(i=e(this,Je,"f"),++i),"f");return e(this,Ke,"f").substring(r,e(this,Je,"f"))},fn=function(){return e(this,Ke,"f")[e(this,Je,"f")]},dn=function(){var t;return null!==(t=e(this,Ke,"f")[e(this,Je,"f")-1])&&void 0!==t?t:""},vn=function(){var t;return null!==(t=e(this,Ke,"f")[e(this,Je,"f")+1])&&void 0!==t?t:""};bn=new WeakMap,Tn=new WeakMap;class Un{constructor(t,e,i){En.add(this),Sn.set(this,void 0),An.set(this,void 0),kn.set(this,void 0),n(this,Sn,t,"f"),n(this,An,e,"f"),n(this,kn,i,"f")}match(t){const n=e(this,En,"m",On).call(this);return(null==n?void 0:n.id)===t&&(e(this,En,"m",Pn).call(this),!0)}consumeAndParse(t=100){const n=e(this,En,"m",Pn).call(this),i=e(this,An,"f")[n.id];if(!i)throw Error(`Parse error at ${n.value}. No matching prefix parselet.`);let r=i.parse(this,n);for(;t>e(this,En,"m",xn).call(this);){const t=e(this,En,"m",Pn).call(this);r=e(this,kn,"f")[t.id].parse(this,r,t)}return r}}Sn=new WeakMap,An=new WeakMap,kn=new WeakMap,En=new WeakSet,xn=function(){const t=e(this,En,"m",On).call(this);if(!t)return 100;const n=e(this,kn,"f")[t.id];return n?n.precedence:100},Pn=function(){if(!e(this,Sn,"f").length)throw Error("Cant consume unknown more tokens.");return e(this,Sn,"f").shift()},On=function(){return e(this,Sn,"f").length>0?e(this,Sn,"f")[0]:void 0};const Mn={parse(t){const e=t.consumeAndParse();if(!t.match(")"))throw new Error("Parse error: expected `)`");return e}},Rn={parse(t,e){const n=t.consumeAndParse();if(!t.match("]"))throw new Error("Parse error: expected `]`");return new Fe(e,n)},precedence:2},Cn={parse(t,e){if(!(e instanceof Ae))throw new Error("Unexpected parentheses");if(!(e.name in Xe))throw new Error("Unrecognized function: "+e.name);const n=[];for(;!t.match(")");)n.push(t.consumeAndParse()),t.match(",");return new $e(e.name,n,Xe[e.name])},precedence:0};function Ln(t){const e=t.split(" "),n=parseFloat(e[0]);let i=e[1];return i=i&&i.startsWith("'")&&i.endsWith("'")?i.substring(1,i.length-1):"{"+i+"}",{value:n,unit:i}}const Dn=(new class{constructor(){bn.set(this,{}),Tn.set(this,{})}registerInfix(t,n){return e(this,Tn,"f")[t]=n,this}registerPrefix(t,n){return e(this,bn,"f")[t]=n,this}prefix(t,e,n){return this.registerPrefix(t,{parse(t,i){const r=t.consumeAndParse(e);return n(i,r)}})}infixLeft(t,e,n){return this.registerInfix(t,{parse(t,i,r){const s=t.consumeAndParse(e);return n(i,r,s)},precedence:e})}construct(t){return new Un(pn(t),e(this,bn,"f"),e(this,Tn,"f"))}}).registerPrefix("String",{parse:(t,e)=>new Se({type:gt.string,value:e.value})}).registerPrefix("DateTime",{parse:(t,e)=>new Se({type:gt.dateTime,value:He(e.value)})}).registerPrefix("Quantity",{parse:(t,e)=>new Se({type:gt.Quantity,value:Ln(e.value)})}).registerPrefix("Number",{parse:(t,e)=>new Se({type:gt.decimal,value:parseFloat(e.value)})}).registerPrefix("Symbol",{parse:(t,e)=>"false"===e.value?new Se({type:gt.boolean,value:!1}):"true"===e.value?new Se({type:gt.boolean,value:!0}):new Ae(e.value)}).registerPrefix("{}",{parse:()=>new ke}).registerPrefix("(",Mn).registerInfix("[",Rn).registerInfix("(",Cn).prefix("+",3,((t,e)=>new xe(e,(t=>t)))).prefix("-",3,((t,e)=>new Oe(e,e,((t,e)=>-e)))).infixLeft(".",1,((t,e,n)=>new Ce(t,n))).infixLeft("/",4,((t,e,n)=>new Oe(t,n,((t,e)=>t/e)))).infixLeft("*",4,((t,e,n)=>new Oe(t,n,((t,e)=>t*e)))).infixLeft("+",5,((t,e,n)=>new Oe(t,n,((t,e)=>t+e)))).infixLeft("-",5,((t,e,n)=>new Oe(t,n,((t,e)=>t-e)))).infixLeft("|",7,((t,e,n)=>new Le(t,n))).infixLeft("=",9,((t,e,n)=>new De(t,n))).infixLeft("!=",9,((t,e,n)=>new _e(t,n))).infixLeft("~",9,((t,e,n)=>new Ie(t,n))).infixLeft("!~",9,((t,e,n)=>new je(t,n))).infixLeft("<",8,((t,e,n)=>new Oe(t,n,((t,e)=>t<e)))).infixLeft("<=",8,((t,e,n)=>new Oe(t,n,((t,e)=>t<=e)))).infixLeft(">",8,((t,e,n)=>new Oe(t,n,((t,e)=>t>e)))).infixLeft(">=",8,((t,e,n)=>new Oe(t,n,((t,e)=>t>=e)))).infixLeft("&",5,((t,e,n)=>new Ue(t,n))).infixLeft("Symbol",6,((t,e,n)=>{switch(e.value){case"and":return new Ne(t,n);case"as":return new Pe(t,n);case"contains":return new Me(t,n);case"div":return new Oe(t,n,((t,e)=>t/e|0));case"in":return new Re(t,n);case"is":return new We(t,n);case"mod":return new Oe(t,n,((t,e)=>t%e));case"or":return new Be(t,n);case"xor":return new Qe(t,n);default:throw new Error("Cannot use "+e.value+" as infix operator")}}));function _n(t){try{return new Ee(t,Dn.construct(t).consumeAndParse())}catch(e){throw new Error(`FhirPathError on "${t}": ${e}`)}}function In(t,e){Array.isArray(e)||(e=[e]);const n=Array.isArray(e)?e:[e];for(let t=0;t<n.length;t++){const e=n[t];"object"==typeof e&&"type"in e&&"value"in e||(n[t]={type:gt.BackboneElement,value:e})}return _n(t).eval(n).map((t=>t.value))}const jn="\r",Wn="|",Nn="^";class Bn{constructor(t){this.segments=t}get(t){return"number"==typeof t?this.segments[t]:this.segments.find((e=>e.name===t))}getAll(t){return this.segments.filter((e=>e.name===t))}toString(){return this.segments.map((t=>t.toString())).join("\r")}buildAck(){var t,e,n,i,r,s;const o=new Date,a=this.get("MSH"),l=(null===(t=null==a?void 0:a.get(2))||void 0===t?void 0:t.toString())||"",c=(null===(e=null==a?void 0:a.get(3))||void 0===e?void 0:e.toString())||"",u=(null===(n=null==a?void 0:a.get(4))||void 0===n?void 0:n.toString())||"",h=(null===(i=null==a?void 0:a.get(5))||void 0===i?void 0:i.toString())||"",f=(null===(r=null==a?void 0:a.get(9))||void 0===r?void 0:r.toString())||"",d=(null===(s=null==a?void 0:a.get(12))||void 0===s?void 0:s.toString())||"2.5.1";return new Bn([new Qn(["MSH","^~\\&",u,h,l,c,o.toISOString(),"","ACK",o.getTime().toString(),"P",d]),new Qn(["MSA","AA",f,"OK"])])}static parse(t){if(!t.startsWith("MSH|^~\\&")){const t=new Error("Invalid HL7 message");throw t.type="entity.parse.failed",t}return new Bn(t.split(/[\r\n]+/).map((t=>Qn.parse(t))))}}class Qn{constructor(t){C(t)?this.fields=t.map((t=>$n.parse(t))):this.fields=t,this.name=this.fields[0].components[0]}get(t){return this.fields[t]}toString(){return this.fields.map((t=>t.toString())).join("|")}static parse(t){return new Qn(t.split("|").map((t=>$n.parse(t))))}}class $n{constructor(t){this.components=t}get(t){return this.components[t]}toString(){return this.components.join("^")}static parse(t){return new $n(t.split("^"))}}const Fn=20;var Hn;!function(t){t.EQUALS="eq",t.NOT_EQUALS="ne",t.GREATER_THAN="gt",t.LESS_THAN="lt",t.GREATER_THAN_OR_EQUALS="ge",t.LESS_THAN_OR_EQUALS="le",t.STARTS_AFTER="sa",t.ENDS_BEFORE="eb",t.APPROXIMATELY="ap",t.CONTAINS="contains",t.EXACT="exact",t.TEXT="text",t.ABOVE="above",t.BELOW="below",t.IN="in",t.NOT_IN="not-in",t.OF_TYPE="of-type"}(Hn||(Hn={}));const qn=[Hn.CONTAINS,Hn.EXACT,Hn.TEXT,Hn.ABOVE,Hn.BELOW,Hn.IN,Hn.NOT_IN,Hn.OF_TYPE],Xn=[Hn.NOT_EQUALS,Hn.GREATER_THAN,Hn.LESS_THAN,Hn.GREATER_THAN_OR_EQUALS,Hn.LESS_THAN_OR_EQUALS,Hn.STARTS_AFTER,Hn.ENDS_BEFORE,Hn.APPROXIMATELY];function zn(t){const e=new URL(t,"https://example.com/"),n=e.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let i,r,s,o,a,l;return new URLSearchParams(e.search).forEach(((t,e)=>{"_fields"===e?s=t.split(","):"_offset"===e?o=parseInt(t):"_count"===e?a=parseInt(t):"_total"===e?l=t:"_sort"===e?(r=r||[],r.push(function(t){return t.startsWith("-")?{code:t.substring(1),descending:!0}:{code:t}}(t))):(i=i||[],i.push(function(t,e){let n=t,i=Hn.EQUALS;for(const t of qn){const e=n.indexOf(":"+t);-1!==e&&(i=t,n=n.substring(0,e))}for(const t of Xn)e.match(new RegExp("^"+t+"\\d"))&&(i=t,e=e.substring(t.length));return{code:n,operator:i,value:e}}(e,t)))})),{resourceType:n,filters:i,fields:s,offset:o,count:a,total:l,sortRules:r}}function Yn(t){const e=[];return t.fields&&e.push("_fields="+t.fields.join(",")),t.filters&&t.filters.forEach((t=>e.push(function(t){const e=qn.includes(t.operator)?":"+t.operator:"",n=Xn.includes(t.operator)?t.operator:"";return`${t.code}${e}=${n}${encodeURIComponent(t.value)}`}(t)))),t.sortRules&&t.sortRules.length>0&&e.push(function(t){if(!t||0===t.length)return"";return"_sort="+t.map((t=>t.descending?"-"+t.code:t.code)).join(",")}(t.sortRules)),void 0!==t.offset&&e.push("_offset="+t.offset),void 0!==t.count&&e.push("_count="+t.count),void 0!==t.total&&e.push("_total="+t.total),0===e.length?"":(e.sort(),"?"+e.join("&"))}var Vn;function Gn(t,e,n){var i,r,s,o;if("_lastUpdated"===n.code)return{columnName:"lastUpdated",type:Vn.DATETIME};const a=n.code.split("-").reduce(((t,e,n)=>t+(n?I(e):e)),"");const l=null===(i=Kn(e,n.expression))||void 0===i?void 0:i.split(".");if(!l)return{columnName:a,type:Vn.TEXT};let c,u,h=e,f=!1;for(let e=1;e<l.length;e++){const n=l[e];if(c=null===(s=null===(r=t.types[h])||void 0===r?void 0:r.properties)||void 0===s?void 0:s[n],!c)return{columnName:a,type:Vn.TEXT,array:f};if("*"===c.max&&(f=!0),u=null===(o=c.type)||void 0===o?void 0:o[0].code,!u)return{columnName:a,type:Vn.TEXT,array:f};e<l.length-1&&("Element"===u||"BackboneElement"===u?h+=I(n):h=u)}const d=function(t,e){let n=Vn.TEXT;switch(t.type){case"date":n=e===gt.dateTime||e===gt.instant?Vn.DATETIME:Vn.DATE;break;case"number":n=Vn.NUMBER;break;case"quantity":n=Vn.QUANTITY;break;case"reference":n=Vn.REFERENCE;break;case"token":"boolean"===e&&(n=Vn.BOOLEAN)}return n}(n,u);return{columnName:a,type:d,elementDefinition:c,array:f}}function Kn(t,e){const n=e.split(" | ");for(const e of n){const n=Jn(e);if(n.startsWith(t+"."))return n}}function Jn(t){let e=t.trim();return e.startsWith("(")&&e.endsWith(")")&&(e=e.substring(1,e.length-1)),e.includes(" as ")&&(e=e.substring(0,e.indexOf(" as "))),e.includes(".where(")&&(e=e.substring(0,e.indexOf(".where("))),e}!function(t){t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.QUANTITY="QUANTITY",t.TEXT="TEXT",t.REFERENCE="REFERENCE",t.DATE="DATE",t.DATETIME="DATETIME",t.PERIOD="PERIOD"}(Vn||(Vn={}));export{Nn as COMPONENT_SEPARATOR,Fn as DEFAULT_SEARCH_COUNT,Wn as FIELD_SEPARATOR,$n as Hl7Field,Bn as Hl7Message,Qn as Hl7Segment,a as LRUCache,re as MedplumClient,lt as OperationOutcomeError,Hn as Operator,gt as PropertyType,Yt as ReadablePromise,jn as SEGMENT_SEPARATOR,Vn as SearchParameterType,et as accessDenied,G as allOk,_ as arrayBufferToBase64,D as arrayBufferToHex,at as assertOk,nt as badRequest,ee as buildTypeName,b as calculateAge,T as calculateAgeString,I as capitalize,f as createReference,Kt as createSchema,Jt as createTypeSchema,K as created,U as deepEquals,In as evalFhirPath,B as findObservationInterval,l as formatAddress,h as formatFamilyName,u as formatGivenName,c as formatHumanName,Yn as formatSearchQuery,W as getCodeBySystem,w as getDateProperty,g as getDisplayString,Kn as getExpressionForResourceType,k as getExtensionValue,A as getIdentifier,m as getImageSrc,ne as getPropertyDisplayName,E as getQuestionnaireAnswers,d as getReferenceString,Gn as getSearchParameterDetails,ot as getStatus,tt as gone,te as indexSearchParameter,Zt as indexStructureDefinition,st as isGone,j as isLowerCase,rt as isNotFound,R as isObject,it as isOk,p as isProfileResource,C as isStringArray,M as isUUID,Q as matchesRange,Z as notFound,J as notModified,_n as parseFhirPath,zn as parseSearchDefinition,$ as preciseEquals,H as preciseGreaterThan,X as preciseGreaterThanOrEquals,F as preciseLessThan,q as preciseLessThanOrEquals,v as resolveId,N as setCodeBySystem,x as stringify,pn as tokenize};
|
|
1
|
+
function t(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}l((i=i.apply(t,e||[])).next())}))}function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n}var i,r,s,o;class a{constructor(t=10){i.add(this),r.set(this,void 0),s.set(this,void 0),n(this,r,t,"f"),n(this,s,new Map,"f")}clear(){e(this,s,"f").clear()}get(t){const n=e(this,s,"f").get(t);return n&&(e(this,s,"f").delete(t),e(this,s,"f").set(t,n)),n}set(t,n){e(this,s,"f").has(t)?e(this,s,"f").delete(t):e(this,s,"f").size>=e(this,r,"f")&&e(this,s,"f").delete(e(this,i,"m",o).call(this)),e(this,s,"f").set(t,n)}delete(t){e(this,s,"f").delete(t)}keys(){return e(this,s,"f").keys()}}function l(t,e){const n=[];return t.line&&n.push(...t.line),t.city&&n.push(t.city),t.state&&n.push(t.state),t.postalCode&&n.push(t.postalCode),t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&n.push("["+t.use+"]"),n.join(", ").trim()}function c(t,e){const n=[];return t.prefix&&((null==e?void 0:e.all)||(null==e?void 0:e.prefix))&&n.push(...t.prefix),t.given&&n.push(...t.given),t.family&&n.push(t.family),t.suffix&&((null==e?void 0:e.all)||(null==e?void 0:e.suffix))&&n.push(...t.suffix),t.use&&((null==e?void 0:e.all)||(null==e?void 0:e.use))&&n.push("["+t.use+"]"),n.join(" ").trim()}function u(t){const e=[];return t.given&&e.push(...t.given),e.join(" ").trim()}function h(t){return t.family||""}function f(t){const e=d(t),n=g(t);return n===e?{reference:e}:{reference:e,display:n}}function d(t){return t.resourceType+"/"+t.id}function v(t){var e;return null===(e=null==t?void 0:t.reference)||void 0===e?void 0:e.split("/")[1]}function p(t){return"Patient"===t.resourceType||"Practitioner"===t.resourceType||"RelatedPerson"===t.resourceType}function g(t){var e,n;if(p(t)){const e=function(t){const e=t.name;if(e&&e.length>0)return c(e[0]);return}(t);if(e)return e}if("Device"===t.resourceType){const e=function(t){const e=t.deviceName;if(e&&e.length>0)return e[0].name;return}(t);if(e)return e}return"Observation"===t.resourceType&&"code"in t&&(null===(e=t.code)||void 0===e?void 0:e.text)?null===(n=t.code)||void 0===n?void 0:n.text:"User"===t.resourceType&&t.email?t.email:"name"in t&&t.name&&"string"==typeof t.name?t.name:d(t)}function m(t){if(p(t)){const e=t.photo;if(e)for(const t of e){const e=y(t);if(e)return e}}if("Bot"===t.resourceType&&t.photo){const e=y(t.photo);if(e)return e}}function y(t){if(t.url&&t.contentType&&t.contentType.startsWith("image/"))return t.url}function w(t){return t?new Date(t):void 0}function b(t,e){const n=new Date(t);n.setUTCHours(0,0,0,0);const i=e?new Date(e):new Date;i.setUTCHours(0,0,0,0);const r=n.getUTCFullYear(),s=n.getUTCMonth(),o=n.getUTCDate(),a=i.getUTCFullYear(),l=i.getUTCMonth(),c=i.getUTCDate();let u=a-r;(l<s||l===s&&c<o)&&u--;let h=12*a+l-(12*r+s);c<o&&h--;return{years:u,months:h,days:Math.floor((i.getTime()-n.getTime())/864e5)}}function T(t,e){const{years:n,months:i,days:r}=b(t,e);return n>=2?n.toString().padStart(3,"0")+"Y":i>=1?i.toString().padStart(3,"0")+"M":r.toString().padStart(3,"0")+"D"}function E(t){const e={};return S(t.item,e),e}function S(t,e){if(t)for(const n of t)n.linkId&&n.answer&&n.answer.length>0&&(e[n.linkId]=n.answer[0]),S(n.item,e)}function A(t,e){const n=t.identifier;if(!n)return;const i=Array.isArray(n)?n:[n];for(const t of i)if(t.system===e)return t.value}function k(t,...e){var n;let i=t;for(let t=0;t<e.length&&i;t++)i=null===(n=null==i?void 0:i.extension)||void 0===n?void 0:n.find((n=>n.url===e[t]));return null==i?void 0:i.valueString}function x(t,e){return JSON.stringify(t,P,e?2:void 0)}function P(t,e){return!function(t){return!!t.match(/\d+$/)}(t)&&O(e)?void 0:e}function O(t){if(null==t)return!0;const e=typeof t;return"string"===e&&""===t||"object"===e&&0===Object.keys(t).length}function U(t,e,n){return t===e||(!(!O(t)||!O(e))||!O(t)&&!O(e)&&(Array.isArray(t)&&Array.isArray(e)?function(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!U(t[n],e[n]))return!1;return!0}(t,e):!Array.isArray(t)&&!Array.isArray(e)&&(R(t)&&R(e)?function(t,e,n){const i=new Set;Object.keys(t).forEach((t=>i.add(t))),Object.keys(e).forEach((t=>i.add(t))),"meta"===n&&(i.delete("versionId"),i.delete("lastUpdated"),i.delete("author"));for(const n of i){if(!U(t[n],e[n],n))return!1}return!0}(t,e,n):(R(t)||R(e),!1))))}function M(t){return!!t.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)}function R(t){return null!==t&&"object"==typeof t}function C(t){return t.every((t=>"string"==typeof t))}r=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(){return e(this,s,"f").keys().next().value};const L=[];for(let t=0;t<256;t++)L.push(t.toString(16).padStart(2,"0"));function D(t){const e=new Uint8Array(t),n=new Array(e.length);for(let t=0;t<e.length;t++)n[t]=L[e[t]];return n.join("")}function _(t){const e=new Uint8Array(t),n=[];for(let t=0;t<e.length;t++)n[t]=String.fromCharCode(e[t]);return window.btoa(n.join(""))}function I(t){return t.charAt(0).toUpperCase()+t.substring(1)}function j(t){return t===t.toLowerCase()}function W(t,e){var n,i;return null===(i=null===(n=null==t?void 0:t.coding)||void 0===n?void 0:n.find((t=>t.system===e)))||void 0===i?void 0:i.code}function N(t,e,n){var i,r;t.coding||(t.coding=[]);const s=null===(i=t.coding)||void 0===i?void 0:i.find((t=>t.system===e));s?s.code=n:null===(r=t.coding)||void 0===r||r.push({system:e,code:n})}function B(t,e,n,i){var r;return null===(r=t.qualifiedInterval)||void 0===r?void 0:r.find((r=>{var s;return function(t,e){return function(t,e){return!t.gender||t.gender===e.gender}(t,e)&&function(t,e){return!t.age||Q(b(e.birthDate).years,t.age)}(t,e)}(r,e)&&function(t,e,n){return!!t.range&&Q(e,t.range,n)}(r,n,null===(s=t.quantitativeDetails)||void 0===s?void 0:s.decimalPrecision)&&(void 0===i||r.category===i)}))}function Q(t,e,n){var i,r;return(void 0===(null===(i=e.low)||void 0===i?void 0:i.value)||X(t,e.low.value,n))&&(void 0===(null===(r=e.high)||void 0===r?void 0:r.value)||q(t,e.high.value,n))}function $(t,e,n){return n?Math.abs(t-e)<Math.pow(10,-n):t===e}function F(t,e,n){return n?t<e&&Math.abs(t-e)>Math.pow(10,-n):t<e}function H(t,e,n){return n?t>e&&Math.abs(t-e)>Math.pow(10,-n):t>e}function q(t,e,n){return F(t,e,n)||$(t,e,n)}function X(t,e,n){return H(t,e,n)||$(t,e,n)}function z(){const t=new Uint32Array(28);return crypto.getRandomValues(t),D(t.buffer)}var Y,V,G,K,J,Z,tt,et,nt,it,rt,st,ot,at,lt,ct,ut,ht,ft,dt,vt,pt,gt,mt,yt,wt,bt,Tt,Et,St,At,kt,xt,Pt,Ot,Ut,Mt,Rt,Ct,Lt,Dt,_t,It;function jt(t){const e=function(t){if("undefined"!=typeof window)return window.atob(t);if("undefined"!=typeof Buffer)return Buffer.from(t,"base64").toString("binary");throw new Error("Unable to decode base64")}(t.replace(/-/g,"+").replace(/_/g,"/")),n=Array.from(e).reduce(((t,e)=>`${t}%${("00"+e.charCodeAt(0).toString(16)).slice(-2)}`),""),i=decodeURIComponent(n);return JSON.parse(i)}Y=new WeakMap;class Wt{constructor(t){this[Z]="ReadablePromise",V.set(this,void 0),G.set(this,"pending"),K.set(this,void 0),J.set(this,void 0),n(this,V,t.then((t=>(n(this,G,"success","f"),n(this,K,t,"f"),t)),(t=>{throw n(this,G,"error","f"),n(this,J,t,"f"),t})),"f")}isPending(){return"pending"===e(this,G,"f")}read(){switch(e(this,G,"f")){case"pending":throw e(this,V,"f");case"error":throw e(this,J,"f");default:return e(this,K,"f")}}then(t,n){return e(this,V,"f").then(t,n)}catch(t){return e(this,V,"f").catch(t)}finally(t){return e(this,V,"f").finally(t)}}V=new WeakMap,G=new WeakMap,K=new WeakMap,J=new WeakMap,Z=Symbol.toStringTag;class Nt{constructor(){tt.set(this,void 0),n(this,tt,"undefined"!=typeof localStorage?localStorage:new Bt,"f")}clear(){e(this,tt,"f").clear()}getString(t){return e(this,tt,"f").getItem(t)||void 0}setString(t,n){n?e(this,tt,"f").setItem(t,n):e(this,tt,"f").removeItem(t)}getObject(t){const e=this.getString(t);return e?JSON.parse(e):void 0}setObject(t,e){this.setString(t,e?x(e):void 0)}}tt=new WeakMap;class Bt{constructor(){et.set(this,void 0),n(this,et,new Map,"f")}get length(){return e(this,et,"f").size}clear(){e(this,et,"f").clear()}getItem(t){var n;return null!==(n=e(this,et,"f").get(t))&&void 0!==n?n:null}setItem(t,n){n?e(this,et,"f").set(t,n):e(this,et,"f").delete(t)}removeItem(t){e(this,et,"f").delete(t)}key(t){return Array.from(e(this,et,"f").keys())[t]}}function Qt(){return{types:{}}}function $t(t,e){return{display:t,description:e,properties:{},searchParams:{_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"}}}}function Ft(t,e){var n;const i=e.name;if(!i)return;t.types[i]=$t(i,e.description);const r=null===(n=e.snapshot)||void 0===n?void 0:n.element;if(r){const e=r.filter((t=>t.path!==i&&t.path));e.forEach((e=>function(t,e){var n,i;const r=e.path,s=null===(i=null===(n=e.type)||void 0===n?void 0:n[0])||void 0===i?void 0:i.code;if("Element"!==s&&"BackboneElement"!==s)return;const o=r.split("."),a=qt(o);a in t.types||(t.types[a]=$t(a,e.definition),t.types[a].parentType=qt(o.slice(0,o.length-1)))}(t,e))),e.forEach((e=>function(t,e){const n=e.path.split(".");if(1===n.length)return;const i=qt(n.slice(0,n.length-1)),r=t.types[i],s=n[n.length-1];r.properties[s]=e}(t,e)))}}function Ht(t,e){if(e.base)for(const n of e.base){const i=t.types[n];i&&(i.searchParams||(i.searchParams={}),i.searchParams[e.code]=e)}}function qt(t){return t.map(I).join("")}function Xt(t){const e=t.path.replaceAll("[x]","").split(".").pop();return"id"===e?"ID":e.split(/(?=[A-Z])/).map(I).join(" ").replace("_"," ").replace(/\s+/g," ")}et=new WeakMap,function(t){t.Address="Address",t.Age="Age",t.Annotation="Annotation",t.Attachment="Attachment",t.BackboneElement="BackboneElement",t.CodeableConcept="CodeableConcept",t.Coding="Coding",t.ContactDetail="ContactDetail",t.ContactPoint="ContactPoint",t.Contributor="Contributor",t.Count="Count",t.DataRequirement="DataRequirement",t.Distance="Distance",t.Dosage="Dosage",t.Duration="Duration",t.Expression="Expression",t.Extension="Extension",t.HumanName="HumanName",t.Identifier="Identifier",t.MarketingStatus="MarketingStatus",t.Meta="Meta",t.Money="Money",t.Narrative="Narrative",t.ParameterDefinition="ParameterDefinition",t.Period="Period",t.Population="Population",t.ProdCharacteristic="ProdCharacteristic",t.ProductShelfLife="ProductShelfLife",t.Quantity="Quantity",t.Range="Range",t.Ratio="Ratio",t.Reference="Reference",t.RelatedArtifact="RelatedArtifact",t.Resource="Resource",t.SampledData="SampledData",t.Signature="Signature",t.SubstanceAmount="SubstanceAmount",t.SystemString="http://hl7.org/fhirpath/System.String",t.Timing="Timing",t.TriggerDefinition="TriggerDefinition",t.UsageContext="UsageContext",t.base64Binary="base64Binary",t.boolean="boolean",t.canonical="canonical",t.code="code",t.date="date",t.dateTime="dateTime",t.decimal="decimal",t.id="id",t.instant="instant",t.integer="integer",t.markdown="markdown",t.oid="oid",t.positiveInt="positiveInt",t.string="string",t.time="time",t.unsignedInt="unsignedInt",t.uri="uri",t.url="url",t.uuid="uuid"}(nt||(nt={}));const zt="launch/patient openid fhirUser offline_access user/*.*";class Yt extends class{constructor(){Y.set(this,void 0),n(this,Y,{},"f")}addEventListener(t,n){e(this,Y,"f")[t]||(e(this,Y,"f")[t]=[]),e(this,Y,"f")[t].push(n)}removeEventListeneer(t,n){const i=e(this,Y,"f")[t];if(i)for(let t=0;t<i.length;t++)if(i[t]===n)return void i.splice(t,1)}dispatchEvent(t){const n=e(this,Y,"f")[t.type];return n&&n.forEach((e=>e.call(this,t))),!t.defaultPrevented}}{constructor(t){var i,r;if(super(),it.add(this),rt.set(this,void 0),st.set(this,void 0),ot.set(this,void 0),at.set(this,void 0),lt.set(this,void 0),ct.set(this,void 0),ut.set(this,void 0),ht.set(this,void 0),ft.set(this,void 0),dt.set(this,void 0),vt.set(this,void 0),pt.set(this,void 0),gt.set(this,void 0),mt.set(this,void 0),yt.set(this,void 0),wt.set(this,void 0),bt.set(this,void 0),Tt.set(this,void 0),null==t?void 0:t.baseUrl){if(!t.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");if(!t.baseUrl.endsWith("/"))throw new Error("Base URL must end with a trailing slash")}n(this,rt,(null==t?void 0:t.fetch)||window.fetch.bind(window),"f"),n(this,st,null==t?void 0:t.createPdf,"f"),n(this,ot,new Nt,"f"),n(this,at,{types:{}},"f"),n(this,lt,new a(null!==(i=null==t?void 0:t.resourceCacheSize)&&void 0!==i?i:1e3),"f"),n(this,ct,null!==(r=null==t?void 0:t.cacheTime)&&void 0!==r?r:1e4,"f"),n(this,ut,(null==t?void 0:t.baseUrl)||"https://api.medplum.com/","f"),n(this,ht,(null==t?void 0:t.clientId)||"","f"),n(this,ft,(null==t?void 0:t.authorizeUrl)||e(this,ut,"f")+"oauth2/authorize","f"),n(this,dt,(null==t?void 0:t.tokenUrl)||e(this,ut,"f")+"oauth2/token","f"),n(this,vt,(null==t?void 0:t.logoutUrl)||e(this,ut,"f")+"oauth2/logout","f"),n(this,pt,null==t?void 0:t.onUnauthenticated,"f");const s=this.getActiveLogin();s&&(n(this,gt,s.accessToken,"f"),n(this,mt,s.refreshToken,"f"),e(this,it,"m",St).call(this).catch(console.log)),e(this,it,"m",It).call(this)}getBaseUrl(){return e(this,ut,"f")}clear(){e(this,ot,"f").clear(),e(this,lt,"f").clear(),n(this,gt,void 0,"f"),n(this,mt,void 0,"f"),n(this,bt,void 0,"f"),n(this,Tt,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(t){t=t.toString(),e(this,lt,"f").delete(t)}invalidateSearches(t){const n="fhir/R4/"+t;for(const t of e(this,lt,"f").keys())(t.endsWith(n)||t.includes(n+"?"))&&e(this,lt,"f").delete(t)}get(t,n={}){t=t.toString();const i=e(this,it,"m",At).call(this,t,n);if(i)return i.value;const r=new Wt(e(this,it,"m",xt).call(this,"GET",t,n));return e(this,it,"m",kt).call(this,t,r),r}post(t,n,i,r={}){return t=t.toString(),n&&e(this,it,"m",Ut).call(this,r,n),i&&e(this,it,"m",Ot).call(this,r,i),this.invalidateUrl(t),e(this,it,"m",xt).call(this,"POST",t,r)}put(t,n,i,r={}){return t=t.toString(),n&&e(this,it,"m",Ut).call(this,r,n),i&&e(this,it,"m",Ot).call(this,r,i),this.invalidateUrl(t),e(this,it,"m",xt).call(this,"PUT",t,r)}patch(t,n,i={}){return t=t.toString(),e(this,it,"m",Ut).call(this,i,n),e(this,it,"m",Ot).call(this,i,"application/json-patch+json"),this.invalidateUrl(t),e(this,it,"m",xt).call(this,"PATCH",t,i)}delete(t,n={}){return t=t.toString(),this.invalidateUrl(t),e(this,it,"m",xt).call(this,"DELETE",t,n)}register(e){return t(this,void 0,void 0,(function*(){const t=yield this.post("auth/register",e);yield this.setActiveLogin(t)}))}startLogin(n){return t(this,void 0,void 0,(function*(){return yield e(this,it,"m",Rt).call(this),this.post("auth/login",Object.assign(Object.assign({},n),{clientId:e(this,ht,"f"),scope:zt,codeChallengeMethod:"S256",codeChallenge:e(this,ot,"f").getString("codeChallenge")}))}))}startGoogleLogin(n){return t(this,void 0,void 0,(function*(){return yield e(this,it,"m",Rt).call(this),this.post("auth/google",n)}))}signOut(){return this.clear(),Promise.resolve()}signInWithRedirect(){const t=new URLSearchParams(window.location.search).get("code");return t?this.processCode(t):void e(this,it,"m",Ct).call(this)}signOutWithRedirect(){window.location.assign(e(this,vt,"f"))}fhirUrl(...t){return new URL(e(this,ut,"f")+"fhir/R4/"+t.join("/"))}fhirSearchUrl(t,e){const n=this.fhirUrl(t);return e&&(n.search=e.toString()),n}search(t,e,n={}){return this.get(this.fhirSearchUrl(t,e),n)}searchOne(t,n,i={}){const r=this.fhirSearchUrl(t,n);r.searchParams.set("_count","1"),r.searchParams.sort();const s=r.toString()+"-searchOne",o=e(this,it,"m",At).call(this,s,i);if(o)return o.value;const a=new Wt(this.search(t,r.searchParams,i).then((t=>{var e,n;return null===(n=null===(e=t.entry)||void 0===e?void 0:e[0])||void 0===n?void 0:n.resource})));return e(this,it,"m",kt).call(this,s,a),a}searchResources(t,n,i={}){const r=this.fhirSearchUrl(t,n).toString()+"-searchResources",s=e(this,it,"m",At).call(this,r,i);if(s)return s.value;const o=new Wt(this.search(t,n,i).then((t=>{var e,n;return null!==(n=null===(e=t.entry)||void 0===e?void 0:e.map((t=>t.resource)))&&void 0!==n?n:[]})));return e(this,it,"m",kt).call(this,r,o),o}searchValueSet(t,e,n={}){const i=this.fhirUrl("ValueSet","$expand");return i.searchParams.set("url",t),i.searchParams.set("filter",e),this.get(i.toString(),n)}getCached(t,n){var i;const r=null===(i=e(this,lt,"f").get(this.fhirUrl(t,n).toString()))||void 0===i?void 0:i.value;return r&&!r.isPending()?r.read():void 0}getCachedReference(t){const e=t.reference;if(!e)return;const[n,i]=e.split("/");return n&&i?this.getCached(n,i):void 0}readResource(t,e){return this.get(this.fhirUrl(t,e))}readReference(t){const e=null==t?void 0:t.reference;if(!e)return new Wt(Promise.reject(new Error("Missing reference")));const[n,i]=e.split("/");return n&&i?this.readResource(n,i):new Wt(Promise.reject(new Error("Invalid reference")))}getSchema(){return e(this,at,"f")}requestSchema(n){return t(this,void 0,void 0,(function*(){if(n in e(this,at,"f").types)return Promise.resolve(e(this,at,"f"));const t=`{\n StructureDefinitionList(name: "${n}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${n}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(t);for(const t of i.data.StructureDefinitionList)Ft(e(this,at,"f"),t);for(const t of i.data.SearchParameterList)Ht(e(this,at,"f"),t);return e(this,at,"f")}))}readHistory(t,e){return this.get(this.fhirUrl(t,e,"_history"))}readVersion(t,e,n){return this.get(this.fhirUrl(t,e,"_history",n))}readPatientEverything(t){return this.get(this.fhirUrl("Patient",t,"$everything"))}createResource(t){if(!t.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(t.resourceType),this.post(this.fhirUrl(t.resourceType),t)}createResourceIfNoneExist(e,n){var i;return t(this,void 0,void 0,(function*(){return null!==(i=yield this.searchOne(e.resourceType,n))&&void 0!==i?i:this.createResource(e)}))}createBinary(t,e,n){const i=this.fhirUrl("Binary");return e&&i.searchParams.set("_filename",e),this.post(i,t,n)}createPdf(n,i,r,s){return t(this,void 0,void 0,(function*(){if(!e(this,st,"f"))throw new Error("PDF creation not enabled");const t=yield e(this,st,"f").call(this,n,r,s);return this.createBinary(t,i,"application/pdf")}))}createComment(t,e){const n=this.getProfile();let i,r;return"Encounter"===t.resourceType&&(i=f(t),r=t.subject),"ServiceRequest"===t.resourceType&&(i=t.encounter,r=t.subject),"Patient"===t.resourceType&&(r=f(t)),this.createResource({resourceType:"Communication",basedOn:[f(t)],encounter:i,subject:r,sender:n?f(n):void 0,sent:(new Date).toISOString(),payload:[{contentString:e}]})}updateResource(t){if(!t.resourceType)throw new Error("Missing resourceType");if(!t.id)throw new Error("Missing id");return this.invalidateSearches(t.resourceType),this.put(this.fhirUrl(t.resourceType,t.id),t)}patchResource(t,e,n){return this.invalidateSearches(t),this.patch(this.fhirUrl(t,e),n)}deleteResource(t,e){return this.invalidateSearches(t),this.delete(this.fhirUrl(t,e))}sendEmail(t){return this.post("email/v1/send",t,"application/json")}graphql(t,e){return this.post(this.fhirUrl("$graphql"),{query:t},"application/json",e)}getActiveLogin(){return e(this,ot,"f").getObject("activeLogin")}setActiveLogin(i){return t(this,void 0,void 0,(function*(){n(this,gt,i.accessToken,"f"),n(this,mt,i.refreshToken,"f"),n(this,bt,void 0,"f"),n(this,Tt,void 0,"f"),e(this,ot,"f").setObject("activeLogin",i),e(this,it,"m",Et).call(this,i),e(this,lt,"f").clear(),n(this,yt,void 0,"f"),yield e(this,it,"m",St).call(this)}))}getAccessToken(){return e(this,gt,"f")}setAccessToken(t){n(this,gt,t,"f"),n(this,mt,void 0,"f"),n(this,bt,void 0,"f"),n(this,Tt,void 0,"f")}getLogins(){var t;return null!==(t=e(this,ot,"f").getObject("logins"))&&void 0!==t?t:[]}isLoading(){return!!e(this,wt,"f")}getProfile(){return e(this,bt,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return e(this,wt,"f")&&(yield e(this,wt,"f")),this.getProfile()}))}getUserConfiguration(){return e(this,Tt,"f")}download(n,i={}){return t(this,void 0,void 0,(function*(){e(this,yt,"f")&&(yield e(this,yt,"f")),e(this,it,"m",Pt).call(this,i);return(yield e(this,rt,"f").call(this,n.toString(),i)).blob()}))}processCode(t){if(!e(this,ot,"f").getString("pkceState"))throw this.clear(),new Error("Invalid PCKE state");const n=e(this,ot,"f").getString("codeVerifier");if(!n)throw this.clear(),new Error("Invalid PCKE code verifier");const i=new URLSearchParams;return i.set("grant_type","authorization_code"),i.set("client_id",e(this,ht,"f")),i.set("code_verifier",n),i.set("code",t),i.set("redirect_uri",Vt()),e(this,it,"m",Dt).call(this,i)}startClientLogin(n,i){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",n),t.set("client_secret",i),e(this,it,"m",Dt).call(this,t)}))}}function Vt(){return window.location.protocol+"//"+window.location.host+"/"}function Gt(t){return[{type:nt.boolean,value:t}]}function Kt(t){return Number.isSafeInteger(t)?{type:nt.integer,value:t}:"number"==typeof t?{type:nt.decimal,value:t}:"boolean"==typeof t?{type:nt.boolean,value:t}:"string"==typeof t?{type:nt.string,value:t}:oe(t)?{type:nt.Quantity,value:t}:{type:nt.BackboneElement,value:t}}function Jt(t){return 0!==t.length&&!!t[0].value}function Zt(t){const e=[];for(const n of t){let t=!1;for(const i of e)if(Jt(ne(n,i))){t=!0;break}t||e.push(n)}return e}function te(t){return Gt(!Jt(t))}function ee(t,e){return 0===t.length||0===e.length?[]:t.length!==e.length?Gt(!1):Gt(t.every(((t,n)=>Jt(ne(t,e[n])))))}function ne(t,e){const n=t.value,i=e.value;return"number"==typeof n&&"number"==typeof i?Gt(Math.abs(n-i)<1e-8):oe(n)&&oe(i)?Gt(ae(n,i)):Gt("object"==typeof n&&"object"==typeof i?le(t,e):n===i)}function ie(t,e){return 0===t.length&&0===e.length?Gt(!0):t.length!==e.length?Gt(!1):(t.sort(re),e.sort(re),Gt(t.every(((t,n)=>Jt(function(t,e){const n=t.value,i=e.value;if("number"==typeof n&&"number"==typeof i)return Gt(Math.abs(n-i)<.01);if(oe(n)&&oe(i))return Gt(ae(n,i));if("object"==typeof n&&"object"==typeof i)return Gt(le(n,i));if("string"==typeof n&&"string"==typeof i)return Gt(n.toLowerCase()===i.toLowerCase());return Gt(n===i)}(t,e[n]))))))}function re(t,e){const n=t.value,i=e.value;return"number"==typeof n&&"number"==typeof i?n-i:"string"==typeof n&&"string"==typeof i?n.localeCompare(i):0}function se(t,e){const{value:n}=t;if(null==n)return!1;switch(e){case"Boolean":return"boolean"==typeof n;case"Decimal":case"Integer":return"number"==typeof n;case"Date":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof n&&!!n.match(/^T\d/);case"Period":return!(!(i=n)||"object"!=typeof i||!("start"in i));case"Quantity":return oe(n);default:return"object"==typeof n&&(null==n?void 0:n.resourceType)===e}var i}function oe(t){return!(!t||"object"!=typeof t||!("value"in t)||"number"!=typeof t.value)}function ae(t,e){return Math.abs(t.value-e.value)<.01&&(t.unit===e.unit||t.code===e.code||t.unit===e.code||t.code===e.unit)}function le(t,e){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){const n=t[i],r=e[i];if(ce(n)&&ce(r)){if(!le(n,r))return!1}else if(n!==r)return!1}return!0}function ce(t){return null!==t&&"object"==typeof t}var ue,he;rt=new WeakMap,st=new WeakMap,ot=new WeakMap,at=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,ft=new WeakMap,dt=new WeakMap,vt=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,yt=new WeakMap,wt=new WeakMap,bt=new WeakMap,Tt=new WeakMap,it=new WeakSet,Et=function(t){const n=this.getLogins().filter((e=>{var n,i;return(null===(n=e.profile)||void 0===n?void 0:n.reference)!==(null===(i=t.profile)||void 0===i?void 0:i.reference)}));n.push(t),e(this,ot,"f").setObject("logins",n)},St=function(){return t(this,void 0,void 0,(function*(){return n(this,wt,new Promise(((t,i)=>{this.get("auth/me").then((i=>{n(this,wt,void 0,"f"),n(this,bt,i.profile,"f"),n(this,Tt,i.config,"f"),this.dispatchEvent({type:"change"}),t(e(this,bt,"f"))})).catch(i)})),"f"),e(this,wt,"f")}))},At=function(t,n){if(e(this,ct,"f")<=0||"no-cache"===(null==n?void 0:n.cache)||"reload"===(null==n?void 0:n.cache))return;const i=e(this,lt,"f").get(t);return!i||i.requestTime+e(this,ct,"f")<Date.now()?void 0:i},kt=function(t,n){e(this,ct,"f")>0&&e(this,lt,"f").set(t,{requestTime:Date.now(),value:n})},xt=function(n,i,r={}){return t(this,void 0,void 0,(function*(){e(this,yt,"f")&&(yield e(this,yt,"f")),i.startsWith("http")||(i=e(this,ut,"f")+i),r.method=n,e(this,it,"m",Pt).call(this,r);const t=yield e(this,rt,"f").call(this,i,r);if(401===t.status)return e(this,it,"m",Mt).call(this,n,i,r);if(204===t.status||304===t.status)return;const s=yield t.json();if(t.status>=400)throw s;return s}))},Pt=function(t){t.headers||(t.headers={});const n=t.headers;n["Content-Type"]||(n["Content-Type"]="application/fhir+json"),e(this,gt,"f")&&(n.Authorization="Bearer "+e(this,gt,"f")),t.cache||(t.cache="no-cache"),t.credentials||(t.credentials="include")},Ot=function(t,e){t.headers||(t.headers={});t.headers["Content-Type"]=e},Ut=function(t,e){"string"==typeof e||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Uint8Array&&e instanceof Uint8Array?t.body=e:e&&(t.body=JSON.stringify(e))},Mt=function(n,i,r){return t(this,void 0,void 0,(function*(){return e(this,it,"m",Lt).call(this).then((()=>e(this,it,"m",xt).call(this,n,i,r))).catch((t=>(this.clear(),e(this,pt,"f")&&e(this,pt,"f").call(this),Promise.reject(t))))}))},Rt=function(){return t(this,void 0,void 0,(function*(){const n=z();e(this,ot,"f").setString("pkceState",n);const i=z();e(this,ot,"f").setString("codeVerifier",i);const r=_(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(i)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");e(this,ot,"f").setString("codeChallenge",r)}))},Ct=function(){e(this,it,"m",Rt).call(this);const t=new URL(e(this,ft,"f"));t.searchParams.set("response_type","code"),t.searchParams.set("state",e(this,ot,"f").getString("pkceState")),t.searchParams.set("client_id",e(this,ht,"f")),t.searchParams.set("redirect_uri",Vt()),t.searchParams.set("scope",zt),t.searchParams.set("code_challenge_method","S256"),t.searchParams.set("code_challenge",e(this,ot,"f").getString("codeChallenge")),window.location.assign(t.toString())},Lt=function(){return t(this,void 0,void 0,(function*(){if(e(this,yt,"f"))return e(this,yt,"f");if(!e(this,mt,"f"))throw this.clear(),new Error("Invalid refresh token");const t=new URLSearchParams;t.set("grant_type","refresh_token"),t.set("client_id",e(this,ht,"f")),t.set("refresh_token",e(this,mt,"f")),n(this,yt,e(this,it,"m",Dt).call(this,t),"f"),yield e(this,yt,"f")}))},Dt=function(n){return t(this,void 0,void 0,(function*(){return e(this,rt,"f").call(this,e(this,dt,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n}).then((t=>{if(!t.ok)throw new Error("Failed to fetch tokens");return t.json()})).then((t=>e(this,it,"m",_t).call(this,t))).then((()=>this.getProfile()))}))},_t=function(n){return t(this,void 0,void 0,(function*(){const t=n.access_token,i=function(t){const[e,n,i]=t.split(".");return jt(n)}(t);if(Date.now()>=1e3*i.exp)throw this.clear(),new Error("Token expired");if(e(this,ht,"f")&&i.client_id!==e(this,ht,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:n.refresh_token,project:n.project,profile:n.profile})}))},It=function(){try{window.addEventListener("storage",(t=>{null!==t.key&&"activeLogin"!==t.key||window.location.reload()}))}catch(t){}};class fe{constructor(t,e){this.original=t,this.child=e}eval(t){try{return t.length>0?t.map((t=>this.child.eval([t]))).flat():this.child.eval(t)}catch(t){throw new Error(`FhirPathError on "${this.original}": ${t}`)}}}class de{constructor(t){this.value=t}eval(){return[this.value]}}class ve{constructor(t){this.name=t,ue.add(this)}eval(t){return"$this"===this.name?t:t.map((t=>e(this,ue,"m",he).call(this,t))).flat().filter((t=>void 0!==(null==t?void 0:t.value)))}}ue=new WeakSet,he=function(t){const e=t.value;if(!e||"object"!=typeof e)return;if("resourceType"in e&&e.resourceType===this.name)return t;let n;if(this.name in e)n=e[this.name];else{const t=Object.keys(e).find((t=>t.startsWith(this.name)));t&&(n=e[t])}return void 0!==n?Array.isArray(n)?n.map(Kt):[Kt(n)]:void 0};class pe{eval(){return[]}}class ge{constructor(t,e){this.child=t,this.impl=e}eval(t){return this.impl(this.child.eval(t))}}class me{constructor(t,e){this.left=t,this.right=e}eval(t){return this.left.eval(t)}}class ye{constructor(t,e,n){this.left=t,this.right=e,this.impl=n}eval(t){const e=this.left.eval(t);if(1!==e.length)return[];const n=this.right.eval(t);if(1!==n.length)return[];const i=e[0].value,r=n[0].value,s=oe(i)?i.value:i,o=oe(r)?r.value:r,a=this.impl(s,o);return"boolean"==typeof a?Gt(a):oe(i)?[{type:nt.Quantity,value:Object.assign(Object.assign({},i),{value:a})}]:[Kt(a)]}}class we{constructor(t,e){this.left=t,this.right=e}eval(t){const e=[...this.left.eval(t),...this.right.eval(t)];return e.length>0&&e.every((t=>"string"==typeof t.value))?[{type:nt.string,value:e.map((t=>t.value)).join("")}]:e}}class be{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t),n=this.right.eval(t);return Gt(e.some((t=>t.value===n[0].value)))}}class Te{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t);return Gt(this.right.eval(t).some((t=>t.value===e[0].value)))}}class Ee{constructor(t,e){this.left=t,this.right=e}eval(t){return this.right.eval(this.left.eval(t))}}class Se{constructor(t,e){this.left=t,this.right=e}eval(t){return Zt([...this.left.eval(t),...this.right.eval(t)])}}class Ae{constructor(t,e){this.left=t,this.right=e}eval(t){return ee(this.left.eval(t),this.right.eval(t))}}class ke{constructor(t,e){this.left=t,this.right=e}eval(t){return te(ee(this.left.eval(t),this.right.eval(t)))}}class xe{constructor(t,e){this.left=t,this.right=e}eval(t){return ie(this.left.eval(t),this.right.eval(t))}}class Pe{constructor(t,e){this.left=t,this.right=e}eval(t){return te(ie(this.left.eval(t),this.right.eval(t)))}}class Oe{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t);if(1!==e.length)return[];const n=this.right.name;return Gt(se(e[0],n))}}class Ue{constructor(t,e){this.left=t,this.right=e}eval(t){var e,n,i,r;const s=this.left.eval(t),o=this.right.eval(t);return!0===(null===(e=s[0])||void 0===e?void 0:e.value)&&!0===(null===(n=o[0])||void 0===n?void 0:n.value)?Gt(!0):!1===(null===(i=s[0])||void 0===i?void 0:i.value)||!1===(null===(r=o[0])||void 0===r?void 0:r.value)?Gt(!1):[]}}class Me{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t);if(Jt(e))return e;const n=this.right.eval(t);return Jt(n)?n:[]}}class Re{constructor(t,e){this.left=t,this.right=e}eval(t){const e=this.left.eval(t),n=this.right.eval(t);if(0===e.length&&0===n.length)return[];const i=0===e.length?null:e[0].value,r=0===n.length?null:n[0].value;return!0===i&&!0!==r||!0!==i&&!0===r?Gt(!0):!0===i&&!0===r||!1===i&&!1===r?Gt(!1):[]}}class Ce{constructor(t,e,n){this.name=t,this.args=e,this.impl=n}eval(t){return this.impl(t,...this.args)}}class Le{constructor(t,e){this.left=t,this.expr=e}eval(t){const e=this.expr.eval(t);if(1!==e.length)return[];const n=e[0].value;if("number"!=typeof n)throw new Error("Invalid indexer expression: should return integer}");const i=this.left.eval(t);return n in i?[i[n]]:[]}}function De(t){if(t.startsWith("T"))return t+"T00:00:00.000Z".substring(t.length);if(t.length<=10)return t;try{return new Date(t).toISOString()}catch(e){return t}}const _e=()=>[],Ie={empty:t=>Gt(0===t.length),exists:(t,e)=>Gt(e?t.filter((t=>Jt(e.eval([t])))).length>0:t.length>0),all:(t,e)=>Gt(t.every((t=>Jt(e.eval([t]))))),allTrue:t=>{for(const e of t)if(!e.value)return Gt(!1);return Gt(!0)},anyTrue:t=>{for(const e of t)if(e.value)return Gt(!0);return Gt(!1)},allFalse:t=>{for(const e of t)if(e.value)return Gt(!1);return Gt(!0)},anyFalse:t=>{for(const e of t)if(!e.value)return Gt(!0);return Gt(!1)},subsetOf:_e,supersetOf:_e,count:t=>[{type:nt.integer,value:t.length}],distinct:t=>{const e=[];for(const n of t)e.some((t=>t.value===n.value))||e.push(n);return e},isDistinct:t=>Gt(t.length===Ie.distinct(t).length),where:(t,e)=>t.filter((t=>Jt(e.eval([t])))),select:(t,e)=>t.map((t=>e.eval([t]))).flat(),repeat:_e,ofType:_e,single:t=>{if(t.length>1)throw new Error("Expected input length one for single()");return 0===t.length?[]:t.slice(0,1)},first:t=>0===t.length?[]:t.slice(0,1),last:t=>0===t.length?[]:t.slice(t.length-1,t.length),tail:t=>0===t.length?[]:t.slice(1,t.length),skip:(t,e)=>{var n;const i=null===(n=e.eval([])[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for skip(num)");return i>=t.length?[]:i<=0?t:t.slice(i,t.length)},take:(t,e)=>{var n;const i=null===(n=e.eval([])[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for take(num)");return i>=t.length?t:i<=0?[]:t.slice(0,i)},intersect:(t,e)=>{if(!e)return t;const n=e.eval([]),i=[];for(const e of t)!i.some((t=>t.value===e.value))&&n.some((t=>t.value===e.value))&&i.push(e);return i},exclude:(t,e)=>{if(!e)return t;const n=e.eval([]),i=[];for(const e of t)n.some((t=>t.value===e.value))||i.push(e);return i},union:(t,e)=>{if(!e)return t;const n=e.eval([]);return Zt([...t,...n])},combine:(t,e)=>{if(!e)return t;const n=e.eval([]);return[...t,...n]},iif:(t,e,n,i)=>{const r=e.eval(t);if(r.length>1||1===r.length&&"boolean"!=typeof r[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return Jt(r)?n.eval(t):i?i.eval(t):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);if("boolean"==typeof e)return[{type:nt.boolean,value:e}];if("number"==typeof e&&(0===e||1===e))return Gt(!!e);if("string"==typeof e){const t=e.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(t))return Gt(!0);if(["false","f","no","n","0","0.0"].includes(t))return Gt(!1)}return[]},convertsToBoolean:t=>0===t.length?[]:Gt(1===Ie.toBoolean(t).length),toInteger:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);return"number"==typeof e?[{type:nt.integer,value:e}]:"string"==typeof e&&e.match(/^[+-]?\d+$/)?[{type:nt.integer,value:parseInt(e,10)}]:"boolean"==typeof e?[{type:nt.integer,value:e?1:0}]:[]},convertsToInteger:t=>0===t.length?[]:Gt(1===Ie.toInteger(t).length),toDate:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);return"string"==typeof e&&e.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:nt.date,value:De(e)}]:[]},convertsToDate:t=>0===t.length?[]:Gt(1===Ie.toDate(t).length),toDateTime:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);return"string"==typeof e&&e.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:nt.dateTime,value:De(e)}]:[]},convertsToDateTime:t=>0===t.length?[]:Gt(1===Ie.toDateTime(t).length),toDecimal:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);return"number"==typeof e?[{type:nt.decimal,value:e}]:"string"==typeof e&&e.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:nt.decimal,value:parseFloat(e)}]:"boolean"==typeof e?[{type:nt.decimal,value:e?1:0}]:[]},convertsToDecimal:t=>0===t.length?[]:Gt(1===Ie.toDecimal(t).length),toQuantity:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);return oe(e)?[{type:nt.Quantity,value:e}]:"number"==typeof e?[{type:nt.Quantity,value:{value:e,unit:"1"}}]:"string"==typeof e&&e.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:nt.Quantity,value:{value:parseFloat(e),unit:"1"}}]:"boolean"==typeof e?[{type:nt.Quantity,value:{value:e?1:0,unit:"1"}}]:[]},convertsToQuantity:t=>0===t.length?[]:Gt(1===Ie.toQuantity(t).length),toString:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);return null==e?[]:oe(e)?[{type:nt.string,value:`${e.value} '${e.unit}'`}]:[{type:nt.string,value:e.toString()}]},convertsToString:t=>0===t.length?[]:Gt(1===Ie.toString(t).length),toTime:t=>{if(0===t.length)return[];const[{value:e}]=Ne(t,1);if("string"==typeof e){const t=e.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:nt.time,value:De("T"+t[1])}]}return[]},convertsToTime:t=>0===t.length?[]:Gt(1===Ie.toTime(t).length),indexOf:(t,e)=>je(((t,e)=>t.indexOf(e)),t,e),substring:(t,e,n)=>je(((t,e,n)=>{const i=e,r=n?i+n:t.length;return i<0||i>=t.length?void 0:t.substring(i,r)}),t,e,n),startsWith:(t,e)=>je(((t,e)=>t.startsWith(e)),t,e),endsWith:(t,e)=>je(((t,e)=>t.endsWith(e)),t,e),contains:(t,e)=>je(((t,e)=>t.includes(e)),t,e),upper:t=>je((t=>t.toUpperCase()),t),lower:t=>je((t=>t.toLowerCase()),t),replace:(t,e,n)=>je(((t,e,n)=>t.replaceAll(e,n)),t,e,n),matches:(t,e)=>je(((t,e)=>!!t.match(e)),t,e),replaceMatches:(t,e,n)=>je(((t,e,n)=>t.replaceAll(e,n)),t,e,n),length:t=>je((t=>t.length),t),toChars:t=>je((t=>t?t.split(""):void 0),t),abs:t=>We(Math.abs,t),ceiling:t=>We(Math.ceil,t),exp:t=>We(Math.exp,t),floor:t=>We(Math.floor,t),ln:t=>We(Math.log,t),log:(t,e)=>We(((t,e)=>Math.log(t)/Math.log(e)),t,e),power:(t,e)=>We(Math.pow,t,e),round:t=>We(Math.round,t),sqrt:t=>We(Math.sqrt,t),truncate:t=>We((t=>0|t),t),children:_e,descendants:_e,trace:(t,e)=>(console.log("trace",t,e),t),now:()=>[{type:nt.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:nt.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:nt.date,value:(new Date).toISOString().substring(0,10)}],between:(t,e,n,i)=>{const r=Ie.toDateTime(e.eval(t));if(0===r.length)throw new Error("Invalid start date");const s=Ie.toDateTime(n.eval(t));if(0===s.length)throw new Error("Invalid end date");const o=i.eval(t)[0].value;if("years"!==o&&"months"!==o&&"days"!==o)throw new Error("Invalid units");const a=b(r[0].value,s[0].value);return[{type:nt.Quantity,value:{value:a[o],unit:o}}]},is:(t,e)=>{let n="";return e instanceof ve?n=e.name:e instanceof Ee&&(n=e.left.name+"."+e.right.name),n?t.map((t=>({type:nt.boolean,value:se(t,n)}))):[]},not:t=>Ie.toBoolean(t).map((t=>({type:nt.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const e=t.value;let n;if("string"==typeof e)n=e;else if("object"==typeof e){const t=e;if(t.resource)return{type:nt.BackboneElement,value:t.resource};n=t.reference}if(!n)return{type:nt.BackboneElement,value:null};const[i,r]=n.split("/");return{type:nt.BackboneElement,value:{resourceType:i,id:r}}})).filter((t=>!!t.value)),as:t=>t,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:nt.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:nt.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:nt.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:nt.BackboneElement,value:null})),conformsTo:(t,e)=>{const n=e.eval([])[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const i=n.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var e;return{type:nt.boolean,value:(null===(e=t.value)||void 0===e?void 0:e.resourceType)===i}}))}};function je(t,e,...n){if(0===e.length)return[];const[{value:i}]=Ne(e,1);if("string"!=typeof i)throw new Error("String function cannot be called with non-string");const r=t(i,...n.map((t=>{var n,i;return t&&(null===(i=null===(n=t.eval(e))||void 0===n?void 0:n[0])||void 0===i?void 0:i.value)})));return void 0===r?[]:Array.isArray(r)?r.map(Kt):[Kt(r)]}function We(t,e,...n){if(0===e.length)return[];const[{value:i}]=Ne(e,1),r=oe(i),s=r?i.value:i;if("number"!=typeof s)throw new Error("Math function cannot be called with non-number");const o=t(s,...n.map((t=>{var e,n;return null===(n=null===(e=t.eval([]))||void 0===e?void 0:e[0])||void 0===n?void 0:n.value})));return[{type:r?nt.Quantity:e[0].type,value:r?Object.assign(Object.assign({},i),{value:o}):o}]}function Ne(t,e){if(t.length!==e)throw new Error(`Expected ${e} arguments`);for(const e of t)if(null==e)throw new Error("Expected non-null argument");return t}var Be,Qe,$e,Fe,He,qe,Xe,ze,Ye,Ve,Ge,Ke,Je,Ze,tn,en,nn,rn;function sn(t){return new ln(t).tokenize()}const on=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],an=["!=","!~","<=",">=","{}"];class ln{constructor(t){Be.add(this),Qe.set(this,void 0),$e.set(this,void 0),n(this,Qe,t,"f"),n(this,$e,0,"f")}tokenize(){const t=[];for(;e(this,$e,"f")<e(this,Qe,"f").length;){const n=e(this,Be,"m",He).call(this);n&&t.push(n)}return t}}function cn(t,e){return{id:t,value:e}}var un,hn,fn,dn,vn,pn,gn,mn,yn;Qe=new WeakMap,$e=new WeakMap,Be=new WeakSet,Fe=function(){const t=e(this,$e,"f"),i=e(this,Be,"m",He).call(this);return n(this,$e,t,"f"),i},He=function(){e(this,Be,"m",qe).call(this);const t=e(this,Be,"m",en).call(this);if(!t)return;const n=e(this,Be,"m",rn).call(this);return"/"===t&&"*"===n?e(this,Be,"m",Xe).call(this):"/"===t&&"/"===n?e(this,Be,"m",ze).call(this):"'"===t?e(this,Be,"m",Ye).call(this):"`"===t?e(this,Be,"m",Ve).call(this):"@"===t?e(this,Be,"m",Ge).call(this):t.match(/\d/)?e(this,Be,"m",Ke).call(this):t.match(/\w/)||"$"===t&&n.match(/\w/)?e(this,Be,"m",Je).call(this):e(this,Be,"m",Ze).call(this)},qe=function(){return cn("Whitespace",e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/\s/))))},Xe=function(){const t=e(this,$e,"f");return e(this,Be,"m",tn).call(this,(()=>"*"!==e(this,Be,"m",en).call(this)||"/"!==e(this,Be,"m",rn).call(this))),n(this,$e,e(this,$e,"f")+2,"f"),cn("Comment",e(this,Qe,"f").substring(t,e(this,$e,"f")))},ze=function(){return cn("Comment",e(this,Be,"m",tn).call(this,(()=>"\n"!==e(this,Be,"m",en).call(this))))},Ye=function(){var t,i;n(this,$e,(t=e(this,$e,"f"),++t),"f");const r=cn("String",e(this,Be,"m",tn).call(this,(()=>"\\"===e(this,Be,"m",nn).call(this)||"'"!==e(this,Be,"m",en).call(this))));return n(this,$e,(i=e(this,$e,"f"),++i),"f"),r},Ve=function(){var t,i;n(this,$e,(t=e(this,$e,"f"),++t),"f");const r=cn("Symbol",e(this,Be,"m",tn).call(this,(()=>"`"!==e(this,Be,"m",en).call(this))));return n(this,$e,(i=e(this,$e,"f"),++i),"f"),r},Ge=function(){var t,i,r,s,o;const a=e(this,$e,"f");return n(this,$e,(t=e(this,$e,"f"),++t),"f"),e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/[\d-]/))),"T"===e(this,Be,"m",en).call(this)&&(n(this,$e,(i=e(this,$e,"f"),++i),"f"),e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/[\d:]/))),"."===e(this,Be,"m",en).call(this)&&e(this,Be,"m",rn).call(this).match(/\d/)&&(n(this,$e,(r=e(this,$e,"f"),++r),"f"),e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/[\d]/)))),"Z"===e(this,Be,"m",en).call(this)?n(this,$e,(s=e(this,$e,"f"),++s),"f"):"+"!==e(this,Be,"m",en).call(this)&&"-"!==e(this,Be,"m",en).call(this)||(n(this,$e,(o=e(this,$e,"f"),++o),"f"),e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/[\d:]/))))),cn("DateTime",e(this,Qe,"f").substring(a+1,e(this,$e,"f")))},Ke=function(){var t;const i=e(this,$e,"f");let r="Number";return e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/\d/))),"."===e(this,Be,"m",en).call(this)&&e(this,Be,"m",rn).call(this).match(/\d/)&&(n(this,$e,(t=e(this,$e,"f"),++t),"f"),e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/\d/))))," "===e(this,Be,"m",en).call(this)&&function(t){if(t){if("String"===t.id)return!0;if("Symbol"===t.id&&on.includes(t.value))return!0}return!1}(e(this,Be,"m",Fe).call(this))&&(r="Quantity",e(this,Be,"m",He).call(this)),cn(r,e(this,Qe,"f").substring(i,e(this,$e,"f")))},Je=function(){return cn("Symbol",e(this,Be,"m",tn).call(this,(()=>e(this,Be,"m",en).call(this).match(/[$\w]/))))},Ze=function(){var t;const i=e(this,Be,"m",en).call(this),r=i+e(this,Be,"m",rn).call(this);return an.includes(r)?(n(this,$e,e(this,$e,"f")+2,"f"),cn(r,r)):(n(this,$e,(t=e(this,$e,"f"),++t),"f"),cn(i,i))},tn=function(t){var i;const r=e(this,$e,"f");for(;e(this,$e,"f")<e(this,Qe,"f").length&&t();)n(this,$e,(i=e(this,$e,"f"),++i),"f");return e(this,Qe,"f").substring(r,e(this,$e,"f"))},en=function(){return e(this,Qe,"f")[e(this,$e,"f")]},nn=function(){var t;return null!==(t=e(this,Qe,"f")[e(this,$e,"f")-1])&&void 0!==t?t:""},rn=function(){var t;return null!==(t=e(this,Qe,"f")[e(this,$e,"f")+1])&&void 0!==t?t:""};un=new WeakMap,hn=new WeakMap;class wn{constructor(t,e,i){fn.add(this),dn.set(this,void 0),vn.set(this,void 0),pn.set(this,void 0),n(this,dn,t,"f"),n(this,vn,e,"f"),n(this,pn,i,"f")}match(t){const n=e(this,fn,"m",yn).call(this);return(null==n?void 0:n.id)===t&&(e(this,fn,"m",mn).call(this),!0)}consumeAndParse(t=100){const n=e(this,fn,"m",mn).call(this),i=e(this,vn,"f")[n.id];if(!i)throw Error(`Parse error at ${n.value}. No matching prefix parselet.`);let r=i.parse(this,n);for(;t>e(this,fn,"m",gn).call(this);){const t=e(this,fn,"m",mn).call(this);r=e(this,pn,"f")[t.id].parse(this,r,t)}return r}}dn=new WeakMap,vn=new WeakMap,pn=new WeakMap,fn=new WeakSet,gn=function(){const t=e(this,fn,"m",yn).call(this);if(!t)return 100;const n=e(this,pn,"f")[t.id];return n?n.precedence:100},mn=function(){if(!e(this,dn,"f").length)throw Error("Cant consume unknown more tokens.");return e(this,dn,"f").shift()},yn=function(){return e(this,dn,"f").length>0?e(this,dn,"f")[0]:void 0};const bn={parse(t){const e=t.consumeAndParse();if(!t.match(")"))throw new Error("Parse error: expected `)`");return e}},Tn={parse(t,e){const n=t.consumeAndParse();if(!t.match("]"))throw new Error("Parse error: expected `]`");return new Le(e,n)},precedence:2},En={parse(t,e){if(!(e instanceof ve))throw new Error("Unexpected parentheses");if(!(e.name in Ie))throw new Error("Unrecognized function: "+e.name);const n=[];for(;!t.match(")");)n.push(t.consumeAndParse()),t.match(",");return new Ce(e.name,n,Ie[e.name])},precedence:0};function Sn(t){const e=t.split(" "),n=parseFloat(e[0]);let i=e[1];return i=i&&i.startsWith("'")&&i.endsWith("'")?i.substring(1,i.length-1):"{"+i+"}",{value:n,unit:i}}const An=(new class{constructor(){un.set(this,{}),hn.set(this,{})}registerInfix(t,n){return e(this,hn,"f")[t]=n,this}registerPrefix(t,n){return e(this,un,"f")[t]=n,this}prefix(t,e,n){return this.registerPrefix(t,{parse(t,i){const r=t.consumeAndParse(e);return n(i,r)}})}infixLeft(t,e,n){return this.registerInfix(t,{parse(t,i,r){const s=t.consumeAndParse(e);return n(i,r,s)},precedence:e})}construct(t){return new wn(sn(t),e(this,un,"f"),e(this,hn,"f"))}}).registerPrefix("String",{parse:(t,e)=>new de({type:nt.string,value:e.value})}).registerPrefix("DateTime",{parse:(t,e)=>new de({type:nt.dateTime,value:De(e.value)})}).registerPrefix("Quantity",{parse:(t,e)=>new de({type:nt.Quantity,value:Sn(e.value)})}).registerPrefix("Number",{parse:(t,e)=>new de({type:nt.decimal,value:parseFloat(e.value)})}).registerPrefix("Symbol",{parse:(t,e)=>"false"===e.value?new de({type:nt.boolean,value:!1}):"true"===e.value?new de({type:nt.boolean,value:!0}):new ve(e.value)}).registerPrefix("{}",{parse:()=>new pe}).registerPrefix("(",bn).registerInfix("[",Tn).registerInfix("(",En).prefix("+",3,((t,e)=>new ge(e,(t=>t)))).prefix("-",3,((t,e)=>new ye(e,e,((t,e)=>-e)))).infixLeft(".",1,((t,e,n)=>new Ee(t,n))).infixLeft("/",4,((t,e,n)=>new ye(t,n,((t,e)=>t/e)))).infixLeft("*",4,((t,e,n)=>new ye(t,n,((t,e)=>t*e)))).infixLeft("+",5,((t,e,n)=>new ye(t,n,((t,e)=>t+e)))).infixLeft("-",5,((t,e,n)=>new ye(t,n,((t,e)=>t-e)))).infixLeft("|",7,((t,e,n)=>new Se(t,n))).infixLeft("=",9,((t,e,n)=>new Ae(t,n))).infixLeft("!=",9,((t,e,n)=>new ke(t,n))).infixLeft("~",9,((t,e,n)=>new xe(t,n))).infixLeft("!~",9,((t,e,n)=>new Pe(t,n))).infixLeft("<",8,((t,e,n)=>new ye(t,n,((t,e)=>t<e)))).infixLeft("<=",8,((t,e,n)=>new ye(t,n,((t,e)=>t<=e)))).infixLeft(">",8,((t,e,n)=>new ye(t,n,((t,e)=>t>e)))).infixLeft(">=",8,((t,e,n)=>new ye(t,n,((t,e)=>t>=e)))).infixLeft("&",5,((t,e,n)=>new we(t,n))).infixLeft("Symbol",6,((t,e,n)=>{switch(e.value){case"and":return new Ue(t,n);case"as":return new me(t,n);case"contains":return new be(t,n);case"div":return new ye(t,n,((t,e)=>t/e|0));case"in":return new Te(t,n);case"is":return new Oe(t,n);case"mod":return new ye(t,n,((t,e)=>t%e));case"or":return new Me(t,n);case"xor":return new Re(t,n);default:throw new Error("Cannot use "+e.value+" as infix operator")}}));function kn(t){try{return new fe(t,An.construct(t).consumeAndParse())}catch(e){throw new Error(`FhirPathError on "${t}": ${e}`)}}function xn(t,e){Array.isArray(e)||(e=[e]);const n=Array.isArray(e)?e:[e];for(let t=0;t<n.length;t++){const e=n[t];"object"==typeof e&&"type"in e&&"value"in e||(n[t]={type:nt.BackboneElement,value:e})}return kn(t).eval(n).map((t=>t.value))}const Pn="\r",On="|",Un="^";class Mn{constructor(t){this.segments=t}get(t){return"number"==typeof t?this.segments[t]:this.segments.find((e=>e.name===t))}getAll(t){return this.segments.filter((e=>e.name===t))}toString(){return this.segments.map((t=>t.toString())).join("\r")}buildAck(){var t,e,n,i,r,s;const o=new Date,a=this.get("MSH"),l=(null===(t=null==a?void 0:a.get(2))||void 0===t?void 0:t.toString())||"",c=(null===(e=null==a?void 0:a.get(3))||void 0===e?void 0:e.toString())||"",u=(null===(n=null==a?void 0:a.get(4))||void 0===n?void 0:n.toString())||"",h=(null===(i=null==a?void 0:a.get(5))||void 0===i?void 0:i.toString())||"",f=(null===(r=null==a?void 0:a.get(9))||void 0===r?void 0:r.toString())||"",d=(null===(s=null==a?void 0:a.get(12))||void 0===s?void 0:s.toString())||"2.5.1";return new Mn([new Rn(["MSH","^~\\&",u,h,l,c,o.toISOString(),"","ACK",o.getTime().toString(),"P",d]),new Rn(["MSA","AA",f,"OK"])])}static parse(t){if(!t.startsWith("MSH|^~\\&")){const t=new Error("Invalid HL7 message");throw t.type="entity.parse.failed",t}return new Mn(t.split(/[\r\n]+/).map((t=>Rn.parse(t))))}}class Rn{constructor(t){C(t)?this.fields=t.map((t=>Cn.parse(t))):this.fields=t,this.name=this.fields[0].components[0]}get(t){return this.fields[t]}toString(){return this.fields.map((t=>t.toString())).join("|")}static parse(t){return new Rn(t.split("|").map((t=>Cn.parse(t))))}}class Cn{constructor(t){this.components=t}get(t){return this.components[t]}toString(){return this.components.join("^")}static parse(t){return new Cn(t.split("^"))}}const Ln={resourceType:"OperationOutcome",id:"ok",issue:[{severity:"information",code:"information",details:{text:"All OK"}}]},Dn={resourceType:"OperationOutcome",id:"created",issue:[{severity:"information",code:"information",details:{text:"Created"}}]},_n={resourceType:"OperationOutcome",id:"not-modified",issue:[{severity:"information",code:"information",details:{text:"Not Modified"}}]},In={resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},jn={resourceType:"OperationOutcome",id:"gone",issue:[{severity:"error",code:"gone",details:{text:"Gone"}}]},Wn={resourceType:"OperationOutcome",id:"access-denied",issue:[{severity:"error",code:"access-denied",details:{text:"Access Denied"}}]};function Nn(t,e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:t},expression:e?[e]:void 0}]}}function Bn(t){return"ok"===t.id||"created"===t.id||"not-modified"===t.id}function Qn(t){return"not-found"===t.id}function $n(t){return"gone"===t.id}function Fn(t){return"ok"===t.id?200:"created"===t.id?201:"not-modified"===t.id?304:"access-denied"===t.id?403:"not-found"===t.id?404:"gone"===t.id?410:400}function Hn(t,e){if(!Bn(t)||void 0===e)throw new qn(t)}class qn extends Error{constructor(t){var e,n;super(null===(n=null===(e=null==t?void 0:t.issue)||void 0===e?void 0:e[0].details)||void 0===n?void 0:n.text),this.outcome=t}}const Xn=20;var zn;!function(t){t.EQUALS="eq",t.NOT_EQUALS="ne",t.GREATER_THAN="gt",t.LESS_THAN="lt",t.GREATER_THAN_OR_EQUALS="ge",t.LESS_THAN_OR_EQUALS="le",t.STARTS_AFTER="sa",t.ENDS_BEFORE="eb",t.APPROXIMATELY="ap",t.CONTAINS="contains",t.EXACT="exact",t.TEXT="text",t.ABOVE="above",t.BELOW="below",t.IN="in",t.NOT_IN="not-in",t.OF_TYPE="of-type"}(zn||(zn={}));const Yn=[zn.CONTAINS,zn.EXACT,zn.TEXT,zn.ABOVE,zn.BELOW,zn.IN,zn.NOT_IN,zn.OF_TYPE],Vn=[zn.NOT_EQUALS,zn.GREATER_THAN,zn.LESS_THAN,zn.GREATER_THAN_OR_EQUALS,zn.LESS_THAN_OR_EQUALS,zn.STARTS_AFTER,zn.ENDS_BEFORE,zn.APPROXIMATELY];function Gn(t){const e=new URL(t,"https://example.com/"),n=e.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let i,r,s,o,a,l;return new URLSearchParams(e.search).forEach(((t,e)=>{"_fields"===e?s=t.split(","):"_offset"===e?o=parseInt(t):"_count"===e?a=parseInt(t):"_total"===e?l=t:"_sort"===e?(r=r||[],r.push(function(t){return t.startsWith("-")?{code:t.substring(1),descending:!0}:{code:t}}(t))):(i=i||[],i.push(function(t,e){let n=t,i=zn.EQUALS;for(const t of Yn){const e=n.indexOf(":"+t);-1!==e&&(i=t,n=n.substring(0,e))}for(const t of Vn)e.match(new RegExp("^"+t+"\\d"))&&(i=t,e=e.substring(t.length));return{code:n,operator:i,value:e}}(e,t)))})),{resourceType:n,filters:i,fields:s,offset:o,count:a,total:l,sortRules:r}}function Kn(t){const e=[];return t.fields&&e.push("_fields="+t.fields.join(",")),t.filters&&t.filters.forEach((t=>e.push(function(t){const e=Yn.includes(t.operator)?":"+t.operator:"",n=Vn.includes(t.operator)?t.operator:"";return`${t.code}${e}=${n}${encodeURIComponent(t.value)}`}(t)))),t.sortRules&&t.sortRules.length>0&&e.push(function(t){if(!t||0===t.length)return"";return"_sort="+t.map((t=>t.descending?"-"+t.code:t.code)).join(",")}(t.sortRules)),void 0!==t.offset&&e.push("_offset="+t.offset),void 0!==t.count&&e.push("_count="+t.count),void 0!==t.total&&e.push("_total="+t.total),0===e.length?"":(e.sort(),"?"+e.join("&"))}var Jn;function Zn(t,e,n){var i,r,s,o;if("_lastUpdated"===n.code)return{columnName:"lastUpdated",type:Jn.DATETIME};const a=n.code.split("-").reduce(((t,e,n)=>t+(n?I(e):e)),"");const l=null===(i=ti(e,n.expression))||void 0===i?void 0:i.split(".");if(!l)return{columnName:a,type:Jn.TEXT};let c,u,h=e,f=!1;for(let e=1;e<l.length;e++){const n=l[e];if(c=null===(s=null===(r=t.types[h])||void 0===r?void 0:r.properties)||void 0===s?void 0:s[n],!c)return{columnName:a,type:Jn.TEXT,array:f};if("*"===c.max&&(f=!0),u=null===(o=c.type)||void 0===o?void 0:o[0].code,!u)return{columnName:a,type:Jn.TEXT,array:f};e<l.length-1&&("Element"===u||"BackboneElement"===u?h+=I(n):h=u)}const d=function(t,e){let n=Jn.TEXT;switch(t.type){case"date":n=e===nt.dateTime||e===nt.instant?Jn.DATETIME:Jn.DATE;break;case"number":n=Jn.NUMBER;break;case"quantity":n=Jn.QUANTITY;break;case"reference":n=Jn.REFERENCE;break;case"token":"boolean"===e&&(n=Jn.BOOLEAN)}return n}(n,u);return{columnName:a,type:d,elementDefinition:c,array:f}}function ti(t,e){const n=e.split(" | ");for(const e of n){const n=ei(e);if(n.startsWith(t+"."))return n}}function ei(t){let e=t.trim();return e.startsWith("(")&&e.endsWith(")")&&(e=e.substring(1,e.length-1)),e.includes(" as ")&&(e=e.substring(0,e.indexOf(" as "))),e.includes(".where(")&&(e=e.substring(0,e.indexOf(".where("))),e}!function(t){t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.QUANTITY="QUANTITY",t.TEXT="TEXT",t.REFERENCE="REFERENCE",t.DATE="DATE",t.DATETIME="DATETIME",t.PERIOD="PERIOD"}(Jn||(Jn={}));export{Un as COMPONENT_SEPARATOR,Xn as DEFAULT_SEARCH_COUNT,On as FIELD_SEPARATOR,Cn as Hl7Field,Mn as Hl7Message,Rn as Hl7Segment,a as LRUCache,Yt as MedplumClient,qn as OperationOutcomeError,zn as Operator,nt as PropertyType,Wt as ReadablePromise,Pn as SEGMENT_SEPARATOR,Jn as SearchParameterType,Wn as accessDenied,Ln as allOk,_ as arrayBufferToBase64,D as arrayBufferToHex,Hn as assertOk,Nn as badRequest,qt as buildTypeName,b as calculateAge,T as calculateAgeString,I as capitalize,f as createReference,Qt as createSchema,$t as createTypeSchema,Dn as created,U as deepEquals,xn as evalFhirPath,B as findObservationInterval,l as formatAddress,h as formatFamilyName,u as formatGivenName,c as formatHumanName,Kn as formatSearchQuery,W as getCodeBySystem,w as getDateProperty,g as getDisplayString,ti as getExpressionForResourceType,k as getExtensionValue,A as getIdentifier,m as getImageSrc,Xt as getPropertyDisplayName,E as getQuestionnaireAnswers,d as getReferenceString,Zn as getSearchParameterDetails,Fn as getStatus,jn as gone,Ht as indexSearchParameter,Ft as indexStructureDefinition,$n as isGone,j as isLowerCase,Qn as isNotFound,R as isObject,Bn as isOk,p as isProfileResource,C as isStringArray,M as isUUID,Q as matchesRange,In as notFound,_n as notModified,kn as parseFhirPath,Gn as parseSearchDefinition,$ as preciseEquals,H as preciseGreaterThan,X as preciseGreaterThanOrEquals,F as preciseLessThan,q as preciseLessThanOrEquals,v as resolveId,N as setCodeBySystem,x as stringify,sn as tokenize};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|