@medplum/core 1.0.4 → 1.0.6

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.
Files changed (107) hide show
  1. package/README.md +9 -7
  2. package/dist/cjs/client.d.ts +1 -0
  3. package/dist/cjs/fhirlexer/parse.d.ts +18 -2
  4. package/dist/cjs/fhirmapper/parse.d.ts +2 -2
  5. package/dist/cjs/fhirpath/atoms.d.ts +28 -53
  6. package/dist/cjs/fhirpath/parse.d.ts +37 -0
  7. package/dist/cjs/format.d.ts +2 -1
  8. package/dist/cjs/{index.js → index.cjs} +999 -996
  9. package/dist/cjs/index.cjs.map +1 -0
  10. package/dist/cjs/index.min.cjs +1 -0
  11. package/dist/cjs/search.d.ts +2 -1
  12. package/dist/esm/{base-schema.json.js → base-schema.json.mjs} +1 -1
  13. package/dist/esm/{base-schema.json.js.map → base-schema.json.mjs.map} +1 -1
  14. package/dist/esm/{cache.js → cache.mjs} +2 -2
  15. package/dist/esm/cache.mjs.map +1 -0
  16. package/dist/esm/client.d.ts +1 -0
  17. package/dist/esm/{client.js → client.mjs} +264 -268
  18. package/dist/esm/client.mjs.map +1 -0
  19. package/dist/esm/{crypto.js → crypto.mjs} +4 -7
  20. package/dist/esm/crypto.mjs.map +1 -0
  21. package/dist/esm/{eventtarget.js → eventtarget.mjs} +2 -2
  22. package/dist/esm/eventtarget.mjs.map +1 -0
  23. package/dist/esm/fhirlexer/parse.d.ts +18 -2
  24. package/dist/esm/fhirlexer/{parse.js → parse.mjs} +35 -10
  25. package/dist/esm/fhirlexer/parse.mjs.map +1 -0
  26. package/dist/esm/fhirlexer/{tokenize.js → tokenize.mjs} +12 -12
  27. package/dist/esm/fhirlexer/tokenize.mjs.map +1 -0
  28. package/dist/esm/fhirmapper/parse.d.ts +2 -2
  29. package/dist/esm/fhirpath/atoms.d.ts +28 -53
  30. package/dist/esm/fhirpath/{atoms.js → atoms.mjs} +79 -62
  31. package/dist/esm/fhirpath/atoms.mjs.map +1 -0
  32. package/dist/esm/fhirpath/{date.js → date.mjs} +1 -1
  33. package/dist/esm/fhirpath/date.mjs.map +1 -0
  34. package/dist/esm/fhirpath/{functions.js → functions.mjs} +16 -22
  35. package/dist/esm/fhirpath/functions.mjs.map +1 -0
  36. package/dist/esm/fhirpath/parse.d.ts +37 -0
  37. package/dist/esm/fhirpath/{parse.js → parse.mjs} +38 -42
  38. package/dist/esm/fhirpath/parse.mjs.map +1 -0
  39. package/dist/esm/fhirpath/{tokenize.js → tokenize.mjs} +4 -4
  40. package/dist/esm/fhirpath/tokenize.mjs.map +1 -0
  41. package/dist/esm/fhirpath/{utils.js → utils.mjs} +6 -7
  42. package/dist/esm/fhirpath/utils.mjs.map +1 -0
  43. package/dist/esm/format.d.ts +2 -1
  44. package/dist/esm/{format.js → format.mjs} +29 -21
  45. package/dist/esm/format.mjs.map +1 -0
  46. package/dist/esm/{hl7.js → hl7.mjs} +8 -9
  47. package/dist/esm/hl7.mjs.map +1 -0
  48. package/dist/esm/index.min.mjs +1 -0
  49. package/dist/esm/{index.js → index.mjs} +17 -17
  50. package/dist/esm/index.mjs.map +1 -0
  51. package/dist/esm/{jwt.js → jwt.mjs} +1 -1
  52. package/dist/esm/jwt.mjs.map +1 -0
  53. package/dist/esm/{match.js → match.mjs} +12 -13
  54. package/dist/esm/match.mjs.map +1 -0
  55. package/dist/esm/node_modules/tslib/{tslib.es6.js → tslib.es6.mjs} +2 -12
  56. package/dist/esm/node_modules/tslib/tslib.es6.mjs.map +1 -0
  57. package/dist/esm/{outcomes.js → outcomes.mjs} +3 -5
  58. package/dist/esm/outcomes.mjs.map +1 -0
  59. package/dist/esm/{readablepromise.js → readablepromise.mjs} +2 -2
  60. package/dist/esm/readablepromise.mjs.map +1 -0
  61. package/dist/esm/search.d.ts +2 -1
  62. package/dist/esm/{search.js → search.mjs} +1 -1
  63. package/dist/esm/search.mjs.map +1 -0
  64. package/dist/esm/{searchparams.js → searchparams.mjs} +8 -9
  65. package/dist/esm/searchparams.mjs.map +1 -0
  66. package/dist/esm/{storage.js → storage.mjs} +4 -5
  67. package/dist/esm/storage.mjs.map +1 -0
  68. package/dist/esm/{types.js → types.mjs} +6 -9
  69. package/dist/esm/types.mjs.map +1 -0
  70. package/dist/esm/{utils.js → utils.mjs} +15 -26
  71. package/dist/esm/utils.mjs.map +1 -0
  72. package/package.json +5 -5
  73. package/rollup.config.mjs +6 -7
  74. package/dist/cjs/fhirmapper/atoms.d.ts +0 -67
  75. package/dist/cjs/fhirmapper/testall.d.ts +0 -1
  76. package/dist/cjs/index.js.map +0 -1
  77. package/dist/cjs/index.min.js +0 -2
  78. package/dist/cjs/index.min.js.map +0 -1
  79. package/dist/esm/cache.js.map +0 -1
  80. package/dist/esm/client.js.map +0 -1
  81. package/dist/esm/crypto.js.map +0 -1
  82. package/dist/esm/eventtarget.js.map +0 -1
  83. package/dist/esm/fhirlexer/parse.js.map +0 -1
  84. package/dist/esm/fhirlexer/tokenize.js.map +0 -1
  85. package/dist/esm/fhirmapper/atoms.d.ts +0 -67
  86. package/dist/esm/fhirmapper/testall.d.ts +0 -1
  87. package/dist/esm/fhirpath/atoms.js.map +0 -1
  88. package/dist/esm/fhirpath/date.js.map +0 -1
  89. package/dist/esm/fhirpath/functions.js.map +0 -1
  90. package/dist/esm/fhirpath/parse.js.map +0 -1
  91. package/dist/esm/fhirpath/tokenize.js.map +0 -1
  92. package/dist/esm/fhirpath/utils.js.map +0 -1
  93. package/dist/esm/format.js.map +0 -1
  94. package/dist/esm/hl7.js.map +0 -1
  95. package/dist/esm/index.js.map +0 -1
  96. package/dist/esm/index.min.js +0 -2
  97. package/dist/esm/index.min.js.map +0 -1
  98. package/dist/esm/jwt.js.map +0 -1
  99. package/dist/esm/match.js.map +0 -1
  100. package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
  101. package/dist/esm/outcomes.js.map +0 -1
  102. package/dist/esm/readablepromise.js.map +0 -1
  103. package/dist/esm/search.js.map +0 -1
  104. package/dist/esm/searchparams.js.map +0 -1
  105. package/dist/esm/storage.js.map +0 -1
  106. package/dist/esm/types.js.map +0 -1
  107. package/dist/esm/utils.js.map +0 -1
