@medplum/core 0.9.17 → 0.9.18

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.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.core={}))}(this,(function(e){"use strict";function t(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{c(n.next(e))}catch(e){r(e)}}function s(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}var o,r,a,s;class c{constructor(e=10){o.add(this),r.set(this,void 0),a.set(this,void 0),n(this,r,e,"f"),n(this,a,new Map,"f")}clear(){i(this,a,"f").clear()}get(e){const t=i(this,a,"f").get(e);return t&&(i(this,a,"f").delete(e),i(this,a,"f").set(e,t)),t}set(e,t){i(this,a,"f").has(e)?i(this,a,"f").delete(e):i(this,a,"f").size>=i(this,r,"f")&&i(this,a,"f").delete(i(this,o,"m",s).call(this)),i(this,a,"f").set(e,t)}delete(e){i(this,a,"f").delete(e)}keys(){return i(this,a,"f").keys()}}function d(e,t){const i=[];return e.prefix&&((null==t?void 0:t.all)||(null==t?void 0:t.prefix))&&i.push(...e.prefix),e.given&&i.push(...e.given),e.family&&i.push(e.family),e.suffix&&((null==t?void 0:t.all)||(null==t?void 0:t.suffix))&&i.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(" ").trim()}function l(e){const t=u(e),i=p(e);return i===t?{reference:t}:{reference:t,display:i}}function u(e){return e.resourceType+"/"+e.id}function m(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function p(e){var t,i;if(m(e)){const t=function(e){const t=e.name;if(t&&t.length>0)return d(t[0]);return}(e);if(t)return t}if("Device"===e.resourceType){const t=function(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name;return}(e);if(t)return t}return"Observation"===e.resourceType&&"code"in e&&(null===(t=e.code)||void 0===t?void 0:t.text)?null===(i=e.code)||void 0===i?void 0:i.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:u(e)}function h(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function f(e,t){const i=new Date(e);i.setUTCHours(0,0,0,0);const n=t?new Date(t):new Date;n.setUTCHours(0,0,0,0);const o=i.getUTCFullYear(),r=i.getUTCMonth(),a=i.getUTCDate(),s=n.getUTCFullYear(),c=n.getUTCMonth(),d=n.getUTCDate();let l=s-o;(c<r||c===r&&d<a)&&l--;let u=12*s+c-(12*o+r);d<a&&u--;return{years:l,months:u,days:Math.floor((n.getTime()-i.getTime())/864e5)}}function y(e,t){if(e)for(const i of e)i.linkId&&i.answer&&i.answer.length>0&&(t[i.linkId]=i.answer[0]),y(i.item,t)}function g(e,t){return JSON.stringify(e,x,t?2:void 0)}function x(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&v(t)?void 0:t}function v(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function E(e,t,i){return e===t||(!(!v(e)||!v(t))||!v(e)&&!v(t)&&(Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!E(e[i],t[i]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(T(e)&&T(t)?function(e,t,i){const n=new Set;Object.keys(e).forEach((e=>n.add(e))),Object.keys(t).forEach((e=>n.add(e))),"meta"===i&&(n.delete("versionId"),n.delete("lastUpdated"),n.delete("author"));for(const i of n){if(!E(e[i],t[i],i))return!1}return!0}(e,t,i):(T(e)||T(t),!1))))}function T(e){return null!==e&&"object"==typeof e}function w(e){return e.every((e=>"string"==typeof e))}r=new WeakMap,a=new WeakMap,o=new WeakSet,s=function(){return i(this,a,"f").keys().next().value};const S=[];for(let e=0;e<256;e++)S.push(e.toString(16).padStart(2,"0"));function b(e){const t=new Uint8Array(e),i=new Array(t.length);for(let e=0;e<t.length;e++)i[e]=S[t[e]];return i.join("")}function P(e){const t=new Uint8Array(e),i=[];for(let e=0;e<t.length;e++)i[e]=String.fromCharCode(t[e]);return window.btoa(i.join(""))}function D(e){return e.charAt(0).toUpperCase()+e.substring(1)}function C(e,t,i){var n,o;return(void 0===(null===(n=t.low)||void 0===n?void 0:n.value)||I(e,t.low.value,i))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||k(e,t.high.value,i))}function A(e,t,i){return i?Math.abs(e-t)<Math.pow(10,-i):e===t}function R(e,t,i){return i?e<t&&Math.abs(e-t)>Math.pow(10,-i):e<t}function O(e,t,i){return i?e>t&&Math.abs(e-t)>Math.pow(10,-i):e>t}function k(e,t,i){return R(e,t,i)||A(e,t,i)}function I(e,t,i){return O(e,t,i)||A(e,t,i)}function M(){const e=new Uint32Array(28);return crypto.getRandomValues(e),b(e.buffer)}var U,L,N,_,j,Q,B,W;function q(e){const t=function(e){if("undefined"!=typeof window)return window.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}(e.replace(/-/g,"+").replace(/_/g,"/")),i=Array.from(t).reduce(((e,t)=>`${e}%${("00"+t.charCodeAt(0).toString(16)).slice(-2)}`),""),n=decodeURIComponent(i);return JSON.parse(n)}U=new WeakMap;class F{constructor(e){this[Q]="ReadablePromise",L.set(this,void 0),N.set(this,"pending"),_.set(this,void 0),j.set(this,void 0),n(this,L,e.then((e=>(n(this,N,"success","f"),n(this,_,e,"f"),e)),(e=>{throw n(this,N,"error","f"),n(this,j,e,"f"),e})),"f")}isPending(){return"pending"===i(this,N,"f")}isOk(){return"success"===i(this,N,"f")}read(){switch(i(this,N,"f")){case"pending":throw i(this,L,"f");case"error":throw i(this,j,"f");default:return i(this,_,"f")}}then(e,t){return i(this,L,"f").then(e,t)}catch(e){return i(this,L,"f").catch(e)}finally(e){return i(this,L,"f").finally(e)}}L=new WeakMap,N=new WeakMap,_=new WeakMap,j=new WeakMap,Q=Symbol.toStringTag;class H{constructor(){B.set(this,void 0),n(this,B,"undefined"!=typeof localStorage?localStorage:new $,"f")}clear(){i(this,B,"f").clear()}getString(e){return i(this,B,"f").getItem(e)||void 0}setString(e,t){t?i(this,B,"f").setItem(e,t):i(this,B,"f").removeItem(e)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?g(t):void 0)}}B=new WeakMap;class ${constructor(){W.set(this,void 0),n(this,W,new Map,"f")}get length(){return i(this,W,"f").size}clear(){i(this,W,"f").clear()}getItem(e){var t;return null!==(t=i(this,W,"f").get(e))&&void 0!==t?t:null}setItem(e,t){t?i(this,W,"f").set(e,t):i(this,W,"f").delete(e)}removeItem(e){i(this,W,"f").delete(e)}key(e){return Array.from(i(this,W,"f").keys())[e]}}W=new WeakMap;var z,G={types:{Element:{display:"Element",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]}}},BackboneElement:{display:"BackboneElement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]}}},Address:{display:"Address",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},line:{min:0,max:"*",type:[{code:"string"}]},city:{min:0,max:"1",type:[{code:"string"}]},district:{min:0,max:"1",type:[{code:"string"}]},state:{min:0,max:"1",type:[{code:"string"}]},postalCode:{min:0,max:"1",type:[{code:"string"}]},country:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Age:{display:"Age",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Annotation:{display:"Annotation",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"author[x]":{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{min:0,max:"1",type:[{code:"dateTime"}]},text:{min:1,max:"1",type:[{code:"markdown"}]}}},Attachment:{display:"Attachment",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},contentType:{min:0,max:"1",type:[{code:"code"}]},language:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]},url:{min:0,max:"1",type:[{code:"url"}]},size:{min:0,max:"1",type:[{code:"unsignedInt"}]},hash:{min:0,max:"1",type:[{code:"base64Binary"}]},title:{min:0,max:"1",type:[{code:"string"}]},creation:{min:0,max:"1",type:[{code:"dateTime"}]}}},CodeableConcept:{display:"CodeableConcept",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},coding:{min:0,max:"*",type:[{code:"Coding"}]},text:{min:0,max:"1",type:[{code:"string"}]}}},Coding:{display:"Coding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"uri"}]},version:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"1",type:[{code:"code"}]},display:{min:0,max:"1",type:[{code:"string"}]},userSelected:{min:0,max:"1",type:[{code:"boolean"}]}}},ContactDetail:{display:"ContactDetail",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"string"}]},telecom:{min:0,max:"*",type:[{code:"ContactPoint"}]}}},ContactPoint:{display:"ContactPoint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"code"}]},value:{min:0,max:"1",type:[{code:"string"}]},use:{min:0,max:"1",type:[{code:"code"}]},rank:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Contributor:{display:"Contributor",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:1,max:"1",type:[{code:"string"}]},contact:{min:0,max:"*",type:[{code:"ContactDetail"}]}}},Count:{display:"Count",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},DataRequirement:{display:"DataRequirement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{min:0,max:"1",type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{min:0,max:"*",type:[{code:"string"}]},codeFilter:{min:0,max:"*",type:[{code:"Element"}]},dateFilter:{min:0,max:"*",type:[{code:"Element"}]},limit:{min:0,max:"1",type:[{code:"positiveInt"}]},sort:{min:0,max:"*",type:[{code:"Element"}]}}},DataRequirementCodeFilter:{display:"DataRequirementCodeFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{min:0,max:"*",type:[{code:"Coding"}]}},parentType:"DataRequirement"},DataRequirementDateFilter:{display:"DataRequirementDateFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}},parentType:"DataRequirement"},DataRequirementSort:{display:"DataRequirementSort",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},direction:{min:1,max:"1",type:[{code:"code"}]}},parentType:"DataRequirement"},Distance:{display:"Distance",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Dosage:{display:"Dosage",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},sequence:{min:0,max:"1",type:[{code:"integer"}]},text:{min:0,max:"1",type:[{code:"string"}]},additionalInstruction:{min:0,max:"*",type:[{code:"CodeableConcept"}]},patientInstruction:{min:0,max:"1",type:[{code:"string"}]},timing:{min:0,max:"1",type:[{code:"Timing"}]},"asNeeded[x]":{min:0,max:"1",type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{min:0,max:"1",type:[{code:"CodeableConcept"}]},route:{min:0,max:"1",type:[{code:"CodeableConcept"}]},method:{min:0,max:"1",type:[{code:"CodeableConcept"}]},doseAndRate:{min:0,max:"*",type:[{code:"Element"}]},maxDosePerPeriod:{min:0,max:"1",type:[{code:"Ratio"}]},maxDosePerAdministration:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},DosageDoseAndRate:{display:"DosageDoseAndRate",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},"dose[x]":{min:0,max:"1",type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{min:0,max:"1",type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}},parentType:"Dosage"},Duration:{display:"Duration",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},ElementDefinition:{display:"ElementDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},representation:{min:0,max:"*",type:[{code:"code"}]},sliceName:{min:0,max:"1",type:[{code:"string"}]},sliceIsConstraining:{min:0,max:"1",type:[{code:"boolean"}]},label:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"*",type:[{code:"Coding"}]},slicing:{min:0,max:"1",type:[{code:"Element"}]},short:{min:0,max:"1",type:[{code:"string"}]},definition:{min:0,max:"1",type:[{code:"markdown"}]},comment:{min:0,max:"1",type:[{code:"markdown"}]},requirements:{min:0,max:"1",type:[{code:"markdown"}]},alias:{min:0,max:"*",type:[{code:"string"}]},min:{min:0,max:"1",type:[{code:"unsignedInt"}]},max:{min:0,max:"1",type:[{code:"string"}]},base:{min:0,max:"1",type:[{code:"Element"}]},contentReference:{min:0,max:"1",type:[{code:"uri"}]},type:{min:0,max:"*",type:[{code:"Element"}]},"defaultValue[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{min:0,max:"1",type:[{code:"markdown"}]},orderMeaning:{min:0,max:"1",type:[{code:"string"}]},"fixed[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{min:0,max:"*",type:[{code:"Element"}]},"minValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{min:0,max:"1",type:[{code:"integer"}]},condition:{min:0,max:"*",type:[{code:"id"}]},constraint:{min:0,max:"*",type:[{code:"Element"}]},mustSupport:{min:0,max:"1",type:[{code:"boolean"}]},isModifier:{min:0,max:"1",type:[{code:"boolean"}]},isModifierReason:{min:0,max:"1",type:[{code:"string"}]},isSummary:{min:0,max:"1",type:[{code:"boolean"}]},binding:{min:0,max:"1",type:[{code:"Element"}]},mapping:{min:0,max:"*",type:[{code:"Element"}]}}},ElementDefinitionSlicing:{display:"ElementDefinitionSlicing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},discriminator:{min:0,max:"*",type:[{code:"Element"}]},description:{min:0,max:"1",type:[{code:"string"}]},ordered:{min:0,max:"1",type:[{code:"boolean"}]},rules:{min:1,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionSlicingDiscriminator:{display:"ElementDefinitionSlicingDiscriminator",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},path:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinitionSlicing"},ElementDefinitionBase:{display:"ElementDefinitionBase",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},min:{min:1,max:"1",type:[{code:"unsignedInt"}]},max:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},ElementDefinitionType:{display:"ElementDefinitionType",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{min:0,max:"*",type:[{code:"code"}]},versioning:{min:0,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionExample:{display:"ElementDefinitionExample",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},label:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:1,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}},parentType:"ElementDefinition"},ElementDefinitionConstraint:{display:"ElementDefinitionConstraint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},key:{min:1,max:"1",type:[{code:"id"}]},requirements:{min:0,max:"1",type:[{code:"string"}]},severity:{min:1,max:"1",type:[{code:"code"}]},human:{min:1,max:"1",type:[{code:"string"}]},expression:{min:0,max:"1",type:[{code:"string"}]},xpath:{min:0,max:"1",type:[{code:"string"}]},source:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}},parentType:"ElementDefinition"},ElementDefinitionBinding:{display:"ElementDefinitionBinding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},strength:{min:1,max:"1",type:[{code:"code"}]},description:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}},parentType:"ElementDefinition"},ElementDefinitionMapping:{display:"ElementDefinitionMapping",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},identity:{min:1,max:"1",type:[{code:"id"}]},language:{min:0,max:"1",type:[{code:"code"}]},map:{min:1,max:"1",type:[{code:"string"}]},comment:{min:0,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},Expression:{display:"Expression",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},description:{min:0,max:"1",type:[{code:"string"}]},name:{min:0,max:"1",type:[{code:"id"}]},language:{min:1,max:"1",type:[{code:"code"}]},expression:{min:0,max:"1",type:[{code:"string"}]},reference:{min:0,max:"1",type:[{code:"uri"}]}}},Extension:{display:"Extension",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},url:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},HumanName:{display:"HumanName",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},family:{min:0,max:"1",type:[{code:"string"}]},given:{min:0,max:"*",type:[{code:"string"}]},prefix:{min:0,max:"*",type:[{code:"string"}]},suffix:{min:0,max:"*",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Identifier:{display:"Identifier",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},system:{min:0,max:"1",type:[{code:"uri"}]},value:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]},assigner:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},MarketingStatus:{display:"MarketingStatus",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},country:{min:1,max:"1",type:[{code:"CodeableConcept"}]},jurisdiction:{min:0,max:"1",type:[{code:"CodeableConcept"}]},status:{min:1,max:"1",type:[{code:"CodeableConcept"}]},dateRange:{min:1,max:"1",type:[{code:"Period"}]},restoreDate:{min:0,max:"1",type:[{code:"dateTime"}]}}},Meta:{display:"Meta",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},versionId:{min:0,max:"1",type:[{code:"id"}]},lastUpdated:{min:0,max:"1",type:[{code:"instant"}]},source:{min:0,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{min:0,max:"*",type:[{code:"Coding"}]},tag:{min:0,max:"*",type:[{code:"Coding"}]},project:{min:0,max:"1",type:[{code:"uri"}]},author:{min:0,max:"1",type:[{code:"Reference"}]},account:{min:0,max:"1",type:[{code:"Reference"}]}}},Money:{display:"Money",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},currency:{min:0,max:"1",type:[{code:"code"}]}}},Narrative:{display:"Narrative",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},status:{min:1,max:"1",type:[{code:"code"}]},div:{min:1,max:"1",type:[{code:"xhtml"}]}}},ParameterDefinition:{display:"ParameterDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"code"}]},use:{min:1,max:"1",type:[{code:"code"}]},min:{min:0,max:"1",type:[{code:"integer"}]},max:{min:0,max:"1",type:[{code:"string"}]},documentation:{min:0,max:"1",type:[{code:"string"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},Period:{display:"Period",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},start:{min:0,max:"1",type:[{code:"dateTime"}]},end:{min:0,max:"1",type:[{code:"dateTime"}]}}},Population:{display:"Population",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"age[x]":{min:0,max:"1",type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{min:0,max:"1",type:[{code:"CodeableConcept"}]},race:{min:0,max:"1",type:[{code:"CodeableConcept"}]},physiologicalCondition:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProdCharacteristic:{display:"ProdCharacteristic",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},height:{min:0,max:"1",type:[{code:"Quantity"}]},width:{min:0,max:"1",type:[{code:"Quantity"}]},depth:{min:0,max:"1",type:[{code:"Quantity"}]},weight:{min:0,max:"1",type:[{code:"Quantity"}]},nominalVolume:{min:0,max:"1",type:[{code:"Quantity"}]},externalDiameter:{min:0,max:"1",type:[{code:"Quantity"}]},shape:{min:0,max:"1",type:[{code:"string"}]},color:{min:0,max:"*",type:[{code:"string"}]},imprint:{min:0,max:"*",type:[{code:"string"}]},image:{min:0,max:"*",type:[{code:"Attachment"}]},scoring:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProductShelfLife:{display:"ProductShelfLife",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},type:{min:1,max:"1",type:[{code:"CodeableConcept"}]},period:{min:1,max:"1",type:[{code:"Quantity"}]},specialPrecautionsForStorage:{min:0,max:"*",type:[{code:"CodeableConcept"}]}}},Quantity:{display:"Quantity",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"0",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Range:{display:"Range",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},low:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Ratio:{display:"Ratio",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},numerator:{min:0,max:"1",type:[{code:"Quantity"}]},denominator:{min:0,max:"1",type:[{code:"Quantity"}]}}},Reference:{display:"Reference",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},reference:{min:0,max:"1",type:[{code:"string"}]},type:{min:0,max:"1",type:[{code:"uri"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},display:{min:0,max:"1",type:[{code:"string"}]}}},RelatedArtifact:{display:"RelatedArtifact",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},label:{min:0,max:"1",type:[{code:"string"}]},display:{min:0,max:"1",type:[{code:"string"}]},citation:{min:0,max:"1",type:[{code:"markdown"}]},url:{min:0,max:"1",type:[{code:"url"}]},document:{min:0,max:"1",type:[{code:"Attachment"}]},resource:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},SampledData:{display:"SampledData",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},origin:{min:1,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,max:"1",type:[{code:"decimal"}]},factor:{min:0,max:"1",type:[{code:"decimal"}]},lowerLimit:{min:0,max:"1",type:[{code:"decimal"}]},upperLimit:{min:0,max:"1",type:[{code:"decimal"}]},dimensions:{min:1,max:"1",type:[{code:"positiveInt"}]},data:{min:0,max:"1",type:[{code:"string"}]}}},Signature:{display:"Signature",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"*",type:[{code:"Coding"}]},when:{min:1,max:"1",type:[{code:"instant"}]},who:{min:1,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{min:0,max:"1",type:[{code:"code"}]},sigFormat:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]}}},SubstanceAmount:{display:"SubstanceAmount",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"amount[x]":{min:0,max:"1",type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{min:0,max:"1",type:[{code:"CodeableConcept"}]},amountText:{min:0,max:"1",type:[{code:"string"}]},referenceRange:{min:0,max:"1",type:[{code:"Element"}]}}},SubstanceAmountReferenceRange:{display:"SubstanceAmountReferenceRange",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},lowLimit:{min:0,max:"1",type:[{code:"Quantity"}]},highLimit:{min:0,max:"1",type:[{code:"Quantity"}]}},parentType:"SubstanceAmount"},Timing:{display:"Timing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},event:{min:0,max:"*",type:[{code:"dateTime"}]},repeat:{min:0,max:"1",type:[{code:"Element"}]},code:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},TimingRepeat:{display:"TimingRepeat",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"bounds[x]":{min:0,max:"1",type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{min:0,max:"1",type:[{code:"positiveInt"}]},countMax:{min:0,max:"1",type:[{code:"positiveInt"}]},duration:{min:0,max:"1",type:[{code:"decimal"}]},durationMax:{min:0,max:"1",type:[{code:"decimal"}]},durationUnit:{min:0,max:"1",type:[{code:"code"}]},frequency:{min:0,max:"1",type:[{code:"positiveInt"}]},frequencyMax:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"decimal"}]},periodMax:{min:0,max:"1",type:[{code:"decimal"}]},periodUnit:{min:0,max:"1",type:[{code:"code"}]},dayOfWeek:{min:0,max:"*",type:[{code:"code"}]},timeOfDay:{min:0,max:"*",type:[{code:"time"}]},when:{min:0,max:"*",type:[{code:"code"}]},offset:{min:0,max:"1",type:[{code:"unsignedInt"}]}},parentType:"Timing"},TriggerDefinition:{display:"TriggerDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:0,max:"1",type:[{code:"string"}]},"timing[x]":{min:0,max:"1",type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{min:0,max:"*",type:[{code:"DataRequirement"}]},condition:{min:0,max:"1",type:[{code:"Expression"}]}}},UsageContext:{display:"UsageContext",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"Coding"}]},"value[x]":{min:1,max:"1",type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}}}};function V(e,t){return{display:e,description:t,properties:{},searchParams:{_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"}}}}function X(e,t){var i;const n=t.name;if(!n)return;n in e.types||(e.types[n]=V(n,t.description));const o=null===(i=t.snapshot)||void 0===i?void 0:i.element;if(o){const t=o.filter((e=>e.path!==n&&e.path));t.forEach((t=>function(e,t){var i,n;const o=t.path,r=null===(n=null===(i=t.type)||void 0===i?void 0:i[0])||void 0===n?void 0:n.code;if("Element"!==r&&"BackboneElement"!==r)return;const a=o.split("."),s=J(a);s in e.types||(e.types[s]=V(s,t.definition),e.types[s].parentType=J(a.slice(0,a.length-1)))}(e,t))),t.forEach((t=>function(e,t){const i=t.path.split(".");if(1===i.length)return;const n=J(i.slice(0,i.length-1)),o=e.types[n];if(!o)return;const r=i[i.length-1];o.properties[r]=t}(e,t)))}}function Y(e,t){if(t.base)for(const i of t.base){const n=e.types[i];n&&(n.searchParams||(n.searchParams={}),n.searchParams[t.code]=t)}}function J(e){return e.map(D).join("")}e.PropertyType=void 0,(z=e.PropertyType||(e.PropertyType={})).Address="Address",z.Age="Age",z.Annotation="Annotation",z.Attachment="Attachment",z.BackboneElement="BackboneElement",z.CodeableConcept="CodeableConcept",z.Coding="Coding",z.ContactDetail="ContactDetail",z.ContactPoint="ContactPoint",z.Contributor="Contributor",z.Count="Count",z.DataRequirement="DataRequirement",z.Distance="Distance",z.Dosage="Dosage",z.Duration="Duration",z.Expression="Expression",z.Extension="Extension",z.HumanName="HumanName",z.Identifier="Identifier",z.MarketingStatus="MarketingStatus",z.Meta="Meta",z.Money="Money",z.Narrative="Narrative",z.ParameterDefinition="ParameterDefinition",z.Period="Period",z.Population="Population",z.ProdCharacteristic="ProdCharacteristic",z.ProductShelfLife="ProductShelfLife",z.Quantity="Quantity",z.Range="Range",z.Ratio="Ratio",z.Reference="Reference",z.RelatedArtifact="RelatedArtifact",z.SampledData="SampledData",z.Signature="Signature",z.SubstanceAmount="SubstanceAmount",z.SystemString="http://hl7.org/fhirpath/System.String",z.Timing="Timing",z.TriggerDefinition="TriggerDefinition",z.UsageContext="UsageContext",z.base64Binary="base64Binary",z.boolean="boolean",z.canonical="canonical",z.code="code",z.date="date",z.dateTime="dateTime",z.decimal="decimal",z.id="id",z.instant="instant",z.integer="integer",z.markdown="markdown",z.oid="oid",z.positiveInt="positiveInt",z.string="string",z.time="time",z.unsignedInt="unsignedInt",z.uri="uri",z.url="url",z.uuid="uuid";const K=G;var Z,ee,te,ie,ne,oe,re,ae,se,ce,de,le,ue,me,pe,he,fe,ye,ge,xe,ve,Ee,Te,we,Se,be,Pe,De,Ce,Ae,Re,Oe,ke;const Ie="launch/patient openid fhirUser offline_access user/*.*";function Me(){return window.location.protocol+"//"+window.location.host+"/"}function Ue(t){return[{type:e.PropertyType.boolean,value:t}]}function Le(t){return null==t?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:e.PropertyType.integer,value:t}:"number"==typeof t?{type:e.PropertyType.decimal,value:t}:"boolean"==typeof t?{type:e.PropertyType.boolean,value:t}:"string"==typeof t?{type:e.PropertyType.string,value:t}:Ge(t)?{type:e.PropertyType.Quantity,value:t}:"object"==typeof t&&"resourceType"in t?{type:t.resourceType,value:t}:{type:e.PropertyType.BackboneElement,value:t}}function Ne(e){return 0!==e.length&&!!e[0].value}function _e(e,t){if(!(null==e?void 0:e.value))return;const i=K.types[e.type];return i?function(e,t,i){var n;const o=null!==(n=i.properties[t])&&void 0!==n?n:i.properties[t+"[x]"];if(!o)return;const r=o.type;if(!r||0===r.length)return;let a,s,c="undefined";if(1===r.length)a=t,s=e.value[t],c=r[0].code;else for(const i of r){const n=t.replace("[x]","")+D(i.code);if(n in e.value){a=n,s=e.value[n],c=i.code;break}}if(void 0===s)return;"BackboneElement"===c&&(c=J([e.type,a]));return Array.isArray(s)?s.map((e=>({value:e,type:c}))):{value:s,type:c}}(e,t,i):function(e,t){const i=e.value;if(!i||"object"!=typeof i)return;let n;if(t in i)n=i[t];else{const e=Object.keys(i).find((e=>e.startsWith(t)));e&&(n=i[e])}if(void 0===n)return;return Array.isArray(n)?n.map(Le):Le(n)}(e,t)}function je(e){const t=[];for(const i of e){let e=!1;for(const n of t)if(Ne(We(i,n))){e=!0;break}e||t.push(i)}return t}function Qe(e){return Ue(!Ne(e))}function Be(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?Ue(!1):Ue(e.every(((e,i)=>Ne(We(e,t[i])))))}function We(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Ue(Math.abs(i-n)<1e-8):Ge(i)&&Ge(n)?Ue(Ve(i,n)):Ue("object"==typeof i&&"object"==typeof n?Xe(e,t):i===n)}function qe(e,t){return 0===e.length&&0===t.length?Ue(!0):e.length!==t.length?Ue(!1):(e.sort(He),t.sort(He),Ue(e.every(((e,i)=>Ne(Fe(e,t[i]))))))}function Fe(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Ue(Math.abs(i-n)<.01):Ge(i)&&Ge(n)?Ue(Ve(i,n)):Ue("object"==typeof i&&"object"==typeof n?Xe(i,n):"string"==typeof i&&"string"==typeof n?i.toLowerCase()===n.toLowerCase():i===n)}function He(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?i-n:"string"==typeof i&&"string"==typeof n?i.localeCompare(n):0}function $e(e,t){const{value:i}=e;if(null==i)return!1;switch(t){case"Boolean":return"boolean"==typeof i;case"Decimal":case"Integer":return"number"==typeof i;case"Date":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof i&&!!i.match(/^T\d/);case"Period":return ze(i);case"Quantity":return Ge(i);default:return"object"==typeof i&&(null==i?void 0:i.resourceType)===t}}function ze(e){return!(!e||"object"!=typeof e||!("start"in e))}function Ge(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function Ve(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function Xe(e,t){const i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(const n of i){const i=e[n],o=t[n];if(Ye(i)&&Ye(o)){if(!Xe(i,o))return!1}else if(i!==o)return!1}return!0}function Ye(e){return null!==e&&"object"==typeof e}var Je,Ke;ee=new WeakMap,te=new WeakMap,ie=new WeakMap,ne=new WeakMap,oe=new WeakMap,re=new WeakMap,ae=new WeakMap,se=new WeakMap,ce=new WeakMap,de=new WeakMap,le=new WeakMap,ue=new WeakMap,me=new WeakMap,pe=new WeakMap,he=new WeakMap,fe=new WeakMap,ye=new WeakMap,Z=new WeakSet,ge=function(e){const t=this.getLogins().filter((t=>{var i,n;return(null===(i=t.profile)||void 0===i?void 0:i.reference)!==(null===(n=e.profile)||void 0===n?void 0:n.reference)}));t.push(e),i(this,ie,"f").setObject("logins",t)},xe=function(){return t(this,void 0,void 0,(function*(){return n(this,he,new Promise(((e,t)=>{this.get("auth/me").then((t=>{n(this,he,void 0,"f"),n(this,fe,t.profile,"f"),n(this,ye,t.config,"f"),this.dispatchEvent({type:"change"}),e(i(this,fe,"f"))})).catch(t)})),"f"),i(this,he,"f")}))},ve=function(e,t){if(i(this,oe,"f")<=0||"no-cache"===(null==t?void 0:t.cache)||"reload"===(null==t?void 0:t.cache))return;const n=i(this,ne,"f").get(e);return!n||n.requestTime+i(this,oe,"f")<Date.now()?void 0:n},Ee=function(e,t){i(this,oe,"f")>0&&i(this,ne,"f").set(e,{requestTime:Date.now(),value:t})},Te=function(e,n,o={}){return t(this,void 0,void 0,(function*(){i(this,pe,"f")&&(yield i(this,pe,"f")),n.startsWith("http")||(n=i(this,re,"f")+n),o.method=e,i(this,Z,"m",we).call(this,o);const t=yield i(this,ee,"f").call(this,n,o);if(401===t.status)return i(this,Z,"m",Pe).call(this,e,n,o);if(204===t.status||304===t.status)return;const r=yield t.json();if(t.status>=400)throw r;return r}))},we=function(e){e.headers||(e.headers={});const t=e.headers;t["Content-Type"]||(t["Content-Type"]="application/fhir+json"),i(this,ue,"f")&&(t.Authorization="Bearer "+i(this,ue,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},Se=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},be=function(e,t){"string"==typeof t||"undefined"!=typeof Blob&&t instanceof Blob||"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Uint8Array&&t instanceof Uint8Array?e.body=t:t&&(e.body=JSON.stringify(t))},Pe=function(e,n,o){return t(this,void 0,void 0,(function*(){return i(this,Z,"m",Ae).call(this).then((()=>i(this,Z,"m",Te).call(this,e,n,o))).catch((e=>(this.clear(),i(this,le,"f")&&i(this,le,"f").call(this),Promise.reject(e))))}))},De=function(){return t(this,void 0,void 0,(function*(){const e=M();i(this,ie,"f").setString("pkceState",e);const n=M();i(this,ie,"f").setString("codeVerifier",n);const o=P(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");i(this,ie,"f").setString("codeChallenge",o)}))},Ce=function(){i(this,Z,"m",De).call(this);const e=new URL(i(this,se,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",i(this,ie,"f").getString("pkceState")),e.searchParams.set("client_id",i(this,ae,"f")),e.searchParams.set("redirect_uri",Me()),e.searchParams.set("scope",Ie),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",i(this,ie,"f").getString("codeChallenge")),window.location.assign(e.toString())},Ae=function(){return t(this,void 0,void 0,(function*(){if(i(this,pe,"f"))return i(this,pe,"f");if(!i(this,me,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",i(this,ae,"f")),e.set("refresh_token",i(this,me,"f")),n(this,pe,i(this,Z,"m",Re).call(this,e),"f"),yield i(this,pe,"f")}))},Re=function(e){return t(this,void 0,void 0,(function*(){return i(this,ee,"f").call(this,i(this,ce,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>i(this,Z,"m",Oe).call(this,e))).then((()=>this.getProfile()))}))},Oe=function(e){return t(this,void 0,void 0,(function*(){const t=e.access_token,n=function(e){const[t,i,n]=e.split(".");return q(i)}(t);if(Date.now()>=1e3*n.exp)throw this.clear(),new Error("Token expired");if(i(this,ae,"f")&&n.client_id!==i(this,ae,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}))},ke=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};class Ze{constructor(e,t){this.original=e,this.child=t}eval(e){try{return e.length>0?e.map((e=>this.child.eval([e]))).flat():this.child.eval([])}catch(e){throw new Error(`FhirPathError on "${this.original}": ${e}`)}}}class et{constructor(e){this.value=e}eval(){return[this.value]}}class tt{constructor(e){this.name=e,Je.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>i(this,Je,"m",Ke).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}Je=new WeakSet,Ke=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:_e(e,this.name)};class it{eval(){return[]}}class nt{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class ot{constructor(e,t){this.left=e,this.right=t}eval(e){return this.left.eval(e)}}class rt{constructor(e,t,i){this.left=e,this.right=t,this.impl=i}eval(t){const i=this.left.eval(t);if(1!==i.length)return[];const n=this.right.eval(t);if(1!==n.length)return[];const o=i[0].value,r=n[0].value,a=Ge(o)?o.value:o,s=Ge(r)?r.value:r,c=this.impl(a,s);return"boolean"==typeof c?Ue(c):Ge(o)?[{type:e.PropertyType.Quantity,value:Object.assign(Object.assign({},o),{value:c})}]:[Le(c)]}}class at{constructor(e,t){this.left=e,this.right=t}eval(t){const i=[...this.left.eval(t),...this.right.eval(t)];return i.length>0&&i.every((e=>"string"==typeof e.value))?[{type:e.PropertyType.string,value:i.map((e=>e.value)).join("")}]:i}}class st{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);return Ue(t.some((e=>e.value===i[0].value)))}}class ct{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);return Ue(this.right.eval(e).some((e=>e.value===t[0].value)))}}class dt{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class lt{constructor(e,t){this.left=e,this.right=t}eval(e){return je([...this.left.eval(e),...this.right.eval(e)])}}class ut{constructor(e,t){this.left=e,this.right=t}eval(e){return Be(this.left.eval(e),this.right.eval(e))}}class mt{constructor(e,t){this.left=e,this.right=t}eval(e){return Qe(Be(this.left.eval(e),this.right.eval(e)))}}class pt{constructor(e,t){this.left=e,this.right=t}eval(e){return qe(this.left.eval(e),this.right.eval(e))}}class ht{constructor(e,t){this.left=e,this.right=t}eval(e){return Qe(qe(this.left.eval(e),this.right.eval(e)))}}class ft{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const i=this.right.name;return Ue($e(t[0],i))}}class yt{constructor(e,t){this.left=e,this.right=t}eval(e){var t,i,n,o;const r=this.left.eval(e),a=this.right.eval(e);return!0===(null===(t=r[0])||void 0===t?void 0:t.value)&&!0===(null===(i=a[0])||void 0===i?void 0:i.value)?Ue(!0):!1===(null===(n=r[0])||void 0===n?void 0:n.value)||!1===(null===(o=a[0])||void 0===o?void 0:o.value)?Ue(!1):[]}}class gt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(Ne(t))return t;const i=this.right.eval(e);return Ne(i)?i:[]}}class xt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);if(0===t.length&&0===i.length)return[];const n=0===t.length?null:t[0].value,o=0===i.length?null:i[0].value;return!0===n&&!0!==o||!0!==n&&!0===o?Ue(!0):!0===n&&!0===o||!1===n&&!1===o?Ue(!1):[]}}class vt{constructor(e,t,i){this.name=e,this.args=t,this.impl=i}eval(e){return this.impl(e,...this.args)}}class Et{constructor(e,t){this.left=e,this.expr=t}eval(e){const t=this.expr.eval(e);if(1!==t.length)return[];const i=t[0].value;if("number"!=typeof i)throw new Error("Invalid indexer expression: should return integer}");const n=this.left.eval(e);return i in n?[n[i]]:[]}}function Tt(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch(t){return e}}const wt=()=>[],St={empty:e=>Ue(0===e.length),exists:(e,t)=>Ue(t?e.filter((e=>Ne(t.eval([e])))).length>0:e.length>0),all:(e,t)=>Ue(e.every((e=>Ne(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return Ue(!1);return Ue(!0)},anyTrue:e=>{for(const t of e)if(t.value)return Ue(!0);return Ue(!1)},allFalse:e=>{for(const t of e)if(t.value)return Ue(!1);return Ue(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return Ue(!0);return Ue(!1)},subsetOf:wt,supersetOf:wt,count:t=>[{type:e.PropertyType.integer,value:t.length}],distinct:e=>{const t=[];for(const i of e)t.some((e=>e.value===i.value))||t.push(i);return t},isDistinct:e=>Ue(e.length===St.distinct(e).length),where:(e,t)=>e.filter((e=>Ne(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:wt,ofType:wt,single:e=>{if(e.length>1)throw new Error("Expected input length one for single()");return 0===e.length?[]:e.slice(0,1)},first:e=>0===e.length?[]:e.slice(0,1),last:e=>0===e.length?[]:e.slice(e.length-1,e.length),tail:e=>0===e.length?[]:e.slice(1,e.length),skip:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for skip(num)");return n>=e.length?[]:n<=0?e:e.slice(n,e.length)},take:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for take(num)");return n>=e.length?e:n<=0?[]:e.slice(0,n)},intersect:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)!n.some((e=>e.value===t.value))&&i.some((e=>e.value===t.value))&&n.push(t);return n},exclude:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)i.some((e=>e.value===t.value))||n.push(t);return n},union:(e,t)=>{if(!t)return e;const i=t.eval(e);return je([...e,...i])},combine:(e,t)=>{if(!t)return e;const i=t.eval(e);return[...e,...i]},iif:(e,t,i,n)=>{const o=t.eval(e);if(o.length>1||1===o.length&&"boolean"!=typeof o[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return Ne(o)?i.eval(e):n?n.eval(e):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);if("boolean"==typeof i)return[{type:e.PropertyType.boolean,value:i}];if("number"==typeof i&&(0===i||1===i))return Ue(!!i);if("string"==typeof i){const e=i.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return Ue(!0);if(["false","f","no","n","0","0.0"].includes(e))return Ue(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:Ue(1===St.toBoolean(e).length),toInteger:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"number"==typeof i?[{type:e.PropertyType.integer,value:i}]:"string"==typeof i&&i.match(/^[+-]?\d+$/)?[{type:e.PropertyType.integer,value:parseInt(i,10)}]:"boolean"==typeof i?[{type:e.PropertyType.integer,value:i?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:Ue(1===St.toInteger(e).length),toDate:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.date,value:Tt(i)}]:[]},convertsToDate:e=>0===e.length?[]:Ue(1===St.toDate(e).length),toDateTime:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.dateTime,value:Tt(i)}]:[]},convertsToDateTime:e=>0===e.length?[]:Ue(1===St.toDateTime(e).length),toDecimal:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"number"==typeof i?[{type:e.PropertyType.decimal,value:i}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:e.PropertyType.decimal,value:parseFloat(i)}]:"boolean"==typeof i?[{type:e.PropertyType.decimal,value:i?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:Ue(1===St.toDecimal(e).length),toQuantity:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return Ge(i)?[{type:e.PropertyType.Quantity,value:i}]:"number"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i,unit:"1"}}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:e.PropertyType.Quantity,value:{value:parseFloat(i),unit:"1"}}]:"boolean"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:Ue(1===St.toQuantity(e).length),toString:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return null==i?[]:Ge(i)?[{type:e.PropertyType.string,value:`${i.value} '${i.unit}'`}]:[{type:e.PropertyType.string,value:i.toString()}]},convertsToString:e=>0===e.length?[]:Ue(1===St.toString(e).length),toTime:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);if("string"==typeof i){const t=i.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:e.PropertyType.time,value:Tt("T"+t[1])}]}return[]},convertsToTime:e=>0===e.length?[]:Ue(1===St.toTime(e).length),indexOf:(e,t)=>bt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,i)=>bt(((e,t,i)=>{const n=t,o=i?n+i:e.length;return n<0||n>=e.length?void 0:e.substring(n,o)}),e,t,i),startsWith:(e,t)=>bt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>bt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>bt(((e,t)=>e.includes(t)),e,t),upper:e=>bt((e=>e.toUpperCase()),e),lower:e=>bt((e=>e.toLowerCase()),e),replace:(e,t,i)=>bt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),matches:(e,t)=>bt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,i)=>bt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),length:e=>bt((e=>e.length),e),toChars:e=>bt((e=>e?e.split(""):void 0),e),abs:e=>Pt(Math.abs,e),ceiling:e=>Pt(Math.ceil,e),exp:e=>Pt(Math.exp,e),floor:e=>Pt(Math.floor,e),ln:e=>Pt(Math.log,e),log:(e,t)=>Pt(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>Pt(Math.pow,e,t),round:e=>Pt(Math.round,e),sqrt:e=>Pt(Math.sqrt,e),truncate:e=>Pt((e=>0|e),e),children:wt,descendants:wt,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:e.PropertyType.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:e.PropertyType.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:e.PropertyType.date,value:(new Date).toISOString().substring(0,10)}],between:(t,i,n,o)=>{var r;const a=St.toDateTime(i.eval(t));if(0===a.length)throw new Error("Invalid start date");const s=St.toDateTime(n.eval(t));if(0===s.length)throw new Error("Invalid end date");const c=null===(r=o.eval(t)[0])||void 0===r?void 0:r.value;if("years"!==c&&"months"!==c&&"days"!==c)throw new Error("Invalid units");const d=f(a[0].value,s[0].value);return[{type:e.PropertyType.Quantity,value:{value:d[c],unit:c}}]},is:(t,i)=>{let n="";return i instanceof tt?n=i.name:i instanceof dt&&(n=i.left.name+"."+i.right.name),n?t.map((t=>({type:e.PropertyType.boolean,value:$e(t,n)}))):[]},not:t=>St.toBoolean(t).map((t=>({type:e.PropertyType.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const i=t.value;let n;if("string"==typeof i)n=i;else if("object"==typeof i){const e=i;if(e.resource)return Le(e.resource);n=e.reference}if(!n)return{type:e.PropertyType.BackboneElement,value:null};const[o,r]=n.split("/");return{type:e.PropertyType.BackboneElement,value:{resourceType:o,id:r}}})).filter((e=>!!e.value)),as:e=>e,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:e.PropertyType.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:e.PropertyType.BackboneElement,value:null})),conformsTo:(t,i)=>{const n=i.eval(t)[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=n.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var i;return{type:e.PropertyType.boolean,value:(null===(i=t.value)||void 0===i?void 0:i.resourceType)===o}}))}};function bt(e,t,...i){if(0===t.length)return[];const[{value:n}]=Dt(t,1);if("string"!=typeof n)throw new Error("String function cannot be called with non-string");const o=e(n,...i.map((e=>{var i,n;return e&&(null===(n=null===(i=e.eval(t))||void 0===i?void 0:i[0])||void 0===n?void 0:n.value)})));return void 0===o?[]:Array.isArray(o)?o.map(Le):[Le(o)]}function Pt(t,i,...n){if(0===i.length)return[];const[{value:o}]=Dt(i,1),r=Ge(o),a=r?o.value:o;if("number"!=typeof a)throw new Error("Math function cannot be called with non-number");const s=t(a,...n.map((e=>{var t,n;return null===(n=null===(t=e.eval(i))||void 0===t?void 0:t[0])||void 0===n?void 0:n.value})));return[{type:r?e.PropertyType.Quantity:i[0].type,value:r?Object.assign(Object.assign({},o),{value:s}):s}]}function Dt(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const t of e)if(null==t)throw new Error("Expected non-null argument");return e}var Ct,At,Rt,Ot,kt,It,Mt,Ut,Lt,Nt,_t,jt,Qt,Bt,Wt,qt,Ft,Ht;function $t(e){return new Vt(e).tokenize()}const zt=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],Gt=["!=","!~","<=",">=","{}"];class Vt{constructor(e){Ct.add(this),At.set(this,void 0),Rt.set(this,void 0),n(this,At,e,"f"),n(this,Rt,0,"f")}tokenize(){const e=[];for(;i(this,Rt,"f")<i(this,At,"f").length;){const t=i(this,Ct,"m",kt).call(this);t&&e.push(t)}return e}}function Xt(e,t){return{id:e,value:t}}var Yt,Jt,Kt,Zt,ei,ti,ii,ni,oi;At=new WeakMap,Rt=new WeakMap,Ct=new WeakSet,Ot=function(){const e=i(this,Rt,"f"),t=i(this,Ct,"m",kt).call(this);return n(this,Rt,e,"f"),t},kt=function(){i(this,Ct,"m",It).call(this);const e=i(this,Ct,"m",qt).call(this);if(!e)return;const t=i(this,Ct,"m",Ht).call(this);return"/"===e&&"*"===t?i(this,Ct,"m",Mt).call(this):"/"===e&&"/"===t?i(this,Ct,"m",Ut).call(this):"'"===e?i(this,Ct,"m",Lt).call(this):"`"===e?i(this,Ct,"m",Nt).call(this):"@"===e?i(this,Ct,"m",_t).call(this):e.match(/\d/)?i(this,Ct,"m",jt).call(this):e.match(/\w/)||"$"===e&&t.match(/\w/)?i(this,Ct,"m",Qt).call(this):i(this,Ct,"m",Bt).call(this)},It=function(){return Xt("Whitespace",i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/\s/))))},Mt=function(){const e=i(this,Rt,"f");return i(this,Ct,"m",Wt).call(this,(()=>"*"!==i(this,Ct,"m",qt).call(this)||"/"!==i(this,Ct,"m",Ht).call(this))),n(this,Rt,i(this,Rt,"f")+2,"f"),Xt("Comment",i(this,At,"f").substring(e,i(this,Rt,"f")))},Ut=function(){return Xt("Comment",i(this,Ct,"m",Wt).call(this,(()=>"\n"!==i(this,Ct,"m",qt).call(this))))},Lt=function(){var e,t;n(this,Rt,(e=i(this,Rt,"f"),++e),"f");const o=Xt("String",i(this,Ct,"m",Wt).call(this,(()=>"\\"===i(this,Ct,"m",Ft).call(this)||"'"!==i(this,Ct,"m",qt).call(this))));return n(this,Rt,(t=i(this,Rt,"f"),++t),"f"),o},Nt=function(){var e,t;n(this,Rt,(e=i(this,Rt,"f"),++e),"f");const o=Xt("Symbol",i(this,Ct,"m",Wt).call(this,(()=>"`"!==i(this,Ct,"m",qt).call(this))));return n(this,Rt,(t=i(this,Rt,"f"),++t),"f"),o},_t=function(){var e,t,o,r,a;const s=i(this,Rt,"f");return n(this,Rt,(e=i(this,Rt,"f"),++e),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d-]/))),"T"===i(this,Ct,"m",qt).call(this)&&(n(this,Rt,(t=i(this,Rt,"f"),++t),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d:]/))),"."===i(this,Ct,"m",qt).call(this)&&i(this,Ct,"m",Ht).call(this).match(/\d/)&&(n(this,Rt,(o=i(this,Rt,"f"),++o),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d]/)))),"Z"===i(this,Ct,"m",qt).call(this)?n(this,Rt,(r=i(this,Rt,"f"),++r),"f"):"+"!==i(this,Ct,"m",qt).call(this)&&"-"!==i(this,Ct,"m",qt).call(this)||(n(this,Rt,(a=i(this,Rt,"f"),++a),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d:]/))))),Xt("DateTime",i(this,At,"f").substring(s+1,i(this,Rt,"f")))},jt=function(){var e;const t=i(this,Rt,"f");let o="Number";return i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/\d/))),"."===i(this,Ct,"m",qt).call(this)&&i(this,Ct,"m",Ht).call(this).match(/\d/)&&(n(this,Rt,(e=i(this,Rt,"f"),++e),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/\d/))))," "===i(this,Ct,"m",qt).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&zt.includes(e.value))return!0}return!1}(i(this,Ct,"m",Ot).call(this))&&(o="Quantity",i(this,Ct,"m",kt).call(this)),Xt(o,i(this,At,"f").substring(t,i(this,Rt,"f")))},Qt=function(){return Xt("Symbol",i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[$\w]/))))},Bt=function(){var e;const t=i(this,Ct,"m",qt).call(this),o=t+i(this,Ct,"m",Ht).call(this);return Gt.includes(o)?(n(this,Rt,i(this,Rt,"f")+2,"f"),Xt(o,o)):(n(this,Rt,(e=i(this,Rt,"f"),++e),"f"),Xt(t,t))},Wt=function(e){var t;const o=i(this,Rt,"f");for(;i(this,Rt,"f")<i(this,At,"f").length&&e();)n(this,Rt,(t=i(this,Rt,"f"),++t),"f");return i(this,At,"f").substring(o,i(this,Rt,"f"))},qt=function(){return i(this,At,"f")[i(this,Rt,"f")]},Ft=function(){var e;return null!==(e=i(this,At,"f")[i(this,Rt,"f")-1])&&void 0!==e?e:""},Ht=function(){var e;return null!==(e=i(this,At,"f")[i(this,Rt,"f")+1])&&void 0!==e?e:""};Yt=new WeakMap,Jt=new WeakMap;class ri{constructor(e,t,i){Kt.add(this),Zt.set(this,void 0),ei.set(this,void 0),ti.set(this,void 0),n(this,Zt,e,"f"),n(this,ei,t,"f"),n(this,ti,i,"f")}match(e){const t=i(this,Kt,"m",oi).call(this);return(null==t?void 0:t.id)===e&&(i(this,Kt,"m",ni).call(this),!0)}consumeAndParse(e=100){const t=i(this,Kt,"m",ni).call(this),n=i(this,ei,"f")[t.id];if(!n)throw Error(`Parse error at ${t.value}. No matching prefix parselet.`);let o=n.parse(this,t);for(;e>i(this,Kt,"m",ii).call(this);){const e=i(this,Kt,"m",ni).call(this);o=i(this,ti,"f")[e.id].parse(this,o,e)}return o}}Zt=new WeakMap,ei=new WeakMap,ti=new WeakMap,Kt=new WeakSet,ii=function(){const e=i(this,Kt,"m",oi).call(this);if(!e)return 100;const t=i(this,ti,"f")[e.id];return t?t.precedence:100},ni=function(){if(!i(this,Zt,"f").length)throw Error("Cant consume unknown more tokens.");return i(this,Zt,"f").shift()},oi=function(){return i(this,Zt,"f").length>0?i(this,Zt,"f")[0]:void 0};const ai={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},si={parse(e,t){const i=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new Et(t,i)},precedence:2},ci={parse(e,t){if(!(t instanceof tt))throw new Error("Unexpected parentheses");if(!(t.name in St))throw new Error("Unrecognized function: "+t.name);const i=[];for(;!e.match(")");)i.push(e.consumeAndParse()),e.match(",");return new vt(t.name,i,St[t.name])},precedence:0};function di(e){const t=e.split(" "),i=parseFloat(t[0]);let n=t[1];return n=n&&n.startsWith("'")&&n.endsWith("'")?n.substring(1,n.length-1):"{"+n+"}",{value:i,unit:n}}const li=(new class{constructor(){Yt.set(this,{}),Jt.set(this,{})}registerInfix(e,t){return i(this,Jt,"f")[e]=t,this}registerPrefix(e,t){return i(this,Yt,"f")[e]=t,this}prefix(e,t,i){return this.registerPrefix(e,{parse(e,n){const o=e.consumeAndParse(t);return i(n,o)}})}infixLeft(e,t,i){return this.registerInfix(e,{parse(e,n,o){const r=e.consumeAndParse(t);return i(n,o,r)},precedence:t})}construct(e){return new ri($t(e),i(this,Yt,"f"),i(this,Jt,"f"))}}).registerPrefix("String",{parse:(t,i)=>new et({type:e.PropertyType.string,value:i.value})}).registerPrefix("DateTime",{parse:(t,i)=>new et({type:e.PropertyType.dateTime,value:Tt(i.value)})}).registerPrefix("Quantity",{parse:(t,i)=>new et({type:e.PropertyType.Quantity,value:di(i.value)})}).registerPrefix("Number",{parse:(t,i)=>new et({type:e.PropertyType.decimal,value:parseFloat(i.value)})}).registerPrefix("Symbol",{parse:(t,i)=>"false"===i.value?new et({type:e.PropertyType.boolean,value:!1}):"true"===i.value?new et({type:e.PropertyType.boolean,value:!0}):new tt(i.value)}).registerPrefix("{}",{parse:()=>new it}).registerPrefix("(",ai).registerInfix("[",si).registerInfix("(",ci).prefix("+",3,((e,t)=>new nt(t,(e=>e)))).prefix("-",3,((e,t)=>new rt(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,i)=>new dt(e,i))).infixLeft("/",4,((e,t,i)=>new rt(e,i,((e,t)=>e/t)))).infixLeft("*",4,((e,t,i)=>new rt(e,i,((e,t)=>e*t)))).infixLeft("+",5,((e,t,i)=>new rt(e,i,((e,t)=>e+t)))).infixLeft("-",5,((e,t,i)=>new rt(e,i,((e,t)=>e-t)))).infixLeft("|",7,((e,t,i)=>new lt(e,i))).infixLeft("=",9,((e,t,i)=>new ut(e,i))).infixLeft("!=",9,((e,t,i)=>new mt(e,i))).infixLeft("~",9,((e,t,i)=>new pt(e,i))).infixLeft("!~",9,((e,t,i)=>new ht(e,i))).infixLeft("<",8,((e,t,i)=>new rt(e,i,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,i)=>new rt(e,i,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,i)=>new rt(e,i,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,i)=>new rt(e,i,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,i)=>new at(e,i))).infixLeft("Symbol",6,((e,t,i)=>{switch(t.value){case"and":return new yt(e,i);case"as":return new ot(e,i);case"contains":return new st(e,i);case"div":return new rt(e,i,((e,t)=>e/t|0));case"in":return new ct(e,i);case"is":return new ft(e,i);case"mod":return new rt(e,i,((e,t)=>e%t));case"or":return new gt(e,i);case"xor":return new xt(e,i);default:throw new Error("Cannot use "+t.value+" as infix operator")}}));function ui(e){try{return new Ze(e,li.construct(e).consumeAndParse())}catch(t){throw new Error(`FhirPathError on "${e}": ${t}`)}}function mi(e,t){return ui(e).eval(t)}class pi{constructor(e){this.segments=e}get(e){return"number"==typeof e?this.segments[e]:this.segments.find((t=>t.name===e))}getAll(e){return this.segments.filter((t=>t.name===e))}toString(){return this.segments.map((e=>e.toString())).join("\r")}buildAck(){var e,t,i,n,o,r;const a=new Date,s=this.get("MSH"),c=(null===(e=null==s?void 0:s.get(2))||void 0===e?void 0:e.toString())||"",d=(null===(t=null==s?void 0:s.get(3))||void 0===t?void 0:t.toString())||"",l=(null===(i=null==s?void 0:s.get(4))||void 0===i?void 0:i.toString())||"",u=(null===(n=null==s?void 0:s.get(5))||void 0===n?void 0:n.toString())||"",m=(null===(o=null==s?void 0:s.get(9))||void 0===o?void 0:o.toString())||"",p=(null===(r=null==s?void 0:s.get(12))||void 0===r?void 0:r.toString())||"2.5.1";return new pi([new hi(["MSH","^~\\&",l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p]),new hi(["MSA","AA",m,"OK"])])}static parse(e){if(!e.startsWith("MSH|^~\\&")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}return new pi(e.split(/[\r\n]+/).map((e=>hi.parse(e))))}}class hi{constructor(e){w(e)?this.fields=e.map((e=>fi.parse(e))):this.fields=e,this.name=this.fields[0].components[0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join("|")}static parse(e){return new hi(e.split("|").map((e=>fi.parse(e))))}}class fi{constructor(e){this.components=e}get(e){return this.components[e]}toString(){return this.components.join("^")}static parse(e){return new fi(e.split("^"))}}const yi="ok",gi="created",xi="gone",vi="not-modified",Ei="not-found",Ti="access-denied",wi={resourceType:"OperationOutcome",id:yi,issue:[{severity:"information",code:"information",details:{text:"All OK"}}]},Si={resourceType:"OperationOutcome",id:gi,issue:[{severity:"information",code:"information",details:{text:"Created"}}]},bi={resourceType:"OperationOutcome",id:vi,issue:[{severity:"information",code:"information",details:{text:"Not Modified"}}]},Pi={resourceType:"OperationOutcome",id:Ei,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},Di={resourceType:"OperationOutcome",id:xi,issue:[{severity:"error",code:"gone",details:{text:"Gone"}}]},Ci={resourceType:"OperationOutcome",id:Ti,issue:[{severity:"error",code:"access-denied",details:{text:"Access Denied"}}]};function Ai(e){return e.id===yi||e.id===gi||e.id===vi}class Ri extends Error{constructor(e){var t,i;super(null===(i=null===(t=null==e?void 0:e.issue)||void 0===t?void 0:t[0].details)||void 0===i?void 0:i.text),this.outcome=e}}var Oi;e.Operator=void 0,(Oi=e.Operator||(e.Operator={})).EQUALS="eq",Oi.NOT_EQUALS="ne",Oi.GREATER_THAN="gt",Oi.LESS_THAN="lt",Oi.GREATER_THAN_OR_EQUALS="ge",Oi.LESS_THAN_OR_EQUALS="le",Oi.STARTS_AFTER="sa",Oi.ENDS_BEFORE="eb",Oi.APPROXIMATELY="ap",Oi.CONTAINS="contains",Oi.EXACT="exact",Oi.TEXT="text",Oi.NOT="not",Oi.ABOVE="above",Oi.BELOW="below",Oi.IN="in",Oi.NOT_IN="not-in",Oi.OF_TYPE="of-type",Oi.MISSING="missing";const ki=[e.Operator.CONTAINS,e.Operator.EXACT,e.Operator.TEXT,e.Operator.NOT,e.Operator.ABOVE,e.Operator.BELOW,e.Operator.IN,e.Operator.NOT_IN,e.Operator.OF_TYPE,e.Operator.MISSING],Ii=[e.Operator.NOT_EQUALS,e.Operator.GREATER_THAN,e.Operator.LESS_THAN,e.Operator.GREATER_THAN_OR_EQUALS,e.Operator.LESS_THAN_OR_EQUALS,e.Operator.STARTS_AFTER,e.Operator.ENDS_BEFORE,e.Operator.APPROXIMATELY];var Mi;function Ui(t,i){let n=e.SearchParameterType.TEXT;switch(t.type){case"date":n=i===e.PropertyType.dateTime||i===e.PropertyType.instant?e.SearchParameterType.DATETIME:e.SearchParameterType.DATE;break;case"number":n=e.SearchParameterType.NUMBER;break;case"quantity":n=e.SearchParameterType.QUANTITY;break;case"reference":n=e.SearchParameterType.REFERENCE;break;case"token":"boolean"===i&&(n=e.SearchParameterType.BOOLEAN)}return n}function Li(e,t){const i=t.split(" | ");for(const t of i){if((n=t).includes(" as Period")||n.includes(" as SampledDate"))continue;const i=Ni(t);if(i.startsWith(e+"."))return i}var n}function Ni(e){let t=e.trim();t.startsWith("(")&&t.endsWith(")")&&(t=t.substring(1,t.length-1)),t.includes("[0]")&&(t=t.replaceAll("[0]",""));const i=[" != "," as ",".as(",".exists(",".where("];for(const e of i)t.includes(e)&&(t=t.substring(0,t.indexOf(e)));return t}e.SearchParameterType=void 0,(Mi=e.SearchParameterType||(e.SearchParameterType={})).BOOLEAN="BOOLEAN",Mi.NUMBER="NUMBER",Mi.QUANTITY="QUANTITY",Mi.TEXT="TEXT",Mi.REFERENCE="REFERENCE",Mi.DATE="DATE",Mi.DATETIME="DATETIME",Mi.PERIOD="PERIOD",e.AndAtom=yt,e.ArithemticOperatorAtom=rt,e.AsAtom=ot,e.COMPONENT_SEPARATOR="^",e.ConcatAtom=at,e.ContainsAtom=st,e.DEFAULT_SEARCH_COUNT=20,e.DotAtom=dt,e.EmptySetAtom=it,e.EqualsAtom=ut,e.EquivalentAtom=pt,e.FIELD_SEPARATOR="|",e.FhirPathAtom=Ze,e.FunctionAtom=vt,e.Hl7Field=fi,e.Hl7Message=pi,e.Hl7Segment=hi,e.InAtom=ct,e.IndexerAtom=Et,e.IsAtom=ft,e.LRUCache=c,e.LiteralAtom=et,e.MedplumClient=class extends class{constructor(){U.set(this,void 0),n(this,U,{},"f")}addEventListener(e,t){i(this,U,"f")[e]||(i(this,U,"f")[e]=[]),i(this,U,"f")[e].push(t)}removeEventListeneer(e,t){const n=i(this,U,"f")[e];if(n)for(let e=0;e<n.length;e++)if(n[e]===t)return void n.splice(e,1)}dispatchEvent(e){const t=i(this,U,"f")[e.type];return t&&t.forEach((t=>t.call(this,e))),!e.defaultPrevented}}{constructor(e){var t,o;if(super(),Z.add(this),ee.set(this,void 0),te.set(this,void 0),ie.set(this,void 0),ne.set(this,void 0),oe.set(this,void 0),re.set(this,void 0),ae.set(this,void 0),se.set(this,void 0),ce.set(this,void 0),de.set(this,void 0),le.set(this,void 0),ue.set(this,void 0),me.set(this,void 0),pe.set(this,void 0),he.set(this,void 0),fe.set(this,void 0),ye.set(this,void 0),null==e?void 0:e.baseUrl){if(!e.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");if(!e.baseUrl.endsWith("/"))throw new Error("Base URL must end with a trailing slash")}n(this,ee,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),n(this,te,null==e?void 0:e.createPdf,"f"),n(this,ie,new H,"f"),n(this,ne,new c(null!==(t=null==e?void 0:e.resourceCacheSize)&&void 0!==t?t:1e3),"f"),n(this,oe,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:1e4,"f"),n(this,re,(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),n(this,ae,(null==e?void 0:e.clientId)||"","f"),n(this,se,(null==e?void 0:e.authorizeUrl)||i(this,re,"f")+"oauth2/authorize","f"),n(this,ce,(null==e?void 0:e.tokenUrl)||i(this,re,"f")+"oauth2/token","f"),n(this,de,(null==e?void 0:e.logoutUrl)||i(this,re,"f")+"oauth2/logout","f"),n(this,le,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(n(this,ue,r.accessToken,"f"),n(this,me,r.refreshToken,"f"),i(this,Z,"m",xe).call(this).catch(console.log)),i(this,Z,"m",ke).call(this)}getBaseUrl(){return i(this,re,"f")}clear(){i(this,ie,"f").clear(),i(this,ne,"f").clear(),n(this,ue,void 0,"f"),n(this,me,void 0,"f"),n(this,fe,void 0,"f"),n(this,ye,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),i(this,ne,"f").delete(e)}invalidateSearches(e){const t="fhir/R4/"+e;for(const e of i(this,ne,"f").keys())(e.endsWith(t)||e.includes(t+"?"))&&i(this,ne,"f").delete(e)}get(e,t={}){e=e.toString();const n=i(this,Z,"m",ve).call(this,e,t);if(n)return n.value;const o=new F(i(this,Z,"m",Te).call(this,"GET",e,t));return i(this,Z,"m",Ee).call(this,e,o),o}post(e,t,n,o={}){return e=e.toString(),t&&i(this,Z,"m",be).call(this,o,t),n&&i(this,Z,"m",Se).call(this,o,n),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"POST",e,o)}put(e,t,n,o={}){return e=e.toString(),t&&i(this,Z,"m",be).call(this,o,t),n&&i(this,Z,"m",Se).call(this,o,n),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"PUT",e,o)}patch(e,t,n={}){return e=e.toString(),i(this,Z,"m",be).call(this,n,t),i(this,Z,"m",Se).call(this,n,"application/json-patch+json"),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"PATCH",e,n)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"DELETE",e,t)}register(e){return t(this,void 0,void 0,(function*(){const t=yield this.post("auth/register",e);yield this.setActiveLogin(t)}))}startLogin(e){return t(this,void 0,void 0,(function*(){return yield i(this,Z,"m",De).call(this),this.post("auth/login",Object.assign(Object.assign({},e),{clientId:i(this,ae,"f"),scope:Ie,codeChallengeMethod:"S256",codeChallenge:i(this,ie,"f").getString("codeChallenge")}))}))}startGoogleLogin(e){return t(this,void 0,void 0,(function*(){return yield i(this,Z,"m",De).call(this),this.post("auth/google",e)}))}signOut(){return this.clear(),Promise.resolve()}signInWithRedirect(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void i(this,Z,"m",Ce).call(this)}signOutWithRedirect(){window.location.assign(i(this,de,"f"))}fhirUrl(...e){return new URL(i(this,re,"f")+"fhir/R4/"+e.join("/"))}fhirSearchUrl(e,t){const i=this.fhirUrl(e);return t&&(i.search=t.toString()),i}search(e,t,i={}){return this.get(this.fhirSearchUrl(e,t),i)}searchOne(e,t,n={}){const o=this.fhirSearchUrl(e,t);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=i(this,Z,"m",ve).call(this,r,n);if(a)return a.value;const s=new F(this.search(e,o.searchParams,n).then((e=>{var t,i;return null===(i=null===(t=e.entry)||void 0===t?void 0:t[0])||void 0===i?void 0:i.resource})));return i(this,Z,"m",Ee).call(this,r,s),s}searchResources(e,t,n={}){const o=this.fhirSearchUrl(e,t).toString()+"-searchResources",r=i(this,Z,"m",ve).call(this,o,n);if(r)return r.value;const a=new F(this.search(e,t,n).then((e=>{var t,i;return null!==(i=null===(t=e.entry)||void 0===t?void 0:t.map((e=>e.resource)))&&void 0!==i?i:[]})));return i(this,Z,"m",Ee).call(this,o,a),a}searchValueSet(e,t,i={}){const n=this.fhirUrl("ValueSet","$expand");return n.searchParams.set("url",e),n.searchParams.set("filter",t),this.get(n.toString(),i)}getCached(e,t){var n;const o=null===(n=i(this,ne,"f").get(this.fhirUrl(e,t).toString()))||void 0===n?void 0:n.value;return o&&o.isOk()?o.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[i,n]=t.split("/");return i&&n?this.getCached(i,n):void 0}readResource(e,t){return this.get(this.fhirUrl(e,t))}readReference(e){const t=null==e?void 0:e.reference;if(!t)return new F(Promise.reject(new Error("Missing reference")));const[i,n]=t.split("/");return i&&n?this.readResource(i,n):new F(Promise.reject(new Error("Invalid reference")))}getSchema(){return K}requestSchema(e){return t(this,void 0,void 0,(function*(){if(e in K.types)return K;const t=`{\n StructureDefinitionList(name: "${e}") {\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: "${e}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(t);for(const e of i.data.StructureDefinitionList)X(K,e);for(const e of i.data.SearchParameterList)Y(K,e);return K}))}readHistory(e,t){return this.get(this.fhirUrl(e,t,"_history"))}readVersion(e,t,i){return this.get(this.fhirUrl(e,t,"_history",i))}readPatientEverything(e){return this.get(this.fhirUrl("Patient",e,"$everything"))}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}createResourceIfNoneExist(e,i){var n;return t(this,void 0,void 0,(function*(){return null!==(n=yield this.searchOne(e.resourceType,i))&&void 0!==n?n:this.createResource(e)}))}createBinary(e,t,i){const n=this.fhirUrl("Binary");return t&&n.searchParams.set("_filename",t),this.post(n,e,i)}createPdf(e,n,o,r){return t(this,void 0,void 0,(function*(){if(!i(this,te,"f"))throw new Error("PDF creation not enabled");const t=yield i(this,te,"f").call(this,e,o,r);return this.createBinary(t,n,"application/pdf")}))}createComment(e,t){const i=this.getProfile();let n,o;return"Encounter"===e.resourceType&&(n=l(e),o=e.subject),"ServiceRequest"===e.resourceType&&(n=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=l(e)),this.createResource({resourceType:"Communication",basedOn:[l(e)],encounter:n,subject:o,sender:i?l(i):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}updateResource(e){if(!e.resourceType)throw new Error("Missing resourceType");if(!e.id)throw new Error("Missing id");return this.invalidateSearches(e.resourceType),this.put(this.fhirUrl(e.resourceType,e.id),e)}patchResource(e,t,i){return this.invalidateSearches(e),this.patch(this.fhirUrl(e,t),i)}deleteResource(e,t){return this.invalidateSearches(e),this.delete(this.fhirUrl(e,t))}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t){return this.post(this.fhirUrl("$graphql"),{query:e},"application/json",t)}getActiveLogin(){return i(this,ie,"f").getObject("activeLogin")}setActiveLogin(e){return t(this,void 0,void 0,(function*(){n(this,ue,e.accessToken,"f"),n(this,me,e.refreshToken,"f"),n(this,fe,void 0,"f"),n(this,ye,void 0,"f"),i(this,ie,"f").setObject("activeLogin",e),i(this,Z,"m",ge).call(this,e),i(this,ne,"f").clear(),n(this,pe,void 0,"f"),yield i(this,Z,"m",xe).call(this)}))}getAccessToken(){return i(this,ue,"f")}setAccessToken(e){n(this,ue,e,"f"),n(this,me,void 0,"f"),n(this,fe,void 0,"f"),n(this,ye,void 0,"f")}getLogins(){var e;return null!==(e=i(this,ie,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!i(this,he,"f")}getProfile(){return i(this,fe,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return i(this,he,"f")&&(yield i(this,he,"f")),this.getProfile()}))}getUserConfiguration(){return i(this,ye,"f")}download(e,n={}){return t(this,void 0,void 0,(function*(){i(this,pe,"f")&&(yield i(this,pe,"f")),i(this,Z,"m",we).call(this,n);return(yield i(this,ee,"f").call(this,e.toString(),n)).blob()}))}processCode(e){if(!i(this,ie,"f").getString("pkceState"))throw this.clear(),new Error("Invalid PCKE state");const t=i(this,ie,"f").getString("codeVerifier");if(!t)throw this.clear(),new Error("Invalid PCKE code verifier");const n=new URLSearchParams;return n.set("grant_type","authorization_code"),n.set("client_id",i(this,ae,"f")),n.set("code_verifier",t),n.set("code",e),n.set("redirect_uri",Me()),i(this,Z,"m",Re).call(this,n)}startClientLogin(e,n){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",e),t.set("client_secret",n),i(this,Z,"m",Re).call(this,t)}))}},e.NotEqualsAtom=mt,e.NotEquivalentAtom=ht,e.OperationOutcomeError=Ri,e.OrAtom=gt,e.ReadablePromise=F,e.SEGMENT_SEPARATOR="\r",e.SymbolAtom=tt,e.UnaryOperatorAtom=nt,e.UnionAtom=lt,e.XorAtom=xt,e.accessDenied=Ci,e.allOk=wi,e.arrayBufferToBase64=P,e.arrayBufferToHex=b,e.assertOk=function(e,t){if(!Ai(e)||void 0===t)throw new Ri(e)},e.badRequest=function(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}},e.booleanToTypedValue=Ue,e.buildTypeName=J,e.calculateAge=f,e.calculateAgeString=function(e,t){const{years:i,months:n,days:o}=f(e,t);return i>=2?i.toString().padStart(3,"0")+"Y":n>=1?n.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"},e.capitalize=D,e.createReference=l,e.createSchema=function(){return{types:{}}},e.createTypeSchema=V,e.created=Si,e.deepEquals=E,e.evalFhirPath=function(e,t){const i=Array.isArray(t)?t:[t];for(let e=0;e<i.length;e++){const t=i[e];"object"==typeof t&&"type"in t&&"value"in t||(i[e]=Le(i[e]))}return mi(e,i).map((e=>e.value))},e.evalFhirPathTyped=mi,e.fhirPathArrayEquals=Be,e.fhirPathArrayEquivalent=qe,e.fhirPathEquals=We,e.fhirPathEquivalent=Fe,e.fhirPathIs=$e,e.fhirPathNot=Qe,e.findObservationInterval=function(e,t,i,n){var o;return null===(o=e.qualifiedInterval)||void 0===o?void 0:o.find((o=>{var r;return function(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||C(f(t.birthDate).years,e.age)}(e,t)}(o,t)&&function(e,t,i){return!!e.range&&C(t,e.range,i)}(o,i,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===n||o.category===n)}))},e.formatAddress=function(e,t){const i=[];return e.line&&i.push(...e.line),e.city&&i.push(e.city),e.state&&i.push(e.state),e.postalCode&&i.push(e.postalCode),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(", ").trim()},e.formatFamilyName=function(e){return e.family||""},e.formatGivenName=function(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()},e.formatHumanName=d,e.formatSearchQuery=function(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=ki.includes(e.operator)?":"+e.operator:"",i=Ii.includes(e.operator)?e.operator:"";return`${e.code}${t}=${i}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))},e.getCodeBySystem=function(e,t){var i,n;return null===(n=null===(i=null==e?void 0:e.coding)||void 0===i?void 0:i.find((e=>e.system===t)))||void 0===n?void 0:n.code},e.getDateProperty=function(e){return e?new Date(e):void 0},e.getDisplayString=p,e.getExpressionForResourceType=Li,e.getExtensionValue=function(e,...t){var i;let n=e;for(let e=0;e<t.length&&n;e++)n=null===(i=null==n?void 0:n.extension)||void 0===i?void 0:i.find((i=>i.url===t[e]));return null==n?void 0:n.valueString},e.getIdentifier=function(e,t){const i=e.identifier;if(!i)return;const n=Array.isArray(i)?i:[i];for(const e of n)if(e.system===t)return e.value},e.getImageSrc=function(e){if(m(e)){const t=e.photo;if(t)for(const e of t){const t=h(e);if(t)return t}}if("Bot"===e.resourceType&&e.photo){const t=h(e.photo);if(t)return t}},e.getPropertyDisplayName=function(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(D).join(" ").replace("_"," ").replace(/\s+/g," ")},e.getQuestionnaireAnswers=function(e){const t={};return y(e.item,t),t},e.getReferenceString=u,e.getSearchParameterDetails=function(t,i,n){var o,r,a,s,c,d,l;if("_lastUpdated"===n.code)return{columnName:"lastUpdated",type:e.SearchParameterType.DATETIME};const u=n.code.split("-").reduce(((e,t,i)=>e+(i?D(t):t)),""),m=null===(o=Li(i,n.expression))||void 0===o?void 0:o.split(".");if(!m)return{columnName:u,type:e.SearchParameterType.TEXT};const p=Ui(n);let h,f,y=i,g=!1;for(let e=1;e<m.length;e++){const o=m[e];if(h=null!==(s=null===(a=null===(r=t.types[y])||void 0===r?void 0:r.properties)||void 0===a?void 0:a[o])&&void 0!==s?s:null===(d=null===(c=t.types[y])||void 0===c?void 0:c.properties)||void 0===d?void 0:d[o+"[x]"],!h)throw new Error(`Element definition not found for ${i} ${n.code}`);if("*"===h.max&&(g=!0),f=null===(l=h.type)||void 0===l?void 0:l[0].code,!f)return{columnName:u,type:p,array:g};e<m.length-1&&("Element"===f||"BackboneElement"===f?y+=D(o):y=f)}return{columnName:u,type:Ui(n,f),elementDefinition:h,array:g}},e.getStatus=function(e){return e.id===yi?200:e.id===gi?201:e.id===vi?304:e.id===Ti?403:e.id===Ei?404:e.id===xi?410:400},e.getTypedPropertyValue=_e,e.globalSchema=K,e.gone=Di,e.indexSearchParameter=Y,e.indexStructureDefinition=X,e.indexStructureDefinitionBundle=function(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&X(K,e)}},e.isGone=function(e){return e.id===xi},e.isLowerCase=function(e){return e===e.toLowerCase()},e.isNotFound=function(e){return e.id===Ei},e.isObject=T,e.isOk=Ai,e.isPeriod=ze,e.isProfileResource=m,e.isQuantity=Ge,e.isQuantityEquivalent=Ve,e.isStringArray=w,e.isUUID=function(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)},e.matchesRange=C,e.notFound=Pi,e.notModified=bi,e.parseFhirPath=ui,e.parseSearchDefinition=function(t){const i=new URL(t,"https://example.com/"),n=i.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let o,r,a,s,c,d;return new URLSearchParams(i.search).forEach(((t,i)=>{"_fields"===i?a=t.split(","):"_offset"===i?s=parseInt(t):"_count"===i?c=parseInt(t):"_total"===i?d=t:"_sort"===i?(r=r||[],r.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(t))):(o=o||[],o.push(function(t,i){let n=t,o=e.Operator.EQUALS;for(const e of ki){const t=n.indexOf(":"+e);-1!==t&&(o=e,n=n.substring(0,t))}for(const e of Ii)i.match(new RegExp("^"+e+"\\d"))&&(o=e,i=i.substring(e.length));return{code:n,operator:o,value:i}}(i,t)))})),{resourceType:n,filters:o,fields:a,offset:s,count:c,total:d,sortRules:r}},e.preciseEquals=A,e.preciseGreaterThan=O,e.preciseGreaterThanOrEquals=I,e.preciseLessThan=R,e.preciseLessThanOrEquals=k,e.removeDuplicates=je,e.resolveId=function(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]},e.setCodeBySystem=function(e,t,i){var n,o;e.coding||(e.coding=[]);const r=null===(n=e.coding)||void 0===n?void 0:n.find((e=>e.system===t));r?r.code=i:null===(o=e.coding)||void 0===o||o.push({system:t,code:i})},e.stringify=g,e.toJsBoolean=Ne,e.toTypedValue=Le,e.tokenize=$t,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.core={}))}(this,(function(e){"use strict";function t(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{c(n.next(e))}catch(e){r(e)}}function s(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}var o,r,a,s;class c{constructor(e=10){o.add(this),r.set(this,void 0),a.set(this,void 0),n(this,r,e,"f"),n(this,a,new Map,"f")}clear(){i(this,a,"f").clear()}get(e){const t=i(this,a,"f").get(e);return t&&(i(this,a,"f").delete(e),i(this,a,"f").set(e,t)),t}set(e,t){i(this,a,"f").has(e)?i(this,a,"f").delete(e):i(this,a,"f").size>=i(this,r,"f")&&i(this,a,"f").delete(i(this,o,"m",s).call(this)),i(this,a,"f").set(e,t)}delete(e){i(this,a,"f").delete(e)}keys(){return i(this,a,"f").keys()}}function d(e,t){const i=[];return e.prefix&&((null==t?void 0:t.all)||(null==t?void 0:t.prefix))&&i.push(...e.prefix),e.given&&i.push(...e.given),e.family&&i.push(e.family),e.suffix&&((null==t?void 0:t.all)||(null==t?void 0:t.suffix))&&i.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(" ").trim()}function l(e){const t=u(e),i=p(e);return i===t?{reference:t}:{reference:t,display:i}}function u(e){return e.resourceType+"/"+e.id}function m(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function p(e){var t,i;if(m(e)){const t=function(e){const t=e.name;if(t&&t.length>0)return d(t[0]);return}(e);if(t)return t}if("Device"===e.resourceType){const t=function(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name;return}(e);if(t)return t}return"Observation"===e.resourceType&&"code"in e&&(null===(t=e.code)||void 0===t?void 0:t.text)?null===(i=e.code)||void 0===i?void 0:i.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:u(e)}function h(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function f(e,t){const i=new Date(e);i.setUTCHours(0,0,0,0);const n=t?new Date(t):new Date;n.setUTCHours(0,0,0,0);const o=i.getUTCFullYear(),r=i.getUTCMonth(),a=i.getUTCDate(),s=n.getUTCFullYear(),c=n.getUTCMonth(),d=n.getUTCDate();let l=s-o;(c<r||c===r&&d<a)&&l--;let u=12*s+c-(12*o+r);d<a&&u--;return{years:l,months:u,days:Math.floor((n.getTime()-i.getTime())/864e5)}}function y(e,t){if(e)for(const i of e)i.linkId&&i.answer&&i.answer.length>0&&(t[i.linkId]=i.answer[0]),y(i.item,t)}function g(e,t){return JSON.stringify(e,x,t?2:void 0)}function x(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&v(t)?void 0:t}function v(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function E(e,t,i){return e===t||(!(!v(e)||!v(t))||!v(e)&&!v(t)&&(Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!E(e[i],t[i]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(T(e)&&T(t)?function(e,t,i){const n=new Set;Object.keys(e).forEach((e=>n.add(e))),Object.keys(t).forEach((e=>n.add(e))),"meta"===i&&(n.delete("versionId"),n.delete("lastUpdated"),n.delete("author"));for(const i of n){if(!E(e[i],t[i],i))return!1}return!0}(e,t,i):(T(e)||T(t),!1))))}function T(e){return null!==e&&"object"==typeof e}function w(e){return e.every((e=>"string"==typeof e))}r=new WeakMap,a=new WeakMap,o=new WeakSet,s=function(){return i(this,a,"f").keys().next().value};const S=[];for(let e=0;e<256;e++)S.push(e.toString(16).padStart(2,"0"));function b(e){const t=new Uint8Array(e),i=new Array(t.length);for(let e=0;e<t.length;e++)i[e]=S[t[e]];return i.join("")}function P(e){const t=new Uint8Array(e),i=[];for(let e=0;e<t.length;e++)i[e]=String.fromCharCode(t[e]);return window.btoa(i.join(""))}function D(e){return e.charAt(0).toUpperCase()+e.substring(1)}function C(e,t,i){var n,o;return(void 0===(null===(n=t.low)||void 0===n?void 0:n.value)||I(e,t.low.value,i))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||k(e,t.high.value,i))}function A(e,t,i){return i?Math.abs(e-t)<Math.pow(10,-i):e===t}function R(e,t,i){return i?e<t&&Math.abs(e-t)>Math.pow(10,-i):e<t}function O(e,t,i){return i?e>t&&Math.abs(e-t)>Math.pow(10,-i):e>t}function k(e,t,i){return R(e,t,i)||A(e,t,i)}function I(e,t,i){return O(e,t,i)||A(e,t,i)}function M(){const e=new Uint32Array(28);return crypto.getRandomValues(e),b(e.buffer)}var U,L,N,_,j,Q,B,W;function q(e){const t=function(e){if("undefined"!=typeof window)return window.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}(e.replace(/-/g,"+").replace(/_/g,"/")),i=Array.from(t).reduce(((e,t)=>`${e}%${("00"+t.charCodeAt(0).toString(16)).slice(-2)}`),""),n=decodeURIComponent(i);return JSON.parse(n)}U=new WeakMap;class F{constructor(e){this[Q]="ReadablePromise",L.set(this,void 0),N.set(this,"pending"),_.set(this,void 0),j.set(this,void 0),n(this,L,e.then((e=>(n(this,N,"success","f"),n(this,_,e,"f"),e)),(e=>{throw n(this,N,"error","f"),n(this,j,e,"f"),e})),"f")}isPending(){return"pending"===i(this,N,"f")}isOk(){return"success"===i(this,N,"f")}read(){switch(i(this,N,"f")){case"pending":throw i(this,L,"f");case"error":throw i(this,j,"f");default:return i(this,_,"f")}}then(e,t){return i(this,L,"f").then(e,t)}catch(e){return i(this,L,"f").catch(e)}finally(e){return i(this,L,"f").finally(e)}}L=new WeakMap,N=new WeakMap,_=new WeakMap,j=new WeakMap,Q=Symbol.toStringTag;class H{constructor(){B.set(this,void 0),n(this,B,"undefined"!=typeof localStorage?localStorage:new $,"f")}clear(){i(this,B,"f").clear()}getString(e){return i(this,B,"f").getItem(e)||void 0}setString(e,t){t?i(this,B,"f").setItem(e,t):i(this,B,"f").removeItem(e)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?g(t):void 0)}}B=new WeakMap;class ${constructor(){W.set(this,void 0),n(this,W,new Map,"f")}get length(){return i(this,W,"f").size}clear(){i(this,W,"f").clear()}getItem(e){var t;return null!==(t=i(this,W,"f").get(e))&&void 0!==t?t:null}setItem(e,t){t?i(this,W,"f").set(e,t):i(this,W,"f").delete(e)}removeItem(e){i(this,W,"f").delete(e)}key(e){return Array.from(i(this,W,"f").keys())[e]}}W=new WeakMap;var z,G={types:{Element:{display:"Element",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]}}},BackboneElement:{display:"BackboneElement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]}}},Address:{display:"Address",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},line:{min:0,max:"*",type:[{code:"string"}]},city:{min:0,max:"1",type:[{code:"string"}]},district:{min:0,max:"1",type:[{code:"string"}]},state:{min:0,max:"1",type:[{code:"string"}]},postalCode:{min:0,max:"1",type:[{code:"string"}]},country:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Age:{display:"Age",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Annotation:{display:"Annotation",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"author[x]":{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{min:0,max:"1",type:[{code:"dateTime"}]},text:{min:1,max:"1",type:[{code:"markdown"}]}}},Attachment:{display:"Attachment",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},contentType:{min:0,max:"1",type:[{code:"code"}]},language:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]},url:{min:0,max:"1",type:[{code:"url"}]},size:{min:0,max:"1",type:[{code:"unsignedInt"}]},hash:{min:0,max:"1",type:[{code:"base64Binary"}]},title:{min:0,max:"1",type:[{code:"string"}]},creation:{min:0,max:"1",type:[{code:"dateTime"}]}}},CodeableConcept:{display:"CodeableConcept",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},coding:{min:0,max:"*",type:[{code:"Coding"}]},text:{min:0,max:"1",type:[{code:"string"}]}}},Coding:{display:"Coding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"uri"}]},version:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"1",type:[{code:"code"}]},display:{min:0,max:"1",type:[{code:"string"}]},userSelected:{min:0,max:"1",type:[{code:"boolean"}]}}},ContactDetail:{display:"ContactDetail",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"string"}]},telecom:{min:0,max:"*",type:[{code:"ContactPoint"}]}}},ContactPoint:{display:"ContactPoint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"code"}]},value:{min:0,max:"1",type:[{code:"string"}]},use:{min:0,max:"1",type:[{code:"code"}]},rank:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Contributor:{display:"Contributor",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:1,max:"1",type:[{code:"string"}]},contact:{min:0,max:"*",type:[{code:"ContactDetail"}]}}},Count:{display:"Count",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},DataRequirement:{display:"DataRequirement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{min:0,max:"1",type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{min:0,max:"*",type:[{code:"string"}]},codeFilter:{min:0,max:"*",type:[{code:"Element"}]},dateFilter:{min:0,max:"*",type:[{code:"Element"}]},limit:{min:0,max:"1",type:[{code:"positiveInt"}]},sort:{min:0,max:"*",type:[{code:"Element"}]}}},DataRequirementCodeFilter:{display:"DataRequirementCodeFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{min:0,max:"*",type:[{code:"Coding"}]}},parentType:"DataRequirement"},DataRequirementDateFilter:{display:"DataRequirementDateFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}},parentType:"DataRequirement"},DataRequirementSort:{display:"DataRequirementSort",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},direction:{min:1,max:"1",type:[{code:"code"}]}},parentType:"DataRequirement"},Distance:{display:"Distance",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Dosage:{display:"Dosage",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},sequence:{min:0,max:"1",type:[{code:"integer"}]},text:{min:0,max:"1",type:[{code:"string"}]},additionalInstruction:{min:0,max:"*",type:[{code:"CodeableConcept"}]},patientInstruction:{min:0,max:"1",type:[{code:"string"}]},timing:{min:0,max:"1",type:[{code:"Timing"}]},"asNeeded[x]":{min:0,max:"1",type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{min:0,max:"1",type:[{code:"CodeableConcept"}]},route:{min:0,max:"1",type:[{code:"CodeableConcept"}]},method:{min:0,max:"1",type:[{code:"CodeableConcept"}]},doseAndRate:{min:0,max:"*",type:[{code:"Element"}]},maxDosePerPeriod:{min:0,max:"1",type:[{code:"Ratio"}]},maxDosePerAdministration:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},DosageDoseAndRate:{display:"DosageDoseAndRate",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},"dose[x]":{min:0,max:"1",type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{min:0,max:"1",type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}},parentType:"Dosage"},Duration:{display:"Duration",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},ElementDefinition:{display:"ElementDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},representation:{min:0,max:"*",type:[{code:"code"}]},sliceName:{min:0,max:"1",type:[{code:"string"}]},sliceIsConstraining:{min:0,max:"1",type:[{code:"boolean"}]},label:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"*",type:[{code:"Coding"}]},slicing:{min:0,max:"1",type:[{code:"Element"}]},short:{min:0,max:"1",type:[{code:"string"}]},definition:{min:0,max:"1",type:[{code:"markdown"}]},comment:{min:0,max:"1",type:[{code:"markdown"}]},requirements:{min:0,max:"1",type:[{code:"markdown"}]},alias:{min:0,max:"*",type:[{code:"string"}]},min:{min:0,max:"1",type:[{code:"unsignedInt"}]},max:{min:0,max:"1",type:[{code:"string"}]},base:{min:0,max:"1",type:[{code:"Element"}]},contentReference:{min:0,max:"1",type:[{code:"uri"}]},type:{min:0,max:"*",type:[{code:"Element"}]},"defaultValue[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{min:0,max:"1",type:[{code:"markdown"}]},orderMeaning:{min:0,max:"1",type:[{code:"string"}]},"fixed[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{min:0,max:"*",type:[{code:"Element"}]},"minValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{min:0,max:"1",type:[{code:"integer"}]},condition:{min:0,max:"*",type:[{code:"id"}]},constraint:{min:0,max:"*",type:[{code:"Element"}]},mustSupport:{min:0,max:"1",type:[{code:"boolean"}]},isModifier:{min:0,max:"1",type:[{code:"boolean"}]},isModifierReason:{min:0,max:"1",type:[{code:"string"}]},isSummary:{min:0,max:"1",type:[{code:"boolean"}]},binding:{min:0,max:"1",type:[{code:"Element"}]},mapping:{min:0,max:"*",type:[{code:"Element"}]}}},ElementDefinitionSlicing:{display:"ElementDefinitionSlicing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},discriminator:{min:0,max:"*",type:[{code:"Element"}]},description:{min:0,max:"1",type:[{code:"string"}]},ordered:{min:0,max:"1",type:[{code:"boolean"}]},rules:{min:1,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionSlicingDiscriminator:{display:"ElementDefinitionSlicingDiscriminator",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},path:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinitionSlicing"},ElementDefinitionBase:{display:"ElementDefinitionBase",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},min:{min:1,max:"1",type:[{code:"unsignedInt"}]},max:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},ElementDefinitionType:{display:"ElementDefinitionType",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{min:0,max:"*",type:[{code:"code"}]},versioning:{min:0,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionExample:{display:"ElementDefinitionExample",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},label:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:1,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}},parentType:"ElementDefinition"},ElementDefinitionConstraint:{display:"ElementDefinitionConstraint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},key:{min:1,max:"1",type:[{code:"id"}]},requirements:{min:0,max:"1",type:[{code:"string"}]},severity:{min:1,max:"1",type:[{code:"code"}]},human:{min:1,max:"1",type:[{code:"string"}]},expression:{min:0,max:"1",type:[{code:"string"}]},xpath:{min:0,max:"1",type:[{code:"string"}]},source:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}},parentType:"ElementDefinition"},ElementDefinitionBinding:{display:"ElementDefinitionBinding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},strength:{min:1,max:"1",type:[{code:"code"}]},description:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}},parentType:"ElementDefinition"},ElementDefinitionMapping:{display:"ElementDefinitionMapping",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},identity:{min:1,max:"1",type:[{code:"id"}]},language:{min:0,max:"1",type:[{code:"code"}]},map:{min:1,max:"1",type:[{code:"string"}]},comment:{min:0,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},Expression:{display:"Expression",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},description:{min:0,max:"1",type:[{code:"string"}]},name:{min:0,max:"1",type:[{code:"id"}]},language:{min:1,max:"1",type:[{code:"code"}]},expression:{min:0,max:"1",type:[{code:"string"}]},reference:{min:0,max:"1",type:[{code:"uri"}]}}},Extension:{display:"Extension",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},url:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},HumanName:{display:"HumanName",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},family:{min:0,max:"1",type:[{code:"string"}]},given:{min:0,max:"*",type:[{code:"string"}]},prefix:{min:0,max:"*",type:[{code:"string"}]},suffix:{min:0,max:"*",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Identifier:{display:"Identifier",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},system:{min:0,max:"1",type:[{code:"uri"}]},value:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]},assigner:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},MarketingStatus:{display:"MarketingStatus",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},country:{min:1,max:"1",type:[{code:"CodeableConcept"}]},jurisdiction:{min:0,max:"1",type:[{code:"CodeableConcept"}]},status:{min:1,max:"1",type:[{code:"CodeableConcept"}]},dateRange:{min:1,max:"1",type:[{code:"Period"}]},restoreDate:{min:0,max:"1",type:[{code:"dateTime"}]}}},Meta:{display:"Meta",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},versionId:{min:0,max:"1",type:[{code:"id"}]},lastUpdated:{min:0,max:"1",type:[{code:"instant"}]},source:{min:0,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{min:0,max:"*",type:[{code:"Coding"}]},tag:{min:0,max:"*",type:[{code:"Coding"}]},project:{min:0,max:"1",type:[{code:"uri"}]},author:{min:0,max:"1",type:[{code:"Reference"}]},account:{min:0,max:"1",type:[{code:"Reference"}]}}},Money:{display:"Money",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},currency:{min:0,max:"1",type:[{code:"code"}]}}},Narrative:{display:"Narrative",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},status:{min:1,max:"1",type:[{code:"code"}]},div:{min:1,max:"1",type:[{code:"xhtml"}]}}},ParameterDefinition:{display:"ParameterDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"code"}]},use:{min:1,max:"1",type:[{code:"code"}]},min:{min:0,max:"1",type:[{code:"integer"}]},max:{min:0,max:"1",type:[{code:"string"}]},documentation:{min:0,max:"1",type:[{code:"string"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},Period:{display:"Period",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},start:{min:0,max:"1",type:[{code:"dateTime"}]},end:{min:0,max:"1",type:[{code:"dateTime"}]}}},Population:{display:"Population",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"age[x]":{min:0,max:"1",type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{min:0,max:"1",type:[{code:"CodeableConcept"}]},race:{min:0,max:"1",type:[{code:"CodeableConcept"}]},physiologicalCondition:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProdCharacteristic:{display:"ProdCharacteristic",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},height:{min:0,max:"1",type:[{code:"Quantity"}]},width:{min:0,max:"1",type:[{code:"Quantity"}]},depth:{min:0,max:"1",type:[{code:"Quantity"}]},weight:{min:0,max:"1",type:[{code:"Quantity"}]},nominalVolume:{min:0,max:"1",type:[{code:"Quantity"}]},externalDiameter:{min:0,max:"1",type:[{code:"Quantity"}]},shape:{min:0,max:"1",type:[{code:"string"}]},color:{min:0,max:"*",type:[{code:"string"}]},imprint:{min:0,max:"*",type:[{code:"string"}]},image:{min:0,max:"*",type:[{code:"Attachment"}]},scoring:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProductShelfLife:{display:"ProductShelfLife",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},type:{min:1,max:"1",type:[{code:"CodeableConcept"}]},period:{min:1,max:"1",type:[{code:"Quantity"}]},specialPrecautionsForStorage:{min:0,max:"*",type:[{code:"CodeableConcept"}]}}},Quantity:{display:"Quantity",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"0",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Range:{display:"Range",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},low:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Ratio:{display:"Ratio",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},numerator:{min:0,max:"1",type:[{code:"Quantity"}]},denominator:{min:0,max:"1",type:[{code:"Quantity"}]}}},Reference:{display:"Reference",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},reference:{min:0,max:"1",type:[{code:"string"}]},type:{min:0,max:"1",type:[{code:"uri"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},display:{min:0,max:"1",type:[{code:"string"}]}}},RelatedArtifact:{display:"RelatedArtifact",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},label:{min:0,max:"1",type:[{code:"string"}]},display:{min:0,max:"1",type:[{code:"string"}]},citation:{min:0,max:"1",type:[{code:"markdown"}]},url:{min:0,max:"1",type:[{code:"url"}]},document:{min:0,max:"1",type:[{code:"Attachment"}]},resource:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},SampledData:{display:"SampledData",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},origin:{min:1,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,max:"1",type:[{code:"decimal"}]},factor:{min:0,max:"1",type:[{code:"decimal"}]},lowerLimit:{min:0,max:"1",type:[{code:"decimal"}]},upperLimit:{min:0,max:"1",type:[{code:"decimal"}]},dimensions:{min:1,max:"1",type:[{code:"positiveInt"}]},data:{min:0,max:"1",type:[{code:"string"}]}}},Signature:{display:"Signature",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"*",type:[{code:"Coding"}]},when:{min:1,max:"1",type:[{code:"instant"}]},who:{min:1,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{min:0,max:"1",type:[{code:"code"}]},sigFormat:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]}}},SubstanceAmount:{display:"SubstanceAmount",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"amount[x]":{min:0,max:"1",type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{min:0,max:"1",type:[{code:"CodeableConcept"}]},amountText:{min:0,max:"1",type:[{code:"string"}]},referenceRange:{min:0,max:"1",type:[{code:"Element"}]}}},SubstanceAmountReferenceRange:{display:"SubstanceAmountReferenceRange",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},lowLimit:{min:0,max:"1",type:[{code:"Quantity"}]},highLimit:{min:0,max:"1",type:[{code:"Quantity"}]}},parentType:"SubstanceAmount"},Timing:{display:"Timing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},event:{min:0,max:"*",type:[{code:"dateTime"}]},repeat:{min:0,max:"1",type:[{code:"Element"}]},code:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},TimingRepeat:{display:"TimingRepeat",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"bounds[x]":{min:0,max:"1",type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{min:0,max:"1",type:[{code:"positiveInt"}]},countMax:{min:0,max:"1",type:[{code:"positiveInt"}]},duration:{min:0,max:"1",type:[{code:"decimal"}]},durationMax:{min:0,max:"1",type:[{code:"decimal"}]},durationUnit:{min:0,max:"1",type:[{code:"code"}]},frequency:{min:0,max:"1",type:[{code:"positiveInt"}]},frequencyMax:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"decimal"}]},periodMax:{min:0,max:"1",type:[{code:"decimal"}]},periodUnit:{min:0,max:"1",type:[{code:"code"}]},dayOfWeek:{min:0,max:"*",type:[{code:"code"}]},timeOfDay:{min:0,max:"*",type:[{code:"time"}]},when:{min:0,max:"*",type:[{code:"code"}]},offset:{min:0,max:"1",type:[{code:"unsignedInt"}]}},parentType:"Timing"},TriggerDefinition:{display:"TriggerDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:0,max:"1",type:[{code:"string"}]},"timing[x]":{min:0,max:"1",type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{min:0,max:"*",type:[{code:"DataRequirement"}]},condition:{min:0,max:"1",type:[{code:"Expression"}]}}},UsageContext:{display:"UsageContext",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"Coding"}]},"value[x]":{min:1,max:"1",type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}}}};function V(e,t){return{display:e,description:t,properties:{},searchParams:{_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"}}}}function X(e,t){var i;const n=t.name;if(!n)return;n in e.types||(e.types[n]=V(n,t.description));const o=null===(i=t.snapshot)||void 0===i?void 0:i.element;if(o){const t=o.filter((e=>e.path!==n&&e.path));t.forEach((t=>function(e,t){var i,n;const o=t.path,r=null===(n=null===(i=t.type)||void 0===i?void 0:i[0])||void 0===n?void 0:n.code;if("Element"!==r&&"BackboneElement"!==r)return;const a=o.split("."),s=J(a);s in e.types||(e.types[s]=V(s,t.definition),e.types[s].parentType=J(a.slice(0,a.length-1)))}(e,t))),t.forEach((t=>function(e,t){const i=t.path.split(".");if(1===i.length)return;const n=J(i.slice(0,i.length-1)),o=e.types[n];if(!o)return;const r=i[i.length-1];o.properties[r]=t}(e,t)))}}function Y(e,t){if(t.base)for(const i of t.base){const n=e.types[i];n&&(n.searchParams||(n.searchParams={}),n.searchParams[t.code]=t)}}function J(e){return e.map(D).join("")}e.PropertyType=void 0,(z=e.PropertyType||(e.PropertyType={})).Address="Address",z.Age="Age",z.Annotation="Annotation",z.Attachment="Attachment",z.BackboneElement="BackboneElement",z.CodeableConcept="CodeableConcept",z.Coding="Coding",z.ContactDetail="ContactDetail",z.ContactPoint="ContactPoint",z.Contributor="Contributor",z.Count="Count",z.DataRequirement="DataRequirement",z.Distance="Distance",z.Dosage="Dosage",z.Duration="Duration",z.Expression="Expression",z.Extension="Extension",z.HumanName="HumanName",z.Identifier="Identifier",z.MarketingStatus="MarketingStatus",z.Meta="Meta",z.Money="Money",z.Narrative="Narrative",z.ParameterDefinition="ParameterDefinition",z.Period="Period",z.Population="Population",z.ProdCharacteristic="ProdCharacteristic",z.ProductShelfLife="ProductShelfLife",z.Quantity="Quantity",z.Range="Range",z.Ratio="Ratio",z.Reference="Reference",z.RelatedArtifact="RelatedArtifact",z.SampledData="SampledData",z.Signature="Signature",z.SubstanceAmount="SubstanceAmount",z.SystemString="http://hl7.org/fhirpath/System.String",z.Timing="Timing",z.TriggerDefinition="TriggerDefinition",z.UsageContext="UsageContext",z.base64Binary="base64Binary",z.boolean="boolean",z.canonical="canonical",z.code="code",z.date="date",z.dateTime="dateTime",z.decimal="decimal",z.id="id",z.instant="instant",z.integer="integer",z.markdown="markdown",z.oid="oid",z.positiveInt="positiveInt",z.string="string",z.time="time",z.unsignedInt="unsignedInt",z.uri="uri",z.url="url",z.uuid="uuid";const K=G;var Z,ee,te,ie,ne,oe,re,ae,se,ce,de,le,ue,me,pe,he,fe,ye,ge,xe,ve,Ee,Te,we,Se,be,Pe,De,Ce,Ae,Re,Oe,ke;const Ie="launch/patient openid fhirUser offline_access user/*.*";function Me(){return window.location.protocol+"//"+window.location.host+"/"}function Ue(t){return[{type:e.PropertyType.boolean,value:t}]}function Le(t){return null==t?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:e.PropertyType.integer,value:t}:"number"==typeof t?{type:e.PropertyType.decimal,value:t}:"boolean"==typeof t?{type:e.PropertyType.boolean,value:t}:"string"==typeof t?{type:e.PropertyType.string,value:t}:Ge(t)?{type:e.PropertyType.Quantity,value:t}:"object"==typeof t&&"resourceType"in t?{type:t.resourceType,value:t}:{type:e.PropertyType.BackboneElement,value:t}}function Ne(e){return 0!==e.length&&!!e[0].value}function _e(e,t){if(!(null==e?void 0:e.value))return;const i=K.types[e.type];if(i){const n=function(e,t,i){var n;const o=null!==(n=i.properties[t])&&void 0!==n?n:i.properties[t+"[x]"];if(!o)return;const r=o.type;if(!r||0===r.length)return;let a,s,c="undefined";if(1===r.length)a=t,s=e.value[t],c=r[0].code;else for(const i of r){const n=t.replace("[x]","")+D(i.code);if(n in e.value){a=n,s=e.value[n],c=i.code;break}}if(void 0===s)return;"BackboneElement"===c&&(c=J([e.type,a]));return Array.isArray(s)?s.map((e=>({value:e,type:c}))):{value:s,type:c}}(e,t,i);if(n)return n}return function(e,t){const i=e.value;if(!i||"object"!=typeof i)return;let n;if(t in i)n=i[t];else{const e=Object.keys(i).find((e=>e.startsWith(t)));e&&(n=i[e])}if(void 0===n)return;return Array.isArray(n)?n.map(Le):Le(n)}(e,t)}function je(e){const t=[];for(const i of e){let e=!1;for(const n of t)if(Ne(We(i,n))){e=!0;break}e||t.push(i)}return t}function Qe(e){return Ue(!Ne(e))}function Be(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?Ue(!1):Ue(e.every(((e,i)=>Ne(We(e,t[i])))))}function We(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Ue(Math.abs(i-n)<1e-8):Ge(i)&&Ge(n)?Ue(Ve(i,n)):Ue("object"==typeof i&&"object"==typeof n?Xe(e,t):i===n)}function qe(e,t){return 0===e.length&&0===t.length?Ue(!0):e.length!==t.length?Ue(!1):(e.sort(He),t.sort(He),Ue(e.every(((e,i)=>Ne(Fe(e,t[i]))))))}function Fe(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Ue(Math.abs(i-n)<.01):Ge(i)&&Ge(n)?Ue(Ve(i,n)):Ue("object"==typeof i&&"object"==typeof n?Xe(i,n):"string"==typeof i&&"string"==typeof n?i.toLowerCase()===n.toLowerCase():i===n)}function He(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?i-n:"string"==typeof i&&"string"==typeof n?i.localeCompare(n):0}function $e(e,t){const{value:i}=e;if(null==i)return!1;switch(t){case"Boolean":return"boolean"==typeof i;case"Decimal":case"Integer":return"number"==typeof i;case"Date":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof i&&!!i.match(/^T\d/);case"Period":return ze(i);case"Quantity":return Ge(i);default:return"object"==typeof i&&(null==i?void 0:i.resourceType)===t}}function ze(e){return!(!e||"object"!=typeof e||!("start"in e))}function Ge(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function Ve(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function Xe(e,t){const i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(const n of i){const i=e[n],o=t[n];if(Ye(i)&&Ye(o)){if(!Xe(i,o))return!1}else if(i!==o)return!1}return!0}function Ye(e){return null!==e&&"object"==typeof e}var Je,Ke;ee=new WeakMap,te=new WeakMap,ie=new WeakMap,ne=new WeakMap,oe=new WeakMap,re=new WeakMap,ae=new WeakMap,se=new WeakMap,ce=new WeakMap,de=new WeakMap,le=new WeakMap,ue=new WeakMap,me=new WeakMap,pe=new WeakMap,he=new WeakMap,fe=new WeakMap,ye=new WeakMap,Z=new WeakSet,ge=function(e){const t=this.getLogins().filter((t=>{var i,n;return(null===(i=t.profile)||void 0===i?void 0:i.reference)!==(null===(n=e.profile)||void 0===n?void 0:n.reference)}));t.push(e),i(this,ie,"f").setObject("logins",t)},xe=function(){return t(this,void 0,void 0,(function*(){return n(this,he,new Promise(((e,t)=>{this.get("auth/me").then((t=>{n(this,he,void 0,"f"),n(this,fe,t.profile,"f"),n(this,ye,t.config,"f"),this.dispatchEvent({type:"change"}),e(i(this,fe,"f"))})).catch(t)})),"f"),i(this,he,"f")}))},ve=function(e,t){if(i(this,oe,"f")<=0||"no-cache"===(null==t?void 0:t.cache)||"reload"===(null==t?void 0:t.cache))return;const n=i(this,ne,"f").get(e);return!n||n.requestTime+i(this,oe,"f")<Date.now()?void 0:n},Ee=function(e,t){i(this,oe,"f")>0&&i(this,ne,"f").set(e,{requestTime:Date.now(),value:t})},Te=function(e,n,o={}){return t(this,void 0,void 0,(function*(){i(this,pe,"f")&&(yield i(this,pe,"f")),n.startsWith("http")||(n=i(this,re,"f")+n),o.method=e,i(this,Z,"m",we).call(this,o);const t=yield i(this,ee,"f").call(this,n,o);if(401===t.status)return i(this,Z,"m",Pe).call(this,e,n,o);if(204===t.status||304===t.status)return;const r=yield t.json();if(t.status>=400)throw r;return r}))},we=function(e){e.headers||(e.headers={});const t=e.headers;t["Content-Type"]||(t["Content-Type"]="application/fhir+json"),i(this,ue,"f")&&(t.Authorization="Bearer "+i(this,ue,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},Se=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},be=function(e,t){"string"==typeof t||"undefined"!=typeof Blob&&t instanceof Blob||"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Uint8Array&&t instanceof Uint8Array?e.body=t:t&&(e.body=JSON.stringify(t))},Pe=function(e,n,o){return t(this,void 0,void 0,(function*(){return i(this,Z,"m",Ae).call(this).then((()=>i(this,Z,"m",Te).call(this,e,n,o))).catch((e=>(this.clear(),i(this,le,"f")&&i(this,le,"f").call(this),Promise.reject(e))))}))},De=function(){return t(this,void 0,void 0,(function*(){const e=M();i(this,ie,"f").setString("pkceState",e);const n=M();i(this,ie,"f").setString("codeVerifier",n);const o=P(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");i(this,ie,"f").setString("codeChallenge",o)}))},Ce=function(){i(this,Z,"m",De).call(this);const e=new URL(i(this,se,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",i(this,ie,"f").getString("pkceState")),e.searchParams.set("client_id",i(this,ae,"f")),e.searchParams.set("redirect_uri",Me()),e.searchParams.set("scope",Ie),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",i(this,ie,"f").getString("codeChallenge")),window.location.assign(e.toString())},Ae=function(){return t(this,void 0,void 0,(function*(){if(i(this,pe,"f"))return i(this,pe,"f");if(!i(this,me,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",i(this,ae,"f")),e.set("refresh_token",i(this,me,"f")),n(this,pe,i(this,Z,"m",Re).call(this,e),"f"),yield i(this,pe,"f")}))},Re=function(e){return t(this,void 0,void 0,(function*(){return i(this,ee,"f").call(this,i(this,ce,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>i(this,Z,"m",Oe).call(this,e))).then((()=>this.getProfile()))}))},Oe=function(e){return t(this,void 0,void 0,(function*(){const t=e.access_token,n=function(e){const[t,i,n]=e.split(".");return q(i)}(t);if(Date.now()>=1e3*n.exp)throw this.clear(),new Error("Token expired");if(i(this,ae,"f")&&n.client_id!==i(this,ae,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}))},ke=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};class Ze{constructor(e,t){this.original=e,this.child=t}eval(e){try{return e.length>0?e.map((e=>this.child.eval([e]))).flat():this.child.eval([])}catch(e){throw new Error(`FhirPathError on "${this.original}": ${e}`)}}}class et{constructor(e){this.value=e}eval(){return[this.value]}}class tt{constructor(e){this.name=e,Je.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>i(this,Je,"m",Ke).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}Je=new WeakSet,Ke=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:_e(e,this.name)};class it{eval(){return[]}}class nt{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class ot{constructor(e,t){this.left=e,this.right=t}eval(e){return this.left.eval(e)}}class rt{constructor(e,t,i){this.left=e,this.right=t,this.impl=i}eval(t){const i=this.left.eval(t);if(1!==i.length)return[];const n=this.right.eval(t);if(1!==n.length)return[];const o=i[0].value,r=n[0].value,a=Ge(o)?o.value:o,s=Ge(r)?r.value:r,c=this.impl(a,s);return"boolean"==typeof c?Ue(c):Ge(o)?[{type:e.PropertyType.Quantity,value:Object.assign(Object.assign({},o),{value:c})}]:[Le(c)]}}class at{constructor(e,t){this.left=e,this.right=t}eval(t){const i=[...this.left.eval(t),...this.right.eval(t)];return i.length>0&&i.every((e=>"string"==typeof e.value))?[{type:e.PropertyType.string,value:i.map((e=>e.value)).join("")}]:i}}class st{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);return Ue(t.some((e=>e.value===i[0].value)))}}class ct{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);return Ue(this.right.eval(e).some((e=>e.value===t[0].value)))}}class dt{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class lt{constructor(e,t){this.left=e,this.right=t}eval(e){return je([...this.left.eval(e),...this.right.eval(e)])}}class ut{constructor(e,t){this.left=e,this.right=t}eval(e){return Be(this.left.eval(e),this.right.eval(e))}}class mt{constructor(e,t){this.left=e,this.right=t}eval(e){return Qe(Be(this.left.eval(e),this.right.eval(e)))}}class pt{constructor(e,t){this.left=e,this.right=t}eval(e){return qe(this.left.eval(e),this.right.eval(e))}}class ht{constructor(e,t){this.left=e,this.right=t}eval(e){return Qe(qe(this.left.eval(e),this.right.eval(e)))}}class ft{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const i=this.right.name;return Ue($e(t[0],i))}}class yt{constructor(e,t){this.left=e,this.right=t}eval(e){var t,i,n,o;const r=this.left.eval(e),a=this.right.eval(e);return!0===(null===(t=r[0])||void 0===t?void 0:t.value)&&!0===(null===(i=a[0])||void 0===i?void 0:i.value)?Ue(!0):!1===(null===(n=r[0])||void 0===n?void 0:n.value)||!1===(null===(o=a[0])||void 0===o?void 0:o.value)?Ue(!1):[]}}class gt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(Ne(t))return t;const i=this.right.eval(e);return Ne(i)?i:[]}}class xt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);if(0===t.length&&0===i.length)return[];const n=0===t.length?null:t[0].value,o=0===i.length?null:i[0].value;return!0===n&&!0!==o||!0!==n&&!0===o?Ue(!0):!0===n&&!0===o||!1===n&&!1===o?Ue(!1):[]}}class vt{constructor(e,t,i){this.name=e,this.args=t,this.impl=i}eval(e){return this.impl(e,...this.args)}}class Et{constructor(e,t){this.left=e,this.expr=t}eval(e){const t=this.expr.eval(e);if(1!==t.length)return[];const i=t[0].value;if("number"!=typeof i)throw new Error("Invalid indexer expression: should return integer}");const n=this.left.eval(e);return i in n?[n[i]]:[]}}function Tt(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch(t){return e}}const wt=()=>[],St={empty:e=>Ue(0===e.length),exists:(e,t)=>Ue(t?e.filter((e=>Ne(t.eval([e])))).length>0:e.length>0),all:(e,t)=>Ue(e.every((e=>Ne(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return Ue(!1);return Ue(!0)},anyTrue:e=>{for(const t of e)if(t.value)return Ue(!0);return Ue(!1)},allFalse:e=>{for(const t of e)if(t.value)return Ue(!1);return Ue(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return Ue(!0);return Ue(!1)},subsetOf:wt,supersetOf:wt,count:t=>[{type:e.PropertyType.integer,value:t.length}],distinct:e=>{const t=[];for(const i of e)t.some((e=>e.value===i.value))||t.push(i);return t},isDistinct:e=>Ue(e.length===St.distinct(e).length),where:(e,t)=>e.filter((e=>Ne(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:wt,ofType:wt,single:e=>{if(e.length>1)throw new Error("Expected input length one for single()");return 0===e.length?[]:e.slice(0,1)},first:e=>0===e.length?[]:e.slice(0,1),last:e=>0===e.length?[]:e.slice(e.length-1,e.length),tail:e=>0===e.length?[]:e.slice(1,e.length),skip:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for skip(num)");return n>=e.length?[]:n<=0?e:e.slice(n,e.length)},take:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for take(num)");return n>=e.length?e:n<=0?[]:e.slice(0,n)},intersect:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)!n.some((e=>e.value===t.value))&&i.some((e=>e.value===t.value))&&n.push(t);return n},exclude:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)i.some((e=>e.value===t.value))||n.push(t);return n},union:(e,t)=>{if(!t)return e;const i=t.eval(e);return je([...e,...i])},combine:(e,t)=>{if(!t)return e;const i=t.eval(e);return[...e,...i]},iif:(e,t,i,n)=>{const o=t.eval(e);if(o.length>1||1===o.length&&"boolean"!=typeof o[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return Ne(o)?i.eval(e):n?n.eval(e):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);if("boolean"==typeof i)return[{type:e.PropertyType.boolean,value:i}];if("number"==typeof i&&(0===i||1===i))return Ue(!!i);if("string"==typeof i){const e=i.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return Ue(!0);if(["false","f","no","n","0","0.0"].includes(e))return Ue(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:Ue(1===St.toBoolean(e).length),toInteger:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"number"==typeof i?[{type:e.PropertyType.integer,value:i}]:"string"==typeof i&&i.match(/^[+-]?\d+$/)?[{type:e.PropertyType.integer,value:parseInt(i,10)}]:"boolean"==typeof i?[{type:e.PropertyType.integer,value:i?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:Ue(1===St.toInteger(e).length),toDate:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.date,value:Tt(i)}]:[]},convertsToDate:e=>0===e.length?[]:Ue(1===St.toDate(e).length),toDateTime:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.dateTime,value:Tt(i)}]:[]},convertsToDateTime:e=>0===e.length?[]:Ue(1===St.toDateTime(e).length),toDecimal:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return"number"==typeof i?[{type:e.PropertyType.decimal,value:i}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:e.PropertyType.decimal,value:parseFloat(i)}]:"boolean"==typeof i?[{type:e.PropertyType.decimal,value:i?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:Ue(1===St.toDecimal(e).length),toQuantity:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return Ge(i)?[{type:e.PropertyType.Quantity,value:i}]:"number"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i,unit:"1"}}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:e.PropertyType.Quantity,value:{value:parseFloat(i),unit:"1"}}]:"boolean"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:Ue(1===St.toQuantity(e).length),toString:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);return null==i?[]:Ge(i)?[{type:e.PropertyType.string,value:`${i.value} '${i.unit}'`}]:[{type:e.PropertyType.string,value:i.toString()}]},convertsToString:e=>0===e.length?[]:Ue(1===St.toString(e).length),toTime:t=>{if(0===t.length)return[];const[{value:i}]=Dt(t,1);if("string"==typeof i){const t=i.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:e.PropertyType.time,value:Tt("T"+t[1])}]}return[]},convertsToTime:e=>0===e.length?[]:Ue(1===St.toTime(e).length),indexOf:(e,t)=>bt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,i)=>bt(((e,t,i)=>{const n=t,o=i?n+i:e.length;return n<0||n>=e.length?void 0:e.substring(n,o)}),e,t,i),startsWith:(e,t)=>bt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>bt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>bt(((e,t)=>e.includes(t)),e,t),upper:e=>bt((e=>e.toUpperCase()),e),lower:e=>bt((e=>e.toLowerCase()),e),replace:(e,t,i)=>bt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),matches:(e,t)=>bt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,i)=>bt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),length:e=>bt((e=>e.length),e),toChars:e=>bt((e=>e?e.split(""):void 0),e),abs:e=>Pt(Math.abs,e),ceiling:e=>Pt(Math.ceil,e),exp:e=>Pt(Math.exp,e),floor:e=>Pt(Math.floor,e),ln:e=>Pt(Math.log,e),log:(e,t)=>Pt(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>Pt(Math.pow,e,t),round:e=>Pt(Math.round,e),sqrt:e=>Pt(Math.sqrt,e),truncate:e=>Pt((e=>0|e),e),children:wt,descendants:wt,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:e.PropertyType.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:e.PropertyType.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:e.PropertyType.date,value:(new Date).toISOString().substring(0,10)}],between:(t,i,n,o)=>{var r;const a=St.toDateTime(i.eval(t));if(0===a.length)throw new Error("Invalid start date");const s=St.toDateTime(n.eval(t));if(0===s.length)throw new Error("Invalid end date");const c=null===(r=o.eval(t)[0])||void 0===r?void 0:r.value;if("years"!==c&&"months"!==c&&"days"!==c)throw new Error("Invalid units");const d=f(a[0].value,s[0].value);return[{type:e.PropertyType.Quantity,value:{value:d[c],unit:c}}]},is:(t,i)=>{let n="";return i instanceof tt?n=i.name:i instanceof dt&&(n=i.left.name+"."+i.right.name),n?t.map((t=>({type:e.PropertyType.boolean,value:$e(t,n)}))):[]},not:t=>St.toBoolean(t).map((t=>({type:e.PropertyType.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const i=t.value;let n;if("string"==typeof i)n=i;else if("object"==typeof i){const e=i;if(e.resource)return Le(e.resource);n=e.reference}if(!n)return{type:e.PropertyType.BackboneElement,value:null};const[o,r]=n.split("/");return{type:e.PropertyType.BackboneElement,value:{resourceType:o,id:r}}})).filter((e=>!!e.value)),as:e=>e,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:e.PropertyType.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:e.PropertyType.BackboneElement,value:null})),conformsTo:(t,i)=>{const n=i.eval(t)[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=n.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var i;return{type:e.PropertyType.boolean,value:(null===(i=t.value)||void 0===i?void 0:i.resourceType)===o}}))}};function bt(e,t,...i){if(0===t.length)return[];const[{value:n}]=Dt(t,1);if("string"!=typeof n)throw new Error("String function cannot be called with non-string");const o=e(n,...i.map((e=>{var i,n;return e&&(null===(n=null===(i=e.eval(t))||void 0===i?void 0:i[0])||void 0===n?void 0:n.value)})));return void 0===o?[]:Array.isArray(o)?o.map(Le):[Le(o)]}function Pt(t,i,...n){if(0===i.length)return[];const[{value:o}]=Dt(i,1),r=Ge(o),a=r?o.value:o;if("number"!=typeof a)throw new Error("Math function cannot be called with non-number");const s=t(a,...n.map((e=>{var t,n;return null===(n=null===(t=e.eval(i))||void 0===t?void 0:t[0])||void 0===n?void 0:n.value})));return[{type:r?e.PropertyType.Quantity:i[0].type,value:r?Object.assign(Object.assign({},o),{value:s}):s}]}function Dt(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const t of e)if(null==t)throw new Error("Expected non-null argument");return e}var Ct,At,Rt,Ot,kt,It,Mt,Ut,Lt,Nt,_t,jt,Qt,Bt,Wt,qt,Ft,Ht;function $t(e){return new Vt(e).tokenize()}const zt=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],Gt=["!=","!~","<=",">=","{}"];class Vt{constructor(e){Ct.add(this),At.set(this,void 0),Rt.set(this,void 0),n(this,At,e,"f"),n(this,Rt,0,"f")}tokenize(){const e=[];for(;i(this,Rt,"f")<i(this,At,"f").length;){const t=i(this,Ct,"m",kt).call(this);t&&e.push(t)}return e}}function Xt(e,t){return{id:e,value:t}}var Yt,Jt,Kt,Zt,ei,ti,ii,ni,oi;At=new WeakMap,Rt=new WeakMap,Ct=new WeakSet,Ot=function(){const e=i(this,Rt,"f"),t=i(this,Ct,"m",kt).call(this);return n(this,Rt,e,"f"),t},kt=function(){i(this,Ct,"m",It).call(this);const e=i(this,Ct,"m",qt).call(this);if(!e)return;const t=i(this,Ct,"m",Ht).call(this);return"/"===e&&"*"===t?i(this,Ct,"m",Mt).call(this):"/"===e&&"/"===t?i(this,Ct,"m",Ut).call(this):"'"===e?i(this,Ct,"m",Lt).call(this):"`"===e?i(this,Ct,"m",Nt).call(this):"@"===e?i(this,Ct,"m",_t).call(this):e.match(/\d/)?i(this,Ct,"m",jt).call(this):e.match(/\w/)||"$"===e&&t.match(/\w/)?i(this,Ct,"m",Qt).call(this):i(this,Ct,"m",Bt).call(this)},It=function(){return Xt("Whitespace",i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/\s/))))},Mt=function(){const e=i(this,Rt,"f");return i(this,Ct,"m",Wt).call(this,(()=>"*"!==i(this,Ct,"m",qt).call(this)||"/"!==i(this,Ct,"m",Ht).call(this))),n(this,Rt,i(this,Rt,"f")+2,"f"),Xt("Comment",i(this,At,"f").substring(e,i(this,Rt,"f")))},Ut=function(){return Xt("Comment",i(this,Ct,"m",Wt).call(this,(()=>"\n"!==i(this,Ct,"m",qt).call(this))))},Lt=function(){var e,t;n(this,Rt,(e=i(this,Rt,"f"),++e),"f");const o=Xt("String",i(this,Ct,"m",Wt).call(this,(()=>"\\"===i(this,Ct,"m",Ft).call(this)||"'"!==i(this,Ct,"m",qt).call(this))));return n(this,Rt,(t=i(this,Rt,"f"),++t),"f"),o},Nt=function(){var e,t;n(this,Rt,(e=i(this,Rt,"f"),++e),"f");const o=Xt("Symbol",i(this,Ct,"m",Wt).call(this,(()=>"`"!==i(this,Ct,"m",qt).call(this))));return n(this,Rt,(t=i(this,Rt,"f"),++t),"f"),o},_t=function(){var e,t,o,r,a;const s=i(this,Rt,"f");return n(this,Rt,(e=i(this,Rt,"f"),++e),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d-]/))),"T"===i(this,Ct,"m",qt).call(this)&&(n(this,Rt,(t=i(this,Rt,"f"),++t),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d:]/))),"."===i(this,Ct,"m",qt).call(this)&&i(this,Ct,"m",Ht).call(this).match(/\d/)&&(n(this,Rt,(o=i(this,Rt,"f"),++o),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d]/)))),"Z"===i(this,Ct,"m",qt).call(this)?n(this,Rt,(r=i(this,Rt,"f"),++r),"f"):"+"!==i(this,Ct,"m",qt).call(this)&&"-"!==i(this,Ct,"m",qt).call(this)||(n(this,Rt,(a=i(this,Rt,"f"),++a),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[\d:]/))))),Xt("DateTime",i(this,At,"f").substring(s+1,i(this,Rt,"f")))},jt=function(){var e;const t=i(this,Rt,"f");let o="Number";return i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/\d/))),"."===i(this,Ct,"m",qt).call(this)&&i(this,Ct,"m",Ht).call(this).match(/\d/)&&(n(this,Rt,(e=i(this,Rt,"f"),++e),"f"),i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/\d/))))," "===i(this,Ct,"m",qt).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&zt.includes(e.value))return!0}return!1}(i(this,Ct,"m",Ot).call(this))&&(o="Quantity",i(this,Ct,"m",kt).call(this)),Xt(o,i(this,At,"f").substring(t,i(this,Rt,"f")))},Qt=function(){return Xt("Symbol",i(this,Ct,"m",Wt).call(this,(()=>i(this,Ct,"m",qt).call(this).match(/[$\w]/))))},Bt=function(){var e;const t=i(this,Ct,"m",qt).call(this),o=t+i(this,Ct,"m",Ht).call(this);return Gt.includes(o)?(n(this,Rt,i(this,Rt,"f")+2,"f"),Xt(o,o)):(n(this,Rt,(e=i(this,Rt,"f"),++e),"f"),Xt(t,t))},Wt=function(e){var t;const o=i(this,Rt,"f");for(;i(this,Rt,"f")<i(this,At,"f").length&&e();)n(this,Rt,(t=i(this,Rt,"f"),++t),"f");return i(this,At,"f").substring(o,i(this,Rt,"f"))},qt=function(){return i(this,At,"f")[i(this,Rt,"f")]},Ft=function(){var e;return null!==(e=i(this,At,"f")[i(this,Rt,"f")-1])&&void 0!==e?e:""},Ht=function(){var e;return null!==(e=i(this,At,"f")[i(this,Rt,"f")+1])&&void 0!==e?e:""};Yt=new WeakMap,Jt=new WeakMap;class ri{constructor(e,t,i){Kt.add(this),Zt.set(this,void 0),ei.set(this,void 0),ti.set(this,void 0),n(this,Zt,e,"f"),n(this,ei,t,"f"),n(this,ti,i,"f")}match(e){const t=i(this,Kt,"m",oi).call(this);return(null==t?void 0:t.id)===e&&(i(this,Kt,"m",ni).call(this),!0)}consumeAndParse(e=100){const t=i(this,Kt,"m",ni).call(this),n=i(this,ei,"f")[t.id];if(!n)throw Error(`Parse error at ${t.value}. No matching prefix parselet.`);let o=n.parse(this,t);for(;e>i(this,Kt,"m",ii).call(this);){const e=i(this,Kt,"m",ni).call(this);o=i(this,ti,"f")[e.id].parse(this,o,e)}return o}}Zt=new WeakMap,ei=new WeakMap,ti=new WeakMap,Kt=new WeakSet,ii=function(){const e=i(this,Kt,"m",oi).call(this);if(!e)return 100;const t=i(this,ti,"f")[e.id];return t?t.precedence:100},ni=function(){if(!i(this,Zt,"f").length)throw Error("Cant consume unknown more tokens.");return i(this,Zt,"f").shift()},oi=function(){return i(this,Zt,"f").length>0?i(this,Zt,"f")[0]:void 0};const ai={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},si={parse(e,t){const i=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new Et(t,i)},precedence:2},ci={parse(e,t){if(!(t instanceof tt))throw new Error("Unexpected parentheses");if(!(t.name in St))throw new Error("Unrecognized function: "+t.name);const i=[];for(;!e.match(")");)i.push(e.consumeAndParse()),e.match(",");return new vt(t.name,i,St[t.name])},precedence:0};function di(e){const t=e.split(" "),i=parseFloat(t[0]);let n=t[1];return n=n&&n.startsWith("'")&&n.endsWith("'")?n.substring(1,n.length-1):"{"+n+"}",{value:i,unit:n}}const li=(new class{constructor(){Yt.set(this,{}),Jt.set(this,{})}registerInfix(e,t){return i(this,Jt,"f")[e]=t,this}registerPrefix(e,t){return i(this,Yt,"f")[e]=t,this}prefix(e,t,i){return this.registerPrefix(e,{parse(e,n){const o=e.consumeAndParse(t);return i(n,o)}})}infixLeft(e,t,i){return this.registerInfix(e,{parse(e,n,o){const r=e.consumeAndParse(t);return i(n,o,r)},precedence:t})}construct(e){return new ri($t(e),i(this,Yt,"f"),i(this,Jt,"f"))}}).registerPrefix("String",{parse:(t,i)=>new et({type:e.PropertyType.string,value:i.value})}).registerPrefix("DateTime",{parse:(t,i)=>new et({type:e.PropertyType.dateTime,value:Tt(i.value)})}).registerPrefix("Quantity",{parse:(t,i)=>new et({type:e.PropertyType.Quantity,value:di(i.value)})}).registerPrefix("Number",{parse:(t,i)=>new et({type:e.PropertyType.decimal,value:parseFloat(i.value)})}).registerPrefix("Symbol",{parse:(t,i)=>"false"===i.value?new et({type:e.PropertyType.boolean,value:!1}):"true"===i.value?new et({type:e.PropertyType.boolean,value:!0}):new tt(i.value)}).registerPrefix("{}",{parse:()=>new it}).registerPrefix("(",ai).registerInfix("[",si).registerInfix("(",ci).prefix("+",3,((e,t)=>new nt(t,(e=>e)))).prefix("-",3,((e,t)=>new rt(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,i)=>new dt(e,i))).infixLeft("/",4,((e,t,i)=>new rt(e,i,((e,t)=>e/t)))).infixLeft("*",4,((e,t,i)=>new rt(e,i,((e,t)=>e*t)))).infixLeft("+",5,((e,t,i)=>new rt(e,i,((e,t)=>e+t)))).infixLeft("-",5,((e,t,i)=>new rt(e,i,((e,t)=>e-t)))).infixLeft("|",7,((e,t,i)=>new lt(e,i))).infixLeft("=",9,((e,t,i)=>new ut(e,i))).infixLeft("!=",9,((e,t,i)=>new mt(e,i))).infixLeft("~",9,((e,t,i)=>new pt(e,i))).infixLeft("!~",9,((e,t,i)=>new ht(e,i))).infixLeft("<",8,((e,t,i)=>new rt(e,i,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,i)=>new rt(e,i,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,i)=>new rt(e,i,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,i)=>new rt(e,i,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,i)=>new at(e,i))).infixLeft("Symbol",6,((e,t,i)=>{switch(t.value){case"and":return new yt(e,i);case"as":return new ot(e,i);case"contains":return new st(e,i);case"div":return new rt(e,i,((e,t)=>e/t|0));case"in":return new ct(e,i);case"is":return new ft(e,i);case"mod":return new rt(e,i,((e,t)=>e%t));case"or":return new gt(e,i);case"xor":return new xt(e,i);default:throw new Error("Cannot use "+t.value+" as infix operator")}}));function ui(e){try{return new Ze(e,li.construct(e).consumeAndParse())}catch(t){throw new Error(`FhirPathError on "${e}": ${t}`)}}function mi(e,t){return ui(e).eval(t)}class pi{constructor(e){this.segments=e}get(e){return"number"==typeof e?this.segments[e]:this.segments.find((t=>t.name===e))}getAll(e){return this.segments.filter((t=>t.name===e))}toString(){return this.segments.map((e=>e.toString())).join("\r")}buildAck(){var e,t,i,n,o,r;const a=new Date,s=this.get("MSH"),c=(null===(e=null==s?void 0:s.get(2))||void 0===e?void 0:e.toString())||"",d=(null===(t=null==s?void 0:s.get(3))||void 0===t?void 0:t.toString())||"",l=(null===(i=null==s?void 0:s.get(4))||void 0===i?void 0:i.toString())||"",u=(null===(n=null==s?void 0:s.get(5))||void 0===n?void 0:n.toString())||"",m=(null===(o=null==s?void 0:s.get(9))||void 0===o?void 0:o.toString())||"",p=(null===(r=null==s?void 0:s.get(12))||void 0===r?void 0:r.toString())||"2.5.1";return new pi([new hi(["MSH","^~\\&",l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p]),new hi(["MSA","AA",m,"OK"])])}static parse(e){if(!e.startsWith("MSH|^~\\&")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}return new pi(e.split(/[\r\n]+/).map((e=>hi.parse(e))))}}class hi{constructor(e){w(e)?this.fields=e.map((e=>fi.parse(e))):this.fields=e,this.name=this.fields[0].components[0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join("|")}static parse(e){return new hi(e.split("|").map((e=>fi.parse(e))))}}class fi{constructor(e){this.components=e}get(e){return this.components[e]}toString(){return this.components.join("^")}static parse(e){return new fi(e.split("^"))}}const yi="ok",gi="created",xi="gone",vi="not-modified",Ei="not-found",Ti="access-denied",wi={resourceType:"OperationOutcome",id:yi,issue:[{severity:"information",code:"information",details:{text:"All OK"}}]},Si={resourceType:"OperationOutcome",id:gi,issue:[{severity:"information",code:"information",details:{text:"Created"}}]},bi={resourceType:"OperationOutcome",id:vi,issue:[{severity:"information",code:"information",details:{text:"Not Modified"}}]},Pi={resourceType:"OperationOutcome",id:Ei,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},Di={resourceType:"OperationOutcome",id:xi,issue:[{severity:"error",code:"gone",details:{text:"Gone"}}]},Ci={resourceType:"OperationOutcome",id:Ti,issue:[{severity:"error",code:"access-denied",details:{text:"Access Denied"}}]};function Ai(e){return e.id===yi||e.id===gi||e.id===vi}class Ri extends Error{constructor(e){var t,i;super(null===(i=null===(t=null==e?void 0:e.issue)||void 0===t?void 0:t[0].details)||void 0===i?void 0:i.text),this.outcome=e}}var Oi;e.Operator=void 0,(Oi=e.Operator||(e.Operator={})).EQUALS="eq",Oi.NOT_EQUALS="ne",Oi.GREATER_THAN="gt",Oi.LESS_THAN="lt",Oi.GREATER_THAN_OR_EQUALS="ge",Oi.LESS_THAN_OR_EQUALS="le",Oi.STARTS_AFTER="sa",Oi.ENDS_BEFORE="eb",Oi.APPROXIMATELY="ap",Oi.CONTAINS="contains",Oi.EXACT="exact",Oi.TEXT="text",Oi.NOT="not",Oi.ABOVE="above",Oi.BELOW="below",Oi.IN="in",Oi.NOT_IN="not-in",Oi.OF_TYPE="of-type",Oi.MISSING="missing";const ki=[e.Operator.CONTAINS,e.Operator.EXACT,e.Operator.TEXT,e.Operator.NOT,e.Operator.ABOVE,e.Operator.BELOW,e.Operator.IN,e.Operator.NOT_IN,e.Operator.OF_TYPE,e.Operator.MISSING],Ii=[e.Operator.NOT_EQUALS,e.Operator.GREATER_THAN,e.Operator.LESS_THAN,e.Operator.GREATER_THAN_OR_EQUALS,e.Operator.LESS_THAN_OR_EQUALS,e.Operator.STARTS_AFTER,e.Operator.ENDS_BEFORE,e.Operator.APPROXIMATELY];var Mi;function Ui(t,i){let n=e.SearchParameterType.TEXT;switch(t.type){case"date":n=i===e.PropertyType.dateTime||i===e.PropertyType.instant?e.SearchParameterType.DATETIME:e.SearchParameterType.DATE;break;case"number":n=e.SearchParameterType.NUMBER;break;case"quantity":n=e.SearchParameterType.QUANTITY;break;case"reference":n=e.SearchParameterType.REFERENCE;break;case"token":"boolean"===i&&(n=e.SearchParameterType.BOOLEAN)}return n}function Li(e,t){const i=t.split(" | ");for(const t of i){if((n=t).includes(" as Period")||n.includes(" as SampledDate"))continue;const i=Ni(t);if(i.startsWith(e+"."))return i}var n}function Ni(e){let t=e.trim();t.startsWith("(")&&t.endsWith(")")&&(t=t.substring(1,t.length-1)),t.includes("[0]")&&(t=t.replaceAll("[0]",""));const i=[" != "," as ",".as(",".exists(",".where("];for(const e of i)t.includes(e)&&(t=t.substring(0,t.indexOf(e)));return t}e.SearchParameterType=void 0,(Mi=e.SearchParameterType||(e.SearchParameterType={})).BOOLEAN="BOOLEAN",Mi.NUMBER="NUMBER",Mi.QUANTITY="QUANTITY",Mi.TEXT="TEXT",Mi.REFERENCE="REFERENCE",Mi.DATE="DATE",Mi.DATETIME="DATETIME",Mi.PERIOD="PERIOD",e.AndAtom=yt,e.ArithemticOperatorAtom=rt,e.AsAtom=ot,e.COMPONENT_SEPARATOR="^",e.ConcatAtom=at,e.ContainsAtom=st,e.DEFAULT_SEARCH_COUNT=20,e.DotAtom=dt,e.EmptySetAtom=it,e.EqualsAtom=ut,e.EquivalentAtom=pt,e.FIELD_SEPARATOR="|",e.FhirPathAtom=Ze,e.FunctionAtom=vt,e.Hl7Field=fi,e.Hl7Message=pi,e.Hl7Segment=hi,e.InAtom=ct,e.IndexerAtom=Et,e.IsAtom=ft,e.LRUCache=c,e.LiteralAtom=et,e.MedplumClient=class extends class{constructor(){U.set(this,void 0),n(this,U,{},"f")}addEventListener(e,t){i(this,U,"f")[e]||(i(this,U,"f")[e]=[]),i(this,U,"f")[e].push(t)}removeEventListeneer(e,t){const n=i(this,U,"f")[e];if(n)for(let e=0;e<n.length;e++)if(n[e]===t)return void n.splice(e,1)}dispatchEvent(e){const t=i(this,U,"f")[e.type];return t&&t.forEach((t=>t.call(this,e))),!e.defaultPrevented}}{constructor(e){var t,o;if(super(),Z.add(this),ee.set(this,void 0),te.set(this,void 0),ie.set(this,void 0),ne.set(this,void 0),oe.set(this,void 0),re.set(this,void 0),ae.set(this,void 0),se.set(this,void 0),ce.set(this,void 0),de.set(this,void 0),le.set(this,void 0),ue.set(this,void 0),me.set(this,void 0),pe.set(this,void 0),he.set(this,void 0),fe.set(this,void 0),ye.set(this,void 0),null==e?void 0:e.baseUrl){if(!e.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");if(!e.baseUrl.endsWith("/"))throw new Error("Base URL must end with a trailing slash")}n(this,ee,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),n(this,te,null==e?void 0:e.createPdf,"f"),n(this,ie,new H,"f"),n(this,ne,new c(null!==(t=null==e?void 0:e.resourceCacheSize)&&void 0!==t?t:1e3),"f"),n(this,oe,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:1e4,"f"),n(this,re,(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),n(this,ae,(null==e?void 0:e.clientId)||"","f"),n(this,se,(null==e?void 0:e.authorizeUrl)||i(this,re,"f")+"oauth2/authorize","f"),n(this,ce,(null==e?void 0:e.tokenUrl)||i(this,re,"f")+"oauth2/token","f"),n(this,de,(null==e?void 0:e.logoutUrl)||i(this,re,"f")+"oauth2/logout","f"),n(this,le,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(n(this,ue,r.accessToken,"f"),n(this,me,r.refreshToken,"f"),i(this,Z,"m",xe).call(this).catch(console.log)),i(this,Z,"m",ke).call(this)}getBaseUrl(){return i(this,re,"f")}clear(){i(this,ie,"f").clear(),i(this,ne,"f").clear(),n(this,ue,void 0,"f"),n(this,me,void 0,"f"),n(this,fe,void 0,"f"),n(this,ye,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),i(this,ne,"f").delete(e)}invalidateSearches(e){const t="fhir/R4/"+e;for(const e of i(this,ne,"f").keys())(e.endsWith(t)||e.includes(t+"?"))&&i(this,ne,"f").delete(e)}get(e,t={}){e=e.toString();const n=i(this,Z,"m",ve).call(this,e,t);if(n)return n.value;const o=new F(i(this,Z,"m",Te).call(this,"GET",e,t));return i(this,Z,"m",Ee).call(this,e,o),o}post(e,t,n,o={}){return e=e.toString(),t&&i(this,Z,"m",be).call(this,o,t),n&&i(this,Z,"m",Se).call(this,o,n),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"POST",e,o)}put(e,t,n,o={}){return e=e.toString(),t&&i(this,Z,"m",be).call(this,o,t),n&&i(this,Z,"m",Se).call(this,o,n),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"PUT",e,o)}patch(e,t,n={}){return e=e.toString(),i(this,Z,"m",be).call(this,n,t),i(this,Z,"m",Se).call(this,n,"application/json-patch+json"),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"PATCH",e,n)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),i(this,Z,"m",Te).call(this,"DELETE",e,t)}register(e){return t(this,void 0,void 0,(function*(){const t=yield this.post("auth/register",e);yield this.setActiveLogin(t)}))}startLogin(e){return t(this,void 0,void 0,(function*(){return yield i(this,Z,"m",De).call(this),this.post("auth/login",Object.assign(Object.assign({},e),{clientId:i(this,ae,"f"),scope:Ie,codeChallengeMethod:"S256",codeChallenge:i(this,ie,"f").getString("codeChallenge")}))}))}startGoogleLogin(e){return t(this,void 0,void 0,(function*(){return yield i(this,Z,"m",De).call(this),this.post("auth/google",e)}))}signOut(){return this.clear(),Promise.resolve()}signInWithRedirect(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void i(this,Z,"m",Ce).call(this)}signOutWithRedirect(){window.location.assign(i(this,de,"f"))}fhirUrl(...e){return new URL(i(this,re,"f")+"fhir/R4/"+e.join("/"))}fhirSearchUrl(e,t){const i=this.fhirUrl(e);return t&&(i.search=t.toString()),i}search(e,t,i={}){return this.get(this.fhirSearchUrl(e,t),i)}searchOne(e,t,n={}){const o=this.fhirSearchUrl(e,t);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=i(this,Z,"m",ve).call(this,r,n);if(a)return a.value;const s=new F(this.search(e,o.searchParams,n).then((e=>{var t,i;return null===(i=null===(t=e.entry)||void 0===t?void 0:t[0])||void 0===i?void 0:i.resource})));return i(this,Z,"m",Ee).call(this,r,s),s}searchResources(e,t,n={}){const o=this.fhirSearchUrl(e,t).toString()+"-searchResources",r=i(this,Z,"m",ve).call(this,o,n);if(r)return r.value;const a=new F(this.search(e,t,n).then((e=>{var t,i;return null!==(i=null===(t=e.entry)||void 0===t?void 0:t.map((e=>e.resource)))&&void 0!==i?i:[]})));return i(this,Z,"m",Ee).call(this,o,a),a}searchValueSet(e,t,i={}){const n=this.fhirUrl("ValueSet","$expand");return n.searchParams.set("url",e),n.searchParams.set("filter",t),this.get(n.toString(),i)}getCached(e,t){var n;const o=null===(n=i(this,ne,"f").get(this.fhirUrl(e,t).toString()))||void 0===n?void 0:n.value;return o&&o.isOk()?o.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[i,n]=t.split("/");return i&&n?this.getCached(i,n):void 0}readResource(e,t){return this.get(this.fhirUrl(e,t))}readReference(e){const t=null==e?void 0:e.reference;if(!t)return new F(Promise.reject(new Error("Missing reference")));const[i,n]=t.split("/");return i&&n?this.readResource(i,n):new F(Promise.reject(new Error("Invalid reference")))}getSchema(){return K}requestSchema(e){return t(this,void 0,void 0,(function*(){if(e in K.types)return K;const t=`{\n StructureDefinitionList(name: "${e}") {\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: "${e}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(t);for(const e of i.data.StructureDefinitionList)X(K,e);for(const e of i.data.SearchParameterList)Y(K,e);return K}))}readHistory(e,t){return this.get(this.fhirUrl(e,t,"_history"))}readVersion(e,t,i){return this.get(this.fhirUrl(e,t,"_history",i))}readPatientEverything(e){return this.get(this.fhirUrl("Patient",e,"$everything"))}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}createResourceIfNoneExist(e,i){var n;return t(this,void 0,void 0,(function*(){return null!==(n=yield this.searchOne(e.resourceType,i))&&void 0!==n?n:this.createResource(e)}))}createBinary(e,t,i){const n=this.fhirUrl("Binary");return t&&n.searchParams.set("_filename",t),this.post(n,e,i)}createPdf(e,n,o,r){return t(this,void 0,void 0,(function*(){if(!i(this,te,"f"))throw new Error("PDF creation not enabled");const t=yield i(this,te,"f").call(this,e,o,r);return this.createBinary(t,n,"application/pdf")}))}createComment(e,t){const i=this.getProfile();let n,o;return"Encounter"===e.resourceType&&(n=l(e),o=e.subject),"ServiceRequest"===e.resourceType&&(n=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=l(e)),this.createResource({resourceType:"Communication",basedOn:[l(e)],encounter:n,subject:o,sender:i?l(i):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}updateResource(e){if(!e.resourceType)throw new Error("Missing resourceType");if(!e.id)throw new Error("Missing id");return this.invalidateSearches(e.resourceType),this.put(this.fhirUrl(e.resourceType,e.id),e)}patchResource(e,t,i){return this.invalidateSearches(e),this.patch(this.fhirUrl(e,t),i)}deleteResource(e,t){return this.invalidateSearches(e),this.delete(this.fhirUrl(e,t))}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t){return this.post(this.fhirUrl("$graphql"),{query:e},"application/json",t)}getActiveLogin(){return i(this,ie,"f").getObject("activeLogin")}setActiveLogin(e){return t(this,void 0,void 0,(function*(){n(this,ue,e.accessToken,"f"),n(this,me,e.refreshToken,"f"),n(this,fe,void 0,"f"),n(this,ye,void 0,"f"),i(this,ie,"f").setObject("activeLogin",e),i(this,Z,"m",ge).call(this,e),i(this,ne,"f").clear(),n(this,pe,void 0,"f"),yield i(this,Z,"m",xe).call(this)}))}getAccessToken(){return i(this,ue,"f")}setAccessToken(e){n(this,ue,e,"f"),n(this,me,void 0,"f"),n(this,fe,void 0,"f"),n(this,ye,void 0,"f")}getLogins(){var e;return null!==(e=i(this,ie,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!i(this,he,"f")}getProfile(){return i(this,fe,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return i(this,he,"f")&&(yield i(this,he,"f")),this.getProfile()}))}getUserConfiguration(){return i(this,ye,"f")}download(e,n={}){return t(this,void 0,void 0,(function*(){i(this,pe,"f")&&(yield i(this,pe,"f")),i(this,Z,"m",we).call(this,n);return(yield i(this,ee,"f").call(this,e.toString(),n)).blob()}))}processCode(e){if(!i(this,ie,"f").getString("pkceState"))throw this.clear(),new Error("Invalid PCKE state");const t=i(this,ie,"f").getString("codeVerifier");if(!t)throw this.clear(),new Error("Invalid PCKE code verifier");const n=new URLSearchParams;return n.set("grant_type","authorization_code"),n.set("client_id",i(this,ae,"f")),n.set("code_verifier",t),n.set("code",e),n.set("redirect_uri",Me()),i(this,Z,"m",Re).call(this,n)}startClientLogin(e,n){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",e),t.set("client_secret",n),i(this,Z,"m",Re).call(this,t)}))}},e.NotEqualsAtom=mt,e.NotEquivalentAtom=ht,e.OperationOutcomeError=Ri,e.OrAtom=gt,e.ReadablePromise=F,e.SEGMENT_SEPARATOR="\r",e.SymbolAtom=tt,e.UnaryOperatorAtom=nt,e.UnionAtom=lt,e.XorAtom=xt,e.accessDenied=Ci,e.allOk=wi,e.arrayBufferToBase64=P,e.arrayBufferToHex=b,e.assertOk=function(e,t){if(!Ai(e)||void 0===t)throw new Ri(e)},e.badRequest=function(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}},e.booleanToTypedValue=Ue,e.buildTypeName=J,e.calculateAge=f,e.calculateAgeString=function(e,t){const{years:i,months:n,days:o}=f(e,t);return i>=2?i.toString().padStart(3,"0")+"Y":n>=1?n.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"},e.capitalize=D,e.createReference=l,e.createSchema=function(){return{types:{}}},e.createTypeSchema=V,e.created=Si,e.deepEquals=E,e.evalFhirPath=function(e,t){const i=Array.isArray(t)?t:[t];for(let e=0;e<i.length;e++){const t=i[e];"object"==typeof t&&"type"in t&&"value"in t||(i[e]=Le(i[e]))}return mi(e,i).map((e=>e.value))},e.evalFhirPathTyped=mi,e.fhirPathArrayEquals=Be,e.fhirPathArrayEquivalent=qe,e.fhirPathEquals=We,e.fhirPathEquivalent=Fe,e.fhirPathIs=$e,e.fhirPathNot=Qe,e.findObservationInterval=function(e,t,i,n){var o;return null===(o=e.qualifiedInterval)||void 0===o?void 0:o.find((o=>{var r;return function(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||C(f(t.birthDate).years,e.age)}(e,t)}(o,t)&&function(e,t,i){return!!e.range&&C(t,e.range,i)}(o,i,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===n||o.category===n)}))},e.formatAddress=function(e,t){const i=[];return e.line&&i.push(...e.line),e.city&&i.push(e.city),e.state&&i.push(e.state),e.postalCode&&i.push(e.postalCode),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(", ").trim()},e.formatFamilyName=function(e){return e.family||""},e.formatGivenName=function(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()},e.formatHumanName=d,e.formatSearchQuery=function(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=ki.includes(e.operator)?":"+e.operator:"",i=Ii.includes(e.operator)?e.operator:"";return`${e.code}${t}=${i}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))},e.getCodeBySystem=function(e,t){var i,n;return null===(n=null===(i=null==e?void 0:e.coding)||void 0===i?void 0:i.find((e=>e.system===t)))||void 0===n?void 0:n.code},e.getDateProperty=function(e){return e?new Date(e):void 0},e.getDisplayString=p,e.getExpressionForResourceType=Li,e.getExtensionValue=function(e,...t){var i;let n=e;for(let e=0;e<t.length&&n;e++)n=null===(i=null==n?void 0:n.extension)||void 0===i?void 0:i.find((i=>i.url===t[e]));return null==n?void 0:n.valueString},e.getIdentifier=function(e,t){const i=e.identifier;if(!i)return;const n=Array.isArray(i)?i:[i];for(const e of n)if(e.system===t)return e.value},e.getImageSrc=function(e){if(m(e)){const t=e.photo;if(t)for(const e of t){const t=h(e);if(t)return t}}if("Bot"===e.resourceType&&e.photo){const t=h(e.photo);if(t)return t}},e.getPropertyDisplayName=function(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(D).join(" ").replace("_"," ").replace(/\s+/g," ")},e.getQuestionnaireAnswers=function(e){const t={};return y(e.item,t),t},e.getReferenceString=u,e.getSearchParameterDetails=function(t,i,n){var o,r,a,s,c,d,l;if("_lastUpdated"===n.code)return{columnName:"lastUpdated",type:e.SearchParameterType.DATETIME};const u=n.code.split("-").reduce(((e,t,i)=>e+(i?D(t):t)),""),m=null===(o=Li(i,n.expression))||void 0===o?void 0:o.split(".");if(!m)return{columnName:u,type:e.SearchParameterType.TEXT};const p=Ui(n);let h,f,y=i,g=!1;for(let e=1;e<m.length;e++){const o=m[e];if(h=null!==(s=null===(a=null===(r=t.types[y])||void 0===r?void 0:r.properties)||void 0===a?void 0:a[o])&&void 0!==s?s:null===(d=null===(c=t.types[y])||void 0===c?void 0:c.properties)||void 0===d?void 0:d[o+"[x]"],!h)throw new Error(`Element definition not found for ${i} ${n.code}`);if("*"===h.max&&(g=!0),f=null===(l=h.type)||void 0===l?void 0:l[0].code,!f)return{columnName:u,type:p,array:g};e<m.length-1&&("Element"===f||"BackboneElement"===f?y+=D(o):y=f)}return{columnName:u,type:Ui(n,f),elementDefinition:h,array:g}},e.getStatus=function(e){return e.id===yi?200:e.id===gi?201:e.id===vi?304:e.id===Ti?403:e.id===Ei?404:e.id===xi?410:400},e.getTypedPropertyValue=_e,e.globalSchema=K,e.gone=Di,e.indexSearchParameter=Y,e.indexStructureDefinition=X,e.indexStructureDefinitionBundle=function(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&X(K,e)}},e.isGone=function(e){return e.id===xi},e.isLowerCase=function(e){return e===e.toLowerCase()},e.isNotFound=function(e){return e.id===Ei},e.isObject=T,e.isOk=Ai,e.isPeriod=ze,e.isProfileResource=m,e.isQuantity=Ge,e.isQuantityEquivalent=Ve,e.isStringArray=w,e.isUUID=function(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)},e.matchesRange=C,e.notFound=Pi,e.notModified=bi,e.parseFhirPath=ui,e.parseSearchDefinition=function(t){const i=new URL(t,"https://example.com/"),n=i.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let o,r,a,s,c,d;return new URLSearchParams(i.search).forEach(((t,i)=>{"_fields"===i?a=t.split(","):"_offset"===i?s=parseInt(t):"_count"===i?c=parseInt(t):"_total"===i?d=t:"_sort"===i?(r=r||[],r.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(t))):(o=o||[],o.push(function(t,i){let n=t,o=e.Operator.EQUALS;for(const e of ki){const t=n.indexOf(":"+e);-1!==t&&(o=e,n=n.substring(0,t))}for(const e of Ii)i.match(new RegExp("^"+e+"\\d"))&&(o=e,i=i.substring(e.length));return{code:n,operator:o,value:i}}(i,t)))})),{resourceType:n,filters:o,fields:a,offset:s,count:c,total:d,sortRules:r}},e.preciseEquals=A,e.preciseGreaterThan=O,e.preciseGreaterThanOrEquals=I,e.preciseLessThan=R,e.preciseLessThanOrEquals=k,e.removeDuplicates=je,e.resolveId=function(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]},e.setCodeBySystem=function(e,t,i){var n,o;e.coding||(e.coding=[]);const r=null===(n=e.coding)||void 0===n?void 0:n.find((e=>e.system===t));r?r.code=i:null===(o=e.coding)||void 0===o||o.push({system:t,code:i})},e.stringify=g,e.toJsBoolean=Ne,e.toTypedValue=Le,e.tokenize=$t,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=index.min.js.map