@medplum/core 0.9.30 → 0.9.33

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