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