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