@medplum/core 0.9.34 → 0.9.35

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