@@ -1,2 +0,0 @@
1
- function e(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}))}function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}var i,o,r,a;class s{constructor(e=10){i.add(this),o.set(this,void 0),r.set(this,void 0),n(this,o,e,"f"),n(this,r,new Map,"f")}clear(){t(this,r,"f").clear()}get(e){const n=t(this,r,"f").get(e);return n&&(t(this,r,"f").delete(e),t(this,r,"f").set(e,n)),n}set(e,n){t(this,r,"f").has(e)?t(this,r,"f").delete(e):t(this,r,"f").size>=t(this,o,"f")&&t(this,r,"f").delete(t(this,i,"m",a).call(this)),t(this,r,"f").set(e,n)}delete(e){t(this,r,"f").delete(e)}keys(){return t(this,r,"f").keys()}}function c(e,t){const n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),n.push(t.join(", "))}return e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&n.push("["+e.use+"]"),n.join((null==t?void 0:t.lineSeparator)||", ").trim()}function d(e,t){const n=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&n.push(...e.prefix),e.given&&n.push(...e.given),e.family&&n.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&n.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&n.push("["+e.use+"]"),n.join(" ").trim()}function l(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()}function u(e){return e.family||""}function m(e){return e instanceof Date&&!isNaN(e.getTime())}function p(e,t,n){if(!e)return"";const i=new Date(e);return m(i)?(i.setUTCHours(0,0,0,0),i.toLocaleDateString(t,Object.assign({timeZone:"UTC"},n))):""}function h(e,t,n){if(!e)return"";const i=new Date("2000-01-01T"+e+"Z");return m(i)?i.toLocaleTimeString(t,n):""}function f(e,t,n){if(!e)return"";const i=new Date(e);return m(i)?i.toLocaleString(t,n):""}function y(e,t,n){return e&&(e.start||e.end)?f(e.start,t,n)+" - "+f(e.end,t,n):""}o=new WeakMap,r=new WeakMap,i=new WeakSet,a=function(){return t(this,r,"f").keys().next().value};const g={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},x={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},v={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function w(e){var t;if(!e)return"";const n=[];if(null===(t=e.repeat)||void 0===t?void 0:t.periodUnit){const t=e.repeat.frequency||1,i=e.repeat.period||1,o=e.repeat.periodUnit;1===t&&1===i?n.push(g[o]):(1===t?n.push("once"):n.push(t+" times"),1===i?n.push("per "+x[o]):n.push("per "+i+" "+v[o])),e.repeat.dayOfWeek&&n.push("on "+e.repeat.dayOfWeek.map(Z).join(", ")),e.repeat.timeOfDay&&n.push("at "+e.repeat.timeOfDay.map((e=>h(e))).join(", "))}return e.event&&n.push(e.event.map((e=>f(e))).join(", ")),Z(n.join(" ").trim())}function E(e,t,n=!1){var i,o,r,a;if(n&&void 0===t)throw new Error("Precision must be specified for exclusive ranges");const s=(null==e?void 0:e.low)&&Object.assign({},e.low),c=(null==e?void 0:e.high)&&Object.assign({},e.high);return!e||void 0===(null==s?void 0:s.value)&&void 0===(null==c?void 0:c.value)?"":void 0!==(null===(i=e.low)||void 0===i?void 0:i.value)&&void 0===(null===(o=e.high)||void 0===o?void 0:o.value)?n&&void 0!==t?(e.low.value=function(e,t,n=1){return(C(e,t)-n)*Math.pow(10,-t)}(e.low.value,t),`> ${S(e.low,t)}`):`>= ${S(e.low,t)}`:void 0===(null===(r=e.low)||void 0===r?void 0:r.value)&&void 0!==(null===(a=e.high)||void 0===a?void 0:a.value)?n&&void 0!==t?(e.high.value=function(e,t,n=1){return(C(e,t)+n)*Math.pow(10,-t)}(e.high.value,t),`< ${S(e.high,t)}`):`<= ${S(e.high,t)}`:((null==s?void 0:s.unit)===(null==c?void 0:c.unit)&&(null==s||delete s.unit),`${S(s,t)} - ${S(c,t)}`)}function S(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),void 0!==e.value&&(void 0!==t?n.push(e.value.toFixed(t)):n.push(e.value)),e.unit&&("%"!==e.unit&&" "!==n[n.length-1]&&n.push(" "),n.push(e.unit)),n.join("").trim()}function b(e){return e?e.text?e.text:e.coding?e.coding.map((e=>T(e))).join(", "):"":""}function T(e){return(null==e?void 0:e.display)||(null==e?void 0:e.code)||""}function D(e){return e?"component"in e?e.component.map((e=>D(e))).join(" / "):(null==e?void 0:e.valueQuantity)?S(e.valueQuantity):e.valueCodeableConcept?b(e.valueCodeableConcept):e.valueString?e.valueString:"":""}function C(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function P(e){const t=A(e),n=M(e);return n===t?{reference:t}:{reference:t,display:n}}function A(e){return e.resourceType+"/"+e.id}function R(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]}function k(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function M(e){var t;if(k(e)){const t=function(e){const t=e.name;if(t&&t.length>0)return d(t[0]);return}(e);if(t)return t}if("Device"===e.resourceType){const t=function(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name;return}(e);if(t)return t}return"Observation"===e.resourceType&&"code"in e&&(null===(t=e.code)||void 0===t?void 0:t.text)?e.code.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:A(e)}function O(e){if(!("photo"in e))return;const t=e.photo;if(t){if(!Array.isArray(t))return I(t);for(const e of t){const t=I(e);if(t)return t}}}function I(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function U(e){return e?new Date(e):void 0}function L(e,t){const n=new Date(e);n.setUTCHours(0,0,0,0);const i=t?new Date(t):new Date;i.setUTCHours(0,0,0,0);const o=n.getUTCFullYear(),r=n.getUTCMonth(),a=n.getUTCDate(),s=i.getUTCFullYear(),c=i.getUTCMonth(),d=i.getUTCDate();let l=s-o;(c<r||c===r&&d<a)&&l--;let u=12*s+c-(12*o+r);d<a&&u--;return{years:l,months:u,days:Math.floor((i.getTime()-n.getTime())/864e5)}}function j(e,t){const{years:n,months:i,days:o}=L(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":i>=1?i.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"}function N(e){const t={};return _(e.item,t),t}function _(e,t){if(e)for(const n of e)n.linkId&&n.answer&&n.answer.length>0&&(t[n.linkId]=n.answer[0]),_(n.item,t)}function Q(e,t){const n=e.identifier;if(!n)return;const i=Array.isArray(n)?n:[n];for(const e of i)if(e.system===t)return e.value}function W(e,...t){var n;let i=e;for(let e=0;e<t.length&&i;e++)i=null===(n=null==i?void 0:i.extension)||void 0===n?void 0:n.find((n=>n.url===t[e]));return null==i?void 0:i.valueString}function B(e,t){return JSON.stringify(e,q,t?2:void 0)}function q(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&$(t)?void 0:t}function $(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function F(e,t,n){return e===t||(!(!$(e)||!$(t))||!$(e)&&!$(t)&&(Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!F(e[n],t[n]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(G(e)&&G(t)?function(e,t,n){const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e))),"meta"===n&&(i.delete("versionId"),i.delete("lastUpdated"),i.delete("author"));for(const n of i){if(!F(e[n],t[n],n))return!1}return!0}(e,t,n):(G(e)||G(t),!1))))}function H(e){return JSON.parse(JSON.stringify(e))}function z(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)}function G(e){return null!==e&&"object"==typeof e}function V(e){return e.every((e=>"string"==typeof e))}const X=[];for(let e=0;e<256;e++)X.push(e.toString(16).padStart(2,"0"));function Y(e){const t=new Uint8Array(e),n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=X[t[e]];return n.join("")}function J(e){const t=new Uint8Array(e),n=[];for(let e=0;e<t.length;e++)n[e]=String.fromCharCode(t[e]);return window.btoa(n.join(""))}function Z(e){return e.charAt(0).toUpperCase()+e.substring(1)}function K(e){return e===e.toLowerCase()&&e!==e.toUpperCase()}function ee(e,t){var n,i;return null===(i=null===(n=null==e?void 0:e.coding)||void 0===n?void 0:n.find((e=>e.system===t)))||void 0===i?void 0:i.code}function te(e,t,n){var i,o;e.coding||(e.coding=[]);const r=null===(i=e.coding)||void 0===i?void 0:i.find((e=>e.system===t));r?r.code=n:null===(o=e.coding)||void 0===o||o.push({system:t,code:n})}function ne(e,t,n,i){var o;return null===(o=e.qualifiedInterval)||void 0===o?void 0:o.find((o=>{var r;return oe(o,t)&&function(e,t,n){return!!e.range&&re(t,e.range,n)}(o,n,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===i||o.category===i)}))}function ie(e,t,n){var i;return null===(i=e.qualifiedInterval)||void 0===i?void 0:i.find((e=>oe(e,t)&&n.includes(e.condition)))}function oe(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||re(L(t.birthDate).years,e.age)}(e,t)}function re(e,t,n){var i,o;return(void 0===(null===(i=t.low)||void 0===i?void 0:i.value)||ue(e,t.low.value,n))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||le(e,t.high.value,n))}function ae(e,t){return parseFloat(e.toFixed(t))}function se(e,t,n){return me(e,n)===me(t,n)}function ce(e,t,n){return me(e,n)<me(t,n)}function de(e,t,n){return me(e,n)>me(t,n)}function le(e,t,n){return me(e,n)<=me(t,n)}function ue(e,t,n){return me(e,n)>=me(t,n)}function me(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function pe(){const e=new Uint32Array(28);return crypto.getRandomValues(e),Y(e.buffer)}var he,fe,ye,ge,xe,ve,we,Ee;class Se{constructor(){he.set(this,void 0),n(this,he,{},"f")}addEventListener(e,n){t(this,he,"f")[e]||(t(this,he,"f")[e]=[]),t(this,he,"f")[e].push(n)}removeEventListeneer(e,n){const i=t(this,he,"f")[e];if(i)for(let e=0;e<i.length;e++)if(i[e]===n)return void i.splice(e,1)}dispatchEvent(e){const n=t(this,he,"f")[e.type];return n&&n.forEach((t=>t.call(this,e))),!e.defaultPrevented}}function be(e){const t=function(e){if("undefined"!=typeof window)return window.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}(e.replace(/-/g,"+").replace(/_/g,"/")),n=Array.from(t).reduce(((e,t)=>`${e}%${("00"+t.charCodeAt(0).toString(16)).slice(-2)}`),""),i=decodeURIComponent(n);return JSON.parse(i)}function Te(e){const[t,n,i]=e.split(".");return be(n)}he=new WeakMap;class De{constructor(e){this[ve]="ReadablePromise",fe.set(this,void 0),ye.set(this,"pending"),ge.set(this,void 0),xe.set(this,void 0),n(this,fe,e.then((e=>(n(this,ye,"success","f"),n(this,ge,e,"f"),e)),(e=>{throw n(this,ye,"error","f"),n(this,xe,e,"f"),e})),"f")}isPending(){return"pending"===t(this,ye,"f")}isOk(){return"success"===t(this,ye,"f")}read(){switch(t(this,ye,"f")){case"pending":throw t(this,fe,"f");case"error":throw t(this,xe,"f");default:return t(this,ge,"f")}}then(e,n){return t(this,fe,"f").then(e,n)}catch(e){return t(this,fe,"f").catch(e)}finally(e){return t(this,fe,"f").finally(e)}}fe=new WeakMap,ye=new WeakMap,ge=new WeakMap,xe=new WeakMap,ve=Symbol.toStringTag;class Ce{constructor(){we.set(this,void 0),n(this,we,"undefined"!=typeof localStorage?localStorage:new Pe,"f")}clear(){t(this,we,"f").clear()}getString(e){return t(this,we,"f").getItem(e)||void 0}setString(e,n){n?t(this,we,"f").setItem(e,n):t(this,we,"f").removeItem(e)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?B(t):void 0)}}we=new WeakMap;class Pe{constructor(){Ee.set(this,void 0),n(this,Ee,new Map,"f")}get length(){return t(this,Ee,"f").size}clear(){t(this,Ee,"f").clear()}getItem(e){var n;return null!==(n=t(this,Ee,"f").get(e))&&void 0!==n?n:null}setItem(e,n){n?t(this,Ee,"f").set(e,n):t(this,Ee,"f").delete(e)}removeItem(e){t(this,Ee,"f").delete(e)}key(e){return Array.from(t(this,Ee,"f").keys())[e]}}Ee=new WeakMap;var Ae,Re={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 ke(){return{types:{}}}function Me(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&Oe(e)}}function Oe(e){var t;if(!e.name)return;const n=null===(t=e.snapshot)||void 0===t?void 0:t.element;n&&(n.forEach((t=>function(e,t){var n,i;const o=t.path,r=null===(i=null===(n=t.type)||void 0===n?void 0:n[0])||void 0===i?void 0:i.code;if(void 0!==r&&"Element"!==r&&"BackboneElement"!==r)return;const a=o.split("."),s=Le(a);_e.types[s]=function(e,t,n){return{structureDefinition:t,elementDefinition:n,display:e,description:n.definition,properties:{}}}(s,e,t),_e.types[s].parentType=Le(a.slice(0,a.length-1))}(e,t))),n.forEach((e=>function(e){const t=e.path,n=t.split(".");if(1===n.length)return;const i=Le(n.slice(0,n.length-1)),o=_e.types[i];if(!o)return;const r=n[n.length-1];o.properties[r]=e}(e))))}function Ie(e){for(const t of e.entry){const e=t.resource;"SearchParameter"===e.resourceType&&Ue(e)}}function Ue(e){if(e.base)for(const t of e.base){const n=_e.types[t];n&&(n.searchParams||(n.searchParams={_id:{base:[t],code:"_id",type:"token",expression:t+".id"},_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"},_compartment:{base:[t],code:"_compartment",type:"reference",expression:t+".meta.compartment"}}),n.searchParams[e.code]=e)}}function Le(e){return 1===e.length?e[0]:e.map(Z).join("")}function je(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(Z).join(" ").replace("_"," ").replace(/\s+/g," ")}function Ne(e,t){var n;const i=_e.types[e];if(!i)return;const o=null!==(n=i.properties[t])&&void 0!==n?n:i.properties[t+"[x]"];if(o){if(o.contentReference){const e=o.contentReference.substring(1).split("."),t=e.pop();return Ne(Le(e),t)}return o}}!function(e){e.Address="Address",e.Age="Age",e.Annotation="Annotation",e.Attachment="Attachment",e.BackboneElement="BackboneElement",e.CodeableConcept="CodeableConcept",e.Coding="Coding",e.ContactDetail="ContactDetail",e.ContactPoint="ContactPoint",e.Contributor="Contributor",e.Count="Count",e.DataRequirement="DataRequirement",e.Distance="Distance",e.Dosage="Dosage",e.Duration="Duration",e.Expression="Expression",e.Extension="Extension",e.HumanName="HumanName",e.Identifier="Identifier",e.MarketingStatus="MarketingStatus",e.Meta="Meta",e.Money="Money",e.Narrative="Narrative",e.ParameterDefinition="ParameterDefinition",e.Period="Period",e.Population="Population",e.ProdCharacteristic="ProdCharacteristic",e.ProductShelfLife="ProductShelfLife",e.Quantity="Quantity",e.Range="Range",e.Ratio="Ratio",e.Reference="Reference",e.RelatedArtifact="RelatedArtifact",e.SampledData="SampledData",e.Signature="Signature",e.SubstanceAmount="SubstanceAmount",e.SystemString="http://hl7.org/fhirpath/System.String",e.Timing="Timing",e.TriggerDefinition="TriggerDefinition",e.UsageContext="UsageContext",e.base64Binary="base64Binary",e.boolean="boolean",e.canonical="canonical",e.code="code",e.date="date",e.dateTime="dateTime",e.decimal="decimal",e.id="id",e.instant="instant",e.integer="integer",e.markdown="markdown",e.oid="oid",e.positiveInt="positiveInt",e.string="string",e.time="time",e.unsignedInt="unsignedInt",e.uri="uri",e.url="url",e.uuid="uuid"}(Ae||(Ae={}));const _e=Re;var Qe,We,Be,qe,$e,Fe,He,ze,Ge,Ve,Xe,Ye,Je,Ze,Ke,et,tt,nt,it,ot,rt,at,st,ct,dt,lt,ut,mt,pt,ht,ft,yt;const gt="1.0.4-6dbdb7f6";class xt extends Se{constructor(e){var i,o;if(super(),Qe.add(this),We.set(this,void 0),Be.set(this,void 0),qe.set(this,void 0),$e.set(this,void 0),Fe.set(this,void 0),He.set(this,void 0),ze.set(this,void 0),Ge.set(this,void 0),Ve.set(this,void 0),Xe.set(this,void 0),Ye.set(this,void 0),Je.set(this,void 0),Ze.set(this,void 0),Ke.set(this,void 0),et.set(this,void 0),tt.set(this,void 0),nt.set(this,void 0),(null==e?void 0:e.baseUrl)&&!e.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");n(this,We,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),n(this,Be,null==e?void 0:e.createPdf,"f"),n(this,qe,new Ce,"f"),n(this,$e,new s(null!==(i=null==e?void 0:e.resourceCacheSize)&&void 0!==i?i:1e3),"f"),n(this,Fe,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:6e4,"f"),n(this,He,function(e){if(!e)return e;return e.endsWith("/")?e:e+"/"}(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),n(this,ze,(null==e?void 0:e.clientId)||"","f"),n(this,Ge,(null==e?void 0:e.authorizeUrl)||t(this,He,"f")+"oauth2/authorize","f"),n(this,Ve,(null==e?void 0:e.tokenUrl)||t(this,He,"f")+"oauth2/token","f"),n(this,Xe,(null==e?void 0:e.logoutUrl)||t(this,He,"f")+"oauth2/logout","f"),n(this,Ye,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(n(this,Je,r.accessToken,"f"),n(this,Ze,r.refreshToken,"f"),t(this,Qe,"m",ot).call(this).catch(console.log)),t(this,Qe,"m",yt).call(this)}getBaseUrl(){return t(this,He,"f")}clear(){t(this,qe,"f").clear(),t(this,$e,"f").clear(),n(this,Je,void 0,"f"),n(this,Ze,void 0,"f"),n(this,tt,void 0,"f"),n(this,nt,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),t(this,$e,"f").delete(e)}invalidateSearches(e){const n="fhir/R4/"+e;for(const e of t(this,$e,"f").keys())(e.endsWith(n)||e.includes(n+"?"))&&t(this,$e,"f").delete(e)}get(e,n={}){e=e.toString();const i=t(this,Qe,"m",rt).call(this,e,n);if(i)return i.value;const o=new De(t(this,Qe,"m",st).call(this,"GET",e,n));return t(this,Qe,"m",at).call(this,e,o),o}post(e,n,i,o={}){return e=e.toString(),n&&t(this,Qe,"m",lt).call(this,o,n),i&&t(this,Qe,"m",dt).call(this,o,i),this.invalidateUrl(e),t(this,Qe,"m",st).call(this,"POST",e,o)}put(e,n,i,o={}){return e=e.toString(),n&&t(this,Qe,"m",lt).call(this,o,n),i&&t(this,Qe,"m",dt).call(this,o,i),this.invalidateUrl(e),t(this,Qe,"m",st).call(this,"PUT",e,o)}patch(e,n,i={}){return e=e.toString(),t(this,Qe,"m",lt).call(this,i,n),t(this,Qe,"m",dt).call(this,i,"application/json-patch+json"),this.invalidateUrl(e),t(this,Qe,"m",st).call(this,"PATCH",e,i)}delete(e,n={}){return e=e.toString(),this.invalidateUrl(e),t(this,Qe,"m",st).call(this,"DELETE",e,n)}startNewUser(t){return e(this,void 0,void 0,(function*(){return yield this.startPkce(),this.post("auth/newuser",Object.assign(Object.assign({},t),{codeChallengeMethod:"S256",codeChallenge:sessionStorage.getItem("codeChallenge")}))}))}startNewProject(t){return e(this,void 0,void 0,(function*(){return this.post("auth/newproject",t)}))}startNewPatient(t){return e(this,void 0,void 0,(function*(){return this.post("auth/newpatient",t)}))}startLogin(n){var i;return e(this,void 0,void 0,(function*(){const{codeChallenge:e,codeChallengeMethod:o}=this.getCodeChallenge(n);return this.post("auth/login",Object.assign(Object.assign({},n),{clientId:null!==(i=n.clientId)&&void 0!==i?i:t(this,ze,"f"),scope:n.scope,codeChallengeMethod:o,codeChallenge:e}))}))}startGoogleLogin(n){var i;return e(this,void 0,void 0,(function*(){const{codeChallenge:e,codeChallengeMethod:o}=this.getCodeChallenge(n);return this.post("auth/google",Object.assign(Object.assign({},n),{clientId:null!==(i=n.clientId)&&void 0!==i?i:t(this,ze,"f"),scope:n.scope,codeChallengeMethod:o,codeChallenge:e}))}))}getCodeChallenge(e){if(e.codeChallenge)return{codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod};const t=sessionStorage.getItem("codeChallenge");return t?{codeChallenge:t,codeChallengeMethod:"S256"}:{}}signOut(){this.clear()}signInWithRedirect(){return e(this,void 0,void 0,(function*(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void(yield t(this,Qe,"m",mt).call(this))}))}signOutWithRedirect(){window.location.assign(t(this,Xe,"f"))}fhirUrl(...e){return new URL(t(this,He,"f")+"fhir/R4/"+e.join("/"))}fhirSearchUrl(e,t){const n=this.fhirUrl(e);return t&&(n.search=t.toString()),n}search(e,t,n={}){return this.get(this.fhirSearchUrl(e,t),n)}searchOne(e,n,i={}){const o=this.fhirSearchUrl(e,n);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=t(this,Qe,"m",rt).call(this,r,i);if(a)return a.value;const s=new De(this.search(e,o.searchParams,i).then((e=>{var t,n;return null===(n=null===(t=e.entry)||void 0===t?void 0:t[0])||void 0===n?void 0:n.resource})));return t(this,Qe,"m",at).call(this,r,s),s}searchResources(e,n,i={}){const o=this.fhirSearchUrl(e,n).toString()+"-searchResources",r=t(this,Qe,"m",rt).call(this,o,i);if(r)return r.value;const a=new De(this.search(e,n,i).then((e=>{var t,n;return null!==(n=null===(t=e.entry)||void 0===t?void 0:t.map((e=>e.resource)))&&void 0!==n?n:[]})));return t(this,Qe,"m",at).call(this,o,a),a}searchValueSet(e,t,n={}){const i=this.fhirUrl("ValueSet","$expand");return i.searchParams.set("url",e),i.searchParams.set("filter",t),this.get(i.toString(),n)}getCached(e,n){var i;const o=null===(i=t(this,$e,"f").get(this.fhirUrl(e,n).toString()))||void 0===i?void 0:i.value;return o&&o.isOk()?o.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[n,i]=t.split("/");return n&&i?this.getCached(n,i):void 0}readResource(e,t,n={}){return this.get(this.fhirUrl(e,t),n)}readReference(e,t={}){const n=null==e?void 0:e.reference;if(!n)return new De(Promise.reject(new Error("Missing reference")));const[i,o]=n.split("/");return i&&o?this.readResource(i,o,t):new De(Promise.reject(new Error("Invalid reference")))}getSchema(){return _e}requestSchema(t){return e(this,void 0,void 0,(function*(){if(t in _e.types)return _e;const e=`{\n StructureDefinitionList(name: "${t}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${t}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),n=yield this.graphql(e);for(const e of n.data.StructureDefinitionList)Oe(e);for(const e of n.data.SearchParameterList)Ue(e);return _e}))}readHistory(e,t,n={}){return this.get(this.fhirUrl(e,t,"_history"),n)}readVersion(e,t,n,i={}){return this.get(this.fhirUrl(e,t,"_history",n),i)}readPatientEverything(e,t={}){return this.get(this.fhirUrl("Patient",e,"$everything"),t)}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}createResourceIfNoneExist(t,n){var i;return e(this,void 0,void 0,(function*(){return null!==(i=yield this.searchOne(t.resourceType,n))&&void 0!==i?i:this.createResource(t)}))}createBinary(e,t,n,i){const o=this.fhirUrl("Binary");return t&&o.searchParams.set("_filename",t),i?this.uploadwithProgress(o,e,n,i):this.post(o,e,n)}uploadwithProgress(e,n,i,o){return new Promise(((r,a)=>{const s=new XMLHttpRequest;s.responseType="json",s.onabort=()=>a(new Error("Request aborted")),s.onerror=()=>a(new Error("Request error")),o&&(s.upload.onprogress=e=>o(e),s.upload.onload=e=>o(e)),s.onload=()=>{s.status>=200&&s.status<300?r(s.response):a(new Error(s.statusText))},s.open("POST",e),s.withCredentials=!0,s.setRequestHeader("Authorization","Bearer "+t(this,Je,"f")),s.setRequestHeader("Cache-Control","no-cache, no-store, max-age=0"),s.setRequestHeader("Content-Type",i),s.setRequestHeader("X-Medplum","extended"),s.send(n)}))}createPdf(n,i,o,r){return e(this,void 0,void 0,(function*(){if(!t(this,Be,"f"))throw new Error("PDF creation not enabled");const e=yield t(this,Be,"f").call(this,n,o,r);return this.createBinary(e,i,"application/pdf")}))}createComment(e,t){const n=this.getProfile();let i,o;return"Encounter"===e.resourceType&&(i=P(e),o=e.subject),"ServiceRequest"===e.resourceType&&(i=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=P(e)),this.createResource({resourceType:"Communication",basedOn:[P(e)],encounter:i,subject:o,sender:n?P(n):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}updateResource(t){return e(this,void 0,void 0,(function*(){if(!t.resourceType)throw new Error("Missing resourceType");if(!t.id)throw new Error("Missing id");this.invalidateSearches(t.resourceType);const e=yield this.put(this.fhirUrl(t.resourceType,t.id),t);return null!=e?e:t}))}patchResource(e,t,n){return this.invalidateSearches(e),this.patch(this.fhirUrl(e,t),n)}deleteResource(e,t){return this.invalidateSearches(e),this.delete(this.fhirUrl(e,t))}validateResource(e){return this.post(this.fhirUrl(e.resourceType,"$validate"),e)}executeBatch(e){return this.post("fhir/R4",e)}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t,n,i){return this.post(this.fhirUrl("$graphql"),{query:e,operationName:t,variables:n},"application/json",i)}readResourceGraph(e,t,n){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${n}`)}getActiveLogin(){return t(this,qe,"f").getObject("activeLogin")}setActiveLogin(i){return e(this,void 0,void 0,(function*(){n(this,Je,i.accessToken,"f"),n(this,Ze,i.refreshToken,"f"),n(this,tt,void 0,"f"),n(this,nt,void 0,"f"),t(this,qe,"f").setObject("activeLogin",i),t(this,Qe,"m",it).call(this,i),t(this,$e,"f").clear(),n(this,Ke,void 0,"f"),yield t(this,Qe,"m",ot).call(this)}))}getAccessToken(){return t(this,Je,"f")}setAccessToken(e){n(this,Je,e,"f"),n(this,Ze,void 0,"f"),n(this,tt,void 0,"f"),n(this,nt,void 0,"f")}getLogins(){var e;return null!==(e=t(this,qe,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!t(this,et,"f")}getProfile(){return t(this,tt,"f")}getProfileAsync(){return e(this,void 0,void 0,(function*(){return t(this,et,"f")&&(yield t(this,et,"f")),this.getProfile()}))}getUserConfiguration(){return t(this,nt,"f")}download(n,i={}){return e(this,void 0,void 0,(function*(){t(this,Ke,"f")&&(yield t(this,Ke,"f")),t(this,Qe,"m",ct).call(this,i);return(yield t(this,We,"f").call(this,n.toString(),i)).blob()}))}startPkce(){return e(this,void 0,void 0,(function*(){const t=pe();sessionStorage.setItem("pkceState",t);const n=pe();sessionStorage.setItem("codeVerifier",n);const i=J(yield function(t){return e(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t))}))}(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");sessionStorage.setItem("codeChallenge",i)}))}processCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("client_id",t(this,ze,"f")),n.set("code",e),n.set("redirect_uri",vt());const i=sessionStorage.getItem("codeVerifier");return i&&n.set("code_verifier",i),t(this,Qe,"m",ht).call(this,n)}startClientLogin(n,i){return e(this,void 0,void 0,(function*(){const e=new URLSearchParams;return e.set("grant_type","client_credentials"),e.set("client_id",n),e.set("client_secret",i),t(this,Qe,"m",ht).call(this,e)}))}}function vt(){return window.location.protocol+"//"+window.location.host+"/"}function wt(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch(t){return e}}function Et(e){return[{type:Ae.boolean,value:e}]}function St(e){return null==e?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:Ae.integer,value:e}:"number"==typeof e?{type:Ae.decimal,value:e}:"boolean"==typeof e?{type:Ae.boolean,value:e}:"string"==typeof e?{type:Ae.string,value:e}:Lt(e)?{type:Ae.Quantity,value:e}:"object"==typeof e&&"resourceType"in e?{type:e.resourceType,value:e}:{type:Ae.BackboneElement,value:e}}function bt(e){return 0!==e.length&&!!e[0].value}function Tt(e,t){if(!(null==e?void 0:e.value))return;const n=Ne(e.type,t);if(n){const i=function(e,t,n){var i;const o=n.type;if(!o||0===o.length)return;let r,a="undefined";if(1===o.length)r=e.value[t],a=o[0].code;else for(const n of o){const i=t.replace("[x]","")+Z(n.code);if(i in e.value){r=e.value[i],a=n.code;break}}if($(r))return;"Element"!==a&&"BackboneElement"!==a||(a=Le(null===(i=n.path)||void 0===i?void 0:i.split(".")));return Array.isArray(r)?r.map((e=>Dt(e,a))):Dt(r,a)}(e,t,n);if(i)return i}return function(e,t){const n=e.value;if(!n||"object"!=typeof n)return;let i;if(t in n)i=n[t];else for(const e in Ae){const o=t+Z(e);if(o in n){i=n[o];break}}if($(i))return;return Array.isArray(i)?i.map(St):St(i)}(e,t)}function Dt(e,t){return"Resource"===t&&"object"==typeof e&&"resourceType"in e&&(t=e.resourceType),{type:t,value:e}}function Ct(e){const t=[];for(const n of e){let e=!1;for(const i of t)if(bt(Rt(n,i))){e=!0;break}e||t.push(n)}return t}function Pt(e){return Et(!bt(e))}function At(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?Et(!1):Et(e.every(((e,n)=>bt(Rt(e,t[n])))))}function Rt(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?Et(Math.abs(n-i)<1e-8):Lt(n)&&Lt(i)?Et(jt(n,i)):Et("object"==typeof n&&"object"==typeof i?Nt(e,t):n===i)}function kt(e,t){return 0===e.length&&0===t.length?Et(!0):e.length!==t.length?Et(!1):(e.sort(Ot),t.sort(Ot),Et(e.every(((e,n)=>bt(Mt(e,t[n]))))))}function Mt(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?Et(Math.abs(n-i)<.01):Lt(n)&&Lt(i)?Et(jt(n,i)):Et("object"==typeof n&&"object"==typeof i?Nt(n,i):"string"==typeof n&&"string"==typeof i?n.toLowerCase()===i.toLowerCase():n===i)}function Ot(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?n-i:"string"==typeof n&&"string"==typeof i?n.localeCompare(i):0}function It(e,t){const{value:n}=e;if(null==n)return!1;switch(t){case"Boolean":return"boolean"==typeof n;case"Decimal":case"Integer":return"number"==typeof n;case"Date":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof n&&!!n.match(/^T\d/);case"Period":return Ut(n);case"Quantity":return Lt(n);default:return"object"==typeof n&&(null==n?void 0:n.resourceType)===t}}function Ut(e){return!(!e||"object"!=typeof e||!("start"in e))}function Lt(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function jt(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 n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){const n=e[i],o=t[i];if(_t(n)&&_t(o)){if(!Nt(n,o))return!1}else if(n!==o)return!1}return!0}function _t(e){return null!==e&&"object"==typeof e}We=new WeakMap,Be=new WeakMap,qe=new WeakMap,$e=new WeakMap,Fe=new WeakMap,He=new WeakMap,ze=new WeakMap,Ge=new WeakMap,Ve=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Ke=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,Qe=new WeakSet,it=function(e){const n=this.getLogins().filter((t=>{var n,i;return(null===(n=t.profile)||void 0===n?void 0:n.reference)!==(null===(i=e.profile)||void 0===i?void 0:i.reference)}));n.push(e),t(this,qe,"f").setObject("logins",n)},ot=function(){return e(this,void 0,void 0,(function*(){return n(this,et,new Promise(((e,i)=>{this.get("auth/me").then((i=>{n(this,et,void 0,"f"),n(this,tt,i.profile,"f"),n(this,nt,i.config,"f"),this.dispatchEvent({type:"change"}),e(t(this,tt,"f"))})).catch(i)})),"f"),t(this,et,"f")}))},rt=function(e,n){if(t(this,Fe,"f")<=0||"no-cache"===(null==n?void 0:n.cache)||"reload"===(null==n?void 0:n.cache))return;const i=t(this,$e,"f").get(e);return!i||i.requestTime+t(this,Fe,"f")<Date.now()?void 0:i},at=function(e,n){t(this,Fe,"f")>0&&t(this,$e,"f").set(e,{requestTime:Date.now(),value:n})},st=function(n,i,o={}){return e(this,void 0,void 0,(function*(){t(this,Ke,"f")&&(yield t(this,Ke,"f")),i.startsWith("http")||(i=t(this,He,"f")+i),o.method=n,t(this,Qe,"m",ct).call(this,o);const e=yield t(this,We,"f").call(this,i,o);if(401===e.status)return t(this,Qe,"m",ut).call(this,n,i,o);if(204===e.status||304===e.status)return;const r=yield e.json();if(e.status>=400)throw r;return r}))},ct=function(e){e.headers||(e.headers={});const n=e.headers;n["X-Medplum"]="extended",n["Content-Type"]||(n["Content-Type"]="application/fhir+json"),t(this,Je,"f")&&(n.Authorization="Bearer "+t(this,Je,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},dt=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},lt=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))},ut=function(n,i,o){return e(this,void 0,void 0,(function*(){return t(this,Qe,"m",pt).call(this).then((()=>t(this,Qe,"m",st).call(this,n,i,o))).catch((e=>(this.clear(),t(this,Ye,"f")&&t(this,Ye,"f").call(this),Promise.reject(e))))}))},mt=function(){return e(this,void 0,void 0,(function*(){yield this.startPkce();const e=new URL(t(this,Ge,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",sessionStorage.getItem("pkceState")),e.searchParams.set("client_id",t(this,ze,"f")),e.searchParams.set("redirect_uri",vt()),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",sessionStorage.getItem("codeChallenge")),window.location.assign(e.toString())}))},pt=function(){return e(this,void 0,void 0,(function*(){if(t(this,Ke,"f"))return t(this,Ke,"f");if(!t(this,Ze,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",t(this,ze,"f")),e.set("refresh_token",t(this,Ze,"f")),n(this,Ke,t(this,Qe,"m",ht).call(this,e),"f"),yield t(this,Ke,"f")}))},ht=function(n){return e(this,void 0,void 0,(function*(){return t(this,We,"f").call(this,t(this,Ve,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n,credentials:"include"}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>t(this,Qe,"m",ft).call(this,e))).then((()=>this.getProfile()))}))},ft=function(n){return e(this,void 0,void 0,(function*(){const e=n.access_token,i=Te(e);if(Date.now()>=1e3*i.exp)throw this.clear(),new Error("Token expired");if(t(this,ze,"f")&&i.client_id!==t(this,ze,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:e,refreshToken:n.refresh_token,project:n.project,profile:n.profile})}))},yt=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};const Qt=()=>[],Wt={empty:e=>Et(0===e.length),exists:(e,t)=>Et(t?e.filter((e=>bt(t.eval([e])))).length>0:e.length>0),all:(e,t)=>Et(e.every((e=>bt(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return Et(!1);return Et(!0)},anyTrue:e=>{for(const t of e)if(t.value)return Et(!0);return Et(!1)},allFalse:e=>{for(const t of e)if(t.value)return Et(!1);return Et(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return Et(!0);return Et(!1)},subsetOf:Qt,supersetOf:Qt,count:e=>[{type:Ae.integer,value:e.length}],distinct:e=>{const t=[];for(const n of e)t.some((e=>e.value===n.value))||t.push(n);return t},isDistinct:e=>Et(e.length===Wt.distinct(e).length),where:(e,t)=>e.filter((e=>bt(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:Qt,ofType:(e,t)=>e.filter((e=>e.type===t.name)),single:e=>{if(e.length>1)throw new Error("Expected input length one for single()");return 0===e.length?[]:e.slice(0,1)},first:e=>0===e.length?[]:e.slice(0,1),last:e=>0===e.length?[]:e.slice(e.length-1,e.length),tail:e=>0===e.length?[]:e.slice(1,e.length),skip:(e,t)=>{var n;const i=null===(n=t.eval(e)[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for skip(num)");return i>=e.length?[]:i<=0?e:e.slice(i,e.length)},take:(e,t)=>{var n;const i=null===(n=t.eval(e)[0])||void 0===n?void 0:n.value;if("number"!=typeof i)throw new Error("Expected a number for take(num)");return i>=e.length?e:i<=0?[]:e.slice(0,i)},intersect:(e,t)=>{if(!t)return e;const n=t.eval(e),i=[];for(const t of e)!i.some((e=>e.value===t.value))&&n.some((e=>e.value===t.value))&&i.push(t);return i},exclude:(e,t)=>{if(!t)return e;const n=t.eval(e),i=[];for(const t of e)n.some((e=>e.value===t.value))||i.push(t);return i},union:(e,t)=>{if(!t)return e;const n=t.eval(e);return Ct([...e,...n])},combine:(e,t)=>{if(!t)return e;const n=t.eval(e);return[...e,...n]},iif:(e,t,n,i)=>{const o=t.eval(e);if(o.length>1||1===o.length&&"boolean"!=typeof o[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return bt(o)?n.eval(e):i?i.eval(e):[]},toBoolean:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);if("boolean"==typeof t)return[{type:Ae.boolean,value:t}];if("number"==typeof t&&(0===t||1===t))return Et(!!t);if("string"==typeof t){const e=t.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return Et(!0);if(["false","f","no","n","0","0.0"].includes(e))return Et(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:Et(1===Wt.toBoolean(e).length),toInteger:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"number"==typeof t?[{type:Ae.integer,value:t}]:"string"==typeof t&&t.match(/^[+-]?\d+$/)?[{type:Ae.integer,value:parseInt(t,10)}]:"boolean"==typeof t?[{type:Ae.integer,value:t?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:Et(1===Wt.toInteger(e).length),toDate:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:Ae.date,value:wt(t)}]:[]},convertsToDate:e=>0===e.length?[]:Et(1===Wt.toDate(e).length),toDateTime:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:Ae.dateTime,value:wt(t)}]:[]},convertsToDateTime:e=>0===e.length?[]:Et(1===Wt.toDateTime(e).length),toDecimal:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return"number"==typeof t?[{type:Ae.decimal,value:t}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:Ae.decimal,value:parseFloat(t)}]:"boolean"==typeof t?[{type:Ae.decimal,value:t?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:Et(1===Wt.toDecimal(e).length),toQuantity:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return Lt(t)?[{type:Ae.Quantity,value:t}]:"number"==typeof t?[{type:Ae.Quantity,value:{value:t,unit:"1"}}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:Ae.Quantity,value:{value:parseFloat(t),unit:"1"}}]:"boolean"==typeof t?[{type:Ae.Quantity,value:{value:t?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:Et(1===Wt.toQuantity(e).length),toString:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);return null==t?[]:Lt(t)?[{type:Ae.string,value:`${t.value} '${t.unit}'`}]:[{type:Ae.string,value:t.toString()}]},convertsToString:e=>0===e.length?[]:Et(1===Wt.toString(e).length),toTime:e=>{if(0===e.length)return[];const[{value:t}]=$t(e,1);if("string"==typeof t){const e=t.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(e)return[{type:Ae.time,value:wt("T"+e[1])}]}return[]},convertsToTime:e=>0===e.length?[]:Et(1===Wt.toTime(e).length),indexOf:(e,t)=>Bt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,n)=>Bt(((e,t,n)=>{const i=t,o=n?i+n:e.length;return i<0||i>=e.length?void 0:e.substring(i,o)}),e,t,n),startsWith:(e,t)=>Bt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>Bt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>Bt(((e,t)=>e.includes(t)),e,t),upper:e=>Bt((e=>e.toUpperCase()),e),lower:e=>Bt((e=>e.toLowerCase()),e),replace:(e,t,n)=>Bt(((e,t,n)=>e.replaceAll(t,n)),e,t,n),matches:(e,t)=>Bt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,n)=>Bt(((e,t,n)=>e.replaceAll(t,n)),e,t,n),length:e=>Bt((e=>e.length),e),toChars:e=>Bt((e=>e?e.split(""):void 0),e),abs:e=>qt(Math.abs,e),ceiling:e=>qt(Math.ceil,e),exp:e=>qt(Math.exp,e),floor:e=>qt(Math.floor,e),ln:e=>qt(Math.log,e),log:(e,t)=>qt(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>qt(Math.pow,e,t),round:e=>qt(Math.round,e),sqrt:e=>qt(Math.sqrt,e),truncate:e=>qt((e=>0|e),e),children:Qt,descendants:Qt,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:Ae.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:Ae.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:Ae.date,value:(new Date).toISOString().substring(0,10)}],between:(e,t,n,i)=>{var o;const r=Wt.toDateTime(t.eval(e));if(0===r.length)throw new Error("Invalid start date");const a=Wt.toDateTime(n.eval(e));if(0===a.length)throw new Error("Invalid end date");const s=null===(o=i.eval(e)[0])||void 0===o?void 0:o.value;if("years"!==s&&"months"!==s&&"days"!==s)throw new Error("Invalid units");const c=L(r[0].value,a[0].value);return[{type:Ae.Quantity,value:{value:c[s],unit:s}}]},is:(e,t)=>{let n="";return t instanceof Pn?n=t.name:t instanceof Ln&&(n=t.left.name+"."+t.right.name),n?e.map((e=>({type:Ae.boolean,value:It(e,n)}))):[]},not:e=>Wt.toBoolean(e).map((e=>({type:Ae.boolean,value:!e.value}))),resolve:e=>e.map((e=>{const t=e.value;let n;if("string"==typeof t)n=t;else if("object"==typeof t){const e=t;if(e.resource)return St(e.resource);n=e.reference}if(!n)return{type:Ae.BackboneElement,value:null};const[i,o]=n.split("/");return{type:Ae.BackboneElement,value:{resourceType:i,id:o}}})).filter((e=>!!e.value)),as:e=>e,type:e=>e.map((({value:e})=>"boolean"==typeof e?{type:Ae.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof e?{type:Ae.BackboneElement,value:{namespace:"System",name:"Integer"}}:e&&"object"==typeof e&&"resourceType"in e?{type:Ae.BackboneElement,value:{namespace:"FHIR",name:e.resourceType}}:{type:Ae.BackboneElement,value:null})),conformsTo:(e,t)=>{const n=t.eval(e)[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const i=n.replace("http://hl7.org/fhir/StructureDefinition/","");return e.map((e=>{var t;return{type:Ae.boolean,value:(null===(t=e.value)||void 0===t?void 0:t.resourceType)===i}}))}};function Bt(e,t,...n){if(0===t.length)return[];const[{value:i}]=$t(t,1);if("string"!=typeof i)throw new Error("String function cannot be called with non-string");const o=e(i,...n.map((e=>{var n,i;return e&&(null===(i=null===(n=e.eval(t))||void 0===n?void 0:n[0])||void 0===i?void 0:i.value)})));return void 0===o?[]:Array.isArray(o)?o.map(St):[St(o)]}function qt(e,t,...n){if(0===t.length)return[];const[{value:i}]=$t(t,1),o=Lt(i),r=o?i.value:i;if("number"!=typeof r)throw new Error("Math function cannot be called with non-number");const a=e(r,...n.map((e=>{var n,i;return null===(i=null===(n=e.eval(t))||void 0===n?void 0:n[0])||void 0===i?void 0:i.value})));return[{type:o?Ae.Quantity:t[0].type,value:o?Object.assign(Object.assign({},i),{value:a}):a}]}function $t(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const t of e)if(null==t)throw new Error("Expected non-null argument");return e}var Ft,Ht,zt,Gt,Vt,Xt,Yt,Jt,Zt,Kt,en,tn,nn,on,rn,an,sn,cn,dn,ln,un,mn,pn,hn,fn,yn,gn,xn,vn,wn,En,Sn,bn,Tn;class Dn{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 Cn{constructor(e){this.value=e}eval(){return[this.value]}}class Pn{constructor(e){this.name=e,Ft.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>t(this,Ft,"m",Ht).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}Ft=new WeakSet,Ht=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:Tt(e,this.name)};class An{eval(){return[]}}class Rn{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class kn{constructor(e,t){this.left=e,this.right=t}eval(e){return Wt.ofType(this.left.eval(e),this.right)}}class Mn{constructor(e,t,n){this.left=e,this.right=t,this.impl=n}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const n=this.right.eval(e);if(1!==n.length)return[];const i=t[0].value,o=n[0].value,r=Lt(i)?i.value:i,a=Lt(o)?o.value:o,s=this.impl(r,a);return"boolean"==typeof s?Et(s):Lt(i)?[{type:Ae.Quantity,value:Object.assign(Object.assign({},i),{value:s})}]:[St(s)]}}class On{constructor(e,t){this.left=e,this.right=t}eval(e){const t=[...this.left.eval(e),...this.right.eval(e)];return t.length>0&&t.every((e=>"string"==typeof e.value))?[{type:Ae.string,value:t.map((e=>e.value)).join("")}]:t}}class In{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),n=this.right.eval(e);return Et(t.some((e=>e.value===n[0].value)))}}class Un{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);return Et(this.right.eval(e).some((e=>e.value===t[0].value)))}}class Ln{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class jn{constructor(e,t){this.left=e,this.right=t}eval(e){return Ct([...this.left.eval(e),...this.right.eval(e)])}}class Nn{constructor(e,t){this.left=e,this.right=t}eval(e){return At(this.left.eval(e),this.right.eval(e))}}class _n{constructor(e,t){this.left=e,this.right=t}eval(e){return Pt(At(this.left.eval(e),this.right.eval(e)))}}class Qn{constructor(e,t){this.left=e,this.right=t}eval(e){return kt(this.left.eval(e),this.right.eval(e))}}class Wn{constructor(e,t){this.left=e,this.right=t}eval(e){return Pt(kt(this.left.eval(e),this.right.eval(e)))}}class Bn{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const n=this.right.name;return Et(It(t[0],n))}}class qn{constructor(e,t){this.left=e,this.right=t}eval(e){var t,n,i,o;const r=this.left.eval(e),a=this.right.eval(e);return!0===(null===(t=r[0])||void 0===t?void 0:t.value)&&!0===(null===(n=a[0])||void 0===n?void 0:n.value)?Et(!0):!1===(null===(i=r[0])||void 0===i?void 0:i.value)||!1===(null===(o=a[0])||void 0===o?void 0:o.value)?Et(!1):[]}}class $n{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(bt(t))return t;const n=this.right.eval(e);return bt(n)?n:[]}}class Fn{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),n=this.right.eval(e);if(0===t.length&&0===n.length)return[];const i=0===t.length?null:t[0].value,o=0===n.length?null:n[0].value;return!0===i&&!0!==o||!0!==i&&!0===o?Et(!0):!0===i&&!0===o||!1===i&&!1===o?Et(!1):[]}}class Hn{constructor(e,t,n){this.name=e,this.args=t,this.impl=n}eval(e){return this.impl(e,...this.args)}}class zn{constructor(e,t){this.left=e,this.expr=t}eval(e){const t=this.expr.eval(e);if(1!==t.length)return[];const n=t[0].value;if("number"!=typeof n)throw new Error("Invalid indexer expression: should return integer}");const i=this.left.eval(e);return n in i?[i[n]]:[]}}class Gn{constructor(){zt.set(this,{}),Gt.set(this,{})}registerInfix(e,n){return t(this,Gt,"f")[e]=n,this}registerPrefix(e,n){return t(this,zt,"f")[e]=n,this}prefix(e,t,n){return this.registerPrefix(e,{parse(e,i){const o=e.consumeAndParse(t);return n(i,o)}})}infixLeft(e,t,n){return this.registerInfix(e,{parse(e,i,o){const r=e.consumeAndParse(t);return n(i,o,r)},precedence:t})}construct(e){return new Vn(e,t(this,zt,"f"),t(this,Gt,"f"))}}zt=new WeakMap,Gt=new WeakMap;class Vn{constructor(e,t,i){Vt.set(this,void 0),Xt.set(this,void 0),Yt.set(this,void 0),n(this,Vt,e,"f"),n(this,Xt,t,"f"),n(this,Yt,i,"f")}hasMore(){return t(this,Vt,"f").length>0}match(e){const t=this.peek();return(null==t?void 0:t.id)===e&&(this.consume(),!0)}consumeAndParse(e=1/0){const n=this.consume(),i=t(this,Xt,"f")[n.id];if(!i)throw Error(`Parse error at "${n.value}" (line ${n.line}, column ${n.column}). No matching prefix parselet.`);let o=i.parse(this,n);for(;e>this.getPrecedence();){const e=this.consume();o=t(this,Yt,"f")[e.id].parse(this,o,e)}return o}getPrecedence(){const e=this.peek();if(!e)return 1/0;const n=t(this,Yt,"f")[e.id];return n?n.precedence:1/0}consume(e){var n;if(!t(this,Vt,"f").length)throw Error("Cant consume unknown more tokens.");if(e&&(null===(n=this.peek())||void 0===n?void 0:n.id)!==e){const t=this.peek();throw Error(`Expected ${e} but got "${t.value}" at line ${t.line} column ${t.column}.`)}return t(this,Vt,"f").shift()}peek(){return t(this,Vt,"f").length>0?t(this,Vt,"f")[0]:void 0}removeComments(){n(this,Vt,t(this,Vt,"f").filter((e=>"Comment"!==e.id)),"f")}}Vt=new WeakMap,Xt=new WeakMap,Yt=new WeakMap;const Xn=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class Yn{constructor(e,t,i){Jt.add(this),Zt.set(this,void 0),Kt.set(this,void 0),en.set(this,void 0),tn.set(this,[]),nn.set(this,{index:0,line:0,column:0}),on.set(this,[]),n(this,Zt,e,"f"),n(this,Kt,t,"f"),n(this,en,i,"f")}tokenize(){for(;t(this,nn,"f").index<t(this,Zt,"f").length;){const e=t(this,Jt,"m",sn).call(this);e&&t(this,tn,"f").push(e)}return t(this,tn,"f")}}Zt=new WeakMap,Kt=new WeakMap,en=new WeakMap,tn=new WeakMap,nn=new WeakMap,on=new WeakMap,Jt=new WeakSet,rn=function(){return t(this,tn,"f").slice(-1)[0]},an=function(){t(this,Jt,"m",En).call(this);const e=t(this,Jt,"m",sn).call(this);return t(this,Jt,"m",Sn).call(this),e},sn=function(){t(this,Jt,"m",cn).call(this);const e=t(this,Jt,"m",xn).call(this);if(!e)return;t(this,Jt,"m",En).call(this);const n=t(this,Jt,"m",wn).call(this);return"/"===e&&"*"===n?t(this,Jt,"m",dn).call(this):"/"===e&&"/"===n?t(this,Jt,"m",ln).call(this):"'"===e||'"'===e?t(this,Jt,"m",un).call(this,e):"`"===e?t(this,Jt,"m",mn).call(this):"@"===e?t(this,Jt,"m",pn).call(this):e.match(/\d/)?t(this,Jt,"m",hn).call(this):e.match(/\w/)||"$"===e&&n.match(/\w/)?t(this,Jt,"m",fn).call(this):t(this,Jt,"m",yn).call(this)},cn=function(){t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/\s/)))},dn=function(){const e=t(this,nn,"f").index;return t(this,Jt,"m",gn).call(this,(()=>"*"!==t(this,Jt,"m",xn).call(this)||"/"!==t(this,Jt,"m",wn).call(this))),t(this,Jt,"m",bn).call(this),t(this,Jt,"m",bn).call(this),t(this,Jt,"m",Tn).call(this,"Comment",t(this,Zt,"f").substring(e,t(this,nn,"f").index))},ln=function(){return t(this,Jt,"m",Tn).call(this,"Comment",t(this,Jt,"m",gn).call(this,(()=>"\n"!==t(this,Jt,"m",xn).call(this))))},un=function(e){t(this,Jt,"m",bn).call(this);const n=t(this,Jt,"m",Tn).call(this,"String",t(this,Jt,"m",gn).call(this,(()=>"\\"===t(this,Jt,"m",vn).call(this)||t(this,Jt,"m",xn).call(this)!==e)));return t(this,Jt,"m",bn).call(this),n},mn=function(){t(this,Jt,"m",bn).call(this);const e=t(this,Jt,"m",Tn).call(this,"Symbol",t(this,Jt,"m",gn).call(this,(()=>"`"!==t(this,Jt,"m",xn).call(this))));return t(this,Jt,"m",bn).call(this),e},pn=function(){t(this,Jt,"m",bn).call(this);const e=t(this,nn,"f").index;return t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/[\d-]/))),"T"===t(this,Jt,"m",xn).call(this)&&(t(this,Jt,"m",bn).call(this),t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/[\d:]/))),"."===t(this,Jt,"m",xn).call(this)&&t(this,Jt,"m",wn).call(this).match(/\d/)&&(t(this,Jt,"m",bn).call(this),t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/\d/)))),"Z"===t(this,Jt,"m",xn).call(this)?t(this,Jt,"m",bn).call(this):"+"!==t(this,Jt,"m",xn).call(this)&&"-"!==t(this,Jt,"m",xn).call(this)||(t(this,Jt,"m",bn).call(this),t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/[\d:]/))))),t(this,Jt,"m",Tn).call(this,"DateTime",t(this,Zt,"f").substring(e,t(this,nn,"f").index))},hn=function(){const e=t(this,nn,"f").index;let n="Number";return t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/\d/))),"."===t(this,Jt,"m",xn).call(this)&&t(this,Jt,"m",wn).call(this).match(/\d/)&&(t(this,Jt,"m",bn).call(this),t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/\d/))))," "===t(this,Jt,"m",xn).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&Xn.includes(e.value))return!0}return!1}(t(this,Jt,"m",an).call(this))&&(n="Quantity",t(this,Jt,"m",sn).call(this)),t(this,Jt,"m",Tn).call(this,n,t(this,Zt,"f").substring(e,t(this,nn,"f").index))},fn=function(){var e;const n=t(this,Jt,"m",gn).call(this,(()=>t(this,Jt,"m",xn).call(this).match(/[$\w]/)));return"."!==(null===(e=t(this,Jt,"m",rn).call(this))||void 0===e?void 0:e.value)&&t(this,Kt,"f").includes(n)?t(this,Jt,"m",Tn).call(this,n,n):t(this,Jt,"m",Tn).call(this,"Symbol",n)},yn=function(){const e=t(this,Jt,"m",xn).call(this),n=e+t(this,Jt,"m",wn).call(this);return t(this,en,"f").includes(n)?(t(this,Jt,"m",bn).call(this),t(this,Jt,"m",bn).call(this),t(this,Jt,"m",Tn).call(this,n,n)):(t(this,Jt,"m",bn).call(this),t(this,Jt,"m",Tn).call(this,e,e))},gn=function(e){const n=t(this,nn,"f").index;for(;t(this,nn,"f").index<t(this,Zt,"f").length&&e();)t(this,Jt,"m",bn).call(this);return t(this,Zt,"f").substring(n,t(this,nn,"f").index)},xn=function(){return t(this,Zt,"f")[t(this,nn,"f").index]},vn=function(){var e;return null!==(e=t(this,Zt,"f")[t(this,nn,"f").index-1])&&void 0!==e?e:""},wn=function(){var e;return null!==(e=t(this,Zt,"f")[t(this,nn,"f").index+1])&&void 0!==e?e:""},En=function(){t(this,on,"f").push(Object.assign({},t(this,nn,"f")))},Sn=function(){const e=t(this,on,"f").pop();if(!e)throw new Error("No mark to reset to");t(this,nn,"f").index=e.index,t(this,nn,"f").line=e.line,t(this,nn,"f").column=e.column},bn=function(){t(this,nn,"f").index++,"\n"===t(this,Jt,"m",xn).call(this)?(t(this,nn,"f").line++,t(this,nn,"f").column=0):t(this,nn,"f").column++},Tn=function(e,n){const i=t(this,on,"f").pop();if(!i)throw new Error("No mark for token");return Object.assign({id:e,value:n},i)};const Jn=["true","false","and","as","contains","div","in","is","mod","or","xor"],Zn=["!=","!~","<=",">=","{}","->"];function Kn(e){return new Yn(e,Jn,Zn).tokenize()}const ei={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},ti={parse(e,t){const n=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new zn(t,n)},precedence:2},ni={parse(e,t){if(!(t instanceof Pn))throw new Error("Unexpected parentheses");if(!(t.name in Wt))throw new Error("Unrecognized function: "+t.name);const n=[];for(;!e.match(")");)n.push(e.consumeAndParse()),e.match(",");return new Hn(t.name,n,Wt[t.name])},precedence:0};function ii(e){const t=e.split(" "),n=parseFloat(t[0]);let i=t[1];return i=i&&i.startsWith("'")&&i.endsWith("'")?i.substring(1,i.length-1):"{"+i+"}",{value:n,unit:i}}function oi(){return(new Gn).registerPrefix("String",{parse:(e,t)=>new Cn({type:Ae.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new Cn({type:Ae.dateTime,value:wt(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new Cn({type:Ae.Quantity,value:ii(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new Cn({type:Ae.decimal,value:parseFloat(t.value)})}).registerPrefix("true",{parse:()=>new Cn({type:Ae.boolean,value:!0})}).registerPrefix("false",{parse:()=>new Cn({type:Ae.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new Pn(t.value)}).registerPrefix("{}",{parse:()=>new An}).registerPrefix("(",ei).registerInfix("[",ti).registerInfix("(",ni).prefix("+",3,((e,t)=>new Rn(t,(e=>e)))).prefix("-",3,((e,t)=>new Mn(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,n)=>new Ln(e,n))).infixLeft("/",4,((e,t,n)=>new Mn(e,n,((e,t)=>e/t)))).infixLeft("*",4,((e,t,n)=>new Mn(e,n,((e,t)=>e*t)))).infixLeft("+",5,((e,t,n)=>new Mn(e,n,((e,t)=>e+t)))).infixLeft("-",5,((e,t,n)=>new Mn(e,n,((e,t)=>e-t)))).infixLeft("|",7,((e,t,n)=>new jn(e,n))).infixLeft("=",9,((e,t,n)=>new Nn(e,n))).infixLeft("!=",9,((e,t,n)=>new _n(e,n))).infixLeft("~",9,((e,t,n)=>new Qn(e,n))).infixLeft("!~",9,((e,t,n)=>new Wn(e,n))).infixLeft("<",8,((e,t,n)=>new Mn(e,n,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,n)=>new Mn(e,n,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,n)=>new Mn(e,n,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,n)=>new Mn(e,n,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,n)=>new On(e,n))).infixLeft("and",6,((e,t,n)=>new qn(e,n))).infixLeft("as",6,((e,t,n)=>new kn(e,n))).infixLeft("contains",6,((e,t,n)=>new In(e,n))).infixLeft("div",6,((e,t,n)=>new Mn(e,n,((e,t)=>e/t|0)))).infixLeft("in",6,((e,t,n)=>new Un(e,n))).infixLeft("is",6,((e,t,n)=>new Bn(e,n))).infixLeft("mod",6,((e,t,n)=>new Mn(e,n,((e,t)=>e%t)))).infixLeft("or",6,((e,t,n)=>new $n(e,n))).infixLeft("xor",6,((e,t,n)=>new Fn(e,n)))}const ri=oi();function ai(e){return new Dn(e,ri.construct(Kn(e)).consumeAndParse())}function si(e,t){const n=Array.isArray(t)?t:[t];for(let e=0;e<n.length;e++){const t=n[e];"object"==typeof t&&"type"in t&&"value"in t||(n[e]=St(n[e]))}return ci(e,n).map((e=>e.value))}function ci(e,t){return ai(e).eval(t)}class di{constructor(e="\r",t="|",n="^",i="~",o="\\",r="&"){this.segmentSeparator=e,this.fieldSeparator=t,this.componentSeparator=n,this.repetitionSeparator=i,this.escapeCharacter=o,this.subcomponentSeparator=r}getMsh2(){return this.fieldSeparator+this.componentSeparator+this.repetitionSeparator+this.escapeCharacter+this.subcomponentSeparator}}class li{constructor(e,t=new di){this.context=t,this.segments=e}get(e){return"number"==typeof e?this.segments[e]:this.segments.find((t=>t.name===e))}getAll(e){return this.segments.filter((t=>t.name===e))}toString(){return this.segments.map((e=>e.toString())).join(this.context.segmentSeparator)}buildAck(){var e,t,n,i,o,r;const a=new Date,s=this.get("MSH"),c=(null===(e=null==s?void 0:s.get(2))||void 0===e?void 0:e.toString())||"",d=(null===(t=null==s?void 0:s.get(3))||void 0===t?void 0:t.toString())||"",l=(null===(n=null==s?void 0:s.get(4))||void 0===n?void 0:n.toString())||"",u=(null===(i=null==s?void 0:s.get(5))||void 0===i?void 0:i.toString())||"",m=(null===(o=null==s?void 0:s.get(9))||void 0===o?void 0:o.toString())||"",p=(null===(r=null==s?void 0:s.get(12))||void 0===r?void 0:r.toString())||"2.5.1";return new li([new ui(["MSH",this.context.getMsh2(),l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p],this.context),new ui(["MSA","AA",m,"OK"],this.context)])}static parse(e){if(!e.startsWith("MSH")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}const t=new di("\r",e.charAt(3),e.charAt(4),e.charAt(5),e.charAt(6),e.charAt(7));return new li(e.split(/[\r\n]+/).map((e=>ui.parse(e,t))),t)}}class ui{constructor(e,t=new di){this.context=t,V(e)?this.fields=e.map((e=>mi.parse(e))):this.fields=e,this.name=this.fields[0].components[0][0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join(this.context.fieldSeparator)}static parse(e,t=new di){return new ui(e.split(t.fieldSeparator).map((e=>mi.parse(e,t))),t)}}class mi{constructor(e,t=new di){this.context=t,this.components=e}get(e,t,n=0){let i=this.components[n][e]||"";return void 0!==t&&(i=i.split(this.context.subcomponentSeparator)[t]||""),i}toString(){return this.components.map((e=>e.join(this.context.componentSeparator))).join(this.context.repetitionSeparator)}static parse(e,t=new di){return new mi(e.split(t.repetitionSeparator).map((e=>e.split(t.componentSeparator))),t)}}const pi=20;var hi;!function(e){e.EQUALS="eq",e.NOT_EQUALS="ne",e.GREATER_THAN="gt",e.LESS_THAN="lt",e.GREATER_THAN_OR_EQUALS="ge",e.LESS_THAN_OR_EQUALS="le",e.STARTS_AFTER="sa",e.ENDS_BEFORE="eb",e.APPROXIMATELY="ap",e.CONTAINS="contains",e.EXACT="exact",e.TEXT="text",e.NOT="not",e.ABOVE="above",e.BELOW="below",e.IN="in",e.NOT_IN="not-in",e.OF_TYPE="of-type",e.MISSING="missing"}(hi||(hi={}));const fi=[hi.CONTAINS,hi.EXACT,hi.TEXT,hi.NOT,hi.ABOVE,hi.BELOW,hi.IN,hi.NOT_IN,hi.OF_TYPE,hi.MISSING],yi=[hi.NOT_EQUALS,hi.GREATER_THAN,hi.LESS_THAN,hi.GREATER_THAN_OR_EQUALS,hi.LESS_THAN_OR_EQUALS,hi.STARTS_AFTER,hi.ENDS_BEFORE,hi.APPROXIMATELY];function gi(e){const t=new URL(e,"https://example.com/"),n=t.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let i,o,r,a,s,c;return new URLSearchParams(t.search).forEach(((e,t)=>{"_fields"===t?r=e.split(","):"_offset"===t?a=parseInt(e):"_count"===t?s=parseInt(e):"_total"===t?c=e:"_sort"===t?(o=o||[],o.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(e))):(i=i||[],i.push(function(e,t){let n=e,i=hi.EQUALS;for(const e of fi){const t=n.indexOf(":"+e);-1!==t&&(i=e,n=n.substring(0,t))}for(const e of yi)t.match(new RegExp("^"+e+"\\d"))&&(i=e,t=t.substring(e.length));return{code:n,operator:i,value:t}}(t,e)))})),{resourceType:n,filters:i,fields:r,offset:a,count:s,total:c,sortRules:o}}function xi(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=fi.includes(e.operator)?":"+e.operator:"",n=yi.includes(e.operator)?e.operator:"";return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))}var vi;function wi(e,t){var n,i;let o=null===(i=null===(n=_e.types[e])||void 0===n?void 0:n.searchParamsDetails)||void 0===i?void 0:i[t.code];return o||(o=function(e,t){var n,i,o,r,a,s,c;if("_lastUpdated"===t.code)return{columnName:"lastUpdated",type:vi.DATETIME};const d=t.code,l=function(e){return e.split("-").reduce(((e,t,n)=>e+(n?Z(t):t)),"")}(d),u=null===(n=Si(e,t.expression))||void 0===n?void 0:n.split(".");if(!u)return{columnName:l,type:vi.TEXT};const m=Ei(t);let p,h,f=e,y=!1;for(let n=1;n<u.length;n++){const d=u[n];if(p=null!==(r=null===(o=null===(i=_e.types[f])||void 0===i?void 0:i.properties)||void 0===o?void 0:o[d])&&void 0!==r?r:null===(s=null===(a=_e.types[f])||void 0===a?void 0:a.properties)||void 0===s?void 0:s[d+"[x]"],!p)throw new Error(`Element definition not found for ${e} ${t.code}`);if("*"===p.max&&(y=!0),h=null===(c=p.type)||void 0===c?void 0:c[0].code,!h)return{columnName:l,type:m,array:y};n<u.length-1&&("Element"===h||"BackboneElement"===h?f+=Z(d):f=h)}const g=Ei(t,h),x={columnName:l,type:g,elementDefinition:p,array:y};return function(e,t,n){const i=_e.types[e];i.searchParamsDetails||(i.searchParamsDetails={});i.searchParamsDetails[t]=n}(e,d,x),x}(e,t)),o}function Ei(e,t){let n=vi.TEXT;switch(e.type){case"date":n=t===Ae.dateTime||t===Ae.instant?vi.DATETIME:vi.DATE;break;case"number":n=vi.NUMBER;break;case"quantity":n=vi.QUANTITY;break;case"reference":n=vi.REFERENCE;break;case"token":"boolean"===t&&(n=vi.BOOLEAN)}return n}function Si(e,t){const n=t.split(" | ");for(const t of n){if((i=t).includes(" as Period")||i.includes(" as SampledDate"))continue;const n=bi(t);if(n.startsWith(e+"."))return n}var i}function bi(e){let t=e.trim();t.startsWith("(")&&t.endsWith(")")&&(t=t.substring(1,t.length-1)),t.includes("[0]")&&(t=t.replaceAll("[0]",""));const n=[" != "," as ",".as(",".exists(",".where("];for(const e of n)t.includes(e)&&(t=t.substring(0,t.indexOf(e)));return t}function Ti(e,t){if(t.resourceType!==e.resourceType)return!1;if(t.filters)for(const n of t.filters)if(!Di(e,t,n))return!1;return!0}function Di(e,t,n){var i,o;const r=null===(o=null===(i=_e.types[t.resourceType])||void 0===i?void 0:i.searchParams)||void 0===o?void 0:o[n.code];switch(null==r?void 0:r.type){case"reference":return function(e,t,n){const i=si(n.expression,e),o=Ri(t.operator);if(""===t.value&&0===i.length)return t.operator===hi.EQUALS;const r=i.map((e=>"string"==typeof e?e:e.reference));for(const e of t.value.split(",")){let n=r.includes(e);if(n||"_compartment"!==t.code||(n=r.some((t=>null==t?void 0:t.endsWith("/"+e)))),n)return!o}return o}(e,n,r);case"string":return Ci(e,n,r);case"token":return function(e,t,n){const i=wi(e.resourceType,n);return i.type===vi.BOOLEAN?function(e,t,n){const i=si(n.expression,e),o="true"===t.value,r=i.includes(o);return Ri(t.operator)?!r:r}(e,t,n):Ci(e,t,n)}(e,n,r);case"date":return function(e,t,n){const i=si(n.expression,e),o=t.value.split(","),r=Ri(t.operator);for(const e of i)for(const n of o){if(Ai(e,t.operator,n))return!r}return r}(e,n,r)}return!1}function Ci(e,t,n){const i=si(n.expression,e),o=t.value.split(","),r=Ri(t.operator);for(const e of i)for(const n of o){if(Pi(e,t.operator,n))return!r}return r}function Pi(e,t,n){let i="";return e&&("string"==typeof e?i=e:"object"==typeof e&&(i=JSON.stringify(e))),i.toLowerCase().includes(n.toLowerCase())}function Ai(e,t,n){switch(t){case hi.STARTS_AFTER:case hi.GREATER_THAN:return e>n;case hi.GREATER_THAN_OR_EQUALS:return e>=n;case hi.ENDS_BEFORE:case hi.LESS_THAN:return e<n;case hi.LESS_THAN_OR_EQUALS:return e<=n;case hi.EQUALS:case hi.NOT_EQUALS:return e===n}return!1}function Ri(e){return e===hi.NOT_EQUALS||e===hi.NOT}!function(e){e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.QUANTITY="QUANTITY",e.TEXT="TEXT",e.REFERENCE="REFERENCE",e.DATE="DATE",e.DATETIME="DATETIME",e.PERIOD="PERIOD"}(vi||(vi={}));const ki="ok",Mi="created",Oi="gone",Ii="not-modified",Ui="not-found",Li="unauthorized",ji="forbidden",Ni="too-many-requests",_i={resourceType:"OperationOutcome",id:ki,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},Qi={resourceType:"OperationOutcome",id:Mi,issue:[{severity:"information",code:"informational",details:{text:"Created"}}]},Wi={resourceType:"OperationOutcome",id:Ii,issue:[{severity:"information",code:"informational",details:{text:"Not Modified"}}]},Bi={resourceType:"OperationOutcome",id:Ui,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},qi={resourceType:"OperationOutcome",id:Li,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},$i={resourceType:"OperationOutcome",id:ji,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]},Fi={resourceType:"OperationOutcome",id:Oi,issue:[{severity:"error",code:"deleted",details:{text:"Gone"}}]},Hi={resourceType:"OperationOutcome",id:Ni,issue:[{severity:"error",code:"throttled",details:{text:"Too Many Requests"}}]};function zi(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}}function Gi(e){return e.id===ki||e.id===Mi||e.id===Ii}function Vi(e){return e.id===Ui}function Xi(e){return e.id===Oi}function Yi(e){return e.id===ki?200:e.id===Mi?201:e.id===Ii?304:e.id===Li?401:e.id===ji?403:e.id===Ui?404:e.id===Oi?410:e.id===Ni?429:400}function Ji(e,t){if(!Gi(e)||void 0===t)throw new Zi(e)}class Zi extends Error{constructor(e){var t,n;super(null===(n=null===(t=null==e?void 0:e.issue)||void 0===t?void 0:t[0].details)||void 0===n?void 0:n.text),this.outcome=e}}function Ki(e){var t,n,i,o;if(!e)return"Unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message;if("object"==typeof e&&"resourceType"in e){return null!==(o=null===(i=null===(n=null===(t=e.issue)||void 0===t?void 0:t[0])||void 0===n?void 0:n.details)||void 0===i?void 0:i.text)&&void 0!==o?o:"Unknown error"}return JSON.stringify(e)}export{qn as AndAtom,Mn as ArithemticOperatorAtom,kn as AsAtom,On as ConcatAtom,In as ContainsAtom,pi as DEFAULT_SEARCH_COUNT,Ln as DotAtom,An as EmptySetAtom,Nn as EqualsAtom,Qn as EquivalentAtom,Jn as FHIRPATH_KEYWORDS,Zn as FHIRPATH_OPERATORS,Dn as FhirPathAtom,Hn as FunctionAtom,di as Hl7Context,mi as Hl7Field,li as Hl7Message,ui as Hl7Segment,Un as InAtom,zn as IndexerAtom,Bn as IsAtom,s as LRUCache,Cn as LiteralAtom,gt as MEDPLUM_VERSION,xt as MedplumClient,_n as NotEqualsAtom,Wn as NotEquivalentAtom,Zi as OperationOutcomeError,hi as Operator,$n as OrAtom,Ae as PropertyType,De as ReadablePromise,vi as SearchParameterType,Pn as SymbolAtom,Rn as UnaryOperatorAtom,jn as UnionAtom,Fn as XorAtom,_i as allOk,J as arrayBufferToBase64,Y as arrayBufferToHex,Ji as assertOk,zi as badRequest,Et as booleanToTypedValue,Le as buildTypeName,L as calculateAge,j as calculateAgeString,Z as capitalize,P as createReference,ke as createSchema,Qi as created,H as deepClone,F as deepEquals,si as evalFhirPath,ci as evalFhirPathTyped,At as fhirPathArrayEquals,kt as fhirPathArrayEquivalent,Rt as fhirPathEquals,Mt as fhirPathEquivalent,It as fhirPathIs,Pt as fhirPathNot,ne as findObservationInterval,ie as findObservationReferenceRange,$i as forbidden,c as formatAddress,b as formatCodeableConcept,T as formatCoding,p as formatDate,f as formatDateTime,u as formatFamilyName,l as formatGivenName,d as formatHumanName,D as formatObservationValue,y as formatPeriod,S as formatQuantity,E as formatRange,xi as formatSearchQuery,h as formatTime,w as formatTiming,ee as getCodeBySystem,U as getDateProperty,M as getDisplayString,Ne as getElementDefinition,Si as getExpressionForResourceType,W as getExtensionValue,Q as getIdentifier,O as getImageSrc,je as getPropertyDisplayName,N as getQuestionnaireAnswers,A as getReferenceString,wi as getSearchParameterDetails,Yi as getStatus,Tt as getTypedPropertyValue,_e as globalSchema,Fi as gone,Ue as indexSearchParameter,Ie as indexSearchParameterBundle,Oe as indexStructureDefinition,Me as indexStructureDefinitionBundle,oi as initFhirPathParserBuilder,$ as isEmpty,Xi as isGone,K as isLowerCase,Vi as isNotFound,G as isObject,Gi as isOk,Ut as isPeriod,k as isProfileResource,Lt as isQuantity,jt as isQuantityEquivalent,V as isStringArray,z as isUUID,m as isValidDate,re as matchesRange,Ti as matchesSearchRequest,Ki as normalizeErrorString,Bi as notFound,Wi as notModified,ai as parseFhirPath,Te as parseJWTPayload,gi as parseSearchDefinition,se as preciseEquals,de as preciseGreaterThan,ue as preciseGreaterThanOrEquals,ce as preciseLessThan,le as preciseLessThanOrEquals,ae as preciseRound,Ct as removeDuplicates,R as resolveId,te as setCodeBySystem,B as stringify,bt as toJsBoolean,St as toTypedValue,Kn as tokenize,Hi as tooManyRequests,qi as unauthorized};
2
- //# sourceMappingURL=index.min.js.map