@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(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 t(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 i(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 n,o,r,a;class s{constructor(e=10){n.add(this),o.set(this,void 0),r.set(this,void 0),i(this,o,e,"f"),i(this,r,new Map,"f")}clear(){t(this,r,"f").clear()}get(e){const i=t(this,r,"f").get(e);return i&&(t(this,r,"f").delete(e),t(this,r,"f").set(e,i)),i}set(e,i){t(this,r,"f").has(e)?t(this,r,"f").delete(e):t(this,r,"f").size>=t(this,o,"f")&&t(this,r,"f").delete(t(this,n,"m",a).call(this)),t(this,r,"f").set(e,i)}delete(e){t(this,r,"f").delete(e)}keys(){return t(this,r,"f").keys()}}function c(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()}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=[];return e.given&&t.push(...e.given),t.join(" ").trim()}function u(e){return e.family||""}function m(e){const t=p(e),i=y(e);return i===t?{reference:t}:{reference:t,display:i}}function p(e){return e.resourceType+"/"+e.id}function h(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]}function f(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function y(e){var t,i;if(f(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:p(e)}function g(e){if(f(e)){const t=e.photo;if(t)for(const e of t){const t=x(e);if(t)return t}}if("Bot"===e.resourceType&&e.photo){const t=x(e.photo);if(t)return t}}function x(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function v(e){return e?new Date(e):void 0}function w(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 E(e,t){const{years:i,months:n,days:o}=w(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"}function S(e){const t={};return b(e.item,t),t}function b(e,t){if(e)for(const i of e)i.linkId&&i.answer&&i.answer.length>0&&(t[i.linkId]=i.answer[0]),b(i.item,t)}function D(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}function T(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}function C(e,t){return JSON.stringify(e,P,t?2:void 0)}function P(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&A(t)?void 0:t}function A(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function R(e,t,i){return e===t||(!(!A(e)||!A(t))||!A(e)&&!A(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(!R(e[i],t[i]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(I(e)&&I(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(!R(e[i],t[i],i))return!1}return!0}(e,t,i):(I(e)||I(t),!1))))}function k(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)}function I(e){return null!==e&&"object"==typeof e}function M(e){return e.every((e=>"string"==typeof e))}o=new WeakMap,r=new WeakMap,n=new WeakSet,a=function(){return t(this,r,"f").keys().next().value};const O=[];for(let e=0;e<256;e++)O.push(e.toString(16).padStart(2,"0"));function U(e){const t=new Uint8Array(e),i=new Array(t.length);for(let e=0;e<t.length;e++)i[e]=O[t[e]];return i.join("")}function L(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 j(e){return e.charAt(0).toUpperCase()+e.substring(1)}function _(e){return e===e.toLowerCase()}function N(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}function Q(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})}function W(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||B(w(t.birthDate).years,e.age)}(e,t)}(o,t)&&function(e,t,i){return!!e.range&&B(t,e.range,i)}(o,i,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===n||o.category===n)}))}function B(e,t,i){var n,o;return(void 0===(null===(n=t.low)||void 0===n?void 0:n.value)||z(e,t.low.value,i))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||H(e,t.high.value,i))}function q(e,t,i){return i?Math.abs(e-t)<Math.pow(10,-i):e===t}function F(e,t,i){return i?e<t&&Math.abs(e-t)>Math.pow(10,-i):e<t}function $(e,t,i){return i?e>t&&Math.abs(e-t)>Math.pow(10,-i):e>t}function H(e,t,i){return F(e,t,i)||q(e,t,i)}function z(e,t,i){return $(e,t,i)||q(e,t,i)}function V(){const e=new Uint32Array(28);return crypto.getRandomValues(e),U(e.buffer)}var G,X,Y,K,J,Z,ee,te;function ie(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)}G=new WeakMap;class ne{constructor(e){this[Z]="ReadablePromise",X.set(this,void 0),Y.set(this,"pending"),K.set(this,void 0),J.set(this,void 0),i(this,X,e.then((e=>(i(this,Y,"success","f"),i(this,K,e,"f"),e)),(e=>{throw i(this,Y,"error","f"),i(this,J,e,"f"),e})),"f")}isPending(){return"pending"===t(this,Y,"f")}isOk(){return"success"===t(this,Y,"f")}read(){switch(t(this,Y,"f")){case"pending":throw t(this,X,"f");case"error":throw t(this,J,"f");default:return t(this,K,"f")}}then(e,i){return t(this,X,"f").then(e,i)}catch(e){return t(this,X,"f").catch(e)}finally(e){return t(this,X,"f").finally(e)}}X=new WeakMap,Y=new WeakMap,K=new WeakMap,J=new WeakMap,Z=Symbol.toStringTag;class oe{constructor(){ee.set(this,void 0),i(this,ee,"undefined"!=typeof localStorage?localStorage:new re,"f")}clear(){t(this,ee,"f").clear()}getString(e){return t(this,ee,"f").getItem(e)||void 0}setString(e,i){i?t(this,ee,"f").setItem(e,i):t(this,ee,"f").removeItem(e)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?C(t):void 0)}}ee=new WeakMap;class re{constructor(){te.set(this,void 0),i(this,te,new Map,"f")}get length(){return t(this,te,"f").size}clear(){t(this,te,"f").clear()}getItem(e){var i;return null!==(i=t(this,te,"f").get(e))&&void 0!==i?i:null}setItem(e,i){i?t(this,te,"f").set(e,i):t(this,te,"f").delete(e)}removeItem(e){t(this,te,"f").delete(e)}key(e){return Array.from(t(this,te,"f").keys())[e]}}te=new WeakMap;var ae,se={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 ce(){return{types:{}}}function de(e,t){return{display:e,description:t,properties:{},searchParams:{_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"}}}}function le(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&ue(fe,e)}}function ue(e,t){var i;const n=t.name;if(!n)return;n in e.types||(e.types[n]=de(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=pe(a);s in e.types||(e.types[s]=de(s,t.definition),e.types[s].parentType=pe(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=pe(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 me(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 pe(e){return e.map(j).join("")}function he(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(j).join(" ").replace("_"," ").replace(/\s+/g," ")}!function(e){e.Address="Address",e.Age="Age",e.Annotation="Annotation",e.Attachment="Attachment",e.BackboneElement="BackboneElement",e.CodeableConcept="CodeableConcept",e.Coding="Coding",e.ContactDetail="ContactDetail",e.ContactPoint="ContactPoint",e.Contributor="Contributor",e.Count="Count",e.DataRequirement="DataRequirement",e.Distance="Distance",e.Dosage="Dosage",e.Duration="Duration",e.Expression="Expression",e.Extension="Extension",e.HumanName="HumanName",e.Identifier="Identifier",e.MarketingStatus="MarketingStatus",e.Meta="Meta",e.Money="Money",e.Narrative="Narrative",e.ParameterDefinition="ParameterDefinition",e.Period="Period",e.Population="Population",e.ProdCharacteristic="ProdCharacteristic",e.ProductShelfLife="ProductShelfLife",e.Quantity="Quantity",e.Range="Range",e.Ratio="Ratio",e.Reference="Reference",e.RelatedArtifact="RelatedArtifact",e.SampledData="SampledData",e.Signature="Signature",e.SubstanceAmount="SubstanceAmount",e.SystemString="http://hl7.org/fhirpath/System.String",e.Timing="Timing",e.TriggerDefinition="TriggerDefinition",e.UsageContext="UsageContext",e.base64Binary="base64Binary",e.boolean="boolean",e.canonical="canonical",e.code="code",e.date="date",e.dateTime="dateTime",e.decimal="decimal",e.id="id",e.instant="instant",e.integer="integer",e.markdown="markdown",e.oid="oid",e.positiveInt="positiveInt",e.string="string",e.time="time",e.unsignedInt="unsignedInt",e.uri="uri",e.url="url",e.uuid="uuid"}(ae||(ae={}));const fe=se;var ye,ge,xe,ve,we,Ee,Se,be,De,Te,Ce,Pe,Ae,Re,ke,Ie,Me,Oe,Ue,Le,je,_e,Ne,Qe,We,Be,qe,Fe,$e,He,ze,Ve,Ge;const Xe="launch/patient openid fhirUser offline_access user/*.*";class Ye extends class{constructor(){G.set(this,void 0),i(this,G,{},"f")}addEventListener(e,i){t(this,G,"f")[e]||(t(this,G,"f")[e]=[]),t(this,G,"f")[e].push(i)}removeEventListeneer(e,i){const n=t(this,G,"f")[e];if(n)for(let e=0;e<n.length;e++)if(n[e]===i)return void n.splice(e,1)}dispatchEvent(e){const i=t(this,G,"f")[e.type];return i&&i.forEach((t=>t.call(this,e))),!e.defaultPrevented}}{constructor(e){var n,o;if(super(),ye.add(this),ge.set(this,void 0),xe.set(this,void 0),ve.set(this,void 0),we.set(this,void 0),Ee.set(this,void 0),Se.set(this,void 0),be.set(this,void 0),De.set(this,void 0),Te.set(this,void 0),Ce.set(this,void 0),Pe.set(this,void 0),Ae.set(this,void 0),Re.set(this,void 0),ke.set(this,void 0),Ie.set(this,void 0),Me.set(this,void 0),Oe.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")}i(this,ge,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),i(this,xe,null==e?void 0:e.createPdf,"f"),i(this,ve,new oe,"f"),i(this,we,new s(null!==(n=null==e?void 0:e.resourceCacheSize)&&void 0!==n?n:1e3),"f"),i(this,Ee,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:1e4,"f"),i(this,Se,(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),i(this,be,(null==e?void 0:e.clientId)||"","f"),i(this,De,(null==e?void 0:e.authorizeUrl)||t(this,Se,"f")+"oauth2/authorize","f"),i(this,Te,(null==e?void 0:e.tokenUrl)||t(this,Se,"f")+"oauth2/token","f"),i(this,Ce,(null==e?void 0:e.logoutUrl)||t(this,Se,"f")+"oauth2/logout","f"),i(this,Pe,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(i(this,Ae,r.accessToken,"f"),i(this,Re,r.refreshToken,"f"),t(this,ye,"m",Le).call(this).catch(console.log)),t(this,ye,"m",Ge).call(this)}getBaseUrl(){return t(this,Se,"f")}clear(){t(this,ve,"f").clear(),t(this,we,"f").clear(),i(this,Ae,void 0,"f"),i(this,Re,void 0,"f"),i(this,Me,void 0,"f"),i(this,Oe,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),t(this,we,"f").delete(e)}invalidateSearches(e){const i="fhir/R4/"+e;for(const e of t(this,we,"f").keys())(e.endsWith(i)||e.includes(i+"?"))&&t(this,we,"f").delete(e)}get(e,i={}){e=e.toString();const n=t(this,ye,"m",je).call(this,e,i);if(n)return n.value;const o=new ne(t(this,ye,"m",Ne).call(this,"GET",e,i));return t(this,ye,"m",_e).call(this,e,o),o}post(e,i,n,o={}){return e=e.toString(),i&&t(this,ye,"m",Be).call(this,o,i),n&&t(this,ye,"m",We).call(this,o,n),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"POST",e,o)}put(e,i,n,o={}){return e=e.toString(),i&&t(this,ye,"m",Be).call(this,o,i),n&&t(this,ye,"m",We).call(this,o,n),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"PUT",e,o)}patch(e,i,n={}){return e=e.toString(),t(this,ye,"m",Be).call(this,n,i),t(this,ye,"m",We).call(this,n,"application/json-patch+json"),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"PATCH",e,n)}delete(e,i={}){return e=e.toString(),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"DELETE",e,i)}register(t){return e(this,void 0,void 0,(function*(){const e=yield this.post("auth/register",t);yield this.setActiveLogin(e)}))}startLogin(i){return e(this,void 0,void 0,(function*(){return yield t(this,ye,"m",Fe).call(this),this.post("auth/login",Object.assign(Object.assign({},i),{clientId:t(this,be,"f"),scope:Xe,codeChallengeMethod:"S256",codeChallenge:t(this,ve,"f").getString("codeChallenge")}))}))}startGoogleLogin(i){return e(this,void 0,void 0,(function*(){return yield t(this,ye,"m",Fe).call(this),this.post("auth/google",i)}))}signOut(){return this.clear(),Promise.resolve()}signInWithRedirect(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void t(this,ye,"m",$e).call(this)}signOutWithRedirect(){window.location.assign(t(this,Ce,"f"))}fhirUrl(...e){return new URL(t(this,Se,"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,i,n={}){const o=this.fhirSearchUrl(e,i);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=t(this,ye,"m",je).call(this,r,n);if(a)return a.value;const s=new ne(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 t(this,ye,"m",_e).call(this,r,s),s}searchResources(e,i,n={}){const o=this.fhirSearchUrl(e,i).toString()+"-searchResources",r=t(this,ye,"m",je).call(this,o,n);if(r)return r.value;const a=new ne(this.search(e,i,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 t(this,ye,"m",_e).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,i){var n;const o=null===(n=t(this,we,"f").get(this.fhirUrl(e,i).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 ne(Promise.reject(new Error("Missing reference")));const[i,n]=t.split("/");return i&&n?this.readResource(i,n):new ne(Promise.reject(new Error("Invalid reference")))}getSchema(){return fe}requestSchema(t){return e(this,void 0,void 0,(function*(){if(t in fe.types)return fe;const e=`{\n StructureDefinitionList(name: "${t}") {\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: "${t}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(e);for(const e of i.data.StructureDefinitionList)ue(fe,e);for(const e of i.data.SearchParameterList)me(fe,e);return fe}))}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(t,i){var n;return e(this,void 0,void 0,(function*(){return null!==(n=yield this.searchOne(t.resourceType,i))&&void 0!==n?n:this.createResource(t)}))}createBinary(e,t,i){const n=this.fhirUrl("Binary");return t&&n.searchParams.set("_filename",t),this.post(n,e,i)}createPdf(i,n,o,r){return e(this,void 0,void 0,(function*(){if(!t(this,xe,"f"))throw new Error("PDF creation not enabled");const e=yield t(this,xe,"f").call(this,i,o,r);return this.createBinary(e,n,"application/pdf")}))}createComment(e,t){const i=this.getProfile();let n,o;return"Encounter"===e.resourceType&&(n=m(e),o=e.subject),"ServiceRequest"===e.resourceType&&(n=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=m(e)),this.createResource({resourceType:"Communication",basedOn:[m(e)],encounter:n,subject:o,sender:i?m(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 t(this,ve,"f").getObject("activeLogin")}setActiveLogin(n){return e(this,void 0,void 0,(function*(){i(this,Ae,n.accessToken,"f"),i(this,Re,n.refreshToken,"f"),i(this,Me,void 0,"f"),i(this,Oe,void 0,"f"),t(this,ve,"f").setObject("activeLogin",n),t(this,ye,"m",Ue).call(this,n),t(this,we,"f").clear(),i(this,ke,void 0,"f"),yield t(this,ye,"m",Le).call(this)}))}getAccessToken(){return t(this,Ae,"f")}setAccessToken(e){i(this,Ae,e,"f"),i(this,Re,void 0,"f"),i(this,Me,void 0,"f"),i(this,Oe,void 0,"f")}getLogins(){var e;return null!==(e=t(this,ve,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!t(this,Ie,"f")}getProfile(){return t(this,Me,"f")}getProfileAsync(){return e(this,void 0,void 0,(function*(){return t(this,Ie,"f")&&(yield t(this,Ie,"f")),this.getProfile()}))}getUserConfiguration(){return t(this,Oe,"f")}download(i,n={}){return e(this,void 0,void 0,(function*(){t(this,ke,"f")&&(yield t(this,ke,"f")),t(this,ye,"m",Qe).call(this,n);return(yield t(this,ge,"f").call(this,i.toString(),n)).blob()}))}processCode(e){if(!t(this,ve,"f").getString("pkceState"))throw this.clear(),new Error("Invalid PCKE state");const i=t(this,ve,"f").getString("codeVerifier");if(!i)throw this.clear(),new Error("Invalid PCKE code verifier");const n=new URLSearchParams;return n.set("grant_type","authorization_code"),n.set("client_id",t(this,be,"f")),n.set("code_verifier",i),n.set("code",e),n.set("redirect_uri",Ke()),t(this,ye,"m",ze).call(this,n)}startClientLogin(i,n){return e(this,void 0,void 0,(function*(){const e=new URLSearchParams;return e.set("grant_type","client_credentials"),e.set("client_id",i),e.set("client_secret",n),t(this,ye,"m",ze).call(this,e)}))}}function Ke(){return window.location.protocol+"//"+window.location.host+"/"}function Je(e){return[{type:ae.boolean,value:e}]}function Ze(e){return null==e?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:ae.integer,value:e}:"number"==typeof e?{type:ae.decimal,value:e}:"boolean"==typeof e?{type:ae.boolean,value:e}:"string"==typeof e?{type:ae.string,value:e}:ut(e)?{type:ae.Quantity,value:e}:"object"==typeof e&&"resourceType"in e?{type:e.resourceType,value:e}:{type:ae.BackboneElement,value:e}}function et(e){return 0!==e.length&&!!e[0].value}function tt(e,t){if(!(null==e?void 0:e.value))return;const i=fe.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]","")+j(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=pe([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(Ze):Ze(n)}(e,t)}function it(e){const t=[];for(const i of e){let e=!1;for(const n of t)if(et(rt(i,n))){e=!0;break}e||t.push(i)}return t}function nt(e){return Je(!et(e))}function ot(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?Je(!1):Je(e.every(((e,i)=>et(rt(e,t[i])))))}function rt(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Je(Math.abs(i-n)<1e-8):ut(i)&&ut(n)?Je(mt(i,n)):Je("object"==typeof i&&"object"==typeof n?pt(e,t):i===n)}function at(e,t){return 0===e.length&&0===t.length?Je(!0):e.length!==t.length?Je(!1):(e.sort(ct),t.sort(ct),Je(e.every(((e,i)=>et(st(e,t[i]))))))}function st(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Je(Math.abs(i-n)<.01):ut(i)&&ut(n)?Je(mt(i,n)):Je("object"==typeof i&&"object"==typeof n?pt(i,n):"string"==typeof i&&"string"==typeof n?i.toLowerCase()===n.toLowerCase():i===n)}function ct(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 dt(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 lt(i);case"Quantity":return ut(i);default:return"object"==typeof i&&(null==i?void 0:i.resourceType)===t}}function lt(e){return!(!e||"object"!=typeof e||!("start"in e))}function ut(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function mt(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 pt(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(ht(i)&&ht(o)){if(!pt(i,o))return!1}else if(i!==o)return!1}return!0}function ht(e){return null!==e&&"object"==typeof e}var ft,yt;ge=new WeakMap,xe=new WeakMap,ve=new WeakMap,we=new WeakMap,Ee=new WeakMap,Se=new WeakMap,be=new WeakMap,De=new WeakMap,Te=new WeakMap,Ce=new WeakMap,Pe=new WeakMap,Ae=new WeakMap,Re=new WeakMap,ke=new WeakMap,Ie=new WeakMap,Me=new WeakMap,Oe=new WeakMap,ye=new WeakSet,Ue=function(e){const i=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)}));i.push(e),t(this,ve,"f").setObject("logins",i)},Le=function(){return e(this,void 0,void 0,(function*(){return i(this,Ie,new Promise(((e,n)=>{this.get("auth/me").then((n=>{i(this,Ie,void 0,"f"),i(this,Me,n.profile,"f"),i(this,Oe,n.config,"f"),this.dispatchEvent({type:"change"}),e(t(this,Me,"f"))})).catch(n)})),"f"),t(this,Ie,"f")}))},je=function(e,i){if(t(this,Ee,"f")<=0||"no-cache"===(null==i?void 0:i.cache)||"reload"===(null==i?void 0:i.cache))return;const n=t(this,we,"f").get(e);return!n||n.requestTime+t(this,Ee,"f")<Date.now()?void 0:n},_e=function(e,i){t(this,Ee,"f")>0&&t(this,we,"f").set(e,{requestTime:Date.now(),value:i})},Ne=function(i,n,o={}){return e(this,void 0,void 0,(function*(){t(this,ke,"f")&&(yield t(this,ke,"f")),n.startsWith("http")||(n=t(this,Se,"f")+n),o.method=i,t(this,ye,"m",Qe).call(this,o);const e=yield t(this,ge,"f").call(this,n,o);if(401===e.status)return t(this,ye,"m",qe).call(this,i,n,o);if(204===e.status||304===e.status)return;const r=yield e.json();if(e.status>=400)throw r;return r}))},Qe=function(e){e.headers||(e.headers={});const i=e.headers;i["Content-Type"]||(i["Content-Type"]="application/fhir+json"),t(this,Ae,"f")&&(i.Authorization="Bearer "+t(this,Ae,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},We=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))},qe=function(i,n,o){return e(this,void 0,void 0,(function*(){return t(this,ye,"m",He).call(this).then((()=>t(this,ye,"m",Ne).call(this,i,n,o))).catch((e=>(this.clear(),t(this,Pe,"f")&&t(this,Pe,"f").call(this),Promise.reject(e))))}))},Fe=function(){return e(this,void 0,void 0,(function*(){const i=V();t(this,ve,"f").setString("pkceState",i);const n=V();t(this,ve,"f").setString("codeVerifier",n);const o=L(yield function(t){return e(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t))}))}(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");t(this,ve,"f").setString("codeChallenge",o)}))},$e=function(){t(this,ye,"m",Fe).call(this);const e=new URL(t(this,De,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",t(this,ve,"f").getString("pkceState")),e.searchParams.set("client_id",t(this,be,"f")),e.searchParams.set("redirect_uri",Ke()),e.searchParams.set("scope",Xe),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",t(this,ve,"f").getString("codeChallenge")),window.location.assign(e.toString())},He=function(){return e(this,void 0,void 0,(function*(){if(t(this,ke,"f"))return t(this,ke,"f");if(!t(this,Re,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",t(this,be,"f")),e.set("refresh_token",t(this,Re,"f")),i(this,ke,t(this,ye,"m",ze).call(this,e),"f"),yield t(this,ke,"f")}))},ze=function(i){return e(this,void 0,void 0,(function*(){return t(this,ge,"f").call(this,t(this,Te,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>t(this,ye,"m",Ve).call(this,e))).then((()=>this.getProfile()))}))},Ve=function(i){return e(this,void 0,void 0,(function*(){const e=i.access_token,n=function(e){const[t,i,n]=e.split(".");return ie(i)}(e);if(Date.now()>=1e3*n.exp)throw this.clear(),new Error("Token expired");if(t(this,be,"f")&&n.client_id!==t(this,be,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:e,refreshToken:i.refresh_token,project:i.project,profile:i.profile})}))},Ge=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};class gt{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 xt{constructor(e){this.value=e}eval(){return[this.value]}}class vt{constructor(e){this.name=e,ft.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>t(this,ft,"m",yt).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}ft=new WeakSet,yt=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:tt(e,this.name)};class wt{eval(){return[]}}class Et{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class St{constructor(e,t){this.left=e,this.right=t}eval(e){return this.left.eval(e)}}class bt{constructor(e,t,i){this.left=e,this.right=t,this.impl=i}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const i=this.right.eval(e);if(1!==i.length)return[];const n=t[0].value,o=i[0].value,r=ut(n)?n.value:n,a=ut(o)?o.value:o,s=this.impl(r,a);return"boolean"==typeof s?Je(s):ut(n)?[{type:ae.Quantity,value:Object.assign(Object.assign({},n),{value:s})}]:[Ze(s)]}}class Dt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=[...this.left.eval(e),...this.right.eval(e)];return t.length>0&&t.every((e=>"string"==typeof e.value))?[{type:ae.string,value:t.map((e=>e.value)).join("")}]:t}}class Tt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);return Je(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 Je(this.right.eval(e).some((e=>e.value===t[0].value)))}}class Pt{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class At{constructor(e,t){this.left=e,this.right=t}eval(e){return it([...this.left.eval(e),...this.right.eval(e)])}}class Rt{constructor(e,t){this.left=e,this.right=t}eval(e){return ot(this.left.eval(e),this.right.eval(e))}}class kt{constructor(e,t){this.left=e,this.right=t}eval(e){return nt(ot(this.left.eval(e),this.right.eval(e)))}}class It{constructor(e,t){this.left=e,this.right=t}eval(e){return at(this.left.eval(e),this.right.eval(e))}}class Mt{constructor(e,t){this.left=e,this.right=t}eval(e){return nt(at(this.left.eval(e),this.right.eval(e)))}}class Ot{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 Je(dt(t[0],i))}}class Ut{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)?Je(!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)?Je(!1):[]}}class Lt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(et(t))return t;const i=this.right.eval(e);return et(i)?i:[]}}class jt{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?Je(!0):!0===n&&!0===o||!1===n&&!1===o?Je(!1):[]}}class _t{constructor(e,t,i){this.name=e,this.args=t,this.impl=i}eval(e){return this.impl(e,...this.args)}}class Nt{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 Qt(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=()=>[],Bt={empty:e=>Je(0===e.length),exists:(e,t)=>Je(t?e.filter((e=>et(t.eval([e])))).length>0:e.length>0),all:(e,t)=>Je(e.every((e=>et(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return Je(!1);return Je(!0)},anyTrue:e=>{for(const t of e)if(t.value)return Je(!0);return Je(!1)},allFalse:e=>{for(const t of e)if(t.value)return Je(!1);return Je(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return Je(!0);return Je(!1)},subsetOf:Wt,supersetOf:Wt,count:e=>[{type:ae.integer,value:e.length}],distinct:e=>{const t=[];for(const i of e)t.some((e=>e.value===i.value))||t.push(i);return t},isDistinct:e=>Je(e.length===Bt.distinct(e).length),where:(e,t)=>e.filter((e=>et(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 it([...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 et(o)?i.eval(e):n?n.eval(e):[]},toBoolean:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);if("boolean"==typeof t)return[{type:ae.boolean,value:t}];if("number"==typeof t&&(0===t||1===t))return Je(!!t);if("string"==typeof t){const e=t.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return Je(!0);if(["false","f","no","n","0","0.0"].includes(e))return Je(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:Je(1===Bt.toBoolean(e).length),toInteger:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"number"==typeof t?[{type:ae.integer,value:t}]:"string"==typeof t&&t.match(/^[+-]?\d+$/)?[{type:ae.integer,value:parseInt(t,10)}]:"boolean"==typeof t?[{type:ae.integer,value:t?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:Je(1===Bt.toInteger(e).length),toDate:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:ae.date,value:Qt(t)}]:[]},convertsToDate:e=>0===e.length?[]:Je(1===Bt.toDate(e).length),toDateTime:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:ae.dateTime,value:Qt(t)}]:[]},convertsToDateTime:e=>0===e.length?[]:Je(1===Bt.toDateTime(e).length),toDecimal:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"number"==typeof t?[{type:ae.decimal,value:t}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:ae.decimal,value:parseFloat(t)}]:"boolean"==typeof t?[{type:ae.decimal,value:t?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:Je(1===Bt.toDecimal(e).length),toQuantity:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return ut(t)?[{type:ae.Quantity,value:t}]:"number"==typeof t?[{type:ae.Quantity,value:{value:t,unit:"1"}}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:ae.Quantity,value:{value:parseFloat(t),unit:"1"}}]:"boolean"==typeof t?[{type:ae.Quantity,value:{value:t?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:Je(1===Bt.toQuantity(e).length),toString:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return null==t?[]:ut(t)?[{type:ae.string,value:`${t.value} '${t.unit}'`}]:[{type:ae.string,value:t.toString()}]},convertsToString:e=>0===e.length?[]:Je(1===Bt.toString(e).length),toTime:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);if("string"==typeof t){const e=t.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(e)return[{type:ae.time,value:Qt("T"+e[1])}]}return[]},convertsToTime:e=>0===e.length?[]:Je(1===Bt.toTime(e).length),indexOf:(e,t)=>qt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,i)=>qt(((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)=>qt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>qt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>qt(((e,t)=>e.includes(t)),e,t),upper:e=>qt((e=>e.toUpperCase()),e),lower:e=>qt((e=>e.toLowerCase()),e),replace:(e,t,i)=>qt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),matches:(e,t)=>qt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,i)=>qt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),length:e=>qt((e=>e.length),e),toChars:e=>qt((e=>e?e.split(""):void 0),e),abs:e=>Ft(Math.abs,e),ceiling:e=>Ft(Math.ceil,e),exp:e=>Ft(Math.exp,e),floor:e=>Ft(Math.floor,e),ln:e=>Ft(Math.log,e),log:(e,t)=>Ft(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>Ft(Math.pow,e,t),round:e=>Ft(Math.round,e),sqrt:e=>Ft(Math.sqrt,e),truncate:e=>Ft((e=>0|e),e),children:Wt,descendants:Wt,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:ae.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:ae.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:ae.date,value:(new Date).toISOString().substring(0,10)}],between:(e,t,i,n)=>{var o;const r=Bt.toDateTime(t.eval(e));if(0===r.length)throw new Error("Invalid start date");const a=Bt.toDateTime(i.eval(e));if(0===a.length)throw new Error("Invalid end date");const s=null===(o=n.eval(e)[0])||void 0===o?void 0:o.value;if("years"!==s&&"months"!==s&&"days"!==s)throw new Error("Invalid units");const c=w(r[0].value,a[0].value);return[{type:ae.Quantity,value:{value:c[s],unit:s}}]},is:(e,t)=>{let i="";return t instanceof vt?i=t.name:t instanceof Pt&&(i=t.left.name+"."+t.right.name),i?e.map((e=>({type:ae.boolean,value:dt(e,i)}))):[]},not:e=>Bt.toBoolean(e).map((e=>({type:ae.boolean,value:!e.value}))),resolve:e=>e.map((e=>{const t=e.value;let i;if("string"==typeof t)i=t;else if("object"==typeof t){const e=t;if(e.resource)return Ze(e.resource);i=e.reference}if(!i)return{type:ae.BackboneElement,value:null};const[n,o]=i.split("/");return{type:ae.BackboneElement,value:{resourceType:n,id:o}}})).filter((e=>!!e.value)),as:e=>e,type:e=>e.map((({value:e})=>"boolean"==typeof e?{type:ae.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof e?{type:ae.BackboneElement,value:{namespace:"System",name:"Integer"}}:e&&"object"==typeof e&&"resourceType"in e?{type:ae.BackboneElement,value:{namespace:"FHIR",name:e.resourceType}}:{type:ae.BackboneElement,value:null})),conformsTo:(e,t)=>{const i=t.eval(e)[0].value;if(!i.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const n=i.replace("http://hl7.org/fhir/StructureDefinition/","");return e.map((e=>{var t;return{type:ae.boolean,value:(null===(t=e.value)||void 0===t?void 0:t.resourceType)===n}}))}};function qt(e,t,...i){if(0===t.length)return[];const[{value:n}]=$t(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(Ze):[Ze(o)]}function Ft(e,t,...i){if(0===t.length)return[];const[{value:n}]=$t(t,1),o=ut(n),r=o?n.value:n;if("number"!=typeof r)throw new Error("Math function cannot be called with non-number");const a=e(r,...i.map((e=>{var i,n;return null===(n=null===(i=e.eval(t))||void 0===i?void 0:i[0])||void 0===n?void 0:n.value})));return[{type:o?ae.Quantity:t[0].type,value:o?Object.assign(Object.assign({},n),{value:a}):a}]}function $t(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 Ht,zt,Vt,Gt,Xt,Yt,Kt,Jt,Zt,ei,ti,ii,ni,oi,ri,ai,si,ci;function di(e){return new mi(e).tokenize()}const li=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],ui=["!=","!~","<=",">=","{}"];class mi{constructor(e){Ht.add(this),zt.set(this,void 0),Vt.set(this,void 0),i(this,zt,e,"f"),i(this,Vt,0,"f")}tokenize(){const e=[];for(;t(this,Vt,"f")<t(this,zt,"f").length;){const i=t(this,Ht,"m",Xt).call(this);i&&e.push(i)}return e}}function pi(e,t){return{id:e,value:t}}var hi,fi,yi,gi,xi,vi,wi,Ei,Si;zt=new WeakMap,Vt=new WeakMap,Ht=new WeakSet,Gt=function(){const e=t(this,Vt,"f"),n=t(this,Ht,"m",Xt).call(this);return i(this,Vt,e,"f"),n},Xt=function(){t(this,Ht,"m",Yt).call(this);const e=t(this,Ht,"m",ai).call(this);if(!e)return;const i=t(this,Ht,"m",ci).call(this);return"/"===e&&"*"===i?t(this,Ht,"m",Kt).call(this):"/"===e&&"/"===i?t(this,Ht,"m",Jt).call(this):"'"===e?t(this,Ht,"m",Zt).call(this):"`"===e?t(this,Ht,"m",ei).call(this):"@"===e?t(this,Ht,"m",ti).call(this):e.match(/\d/)?t(this,Ht,"m",ii).call(this):e.match(/\w/)||"$"===e&&i.match(/\w/)?t(this,Ht,"m",ni).call(this):t(this,Ht,"m",oi).call(this)},Yt=function(){return pi("Whitespace",t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/\s/))))},Kt=function(){const e=t(this,Vt,"f");return t(this,Ht,"m",ri).call(this,(()=>"*"!==t(this,Ht,"m",ai).call(this)||"/"!==t(this,Ht,"m",ci).call(this))),i(this,Vt,t(this,Vt,"f")+2,"f"),pi("Comment",t(this,zt,"f").substring(e,t(this,Vt,"f")))},Jt=function(){return pi("Comment",t(this,Ht,"m",ri).call(this,(()=>"\n"!==t(this,Ht,"m",ai).call(this))))},Zt=function(){var e,n;i(this,Vt,(e=t(this,Vt,"f"),++e),"f");const o=pi("String",t(this,Ht,"m",ri).call(this,(()=>"\\"===t(this,Ht,"m",si).call(this)||"'"!==t(this,Ht,"m",ai).call(this))));return i(this,Vt,(n=t(this,Vt,"f"),++n),"f"),o},ei=function(){var e,n;i(this,Vt,(e=t(this,Vt,"f"),++e),"f");const o=pi("Symbol",t(this,Ht,"m",ri).call(this,(()=>"`"!==t(this,Ht,"m",ai).call(this))));return i(this,Vt,(n=t(this,Vt,"f"),++n),"f"),o},ti=function(){var e,n,o,r,a;const s=t(this,Vt,"f");return i(this,Vt,(e=t(this,Vt,"f"),++e),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d-]/))),"T"===t(this,Ht,"m",ai).call(this)&&(i(this,Vt,(n=t(this,Vt,"f"),++n),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d:]/))),"."===t(this,Ht,"m",ai).call(this)&&t(this,Ht,"m",ci).call(this).match(/\d/)&&(i(this,Vt,(o=t(this,Vt,"f"),++o),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d]/)))),"Z"===t(this,Ht,"m",ai).call(this)?i(this,Vt,(r=t(this,Vt,"f"),++r),"f"):"+"!==t(this,Ht,"m",ai).call(this)&&"-"!==t(this,Ht,"m",ai).call(this)||(i(this,Vt,(a=t(this,Vt,"f"),++a),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d:]/))))),pi("DateTime",t(this,zt,"f").substring(s+1,t(this,Vt,"f")))},ii=function(){var e;const n=t(this,Vt,"f");let o="Number";return t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/\d/))),"."===t(this,Ht,"m",ai).call(this)&&t(this,Ht,"m",ci).call(this).match(/\d/)&&(i(this,Vt,(e=t(this,Vt,"f"),++e),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/\d/))))," "===t(this,Ht,"m",ai).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&li.includes(e.value))return!0}return!1}(t(this,Ht,"m",Gt).call(this))&&(o="Quantity",t(this,Ht,"m",Xt).call(this)),pi(o,t(this,zt,"f").substring(n,t(this,Vt,"f")))},ni=function(){return pi("Symbol",t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[$\w]/))))},oi=function(){var e;const n=t(this,Ht,"m",ai).call(this),o=n+t(this,Ht,"m",ci).call(this);return ui.includes(o)?(i(this,Vt,t(this,Vt,"f")+2,"f"),pi(o,o)):(i(this,Vt,(e=t(this,Vt,"f"),++e),"f"),pi(n,n))},ri=function(e){var n;const o=t(this,Vt,"f");for(;t(this,Vt,"f")<t(this,zt,"f").length&&e();)i(this,Vt,(n=t(this,Vt,"f"),++n),"f");return t(this,zt,"f").substring(o,t(this,Vt,"f"))},ai=function(){return t(this,zt,"f")[t(this,Vt,"f")]},si=function(){var e;return null!==(e=t(this,zt,"f")[t(this,Vt,"f")-1])&&void 0!==e?e:""},ci=function(){var e;return null!==(e=t(this,zt,"f")[t(this,Vt,"f")+1])&&void 0!==e?e:""};hi=new WeakMap,fi=new WeakMap;class bi{constructor(e,t,n){yi.add(this),gi.set(this,void 0),xi.set(this,void 0),vi.set(this,void 0),i(this,gi,e,"f"),i(this,xi,t,"f"),i(this,vi,n,"f")}match(e){const i=t(this,yi,"m",Si).call(this);return(null==i?void 0:i.id)===e&&(t(this,yi,"m",Ei).call(this),!0)}consumeAndParse(e=100){const i=t(this,yi,"m",Ei).call(this),n=t(this,xi,"f")[i.id];if(!n)throw Error(`Parse error at ${i.value}. No matching prefix parselet.`);let o=n.parse(this,i);for(;e>t(this,yi,"m",wi).call(this);){const e=t(this,yi,"m",Ei).call(this);o=t(this,vi,"f")[e.id].parse(this,o,e)}return o}}gi=new WeakMap,xi=new WeakMap,vi=new WeakMap,yi=new WeakSet,wi=function(){const e=t(this,yi,"m",Si).call(this);if(!e)return 100;const i=t(this,vi,"f")[e.id];return i?i.precedence:100},Ei=function(){if(!t(this,gi,"f").length)throw Error("Cant consume unknown more tokens.");return t(this,gi,"f").shift()},Si=function(){return t(this,gi,"f").length>0?t(this,gi,"f")[0]:void 0};const Di={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},Ti={parse(e,t){const i=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new Nt(t,i)},precedence:2},Ci={parse(e,t){if(!(t instanceof vt))throw new Error("Unexpected parentheses");if(!(t.name in Bt))throw new Error("Unrecognized function: "+t.name);const i=[];for(;!e.match(")");)i.push(e.consumeAndParse()),e.match(",");return new _t(t.name,i,Bt[t.name])},precedence:0};function Pi(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 Ai=(new class{constructor(){hi.set(this,{}),fi.set(this,{})}registerInfix(e,i){return t(this,fi,"f")[e]=i,this}registerPrefix(e,i){return t(this,hi,"f")[e]=i,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 bi(di(e),t(this,hi,"f"),t(this,fi,"f"))}}).registerPrefix("String",{parse:(e,t)=>new xt({type:ae.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new xt({type:ae.dateTime,value:Qt(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new xt({type:ae.Quantity,value:Pi(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new xt({type:ae.decimal,value:parseFloat(t.value)})}).registerPrefix("Symbol",{parse:(e,t)=>"false"===t.value?new xt({type:ae.boolean,value:!1}):"true"===t.value?new xt({type:ae.boolean,value:!0}):new vt(t.value)}).registerPrefix("{}",{parse:()=>new wt}).registerPrefix("(",Di).registerInfix("[",Ti).registerInfix("(",Ci).prefix("+",3,((e,t)=>new Et(t,(e=>e)))).prefix("-",3,((e,t)=>new bt(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,i)=>new Pt(e,i))).infixLeft("/",4,((e,t,i)=>new bt(e,i,((e,t)=>e/t)))).infixLeft("*",4,((e,t,i)=>new bt(e,i,((e,t)=>e*t)))).infixLeft("+",5,((e,t,i)=>new bt(e,i,((e,t)=>e+t)))).infixLeft("-",5,((e,t,i)=>new bt(e,i,((e,t)=>e-t)))).infixLeft("|",7,((e,t,i)=>new At(e,i))).infixLeft("=",9,((e,t,i)=>new Rt(e,i))).infixLeft("!=",9,((e,t,i)=>new kt(e,i))).infixLeft("~",9,((e,t,i)=>new It(e,i))).infixLeft("!~",9,((e,t,i)=>new Mt(e,i))).infixLeft("<",8,((e,t,i)=>new bt(e,i,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,i)=>new bt(e,i,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,i)=>new bt(e,i,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,i)=>new bt(e,i,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,i)=>new Dt(e,i))).infixLeft("Symbol",6,((e,t,i)=>{switch(t.value){case"and":return new Ut(e,i);case"as":return new St(e,i);case"contains":return new Tt(e,i);case"div":return new bt(e,i,((e,t)=>e/t|0));case"in":return new Ct(e,i);case"is":return new Ot(e,i);case"mod":return new bt(e,i,((e,t)=>e%t));case"or":return new Lt(e,i);case"xor":return new jt(e,i);default:throw new Error("Cannot use "+t.value+" as infix operator")}}));function Ri(e){try{return new gt(e,Ai.construct(e).consumeAndParse())}catch(t){throw new Error(`FhirPathError on "${e}": ${t}`)}}function ki(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]=Ze(i[e]))}return Ii(e,i).map((e=>e.value))}function Ii(e,t){return Ri(e).eval(t)}const Mi="\r",Oi="|",Ui="^";class Li{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 Li([new ji(["MSH","^~\\&",l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p]),new ji(["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 Li(e.split(/[\r\n]+/).map((e=>ji.parse(e))))}}class ji{constructor(e){M(e)?this.fields=e.map((e=>_i.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 ji(e.split("|").map((e=>_i.parse(e))))}}class _i{constructor(e){this.components=e}get(e){return this.components[e]}toString(){return this.components.join("^")}static parse(e){return new _i(e.split("^"))}}const Ni={resourceType:"OperationOutcome",id:"ok",issue:[{severity:"information",code:"information",details:{text:"All OK"}}]},Qi={resourceType:"OperationOutcome",id:"created",issue:[{severity:"information",code:"information",details:{text:"Created"}}]},Wi={resourceType:"OperationOutcome",id:"not-modified",issue:[{severity:"information",code:"information",details:{text:"Not Modified"}}]},Bi={resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},qi={resourceType:"OperationOutcome",id:"gone",issue:[{severity:"error",code:"gone",details:{text:"Gone"}}]},Fi={resourceType:"OperationOutcome",id:"access-denied",issue:[{severity:"error",code:"access-denied",details:{text:"Access Denied"}}]};function $i(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}}function Hi(e){return"ok"===e.id||"created"===e.id||"not-modified"===e.id}function zi(e){return"not-found"===e.id}function Vi(e){return"gone"===e.id}function Gi(e){return"ok"===e.id?200:"created"===e.id?201:"not-modified"===e.id?304:"access-denied"===e.id?403:"not-found"===e.id?404:"gone"===e.id?410:400}function Xi(e,t){if(!Hi(e)||void 0===t)throw new Yi(e)}class Yi 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}}const Ki=20;var Ji;!function(e){e.EQUALS="eq",e.NOT_EQUALS="ne",e.GREATER_THAN="gt",e.LESS_THAN="lt",e.GREATER_THAN_OR_EQUALS="ge",e.LESS_THAN_OR_EQUALS="le",e.STARTS_AFTER="sa",e.ENDS_BEFORE="eb",e.APPROXIMATELY="ap",e.CONTAINS="contains",e.EXACT="exact",e.TEXT="text",e.NOT="not",e.ABOVE="above",e.BELOW="below",e.IN="in",e.NOT_IN="not-in",e.OF_TYPE="of-type",e.MISSING="missing"}(Ji||(Ji={}));const Zi=[Ji.CONTAINS,Ji.EXACT,Ji.TEXT,Ji.NOT,Ji.ABOVE,Ji.BELOW,Ji.IN,Ji.NOT_IN,Ji.OF_TYPE,Ji.MISSING],en=[Ji.NOT_EQUALS,Ji.GREATER_THAN,Ji.LESS_THAN,Ji.GREATER_THAN_OR_EQUALS,Ji.LESS_THAN_OR_EQUALS,Ji.STARTS_AFTER,Ji.ENDS_BEFORE,Ji.APPROXIMATELY];function tn(e){const t=new URL(e,"https://example.com/"),i=t.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let n,o,r,a,s,c;return new URLSearchParams(t.search).forEach(((e,t)=>{"_fields"===t?r=e.split(","):"_offset"===t?a=parseInt(e):"_count"===t?s=parseInt(e):"_total"===t?c=e:"_sort"===t?(o=o||[],o.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(e))):(n=n||[],n.push(function(e,t){let i=e,n=Ji.EQUALS;for(const e of Zi){const t=i.indexOf(":"+e);-1!==t&&(n=e,i=i.substring(0,t))}for(const e of en)t.match(new RegExp("^"+e+"\\d"))&&(n=e,t=t.substring(e.length));return{code:i,operator:n,value:t}}(t,e)))})),{resourceType:i,filters:n,fields:r,offset:a,count:s,total:c,sortRules:o}}function nn(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=Zi.includes(e.operator)?":"+e.operator:"",i=en.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("&"))}var on;function rn(e,t,i){var n,o,r,a,s,c,d;if("_lastUpdated"===i.code)return{columnName:"lastUpdated",type:on.DATETIME};const l=i.code.split("-").reduce(((e,t,i)=>e+(i?j(t):t)),"");const u=null===(n=sn(t,i.expression))||void 0===n?void 0:n.split(".");if(!u)return{columnName:l,type:on.TEXT};const m=an(i);let p,h,f=t,y=!1;for(let n=1;n<u.length;n++){const g=u[n];if(p=null!==(a=null===(r=null===(o=e.types[f])||void 0===o?void 0:o.properties)||void 0===r?void 0:r[g])&&void 0!==a?a:null===(c=null===(s=e.types[f])||void 0===s?void 0:s.properties)||void 0===c?void 0:c[g+"[x]"],!p)throw new Error(`Element definition not found for ${t} ${i.code}`);if("*"===p.max&&(y=!0),h=null===(d=p.type)||void 0===d?void 0:d[0].code,!h)return{columnName:l,type:m,array:y};n<u.length-1&&("Element"===h||"BackboneElement"===h?f+=j(g):f=h)}return{columnName:l,type:an(i,h),elementDefinition:p,array:y}}function an(e,t){let i=on.TEXT;switch(e.type){case"date":i=t===ae.dateTime||t===ae.instant?on.DATETIME:on.DATE;break;case"number":i=on.NUMBER;break;case"quantity":i=on.QUANTITY;break;case"reference":i=on.REFERENCE;break;case"token":"boolean"===t&&(i=on.BOOLEAN)}return i}function sn(e,t){const i=t.split(" | ");for(const t of i){if((n=t).includes(" as Period")||n.includes(" as SampledDate"))continue;const i=cn(t);if(i.startsWith(e+"."))return i}var n}function cn(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}!function(e){e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.QUANTITY="QUANTITY",e.TEXT="TEXT",e.REFERENCE="REFERENCE",e.DATE="DATE",e.DATETIME="DATETIME",e.PERIOD="PERIOD"}(on||(on={}));export{Ut as AndAtom,bt as ArithemticOperatorAtom,St as AsAtom,Ui as COMPONENT_SEPARATOR,Dt as ConcatAtom,Tt as ContainsAtom,Ki as DEFAULT_SEARCH_COUNT,Pt as DotAtom,wt as EmptySetAtom,Rt as EqualsAtom,It as EquivalentAtom,Oi as FIELD_SEPARATOR,gt as FhirPathAtom,_t as FunctionAtom,_i as Hl7Field,Li as Hl7Message,ji as Hl7Segment,Ct as InAtom,Nt as IndexerAtom,Ot as IsAtom,s as LRUCache,xt as LiteralAtom,Ye as MedplumClient,kt as NotEqualsAtom,Mt as NotEquivalentAtom,Yi as OperationOutcomeError,Ji as Operator,Lt as OrAtom,ae as PropertyType,ne as ReadablePromise,Mi as SEGMENT_SEPARATOR,on as SearchParameterType,vt as SymbolAtom,Et as UnaryOperatorAtom,At as UnionAtom,jt as XorAtom,Fi as accessDenied,Ni as allOk,L as arrayBufferToBase64,U as arrayBufferToHex,Xi as assertOk,$i as badRequest,Je as booleanToTypedValue,pe as buildTypeName,w as calculateAge,E as calculateAgeString,j as capitalize,m as createReference,ce as createSchema,de as createTypeSchema,Qi as created,R as deepEquals,ki as evalFhirPath,Ii as evalFhirPathTyped,ot as fhirPathArrayEquals,at as fhirPathArrayEquivalent,rt as fhirPathEquals,st as fhirPathEquivalent,dt as fhirPathIs,nt as fhirPathNot,W as findObservationInterval,c as formatAddress,u as formatFamilyName,l as formatGivenName,d as formatHumanName,nn as formatSearchQuery,N as getCodeBySystem,v as getDateProperty,y as getDisplayString,sn as getExpressionForResourceType,T as getExtensionValue,D as getIdentifier,g as getImageSrc,he as getPropertyDisplayName,S as getQuestionnaireAnswers,p as getReferenceString,rn as getSearchParameterDetails,Gi as getStatus,tt as getTypedPropertyValue,fe as globalSchema,qi as gone,me as indexSearchParameter,ue as indexStructureDefinition,le as indexStructureDefinitionBundle,Vi as isGone,_ as isLowerCase,zi as isNotFound,I as isObject,Hi as isOk,lt as isPeriod,f as isProfileResource,ut as isQuantity,mt as isQuantityEquivalent,M as isStringArray,k as isUUID,B as matchesRange,Bi as notFound,Wi as notModified,Ri as parseFhirPath,tn as parseSearchDefinition,q as preciseEquals,$ as preciseGreaterThan,z as preciseGreaterThanOrEquals,F as preciseLessThan,H as preciseLessThanOrEquals,it as removeDuplicates,h as resolveId,Q as setCodeBySystem,C as stringify,et as toJsBoolean,Ze as toTypedValue,di as tokenize};
1
+ function e(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 t(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 i(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 n,o,r,a;class s{constructor(e=10){n.add(this),o.set(this,void 0),r.set(this,void 0),i(this,o,e,"f"),i(this,r,new Map,"f")}clear(){t(this,r,"f").clear()}get(e){const i=t(this,r,"f").get(e);return i&&(t(this,r,"f").delete(e),t(this,r,"f").set(e,i)),i}set(e,i){t(this,r,"f").has(e)?t(this,r,"f").delete(e):t(this,r,"f").size>=t(this,o,"f")&&t(this,r,"f").delete(t(this,n,"m",a).call(this)),t(this,r,"f").set(e,i)}delete(e){t(this,r,"f").delete(e)}keys(){return t(this,r,"f").keys()}}function c(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()}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=[];return e.given&&t.push(...e.given),t.join(" ").trim()}function u(e){return e.family||""}function m(e){const t=p(e),i=y(e);return i===t?{reference:t}:{reference:t,display:i}}function p(e){return e.resourceType+"/"+e.id}function h(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]}function f(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function y(e){var t,i;if(f(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:p(e)}function g(e){if(f(e)){const t=e.photo;if(t)for(const e of t){const t=x(e);if(t)return t}}if("Bot"===e.resourceType&&e.photo){const t=x(e.photo);if(t)return t}}function x(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function v(e){return e?new Date(e):void 0}function w(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 E(e,t){const{years:i,months:n,days:o}=w(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"}function S(e){const t={};return b(e.item,t),t}function b(e,t){if(e)for(const i of e)i.linkId&&i.answer&&i.answer.length>0&&(t[i.linkId]=i.answer[0]),b(i.item,t)}function D(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}function T(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}function C(e,t){return JSON.stringify(e,P,t?2:void 0)}function P(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&A(t)?void 0:t}function A(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function R(e,t,i){return e===t||(!(!A(e)||!A(t))||!A(e)&&!A(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(!R(e[i],t[i]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(I(e)&&I(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(!R(e[i],t[i],i))return!1}return!0}(e,t,i):(I(e)||I(t),!1))))}function k(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)}function I(e){return null!==e&&"object"==typeof e}function M(e){return e.every((e=>"string"==typeof e))}o=new WeakMap,r=new WeakMap,n=new WeakSet,a=function(){return t(this,r,"f").keys().next().value};const O=[];for(let e=0;e<256;e++)O.push(e.toString(16).padStart(2,"0"));function U(e){const t=new Uint8Array(e),i=new Array(t.length);for(let e=0;e<t.length;e++)i[e]=O[t[e]];return i.join("")}function L(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 j(e){return e.charAt(0).toUpperCase()+e.substring(1)}function _(e){return e===e.toLowerCase()}function N(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}function Q(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})}function W(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||B(w(t.birthDate).years,e.age)}(e,t)}(o,t)&&function(e,t,i){return!!e.range&&B(t,e.range,i)}(o,i,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===n||o.category===n)}))}function B(e,t,i){var n,o;return(void 0===(null===(n=t.low)||void 0===n?void 0:n.value)||z(e,t.low.value,i))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||H(e,t.high.value,i))}function q(e,t,i){return i?Math.abs(e-t)<Math.pow(10,-i):e===t}function F(e,t,i){return i?e<t&&Math.abs(e-t)>Math.pow(10,-i):e<t}function $(e,t,i){return i?e>t&&Math.abs(e-t)>Math.pow(10,-i):e>t}function H(e,t,i){return F(e,t,i)||q(e,t,i)}function z(e,t,i){return $(e,t,i)||q(e,t,i)}function V(){const e=new Uint32Array(28);return crypto.getRandomValues(e),U(e.buffer)}var G,X,Y,K,J,Z,ee,te;function ie(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)}G=new WeakMap;class ne{constructor(e){this[Z]="ReadablePromise",X.set(this,void 0),Y.set(this,"pending"),K.set(this,void 0),J.set(this,void 0),i(this,X,e.then((e=>(i(this,Y,"success","f"),i(this,K,e,"f"),e)),(e=>{throw i(this,Y,"error","f"),i(this,J,e,"f"),e})),"f")}isPending(){return"pending"===t(this,Y,"f")}isOk(){return"success"===t(this,Y,"f")}read(){switch(t(this,Y,"f")){case"pending":throw t(this,X,"f");case"error":throw t(this,J,"f");default:return t(this,K,"f")}}then(e,i){return t(this,X,"f").then(e,i)}catch(e){return t(this,X,"f").catch(e)}finally(e){return t(this,X,"f").finally(e)}}X=new WeakMap,Y=new WeakMap,K=new WeakMap,J=new WeakMap,Z=Symbol.toStringTag;class oe{constructor(){ee.set(this,void 0),i(this,ee,"undefined"!=typeof localStorage?localStorage:new re,"f")}clear(){t(this,ee,"f").clear()}getString(e){return t(this,ee,"f").getItem(e)||void 0}setString(e,i){i?t(this,ee,"f").setItem(e,i):t(this,ee,"f").removeItem(e)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?C(t):void 0)}}ee=new WeakMap;class re{constructor(){te.set(this,void 0),i(this,te,new Map,"f")}get length(){return t(this,te,"f").size}clear(){t(this,te,"f").clear()}getItem(e){var i;return null!==(i=t(this,te,"f").get(e))&&void 0!==i?i:null}setItem(e,i){i?t(this,te,"f").set(e,i):t(this,te,"f").delete(e)}removeItem(e){t(this,te,"f").delete(e)}key(e){return Array.from(t(this,te,"f").keys())[e]}}te=new WeakMap;var ae,se={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 ce(){return{types:{}}}function de(e,t){return{display:e,description:t,properties:{},searchParams:{_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"}}}}function le(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&ue(fe,e)}}function ue(e,t){var i;const n=t.name;if(!n)return;n in e.types||(e.types[n]=de(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=pe(a);s in e.types||(e.types[s]=de(s,t.definition),e.types[s].parentType=pe(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=pe(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 me(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 pe(e){return e.map(j).join("")}function he(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(j).join(" ").replace("_"," ").replace(/\s+/g," ")}!function(e){e.Address="Address",e.Age="Age",e.Annotation="Annotation",e.Attachment="Attachment",e.BackboneElement="BackboneElement",e.CodeableConcept="CodeableConcept",e.Coding="Coding",e.ContactDetail="ContactDetail",e.ContactPoint="ContactPoint",e.Contributor="Contributor",e.Count="Count",e.DataRequirement="DataRequirement",e.Distance="Distance",e.Dosage="Dosage",e.Duration="Duration",e.Expression="Expression",e.Extension="Extension",e.HumanName="HumanName",e.Identifier="Identifier",e.MarketingStatus="MarketingStatus",e.Meta="Meta",e.Money="Money",e.Narrative="Narrative",e.ParameterDefinition="ParameterDefinition",e.Period="Period",e.Population="Population",e.ProdCharacteristic="ProdCharacteristic",e.ProductShelfLife="ProductShelfLife",e.Quantity="Quantity",e.Range="Range",e.Ratio="Ratio",e.Reference="Reference",e.RelatedArtifact="RelatedArtifact",e.SampledData="SampledData",e.Signature="Signature",e.SubstanceAmount="SubstanceAmount",e.SystemString="http://hl7.org/fhirpath/System.String",e.Timing="Timing",e.TriggerDefinition="TriggerDefinition",e.UsageContext="UsageContext",e.base64Binary="base64Binary",e.boolean="boolean",e.canonical="canonical",e.code="code",e.date="date",e.dateTime="dateTime",e.decimal="decimal",e.id="id",e.instant="instant",e.integer="integer",e.markdown="markdown",e.oid="oid",e.positiveInt="positiveInt",e.string="string",e.time="time",e.unsignedInt="unsignedInt",e.uri="uri",e.url="url",e.uuid="uuid"}(ae||(ae={}));const fe=se;var ye,ge,xe,ve,we,Ee,Se,be,De,Te,Ce,Pe,Ae,Re,ke,Ie,Me,Oe,Ue,Le,je,_e,Ne,Qe,We,Be,qe,Fe,$e,He,ze,Ve,Ge;const Xe="launch/patient openid fhirUser offline_access user/*.*";class Ye extends class{constructor(){G.set(this,void 0),i(this,G,{},"f")}addEventListener(e,i){t(this,G,"f")[e]||(t(this,G,"f")[e]=[]),t(this,G,"f")[e].push(i)}removeEventListeneer(e,i){const n=t(this,G,"f")[e];if(n)for(let e=0;e<n.length;e++)if(n[e]===i)return void n.splice(e,1)}dispatchEvent(e){const i=t(this,G,"f")[e.type];return i&&i.forEach((t=>t.call(this,e))),!e.defaultPrevented}}{constructor(e){var n,o;if(super(),ye.add(this),ge.set(this,void 0),xe.set(this,void 0),ve.set(this,void 0),we.set(this,void 0),Ee.set(this,void 0),Se.set(this,void 0),be.set(this,void 0),De.set(this,void 0),Te.set(this,void 0),Ce.set(this,void 0),Pe.set(this,void 0),Ae.set(this,void 0),Re.set(this,void 0),ke.set(this,void 0),Ie.set(this,void 0),Me.set(this,void 0),Oe.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")}i(this,ge,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),i(this,xe,null==e?void 0:e.createPdf,"f"),i(this,ve,new oe,"f"),i(this,we,new s(null!==(n=null==e?void 0:e.resourceCacheSize)&&void 0!==n?n:1e3),"f"),i(this,Ee,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:1e4,"f"),i(this,Se,(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),i(this,be,(null==e?void 0:e.clientId)||"","f"),i(this,De,(null==e?void 0:e.authorizeUrl)||t(this,Se,"f")+"oauth2/authorize","f"),i(this,Te,(null==e?void 0:e.tokenUrl)||t(this,Se,"f")+"oauth2/token","f"),i(this,Ce,(null==e?void 0:e.logoutUrl)||t(this,Se,"f")+"oauth2/logout","f"),i(this,Pe,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(i(this,Ae,r.accessToken,"f"),i(this,Re,r.refreshToken,"f"),t(this,ye,"m",Le).call(this).catch(console.log)),t(this,ye,"m",Ge).call(this)}getBaseUrl(){return t(this,Se,"f")}clear(){t(this,ve,"f").clear(),t(this,we,"f").clear(),i(this,Ae,void 0,"f"),i(this,Re,void 0,"f"),i(this,Me,void 0,"f"),i(this,Oe,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),t(this,we,"f").delete(e)}invalidateSearches(e){const i="fhir/R4/"+e;for(const e of t(this,we,"f").keys())(e.endsWith(i)||e.includes(i+"?"))&&t(this,we,"f").delete(e)}get(e,i={}){e=e.toString();const n=t(this,ye,"m",je).call(this,e,i);if(n)return n.value;const o=new ne(t(this,ye,"m",Ne).call(this,"GET",e,i));return t(this,ye,"m",_e).call(this,e,o),o}post(e,i,n,o={}){return e=e.toString(),i&&t(this,ye,"m",Be).call(this,o,i),n&&t(this,ye,"m",We).call(this,o,n),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"POST",e,o)}put(e,i,n,o={}){return e=e.toString(),i&&t(this,ye,"m",Be).call(this,o,i),n&&t(this,ye,"m",We).call(this,o,n),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"PUT",e,o)}patch(e,i,n={}){return e=e.toString(),t(this,ye,"m",Be).call(this,n,i),t(this,ye,"m",We).call(this,n,"application/json-patch+json"),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"PATCH",e,n)}delete(e,i={}){return e=e.toString(),this.invalidateUrl(e),t(this,ye,"m",Ne).call(this,"DELETE",e,i)}register(t){return e(this,void 0,void 0,(function*(){const e=yield this.post("auth/register",t);yield this.setActiveLogin(e)}))}startLogin(i){return e(this,void 0,void 0,(function*(){return yield t(this,ye,"m",Fe).call(this),this.post("auth/login",Object.assign(Object.assign({},i),{clientId:t(this,be,"f"),scope:Xe,codeChallengeMethod:"S256",codeChallenge:t(this,ve,"f").getString("codeChallenge")}))}))}startGoogleLogin(i){return e(this,void 0,void 0,(function*(){return yield t(this,ye,"m",Fe).call(this),this.post("auth/google",i)}))}signOut(){return this.clear(),Promise.resolve()}signInWithRedirect(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void t(this,ye,"m",$e).call(this)}signOutWithRedirect(){window.location.assign(t(this,Ce,"f"))}fhirUrl(...e){return new URL(t(this,Se,"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,i,n={}){const o=this.fhirSearchUrl(e,i);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=t(this,ye,"m",je).call(this,r,n);if(a)return a.value;const s=new ne(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 t(this,ye,"m",_e).call(this,r,s),s}searchResources(e,i,n={}){const o=this.fhirSearchUrl(e,i).toString()+"-searchResources",r=t(this,ye,"m",je).call(this,o,n);if(r)return r.value;const a=new ne(this.search(e,i,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 t(this,ye,"m",_e).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,i){var n;const o=null===(n=t(this,we,"f").get(this.fhirUrl(e,i).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 ne(Promise.reject(new Error("Missing reference")));const[i,n]=t.split("/");return i&&n?this.readResource(i,n):new ne(Promise.reject(new Error("Invalid reference")))}getSchema(){return fe}requestSchema(t){return e(this,void 0,void 0,(function*(){if(t in fe.types)return fe;const e=`{\n StructureDefinitionList(name: "${t}") {\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: "${t}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(e);for(const e of i.data.StructureDefinitionList)ue(fe,e);for(const e of i.data.SearchParameterList)me(fe,e);return fe}))}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(t,i){var n;return e(this,void 0,void 0,(function*(){return null!==(n=yield this.searchOne(t.resourceType,i))&&void 0!==n?n:this.createResource(t)}))}createBinary(e,t,i){const n=this.fhirUrl("Binary");return t&&n.searchParams.set("_filename",t),this.post(n,e,i)}createPdf(i,n,o,r){return e(this,void 0,void 0,(function*(){if(!t(this,xe,"f"))throw new Error("PDF creation not enabled");const e=yield t(this,xe,"f").call(this,i,o,r);return this.createBinary(e,n,"application/pdf")}))}createComment(e,t){const i=this.getProfile();let n,o;return"Encounter"===e.resourceType&&(n=m(e),o=e.subject),"ServiceRequest"===e.resourceType&&(n=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=m(e)),this.createResource({resourceType:"Communication",basedOn:[m(e)],encounter:n,subject:o,sender:i?m(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 t(this,ve,"f").getObject("activeLogin")}setActiveLogin(n){return e(this,void 0,void 0,(function*(){i(this,Ae,n.accessToken,"f"),i(this,Re,n.refreshToken,"f"),i(this,Me,void 0,"f"),i(this,Oe,void 0,"f"),t(this,ve,"f").setObject("activeLogin",n),t(this,ye,"m",Ue).call(this,n),t(this,we,"f").clear(),i(this,ke,void 0,"f"),yield t(this,ye,"m",Le).call(this)}))}getAccessToken(){return t(this,Ae,"f")}setAccessToken(e){i(this,Ae,e,"f"),i(this,Re,void 0,"f"),i(this,Me,void 0,"f"),i(this,Oe,void 0,"f")}getLogins(){var e;return null!==(e=t(this,ve,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!t(this,Ie,"f")}getProfile(){return t(this,Me,"f")}getProfileAsync(){return e(this,void 0,void 0,(function*(){return t(this,Ie,"f")&&(yield t(this,Ie,"f")),this.getProfile()}))}getUserConfiguration(){return t(this,Oe,"f")}download(i,n={}){return e(this,void 0,void 0,(function*(){t(this,ke,"f")&&(yield t(this,ke,"f")),t(this,ye,"m",Qe).call(this,n);return(yield t(this,ge,"f").call(this,i.toString(),n)).blob()}))}processCode(e){if(!t(this,ve,"f").getString("pkceState"))throw this.clear(),new Error("Invalid PCKE state");const i=t(this,ve,"f").getString("codeVerifier");if(!i)throw this.clear(),new Error("Invalid PCKE code verifier");const n=new URLSearchParams;return n.set("grant_type","authorization_code"),n.set("client_id",t(this,be,"f")),n.set("code_verifier",i),n.set("code",e),n.set("redirect_uri",Ke()),t(this,ye,"m",ze).call(this,n)}startClientLogin(i,n){return e(this,void 0,void 0,(function*(){const e=new URLSearchParams;return e.set("grant_type","client_credentials"),e.set("client_id",i),e.set("client_secret",n),t(this,ye,"m",ze).call(this,e)}))}}function Ke(){return window.location.protocol+"//"+window.location.host+"/"}function Je(e){return[{type:ae.boolean,value:e}]}function Ze(e){return null==e?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:ae.integer,value:e}:"number"==typeof e?{type:ae.decimal,value:e}:"boolean"==typeof e?{type:ae.boolean,value:e}:"string"==typeof e?{type:ae.string,value:e}:ut(e)?{type:ae.Quantity,value:e}:"object"==typeof e&&"resourceType"in e?{type:e.resourceType,value:e}:{type:ae.BackboneElement,value:e}}function et(e){return 0!==e.length&&!!e[0].value}function tt(e,t){if(!(null==e?void 0:e.value))return;const i=fe.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]","")+j(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=pe([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(Ze):Ze(n)}(e,t)}function it(e){const t=[];for(const i of e){let e=!1;for(const n of t)if(et(rt(i,n))){e=!0;break}e||t.push(i)}return t}function nt(e){return Je(!et(e))}function ot(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?Je(!1):Je(e.every(((e,i)=>et(rt(e,t[i])))))}function rt(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Je(Math.abs(i-n)<1e-8):ut(i)&&ut(n)?Je(mt(i,n)):Je("object"==typeof i&&"object"==typeof n?pt(e,t):i===n)}function at(e,t){return 0===e.length&&0===t.length?Je(!0):e.length!==t.length?Je(!1):(e.sort(ct),t.sort(ct),Je(e.every(((e,i)=>et(st(e,t[i]))))))}function st(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Je(Math.abs(i-n)<.01):ut(i)&&ut(n)?Je(mt(i,n)):Je("object"==typeof i&&"object"==typeof n?pt(i,n):"string"==typeof i&&"string"==typeof n?i.toLowerCase()===n.toLowerCase():i===n)}function ct(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 dt(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 lt(i);case"Quantity":return ut(i);default:return"object"==typeof i&&(null==i?void 0:i.resourceType)===t}}function lt(e){return!(!e||"object"!=typeof e||!("start"in e))}function ut(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function mt(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 pt(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(ht(i)&&ht(o)){if(!pt(i,o))return!1}else if(i!==o)return!1}return!0}function ht(e){return null!==e&&"object"==typeof e}var ft,yt;ge=new WeakMap,xe=new WeakMap,ve=new WeakMap,we=new WeakMap,Ee=new WeakMap,Se=new WeakMap,be=new WeakMap,De=new WeakMap,Te=new WeakMap,Ce=new WeakMap,Pe=new WeakMap,Ae=new WeakMap,Re=new WeakMap,ke=new WeakMap,Ie=new WeakMap,Me=new WeakMap,Oe=new WeakMap,ye=new WeakSet,Ue=function(e){const i=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)}));i.push(e),t(this,ve,"f").setObject("logins",i)},Le=function(){return e(this,void 0,void 0,(function*(){return i(this,Ie,new Promise(((e,n)=>{this.get("auth/me").then((n=>{i(this,Ie,void 0,"f"),i(this,Me,n.profile,"f"),i(this,Oe,n.config,"f"),this.dispatchEvent({type:"change"}),e(t(this,Me,"f"))})).catch(n)})),"f"),t(this,Ie,"f")}))},je=function(e,i){if(t(this,Ee,"f")<=0||"no-cache"===(null==i?void 0:i.cache)||"reload"===(null==i?void 0:i.cache))return;const n=t(this,we,"f").get(e);return!n||n.requestTime+t(this,Ee,"f")<Date.now()?void 0:n},_e=function(e,i){t(this,Ee,"f")>0&&t(this,we,"f").set(e,{requestTime:Date.now(),value:i})},Ne=function(i,n,o={}){return e(this,void 0,void 0,(function*(){t(this,ke,"f")&&(yield t(this,ke,"f")),n.startsWith("http")||(n=t(this,Se,"f")+n),o.method=i,t(this,ye,"m",Qe).call(this,o);const e=yield t(this,ge,"f").call(this,n,o);if(401===e.status)return t(this,ye,"m",qe).call(this,i,n,o);if(204===e.status||304===e.status)return;const r=yield e.json();if(e.status>=400)throw r;return r}))},Qe=function(e){e.headers||(e.headers={});const i=e.headers;i["Content-Type"]||(i["Content-Type"]="application/fhir+json"),t(this,Ae,"f")&&(i.Authorization="Bearer "+t(this,Ae,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},We=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))},qe=function(i,n,o){return e(this,void 0,void 0,(function*(){return t(this,ye,"m",He).call(this).then((()=>t(this,ye,"m",Ne).call(this,i,n,o))).catch((e=>(this.clear(),t(this,Pe,"f")&&t(this,Pe,"f").call(this),Promise.reject(e))))}))},Fe=function(){return e(this,void 0,void 0,(function*(){const i=V();t(this,ve,"f").setString("pkceState",i);const n=V();t(this,ve,"f").setString("codeVerifier",n);const o=L(yield function(t){return e(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t))}))}(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");t(this,ve,"f").setString("codeChallenge",o)}))},$e=function(){t(this,ye,"m",Fe).call(this);const e=new URL(t(this,De,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",t(this,ve,"f").getString("pkceState")),e.searchParams.set("client_id",t(this,be,"f")),e.searchParams.set("redirect_uri",Ke()),e.searchParams.set("scope",Xe),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",t(this,ve,"f").getString("codeChallenge")),window.location.assign(e.toString())},He=function(){return e(this,void 0,void 0,(function*(){if(t(this,ke,"f"))return t(this,ke,"f");if(!t(this,Re,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",t(this,be,"f")),e.set("refresh_token",t(this,Re,"f")),i(this,ke,t(this,ye,"m",ze).call(this,e),"f"),yield t(this,ke,"f")}))},ze=function(i){return e(this,void 0,void 0,(function*(){return t(this,ge,"f").call(this,t(this,Te,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>t(this,ye,"m",Ve).call(this,e))).then((()=>this.getProfile()))}))},Ve=function(i){return e(this,void 0,void 0,(function*(){const e=i.access_token,n=function(e){const[t,i,n]=e.split(".");return ie(i)}(e);if(Date.now()>=1e3*n.exp)throw this.clear(),new Error("Token expired");if(t(this,be,"f")&&n.client_id!==t(this,be,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:e,refreshToken:i.refresh_token,project:i.project,profile:i.profile})}))},Ge=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};class gt{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 xt{constructor(e){this.value=e}eval(){return[this.value]}}class vt{constructor(e){this.name=e,ft.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>t(this,ft,"m",yt).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}ft=new WeakSet,yt=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:tt(e,this.name)};class wt{eval(){return[]}}class Et{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class St{constructor(e,t){this.left=e,this.right=t}eval(e){return this.left.eval(e)}}class bt{constructor(e,t,i){this.left=e,this.right=t,this.impl=i}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const i=this.right.eval(e);if(1!==i.length)return[];const n=t[0].value,o=i[0].value,r=ut(n)?n.value:n,a=ut(o)?o.value:o,s=this.impl(r,a);return"boolean"==typeof s?Je(s):ut(n)?[{type:ae.Quantity,value:Object.assign(Object.assign({},n),{value:s})}]:[Ze(s)]}}class Dt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=[...this.left.eval(e),...this.right.eval(e)];return t.length>0&&t.every((e=>"string"==typeof e.value))?[{type:ae.string,value:t.map((e=>e.value)).join("")}]:t}}class Tt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);return Je(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 Je(this.right.eval(e).some((e=>e.value===t[0].value)))}}class Pt{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class At{constructor(e,t){this.left=e,this.right=t}eval(e){return it([...this.left.eval(e),...this.right.eval(e)])}}class Rt{constructor(e,t){this.left=e,this.right=t}eval(e){return ot(this.left.eval(e),this.right.eval(e))}}class kt{constructor(e,t){this.left=e,this.right=t}eval(e){return nt(ot(this.left.eval(e),this.right.eval(e)))}}class It{constructor(e,t){this.left=e,this.right=t}eval(e){return at(this.left.eval(e),this.right.eval(e))}}class Mt{constructor(e,t){this.left=e,this.right=t}eval(e){return nt(at(this.left.eval(e),this.right.eval(e)))}}class Ot{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 Je(dt(t[0],i))}}class Ut{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)?Je(!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)?Je(!1):[]}}class Lt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(et(t))return t;const i=this.right.eval(e);return et(i)?i:[]}}class jt{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?Je(!0):!0===n&&!0===o||!1===n&&!1===o?Je(!1):[]}}class _t{constructor(e,t,i){this.name=e,this.args=t,this.impl=i}eval(e){return this.impl(e,...this.args)}}class Nt{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 Qt(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=()=>[],Bt={empty:e=>Je(0===e.length),exists:(e,t)=>Je(t?e.filter((e=>et(t.eval([e])))).length>0:e.length>0),all:(e,t)=>Je(e.every((e=>et(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return Je(!1);return Je(!0)},anyTrue:e=>{for(const t of e)if(t.value)return Je(!0);return Je(!1)},allFalse:e=>{for(const t of e)if(t.value)return Je(!1);return Je(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return Je(!0);return Je(!1)},subsetOf:Wt,supersetOf:Wt,count:e=>[{type:ae.integer,value:e.length}],distinct:e=>{const t=[];for(const i of e)t.some((e=>e.value===i.value))||t.push(i);return t},isDistinct:e=>Je(e.length===Bt.distinct(e).length),where:(e,t)=>e.filter((e=>et(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 it([...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 et(o)?i.eval(e):n?n.eval(e):[]},toBoolean:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);if("boolean"==typeof t)return[{type:ae.boolean,value:t}];if("number"==typeof t&&(0===t||1===t))return Je(!!t);if("string"==typeof t){const e=t.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return Je(!0);if(["false","f","no","n","0","0.0"].includes(e))return Je(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:Je(1===Bt.toBoolean(e).length),toInteger:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"number"==typeof t?[{type:ae.integer,value:t}]:"string"==typeof t&&t.match(/^[+-]?\d+$/)?[{type:ae.integer,value:parseInt(t,10)}]:"boolean"==typeof t?[{type:ae.integer,value:t?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:Je(1===Bt.toInteger(e).length),toDate:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:ae.date,value:Qt(t)}]:[]},convertsToDate:e=>0===e.length?[]:Je(1===Bt.toDate(e).length),toDateTime:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:ae.dateTime,value:Qt(t)}]:[]},convertsToDateTime:e=>0===e.length?[]:Je(1===Bt.toDateTime(e).length),toDecimal:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"number"==typeof t?[{type:ae.decimal,value:t}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:ae.decimal,value:parseFloat(t)}]:"boolean"==typeof t?[{type:ae.decimal,value:t?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:Je(1===Bt.toDecimal(e).length),toQuantity:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return ut(t)?[{type:ae.Quantity,value:t}]:"number"==typeof t?[{type:ae.Quantity,value:{value:t,unit:"1"}}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:ae.Quantity,value:{value:parseFloat(t),unit:"1"}}]:"boolean"==typeof t?[{type:ae.Quantity,value:{value:t?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:Je(1===Bt.toQuantity(e).length),toString:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return null==t?[]:ut(t)?[{type:ae.string,value:`${t.value} '${t.unit}'`}]:[{type:ae.string,value:t.toString()}]},convertsToString:e=>0===e.length?[]:Je(1===Bt.toString(e).length),toTime:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);if("string"==typeof t){const e=t.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(e)return[{type:ae.time,value:Qt("T"+e[1])}]}return[]},convertsToTime:e=>0===e.length?[]:Je(1===Bt.toTime(e).length),indexOf:(e,t)=>qt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,i)=>qt(((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)=>qt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>qt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>qt(((e,t)=>e.includes(t)),e,t),upper:e=>qt((e=>e.toUpperCase()),e),lower:e=>qt((e=>e.toLowerCase()),e),replace:(e,t,i)=>qt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),matches:(e,t)=>qt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,i)=>qt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),length:e=>qt((e=>e.length),e),toChars:e=>qt((e=>e?e.split(""):void 0),e),abs:e=>Ft(Math.abs,e),ceiling:e=>Ft(Math.ceil,e),exp:e=>Ft(Math.exp,e),floor:e=>Ft(Math.floor,e),ln:e=>Ft(Math.log,e),log:(e,t)=>Ft(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>Ft(Math.pow,e,t),round:e=>Ft(Math.round,e),sqrt:e=>Ft(Math.sqrt,e),truncate:e=>Ft((e=>0|e),e),children:Wt,descendants:Wt,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:ae.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:ae.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:ae.date,value:(new Date).toISOString().substring(0,10)}],between:(e,t,i,n)=>{var o;const r=Bt.toDateTime(t.eval(e));if(0===r.length)throw new Error("Invalid start date");const a=Bt.toDateTime(i.eval(e));if(0===a.length)throw new Error("Invalid end date");const s=null===(o=n.eval(e)[0])||void 0===o?void 0:o.value;if("years"!==s&&"months"!==s&&"days"!==s)throw new Error("Invalid units");const c=w(r[0].value,a[0].value);return[{type:ae.Quantity,value:{value:c[s],unit:s}}]},is:(e,t)=>{let i="";return t instanceof vt?i=t.name:t instanceof Pt&&(i=t.left.name+"."+t.right.name),i?e.map((e=>({type:ae.boolean,value:dt(e,i)}))):[]},not:e=>Bt.toBoolean(e).map((e=>({type:ae.boolean,value:!e.value}))),resolve:e=>e.map((e=>{const t=e.value;let i;if("string"==typeof t)i=t;else if("object"==typeof t){const e=t;if(e.resource)return Ze(e.resource);i=e.reference}if(!i)return{type:ae.BackboneElement,value:null};const[n,o]=i.split("/");return{type:ae.BackboneElement,value:{resourceType:n,id:o}}})).filter((e=>!!e.value)),as:e=>e,type:e=>e.map((({value:e})=>"boolean"==typeof e?{type:ae.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof e?{type:ae.BackboneElement,value:{namespace:"System",name:"Integer"}}:e&&"object"==typeof e&&"resourceType"in e?{type:ae.BackboneElement,value:{namespace:"FHIR",name:e.resourceType}}:{type:ae.BackboneElement,value:null})),conformsTo:(e,t)=>{const i=t.eval(e)[0].value;if(!i.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const n=i.replace("http://hl7.org/fhir/StructureDefinition/","");return e.map((e=>{var t;return{type:ae.boolean,value:(null===(t=e.value)||void 0===t?void 0:t.resourceType)===n}}))}};function qt(e,t,...i){if(0===t.length)return[];const[{value:n}]=$t(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(Ze):[Ze(o)]}function Ft(e,t,...i){if(0===t.length)return[];const[{value:n}]=$t(t,1),o=ut(n),r=o?n.value:n;if("number"!=typeof r)throw new Error("Math function cannot be called with non-number");const a=e(r,...i.map((e=>{var i,n;return null===(n=null===(i=e.eval(t))||void 0===i?void 0:i[0])||void 0===n?void 0:n.value})));return[{type:o?ae.Quantity:t[0].type,value:o?Object.assign(Object.assign({},n),{value:a}):a}]}function $t(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 Ht,zt,Vt,Gt,Xt,Yt,Kt,Jt,Zt,ei,ti,ii,ni,oi,ri,ai,si,ci;function di(e){return new mi(e).tokenize()}const li=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],ui=["!=","!~","<=",">=","{}"];class mi{constructor(e){Ht.add(this),zt.set(this,void 0),Vt.set(this,void 0),i(this,zt,e,"f"),i(this,Vt,0,"f")}tokenize(){const e=[];for(;t(this,Vt,"f")<t(this,zt,"f").length;){const i=t(this,Ht,"m",Xt).call(this);i&&e.push(i)}return e}}function pi(e,t){return{id:e,value:t}}var hi,fi,yi,gi,xi,vi,wi,Ei,Si;zt=new WeakMap,Vt=new WeakMap,Ht=new WeakSet,Gt=function(){const e=t(this,Vt,"f"),n=t(this,Ht,"m",Xt).call(this);return i(this,Vt,e,"f"),n},Xt=function(){t(this,Ht,"m",Yt).call(this);const e=t(this,Ht,"m",ai).call(this);if(!e)return;const i=t(this,Ht,"m",ci).call(this);return"/"===e&&"*"===i?t(this,Ht,"m",Kt).call(this):"/"===e&&"/"===i?t(this,Ht,"m",Jt).call(this):"'"===e?t(this,Ht,"m",Zt).call(this):"`"===e?t(this,Ht,"m",ei).call(this):"@"===e?t(this,Ht,"m",ti).call(this):e.match(/\d/)?t(this,Ht,"m",ii).call(this):e.match(/\w/)||"$"===e&&i.match(/\w/)?t(this,Ht,"m",ni).call(this):t(this,Ht,"m",oi).call(this)},Yt=function(){return pi("Whitespace",t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/\s/))))},Kt=function(){const e=t(this,Vt,"f");return t(this,Ht,"m",ri).call(this,(()=>"*"!==t(this,Ht,"m",ai).call(this)||"/"!==t(this,Ht,"m",ci).call(this))),i(this,Vt,t(this,Vt,"f")+2,"f"),pi("Comment",t(this,zt,"f").substring(e,t(this,Vt,"f")))},Jt=function(){return pi("Comment",t(this,Ht,"m",ri).call(this,(()=>"\n"!==t(this,Ht,"m",ai).call(this))))},Zt=function(){var e,n;i(this,Vt,(e=t(this,Vt,"f"),++e),"f");const o=pi("String",t(this,Ht,"m",ri).call(this,(()=>"\\"===t(this,Ht,"m",si).call(this)||"'"!==t(this,Ht,"m",ai).call(this))));return i(this,Vt,(n=t(this,Vt,"f"),++n),"f"),o},ei=function(){var e,n;i(this,Vt,(e=t(this,Vt,"f"),++e),"f");const o=pi("Symbol",t(this,Ht,"m",ri).call(this,(()=>"`"!==t(this,Ht,"m",ai).call(this))));return i(this,Vt,(n=t(this,Vt,"f"),++n),"f"),o},ti=function(){var e,n,o,r,a;const s=t(this,Vt,"f");return i(this,Vt,(e=t(this,Vt,"f"),++e),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d-]/))),"T"===t(this,Ht,"m",ai).call(this)&&(i(this,Vt,(n=t(this,Vt,"f"),++n),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d:]/))),"."===t(this,Ht,"m",ai).call(this)&&t(this,Ht,"m",ci).call(this).match(/\d/)&&(i(this,Vt,(o=t(this,Vt,"f"),++o),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d]/)))),"Z"===t(this,Ht,"m",ai).call(this)?i(this,Vt,(r=t(this,Vt,"f"),++r),"f"):"+"!==t(this,Ht,"m",ai).call(this)&&"-"!==t(this,Ht,"m",ai).call(this)||(i(this,Vt,(a=t(this,Vt,"f"),++a),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[\d:]/))))),pi("DateTime",t(this,zt,"f").substring(s+1,t(this,Vt,"f")))},ii=function(){var e;const n=t(this,Vt,"f");let o="Number";return t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/\d/))),"."===t(this,Ht,"m",ai).call(this)&&t(this,Ht,"m",ci).call(this).match(/\d/)&&(i(this,Vt,(e=t(this,Vt,"f"),++e),"f"),t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/\d/))))," "===t(this,Ht,"m",ai).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&li.includes(e.value))return!0}return!1}(t(this,Ht,"m",Gt).call(this))&&(o="Quantity",t(this,Ht,"m",Xt).call(this)),pi(o,t(this,zt,"f").substring(n,t(this,Vt,"f")))},ni=function(){return pi("Symbol",t(this,Ht,"m",ri).call(this,(()=>t(this,Ht,"m",ai).call(this).match(/[$\w]/))))},oi=function(){var e;const n=t(this,Ht,"m",ai).call(this),o=n+t(this,Ht,"m",ci).call(this);return ui.includes(o)?(i(this,Vt,t(this,Vt,"f")+2,"f"),pi(o,o)):(i(this,Vt,(e=t(this,Vt,"f"),++e),"f"),pi(n,n))},ri=function(e){var n;const o=t(this,Vt,"f");for(;t(this,Vt,"f")<t(this,zt,"f").length&&e();)i(this,Vt,(n=t(this,Vt,"f"),++n),"f");return t(this,zt,"f").substring(o,t(this,Vt,"f"))},ai=function(){return t(this,zt,"f")[t(this,Vt,"f")]},si=function(){var e;return null!==(e=t(this,zt,"f")[t(this,Vt,"f")-1])&&void 0!==e?e:""},ci=function(){var e;return null!==(e=t(this,zt,"f")[t(this,Vt,"f")+1])&&void 0!==e?e:""};hi=new WeakMap,fi=new WeakMap;class bi{constructor(e,t,n){yi.add(this),gi.set(this,void 0),xi.set(this,void 0),vi.set(this,void 0),i(this,gi,e,"f"),i(this,xi,t,"f"),i(this,vi,n,"f")}match(e){const i=t(this,yi,"m",Si).call(this);return(null==i?void 0:i.id)===e&&(t(this,yi,"m",Ei).call(this),!0)}consumeAndParse(e=100){const i=t(this,yi,"m",Ei).call(this),n=t(this,xi,"f")[i.id];if(!n)throw Error(`Parse error at ${i.value}. No matching prefix parselet.`);let o=n.parse(this,i);for(;e>t(this,yi,"m",wi).call(this);){const e=t(this,yi,"m",Ei).call(this);o=t(this,vi,"f")[e.id].parse(this,o,e)}return o}}gi=new WeakMap,xi=new WeakMap,vi=new WeakMap,yi=new WeakSet,wi=function(){const e=t(this,yi,"m",Si).call(this);if(!e)return 100;const i=t(this,vi,"f")[e.id];return i?i.precedence:100},Ei=function(){if(!t(this,gi,"f").length)throw Error("Cant consume unknown more tokens.");return t(this,gi,"f").shift()},Si=function(){return t(this,gi,"f").length>0?t(this,gi,"f")[0]:void 0};const Di={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},Ti={parse(e,t){const i=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new Nt(t,i)},precedence:2},Ci={parse(e,t){if(!(t instanceof vt))throw new Error("Unexpected parentheses");if(!(t.name in Bt))throw new Error("Unrecognized function: "+t.name);const i=[];for(;!e.match(")");)i.push(e.consumeAndParse()),e.match(",");return new _t(t.name,i,Bt[t.name])},precedence:0};function Pi(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 Ai=(new class{constructor(){hi.set(this,{}),fi.set(this,{})}registerInfix(e,i){return t(this,fi,"f")[e]=i,this}registerPrefix(e,i){return t(this,hi,"f")[e]=i,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 bi(di(e),t(this,hi,"f"),t(this,fi,"f"))}}).registerPrefix("String",{parse:(e,t)=>new xt({type:ae.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new xt({type:ae.dateTime,value:Qt(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new xt({type:ae.Quantity,value:Pi(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new xt({type:ae.decimal,value:parseFloat(t.value)})}).registerPrefix("Symbol",{parse:(e,t)=>"false"===t.value?new xt({type:ae.boolean,value:!1}):"true"===t.value?new xt({type:ae.boolean,value:!0}):new vt(t.value)}).registerPrefix("{}",{parse:()=>new wt}).registerPrefix("(",Di).registerInfix("[",Ti).registerInfix("(",Ci).prefix("+",3,((e,t)=>new Et(t,(e=>e)))).prefix("-",3,((e,t)=>new bt(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,i)=>new Pt(e,i))).infixLeft("/",4,((e,t,i)=>new bt(e,i,((e,t)=>e/t)))).infixLeft("*",4,((e,t,i)=>new bt(e,i,((e,t)=>e*t)))).infixLeft("+",5,((e,t,i)=>new bt(e,i,((e,t)=>e+t)))).infixLeft("-",5,((e,t,i)=>new bt(e,i,((e,t)=>e-t)))).infixLeft("|",7,((e,t,i)=>new At(e,i))).infixLeft("=",9,((e,t,i)=>new Rt(e,i))).infixLeft("!=",9,((e,t,i)=>new kt(e,i))).infixLeft("~",9,((e,t,i)=>new It(e,i))).infixLeft("!~",9,((e,t,i)=>new Mt(e,i))).infixLeft("<",8,((e,t,i)=>new bt(e,i,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,i)=>new bt(e,i,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,i)=>new bt(e,i,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,i)=>new bt(e,i,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,i)=>new Dt(e,i))).infixLeft("Symbol",6,((e,t,i)=>{switch(t.value){case"and":return new Ut(e,i);case"as":return new St(e,i);case"contains":return new Tt(e,i);case"div":return new bt(e,i,((e,t)=>e/t|0));case"in":return new Ct(e,i);case"is":return new Ot(e,i);case"mod":return new bt(e,i,((e,t)=>e%t));case"or":return new Lt(e,i);case"xor":return new jt(e,i);default:throw new Error("Cannot use "+t.value+" as infix operator")}}));function Ri(e){try{return new gt(e,Ai.construct(e).consumeAndParse())}catch(t){throw new Error(`FhirPathError on "${e}": ${t}`)}}function ki(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]=Ze(i[e]))}return Ii(e,i).map((e=>e.value))}function Ii(e,t){return Ri(e).eval(t)}const Mi="\r",Oi="|",Ui="^";class Li{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 Li([new ji(["MSH","^~\\&",l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p]),new ji(["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 Li(e.split(/[\r\n]+/).map((e=>ji.parse(e))))}}class ji{constructor(e){M(e)?this.fields=e.map((e=>_i.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 ji(e.split("|").map((e=>_i.parse(e))))}}class _i{constructor(e){this.components=e}get(e){return this.components[e]}toString(){return this.components.join("^")}static parse(e){return new _i(e.split("^"))}}const Ni={resourceType:"OperationOutcome",id:"ok",issue:[{severity:"information",code:"information",details:{text:"All OK"}}]},Qi={resourceType:"OperationOutcome",id:"created",issue:[{severity:"information",code:"information",details:{text:"Created"}}]},Wi={resourceType:"OperationOutcome",id:"not-modified",issue:[{severity:"information",code:"information",details:{text:"Not Modified"}}]},Bi={resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},qi={resourceType:"OperationOutcome",id:"gone",issue:[{severity:"error",code:"gone",details:{text:"Gone"}}]},Fi={resourceType:"OperationOutcome",id:"access-denied",issue:[{severity:"error",code:"access-denied",details:{text:"Access Denied"}}]};function $i(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}}function Hi(e){return"ok"===e.id||"created"===e.id||"not-modified"===e.id}function zi(e){return"not-found"===e.id}function Vi(e){return"gone"===e.id}function Gi(e){return"ok"===e.id?200:"created"===e.id?201:"not-modified"===e.id?304:"access-denied"===e.id?403:"not-found"===e.id?404:"gone"===e.id?410:400}function Xi(e,t){if(!Hi(e)||void 0===t)throw new Yi(e)}class Yi 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}}const Ki=20;var Ji;!function(e){e.EQUALS="eq",e.NOT_EQUALS="ne",e.GREATER_THAN="gt",e.LESS_THAN="lt",e.GREATER_THAN_OR_EQUALS="ge",e.LESS_THAN_OR_EQUALS="le",e.STARTS_AFTER="sa",e.ENDS_BEFORE="eb",e.APPROXIMATELY="ap",e.CONTAINS="contains",e.EXACT="exact",e.TEXT="text",e.NOT="not",e.ABOVE="above",e.BELOW="below",e.IN="in",e.NOT_IN="not-in",e.OF_TYPE="of-type",e.MISSING="missing"}(Ji||(Ji={}));const Zi=[Ji.CONTAINS,Ji.EXACT,Ji.TEXT,Ji.NOT,Ji.ABOVE,Ji.BELOW,Ji.IN,Ji.NOT_IN,Ji.OF_TYPE,Ji.MISSING],en=[Ji.NOT_EQUALS,Ji.GREATER_THAN,Ji.LESS_THAN,Ji.GREATER_THAN_OR_EQUALS,Ji.LESS_THAN_OR_EQUALS,Ji.STARTS_AFTER,Ji.ENDS_BEFORE,Ji.APPROXIMATELY];function tn(e){const t=new URL(e,"https://example.com/"),i=t.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let n,o,r,a,s,c;return new URLSearchParams(t.search).forEach(((e,t)=>{"_fields"===t?r=e.split(","):"_offset"===t?a=parseInt(e):"_count"===t?s=parseInt(e):"_total"===t?c=e:"_sort"===t?(o=o||[],o.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(e))):(n=n||[],n.push(function(e,t){let i=e,n=Ji.EQUALS;for(const e of Zi){const t=i.indexOf(":"+e);-1!==t&&(n=e,i=i.substring(0,t))}for(const e of en)t.match(new RegExp("^"+e+"\\d"))&&(n=e,t=t.substring(e.length));return{code:i,operator:n,value:t}}(t,e)))})),{resourceType:i,filters:n,fields:r,offset:a,count:s,total:c,sortRules:o}}function nn(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=Zi.includes(e.operator)?":"+e.operator:"",i=en.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("&"))}var on;function rn(e,t,i){var n,o,r,a,s,c,d;if("_lastUpdated"===i.code)return{columnName:"lastUpdated",type:on.DATETIME};const l=i.code.split("-").reduce(((e,t,i)=>e+(i?j(t):t)),"");const u=null===(n=sn(t,i.expression))||void 0===n?void 0:n.split(".");if(!u)return{columnName:l,type:on.TEXT};const m=an(i);let p,h,f=t,y=!1;for(let n=1;n<u.length;n++){const g=u[n];if(p=null!==(a=null===(r=null===(o=e.types[f])||void 0===o?void 0:o.properties)||void 0===r?void 0:r[g])&&void 0!==a?a:null===(c=null===(s=e.types[f])||void 0===s?void 0:s.properties)||void 0===c?void 0:c[g+"[x]"],!p)throw new Error(`Element definition not found for ${t} ${i.code}`);if("*"===p.max&&(y=!0),h=null===(d=p.type)||void 0===d?void 0:d[0].code,!h)return{columnName:l,type:m,array:y};n<u.length-1&&("Element"===h||"BackboneElement"===h?f+=j(g):f=h)}return{columnName:l,type:an(i,h),elementDefinition:p,array:y}}function an(e,t){let i=on.TEXT;switch(e.type){case"date":i=t===ae.dateTime||t===ae.instant?on.DATETIME:on.DATE;break;case"number":i=on.NUMBER;break;case"quantity":i=on.QUANTITY;break;case"reference":i=on.REFERENCE;break;case"token":"boolean"===t&&(i=on.BOOLEAN)}return i}function sn(e,t){const i=t.split(" | ");for(const t of i){if((n=t).includes(" as Period")||n.includes(" as SampledDate"))continue;const i=cn(t);if(i.startsWith(e+"."))return i}var n}function cn(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}!function(e){e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.QUANTITY="QUANTITY",e.TEXT="TEXT",e.REFERENCE="REFERENCE",e.DATE="DATE",e.DATETIME="DATETIME",e.PERIOD="PERIOD"}(on||(on={}));export{Ut as AndAtom,bt as ArithemticOperatorAtom,St as AsAtom,Ui as COMPONENT_SEPARATOR,Dt as ConcatAtom,Tt as ContainsAtom,Ki as DEFAULT_SEARCH_COUNT,Pt as DotAtom,wt as EmptySetAtom,Rt as EqualsAtom,It as EquivalentAtom,Oi as FIELD_SEPARATOR,gt as FhirPathAtom,_t as FunctionAtom,_i as Hl7Field,Li as Hl7Message,ji as Hl7Segment,Ct as InAtom,Nt as IndexerAtom,Ot as IsAtom,s as LRUCache,xt as LiteralAtom,Ye as MedplumClient,kt as NotEqualsAtom,Mt as NotEquivalentAtom,Yi as OperationOutcomeError,Ji as Operator,Lt as OrAtom,ae as PropertyType,ne as ReadablePromise,Mi as SEGMENT_SEPARATOR,on as SearchParameterType,vt as SymbolAtom,Et as UnaryOperatorAtom,At as UnionAtom,jt as XorAtom,Fi as accessDenied,Ni as allOk,L as arrayBufferToBase64,U as arrayBufferToHex,Xi as assertOk,$i as badRequest,Je as booleanToTypedValue,pe as buildTypeName,w as calculateAge,E as calculateAgeString,j as capitalize,m as createReference,ce as createSchema,de as createTypeSchema,Qi as created,R as deepEquals,ki as evalFhirPath,Ii as evalFhirPathTyped,ot as fhirPathArrayEquals,at as fhirPathArrayEquivalent,rt as fhirPathEquals,st as fhirPathEquivalent,dt as fhirPathIs,nt as fhirPathNot,W as findObservationInterval,c as formatAddress,u as formatFamilyName,l as formatGivenName,d as formatHumanName,nn as formatSearchQuery,N as getCodeBySystem,v as getDateProperty,y as getDisplayString,sn as getExpressionForResourceType,T as getExtensionValue,D as getIdentifier,g as getImageSrc,he as getPropertyDisplayName,S as getQuestionnaireAnswers,p as getReferenceString,rn as getSearchParameterDetails,Gi as getStatus,tt as getTypedPropertyValue,fe as globalSchema,qi as gone,me as indexSearchParameter,ue as indexStructureDefinition,le as indexStructureDefinitionBundle,Vi as isGone,_ as isLowerCase,zi as isNotFound,I as isObject,Hi as isOk,lt as isPeriod,f as isProfileResource,ut as isQuantity,mt as isQuantityEquivalent,M as isStringArray,k as isUUID,B as matchesRange,Bi as notFound,Wi as notModified,Ri as parseFhirPath,tn as parseSearchDefinition,q as preciseEquals,$ as preciseGreaterThan,z as preciseGreaterThanOrEquals,F as preciseLessThan,H as preciseLessThanOrEquals,it as removeDuplicates,h as resolveId,Q as setCodeBySystem,C as stringify,et as toJsBoolean,Ze as toTypedValue,di as tokenize};
2
2
  //# sourceMappingURL=index.min.js.map