@medplum/core 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.core={}))}(this,(function(e){"use strict";function t(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{c(n.next(e))}catch(e){r(e)}}function s(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}var o,r,a,s;class c{constructor(e=10){o.add(this),r.set(this,void 0),a.set(this,void 0),n(this,r,e,"f"),n(this,a,new Map,"f")}clear(){i(this,a,"f").clear()}get(e){const t=i(this,a,"f").get(e);return t&&(i(this,a,"f").delete(e),i(this,a,"f").set(e,t)),t}set(e,t){i(this,a,"f").has(e)?i(this,a,"f").delete(e):i(this,a,"f").size>=i(this,r,"f")&&i(this,a,"f").delete(i(this,o,"m",s).call(this)),i(this,a,"f").set(e,t)}delete(e){i(this,a,"f").delete(e)}keys(){return i(this,a,"f").keys()}}function d(e,t){const i=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&i.push(...e.prefix),e.given&&i.push(...e.given),e.family&&i.push(e.family),e.suffix&&!1!==(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){return e instanceof Date&&!isNaN(e.getTime())}function u(e,t,i){if(!e)return"";const n=new Date("2000-01-01T"+e+"Z");return l(n)?n.toLocaleTimeString(t,i):""}function m(e,t,i){if(!e)return"";const n=new Date(e);return l(n)?n.toLocaleString(t,i):""}r=new WeakMap,a=new WeakMap,o=new WeakSet,s=function(){return i(this,a,"f").keys().next().value};const p={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},h={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},f={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function y(e,t){if(!e)return"";const i=[];return e.comparator&&(i.push(e.comparator),i.push(" ")),void 0!==e.value&&(void 0!==t?i.push(e.value.toFixed(t)):i.push(e.value)),e.unit&&("%"!==e.unit&&" "!==i[i.length-1]&&i.push(" "),i.push(e.unit)),i.join("").trim()}function g(e){return e?e.text?e.text:e.coding?e.coding.map((e=>v(e))).join(", "):"":""}function v(e){return(null==e?void 0:e.display)||(null==e?void 0:e.code)||""}function x(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function T(e){const t=w(e),i=E(e);return i===t?{reference:t}:{reference:t,display:i}}function w(e){return e.resourceType+"/"+e.id}function S(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function E(e){var t;if(S(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)?e.code.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:w(e)}function b(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function P(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 D(e,t){if(e)for(const i of e)i.linkId&&i.answer&&i.answer.length>0&&(t[i.linkId]=i.answer[0]),D(i.item,t)}function C(e,t){return JSON.stringify(e,A,t?2:void 0)}function A(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&R(t)?void 0:t}function R(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function O(e,t,i){return e===t||(!(!R(e)||!R(t))||!R(e)&&!R(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(!O(e[i],t[i]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(k(e)&&k(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(!O(e[i],t[i],i))return!1}return!0}(e,t,i):(k(e)||k(t),!1))))}function k(e){return null!==e&&"object"==typeof e}function M(e){return e.every((e=>"string"==typeof e))}const I=[];for(let e=0;e<256;e++)I.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]=I[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 N(e){return e.charAt(0).toUpperCase()+e.substring(1)}function j(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||_(P(t.birthDate).years,e.age)}(e,t)}function _(e,t,i){var n,o;return(void 0===(null===(n=t.low)||void 0===n?void 0:n.value)||B(e,t.low.value,i))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||Q(e,t.high.value,i))}function Q(e,t,i){return W(e,i)<=W(t,i)}function B(e,t,i){return W(e,i)>=W(t,i)}function W(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function q(){const e=new Uint32Array(28);return crypto.getRandomValues(e),U(e.buffer)}var F,H,$,z,V,G,X,Y;class J{constructor(){F.set(this,void 0),n(this,F,{},"f")}addEventListener(e,t){i(this,F,"f")[e]||(i(this,F,"f")[e]=[]),i(this,F,"f")[e].push(t)}removeEventListeneer(e,t){const n=i(this,F,"f")[e];if(n)for(let e=0;e<n.length;e++)if(n[e]===t)return void n.splice(e,1)}dispatchEvent(e){const t=i(this,F,"f")[e.type];return t&&t.forEach((t=>t.call(this,e))),!e.defaultPrevented}}function Z(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)}function K(e){const[t,i,n]=e.split(".");return Z(i)}F=new WeakMap;class ee{constructor(e){this[G]="ReadablePromise",H.set(this,void 0),$.set(this,"pending"),z.set(this,void 0),V.set(this,void 0),n(this,H,e.then((e=>(n(this,$,"success","f"),n(this,z,e,"f"),e)),(e=>{throw n(this,$,"error","f"),n(this,V,e,"f"),e})),"f")}isPending(){return"pending"===i(this,$,"f")}isOk(){return"success"===i(this,$,"f")}read(){switch(i(this,$,"f")){case"pending":throw i(this,H,"f");case"error":throw i(this,V,"f");default:return i(this,z,"f")}}then(e,t){return i(this,H,"f").then(e,t)}catch(e){return i(this,H,"f").catch(e)}finally(e){return i(this,H,"f").finally(e)}}H=new WeakMap,$=new WeakMap,z=new WeakMap,V=new WeakMap,G=Symbol.toStringTag;class te{constructor(){X.set(this,void 0),n(this,X,"undefined"!=typeof localStorage?localStorage:new ie,"f")}clear(){i(this,X,"f").clear()}getString(e){return i(this,X,"f").getItem(e)||void 0}setString(e,t){t?i(this,X,"f").setItem(e,t):i(this,X,"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)}}X=new WeakMap;class ie{constructor(){Y.set(this,void 0),n(this,Y,new Map,"f")}get length(){return i(this,Y,"f").size}clear(){i(this,Y,"f").clear()}getItem(e){var t;return null!==(t=i(this,Y,"f").get(e))&&void 0!==t?t:null}setItem(e,t){t?i(this,Y,"f").set(e,t):i(this,Y,"f").delete(e)}removeItem(e){i(this,Y,"f").delete(e)}key(e){return Array.from(i(this,Y,"f").keys())[e]}}Y=new WeakMap;var ne,oe={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 re(e){var t;if(!e.name)return;const i=null===(t=e.snapshot)||void 0===t?void 0:t.element;i&&(i.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(void 0!==r&&"Element"!==r&&"BackboneElement"!==r)return;const a=o.split("."),s=se(a);de.types[s]=function(e,t,i){return{structureDefinition:t,elementDefinition:i,display:e,description:i.definition,properties:{}}}(s,e,t),de.types[s].parentType=se(a.slice(0,a.length-1))}(e,t))),i.forEach((e=>function(e){const t=e.path,i=t.split(".");if(1===i.length)return;const n=se(i.slice(0,i.length-1)),o=de.types[n];if(!o)return;const r=i[i.length-1];o.properties[r]=e}(e))))}function ae(e){if(e.base)for(const t of e.base){const i=de.types[t];i&&(i.searchParams||(i.searchParams={_id:{base:[t],code:"_id",type:"token",expression:t+".id"},_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"},_compartment:{base:[t],code:"_compartment",type:"reference",expression:t+".meta.compartment"}}),i.searchParams[e.code]=e)}}function se(e){return 1===e.length?e[0]:e.map(N).join("")}function ce(e,t){var i;const n=de.types[e];if(!n)return;const o=null!==(i=n.properties[t])&&void 0!==i?i:n.properties[t+"[x]"];if(o){if(o.contentReference){const e=o.contentReference.substring(1).split("."),t=e.pop();return ce(se(e),t)}return o}}e.PropertyType=void 0,(ne=e.PropertyType||(e.PropertyType={})).Address="Address",ne.Age="Age",ne.Annotation="Annotation",ne.Attachment="Attachment",ne.BackboneElement="BackboneElement",ne.CodeableConcept="CodeableConcept",ne.Coding="Coding",ne.ContactDetail="ContactDetail",ne.ContactPoint="ContactPoint",ne.Contributor="Contributor",ne.Count="Count",ne.DataRequirement="DataRequirement",ne.Distance="Distance",ne.Dosage="Dosage",ne.Duration="Duration",ne.Expression="Expression",ne.Extension="Extension",ne.HumanName="HumanName",ne.Identifier="Identifier",ne.MarketingStatus="MarketingStatus",ne.Meta="Meta",ne.Money="Money",ne.Narrative="Narrative",ne.ParameterDefinition="ParameterDefinition",ne.Period="Period",ne.Population="Population",ne.ProdCharacteristic="ProdCharacteristic",ne.ProductShelfLife="ProductShelfLife",ne.Quantity="Quantity",ne.Range="Range",ne.Ratio="Ratio",ne.Reference="Reference",ne.RelatedArtifact="RelatedArtifact",ne.SampledData="SampledData",ne.Signature="Signature",ne.SubstanceAmount="SubstanceAmount",ne.SystemString="http://hl7.org/fhirpath/System.String",ne.Timing="Timing",ne.TriggerDefinition="TriggerDefinition",ne.UsageContext="UsageContext",ne.base64Binary="base64Binary",ne.boolean="boolean",ne.canonical="canonical",ne.code="code",ne.date="date",ne.dateTime="dateTime",ne.decimal="decimal",ne.id="id",ne.instant="instant",ne.integer="integer",ne.markdown="markdown",ne.oid="oid",ne.positiveInt="positiveInt",ne.string="string",ne.time="time",ne.unsignedInt="unsignedInt",ne.uri="uri",ne.url="url",ne.uuid="uuid";const de=oe;var le,ue,me,pe,he,fe,ye,ge,ve,xe,Te,we,Se,Ee,be,Pe,De,Ce,Ae,Re,Oe,ke,Me,Ie,Ue,Le,Ne,je,_e,Qe,Be,We;function qe(){return window.location.protocol+"//"+window.location.host+"/"}function Fe(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}}function He(t){return[{type:e.PropertyType.boolean,value:t}]}function $e(t){return null==t?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:e.PropertyType.integer,value:t}:"number"==typeof t?{type:e.PropertyType.decimal,value:t}:"boolean"==typeof t?{type:e.PropertyType.boolean,value:t}:"string"==typeof t?{type:e.PropertyType.string,value:t}:ot(t)?{type:e.PropertyType.Quantity,value:t}:"object"==typeof t&&"resourceType"in t?{type:t.resourceType,value:t}:{type:e.PropertyType.BackboneElement,value:t}}function ze(e){return 0!==e.length&&!!e[0].value}function Ve(t,i){if(!(null==t?void 0:t.value))return;const n=ce(t.type,i);if(n){const e=function(e,t,i){var n;const o=i.type;if(!o||0===o.length)return;let r,a="undefined";if(1===o.length)r=e.value[t],a=o[0].code;else for(const i of o){const n=t.replace("[x]","")+N(i.code);if(n in e.value){r=e.value[n],a=i.code;break}}if(R(r))return;"Element"!==a&&"BackboneElement"!==a||(a=se(null===(n=i.path)||void 0===n?void 0:n.split(".")));return Array.isArray(r)?r.map((e=>Ge(e,a))):Ge(r,a)}(t,i,n);if(e)return e}return function(t,i){const n=t.value;if(!n||"object"!=typeof n)return;let o;if(i in n)o=n[i];else for(const t in e.PropertyType){const e=i+N(t);if(e in n){o=n[e];break}}if(R(o))return;return Array.isArray(o)?o.map($e):$e(o)}(t,i)}function Ge(e,t){return"Resource"===t&&"object"==typeof e&&"resourceType"in e&&(t=e.resourceType),{type:t,value:e}}function Xe(e){const t=[];for(const i of e){let e=!1;for(const n of t)if(ze(Ze(i,n))){e=!0;break}e||t.push(i)}return t}function Ye(e){return He(!ze(e))}function Je(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?He(!1):He(e.every(((e,i)=>ze(Ze(e,t[i])))))}function Ze(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?He(Math.abs(i-n)<1e-8):ot(i)&&ot(n)?He(rt(i,n)):He("object"==typeof i&&"object"==typeof n?at(e,t):i===n)}function Ke(e,t){return 0===e.length&&0===t.length?He(!0):e.length!==t.length?He(!1):(e.sort(tt),t.sort(tt),He(e.every(((e,i)=>ze(et(e,t[i]))))))}function et(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?He(Math.abs(i-n)<.01):ot(i)&&ot(n)?He(rt(i,n)):He("object"==typeof i&&"object"==typeof n?at(i,n):"string"==typeof i&&"string"==typeof n?i.toLowerCase()===n.toLowerCase():i===n)}function tt(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 it(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 nt(i);case"Quantity":return ot(i);default:return"object"==typeof i&&(null==i?void 0:i.resourceType)===t}}function nt(e){return!(!e||"object"!=typeof e||!("start"in e))}function ot(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function rt(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 at(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(st(i)&&st(o)){if(!at(i,o))return!1}else if(i!==o)return!1}return!0}function st(e){return null!==e&&"object"==typeof e}ue=new WeakMap,me=new WeakMap,pe=new WeakMap,he=new WeakMap,fe=new WeakMap,ye=new WeakMap,ge=new WeakMap,ve=new WeakMap,xe=new WeakMap,Te=new WeakMap,we=new WeakMap,Se=new WeakMap,Ee=new WeakMap,be=new WeakMap,Pe=new WeakMap,De=new WeakMap,Ce=new WeakMap,le=new WeakSet,Ae=function(e){const t=this.getLogins().filter((t=>{var i,n;return(null===(i=t.profile)||void 0===i?void 0:i.reference)!==(null===(n=e.profile)||void 0===n?void 0:n.reference)}));t.push(e),i(this,pe,"f").setObject("logins",t)},Re=function(){return t(this,void 0,void 0,(function*(){return n(this,Pe,new Promise(((e,t)=>{this.get("auth/me").then((t=>{n(this,Pe,void 0,"f"),n(this,De,t.profile,"f"),n(this,Ce,t.config,"f"),this.dispatchEvent({type:"change"}),e(i(this,De,"f"))})).catch(t)})),"f"),i(this,Pe,"f")}))},Oe=function(e,t){if(i(this,fe,"f")<=0||"no-cache"===(null==t?void 0:t.cache)||"reload"===(null==t?void 0:t.cache))return;const n=i(this,he,"f").get(e);return!n||n.requestTime+i(this,fe,"f")<Date.now()?void 0:n},ke=function(e,t){i(this,fe,"f")>0&&i(this,he,"f").set(e,{requestTime:Date.now(),value:t})},Me=function(e,n,o={}){return t(this,void 0,void 0,(function*(){i(this,be,"f")&&(yield i(this,be,"f")),n.startsWith("http")||(n=i(this,ye,"f")+n),o.method=e,i(this,le,"m",Ie).call(this,o);const t=yield i(this,ue,"f").call(this,n,o);if(401===t.status)return i(this,le,"m",Ne).call(this,e,n,o);if(204===t.status||304===t.status)return;const r=yield t.json();if(t.status>=400)throw r;return r}))},Ie=function(e){e.headers||(e.headers={});const t=e.headers;t["X-Medplum"]="extended",t["Content-Type"]||(t["Content-Type"]="application/fhir+json"),i(this,Se,"f")&&(t.Authorization="Bearer "+i(this,Se,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},Ue=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},Le=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))},Ne=function(e,n,o){return t(this,void 0,void 0,(function*(){return i(this,le,"m",_e).call(this).then((()=>i(this,le,"m",Me).call(this,e,n,o))).catch((e=>(this.clear(),i(this,we,"f")&&i(this,we,"f").call(this),Promise.reject(e))))}))},je=function(){return t(this,void 0,void 0,(function*(){yield this.startPkce();const e=new URL(i(this,ve,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",sessionStorage.getItem("pkceState")),e.searchParams.set("client_id",i(this,ge,"f")),e.searchParams.set("redirect_uri",qe()),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",sessionStorage.getItem("codeChallenge")),window.location.assign(e.toString())}))},_e=function(){return t(this,void 0,void 0,(function*(){if(i(this,be,"f"))return i(this,be,"f");if(!i(this,Ee,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",i(this,ge,"f")),e.set("refresh_token",i(this,Ee,"f")),n(this,be,i(this,le,"m",Qe).call(this,e),"f"),yield i(this,be,"f")}))},Qe=function(e){return t(this,void 0,void 0,(function*(){return i(this,ue,"f").call(this,i(this,xe,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e,credentials:"include"}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>i(this,le,"m",Be).call(this,e))).then((()=>this.getProfile()))}))},Be=function(e){return t(this,void 0,void 0,(function*(){const t=e.access_token,n=K(t);if(Date.now()>=1e3*n.exp)throw this.clear(),new Error("Token expired");if(i(this,ge,"f")&&n.client_id!==i(this,ge,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}))},We=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};const ct=()=>[],dt={empty:e=>He(0===e.length),exists:(e,t)=>He(t?e.filter((e=>ze(t.eval([e])))).length>0:e.length>0),all:(e,t)=>He(e.every((e=>ze(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return He(!1);return He(!0)},anyTrue:e=>{for(const t of e)if(t.value)return He(!0);return He(!1)},allFalse:e=>{for(const t of e)if(t.value)return He(!1);return He(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return He(!0);return He(!1)},subsetOf:ct,supersetOf:ct,count:t=>[{type:e.PropertyType.integer,value:t.length}],distinct:e=>{const t=[];for(const i of e)t.some((e=>e.value===i.value))||t.push(i);return t},isDistinct:e=>He(e.length===dt.distinct(e).length),where:(e,t)=>e.filter((e=>ze(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:ct,ofType:(e,t)=>e.filter((e=>e.type===t.name)),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 Xe([...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 ze(o)?i.eval(e):n?n.eval(e):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);if("boolean"==typeof i)return[{type:e.PropertyType.boolean,value:i}];if("number"==typeof i&&(0===i||1===i))return He(!!i);if("string"==typeof i){const e=i.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return He(!0);if(["false","f","no","n","0","0.0"].includes(e))return He(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:He(1===dt.toBoolean(e).length),toInteger:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);return"number"==typeof i?[{type:e.PropertyType.integer,value:i}]:"string"==typeof i&&i.match(/^[+-]?\d+$/)?[{type:e.PropertyType.integer,value:parseInt(i,10)}]:"boolean"==typeof i?[{type:e.PropertyType.integer,value:i?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:He(1===dt.toInteger(e).length),toDate:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.date,value:Fe(i)}]:[]},convertsToDate:e=>0===e.length?[]:He(1===dt.toDate(e).length),toDateTime:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.dateTime,value:Fe(i)}]:[]},convertsToDateTime:e=>0===e.length?[]:He(1===dt.toDateTime(e).length),toDecimal:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);return"number"==typeof i?[{type:e.PropertyType.decimal,value:i}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:e.PropertyType.decimal,value:parseFloat(i)}]:"boolean"==typeof i?[{type:e.PropertyType.decimal,value:i?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:He(1===dt.toDecimal(e).length),toQuantity:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);return ot(i)?[{type:e.PropertyType.Quantity,value:i}]:"number"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i,unit:"1"}}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:e.PropertyType.Quantity,value:{value:parseFloat(i),unit:"1"}}]:"boolean"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:He(1===dt.toQuantity(e).length),toString:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);return null==i?[]:ot(i)?[{type:e.PropertyType.string,value:`${i.value} '${i.unit}'`}]:[{type:e.PropertyType.string,value:i.toString()}]},convertsToString:e=>0===e.length?[]:He(1===dt.toString(e).length),toTime:t=>{if(0===t.length)return[];const[{value:i}]=mt(t,1);if("string"==typeof i){const t=i.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:e.PropertyType.time,value:Fe("T"+t[1])}]}return[]},convertsToTime:e=>0===e.length?[]:He(1===dt.toTime(e).length),indexOf:(e,t)=>lt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,i)=>lt(((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)=>lt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>lt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>lt(((e,t)=>e.includes(t)),e,t),upper:e=>lt((e=>e.toUpperCase()),e),lower:e=>lt((e=>e.toLowerCase()),e),replace:(e,t,i)=>lt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),matches:(e,t)=>lt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,i)=>lt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),length:e=>lt((e=>e.length),e),toChars:e=>lt((e=>e?e.split(""):void 0),e),abs:e=>ut(Math.abs,e),ceiling:e=>ut(Math.ceil,e),exp:e=>ut(Math.exp,e),floor:e=>ut(Math.floor,e),ln:e=>ut(Math.log,e),log:(e,t)=>ut(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>ut(Math.pow,e,t),round:e=>ut(Math.round,e),sqrt:e=>ut(Math.sqrt,e),truncate:e=>ut((e=>0|e),e),children:ct,descendants:ct,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:e.PropertyType.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:e.PropertyType.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:e.PropertyType.date,value:(new Date).toISOString().substring(0,10)}],between:(t,i,n,o)=>{var r;const a=dt.toDateTime(i.eval(t));if(0===a.length)throw new Error("Invalid start date");const s=dt.toDateTime(n.eval(t));if(0===s.length)throw new Error("Invalid end date");const c=null===(r=o.eval(t)[0])||void 0===r?void 0:r.value;if("years"!==c&&"months"!==c&&"days"!==c)throw new Error("Invalid units");const d=P(a[0].value,s[0].value);return[{type:e.PropertyType.Quantity,value:{value:d[c],unit:c}}]},is:(t,i)=>{let n="";return i instanceof Xt?n=i.name:i instanceof ni&&(n=i.left.name+"."+i.right.name),n?t.map((t=>({type:e.PropertyType.boolean,value:it(t,n)}))):[]},not:t=>dt.toBoolean(t).map((t=>({type:e.PropertyType.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const i=t.value;let n;if("string"==typeof i)n=i;else if("object"==typeof i){const e=i;if(e.resource)return $e(e.resource);n=e.reference}if(!n)return{type:e.PropertyType.BackboneElement,value:null};const[o,r]=n.split("/");return{type:e.PropertyType.BackboneElement,value:{resourceType:o,id:r}}})).filter((e=>!!e.value)),as:e=>e,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:e.PropertyType.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:e.PropertyType.BackboneElement,value:null})),conformsTo:(t,i)=>{const n=i.eval(t)[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=n.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var i;return{type:e.PropertyType.boolean,value:(null===(i=t.value)||void 0===i?void 0:i.resourceType)===o}}))}};function lt(e,t,...i){if(0===t.length)return[];const[{value:n}]=mt(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($e):[$e(o)]}function ut(t,i,...n){if(0===i.length)return[];const[{value:o}]=mt(i,1),r=ot(o),a=r?o.value:o;if("number"!=typeof a)throw new Error("Math function cannot be called with non-number");const s=t(a,...n.map((e=>{var t,n;return null===(n=null===(t=e.eval(i))||void 0===t?void 0:t[0])||void 0===n?void 0:n.value})));return[{type:r?e.PropertyType.Quantity:i[0].type,value:r?Object.assign(Object.assign({},o),{value:s}):s}]}function mt(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 pt,ht,ft,yt,gt,vt,xt,Tt,wt,St,Et,bt,Pt,Dt,Ct,At,Rt,Ot,kt,Mt,It,Ut,Lt,Nt,jt,_t,Qt,Bt,Wt,qt,Ft,Ht,$t,zt;class Vt{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 Gt{constructor(e){this.value=e}eval(){return[this.value]}}class Xt{constructor(e){this.name=e,pt.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>i(this,pt,"m",ht).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}pt=new WeakSet,ht=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:Ve(e,this.name)};class Yt{eval(){return[]}}class Jt{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class Zt{constructor(e,t){this.left=e,this.right=t}eval(e){return dt.ofType(this.left.eval(e),this.right)}}class Kt{constructor(e,t,i){this.left=e,this.right=t,this.impl=i}eval(t){const i=this.left.eval(t);if(1!==i.length)return[];const n=this.right.eval(t);if(1!==n.length)return[];const o=i[0].value,r=n[0].value,a=ot(o)?o.value:o,s=ot(r)?r.value:r,c=this.impl(a,s);return"boolean"==typeof c?He(c):ot(o)?[{type:e.PropertyType.Quantity,value:Object.assign(Object.assign({},o),{value:c})}]:[$e(c)]}}class ei{constructor(e,t){this.left=e,this.right=t}eval(t){const i=[...this.left.eval(t),...this.right.eval(t)];return i.length>0&&i.every((e=>"string"==typeof e.value))?[{type:e.PropertyType.string,value:i.map((e=>e.value)).join("")}]:i}}class ti{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);return He(t.some((e=>e.value===i[0].value)))}}class ii{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);return He(this.right.eval(e).some((e=>e.value===t[0].value)))}}class ni{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class oi{constructor(e,t){this.left=e,this.right=t}eval(e){return Xe([...this.left.eval(e),...this.right.eval(e)])}}class ri{constructor(e,t){this.left=e,this.right=t}eval(e){return Je(this.left.eval(e),this.right.eval(e))}}class ai{constructor(e,t){this.left=e,this.right=t}eval(e){return Ye(Je(this.left.eval(e),this.right.eval(e)))}}class si{constructor(e,t){this.left=e,this.right=t}eval(e){return Ke(this.left.eval(e),this.right.eval(e))}}class ci{constructor(e,t){this.left=e,this.right=t}eval(e){return Ye(Ke(this.left.eval(e),this.right.eval(e)))}}class di{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 He(it(t[0],i))}}class li{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)?He(!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)?He(!1):[]}}class ui{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(ze(t))return t;const i=this.right.eval(e);return ze(i)?i:[]}}class mi{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?He(!0):!0===n&&!0===o||!1===n&&!1===o?He(!1):[]}}class pi{constructor(e,t,i){this.name=e,this.args=t,this.impl=i}eval(e){return this.impl(e,...this.args)}}class hi{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]]:[]}}class fi{constructor(){ft.set(this,{}),yt.set(this,{})}registerInfix(e,t){return i(this,yt,"f")[e]=t,this}registerPrefix(e,t){return i(this,ft,"f")[e]=t,this}prefix(e,t,i){return this.registerPrefix(e,{parse(e,n){const o=e.consumeAndParse(t);return i(n,o)}})}infixLeft(e,t,i){return this.registerInfix(e,{parse(e,n,o){const r=e.consumeAndParse(t);return i(n,o,r)},precedence:t})}construct(e){return new yi(e,i(this,ft,"f"),i(this,yt,"f"))}}ft=new WeakMap,yt=new WeakMap;class yi{constructor(e,t,i){gt.set(this,void 0),vt.set(this,void 0),xt.set(this,void 0),n(this,gt,e,"f"),n(this,vt,t,"f"),n(this,xt,i,"f")}hasMore(){return i(this,gt,"f").length>0}match(e){const t=this.peek();return(null==t?void 0:t.id)===e&&(this.consume(),!0)}consumeAndParse(e=1/0){const t=this.consume(),n=i(this,vt,"f")[t.id];if(!n)throw Error(`Parse error at "${t.value}" (line ${t.line}, column ${t.column}). No matching prefix parselet.`);let o=n.parse(this,t);for(;e>this.getPrecedence();){const e=this.consume();o=i(this,xt,"f")[e.id].parse(this,o,e)}return o}getPrecedence(){const e=this.peek();if(!e)return 1/0;const t=i(this,xt,"f")[e.id];return t?t.precedence:1/0}consume(e){var t;if(!i(this,gt,"f").length)throw Error("Cant consume unknown more tokens.");if(e&&(null===(t=this.peek())||void 0===t?void 0:t.id)!==e){const t=this.peek();throw Error(`Expected ${e} but got "${t.value}" at line ${t.line} column ${t.column}.`)}return i(this,gt,"f").shift()}peek(){return i(this,gt,"f").length>0?i(this,gt,"f")[0]:void 0}removeComments(){n(this,gt,i(this,gt,"f").filter((e=>"Comment"!==e.id)),"f")}}gt=new WeakMap,vt=new WeakMap,xt=new WeakMap;const gi=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class vi{constructor(e,t,i){Tt.add(this),wt.set(this,void 0),St.set(this,void 0),Et.set(this,void 0),bt.set(this,[]),Pt.set(this,{index:0,line:0,column:0}),Dt.set(this,[]),n(this,wt,e,"f"),n(this,St,t,"f"),n(this,Et,i,"f")}tokenize(){for(;i(this,Pt,"f").index<i(this,wt,"f").length;){const e=i(this,Tt,"m",Rt).call(this);e&&i(this,bt,"f").push(e)}return i(this,bt,"f")}}wt=new WeakMap,St=new WeakMap,Et=new WeakMap,bt=new WeakMap,Pt=new WeakMap,Dt=new WeakMap,Tt=new WeakSet,Ct=function(){return i(this,bt,"f").slice(-1)[0]},At=function(){i(this,Tt,"m",Ft).call(this);const e=i(this,Tt,"m",Rt).call(this);return i(this,Tt,"m",Ht).call(this),e},Rt=function(){i(this,Tt,"m",Ot).call(this);const e=i(this,Tt,"m",Bt).call(this);if(!e)return;i(this,Tt,"m",Ft).call(this);const t=i(this,Tt,"m",qt).call(this);return"/"===e&&"*"===t?i(this,Tt,"m",kt).call(this):"/"===e&&"/"===t?i(this,Tt,"m",Mt).call(this):"'"===e||'"'===e?i(this,Tt,"m",It).call(this,e):"`"===e?i(this,Tt,"m",Ut).call(this):"@"===e?i(this,Tt,"m",Lt).call(this):e.match(/\d/)?i(this,Tt,"m",Nt).call(this):e.match(/\w/)||"$"===e&&t.match(/\w/)?i(this,Tt,"m",jt).call(this):i(this,Tt,"m",_t).call(this)},Ot=function(){i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/\s/)))},kt=function(){const e=i(this,Pt,"f").index;return i(this,Tt,"m",Qt).call(this,(()=>"*"!==i(this,Tt,"m",Bt).call(this)||"/"!==i(this,Tt,"m",qt).call(this))),i(this,Tt,"m",$t).call(this),i(this,Tt,"m",$t).call(this),i(this,Tt,"m",zt).call(this,"Comment",i(this,wt,"f").substring(e,i(this,Pt,"f").index))},Mt=function(){return i(this,Tt,"m",zt).call(this,"Comment",i(this,Tt,"m",Qt).call(this,(()=>"\n"!==i(this,Tt,"m",Bt).call(this))))},It=function(e){i(this,Tt,"m",$t).call(this);const t=i(this,Tt,"m",zt).call(this,"String",i(this,Tt,"m",Qt).call(this,(()=>"\\"===i(this,Tt,"m",Wt).call(this)||i(this,Tt,"m",Bt).call(this)!==e)));return i(this,Tt,"m",$t).call(this),t},Ut=function(){i(this,Tt,"m",$t).call(this);const e=i(this,Tt,"m",zt).call(this,"Symbol",i(this,Tt,"m",Qt).call(this,(()=>"`"!==i(this,Tt,"m",Bt).call(this))));return i(this,Tt,"m",$t).call(this),e},Lt=function(){i(this,Tt,"m",$t).call(this);const e=i(this,Pt,"f").index;return i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/[\d-]/))),"T"===i(this,Tt,"m",Bt).call(this)&&(i(this,Tt,"m",$t).call(this),i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/[\d:]/))),"."===i(this,Tt,"m",Bt).call(this)&&i(this,Tt,"m",qt).call(this).match(/\d/)&&(i(this,Tt,"m",$t).call(this),i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/\d/)))),"Z"===i(this,Tt,"m",Bt).call(this)?i(this,Tt,"m",$t).call(this):"+"!==i(this,Tt,"m",Bt).call(this)&&"-"!==i(this,Tt,"m",Bt).call(this)||(i(this,Tt,"m",$t).call(this),i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/[\d:]/))))),i(this,Tt,"m",zt).call(this,"DateTime",i(this,wt,"f").substring(e,i(this,Pt,"f").index))},Nt=function(){const e=i(this,Pt,"f").index;let t="Number";return i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/\d/))),"."===i(this,Tt,"m",Bt).call(this)&&i(this,Tt,"m",qt).call(this).match(/\d/)&&(i(this,Tt,"m",$t).call(this),i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/\d/))))," "===i(this,Tt,"m",Bt).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&gi.includes(e.value))return!0}return!1}(i(this,Tt,"m",At).call(this))&&(t="Quantity",i(this,Tt,"m",Rt).call(this)),i(this,Tt,"m",zt).call(this,t,i(this,wt,"f").substring(e,i(this,Pt,"f").index))},jt=function(){var e;const t=i(this,Tt,"m",Qt).call(this,(()=>i(this,Tt,"m",Bt).call(this).match(/[$\w]/)));return"."!==(null===(e=i(this,Tt,"m",Ct).call(this))||void 0===e?void 0:e.value)&&i(this,St,"f").includes(t)?i(this,Tt,"m",zt).call(this,t,t):i(this,Tt,"m",zt).call(this,"Symbol",t)},_t=function(){const e=i(this,Tt,"m",Bt).call(this),t=e+i(this,Tt,"m",qt).call(this);return i(this,Et,"f").includes(t)?(i(this,Tt,"m",$t).call(this),i(this,Tt,"m",$t).call(this),i(this,Tt,"m",zt).call(this,t,t)):(i(this,Tt,"m",$t).call(this),i(this,Tt,"m",zt).call(this,e,e))},Qt=function(e){const t=i(this,Pt,"f").index;for(;i(this,Pt,"f").index<i(this,wt,"f").length&&e();)i(this,Tt,"m",$t).call(this);return i(this,wt,"f").substring(t,i(this,Pt,"f").index)},Bt=function(){return i(this,wt,"f")[i(this,Pt,"f").index]},Wt=function(){var e;return null!==(e=i(this,wt,"f")[i(this,Pt,"f").index-1])&&void 0!==e?e:""},qt=function(){var e;return null!==(e=i(this,wt,"f")[i(this,Pt,"f").index+1])&&void 0!==e?e:""},Ft=function(){i(this,Dt,"f").push(Object.assign({},i(this,Pt,"f")))},Ht=function(){const e=i(this,Dt,"f").pop();if(!e)throw new Error("No mark to reset to");i(this,Pt,"f").index=e.index,i(this,Pt,"f").line=e.line,i(this,Pt,"f").column=e.column},$t=function(){i(this,Pt,"f").index++,"\n"===i(this,Tt,"m",Bt).call(this)?(i(this,Pt,"f").line++,i(this,Pt,"f").column=0):i(this,Pt,"f").column++},zt=function(e,t){const n=i(this,Dt,"f").pop();if(!n)throw new Error("No mark for token");return Object.assign({id:e,value:t},n)};const xi=["true","false","and","as","contains","div","in","is","mod","or","xor"],Ti=["!=","!~","<=",">=","{}","->"];function wi(e){return new vi(e,xi,Ti).tokenize()}const Si={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},Ei={parse(e,t){const i=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new hi(t,i)},precedence:2},bi={parse(e,t){if(!(t instanceof Xt))throw new Error("Unexpected parentheses");if(!(t.name in dt))throw new Error("Unrecognized function: "+t.name);const i=[];for(;!e.match(")");)i.push(e.consumeAndParse()),e.match(",");return new pi(t.name,i,dt[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}}function Di(){return(new fi).registerPrefix("String",{parse:(t,i)=>new Gt({type:e.PropertyType.string,value:i.value})}).registerPrefix("DateTime",{parse:(t,i)=>new Gt({type:e.PropertyType.dateTime,value:Fe(i.value)})}).registerPrefix("Quantity",{parse:(t,i)=>new Gt({type:e.PropertyType.Quantity,value:Pi(i.value)})}).registerPrefix("Number",{parse:(t,i)=>new Gt({type:e.PropertyType.decimal,value:parseFloat(i.value)})}).registerPrefix("true",{parse:()=>new Gt({type:e.PropertyType.boolean,value:!0})}).registerPrefix("false",{parse:()=>new Gt({type:e.PropertyType.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new Xt(t.value)}).registerPrefix("{}",{parse:()=>new Yt}).registerPrefix("(",Si).registerInfix("[",Ei).registerInfix("(",bi).prefix("+",3,((e,t)=>new Jt(t,(e=>e)))).prefix("-",3,((e,t)=>new Kt(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,i)=>new ni(e,i))).infixLeft("/",4,((e,t,i)=>new Kt(e,i,((e,t)=>e/t)))).infixLeft("*",4,((e,t,i)=>new Kt(e,i,((e,t)=>e*t)))).infixLeft("+",5,((e,t,i)=>new Kt(e,i,((e,t)=>e+t)))).infixLeft("-",5,((e,t,i)=>new Kt(e,i,((e,t)=>e-t)))).infixLeft("|",7,((e,t,i)=>new oi(e,i))).infixLeft("=",9,((e,t,i)=>new ri(e,i))).infixLeft("!=",9,((e,t,i)=>new ai(e,i))).infixLeft("~",9,((e,t,i)=>new si(e,i))).infixLeft("!~",9,((e,t,i)=>new ci(e,i))).infixLeft("<",8,((e,t,i)=>new Kt(e,i,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,i)=>new Kt(e,i,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,i)=>new Kt(e,i,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,i)=>new Kt(e,i,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,i)=>new ei(e,i))).infixLeft("and",6,((e,t,i)=>new li(e,i))).infixLeft("as",6,((e,t,i)=>new Zt(e,i))).infixLeft("contains",6,((e,t,i)=>new ti(e,i))).infixLeft("div",6,((e,t,i)=>new Kt(e,i,((e,t)=>e/t|0)))).infixLeft("in",6,((e,t,i)=>new ii(e,i))).infixLeft("is",6,((e,t,i)=>new di(e,i))).infixLeft("mod",6,((e,t,i)=>new Kt(e,i,((e,t)=>e%t)))).infixLeft("or",6,((e,t,i)=>new ui(e,i))).infixLeft("xor",6,((e,t,i)=>new mi(e,i)))}const Ci=Di();function Ai(e){return new Vt(e,Ci.construct(wi(e)).consumeAndParse())}function Ri(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]=$e(i[e]))}return Oi(e,i).map((e=>e.value))}function Oi(e,t){return Ai(e).eval(t)}class ki{constructor(e="\r",t="|",i="^",n="~",o="\\",r="&"){this.segmentSeparator=e,this.fieldSeparator=t,this.componentSeparator=i,this.repetitionSeparator=n,this.escapeCharacter=o,this.subcomponentSeparator=r}getMsh2(){return this.fieldSeparator+this.componentSeparator+this.repetitionSeparator+this.escapeCharacter+this.subcomponentSeparator}}class Mi{constructor(e,t=new ki){this.context=t,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(this.context.segmentSeparator)}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 Mi([new Ii(["MSH",this.context.getMsh2(),l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p],this.context),new Ii(["MSA","AA",m,"OK"],this.context)])}static parse(e){if(!e.startsWith("MSH")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}const t=new ki("\r",e.charAt(3),e.charAt(4),e.charAt(5),e.charAt(6),e.charAt(7));return new Mi(e.split(/[\r\n]+/).map((e=>Ii.parse(e,t))),t)}}class Ii{constructor(e,t=new ki){this.context=t,M(e)?this.fields=e.map((e=>Ui.parse(e))):this.fields=e,this.name=this.fields[0].components[0][0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join(this.context.fieldSeparator)}static parse(e,t=new ki){return new Ii(e.split(t.fieldSeparator).map((e=>Ui.parse(e,t))),t)}}class Ui{constructor(e,t=new ki){this.context=t,this.components=e}get(e,t,i=0){let n=this.components[i][e]||"";return void 0!==t&&(n=n.split(this.context.subcomponentSeparator)[t]||""),n}toString(){return this.components.map((e=>e.join(this.context.componentSeparator))).join(this.context.repetitionSeparator)}static parse(e,t=new ki){return new Ui(e.split(t.repetitionSeparator).map((e=>e.split(t.componentSeparator))),t)}}var Li;e.Operator=void 0,(Li=e.Operator||(e.Operator={})).EQUALS="eq",Li.NOT_EQUALS="ne",Li.GREATER_THAN="gt",Li.LESS_THAN="lt",Li.GREATER_THAN_OR_EQUALS="ge",Li.LESS_THAN_OR_EQUALS="le",Li.STARTS_AFTER="sa",Li.ENDS_BEFORE="eb",Li.APPROXIMATELY="ap",Li.CONTAINS="contains",Li.EXACT="exact",Li.TEXT="text",Li.NOT="not",Li.ABOVE="above",Li.BELOW="below",Li.IN="in",Li.NOT_IN="not-in",Li.OF_TYPE="of-type",Li.MISSING="missing";const Ni=[e.Operator.CONTAINS,e.Operator.EXACT,e.Operator.TEXT,e.Operator.NOT,e.Operator.ABOVE,e.Operator.BELOW,e.Operator.IN,e.Operator.NOT_IN,e.Operator.OF_TYPE,e.Operator.MISSING],ji=[e.Operator.NOT_EQUALS,e.Operator.GREATER_THAN,e.Operator.LESS_THAN,e.Operator.GREATER_THAN_OR_EQUALS,e.Operator.LESS_THAN_OR_EQUALS,e.Operator.STARTS_AFTER,e.Operator.ENDS_BEFORE,e.Operator.APPROXIMATELY];var _i;function Qi(t,i){var n,o;let r=null===(o=null===(n=de.types[t])||void 0===n?void 0:n.searchParamsDetails)||void 0===o?void 0:o[i.code];return r||(r=function(t,i){var n,o,r,a,s,c,d;if("_lastUpdated"===i.code)return{columnName:"lastUpdated",type:e.SearchParameterType.DATETIME};const l=i.code,u=function(e){return e.split("-").reduce(((e,t,i)=>e+(i?N(t):t)),"")}(l),m=null===(n=Wi(t,i.expression))||void 0===n?void 0:n.split(".");if(!m)return{columnName:u,type:e.SearchParameterType.TEXT};const p=Bi(i);let h,f,y=t,g=!1;for(let e=1;e<m.length;e++){const n=m[e];if(h=null!==(a=null===(r=null===(o=de.types[y])||void 0===o?void 0:o.properties)||void 0===r?void 0:r[n])&&void 0!==a?a:null===(c=null===(s=de.types[y])||void 0===s?void 0:s.properties)||void 0===c?void 0:c[n+"[x]"],!h)throw new Error(`Element definition not found for ${t} ${i.code}`);if("*"===h.max&&(g=!0),f=null===(d=h.type)||void 0===d?void 0:d[0].code,!f)return{columnName:u,type:p,array:g};e<m.length-1&&("Element"===f||"BackboneElement"===f?y+=N(n):y=f)}const v=Bi(i,f),x={columnName:u,type:v,elementDefinition:h,array:g};return function(e,t,i){const n=de.types[e];n.searchParamsDetails||(n.searchParamsDetails={});n.searchParamsDetails[t]=i}(t,l,x),x}(t,i)),r}function Bi(t,i){let n=e.SearchParameterType.TEXT;switch(t.type){case"date":n=i===e.PropertyType.dateTime||i===e.PropertyType.instant?e.SearchParameterType.DATETIME:e.SearchParameterType.DATE;break;case"number":n=e.SearchParameterType.NUMBER;break;case"quantity":n=e.SearchParameterType.QUANTITY;break;case"reference":n=e.SearchParameterType.REFERENCE;break;case"token":"boolean"===i&&(n=e.SearchParameterType.BOOLEAN)}return n}function Wi(e,t){const i=t.split(" | ");for(const t of i){if((n=t).includes(" as Period")||n.includes(" as SampledDate"))continue;const i=qi(t);if(i.startsWith(e+"."))return i}var n}function qi(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 Fi(t,i,n){var o,r;const a=null===(r=null===(o=de.types[i.resourceType])||void 0===o?void 0:o.searchParams)||void 0===r?void 0:r[n.code];switch(null==a?void 0:a.type){case"reference":return function(t,i,n){const o=Ri(n.expression,t),r=Vi(i.operator);if(""===i.value&&0===o.length)return i.operator===e.Operator.EQUALS;const a=o.map((e=>"string"==typeof e?e:e.reference));for(const e of i.value.split(",")){let t=a.includes(e);if(t||"_compartment"!==i.code||(t=a.some((t=>null==t?void 0:t.endsWith("/"+e)))),t)return!r}return r}(t,n,a);case"string":return Hi(t,n,a);case"token":return function(t,i,n){const o=Qi(t.resourceType,n);return o.type===e.SearchParameterType.BOOLEAN?function(e,t,i){const n=Ri(i.expression,e),o="true"===t.value,r=n.includes(o);return Vi(t.operator)?!r:r}(t,i,n):Hi(t,i,n)}(t,n,a);case"date":return function(e,t,i){const n=Ri(i.expression,e),o=t.value.split(","),r=Vi(t.operator);for(const e of n)for(const i of o){if(zi(e,t.operator,i))return!r}return r}(t,n,a)}return!1}function Hi(e,t,i){const n=Ri(i.expression,e),o=t.value.split(","),r=Vi(t.operator);for(const e of n)for(const i of o){if($i(e,t.operator,i))return!r}return r}function $i(e,t,i){let n="";return e&&("string"==typeof e?n=e:"object"==typeof e&&(n=JSON.stringify(e))),n.toLowerCase().includes(i.toLowerCase())}function zi(t,i,n){switch(i){case e.Operator.STARTS_AFTER:case e.Operator.GREATER_THAN:return t>n;case e.Operator.GREATER_THAN_OR_EQUALS:return t>=n;case e.Operator.ENDS_BEFORE:case e.Operator.LESS_THAN:return t<n;case e.Operator.LESS_THAN_OR_EQUALS:return t<=n;case e.Operator.EQUALS:case e.Operator.NOT_EQUALS:return t===n}return!1}function Vi(t){return t===e.Operator.NOT_EQUALS||t===e.Operator.NOT}e.SearchParameterType=void 0,(_i=e.SearchParameterType||(e.SearchParameterType={})).BOOLEAN="BOOLEAN",_i.NUMBER="NUMBER",_i.QUANTITY="QUANTITY",_i.TEXT="TEXT",_i.REFERENCE="REFERENCE",_i.DATE="DATE",_i.DATETIME="DATETIME",_i.PERIOD="PERIOD";const Gi="ok",Xi="created",Yi="gone",Ji="not-modified",Zi="not-found",Ki="unauthorized",en="forbidden",tn="too-many-requests",nn={resourceType:"OperationOutcome",id:Gi,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},on={resourceType:"OperationOutcome",id:Xi,issue:[{severity:"information",code:"informational",details:{text:"Created"}}]},rn={resourceType:"OperationOutcome",id:Ji,issue:[{severity:"information",code:"informational",details:{text:"Not Modified"}}]},an={resourceType:"OperationOutcome",id:Zi,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},sn={resourceType:"OperationOutcome",id:Ki,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},cn={resourceType:"OperationOutcome",id:en,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]},dn={resourceType:"OperationOutcome",id:Yi,issue:[{severity:"error",code:"deleted",details:{text:"Gone"}}]},ln={resourceType:"OperationOutcome",id:tn,issue:[{severity:"error",code:"throttled",details:{text:"Too Many Requests"}}]};function un(e){return e.id===Gi||e.id===Xi||e.id===Ji}class mn 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}}e.AndAtom=li,e.ArithemticOperatorAtom=Kt,e.AsAtom=Zt,e.ConcatAtom=ei,e.ContainsAtom=ti,e.DEFAULT_SEARCH_COUNT=20,e.DotAtom=ni,e.EmptySetAtom=Yt,e.EqualsAtom=ri,e.EquivalentAtom=si,e.FHIRPATH_KEYWORDS=xi,e.FHIRPATH_OPERATORS=Ti,e.FhirPathAtom=Vt,e.FunctionAtom=pi,e.Hl7Context=ki,e.Hl7Field=Ui,e.Hl7Message=Mi,e.Hl7Segment=Ii,e.InAtom=ii,e.IndexerAtom=hi,e.IsAtom=di,e.LRUCache=c,e.LiteralAtom=Gt,e.MEDPLUM_VERSION="1.0.4-6dbdb7f6",e.MedplumClient=class extends J{constructor(e){var t,o;if(super(),le.add(this),ue.set(this,void 0),me.set(this,void 0),pe.set(this,void 0),he.set(this,void 0),fe.set(this,void 0),ye.set(this,void 0),ge.set(this,void 0),ve.set(this,void 0),xe.set(this,void 0),Te.set(this,void 0),we.set(this,void 0),Se.set(this,void 0),Ee.set(this,void 0),be.set(this,void 0),Pe.set(this,void 0),De.set(this,void 0),Ce.set(this,void 0),(null==e?void 0:e.baseUrl)&&!e.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");n(this,ue,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),n(this,me,null==e?void 0:e.createPdf,"f"),n(this,pe,new te,"f"),n(this,he,new c(null!==(t=null==e?void 0:e.resourceCacheSize)&&void 0!==t?t:1e3),"f"),n(this,fe,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:6e4,"f"),n(this,ye,function(e){if(!e)return e;return e.endsWith("/")?e:e+"/"}(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),n(this,ge,(null==e?void 0:e.clientId)||"","f"),n(this,ve,(null==e?void 0:e.authorizeUrl)||i(this,ye,"f")+"oauth2/authorize","f"),n(this,xe,(null==e?void 0:e.tokenUrl)||i(this,ye,"f")+"oauth2/token","f"),n(this,Te,(null==e?void 0:e.logoutUrl)||i(this,ye,"f")+"oauth2/logout","f"),n(this,we,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(n(this,Se,r.accessToken,"f"),n(this,Ee,r.refreshToken,"f"),i(this,le,"m",Re).call(this).catch(console.log)),i(this,le,"m",We).call(this)}getBaseUrl(){return i(this,ye,"f")}clear(){i(this,pe,"f").clear(),i(this,he,"f").clear(),n(this,Se,void 0,"f"),n(this,Ee,void 0,"f"),n(this,De,void 0,"f"),n(this,Ce,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),i(this,he,"f").delete(e)}invalidateSearches(e){const t="fhir/R4/"+e;for(const e of i(this,he,"f").keys())(e.endsWith(t)||e.includes(t+"?"))&&i(this,he,"f").delete(e)}get(e,t={}){e=e.toString();const n=i(this,le,"m",Oe).call(this,e,t);if(n)return n.value;const o=new ee(i(this,le,"m",Me).call(this,"GET",e,t));return i(this,le,"m",ke).call(this,e,o),o}post(e,t,n,o={}){return e=e.toString(),t&&i(this,le,"m",Le).call(this,o,t),n&&i(this,le,"m",Ue).call(this,o,n),this.invalidateUrl(e),i(this,le,"m",Me).call(this,"POST",e,o)}put(e,t,n,o={}){return e=e.toString(),t&&i(this,le,"m",Le).call(this,o,t),n&&i(this,le,"m",Ue).call(this,o,n),this.invalidateUrl(e),i(this,le,"m",Me).call(this,"PUT",e,o)}patch(e,t,n={}){return e=e.toString(),i(this,le,"m",Le).call(this,n,t),i(this,le,"m",Ue).call(this,n,"application/json-patch+json"),this.invalidateUrl(e),i(this,le,"m",Me).call(this,"PATCH",e,n)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),i(this,le,"m",Me).call(this,"DELETE",e,t)}startNewUser(e){return t(this,void 0,void 0,(function*(){return yield this.startPkce(),this.post("auth/newuser",Object.assign(Object.assign({},e),{codeChallengeMethod:"S256",codeChallenge:sessionStorage.getItem("codeChallenge")}))}))}startNewProject(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newproject",e)}))}startNewPatient(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newpatient",e)}))}startLogin(e){var n;return t(this,void 0,void 0,(function*(){const{codeChallenge:t,codeChallengeMethod:o}=this.getCodeChallenge(e);return this.post("auth/login",Object.assign(Object.assign({},e),{clientId:null!==(n=e.clientId)&&void 0!==n?n:i(this,ge,"f"),scope:e.scope,codeChallengeMethod:o,codeChallenge:t}))}))}startGoogleLogin(e){var n;return t(this,void 0,void 0,(function*(){const{codeChallenge:t,codeChallengeMethod:o}=this.getCodeChallenge(e);return this.post("auth/google",Object.assign(Object.assign({},e),{clientId:null!==(n=e.clientId)&&void 0!==n?n:i(this,ge,"f"),scope:e.scope,codeChallengeMethod:o,codeChallenge:t}))}))}getCodeChallenge(e){if(e.codeChallenge)return{codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod};const t=sessionStorage.getItem("codeChallenge");return t?{codeChallenge:t,codeChallengeMethod:"S256"}:{}}signOut(){this.clear()}signInWithRedirect(){return t(this,void 0,void 0,(function*(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void(yield i(this,le,"m",je).call(this))}))}signOutWithRedirect(){window.location.assign(i(this,Te,"f"))}fhirUrl(...e){return new URL(i(this,ye,"f")+"fhir/R4/"+e.join("/"))}fhirSearchUrl(e,t){const i=this.fhirUrl(e);return t&&(i.search=t.toString()),i}search(e,t,i={}){return this.get(this.fhirSearchUrl(e,t),i)}searchOne(e,t,n={}){const o=this.fhirSearchUrl(e,t);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=i(this,le,"m",Oe).call(this,r,n);if(a)return a.value;const s=new ee(this.search(e,o.searchParams,n).then((e=>{var t,i;return null===(i=null===(t=e.entry)||void 0===t?void 0:t[0])||void 0===i?void 0:i.resource})));return i(this,le,"m",ke).call(this,r,s),s}searchResources(e,t,n={}){const o=this.fhirSearchUrl(e,t).toString()+"-searchResources",r=i(this,le,"m",Oe).call(this,o,n);if(r)return r.value;const a=new ee(this.search(e,t,n).then((e=>{var t,i;return null!==(i=null===(t=e.entry)||void 0===t?void 0:t.map((e=>e.resource)))&&void 0!==i?i:[]})));return i(this,le,"m",ke).call(this,o,a),a}searchValueSet(e,t,i={}){const n=this.fhirUrl("ValueSet","$expand");return n.searchParams.set("url",e),n.searchParams.set("filter",t),this.get(n.toString(),i)}getCached(e,t){var n;const o=null===(n=i(this,he,"f").get(this.fhirUrl(e,t).toString()))||void 0===n?void 0:n.value;return o&&o.isOk()?o.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[i,n]=t.split("/");return i&&n?this.getCached(i,n):void 0}readResource(e,t,i={}){return this.get(this.fhirUrl(e,t),i)}readReference(e,t={}){const i=null==e?void 0:e.reference;if(!i)return new ee(Promise.reject(new Error("Missing reference")));const[n,o]=i.split("/");return n&&o?this.readResource(n,o,t):new ee(Promise.reject(new Error("Invalid reference")))}getSchema(){return de}requestSchema(e){return t(this,void 0,void 0,(function*(){if(e in de.types)return de;const t=`{\n StructureDefinitionList(name: "${e}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${e}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(t);for(const e of i.data.StructureDefinitionList)re(e);for(const e of i.data.SearchParameterList)ae(e);return de}))}readHistory(e,t,i={}){return this.get(this.fhirUrl(e,t,"_history"),i)}readVersion(e,t,i,n={}){return this.get(this.fhirUrl(e,t,"_history",i),n)}readPatientEverything(e,t={}){return this.get(this.fhirUrl("Patient",e,"$everything"),t)}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}createResourceIfNoneExist(e,i){var n;return t(this,void 0,void 0,(function*(){return null!==(n=yield this.searchOne(e.resourceType,i))&&void 0!==n?n:this.createResource(e)}))}createBinary(e,t,i,n){const o=this.fhirUrl("Binary");return t&&o.searchParams.set("_filename",t),n?this.uploadwithProgress(o,e,i,n):this.post(o,e,i)}uploadwithProgress(e,t,n,o){return new Promise(((r,a)=>{const s=new XMLHttpRequest;s.responseType="json",s.onabort=()=>a(new Error("Request aborted")),s.onerror=()=>a(new Error("Request error")),o&&(s.upload.onprogress=e=>o(e),s.upload.onload=e=>o(e)),s.onload=()=>{s.status>=200&&s.status<300?r(s.response):a(new Error(s.statusText))},s.open("POST",e),s.withCredentials=!0,s.setRequestHeader("Authorization","Bearer "+i(this,Se,"f")),s.setRequestHeader("Cache-Control","no-cache, no-store, max-age=0"),s.setRequestHeader("Content-Type",n),s.setRequestHeader("X-Medplum","extended"),s.send(t)}))}createPdf(e,n,o,r){return t(this,void 0,void 0,(function*(){if(!i(this,me,"f"))throw new Error("PDF creation not enabled");const t=yield i(this,me,"f").call(this,e,o,r);return this.createBinary(t,n,"application/pdf")}))}createComment(e,t){const i=this.getProfile();let n,o;return"Encounter"===e.resourceType&&(n=T(e),o=e.subject),"ServiceRequest"===e.resourceType&&(n=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=T(e)),this.createResource({resourceType:"Communication",basedOn:[T(e)],encounter:n,subject:o,sender:i?T(i):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}updateResource(e){return t(this,void 0,void 0,(function*(){if(!e.resourceType)throw new Error("Missing resourceType");if(!e.id)throw new Error("Missing id");this.invalidateSearches(e.resourceType);const t=yield this.put(this.fhirUrl(e.resourceType,e.id),e);return null!=t?t: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))}validateResource(e){return this.post(this.fhirUrl(e.resourceType,"$validate"),e)}executeBatch(e){return this.post("fhir/R4",e)}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t,i,n){return this.post(this.fhirUrl("$graphql"),{query:e,operationName:t,variables:i},"application/json",n)}readResourceGraph(e,t,i){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${i}`)}getActiveLogin(){return i(this,pe,"f").getObject("activeLogin")}setActiveLogin(e){return t(this,void 0,void 0,(function*(){n(this,Se,e.accessToken,"f"),n(this,Ee,e.refreshToken,"f"),n(this,De,void 0,"f"),n(this,Ce,void 0,"f"),i(this,pe,"f").setObject("activeLogin",e),i(this,le,"m",Ae).call(this,e),i(this,he,"f").clear(),n(this,be,void 0,"f"),yield i(this,le,"m",Re).call(this)}))}getAccessToken(){return i(this,Se,"f")}setAccessToken(e){n(this,Se,e,"f"),n(this,Ee,void 0,"f"),n(this,De,void 0,"f"),n(this,Ce,void 0,"f")}getLogins(){var e;return null!==(e=i(this,pe,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!i(this,Pe,"f")}getProfile(){return i(this,De,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return i(this,Pe,"f")&&(yield i(this,Pe,"f")),this.getProfile()}))}getUserConfiguration(){return i(this,Ce,"f")}download(e,n={}){return t(this,void 0,void 0,(function*(){i(this,be,"f")&&(yield i(this,be,"f")),i(this,le,"m",Ie).call(this,n);return(yield i(this,ue,"f").call(this,e.toString(),n)).blob()}))}startPkce(){return t(this,void 0,void 0,(function*(){const e=q();sessionStorage.setItem("pkceState",e);const i=q();sessionStorage.setItem("codeVerifier",i);const n=L(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(i)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");sessionStorage.setItem("codeChallenge",n)}))}processCode(e){const t=new URLSearchParams;t.set("grant_type","authorization_code"),t.set("client_id",i(this,ge,"f")),t.set("code",e),t.set("redirect_uri",qe());const n=sessionStorage.getItem("codeVerifier");return n&&t.set("code_verifier",n),i(this,le,"m",Qe).call(this,t)}startClientLogin(e,n){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",e),t.set("client_secret",n),i(this,le,"m",Qe).call(this,t)}))}},e.NotEqualsAtom=ai,e.NotEquivalentAtom=ci,e.OperationOutcomeError=mn,e.OrAtom=ui,e.ReadablePromise=ee,e.SymbolAtom=Xt,e.UnaryOperatorAtom=Jt,e.UnionAtom=oi,e.XorAtom=mi,e.allOk=nn,e.arrayBufferToBase64=L,e.arrayBufferToHex=U,e.assertOk=function(e,t){if(!un(e)||void 0===t)throw new mn(e)},e.badRequest=function(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}},e.booleanToTypedValue=He,e.buildTypeName=se,e.calculateAge=P,e.calculateAgeString=function(e,t){const{years:i,months:n,days:o}=P(e,t);return i>=2?i.toString().padStart(3,"0")+"Y":n>=1?n.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"},e.capitalize=N,e.createReference=T,e.createSchema=function(){return{types:{}}},e.created=on,e.deepClone=function(e){return JSON.parse(JSON.stringify(e))},e.deepEquals=O,e.evalFhirPath=Ri,e.evalFhirPathTyped=Oi,e.fhirPathArrayEquals=Je,e.fhirPathArrayEquivalent=Ke,e.fhirPathEquals=Ze,e.fhirPathEquivalent=et,e.fhirPathIs=it,e.fhirPathNot=Ye,e.findObservationInterval=function(e,t,i,n){var o;return null===(o=e.qualifiedInterval)||void 0===o?void 0:o.find((o=>{var r;return j(o,t)&&function(e,t,i){return!!e.range&&_(t,e.range,i)}(o,i,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===n||o.category===n)}))},e.findObservationReferenceRange=function(e,t,i){var n;return null===(n=e.qualifiedInterval)||void 0===n?void 0:n.find((e=>j(e,t)&&i.includes(e.condition)))},e.forbidden=cn,e.formatAddress=function(e,t){const i=[];if(e.line&&i.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),i.push(t.join(", "))}return e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join((null==t?void 0:t.lineSeparator)||", ").trim()},e.formatCodeableConcept=g,e.formatCoding=v,e.formatDate=function(e,t,i){if(!e)return"";const n=new Date(e);return l(n)?(n.setUTCHours(0,0,0,0),n.toLocaleDateString(t,Object.assign({timeZone:"UTC"},i))):""},e.formatDateTime=m,e.formatFamilyName=function(e){return e.family||""},e.formatGivenName=function(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()},e.formatHumanName=d,e.formatObservationValue=function e(t){return t?"component"in t?t.component.map((t=>e(t))).join(" / "):(null==t?void 0:t.valueQuantity)?y(t.valueQuantity):t.valueCodeableConcept?g(t.valueCodeableConcept):t.valueString?t.valueString:"":""},e.formatPeriod=function(e,t,i){return e&&(e.start||e.end)?m(e.start,t,i)+" - "+m(e.end,t,i):""},e.formatQuantity=y,e.formatRange=function(e,t,i=!1){var n,o,r,a;if(i&&void 0===t)throw new Error("Precision must be specified for exclusive ranges");const s=(null==e?void 0:e.low)&&Object.assign({},e.low),c=(null==e?void 0:e.high)&&Object.assign({},e.high);return!e||void 0===(null==s?void 0:s.value)&&void 0===(null==c?void 0:c.value)?"":void 0!==(null===(n=e.low)||void 0===n?void 0:n.value)&&void 0===(null===(o=e.high)||void 0===o?void 0:o.value)?i&&void 0!==t?(e.low.value=function(e,t,i=1){return(x(e,t)-i)*Math.pow(10,-t)}(e.low.value,t),`> ${y(e.low,t)}`):`>= ${y(e.low,t)}`:void 0===(null===(r=e.low)||void 0===r?void 0:r.value)&&void 0!==(null===(a=e.high)||void 0===a?void 0:a.value)?i&&void 0!==t?(e.high.value=function(e,t,i=1){return(x(e,t)+i)*Math.pow(10,-t)}(e.high.value,t),`< ${y(e.high,t)}`):`<= ${y(e.high,t)}`:((null==s?void 0:s.unit)===(null==c?void 0:c.unit)&&(null==s||delete s.unit),`${y(s,t)} - ${y(c,t)}`)},e.formatSearchQuery=function(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=Ni.includes(e.operator)?":"+e.operator:"",i=ji.includes(e.operator)?e.operator:"";return`${e.code}${t}=${i}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))},e.formatTime=u,e.formatTiming=function(e){var t;if(!e)return"";const i=[];if(null===(t=e.repeat)||void 0===t?void 0:t.periodUnit){const t=e.repeat.frequency||1,n=e.repeat.period||1,o=e.repeat.periodUnit;1===t&&1===n?i.push(p[o]):(1===t?i.push("once"):i.push(t+" times"),1===n?i.push("per "+h[o]):i.push("per "+n+" "+f[o])),e.repeat.dayOfWeek&&i.push("on "+e.repeat.dayOfWeek.map(N).join(", ")),e.repeat.timeOfDay&&i.push("at "+e.repeat.timeOfDay.map((e=>u(e))).join(", "))}return e.event&&i.push(e.event.map((e=>m(e))).join(", ")),N(i.join(" ").trim())},e.getCodeBySystem=function(e,t){var i,n;return null===(n=null===(i=null==e?void 0:e.coding)||void 0===i?void 0:i.find((e=>e.system===t)))||void 0===n?void 0:n.code},e.getDateProperty=function(e){return e?new Date(e):void 0},e.getDisplayString=E,e.getElementDefinition=ce,e.getExpressionForResourceType=Wi,e.getExtensionValue=function(e,...t){var i;let n=e;for(let e=0;e<t.length&&n;e++)n=null===(i=null==n?void 0:n.extension)||void 0===i?void 0:i.find((i=>i.url===t[e]));return null==n?void 0:n.valueString},e.getIdentifier=function(e,t){const i=e.identifier;if(!i)return;const n=Array.isArray(i)?i:[i];for(const e of n)if(e.system===t)return e.value},e.getImageSrc=function(e){if(!("photo"in e))return;const t=e.photo;if(t){if(!Array.isArray(t))return b(t);for(const e of t){const t=b(e);if(t)return t}}},e.getPropertyDisplayName=function(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(N).join(" ").replace("_"," ").replace(/\s+/g," ")},e.getQuestionnaireAnswers=function(e){const t={};return D(e.item,t),t},e.getReferenceString=w,e.getSearchParameterDetails=Qi,e.getStatus=function(e){return e.id===Gi?200:e.id===Xi?201:e.id===Ji?304:e.id===Ki?401:e.id===en?403:e.id===Zi?404:e.id===Yi?410:e.id===tn?429:400},e.getTypedPropertyValue=Ve,e.globalSchema=de,e.gone=dn,e.indexSearchParameter=ae,e.indexSearchParameterBundle=function(e){for(const t of e.entry){const e=t.resource;"SearchParameter"===e.resourceType&&ae(e)}},e.indexStructureDefinition=re,e.indexStructureDefinitionBundle=function(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&re(e)}},e.initFhirPathParserBuilder=Di,e.isEmpty=R,e.isGone=function(e){return e.id===Yi},e.isLowerCase=function(e){return e===e.toLowerCase()&&e!==e.toUpperCase()},e.isNotFound=function(e){return e.id===Zi},e.isObject=k,e.isOk=un,e.isPeriod=nt,e.isProfileResource=S,e.isQuantity=ot,e.isQuantityEquivalent=rt,e.isStringArray=M,e.isUUID=function(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)},e.isValidDate=l,e.matchesRange=_,e.matchesSearchRequest=function(e,t){if(t.resourceType!==e.resourceType)return!1;if(t.filters)for(const i of t.filters)if(!Fi(e,t,i))return!1;return!0},e.normalizeErrorString=function(e){var t,i,n,o;if(!e)return"Unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message;if("object"==typeof e&&"resourceType"in e){return null!==(o=null===(n=null===(i=null===(t=e.issue)||void 0===t?void 0:t[0])||void 0===i?void 0:i.details)||void 0===n?void 0:n.text)&&void 0!==o?o:"Unknown error"}return JSON.stringify(e)},e.notFound=an,e.notModified=rn,e.parseFhirPath=Ai,e.parseJWTPayload=K,e.parseSearchDefinition=function(t){const i=new URL(t,"https://example.com/"),n=i.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let o,r,a,s,c,d;return new URLSearchParams(i.search).forEach(((t,i)=>{"_fields"===i?a=t.split(","):"_offset"===i?s=parseInt(t):"_count"===i?c=parseInt(t):"_total"===i?d=t:"_sort"===i?(r=r||[],r.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(t))):(o=o||[],o.push(function(t,i){let n=t,o=e.Operator.EQUALS;for(const e of Ni){const t=n.indexOf(":"+e);-1!==t&&(o=e,n=n.substring(0,t))}for(const e of ji)i.match(new RegExp("^"+e+"\\d"))&&(o=e,i=i.substring(e.length));return{code:n,operator:o,value:i}}(i,t)))})),{resourceType:n,filters:o,fields:a,offset:s,count:c,total:d,sortRules:r}},e.preciseEquals=function(e,t,i){return W(e,i)===W(t,i)},e.preciseGreaterThan=function(e,t,i){return W(e,i)>W(t,i)},e.preciseGreaterThanOrEquals=B,e.preciseLessThan=function(e,t,i){return W(e,i)<W(t,i)},e.preciseLessThanOrEquals=Q,e.preciseRound=function(e,t){return parseFloat(e.toFixed(t))},e.removeDuplicates=Xe,e.resolveId=function(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]},e.setCodeBySystem=function(e,t,i){var n,o;e.coding||(e.coding=[]);const r=null===(n=e.coding)||void 0===n?void 0:n.find((e=>e.system===t));r?r.code=i:null===(o=e.coding)||void 0===o||o.push({system:t,code:i})},e.stringify=C,e.toJsBoolean=ze,e.toTypedValue=$e,e.tokenize=wi,e.tooManyRequests=ln,e.unauthorized=sn}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.core={}))}(this,(function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}))}function n(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function i(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!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"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}var o,r,a,s;class c{constructor(e=10){o.add(this),r.set(this,void 0),a.set(this,void 0),i(this,r,e,"f"),i(this,a,new Map,"f")}clear(){n(this,a,"f").clear()}get(e){const t=n(this,a,"f").get(e);return t&&(n(this,a,"f").delete(e),n(this,a,"f").set(e,t)),t}set(e,t){n(this,a,"f").has(e)?n(this,a,"f").delete(e):n(this,a,"f").size>=n(this,r,"f")&&n(this,a,"f").delete(n(this,o,"m",s).call(this)),n(this,a,"f").set(e,t)}delete(e){n(this,a,"f").delete(e)}keys(){return n(this,a,"f").keys()}}function d(e,t){const n=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&n.push(...e.prefix),e.given&&n.push(...e.given),e.family&&n.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&n.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&n.push("["+e.use+"]"),n.join(" ").trim()}function l(e){return e instanceof Date&&!isNaN(e.getTime())}function u(e,t,n){if(!e)return"";const i=new Date("2000-01-01T"+e+"Z");return l(i)?i.toLocaleTimeString(t,n):""}function p(e,t,n){if(!e)return"";const i=new Date(e);return l(i)?i.toLocaleString(t,n):""}r=new WeakMap,a=new WeakMap,o=new WeakSet,s=function(){return n(this,a,"f").keys().next().value};const m={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},h={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},f={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function y(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),void 0!==e.value&&(void 0!==t?n.push(e.value.toFixed(t)):n.push(e.value)),e.unit&&("%"!==e.unit&&" "!==n[n.length-1]&&n.push(" "),n.push(e.unit)),n.join("").trim()}function g(e){return e?e.text?e.text:e.coding?e.coding.map((e=>x(e))).join(", "):"":""}function x(e){return(null==e?void 0:e.display)||(null==e?void 0:e.code)||""}function v(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function S(e){const t=T(e),n=E(e);return n===t?{reference:t}:{reference:t,display:n}}function T(e){return e.resourceType+"/"+e.id}function w(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function E(e){var t;if(w(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)?e.code.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:T(e)}function b(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function P(e,t){const n=new Date(e);n.setUTCHours(0,0,0,0);const i=t?new Date(t):new Date;i.setUTCHours(0,0,0,0);const o=n.getUTCFullYear(),r=n.getUTCMonth(),a=n.getUTCDate(),s=i.getUTCFullYear(),c=i.getUTCMonth(),d=i.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((i.getTime()-n.getTime())/864e5)}}function D(e,t){if(e)for(const n of e)n.linkId&&n.answer&&n.answer.length>0&&(t[n.linkId]=n.answer[0]),D(n.item,t)}function C(e,t){return JSON.stringify(e,A,t?2:void 0)}function A(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&R(t)?void 0:t}function R(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function O(e,t,n){return e===t||(!(!R(e)||!R(t))||!R(e)&&!R(t)&&(Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!O(e[n],t[n]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(k(e)&&k(t)?function(e,t,n){const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e))),"meta"===n&&(i.delete("versionId"),i.delete("lastUpdated"),i.delete("author"));for(const n of i){if(!O(e[n],t[n],n))return!1}return!0}(e,t,n):(k(e)||k(t),!1))))}function k(e){return null!==e&&"object"==typeof e}function I(e){return e.every((e=>"string"==typeof e))}const M=[];for(let e=0;e<256;e++)M.push(e.toString(16).padStart(2,"0"));function U(e){const t=new Uint8Array(e),n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=M[t[e]];return n.join("")}function L(e){const t=new Uint8Array(e),n=[];for(let e=0;e<t.length;e++)n[e]=String.fromCharCode(t[e]);return window.btoa(n.join(""))}function N(e){return e.charAt(0).toUpperCase()+e.substring(1)}function j(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||_(P(t.birthDate).years,e.age)}(e,t)}function _(e,t,n){var i,o;return(void 0===(null===(i=t.low)||void 0===i?void 0:i.value)||B(e,t.low.value,n))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||Q(e,t.high.value,n))}function Q(e,t,n){return W(e,n)<=W(t,n)}function B(e,t,n){return W(e,n)>=W(t,n)}function W(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function q(){const e=new Uint32Array(28);return crypto.getRandomValues(e),U(e.buffer)}var $,F,H,z,V,G,X,Y;class J{constructor(){$.set(this,void 0),i(this,$,{},"f")}addEventListener(e,t){n(this,$,"f")[e]||(n(this,$,"f")[e]=[]),n(this,$,"f")[e].push(t)}removeEventListeneer(e,t){const i=n(this,$,"f")[e];if(i)for(let e=0;e<i.length;e++)if(i[e]===t)return void i.splice(e,1)}dispatchEvent(e){const t=n(this,$,"f")[e.type];return t&&t.forEach((t=>t.call(this,e))),!e.defaultPrevented}}function Z(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,"/")),n=Array.from(t).reduce(((e,t)=>`${e}%${("00"+t.charCodeAt(0).toString(16)).slice(-2)}`),""),i=decodeURIComponent(n);return JSON.parse(i)}function K(e){const[t,n,i]=e.split(".");return Z(n)}$=new WeakMap;class ee{constructor(e){this[G]="ReadablePromise",F.set(this,void 0),H.set(this,"pending"),z.set(this,void 0),V.set(this,void 0),i(this,F,e.then((e=>(i(this,H,"success","f"),i(this,z,e,"f"),e)),(e=>{throw i(this,H,"error","f"),i(this,V,e,"f"),e})),"f")}isPending(){return"pending"===n(this,H,"f")}isOk(){return"success"===n(this,H,"f")}read(){switch(n(this,H,"f")){case"pending":throw n(this,F,"f");case"error":throw n(this,V,"f");default:return n(this,z,"f")}}then(e,t){return n(this,F,"f").then(e,t)}catch(e){return n(this,F,"f").catch(e)}finally(e){return n(this,F,"f").finally(e)}}F=new WeakMap,H=new WeakMap,z=new WeakMap,V=new WeakMap,G=Symbol.toStringTag;class te{constructor(){X.set(this,void 0),i(this,X,"undefined"!=typeof localStorage?localStorage:new ne,"f")}clear(){n(this,X,"f").clear()}getString(e){return n(this,X,"f").getItem(e)||void 0}setString(e,t){t?n(this,X,"f").setItem(e,t):n(this,X,"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)}}X=new WeakMap;class ne{constructor(){Y.set(this,void 0),i(this,Y,new Map,"f")}get length(){return n(this,Y,"f").size}clear(){n(this,Y,"f").clear()}getItem(e){var t;return null!==(t=n(this,Y,"f").get(e))&&void 0!==t?t:null}setItem(e,t){t?n(this,Y,"f").set(e,t):n(this,Y,"f").delete(e)}removeItem(e){n(this,Y,"f").delete(e)}key(e){return Array.from(n(this,Y,"f").keys())[e]}}Y=new WeakMap;var ie,oe={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 re(e){var t;if(!e.name)return;const n=null===(t=e.snapshot)||void 0===t?void 0:t.element;n&&(n.forEach((t=>function(e,t){var n,i;const o=t.path,r=null===(i=null===(n=t.type)||void 0===n?void 0:n[0])||void 0===i?void 0:i.code;if(void 0!==r&&"Element"!==r&&"BackboneElement"!==r)return;const a=o.split("."),s=se(a);de.types[s]=function(e,t,n){return{structureDefinition:t,elementDefinition:n,display:e,description:n.definition,properties:{}}}(s,e,t),de.types[s].parentType=se(a.slice(0,a.length-1))}(e,t))),n.forEach((e=>function(e){const t=e.path,n=t.split(".");if(1===n.length)return;const i=se(n.slice(0,n.length-1)),o=de.types[i];if(!o)return;const r=n[n.length-1];o.properties[r]=e}(e))))}function ae(e){if(e.base)for(const t of e.base){const n=de.types[t];n&&(n.searchParams||(n.searchParams={_id:{base:[t],code:"_id",type:"token",expression:t+".id"},_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"},_compartment:{base:[t],code:"_compartment",type:"reference",expression:t+".meta.compartment"}}),n.searchParams[e.code]=e)}}function se(e){return 1===e.length?e[0]:e.map(N).join("")}function ce(e,t){var n;const i=de.types[e];if(!i)return;const o=null!==(n=i.properties[t])&&void 0!==n?n:i.properties[t+"[x]"];if(o){if(o.contentReference){const e=o.contentReference.substring(1).split("."),t=e.pop();return ce(se(e),t)}return o}}e.PropertyType=void 0,(ie=e.PropertyType||(e.PropertyType={})).Address="Address",ie.Age="Age",ie.Annotation="Annotation",ie.Attachment="Attachment",ie.BackboneElement="BackboneElement",ie.CodeableConcept="CodeableConcept",ie.Coding="Coding",ie.ContactDetail="ContactDetail",ie.ContactPoint="ContactPoint",ie.Contributor="Contributor",ie.Count="Count",ie.DataRequirement="DataRequirement",ie.Distance="Distance",ie.Dosage="Dosage",ie.Duration="Duration",ie.Expression="Expression",ie.Extension="Extension",ie.HumanName="HumanName",ie.Identifier="Identifier",ie.MarketingStatus="MarketingStatus",ie.Meta="Meta",ie.Money="Money",ie.Narrative="Narrative",ie.ParameterDefinition="ParameterDefinition",ie.Period="Period",ie.Population="Population",ie.ProdCharacteristic="ProdCharacteristic",ie.ProductShelfLife="ProductShelfLife",ie.Quantity="Quantity",ie.Range="Range",ie.Ratio="Ratio",ie.Reference="Reference",ie.RelatedArtifact="RelatedArtifact",ie.SampledData="SampledData",ie.Signature="Signature",ie.SubstanceAmount="SubstanceAmount",ie.SystemString="http://hl7.org/fhirpath/System.String",ie.Timing="Timing",ie.TriggerDefinition="TriggerDefinition",ie.UsageContext="UsageContext",ie.base64Binary="base64Binary",ie.boolean="boolean",ie.canonical="canonical",ie.code="code",ie.date="date",ie.dateTime="dateTime",ie.decimal="decimal",ie.id="id",ie.instant="instant",ie.integer="integer",ie.markdown="markdown",ie.oid="oid",ie.positiveInt="positiveInt",ie.string="string",ie.time="time",ie.unsignedInt="unsignedInt",ie.uri="uri",ie.url="url",ie.uuid="uuid";const de=oe;var le,ue,pe,me,he,fe,ye,ge,xe,ve,Se,Te,we,Ee,be,Pe,De,Ce,Ae,Re,Oe,ke,Ie,Me,Ue,Le,Ne,je,_e,Qe,Be,We,qe;function $e(){return window.location.protocol+"//"+window.location.host+"/"}var Fe,He,ze,Ve,Ge,Xe,Ye,Je,Ze,Ke,et,tt,nt,it,ot,rt,at,st,ct,dt,lt,ut,pt,mt,ht,ft,yt,gt,xt,vt,St,Tt;ue=new WeakMap,pe=new WeakMap,me=new WeakMap,he=new WeakMap,fe=new WeakMap,ye=new WeakMap,ge=new WeakMap,xe=new WeakMap,ve=new WeakMap,Se=new WeakMap,Te=new WeakMap,we=new WeakMap,Ee=new WeakMap,be=new WeakMap,Pe=new WeakMap,De=new WeakMap,Ce=new WeakMap,Ae=new WeakMap,le=new WeakSet,Re=function(e){const t=this.getLogins().filter((t=>{var n,i;return(null===(n=t.profile)||void 0===n?void 0:n.reference)!==(null===(i=e.profile)||void 0===i?void 0:i.reference)}));t.push(e),n(this,me,"f").setObject("logins",t)},Oe=function(){return t(this,void 0,void 0,(function*(){return i(this,De,new Promise(((e,t)=>{this.get("auth/me").then((t=>{i(this,De,void 0,"f"),i(this,Ce,t.profile,"f"),i(this,Ae,t.config,"f"),this.dispatchEvent({type:"change"}),e(n(this,Ce,"f"))})).catch(t)})),"f"),n(this,De,"f")}))},ke=function(e,t){if(n(this,fe,"f")<=0||"no-cache"===(null==t?void 0:t.cache)||"reload"===(null==t?void 0:t.cache))return;const i=n(this,he,"f").get(e);return!i||i.requestTime+n(this,fe,"f")<Date.now()?void 0:i},Ie=function(e,t){n(this,fe,"f")>0&&n(this,he,"f").set(e,{requestTime:Date.now(),value:t})},Me=function(e,i,o={}){return t(this,void 0,void 0,(function*(){n(this,Pe,"f")&&(yield n(this,Pe,"f")),i.startsWith("http")||(i=n(this,ye,"f")+i),o.method=e,n(this,le,"m",Ue).call(this,o);const t=yield n(this,ue,"f").call(this,i,o);if(401===t.status)return n(this,le,"m",je).call(this,e,i,o);if(204===t.status||304===t.status)return;const r=yield t.json();if(t.status>=400)throw r;return r}))},Ue=function(e){e.headers||(e.headers={});const t=e.headers;t["X-Medplum"]="extended",t["Content-Type"]||(t["Content-Type"]="application/fhir+json"),n(this,Ee,"f")&&(t.Authorization="Bearer "+n(this,Ee,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},Le=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},Ne=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))},je=function(e,t,i){return n(this,le,"m",Qe).call(this)?n(this,le,"m",Me).call(this,e,t,i):(this.clear(),n(this,Se,"f")&&n(this,Se,"f").call(this),Promise.reject(new Error("Unauthenticated")))},_e=function(){return t(this,void 0,void 0,(function*(){yield this.startPkce();const e=new URL(n(this,ge,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",sessionStorage.getItem("pkceState")),e.searchParams.set("client_id",n(this,Te,"f")),e.searchParams.set("redirect_uri",$e()),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",sessionStorage.getItem("codeChallenge")),window.location.assign(e.toString())}))},Qe=function(){if(n(this,Pe,"f"))return n(this,Pe,"f");if(n(this,be,"f")){const e=new URLSearchParams;return e.set("grant_type","refresh_token"),e.set("client_id",n(this,Te,"f")),e.set("refresh_token",n(this,be,"f")),i(this,Pe,n(this,le,"m",Be).call(this,e),"f"),n(this,Pe,"f")}return n(this,Te,"f")&&n(this,we,"f")?(i(this,Pe,this.startClientLogin(n(this,Te,"f"),n(this,we,"f")),"f"),n(this,Pe,"f")):void 0},Be=function(e){return t(this,void 0,void 0,(function*(){return n(this,ue,"f").call(this,n(this,xe,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e,credentials:"include"}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>n(this,le,"m",We).call(this,e))).then((()=>this.getProfile()))}))},We=function(e){return t(this,void 0,void 0,(function*(){const t=e.access_token,i=K(t);if(Date.now()>=1e3*i.exp)throw this.clear(),new Error("Token expired");if(n(this,Te,"f")&&i.client_id!==n(this,Te,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}))},qe=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};class wt{constructor(e,t){this.operator=e,this.child=t}toString(){return`${this.operator}(${this.child.toString()})`}}class Et{constructor(e,t,n){this.operator=e,this.left=t,this.right=n}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}class bt{constructor(){Fe.set(this,{}),He.set(this,{})}registerInfix(e,t){return n(this,He,"f")[e]=t,this}registerPrefix(e,t){return n(this,Fe,"f")[e]=t,this}prefix(e,t,n){return this.registerPrefix(e,{parse(e,i){const o=e.consumeAndParse(t);return n(i,o)}})}infixLeft(e,t,n){return this.registerInfix(e,{parse(e,i,o){const r=e.consumeAndParse(t);return n(i,o,r)},precedence:t})}construct(e){return new Pt(e,n(this,Fe,"f"),n(this,He,"f"))}}Fe=new WeakMap,He=new WeakMap;class Pt{constructor(e,t,n){ze.set(this,void 0),Ve.set(this,void 0),Ge.set(this,void 0),i(this,ze,e,"f"),i(this,Ve,t,"f"),i(this,Ge,n,"f")}hasMore(){return n(this,ze,"f").length>0}match(e){const t=this.peek();return(null==t?void 0:t.id)===e&&(this.consume(),!0)}consumeAndParse(e=1/0){const t=this.consume(),i=n(this,Ve,"f")[t.id];if(!i)throw Error(`Parse error at "${t.value}" (line ${t.line}, column ${t.column}). No matching prefix parselet.`);let o=i.parse(this,t);for(;e>this.getPrecedence();){const e=this.consume();o=this.getInfixParselet(e).parse(this,o,e)}return o}getPrecedence(){const e=this.peek();if(!e)return 1/0;const t=this.getInfixParselet(e);return t?t.precedence:1/0}consume(e,t){var i,o;if(!n(this,ze,"f").length)throw Error("Cant consume unknown more tokens.");if(e&&(null===(i=this.peek())||void 0===i?void 0:i.id)!==e){const t=this.peek();throw Error(`Expected ${e} but got "${t.id}" at line ${t.line} column ${t.column}.`)}if(t&&(null===(o=this.peek())||void 0===o?void 0:o.value)!==t){const e=this.peek();throw Error(`Expected "${t}" but got "${e.value}" at line ${e.line} column ${e.column}.`)}return n(this,ze,"f").shift()}peek(){return n(this,ze,"f").length>0?n(this,ze,"f")[0]:void 0}removeComments(){i(this,ze,n(this,ze,"f").filter((e=>"Comment"!==e.id)),"f")}getInfixParselet(e){return n(this,Ge,"f")["Symbol"===e.id?e.value:e.id]}}ze=new WeakMap,Ve=new WeakMap,Ge=new WeakMap;const Dt=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class Ct{constructor(e,t,n){Xe.add(this),Ye.set(this,void 0),Je.set(this,void 0),Ze.set(this,void 0),Ke.set(this,[]),et.set(this,{index:0,line:1,column:0}),tt.set(this,[]),i(this,Ye,e,"f"),i(this,Je,t,"f"),i(this,Ze,n,"f")}tokenize(){for(;n(this,et,"f").index<n(this,Ye,"f").length;){const e=n(this,Xe,"m",ot).call(this);e&&n(this,Ke,"f").push(e)}return n(this,Ke,"f")}}function At(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}}function Rt(t){return[{type:e.PropertyType.boolean,value:t}]}function Ot(t){return null==t?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:e.PropertyType.integer,value:t}:"number"==typeof t?{type:e.PropertyType.decimal,value:t}:"boolean"==typeof t?{type:e.PropertyType.boolean,value:t}:"string"==typeof t?{type:e.PropertyType.string,value:t}:$t(t)?{type:e.PropertyType.Quantity,value:t}:"object"==typeof t&&"resourceType"in t?{type:t.resourceType,value:t}:{type:e.PropertyType.BackboneElement,value:t}}function kt(e){return 0!==e.length&&!!e[0].value}function It(t,n){if(!(null==t?void 0:t.value))return;const i=ce(t.type,n);if(i){const e=function(e,t,n){var i;const o=n.type;if(!o||0===o.length)return;let r,a="undefined";if(1===o.length)r=e.value[t],a=o[0].code;else for(const n of o){const i=t.replace("[x]","")+N(n.code);if(i in e.value){r=e.value[i],a=n.code;break}}if(R(r))return;"Element"!==a&&"BackboneElement"!==a||(a=se(null===(i=n.path)||void 0===i?void 0:i.split(".")));return Array.isArray(r)?r.map((e=>Mt(e,a))):Mt(r,a)}(t,n,i);if(e)return e}return function(t,n){const i=t.value;if(!i||"object"!=typeof i)return;let o;if(n in i)o=i[n];else for(const t in e.PropertyType){const e=n+N(t);if(e in i){o=i[e];break}}if(R(o))return;return Array.isArray(o)?o.map(Ot):Ot(o)}(t,n)}function Mt(e,t){return"Resource"===t&&"object"==typeof e&&"resourceType"in e&&(t=e.resourceType),{type:t,value:e}}function Ut(e){const t=[];for(const n of e){let e=!1;for(const i of t)if(kt(jt(n,i))){e=!0;break}e||t.push(n)}return t}function Lt(e){return Rt(!kt(e))}function Nt(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?Rt(!1):Rt(e.every(((e,n)=>kt(jt(e,t[n])))))}function jt(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?Rt(Math.abs(n-i)<1e-8):$t(n)&&$t(i)?Rt(Ft(n,i)):Rt("object"==typeof n&&"object"==typeof i?Ht(e,t):n===i)}function _t(e,t){return 0===e.length&&0===t.length?Rt(!0):e.length!==t.length?Rt(!1):(e.sort(Bt),t.sort(Bt),Rt(e.every(((e,n)=>kt(Qt(e,t[n]))))))}function Qt(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?Rt(Math.abs(n-i)<.01):$t(n)&&$t(i)?Rt(Ft(n,i)):Rt("object"==typeof n&&"object"==typeof i?Ht(n,i):"string"==typeof n&&"string"==typeof i?n.toLowerCase()===i.toLowerCase():n===i)}function Bt(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?n-i:"string"==typeof n&&"string"==typeof i?n.localeCompare(i):0}function Wt(e,t){const{value:n}=e;if(null==n)return!1;switch(t){case"Boolean":return"boolean"==typeof n;case"Decimal":case"Integer":return"number"==typeof n;case"Date":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof n&&!!n.match(/^T\d/);case"Period":return qt(n);case"Quantity":return $t(n);default:return"object"==typeof n&&(null==n?void 0:n.resourceType)===t}}function qt(e){return!(!e||"object"!=typeof e||!("start"in e))}function $t(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function Ft(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 Ht(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){const n=e[i],o=t[i];if(zt(n)&&zt(o)){if(!Ht(n,o))return!1}else if(n!==o)return!1}return!0}function zt(e){return null!==e&&"object"==typeof e}Ye=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Ke=new WeakMap,et=new WeakMap,tt=new WeakMap,Xe=new WeakSet,nt=function(){return n(this,Ke,"f").slice(-1)[0]},it=function(){n(this,Xe,"m",xt).call(this);const e=n(this,Xe,"m",ot).call(this);return n(this,Xe,"m",vt).call(this),e},ot=function(){n(this,Xe,"m",rt).call(this);const e=n(this,Xe,"m",ft).call(this);if(!e)return;n(this,Xe,"m",xt).call(this);const t=n(this,Xe,"m",gt).call(this);return"/"===e&&"*"===t?n(this,Xe,"m",at).call(this):"/"===e&&"/"===t?n(this,Xe,"m",st).call(this):"'"===e||'"'===e?n(this,Xe,"m",ct).call(this,e):"`"===e?n(this,Xe,"m",dt).call(this):"@"===e?n(this,Xe,"m",lt).call(this):e.match(/\d/)?n(this,Xe,"m",ut).call(this):e.match(/\w/)||"$"===e&&t.match(/\w/)?n(this,Xe,"m",pt).call(this):n(this,Xe,"m",mt).call(this)},rt=function(){n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/\s/)))},at=function(){const e=n(this,et,"f").index;return n(this,Xe,"m",ht).call(this,(()=>"*"!==n(this,Xe,"m",ft).call(this)||"/"!==n(this,Xe,"m",gt).call(this))),n(this,Xe,"m",St).call(this),n(this,Xe,"m",St).call(this),n(this,Xe,"m",Tt).call(this,"Comment",n(this,Ye,"f").substring(e,n(this,et,"f").index))},st=function(){return n(this,Xe,"m",Tt).call(this,"Comment",n(this,Xe,"m",ht).call(this,(()=>"\n"!==n(this,Xe,"m",ft).call(this))))},ct=function(e){n(this,Xe,"m",St).call(this);const t=n(this,Xe,"m",Tt).call(this,"String",n(this,Xe,"m",ht).call(this,(()=>"\\"===n(this,Xe,"m",yt).call(this)||n(this,Xe,"m",ft).call(this)!==e)));return n(this,Xe,"m",St).call(this),t},dt=function(){n(this,Xe,"m",St).call(this);const e=n(this,Xe,"m",Tt).call(this,"Symbol",n(this,Xe,"m",ht).call(this,(()=>"`"!==n(this,Xe,"m",ft).call(this))));return n(this,Xe,"m",St).call(this),e},lt=function(){n(this,Xe,"m",St).call(this);const e=n(this,et,"f").index;return n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/[\d-]/))),"T"===n(this,Xe,"m",ft).call(this)&&(n(this,Xe,"m",St).call(this),n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/[\d:]/))),"."===n(this,Xe,"m",ft).call(this)&&n(this,Xe,"m",gt).call(this).match(/\d/)&&(n(this,Xe,"m",St).call(this),n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/\d/)))),"Z"===n(this,Xe,"m",ft).call(this)?n(this,Xe,"m",St).call(this):"+"!==n(this,Xe,"m",ft).call(this)&&"-"!==n(this,Xe,"m",ft).call(this)||(n(this,Xe,"m",St).call(this),n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/[\d:]/))))),n(this,Xe,"m",Tt).call(this,"DateTime",n(this,Ye,"f").substring(e,n(this,et,"f").index))},ut=function(){const e=n(this,et,"f").index;let t="Number";return n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/\d/))),"."===n(this,Xe,"m",ft).call(this)&&n(this,Xe,"m",gt).call(this).match(/\d/)&&(n(this,Xe,"m",St).call(this),n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/\d/))))," "===n(this,Xe,"m",ft).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&Dt.includes(e.value))return!0}return!1}(n(this,Xe,"m",it).call(this))&&(t="Quantity",n(this,Xe,"m",ot).call(this)),n(this,Xe,"m",Tt).call(this,t,n(this,Ye,"f").substring(e,n(this,et,"f").index))},pt=function(){var e;const t=n(this,Xe,"m",ht).call(this,(()=>n(this,Xe,"m",ft).call(this).match(/[$\w]/)));return"."!==(null===(e=n(this,Xe,"m",nt).call(this))||void 0===e?void 0:e.value)&&n(this,Je,"f").includes(t)?n(this,Xe,"m",Tt).call(this,t,t):n(this,Xe,"m",Tt).call(this,"Symbol",t)},mt=function(){const e=n(this,Xe,"m",ft).call(this),t=e+n(this,Xe,"m",gt).call(this);return n(this,Ze,"f").includes(t)?(n(this,Xe,"m",St).call(this),n(this,Xe,"m",St).call(this),n(this,Xe,"m",Tt).call(this,t,t)):(n(this,Xe,"m",St).call(this),n(this,Xe,"m",Tt).call(this,e,e))},ht=function(e){const t=n(this,et,"f").index;for(;n(this,et,"f").index<n(this,Ye,"f").length&&e();)n(this,Xe,"m",St).call(this);return n(this,Ye,"f").substring(t,n(this,et,"f").index)},ft=function(){return n(this,Ye,"f")[n(this,et,"f").index]},yt=function(){var e;return null!==(e=n(this,Ye,"f")[n(this,et,"f").index-1])&&void 0!==e?e:""},gt=function(){var e;return null!==(e=n(this,Ye,"f")[n(this,et,"f").index+1])&&void 0!==e?e:""},xt=function(){n(this,tt,"f").push(Object.assign({},n(this,et,"f")))},vt=function(){const e=n(this,tt,"f").pop();if(!e)throw new Error("No mark to reset to");n(this,et,"f").index=e.index,n(this,et,"f").line=e.line,n(this,et,"f").column=e.column},St=function(){n(this,et,"f").index++,"\n"===n(this,Xe,"m",ft).call(this)?(n(this,et,"f").line++,n(this,et,"f").column=0):n(this,et,"f").column++},Tt=function(e,t){const i=n(this,tt,"f").pop();if(!i)throw new Error("No mark for token");return Object.assign({id:e,value:t},i)};const Vt=()=>[],Gt={empty:e=>Rt(0===e.length),exists:(e,t)=>Rt(t?e.filter((e=>kt(t.eval([e])))).length>0:e.length>0),all:(e,t)=>Rt(e.every((e=>kt(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return Rt(!1);return Rt(!0)},anyTrue:e=>{for(const t of e)if(t.value)return Rt(!0);return Rt(!1)},allFalse:e=>{for(const t of e)if(t.value)return Rt(!1);return Rt(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return Rt(!0);return Rt(!1)},subsetOf:Vt,supersetOf:Vt,count:t=>[{type:e.PropertyType.integer,value:t.length}],distinct:e=>{const t=[];for(const n of e)t.some((e=>e.value===n.value))||t.push(n);return t},isDistinct:e=>Rt(e.length===Gt.distinct(e).length),where:(e,t)=>e.filter((e=>kt(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:Vt,ofType:(e,t)=>e.filter((e=>e.type===t.name)),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 n;const i=null===(n=t.eval(e)[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for skip(num)");return i>=e.length?[]:i<=0?e:e.slice(i,e.length)},take:(e,t)=>{var n;const i=null===(n=t.eval(e)[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for take(num)");return i>=e.length?e:i<=0?[]:e.slice(0,i)},intersect:(e,t)=>{if(!t)return e;const n=t.eval(e),i=[];for(const t of e)!i.some((e=>e.value===t.value))&&n.some((e=>e.value===t.value))&&i.push(t);return i},exclude:(e,t)=>{if(!t)return e;const n=t.eval(e),i=[];for(const t of e)n.some((e=>e.value===t.value))||i.push(t);return i},union:(e,t)=>{if(!t)return e;const n=t.eval(e);return Ut([...e,...n])},combine:(e,t)=>{if(!t)return e;const n=t.eval(e);return[...e,...n]},iif:(e,t,n,i)=>{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 kt(o)?n.eval(e):i?i.eval(e):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);if("boolean"==typeof n)return[{type:e.PropertyType.boolean,value:n}];if("number"==typeof n&&(0===n||1===n))return Rt(!!n);if("string"==typeof n){const e=n.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return Rt(!0);if(["false","f","no","n","0","0.0"].includes(e))return Rt(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:Rt(1===Gt.toBoolean(e).length),toInteger:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);return"number"==typeof n?[{type:e.PropertyType.integer,value:n}]:"string"==typeof n&&n.match(/^[+-]?\d+$/)?[{type:e.PropertyType.integer,value:parseInt(n,10)}]:"boolean"==typeof n?[{type:e.PropertyType.integer,value:n?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:Rt(1===Gt.toInteger(e).length),toDate:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);return"string"==typeof n&&n.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.date,value:At(n)}]:[]},convertsToDate:e=>0===e.length?[]:Rt(1===Gt.toDate(e).length),toDateTime:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);return"string"==typeof n&&n.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.dateTime,value:At(n)}]:[]},convertsToDateTime:e=>0===e.length?[]:Rt(1===Gt.toDateTime(e).length),toDecimal:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);return"number"==typeof n?[{type:e.PropertyType.decimal,value:n}]:"string"==typeof n&&n.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:e.PropertyType.decimal,value:parseFloat(n)}]:"boolean"==typeof n?[{type:e.PropertyType.decimal,value:n?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:Rt(1===Gt.toDecimal(e).length),toQuantity:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);return $t(n)?[{type:e.PropertyType.Quantity,value:n}]:"number"==typeof n?[{type:e.PropertyType.Quantity,value:{value:n,unit:"1"}}]:"string"==typeof n&&n.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:e.PropertyType.Quantity,value:{value:parseFloat(n),unit:"1"}}]:"boolean"==typeof n?[{type:e.PropertyType.Quantity,value:{value:n?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:Rt(1===Gt.toQuantity(e).length),toString:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);return null==n?[]:$t(n)?[{type:e.PropertyType.string,value:`${n.value} '${n.unit}'`}]:[{type:e.PropertyType.string,value:n.toString()}]},convertsToString:e=>0===e.length?[]:Rt(1===Gt.toString(e).length),toTime:t=>{if(0===t.length)return[];const[{value:n}]=Jt(t,1);if("string"==typeof n){const t=n.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:e.PropertyType.time,value:At("T"+t[1])}]}return[]},convertsToTime:e=>0===e.length?[]:Rt(1===Gt.toTime(e).length),indexOf:(e,t)=>Xt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,n)=>Xt(((e,t,n)=>{const i=t,o=n?i+n:e.length;return i<0||i>=e.length?void 0:e.substring(i,o)}),e,t,n),startsWith:(e,t)=>Xt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>Xt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>Xt(((e,t)=>e.includes(t)),e,t),upper:e=>Xt((e=>e.toUpperCase()),e),lower:e=>Xt((e=>e.toLowerCase()),e),replace:(e,t,n)=>Xt(((e,t,n)=>e.replaceAll(t,n)),e,t,n),matches:(e,t)=>Xt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,n)=>Xt(((e,t,n)=>e.replaceAll(t,n)),e,t,n),length:e=>Xt((e=>e.length),e),toChars:e=>Xt((e=>e?e.split(""):void 0),e),abs:e=>Yt(Math.abs,e),ceiling:e=>Yt(Math.ceil,e),exp:e=>Yt(Math.exp,e),floor:e=>Yt(Math.floor,e),ln:e=>Yt(Math.log,e),log:(e,t)=>Yt(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>Yt(Math.pow,e,t),round:e=>Yt(Math.round,e),sqrt:e=>Yt(Math.sqrt,e),truncate:e=>Yt((e=>0|e),e),children:Vt,descendants:Vt,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:e.PropertyType.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:e.PropertyType.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:e.PropertyType.date,value:(new Date).toISOString().substring(0,10)}],between:(t,n,i,o)=>{var r;const a=Gt.toDateTime(n.eval(t));if(0===a.length)throw new Error("Invalid start date");const s=Gt.toDateTime(i.eval(t));if(0===s.length)throw new Error("Invalid end date");const c=null===(r=o.eval(t)[0])||void 0===r?void 0:r.value;if("years"!==c&&"months"!==c&&"days"!==c)throw new Error("Invalid units");const d=P(a[0].value,s[0].value);return[{type:e.PropertyType.Quantity,value:{value:d[c],unit:c}}]},is:(t,n)=>{let i="";return n instanceof nn?i=n.name:n instanceof un&&(i=n.left.name+"."+n.right.name),i?t.map((t=>({type:e.PropertyType.boolean,value:Wt(t,i)}))):[]},not:t=>Gt.toBoolean(t).map((t=>({type:e.PropertyType.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const n=t.value;let i;if("string"==typeof n)i=n;else if("object"==typeof n){const e=n;if(e.resource)return Ot(e.resource);i=e.reference}if(!i)return{type:e.PropertyType.BackboneElement,value:null};const[o,r]=i.split("/");return{type:e.PropertyType.BackboneElement,value:{resourceType:o,id:r}}})).filter((e=>!!e.value)),as:e=>e,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:e.PropertyType.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:e.PropertyType.BackboneElement,value:null})),conformsTo:(t,n)=>{const i=n.eval(t)[0].value;if(!i.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=i.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var n;return{type:e.PropertyType.boolean,value:(null===(n=t.value)||void 0===n?void 0:n.resourceType)===o}}))}};function Xt(e,t,...n){if(0===t.length)return[];const[{value:i}]=Jt(t,1);if("string"!=typeof i)throw new Error("String function cannot be called with non-string");const o=e(i,...n.map((e=>{var n,i;return e&&(null===(i=null===(n=e.eval(t))||void 0===n?void 0:n[0])||void 0===i?void 0:i.value)})));return void 0===o?[]:Array.isArray(o)?o.map(Ot):[Ot(o)]}function Yt(t,n,...i){if(0===n.length)return[];const[{value:o}]=Jt(n,1),r=$t(o),a=r?o.value:o;if("number"!=typeof a)throw new Error("Math function cannot be called with non-number");const s=t(a,...i.map((e=>{var t,i;return null===(i=null===(t=e.eval(n))||void 0===t?void 0:t[0])||void 0===i?void 0:i.value})));return[{type:r?e.PropertyType.Quantity:n[0].type,value:r?Object.assign(Object.assign({},o),{value:s}):s}]}function Jt(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 Zt,Kt;class en{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}`)}}toString(){return this.child.toString()}}class tn{constructor(e){this.value=e}eval(){return[this.value]}toString(){const e=this.value.value;return"string"==typeof e?`'${e}'`:e.toString()}}class nn{constructor(e){this.name=e,Zt.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>n(this,Zt,"m",Kt).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}toString(){return this.name}}Zt=new WeakSet,Kt=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:It(e,this.name)};class on{eval(){return[]}toString(){return"{}"}}class rn extends wt{constructor(e,t,n){super(e,t),this.impl=n}eval(e){return this.impl(this.child.eval(e))}toString(){return this.child.toString()}}class an extends Et{constructor(e,t){super("as",e,t)}eval(e){return Gt.ofType(this.left.eval(e),this.right)}}class sn extends Et{constructor(e,t,n,i){super(e,t,n),this.impl=i}eval(t){const n=this.left.eval(t);if(1!==n.length)return[];const i=this.right.eval(t);if(1!==i.length)return[];const o=n[0].value,r=i[0].value,a=$t(o)?o.value:o,s=$t(r)?r.value:r,c=this.impl(a,s);return"boolean"==typeof c?Rt(c):$t(o)?[{type:e.PropertyType.Quantity,value:Object.assign(Object.assign({},o),{value:c})}]:[Ot(c)]}}class cn extends Et{constructor(e,t){super("&",e,t)}eval(t){const n=[...this.left.eval(t),...this.right.eval(t)];return n.length>0&&n.every((e=>"string"==typeof e.value))?[{type:e.PropertyType.string,value:n.map((e=>e.value)).join("")}]:n}}class dn extends Et{constructor(e,t){super("contains",e,t)}eval(e){const t=this.left.eval(e),n=this.right.eval(e);return Rt(t.some((e=>e.value===n[0].value)))}}class ln extends Et{constructor(e,t){super("in",e,t)}eval(e){const t=this.left.eval(e);return Rt(this.right.eval(e).some((e=>e.value===t[0].value)))}}class un extends Et{constructor(e,t){super(".",e,t)}eval(e){return this.right.eval(this.left.eval(e))}toString(){return`${this.left.toString()}.${this.right.toString()}`}}class pn extends Et{constructor(e,t){super("|",e,t)}eval(e){return Ut([...this.left.eval(e),...this.right.eval(e)])}}class mn extends Et{constructor(e,t){super("=",e,t)}eval(e){return Nt(this.left.eval(e),this.right.eval(e))}}class hn extends Et{constructor(e,t){super("!=",e,t)}eval(e){return Lt(Nt(this.left.eval(e),this.right.eval(e)))}}class fn extends Et{constructor(e,t){super("~",e,t)}eval(e){return _t(this.left.eval(e),this.right.eval(e))}}class yn extends Et{constructor(e,t){super("!~",e,t)}eval(e){return Lt(_t(this.left.eval(e),this.right.eval(e)))}}class gn extends Et{constructor(e,t){super("is",e,t)}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const n=this.right.name;return Rt(Wt(t[0],n))}}class xn extends Et{constructor(e,t){super("and",e,t)}eval(e){var t,n,i,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===(n=a[0])||void 0===n?void 0:n.value)?Rt(!0):!1===(null===(i=r[0])||void 0===i?void 0:i.value)||!1===(null===(o=a[0])||void 0===o?void 0:o.value)?Rt(!1):[]}}class vn extends Et{constructor(e,t){super("or",e,t)}eval(e){const t=this.left.eval(e);if(kt(t))return t;const n=this.right.eval(e);return kt(n)?n:[]}}class Sn extends Et{constructor(e,t){super("xor",e,t)}eval(e){const t=this.left.eval(e),n=this.right.eval(e);if(0===t.length&&0===n.length)return[];const i=0===t.length?null:t[0].value,o=0===n.length?null:n[0].value;return!0===i&&!0!==o||!0!==i&&!0===o?Rt(!0):!0===i&&!0===o||!1===i&&!1===o?Rt(!1):[]}}class Tn{constructor(e,t){this.name=e,this.args=t}eval(e){const t=Gt[this.name];if(!t)throw new Error("Unrecognized function: "+this.name);return t(e,...this.args)}toString(){return`${this.name}(${this.args.map((e=>e.toString())).join(", ")})`}}class wn{constructor(e,t){this.left=e,this.expr=t}eval(e){const t=this.expr.eval(e);if(1!==t.length)return[];const n=t[0].value;if("number"!=typeof n)throw new Error("Invalid indexer expression: should return integer}");const i=this.left.eval(e);return n in i?[i[n]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}}const En=["true","false"],bn=["!=","!~","<=",">=","{}","->"];function Pn(e){return new Ct(e,En,bn).tokenize()}const Dn={parse(e){var t;const n=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)` got `"+(null===(t=e.peek())||void 0===t?void 0:t.value)+"`");return n}},Cn={parse(e,t){const n=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new wn(t,n)},precedence:2},An={parse(e,t){if(!(t instanceof nn))throw new Error("Unexpected parentheses");const n=[];for(;!e.match(")");)n.push(e.consumeAndParse()),e.match(",");return new Tn(t.name,n)},precedence:0};function Rn(e){const t=e.split(" "),n=parseFloat(t[0]);let i=t[1];return i=i&&i.startsWith("'")&&i.endsWith("'")?i.substring(1,i.length-1):"{"+i+"}",{value:n,unit:i}}function On(){return(new bt).registerPrefix("String",{parse:(t,n)=>new tn({type:e.PropertyType.string,value:n.value})}).registerPrefix("DateTime",{parse:(t,n)=>new tn({type:e.PropertyType.dateTime,value:At(n.value)})}).registerPrefix("Quantity",{parse:(t,n)=>new tn({type:e.PropertyType.Quantity,value:Rn(n.value)})}).registerPrefix("Number",{parse:(t,n)=>new tn({type:e.PropertyType.decimal,value:parseFloat(n.value)})}).registerPrefix("true",{parse:()=>new tn({type:e.PropertyType.boolean,value:!0})}).registerPrefix("false",{parse:()=>new tn({type:e.PropertyType.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new nn(t.value)}).registerPrefix("{}",{parse:()=>new on}).registerPrefix("(",Dn).registerInfix("[",Cn).registerInfix("(",An).prefix("+",3,((e,t)=>new rn("+",t,(e=>e)))).prefix("-",3,((e,t)=>new sn("-",t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,n)=>new un(e,n))).infixLeft("/",4,((e,t,n)=>new sn("/",e,n,((e,t)=>e/t)))).infixLeft("*",4,((e,t,n)=>new sn("*",e,n,((e,t)=>e*t)))).infixLeft("+",5,((e,t,n)=>new sn("+",e,n,((e,t)=>e+t)))).infixLeft("-",5,((e,t,n)=>new sn("-",e,n,((e,t)=>e-t)))).infixLeft("|",7,((e,t,n)=>new pn(e,n))).infixLeft("=",9,((e,t,n)=>new mn(e,n))).infixLeft("!=",9,((e,t,n)=>new hn(e,n))).infixLeft("~",9,((e,t,n)=>new fn(e,n))).infixLeft("!~",9,((e,t,n)=>new yn(e,n))).infixLeft("<",8,((e,t,n)=>new sn("<",e,n,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,n)=>new sn("<=",e,n,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,n)=>new sn(">",e,n,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,n)=>new sn(">=",e,n,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,n)=>new cn(e,n))).infixLeft("and",6,((e,t,n)=>new xn(e,n))).infixLeft("as",6,((e,t,n)=>new an(e,n))).infixLeft("contains",6,((e,t,n)=>new dn(e,n))).infixLeft("div",6,((e,t,n)=>new sn("div",e,n,((e,t)=>e/t|0)))).infixLeft("in",6,((e,t,n)=>new ln(e,n))).infixLeft("is",6,((e,t,n)=>new gn(e,n))).infixLeft("mod",6,((e,t,n)=>new sn("mod",e,n,((e,t)=>e%t)))).infixLeft("or",6,((e,t,n)=>new vn(e,n))).infixLeft("xor",6,((e,t,n)=>new Sn(e,n)))}const kn=On();function In(e){return new en(e,kn.construct(Pn(e)).consumeAndParse())}function Mn(e,t){const n=Array.isArray(t)?t:[t];for(let e=0;e<n.length;e++){const t=n[e];"object"==typeof t&&"type"in t&&"value"in t||(n[e]=Ot(n[e]))}return Un(e,n).map((e=>e.value))}function Un(e,t){return In(e).eval(t)}class Ln{constructor(e="\r",t="|",n="^",i="~",o="\\",r="&"){this.segmentSeparator=e,this.fieldSeparator=t,this.componentSeparator=n,this.repetitionSeparator=i,this.escapeCharacter=o,this.subcomponentSeparator=r}getMsh2(){return this.fieldSeparator+this.componentSeparator+this.repetitionSeparator+this.escapeCharacter+this.subcomponentSeparator}}class Nn{constructor(e,t=new Ln){this.context=t,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(this.context.segmentSeparator)}buildAck(){var e,t,n,i,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===(n=null==s?void 0:s.get(4))||void 0===n?void 0:n.toString())||"",u=(null===(i=null==s?void 0:s.get(5))||void 0===i?void 0:i.toString())||"",p=(null===(o=null==s?void 0:s.get(9))||void 0===o?void 0:o.toString())||"",m=(null===(r=null==s?void 0:s.get(12))||void 0===r?void 0:r.toString())||"2.5.1";return new Nn([new jn(["MSH",this.context.getMsh2(),l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",m],this.context),new jn(["MSA","AA",p,"OK"],this.context)])}static parse(e){if(!e.startsWith("MSH")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}const t=new Ln("\r",e.charAt(3),e.charAt(4),e.charAt(5),e.charAt(6),e.charAt(7));return new Nn(e.split(/[\r\n]+/).map((e=>jn.parse(e,t))),t)}}class jn{constructor(e,t=new Ln){this.context=t,I(e)?this.fields=e.map((e=>_n.parse(e))):this.fields=e,this.name=this.fields[0].components[0][0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join(this.context.fieldSeparator)}static parse(e,t=new Ln){return new jn(e.split(t.fieldSeparator).map((e=>_n.parse(e,t))),t)}}class _n{constructor(e,t=new Ln){this.context=t,this.components=e}get(e,t,n=0){let i=this.components[n][e]||"";return void 0!==t&&(i=i.split(this.context.subcomponentSeparator)[t]||""),i}toString(){return this.components.map((e=>e.join(this.context.componentSeparator))).join(this.context.repetitionSeparator)}static parse(e,t=new Ln){return new _n(e.split(t.repetitionSeparator).map((e=>e.split(t.componentSeparator))),t)}}var Qn;e.Operator=void 0,(Qn=e.Operator||(e.Operator={})).EQUALS="eq",Qn.NOT_EQUALS="ne",Qn.GREATER_THAN="gt",Qn.LESS_THAN="lt",Qn.GREATER_THAN_OR_EQUALS="ge",Qn.LESS_THAN_OR_EQUALS="le",Qn.STARTS_AFTER="sa",Qn.ENDS_BEFORE="eb",Qn.APPROXIMATELY="ap",Qn.CONTAINS="contains",Qn.EXACT="exact",Qn.TEXT="text",Qn.NOT="not",Qn.ABOVE="above",Qn.BELOW="below",Qn.IN="in",Qn.NOT_IN="not-in",Qn.OF_TYPE="of-type",Qn.MISSING="missing";const Bn=[e.Operator.CONTAINS,e.Operator.EXACT,e.Operator.TEXT,e.Operator.NOT,e.Operator.ABOVE,e.Operator.BELOW,e.Operator.IN,e.Operator.NOT_IN,e.Operator.OF_TYPE,e.Operator.MISSING],Wn=[e.Operator.NOT_EQUALS,e.Operator.GREATER_THAN,e.Operator.LESS_THAN,e.Operator.GREATER_THAN_OR_EQUALS,e.Operator.LESS_THAN_OR_EQUALS,e.Operator.STARTS_AFTER,e.Operator.ENDS_BEFORE,e.Operator.APPROXIMATELY];var qn;function $n(t,n){var i,o;let r=null===(o=null===(i=de.types[t])||void 0===i?void 0:i.searchParamsDetails)||void 0===o?void 0:o[n.code];return r||(r=function(t,n){var i,o,r,a,s,c,d;if("_lastUpdated"===n.code)return{columnName:"lastUpdated",type:e.SearchParameterType.DATETIME};const l=n.code,u=function(e){return e.split("-").reduce(((e,t,n)=>e+(n?N(t):t)),"")}(l),p=null===(i=Hn(t,n.expression))||void 0===i?void 0:i.split(".");if(!p)return{columnName:u,type:e.SearchParameterType.TEXT};const m=Fn(n);let h,f,y=t,g=!1;for(let e=1;e<p.length;e++){const i=p[e];if(h=null!==(a=null===(r=null===(o=de.types[y])||void 0===o?void 0:o.properties)||void 0===r?void 0:r[i])&&void 0!==a?a:null===(c=null===(s=de.types[y])||void 0===s?void 0:s.properties)||void 0===c?void 0:c[i+"[x]"],!h)throw new Error(`Element definition not found for ${t} ${n.code}`);if("*"===h.max&&(g=!0),f=null===(d=h.type)||void 0===d?void 0:d[0].code,!f)return{columnName:u,type:m,array:g};e<p.length-1&&("Element"===f||"BackboneElement"===f?y+=N(i):y=f)}const x=Fn(n,f),v={columnName:u,type:x,elementDefinition:h,array:g};return function(e,t,n){const i=de.types[e];i.searchParamsDetails||(i.searchParamsDetails={});i.searchParamsDetails[t]=n}(t,l,v),v}(t,n)),r}function Fn(t,n){let i=e.SearchParameterType.TEXT;switch(t.type){case"date":i=n===e.PropertyType.dateTime||n===e.PropertyType.instant?e.SearchParameterType.DATETIME:e.SearchParameterType.DATE;break;case"number":i=e.SearchParameterType.NUMBER;break;case"quantity":i=e.SearchParameterType.QUANTITY;break;case"reference":i=e.SearchParameterType.REFERENCE;break;case"token":"boolean"===n&&(i=e.SearchParameterType.BOOLEAN)}return i}function Hn(e,t){const n=t.split(" | ");for(const t of n){if((i=t).includes(" as Period")||i.includes(" as SampledDate"))continue;const n=zn(t);if(n.startsWith(e+"."))return n}var i}function zn(e){let t=e.trim();t.startsWith("(")&&t.endsWith(")")&&(t=t.substring(1,t.length-1)),t.includes("[0]")&&(t=t.replaceAll("[0]",""));const n=[" != "," as ",".as(",".exists(",".where("];for(const e of n)t.includes(e)&&(t=t.substring(0,t.indexOf(e)));return t}function Vn(t,n,i){var o,r;const a=null===(r=null===(o=de.types[n.resourceType])||void 0===o?void 0:o.searchParams)||void 0===r?void 0:r[i.code];switch(null==a?void 0:a.type){case"reference":return function(t,n,i){const o=Mn(i.expression,t),r=Jn(n.operator);if(""===n.value&&0===o.length)return n.operator===e.Operator.EQUALS;const a=o.map((e=>"string"==typeof e?e:e.reference));for(const e of n.value.split(",")){let t=a.includes(e);if(t||"_compartment"!==n.code||(t=a.some((t=>null==t?void 0:t.endsWith("/"+e)))),t)return!r}return r}(t,i,a);case"string":return Gn(t,i,a);case"token":return function(t,n,i){const o=$n(t.resourceType,i);return o.type===e.SearchParameterType.BOOLEAN?function(e,t,n){const i=Mn(n.expression,e),o="true"===t.value,r=i.includes(o);return Jn(t.operator)?!r:r}(t,n,i):Gn(t,n,i)}(t,i,a);case"date":return function(e,t,n){const i=Mn(n.expression,e),o=t.value.split(","),r=Jn(t.operator);for(const e of i)for(const n of o){if(Yn(e,t.operator,n))return!r}return r}(t,i,a)}return!1}function Gn(e,t,n){const i=Mn(n.expression,e),o=t.value.split(","),r=Jn(t.operator);for(const e of i)for(const n of o){if(Xn(e,t.operator,n))return!r}return r}function Xn(e,t,n){let i="";return e&&("string"==typeof e?i=e:"object"==typeof e&&(i=JSON.stringify(e))),i.toLowerCase().includes(n.toLowerCase())}function Yn(t,n,i){switch(n){case e.Operator.STARTS_AFTER:case e.Operator.GREATER_THAN:return t>i;case e.Operator.GREATER_THAN_OR_EQUALS:return t>=i;case e.Operator.ENDS_BEFORE:case e.Operator.LESS_THAN:return t<i;case e.Operator.LESS_THAN_OR_EQUALS:return t<=i;case e.Operator.EQUALS:case e.Operator.NOT_EQUALS:return t===i}return!1}function Jn(t){return t===e.Operator.NOT_EQUALS||t===e.Operator.NOT}e.SearchParameterType=void 0,(qn=e.SearchParameterType||(e.SearchParameterType={})).BOOLEAN="BOOLEAN",qn.NUMBER="NUMBER",qn.QUANTITY="QUANTITY",qn.TEXT="TEXT",qn.REFERENCE="REFERENCE",qn.DATE="DATE",qn.DATETIME="DATETIME",qn.PERIOD="PERIOD";const Zn="ok",Kn="created",ei="gone",ti="not-modified",ni="not-found",ii="unauthorized",oi="forbidden",ri="too-many-requests",ai={resourceType:"OperationOutcome",id:Zn,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},si={resourceType:"OperationOutcome",id:Kn,issue:[{severity:"information",code:"informational",details:{text:"Created"}}]},ci={resourceType:"OperationOutcome",id:ti,issue:[{severity:"information",code:"informational",details:{text:"Not Modified"}}]},di={resourceType:"OperationOutcome",id:ni,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},li={resourceType:"OperationOutcome",id:ii,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},ui={resourceType:"OperationOutcome",id:oi,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]},pi={resourceType:"OperationOutcome",id:ei,issue:[{severity:"error",code:"deleted",details:{text:"Gone"}}]},mi={resourceType:"OperationOutcome",id:ri,issue:[{severity:"error",code:"throttled",details:{text:"Too Many Requests"}}]};function hi(e){return e.id===Zn||e.id===Kn||e.id===ti}class fi extends Error{constructor(e){var t,n;super(null===(n=null===(t=null==e?void 0:e.issue)||void 0===t?void 0:t[0].details)||void 0===n?void 0:n.text),this.outcome=e}}e.AndAtom=xn,e.ArithemticOperatorAtom=sn,e.AsAtom=an,e.ConcatAtom=cn,e.ContainsAtom=dn,e.DEFAULT_SEARCH_COUNT=20,e.DotAtom=un,e.EmptySetAtom=on,e.EqualsAtom=mn,e.EquivalentAtom=fn,e.FHIRPATH_KEYWORDS=En,e.FHIRPATH_OPERATORS=bn,e.FhirPathAtom=en,e.FunctionAtom=Tn,e.Hl7Context=Ln,e.Hl7Field=_n,e.Hl7Message=Nn,e.Hl7Segment=jn,e.InAtom=ln,e.IndexerAtom=wn,e.IsAtom=gn,e.LRUCache=c,e.LiteralAtom=tn,e.MEDPLUM_VERSION="1.0.5-53328b63",e.MedplumClient=class extends J{constructor(e){var t,o;if(super(),le.add(this),ue.set(this,void 0),pe.set(this,void 0),me.set(this,void 0),he.set(this,void 0),fe.set(this,void 0),ye.set(this,void 0),ge.set(this,void 0),xe.set(this,void 0),ve.set(this,void 0),Se.set(this,void 0),Te.set(this,void 0),we.set(this,void 0),Ee.set(this,void 0),be.set(this,void 0),Pe.set(this,void 0),De.set(this,void 0),Ce.set(this,void 0),Ae.set(this,void 0),(null==e?void 0:e.baseUrl)&&!e.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");i(this,ue,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),i(this,pe,null==e?void 0:e.createPdf,"f"),i(this,me,new te,"f"),i(this,he,new c(null!==(t=null==e?void 0:e.resourceCacheSize)&&void 0!==t?t:1e3),"f"),i(this,fe,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:6e4,"f"),i(this,ye,function(e){if(!e)return e;return e.endsWith("/")?e:e+"/"}(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),i(this,Te,(null==e?void 0:e.clientId)||"","f"),i(this,ge,(null==e?void 0:e.authorizeUrl)||n(this,ye,"f")+"oauth2/authorize","f"),i(this,xe,(null==e?void 0:e.tokenUrl)||n(this,ye,"f")+"oauth2/token","f"),i(this,ve,(null==e?void 0:e.logoutUrl)||n(this,ye,"f")+"oauth2/logout","f"),i(this,Se,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(i(this,Ee,r.accessToken,"f"),i(this,be,r.refreshToken,"f"),n(this,le,"m",Oe).call(this).catch(console.log)),n(this,le,"m",qe).call(this)}getBaseUrl(){return n(this,ye,"f")}clear(){n(this,me,"f").clear(),n(this,he,"f").clear(),i(this,Ee,void 0,"f"),i(this,be,void 0,"f"),i(this,Ce,void 0,"f"),i(this,Ae,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),n(this,he,"f").delete(e)}invalidateSearches(e){const t="fhir/R4/"+e;for(const e of n(this,he,"f").keys())(e.endsWith(t)||e.includes(t+"?"))&&n(this,he,"f").delete(e)}get(e,t={}){e=e.toString();const i=n(this,le,"m",ke).call(this,e,t);if(i)return i.value;const o=new ee(n(this,le,"m",Me).call(this,"GET",e,t));return n(this,le,"m",Ie).call(this,e,o),o}post(e,t,i,o={}){return e=e.toString(),t&&n(this,le,"m",Ne).call(this,o,t),i&&n(this,le,"m",Le).call(this,o,i),this.invalidateUrl(e),n(this,le,"m",Me).call(this,"POST",e,o)}put(e,t,i,o={}){return e=e.toString(),t&&n(this,le,"m",Ne).call(this,o,t),i&&n(this,le,"m",Le).call(this,o,i),this.invalidateUrl(e),n(this,le,"m",Me).call(this,"PUT",e,o)}patch(e,t,i={}){return e=e.toString(),n(this,le,"m",Ne).call(this,i,t),n(this,le,"m",Le).call(this,i,"application/json-patch+json"),this.invalidateUrl(e),n(this,le,"m",Me).call(this,"PATCH",e,i)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),n(this,le,"m",Me).call(this,"DELETE",e,t)}startNewUser(e){return t(this,void 0,void 0,(function*(){return yield this.startPkce(),this.post("auth/newuser",Object.assign(Object.assign({},e),{codeChallengeMethod:"S256",codeChallenge:sessionStorage.getItem("codeChallenge")}))}))}startNewProject(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newproject",e)}))}startNewPatient(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newpatient",e)}))}startLogin(e){var i;return t(this,void 0,void 0,(function*(){const{codeChallenge:t,codeChallengeMethod:o}=this.getCodeChallenge(e);return this.post("auth/login",Object.assign(Object.assign({},e),{clientId:null!==(i=e.clientId)&&void 0!==i?i:n(this,Te,"f"),scope:e.scope,codeChallengeMethod:o,codeChallenge:t}))}))}startGoogleLogin(e){var i;return t(this,void 0,void 0,(function*(){const{codeChallenge:t,codeChallengeMethod:o}=this.getCodeChallenge(e);return this.post("auth/google",Object.assign(Object.assign({},e),{clientId:null!==(i=e.clientId)&&void 0!==i?i:n(this,Te,"f"),scope:e.scope,codeChallengeMethod:o,codeChallenge:t}))}))}getCodeChallenge(e){if(e.codeChallenge)return{codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod};const t=sessionStorage.getItem("codeChallenge");return t?{codeChallenge:t,codeChallengeMethod:"S256"}:{}}signOut(){this.clear()}signInWithRedirect(){return t(this,void 0,void 0,(function*(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void(yield n(this,le,"m",_e).call(this))}))}signOutWithRedirect(){window.location.assign(n(this,ve,"f"))}fhirUrl(...e){return new URL(n(this,ye,"f")+"fhir/R4/"+e.join("/"))}fhirSearchUrl(e,t){const n=this.fhirUrl(e);return t&&(n.search=t.toString()),n}search(e,t,n={}){return this.get(this.fhirSearchUrl(e,t),n)}searchOne(e,t,i={}){const o=this.fhirSearchUrl(e,t);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=n(this,le,"m",ke).call(this,r,i);if(a)return a.value;const s=new ee(this.search(e,o.searchParams,i).then((e=>{var t,n;return null===(n=null===(t=e.entry)||void 0===t?void 0:t[0])||void 0===n?void 0:n.resource})));return n(this,le,"m",Ie).call(this,r,s),s}searchResources(e,t,i={}){const o=this.fhirSearchUrl(e,t).toString()+"-searchResources",r=n(this,le,"m",ke).call(this,o,i);if(r)return r.value;const a=new ee(this.search(e,t,i).then((e=>{var t,n;return null!==(n=null===(t=e.entry)||void 0===t?void 0:t.map((e=>e.resource)))&&void 0!==n?n:[]})));return n(this,le,"m",Ie).call(this,o,a),a}searchValueSet(e,t,n={}){const i=this.fhirUrl("ValueSet","$expand");return i.searchParams.set("url",e),i.searchParams.set("filter",t),this.get(i.toString(),n)}getCached(e,t){var i;const o=null===(i=n(this,he,"f").get(this.fhirUrl(e,t).toString()))||void 0===i?void 0:i.value;return o&&o.isOk()?o.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[n,i]=t.split("/");return n&&i?this.getCached(n,i):void 0}readResource(e,t,n={}){return this.get(this.fhirUrl(e,t),n)}readReference(e,t={}){const n=null==e?void 0:e.reference;if(!n)return new ee(Promise.reject(new Error("Missing reference")));const[i,o]=n.split("/");return i&&o?this.readResource(i,o,t):new ee(Promise.reject(new Error("Invalid reference")))}getSchema(){return de}requestSchema(e){return t(this,void 0,void 0,(function*(){if(e in de.types)return de;const t=`{\n StructureDefinitionList(name: "${e}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${e}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),n=yield this.graphql(t);for(const e of n.data.StructureDefinitionList)re(e);for(const e of n.data.SearchParameterList)ae(e);return de}))}readHistory(e,t,n={}){return this.get(this.fhirUrl(e,t,"_history"),n)}readVersion(e,t,n,i={}){return this.get(this.fhirUrl(e,t,"_history",n),i)}readPatientEverything(e,t={}){return this.get(this.fhirUrl("Patient",e,"$everything"),t)}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}createResourceIfNoneExist(e,n){var i;return t(this,void 0,void 0,(function*(){return null!==(i=yield this.searchOne(e.resourceType,n))&&void 0!==i?i:this.createResource(e)}))}createBinary(e,t,n,i){const o=this.fhirUrl("Binary");return t&&o.searchParams.set("_filename",t),i?this.uploadwithProgress(o,e,n,i):this.post(o,e,n)}uploadwithProgress(e,t,i,o){return new Promise(((r,a)=>{const s=new XMLHttpRequest;s.responseType="json",s.onabort=()=>a(new Error("Request aborted")),s.onerror=()=>a(new Error("Request error")),o&&(s.upload.onprogress=e=>o(e),s.upload.onload=e=>o(e)),s.onload=()=>{s.status>=200&&s.status<300?r(s.response):a(new Error(s.statusText))},s.open("POST",e),s.withCredentials=!0,s.setRequestHeader("Authorization","Bearer "+n(this,Ee,"f")),s.setRequestHeader("Cache-Control","no-cache, no-store, max-age=0"),s.setRequestHeader("Content-Type",i),s.setRequestHeader("X-Medplum","extended"),s.send(t)}))}createPdf(e,i,o,r){return t(this,void 0,void 0,(function*(){if(!n(this,pe,"f"))throw new Error("PDF creation not enabled");const t=yield n(this,pe,"f").call(this,e,o,r);return this.createBinary(t,i,"application/pdf")}))}createComment(e,t){const n=this.getProfile();let i,o;return"Encounter"===e.resourceType&&(i=S(e),o=e.subject),"ServiceRequest"===e.resourceType&&(i=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=S(e)),this.createResource({resourceType:"Communication",basedOn:[S(e)],encounter:i,subject:o,sender:n?S(n):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}updateResource(e){return t(this,void 0,void 0,(function*(){if(!e.resourceType)throw new Error("Missing resourceType");if(!e.id)throw new Error("Missing id");this.invalidateSearches(e.resourceType);const t=yield this.put(this.fhirUrl(e.resourceType,e.id),e);return null!=t?t:e}))}patchResource(e,t,n){return this.invalidateSearches(e),this.patch(this.fhirUrl(e,t),n)}deleteResource(e,t){return this.invalidateSearches(e),this.delete(this.fhirUrl(e,t))}validateResource(e){return this.post(this.fhirUrl(e.resourceType,"$validate"),e)}executeBatch(e){return this.post("fhir/R4",e)}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t,n,i){return this.post(this.fhirUrl("$graphql"),{query:e,operationName:t,variables:n},"application/json",i)}readResourceGraph(e,t,n){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${n}`)}getActiveLogin(){return n(this,me,"f").getObject("activeLogin")}setActiveLogin(e){return t(this,void 0,void 0,(function*(){i(this,Ee,e.accessToken,"f"),i(this,be,e.refreshToken,"f"),i(this,Ce,void 0,"f"),i(this,Ae,void 0,"f"),n(this,me,"f").setObject("activeLogin",e),n(this,le,"m",Re).call(this,e),n(this,he,"f").clear(),i(this,Pe,void 0,"f"),yield n(this,le,"m",Oe).call(this)}))}getAccessToken(){return n(this,Ee,"f")}setAccessToken(e){i(this,Ee,e,"f"),i(this,be,void 0,"f"),i(this,Ce,void 0,"f"),i(this,Ae,void 0,"f")}getLogins(){var e;return null!==(e=n(this,me,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!n(this,De,"f")}getProfile(){return n(this,Ce,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return n(this,De,"f")&&(yield n(this,De,"f")),this.getProfile()}))}getUserConfiguration(){return n(this,Ae,"f")}download(e,i={}){return t(this,void 0,void 0,(function*(){n(this,Pe,"f")&&(yield n(this,Pe,"f")),n(this,le,"m",Ue).call(this,i);return(yield n(this,ue,"f").call(this,e.toString(),i)).blob()}))}startPkce(){return t(this,void 0,void 0,(function*(){const e=q();sessionStorage.setItem("pkceState",e);const n=q();sessionStorage.setItem("codeVerifier",n);const i=L(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");sessionStorage.setItem("codeChallenge",i)}))}processCode(e){const t=new URLSearchParams;t.set("grant_type","authorization_code"),t.set("client_id",n(this,Te,"f")),t.set("code",e),t.set("redirect_uri",$e());const i=sessionStorage.getItem("codeVerifier");return i&&t.set("code_verifier",i),n(this,le,"m",Be).call(this,t)}startClientLogin(e,o){return t(this,void 0,void 0,(function*(){i(this,Te,e,"f"),i(this,we,o,"f");const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",e),t.set("client_secret",o),n(this,le,"m",Be).call(this,t)}))}},e.NotEqualsAtom=hn,e.NotEquivalentAtom=yn,e.OperationOutcomeError=fi,e.OrAtom=vn,e.ReadablePromise=ee,e.SymbolAtom=nn,e.UnaryOperatorAtom=rn,e.UnionAtom=pn,e.XorAtom=Sn,e.allOk=ai,e.arrayBufferToBase64=L,e.arrayBufferToHex=U,e.assertOk=function(e,t){if(!hi(e)||void 0===t)throw new fi(e)},e.badRequest=function(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}},e.booleanToTypedValue=Rt,e.buildTypeName=se,e.calculateAge=P,e.calculateAgeString=function(e,t){const{years:n,months:i,days:o}=P(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":i>=1?i.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"},e.capitalize=N,e.createReference=S,e.createSchema=function(){return{types:{}}},e.created=si,e.deepClone=function(e){return JSON.parse(JSON.stringify(e))},e.deepEquals=O,e.evalFhirPath=Mn,e.evalFhirPathTyped=Un,e.fhirPathArrayEquals=Nt,e.fhirPathArrayEquivalent=_t,e.fhirPathEquals=jt,e.fhirPathEquivalent=Qt,e.fhirPathIs=Wt,e.fhirPathNot=Lt,e.findObservationInterval=function(e,t,n,i){var o;return null===(o=e.qualifiedInterval)||void 0===o?void 0:o.find((o=>{var r;return j(o,t)&&function(e,t,n){return!!e.range&&_(t,e.range,n)}(o,n,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===i||o.category===i)}))},e.findObservationReferenceRange=function(e,t,n){var i;return null===(i=e.qualifiedInterval)||void 0===i?void 0:i.find((e=>j(e,t)&&n.includes(e.condition)))},e.forbidden=ui,e.formatAddress=function(e,t){const n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),n.push(t.join(", "))}return e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&n.push("["+e.use+"]"),n.join((null==t?void 0:t.lineSeparator)||", ").trim()},e.formatCodeableConcept=g,e.formatCoding=x,e.formatDate=function(e,t,n){if(!e)return"";const i=new Date(e);return l(i)?(i.setUTCHours(0,0,0,0),i.toLocaleDateString(t,Object.assign({timeZone:"UTC"},n))):""},e.formatDateTime=p,e.formatFamilyName=function(e){return e.family||""},e.formatGivenName=function(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()},e.formatHumanName=d,e.formatObservationValue=function e(t){return t?"component"in t?t.component.map((t=>e(t))).join(" / "):(null==t?void 0:t.valueQuantity)?y(t.valueQuantity):t.valueCodeableConcept?g(t.valueCodeableConcept):t.valueString?t.valueString:"":""},e.formatPeriod=function(e,t,n){return e&&(e.start||e.end)?p(e.start,t,n)+" - "+p(e.end,t,n):""},e.formatQuantity=y,e.formatRange=function(e,t,n=!1){var i,o,r,a;if(n&&void 0===t)throw new Error("Precision must be specified for exclusive ranges");const s=(null==e?void 0:e.low)&&Object.assign({},e.low),c=(null==e?void 0:e.high)&&Object.assign({},e.high);return!e||void 0===(null==s?void 0:s.value)&&void 0===(null==c?void 0:c.value)?"":void 0!==(null===(i=e.low)||void 0===i?void 0:i.value)&&void 0===(null===(o=e.high)||void 0===o?void 0:o.value)?n&&void 0!==t?(e.low.value=function(e,t,n=1){return(v(e,t)-n)*Math.pow(10,-t)}(e.low.value,t),`> ${y(e.low,t)}`):`>= ${y(e.low,t)}`:void 0===(null===(r=e.low)||void 0===r?void 0:r.value)&&void 0!==(null===(a=e.high)||void 0===a?void 0:a.value)?n&&void 0!==t?(e.high.value=function(e,t,n=1){return(v(e,t)+n)*Math.pow(10,-t)}(e.high.value,t),`< ${y(e.high,t)}`):`<= ${y(e.high,t)}`:((null==s?void 0:s.unit)===(null==c?void 0:c.unit)&&(null==s||delete s.unit),`${y(s,t)} - ${y(c,t)}`)},e.formatSearchQuery=function(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=Bn.includes(e.operator)?":"+e.operator:"",n=Wn.includes(e.operator)?e.operator:"";return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))},e.formatTime=u,e.formatTiming=function(e){var t;if(!e)return"";const n=[];if(null===(t=e.repeat)||void 0===t?void 0:t.periodUnit){const t=e.repeat.frequency||1,i=e.repeat.period||1,o=e.repeat.periodUnit;1===t&&1===i?n.push(m[o]):(1===t?n.push("once"):n.push(t+" times"),1===i?n.push("per "+h[o]):n.push("per "+i+" "+f[o])),e.repeat.dayOfWeek&&n.push("on "+e.repeat.dayOfWeek.map(N).join(", ")),e.repeat.timeOfDay&&n.push("at "+e.repeat.timeOfDay.map((e=>u(e))).join(", "))}return e.event&&n.push(e.event.map((e=>p(e))).join(", ")),N(n.join(" ").trim())},e.getCodeBySystem=function(e,t){var n,i;return null===(i=null===(n=null==e?void 0:e.coding)||void 0===n?void 0:n.find((e=>e.system===t)))||void 0===i?void 0:i.code},e.getDateProperty=function(e){return e?new Date(e):void 0},e.getDisplayString=E,e.getElementDefinition=ce,e.getExpressionForResourceType=Hn,e.getExtensionValue=function(e,...t){var n;let i=e;for(let e=0;e<t.length&&i;e++)i=null===(n=null==i?void 0:i.extension)||void 0===n?void 0:n.find((n=>n.url===t[e]));return null==i?void 0:i.valueString},e.getIdentifier=function(e,t){const n=e.identifier;if(!n)return;const i=Array.isArray(n)?n:[n];for(const e of i)if(e.system===t)return e.value},e.getImageSrc=function(e){if(!("photo"in e))return;const t=e.photo;if(t){if(!Array.isArray(t))return b(t);for(const e of t){const t=b(e);if(t)return t}}},e.getPropertyDisplayName=function(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(N).join(" ").replace("_"," ").replace(/\s+/g," ")},e.getQuestionnaireAnswers=function(e){const t={};return D(e.item,t),t},e.getReferenceString=T,e.getSearchParameterDetails=$n,e.getStatus=function(e){return e.id===Zn?200:e.id===Kn?201:e.id===ti?304:e.id===ii?401:e.id===oi?403:e.id===ni?404:e.id===ei?410:e.id===ri?429:400},e.getTypedPropertyValue=It,e.globalSchema=de,e.gone=pi,e.indexSearchParameter=ae,e.indexSearchParameterBundle=function(e){for(const t of e.entry){const e=t.resource;"SearchParameter"===e.resourceType&&ae(e)}},e.indexStructureDefinition=re,e.indexStructureDefinitionBundle=function(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&re(e)}},e.initFhirPathParserBuilder=On,e.isEmpty=R,e.isGone=function(e){return e.id===ei},e.isLowerCase=function(e){return e===e.toLowerCase()&&e!==e.toUpperCase()},e.isNotFound=function(e){return e.id===ni},e.isObject=k,e.isOk=hi,e.isPeriod=qt,e.isProfileResource=w,e.isQuantity=$t,e.isQuantityEquivalent=Ft,e.isStringArray=I,e.isUUID=function(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)},e.isValidDate=l,e.matchesRange=_,e.matchesSearchRequest=function(e,t){if(t.resourceType!==e.resourceType)return!1;if(t.filters)for(const n of t.filters)if(!Vn(e,t,n))return!1;return!0},e.normalizeErrorString=function(e){var t,n,i,o;if(!e)return"Unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message;if("object"==typeof e&&"resourceType"in e){return null!==(o=null===(i=null===(n=null===(t=e.issue)||void 0===t?void 0:t[0])||void 0===n?void 0:n.details)||void 0===i?void 0:i.text)&&void 0!==o?o:"Unknown error"}return JSON.stringify(e)},e.notFound=di,e.notModified=ci,e.parseFhirPath=In,e.parseJWTPayload=K,e.parseSearchDefinition=function(t){const n=new URL(t,"https://example.com/"),i=n.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let o,r,a,s,c,d;return new URLSearchParams(n.search).forEach(((t,n)=>{"_fields"===n?a=t.split(","):"_offset"===n?s=parseInt(t):"_count"===n?c=parseInt(t):"_total"===n?d=t:"_sort"===n?(r=r||[],r.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(t))):(o=o||[],o.push(function(t,n){let i=t,o=e.Operator.EQUALS;for(const e of Bn){const t=i.indexOf(":"+e);-1!==t&&(o=e,i=i.substring(0,t))}for(const e of Wn)n.match(new RegExp("^"+e+"\\d"))&&(o=e,n=n.substring(e.length));return{code:i,operator:o,value:n}}(n,t)))})),{resourceType:i,filters:o,fields:a,offset:s,count:c,total:d,sortRules:r}},e.preciseEquals=function(e,t,n){return W(e,n)===W(t,n)},e.preciseGreaterThan=function(e,t,n){return W(e,n)>W(t,n)},e.preciseGreaterThanOrEquals=B,e.preciseLessThan=function(e,t,n){return W(e,n)<W(t,n)},e.preciseLessThanOrEquals=Q,e.preciseRound=function(e,t){return parseFloat(e.toFixed(t))},e.removeDuplicates=Ut,e.resolveId=function(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]},e.setCodeBySystem=function(e,t,n){var i,o;e.coding||(e.coding=[]);const r=null===(i=e.coding)||void 0===i?void 0:i.find((e=>e.system===t));r?r.code=n:null===(o=e.coding)||void 0===o||o.push({system:t,code:n})},e.stringify=C,e.toJsBoolean=kt,e.toTypedValue=Ot,e.tokenize=Pn,e.tooManyRequests=mi,e.unauthorized=li}));
2
2
  //# sourceMappingURL=index.min.js.map