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