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