@medplum/core 2.0.3 → 2.0.5

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 (82) hide show
  1. package/dist/cjs/index.cjs +477 -209
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.min.cjs +1 -1
  4. package/dist/esm/client.mjs +18 -21
  5. package/dist/esm/client.mjs.map +1 -1
  6. package/dist/esm/index.min.mjs +1 -1
  7. package/dist/esm/index.mjs +6 -5
  8. package/dist/esm/index.mjs.map +1 -1
  9. package/dist/esm/outcomes.mjs +17 -2
  10. package/dist/esm/outcomes.mjs.map +1 -1
  11. package/dist/esm/{searchparams.mjs → search/details.mjs} +9 -11
  12. package/dist/esm/search/details.mjs.map +1 -0
  13. package/dist/esm/{match.mjs → search/match.mjs} +16 -11
  14. package/dist/esm/search/match.mjs.map +1 -0
  15. package/dist/esm/search/parse.mjs +218 -0
  16. package/dist/esm/search/parse.mjs.map +1 -0
  17. package/dist/esm/{search.mjs → search/search.mjs} +0 -3
  18. package/dist/esm/search/search.mjs.map +1 -0
  19. package/dist/esm/types.mjs +63 -25
  20. package/dist/esm/types.mjs.map +1 -1
  21. package/dist/{esm → types}/client.d.ts +5 -3
  22. package/dist/{esm → types}/index.d.ts +4 -3
  23. package/dist/{esm → types}/outcomes.d.ts +7 -1
  24. package/dist/types/search/parse.d.ts +17 -0
  25. package/dist/{cjs → types}/types.d.ts +30 -7
  26. package/package.json +4 -4
  27. package/tsconfig.build.json +9 -0
  28. package/dist/cjs/client.d.ts +0 -1216
  29. package/dist/cjs/index.d.ts +0 -13
  30. package/dist/cjs/outcomes.d.ts +0 -31
  31. package/dist/esm/cache.d.ts +0 -34
  32. package/dist/esm/crypto.d.ts +0 -9
  33. package/dist/esm/eventtarget.d.ts +0 -13
  34. package/dist/esm/fhirlexer/index.d.ts +0 -2
  35. package/dist/esm/fhirlexer/parse.d.ts +0 -47
  36. package/dist/esm/fhirlexer/tokenize.d.ts +0 -14
  37. package/dist/esm/fhirmapper/parse.d.ts +0 -7
  38. package/dist/esm/fhirmapper/tokenize.d.ts +0 -2
  39. package/dist/esm/fhirpath/atoms.d.ts +0 -120
  40. package/dist/esm/fhirpath/date.d.ts +0 -1
  41. package/dist/esm/fhirpath/functions.d.ts +0 -6
  42. package/dist/esm/fhirpath/index.d.ts +0 -4
  43. package/dist/esm/fhirpath/parse.d.ts +0 -64
  44. package/dist/esm/fhirpath/tokenize.d.ts +0 -4
  45. package/dist/esm/fhirpath/utils.d.ts +0 -95
  46. package/dist/esm/format.d.ts +0 -118
  47. package/dist/esm/hl7.d.ts +0 -136
  48. package/dist/esm/jwt.d.ts +0 -5
  49. package/dist/esm/match.d.ts +0 -9
  50. package/dist/esm/match.mjs.map +0 -1
  51. package/dist/esm/readablepromise.d.ts +0 -48
  52. package/dist/esm/search.d.ts +0 -66
  53. package/dist/esm/search.mjs.map +0 -1
  54. package/dist/esm/searchparams.d.ts +0 -33
  55. package/dist/esm/searchparams.mjs.map +0 -1
  56. package/dist/esm/storage.d.ts +0 -47
  57. package/dist/esm/types.d.ts +0 -177
  58. package/dist/esm/utils.d.ts +0 -259
  59. /package/dist/{cjs → types}/cache.d.ts +0 -0
  60. /package/dist/{cjs → types}/crypto.d.ts +0 -0
  61. /package/dist/{cjs → types}/eventtarget.d.ts +0 -0
  62. /package/dist/{cjs → types}/fhirlexer/index.d.ts +0 -0
  63. /package/dist/{cjs → types}/fhirlexer/parse.d.ts +0 -0
  64. /package/dist/{cjs → types}/fhirlexer/tokenize.d.ts +0 -0
  65. /package/dist/{cjs → types}/fhirmapper/parse.d.ts +0 -0
  66. /package/dist/{cjs → types}/fhirmapper/tokenize.d.ts +0 -0
  67. /package/dist/{cjs → types}/fhirpath/atoms.d.ts +0 -0
  68. /package/dist/{cjs → types}/fhirpath/date.d.ts +0 -0
  69. /package/dist/{cjs → types}/fhirpath/functions.d.ts +0 -0
  70. /package/dist/{cjs → types}/fhirpath/index.d.ts +0 -0
  71. /package/dist/{cjs → types}/fhirpath/parse.d.ts +0 -0
  72. /package/dist/{cjs → types}/fhirpath/tokenize.d.ts +0 -0
  73. /package/dist/{cjs → types}/fhirpath/utils.d.ts +0 -0
  74. /package/dist/{cjs → types}/format.d.ts +0 -0
  75. /package/dist/{cjs → types}/hl7.d.ts +0 -0
  76. /package/dist/{cjs → types}/jwt.d.ts +0 -0
  77. /package/dist/{cjs → types}/readablepromise.d.ts +0 -0
  78. /package/dist/{cjs/searchparams.d.ts → types/search/details.d.ts} +0 -0
  79. /package/dist/{cjs → types/search}/match.d.ts +0 -0
  80. /package/dist/{cjs → types/search}/search.d.ts +0 -0
  81. /package/dist/{cjs → types}/storage.d.ts +0 -0
  82. /package/dist/{cjs → types}/utils.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../node_modules/tslib/tslib.es6.js","../../src/cache.ts","../../src/format.ts","../../src/utils.ts","../../src/crypto.ts","../../src/eventtarget.ts","../../src/jwt.ts","../../src/outcomes.ts","../../src/readablepromise.ts","../../src/storage.ts","../../src/types.ts","../../src/client.ts","../../src/fhirlexer/parse.ts","../../src/fhirlexer/tokenize.ts","../../src/fhirpath/date.ts","../../src/fhirpath/utils.ts","../../src/fhirpath/functions.ts","../../src/fhirpath/atoms.ts","../../src/fhirpath/tokenize.ts","../../src/fhirpath/parse.ts","../../src/hl7.ts","../../src/search.ts","../../src/searchparams.ts","../../src/match.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.push(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.push(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * LRU cache (least recently used)\n * Source: https://stackoverflow.com/a/46432113\n */\nexport class LRUCache<T> {\n readonly #max: number;\n readonly #cache: Map<string, T>;\n\n constructor(max = 10) {\n this.#max = max;\n this.#cache = new Map();\n }\n\n /**\n * Deletes all values from the cache.\n */\n clear(): void {\n this.#cache.clear();\n }\n\n /**\n * Returns the value for the given key.\n * @param key The key to retrieve.\n * @returns The value if found; undefined otherwise.\n */\n get(key: string): T | undefined {\n const item = this.#cache.get(key);\n if (item) {\n this.#cache.delete(key);\n this.#cache.set(key, item);\n }\n return item;\n }\n\n /**\n * Sets the value for the given key.\n * @param key The key to set.\n * @param val The value to set.\n */\n set(key: string, val: T): void {\n if (this.#cache.has(key)) {\n this.#cache.delete(key);\n } else if (this.#cache.size >= this.#max) {\n this.#cache.delete(this.#first());\n }\n this.#cache.set(key, val);\n }\n\n /**\n * Deletes the value for the given key.\n * @param key The key to delete.\n */\n delete(key: string): void {\n this.#cache.delete(key);\n }\n\n /**\n * Returns the list of all keys in the cache.\n * @returns The array of keys in the cache.\n */\n keys(): IterableIterator<string> {\n return this.#cache.keys();\n }\n\n #first(): string {\n // This works because the Map class maintains ordered keys.\n return this.#cache.keys().next().value;\n }\n}\n","import {\n Address,\n CodeableConcept,\n Coding,\n HumanName,\n Money,\n Observation,\n ObservationComponent,\n Period,\n Quantity,\n Range,\n Timing,\n} from '@medplum/fhirtypes';\nimport { capitalize } from './utils';\n\nexport interface AddressFormatOptions {\n all?: boolean;\n use?: boolean;\n lineSeparator?: string;\n}\n\nexport interface HumanNameFormatOptions {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n}\n\n/**\n * Formats a FHIR Address as a string.\n * @param address The address to format.\n * @param options Optional address format options.\n * @returns The formatted address string.\n */\nexport function formatAddress(address: Address, options?: AddressFormatOptions): string {\n const builder = [];\n\n if (address.line) {\n builder.push(...address.line);\n }\n\n if (address.city || address.state || address.postalCode) {\n const cityStateZip = [];\n if (address.city) {\n cityStateZip.push(address.city);\n }\n if (address.state) {\n cityStateZip.push(address.state);\n }\n if (address.postalCode) {\n cityStateZip.push(address.postalCode);\n }\n builder.push(cityStateZip.join(', '));\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(options?.lineSeparator || ', ').trim();\n}\n\n/**\n * Formats a FHIR HumanName as a string.\n * @param name The name to format.\n * @param options Optional name format options.\n * @returns The formatted name string.\n */\nexport function formatHumanName(name: HumanName, options?: HumanNameFormatOptions): string {\n const builder = [];\n\n if (name.prefix && options?.prefix !== false) {\n builder.push(...name.prefix);\n }\n\n if (name.given) {\n builder.push(...name.given);\n }\n\n if (name.family) {\n builder.push(name.family);\n }\n\n if (name.suffix && options?.suffix !== false) {\n builder.push(...name.suffix);\n }\n\n if (name.use && (options?.all || options?.use)) {\n builder.push('[' + name.use + ']');\n }\n\n return builder.join(' ').trim();\n}\n\n/**\n * Formats the given name portion of a FHIR HumanName element.\n * @param name The name to format.\n * @returns The formatted given name string.\n */\nexport function formatGivenName(name: HumanName): string {\n const builder: string[] = [];\n if (name.given) {\n builder.push(...name.given);\n }\n return builder.join(' ').trim();\n}\n\n/**\n * Formats the family name portion of a FHIR HumanName element.\n * @param name The name to format.\n * @returns The formatted family name string.\n */\nexport function formatFamilyName(name: HumanName): string {\n return name.family || '';\n}\n\n/**\n * Returns true if the given date object is a valid date.\n * Dates can be invalid if created by parsing an invalid string.\n * @param date A date object.\n * @returns Returns true if the date is a valid date.\n */\nexport function isValidDate(date: Date): boolean {\n return date instanceof Date && !isNaN(date.getTime());\n}\n\n/**\n * Formats a FHIR date string as a human readable string.\n * Handles missing values and invalid dates.\n * @param date The date to format.\n * @param locales Optional locales.\n * @param options Optional date format options.\n * @returns The formatted date string.\n */\nexport function formatDate(\n date: string | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!date) {\n return '';\n }\n const d = new Date(date);\n if (!isValidDate(d)) {\n return '';\n }\n d.setUTCHours(0, 0, 0, 0);\n return d.toLocaleDateString(locales, { timeZone: 'UTC', ...options });\n}\n\n/**\n * Formats a FHIR time string as a human readable string.\n * Handles missing values and invalid dates.\n * @param time The date to format.\n * @param locales Optional locales.\n * @param options Optional time format options.\n * @returns The formatted time string.\n */\nexport function formatTime(\n time: string | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!time) {\n return '';\n }\n const d = new Date('2000-01-01T' + time + 'Z');\n if (!isValidDate(d)) {\n return '';\n }\n return d.toLocaleTimeString(locales, options);\n}\n\n/**\n * Formats a FHIR dateTime string as a human readable string.\n * Handles missing values and invalid dates.\n * @param dateTime The dateTime to format.\n * @param locales Optional locales.\n * @param options Optional dateTime format options.\n * @returns The formatted dateTime string.\n */\nexport function formatDateTime(\n dateTime: string | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!dateTime) {\n return '';\n }\n const d = new Date(dateTime);\n if (!isValidDate(d)) {\n return '';\n }\n return d.toLocaleString(locales, options);\n}\n\n/**\n * Formats a FHIR Period as a human readable string.\n * @param period The period to format.\n * @param locales Optional locales.\n * @param options Optional period format options.\n * @returns The formatted period string.\n */\nexport function formatPeriod(\n period: Period | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!period || (!period.start && !period.end)) {\n return '';\n }\n return formatDateTime(period.start, locales, options) + ' - ' + formatDateTime(period.end, locales, options);\n}\n\nconst unitAdverbForm: Record<string, string> = {\n s: 'every second',\n min: 'every minute',\n h: 'hourly',\n d: 'daily',\n wk: 'weekly',\n mo: 'monthly',\n a: 'annually',\n};\n\nconst singularUnits: Record<string, string> = {\n s: 'second',\n min: 'minute',\n h: 'hour',\n d: 'day',\n wk: 'week',\n mo: 'month',\n a: 'year',\n};\n\nconst pluralUnits: Record<string, string> = {\n s: 'seconds',\n min: 'minutes',\n h: 'hours',\n d: 'days',\n wk: 'weeks',\n mo: 'months',\n a: 'years',\n};\n\n/**\n * Formats a FHIR Timing as a human readable string.\n * @param timing The timing to format.\n * @returns The formatted timing string.\n */\nexport function formatTiming(timing: Timing | undefined): string {\n if (!timing) {\n return '';\n }\n\n const builder: string[] = [];\n\n if (timing.repeat?.periodUnit) {\n const frequency = timing.repeat.frequency || 1;\n const period = timing.repeat.period || 1;\n const periodUnit = timing.repeat.periodUnit;\n\n if (frequency === 1 && period === 1) {\n builder.push(unitAdverbForm[periodUnit]);\n } else {\n if (frequency === 1) {\n builder.push('once');\n } else {\n builder.push(frequency + ' times');\n }\n\n if (period === 1) {\n builder.push('per ' + singularUnits[periodUnit]);\n } else {\n builder.push('per ' + period + ' ' + pluralUnits[periodUnit]);\n }\n }\n\n if (timing.repeat.dayOfWeek) {\n builder.push('on ' + timing.repeat.dayOfWeek.map(capitalize).join(', '));\n }\n\n if (timing.repeat.timeOfDay) {\n builder.push('at ' + timing.repeat.timeOfDay.map((t) => formatTime(t)).join(', '));\n }\n }\n\n if (timing.event) {\n builder.push(timing.event.map((d) => formatDateTime(d)).join(', '));\n }\n\n return capitalize(builder.join(' ').trim());\n}\n\n/**\n * Returns a human-readable string for a FHIR Range datatype, taking into account comparators and one-sided ranges\n * @param range A FHIR Range element\n * @param exclusive If true, one-sided ranges will be rendered with the '>' or '<' bounds rather than '>=' or '<='\n * @returns A human-readable string representation of the Range\n */\nexport function formatRange(range: Range | undefined, precision?: number, exclusive = false): string {\n if (exclusive && precision === undefined) {\n throw new Error('Precision must be specified for exclusive ranges');\n }\n\n const low = range?.low && { ...range.low };\n const high = range?.high && { ...range.high };\n if (!range || (low?.value === undefined && high?.value === undefined)) {\n return '';\n }\n\n if (range.low?.value !== undefined && range.high?.value === undefined) {\n if (exclusive && precision !== undefined) {\n range.low.value = preciseDecrement(range.low.value, precision);\n return `> ${formatQuantity(range.low, precision)}`;\n }\n return `>= ${formatQuantity(range.low, precision)}`;\n }\n\n if (range.low?.value === undefined && range.high?.value !== undefined) {\n if (exclusive && precision !== undefined) {\n range.high.value = preciseIncrement(range.high.value, precision);\n return `< ${formatQuantity(range.high, precision)}`;\n }\n return `<= ${formatQuantity(range.high, precision)}`;\n }\n\n if (low?.unit === high?.unit) {\n delete low?.unit;\n }\n return `${formatQuantity(low, precision)} - ${formatQuantity(high, precision)}`;\n}\n\n/**\n * Returns a human-readable string for a FHIR Quantity datatype, taking into account units and comparators\n * @param quantity A FHIR Quantity element\n * @returns A human-readable string representation of the Quantity\n */\nexport function formatQuantity(quantity: Quantity | undefined, precision?: number): string {\n if (!quantity) {\n return '';\n }\n\n const result = [];\n\n if (quantity.comparator) {\n result.push(quantity.comparator);\n result.push(' ');\n }\n\n if (quantity.value !== undefined) {\n if (precision !== undefined) {\n result.push(quantity.value.toFixed(precision));\n } else {\n result.push(quantity.value);\n }\n }\n\n if (quantity.unit) {\n if (quantity.unit !== '%' && result[result.length - 1] !== ' ') {\n result.push(' ');\n }\n result.push(quantity.unit);\n }\n\n return result.join('').trim();\n}\n\nexport function formatMoney(money: Money | undefined): string {\n if (money?.value === undefined) {\n return '';\n }\n\n return money.value.toLocaleString(undefined, {\n style: 'currency',\n currency: money.currency || 'USD',\n currencyDisplay: 'narrowSymbol',\n });\n}\n\n/**\n * Formats a CodeableConcept element as a string.\n * @param codeableConcept A FHIR CodeableConcept element\n * @returns The codeable concept as a string.\n */\nexport function formatCodeableConcept(codeableConcept: CodeableConcept | undefined): string {\n if (!codeableConcept) {\n return '';\n }\n if (codeableConcept.text) {\n return codeableConcept.text;\n }\n if (codeableConcept.coding) {\n return codeableConcept.coding.map((c) => formatCoding(c)).join(', ');\n }\n return '';\n}\n\n/**\n * Formats a Coding element as a string.\n * @param coding A FHIR Coding element\n * @returns The coding as a string.\n */\nexport function formatCoding(coding: Coding | undefined): string {\n return coding?.display || coding?.code || '';\n}\n\n/**\n * Formats a FHIR Observation resource value as a string.\n * @param obs A FHIR Observation resource.\n * @returns A human-readable string representation of the Observation.\n */\nexport function formatObservationValue(obs: Observation | ObservationComponent | undefined): string {\n if (!obs) {\n return '';\n }\n\n if ('component' in obs) {\n return (obs.component as ObservationComponent[]).map((c) => formatObservationValue(c)).join(' / ');\n }\n\n if (obs?.valueQuantity) {\n return formatQuantity(obs.valueQuantity);\n }\n\n if (obs.valueCodeableConcept) {\n return formatCodeableConcept(obs.valueCodeableConcept);\n }\n\n if (obs.valueString) {\n return obs.valueString;\n }\n\n return '';\n}\n\n/**\n * Returns the input number increased by the `n` units of the specified precision\n * @param a The input number\n * @param precision The precision in number of digits.\n * @param n (default 1) The number of units to add\n */\nfunction preciseIncrement(a: number, precision: number, n = 1): number {\n return (toPreciseInteger(a, precision) + n) * Math.pow(10, -precision);\n}\n\n/**\n * Returns the input number decreased by the `n` units of the specified precision\n * @param a The input number\n * @param precision The precision in number of digits.\n * @param n (default 1) The number of units to subtract\n */\nfunction preciseDecrement(a: number, precision: number, n = 1): number {\n return (toPreciseInteger(a, precision) - n) * Math.pow(10, -precision);\n}\n\n/**\n * Returns an integer representation of the number with the given precision.\n * For example, if precision is 2, then 1.2345 will be returned as 123.\n * @param a The number.\n * @param precision Optional precision in number of digits.\n * @returns The integer with the given precision.\n */\nfunction toPreciseInteger(a: number, precision?: number): number {\n if (precision === undefined) {\n return a;\n }\n return Math.round(a * Math.pow(10, precision));\n}\n","import {\n Attachment,\n CodeableConcept,\n Device,\n Extension,\n Identifier,\n ObservationDefinition,\n ObservationDefinitionQualifiedInterval,\n Patient,\n Practitioner,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer,\n Range,\n Reference,\n RelatedPerson,\n Resource,\n} from '@medplum/fhirtypes';\nimport { formatHumanName } from './format';\n\n/**\n * @internal\n */\nexport type ProfileResource = Patient | Practitioner | RelatedPerson;\n\n/**\n * Creates a reference resource.\n * @param resource The FHIR reesource.\n * @returns A reference resource.\n */\nexport function createReference<T extends Resource>(resource: T): Reference<T> {\n const reference = getReferenceString(resource);\n const display = getDisplayString(resource);\n return display === reference ? { reference } : { reference, display };\n}\n\n/**\n * Returns a reference string for a resource.\n * @param resource The FHIR resource.\n * @returns A reference string of the form resourceType/id.\n */\nexport function getReferenceString(resource: Resource): string {\n return resource.resourceType + '/' + resource.id;\n}\n\n/**\n * Returns the ID portion of a reference.\n * @param reference A FHIR reference.\n * @returns The ID portion of a reference.\n */\nexport function resolveId(reference: Reference | undefined): string | undefined {\n return reference?.reference?.split('/')[1];\n}\n\n/**\n * Returns true if the resource is a \"ProfileResource\".\n * @param resource The FHIR resource.\n * @returns True if the resource is a \"ProfileResource\".\n */\nexport function isProfileResource(resource: Resource): resource is ProfileResource {\n return (\n resource.resourceType === 'Patient' ||\n resource.resourceType === 'Practitioner' ||\n resource.resourceType === 'RelatedPerson'\n );\n}\n\n/**\n * Returns a display string for the resource.\n * @param resource The input resource.\n * @return Human friendly display string.\n */\nexport function getDisplayString(resource: Resource): string {\n if (isProfileResource(resource)) {\n const profileName = getProfileResourceDisplayString(resource);\n if (profileName) {\n return profileName;\n }\n }\n if (resource.resourceType === 'Device') {\n const deviceName = getDeviceDisplayString(resource);\n if (deviceName) {\n return deviceName;\n }\n }\n if (resource.resourceType === 'Observation') {\n if ('code' in resource && resource.code?.text) {\n return resource.code.text;\n }\n }\n if (resource.resourceType === 'User') {\n if (resource.email) {\n return resource.email;\n }\n }\n if ('name' in resource && resource.name && typeof resource.name === 'string') {\n return resource.name;\n }\n return getReferenceString(resource);\n}\n\n/**\n * Returns a display string for a profile resource if one is found.\n * @param resource The profile resource.\n * @returns The display name if one is found.\n */\nfunction getProfileResourceDisplayString(resource: ProfileResource): string | undefined {\n const names = resource.name;\n if (names && names.length > 0) {\n return formatHumanName(names[0]);\n }\n return undefined;\n}\n\n/**\n * Returns a display string for a device resource if one is found.\n * @param device The device resource.\n * @returns The display name if one is found.\n */\nfunction getDeviceDisplayString(device: Device): string | undefined {\n const names = device.deviceName;\n if (names && names.length > 0) {\n return names[0].name;\n }\n return undefined;\n}\n\n/**\n * Returns an image URL for the resource, if one is available.\n * @param resource The input resource.\n * @returns The image URL for the resource or undefined.\n */\nexport function getImageSrc(resource: Resource): string | undefined {\n if (!('photo' in resource)) {\n return undefined;\n }\n\n const photo = resource.photo;\n if (!photo) {\n return undefined;\n }\n\n if (Array.isArray(photo)) {\n for (const p of photo) {\n const url = getPhotoImageSrc(p);\n if (url) {\n return url;\n }\n }\n } else {\n return getPhotoImageSrc(photo);\n }\n\n return undefined;\n}\n\nfunction getPhotoImageSrc(photo: Attachment): string | undefined {\n if (photo.url && photo.contentType && photo.contentType.startsWith('image/')) {\n return photo.url;\n }\n return undefined;\n}\n\n/**\n * Returns a Date property as a Date.\n * When working with JSON objects, Dates are often serialized as ISO-8601 strings.\n * When that happens, we need to safely convert to a proper Date object.\n * @param date The date property value, which could be a string or a Date object.\n * @returns A Date object.\n */\nexport function getDateProperty(date: string | undefined): Date | undefined {\n return date ? new Date(date) : undefined;\n}\n\n/**\n * Calculates the age in years from the birth date.\n * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.\n * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.\n * @returns The age in years, months, and days.\n */\nexport function calculateAge(\n birthDateStr: string,\n endDateStr?: string\n): { years: number; months: number; days: number } {\n const startDate = new Date(birthDateStr);\n startDate.setUTCHours(0, 0, 0, 0);\n\n const endDate = endDateStr ? new Date(endDateStr) : new Date();\n endDate.setUTCHours(0, 0, 0, 0);\n\n const startYear = startDate.getUTCFullYear();\n const startMonth = startDate.getUTCMonth();\n const startDay = startDate.getUTCDate();\n\n const endYear = endDate.getUTCFullYear();\n const endMonth = endDate.getUTCMonth();\n const endDay = endDate.getUTCDate();\n\n let years = endYear - startYear;\n if (endMonth < startMonth || (endMonth === startMonth && endDay < startDay)) {\n years--;\n }\n\n let months = endYear * 12 + endMonth - (startYear * 12 + startMonth);\n if (endDay < startDay) {\n months--;\n }\n\n const days = Math.floor((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));\n\n return { years, months, days };\n}\n\n/**\n * Calculates the age string for display using the age appropriate units.\n * If the age is greater than or equal to 2 years, then the age is displayed in years.\n * If the age is greater than or equal to 1 month, then the age is displayed in months.\n * Otherwise, the age is displayed in days.\n * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.\n * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.\n * @returns The age string.\n */\nexport function calculateAgeString(birthDateStr: string, endDateStr?: string): string | undefined {\n const { years, months, days } = calculateAge(birthDateStr, endDateStr);\n if (years >= 2) {\n return years.toString().padStart(3, '0') + 'Y';\n } else if (months >= 1) {\n return months.toString().padStart(3, '0') + 'M';\n } else {\n return days.toString().padStart(3, '0') + 'D';\n }\n}\n\n/**\n * Returns all questionnaire answers as a map by link ID.\n * @param response The questionnaire response resource.\n * @returns Questionnaire answers mapped by link ID.\n */\nexport function getQuestionnaireAnswers(\n response: QuestionnaireResponse\n): Record<string, QuestionnaireResponseItemAnswer> {\n const result: Record<string, QuestionnaireResponseItemAnswer> = {};\n buildQuestionnaireAnswerItems(response.item, result);\n return result;\n}\n\n/**\n * Recursively builds the questionnaire answer items map.\n * @param item The current questionnaire response item.\n * @param result The cumulative result map.\n */\nfunction buildQuestionnaireAnswerItems(\n items: QuestionnaireResponseItem[] | undefined,\n result: Record<string, QuestionnaireResponseItemAnswer>\n): void {\n if (items) {\n for (const item of items) {\n if (item.linkId && item.answer && item.answer.length > 0) {\n result[item.linkId] = item.answer[0];\n }\n buildQuestionnaireAnswerItems(item.item, result);\n }\n }\n}\n\n/**\n * Returns the resource identifier for the given system.\n *\n * If multiple identifiers exist with the same system, the first one is returned.\n *\n * If the system is not found, then returns undefined.\n *\n * @param resource The resource to check.\n * @param system The identifier system.\n * @returns The identifier value if found; otherwise undefined.\n */\nexport function getIdentifier(resource: Resource, system: string): string | undefined {\n const identifiers = (resource as any).identifier as Identifier[] | Identifier | undefined;\n if (!identifiers) {\n return undefined;\n }\n const array = Array.isArray(identifiers) ? identifiers : [identifiers];\n for (const identifier of array) {\n if (identifier.system === system) {\n return identifier.value;\n }\n }\n return undefined;\n}\n\n/**\n * Returns an extension value by extension URLs.\n * @param resource The base resource.\n * @param urls Array of extension URLs. Each entry represents a nested extension.\n * @returns The extension value if found; undefined otherwise.\n */\nexport function getExtensionValue(resource: any, ...urls: string[]): string | undefined {\n // Let curr be the current resource or extension. Extensions can be nested.\n let curr: any = resource;\n\n // For each of the urls, try to find a matching nested extension.\n for (let i = 0; i < urls.length && curr; i++) {\n curr = (curr?.extension as Extension[] | undefined)?.find((e) => e.url === urls[i]);\n }\n\n return curr?.valueString as string | undefined;\n}\n\n/**\n * Returns an extension by extension URLs.\n * @param resource The base resource.\n * @param urls Array of extension URLs. Each entry represents a nested extension.\n * @returns The extension object if found; undefined otherwise.\n */\nexport function getExtension(resource: any, ...urls: string[]): Extension | undefined {\n // Let curr be the current resource or extension. Extensions can be nested.\n let curr: any = resource;\n\n // For each of the urls, try to find a matching nested extension.\n for (let i = 0; i < urls.length && curr; i++) {\n curr = (curr?.extension as Extension[] | undefined)?.find((e) => e.url === urls[i]);\n }\n\n return curr as Extension | undefined;\n}\n\n/**\n * FHIR JSON stringify.\n * Removes properties with empty string values.\n * Removes objects with zero properties.\n * See: https://www.hl7.org/fhir/json.html\n * @param value The input value.\n * @param pretty Optional flag to pretty-print the JSON.\n * @returns The resulting JSON string.\n */\nexport function stringify(value: any, pretty?: boolean): string {\n return JSON.stringify(value, stringifyReplacer, pretty ? 2 : undefined);\n}\n\n/**\n * Evaluates JSON key/value pairs for FHIR JSON stringify.\n * Removes properties with empty string values.\n * Removes objects with zero properties.\n * @param {string} k Property key.\n * @param {*} v Property value.\n */\nfunction stringifyReplacer(k: string, v: any): any {\n return !isArrayKey(k) && isEmpty(v) ? undefined : v;\n}\n\n/**\n * Returns true if the key is an array key.\n * @param k The property key.\n * @returns True if the key is an array key.\n */\nfunction isArrayKey(k: string): boolean {\n return !!k.match(/\\d+$/);\n}\n\n/**\n * Returns true if the value is empty (null, undefined, empty string, or empty object).\n * @param v Any value.\n * @returns True if the value is an empty string or an empty object.\n */\nexport function isEmpty(v: any): boolean {\n if (v === null || v === undefined) {\n return true;\n }\n const t = typeof v;\n return (t === 'string' && v === '') || (t === 'object' && Object.keys(v).length === 0);\n}\n\n/**\n * Resource equality.\n * Ignores meta.versionId and meta.lastUpdated.\n * @param object1 The first object.\n * @param object2 The second object.\n * @returns True if the objects are equal.\n */\nexport function deepEquals(object1: unknown, object2: unknown, path?: string): boolean {\n if (object1 === object2) {\n return true;\n }\n if (isEmpty(object1) && isEmpty(object2)) {\n return true;\n }\n if (isEmpty(object1) || isEmpty(object2)) {\n return false;\n }\n if (Array.isArray(object1) && Array.isArray(object2)) {\n return deepEqualsArray(object1, object2);\n }\n if (Array.isArray(object1) || Array.isArray(object2)) {\n return false;\n }\n if (isObject(object1) && isObject(object2)) {\n return deepEqualsObject(object1, object2, path);\n }\n if (isObject(object1) || isObject(object2)) {\n return false;\n }\n return false;\n}\n\nfunction deepEqualsArray(array1: unknown[], array2: unknown[]): boolean {\n if (array1.length !== array2.length) {\n return false;\n }\n for (let i = 0; i < array1.length; i++) {\n if (!deepEquals(array1[i], array2[i])) {\n return false;\n }\n }\n return true;\n}\n\nfunction deepEqualsObject(\n object1: Record<string, unknown>,\n object2: Record<string, unknown>,\n path: string | undefined\n): boolean {\n const keySet = new Set<string>();\n Object.keys(object1).forEach((k) => keySet.add(k));\n Object.keys(object2).forEach((k) => keySet.add(k));\n if (path === 'meta') {\n keySet.delete('versionId');\n keySet.delete('lastUpdated');\n keySet.delete('author');\n }\n for (const key of keySet) {\n const val1 = object1[key];\n const val2 = object2[key];\n if (!deepEquals(val1, val2, key)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Creates a deep clone of the input value.\n *\n * Limitations:\n * - Only supports JSON primitives and arrays.\n * - Does not support Functions, lambdas, etc.\n * - Does not support circular references.\n *\n * See: https://web.dev/structured-clone/\n * See: https://stackoverflow.com/questions/40488190/how-is-structured-clone-algorithm-different-from-deep-copy\n *\n * @param input The input to clone.\n * @returns A deep clone of the input.\n */\nexport function deepClone<T>(input: T): T {\n return JSON.parse(JSON.stringify(input)) as T;\n}\n\n/**\n * Returns true if the input string is a UUID.\n * @param input The input string.\n * @returns True if the input string matches the UUID format.\n */\nexport function isUUID(input: string): boolean {\n return !!input.match(/^\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$/i);\n}\n\n/**\n * Returns true if the input is an object.\n * @param object The candidate object.\n * @returns True if the input is a non-null non-undefined object.\n */\nexport function isObject(obj: unknown): obj is Record<string, unknown> {\n return obj !== null && typeof obj === 'object';\n}\n\n/**\n * Returns true if the input array is an array of strings.\n * @param arr Input array.\n * @returns True if the input array is an array of strings.\n */\nexport function isStringArray(arr: any[]): arr is string[] {\n return arr.every((e) => typeof e === 'string');\n}\n\n// Precompute hex octets\n// See: https://stackoverflow.com/a/55200387\nconst byteToHex: string[] = [];\nfor (let n = 0; n < 256; n++) {\n byteToHex.push(n.toString(16).padStart(2, '0'));\n}\n\n/**\n * Converts an ArrayBuffer to hex string.\n * See: https://stackoverflow.com/a/55200387\n * @param arrayBuffer The input array buffer.\n * @returns The resulting hex string.\n */\nexport function arrayBufferToHex(arrayBuffer: ArrayBuffer): string {\n const bytes = new Uint8Array(arrayBuffer);\n const result: string[] = new Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n result[i] = byteToHex[bytes[i]];\n }\n return result.join('');\n}\n\n/**\n * Converts an ArrayBuffer to a base-64 encoded string.\n * @param arrayBuffer The input array buffer.\n * @returns The base-64 encoded string.\n */\nexport function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string {\n const bytes = new Uint8Array(arrayBuffer);\n const result: string[] = [];\n for (let i = 0; i < bytes.length; i++) {\n result[i] = String.fromCharCode(bytes[i]);\n }\n return window.btoa(result.join(''));\n}\n\nexport function capitalize(word: string): string {\n return word.charAt(0).toUpperCase() + word.substring(1);\n}\n\nexport function isLowerCase(c: string): boolean {\n return c === c.toLowerCase() && c !== c.toUpperCase();\n}\n\n/**\n * Tries to find a code string for a given system within a given codeable concept.\n * @param concept The codeable concept.\n * @param system The system string.\n * @returns The code if found; otherwise undefined.\n */\nexport function getCodeBySystem(concept: CodeableConcept, system: string): string | undefined {\n return concept?.coding?.find((coding) => coding.system === system)?.code;\n}\n\n/**\n * Sets a code for a given system within a given codeable concept.\n * @param concept The codeable concept.\n * @param system The system string.\n * @param code The code value.\n */\nexport function setCodeBySystem(concept: CodeableConcept, system: string, code: string): void {\n if (!concept.coding) {\n concept.coding = [];\n }\n const coding = concept.coding?.find((c) => c.system === system);\n if (coding) {\n coding.code = code;\n } else {\n concept.coding?.push({ system, code });\n }\n}\n\n/**\n * Tries to find an observation interval for the given patient and value.\n * @param definition The observation definition.\n * @param patient The patient.\n * @param value The observation value.\n * @returns The observation interval if found; otherwise undefined.\n */\nexport function findObservationInterval(\n definition: ObservationDefinition,\n patient: Patient,\n value: number,\n category?: 'reference' | 'critical' | 'absolute'\n): ObservationDefinitionQualifiedInterval | undefined {\n return definition.qualifiedInterval?.find(\n (interval) =>\n observationIntervalMatchesPatient(interval, patient) &&\n observationIntervalMatchesValue(interval, value, definition.quantitativeDetails?.decimalPrecision) &&\n (category === undefined || interval.category === category)\n );\n}\n\n/**\n * Tries to find an observation reference range for the given patient and condition names.\n * @param definition The observation definition.\n * @param patient The patient.\n * @param names The condition names.\n * @returns The observation interval if found; otherwise undefined.\n */\nexport function findObservationReferenceRange(\n definition: ObservationDefinition,\n patient: Patient,\n names: string[]\n): ObservationDefinitionQualifiedInterval | undefined {\n return definition.qualifiedInterval?.find(\n (interval) => observationIntervalMatchesPatient(interval, patient) && names.includes(interval.condition as string)\n );\n}\n\n/**\n * Returns true if the patient matches the observation interval.\n * @param interval The observation interval.\n * @param patient The patient.\n * @returns True if the patient matches the observation interval.\n */\nfunction observationIntervalMatchesPatient(\n interval: ObservationDefinitionQualifiedInterval,\n patient: Patient\n): boolean {\n return observationIntervalMatchesGender(interval, patient) && observationIntervalMatchesAge(interval, patient);\n}\n\n/**\n * Returns true if the patient gender matches the observation interval.\n * @param interval The observation interval.\n * @param patient The patient.\n * @returns True if the patient gender matches the observation interval.\n */\nfunction observationIntervalMatchesGender(interval: ObservationDefinitionQualifiedInterval, patient: Patient): boolean {\n return !interval.gender || interval.gender === patient.gender;\n}\n\n/**\n * Returns true if the patient age matches the observation interval.\n * @param interval The observation interval.\n * @param patient The patient.\n * @returns True if the patient age matches the observation interval.\n */\nfunction observationIntervalMatchesAge(interval: ObservationDefinitionQualifiedInterval, patient: Patient): boolean {\n return !interval.age || matchesRange(calculateAge(patient.birthDate as string).years, interval.age);\n}\n\n/**\n * Returns true if the value matches the observation interval.\n * @param interval The observation interval.\n * @param value The observation value.\n * @param precision Optional precision in number of digits.\n * @returns True if the value matches the observation interval.\n */\nfunction observationIntervalMatchesValue(\n interval: ObservationDefinitionQualifiedInterval,\n value: number,\n precision?: number\n): boolean {\n return !!interval.range && matchesRange(value, interval.range, precision);\n}\n\n/**\n * Returns true if the value is in the range accounting for precision.\n * @param value The numeric value.\n * @param range The numeric range.\n * @param precision Optional precision in number of digits.\n * @returns True if the value is within the range.\n */\nexport function matchesRange(value: number, range: Range, precision?: number): boolean {\n return (\n (range.low?.value === undefined || preciseGreaterThanOrEquals(value, range.low.value, precision)) &&\n (range.high?.value === undefined || preciseLessThanOrEquals(value, range.high.value, precision))\n );\n}\n\n/**\n * Returns the input number rounded to the specified number of digits.\n * @param a The input number.\n * @param precision The precision in number of digits.\n * @returns The number rounded to the specified number of digits.\n */\nexport function preciseRound(a: number, precision: number): number {\n return parseFloat(a.toFixed(precision));\n}\n\n/**\n * Returns true if the two numbers are equal to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the two numbers are equal to the given precision.\n */\nexport function preciseEquals(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) === toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is less than the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is less than the second number to the given precision.\n */\nexport function preciseLessThan(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) < toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is greater than the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is greater than the second number to the given precision.\n */\nexport function preciseGreaterThan(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) > toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is less than or equal to the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is less than or equal to the second number to the given precision.\n */\nexport function preciseLessThanOrEquals(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) <= toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is greater than or equal to the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is greater than or equal to the second number to the given precision.\n */\nexport function preciseGreaterThanOrEquals(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) >= toPreciseInteger(b, precision);\n}\n\n/**\n * Returns an integer representation of the number with the given precision.\n * For example, if precision is 2, then 1.2345 will be returned as 123.\n * @param a The number.\n * @param precision Optional precision in number of digits.\n * @returns The integer with the given precision.\n */\nfunction toPreciseInteger(a: number, precision?: number): number {\n if (precision === undefined) {\n return a;\n }\n return Math.round(a * Math.pow(10, precision));\n}\n","import { arrayBufferToHex } from './utils';\n\n/**\n * Returns a cryptographically secure random string.\n */\nexport function getRandomString(): string {\n const randomItems = new Uint32Array(28);\n crypto.getRandomValues(randomItems);\n return arrayBufferToHex(randomItems.buffer);\n}\n\n/**\n * Encrypts a string with SHA256 encryption.\n * @param str\n */\nexport async function encryptSHA256(str: string): Promise<ArrayBuffer> {\n return crypto.subtle.digest('SHA-256', new TextEncoder().encode(str));\n}\n","/*\n * Based on: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget\n */\n\ninterface Event {\n readonly type: string;\n readonly defaultPrevented?: boolean;\n}\n\ntype EventListener = (e: Event) => void;\n\nexport class EventTarget {\n readonly #listeners: Record<string, EventListener[]>;\n\n constructor() {\n this.#listeners = {};\n }\n\n addEventListener(type: string, callback: EventListener): void {\n if (!this.#listeners[type]) {\n this.#listeners[type] = [];\n }\n this.#listeners[type].push(callback);\n }\n\n removeEventListeneer(type: string, callback: EventListener): void {\n const array = this.#listeners[type];\n if (!array) {\n return;\n }\n for (let i = 0; i < array.length; i++) {\n if (array[i] === callback) {\n array.splice(i, 1);\n return;\n }\n }\n }\n\n dispatchEvent(event: Event): boolean {\n const array = this.#listeners[event.type];\n if (array) {\n array.forEach((listener) => listener.call(this, event));\n }\n return !event.defaultPrevented;\n }\n}\n","/**\n * Decodes a section of a JWT.\n * See: https://tools.ietf.org/html/rfc7519\n * @param payload\n */\nfunction decodePayload(payload: string): Record<string, number | string> {\n const cleanedPayload = payload.replace(/-/g, '+').replace(/_/g, '/');\n const decodedPayload = decodeBase64(cleanedPayload);\n const uriEncodedPayload = Array.from(decodedPayload).reduce((acc, char) => {\n const uriEncodedChar = ('00' + char.charCodeAt(0).toString(16)).slice(-2);\n return `${acc}%${uriEncodedChar}`;\n }, '');\n const jsonPayload = decodeURIComponent(uriEncodedPayload);\n return JSON.parse(jsonPayload);\n}\n\nfunction decodeBase64(data: string): string {\n if (typeof window !== 'undefined') {\n return window.atob(data);\n }\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(data, 'base64').toString('binary');\n }\n throw new Error('Unable to decode base64');\n}\n\n/**\n * Parses the JWT payload.\n * @param token JWT token\n */\nexport function parseJWTPayload(token: string): Record<string, number | string> {\n const [_header, payload, _signature] = token.split('.');\n return decodePayload(payload);\n}\n","import { OperationOutcome } from '@medplum/fhirtypes';\n\nconst OK_ID = 'ok';\nconst CREATED_ID = 'created';\nconst GONE_ID = 'gone';\nconst NOT_MODIFIED_ID = 'not-modified';\nconst NOT_FOUND_ID = 'not-found';\nconst UNAUTHORIZED_ID = 'unauthorized';\nconst FORBIDDEN_ID = 'forbidden';\nconst TOO_MANY_REQUESTS_ID = 'too-many-requests';\n\nexport const allOk: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: OK_ID,\n issue: [\n {\n severity: 'information',\n code: 'informational',\n details: {\n text: 'All OK',\n },\n },\n ],\n};\n\nexport const created: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: CREATED_ID,\n issue: [\n {\n severity: 'information',\n code: 'informational',\n details: {\n text: 'Created',\n },\n },\n ],\n};\n\nexport const notModified: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: NOT_MODIFIED_ID,\n issue: [\n {\n severity: 'information',\n code: 'informational',\n details: {\n text: 'Not Modified',\n },\n },\n ],\n};\n\nexport const notFound: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: NOT_FOUND_ID,\n issue: [\n {\n severity: 'error',\n code: 'not-found',\n details: {\n text: 'Not found',\n },\n },\n ],\n};\n\nexport const unauthorized: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: UNAUTHORIZED_ID,\n issue: [\n {\n severity: 'error',\n code: 'login',\n details: {\n text: 'Unauthorized',\n },\n },\n ],\n};\n\nexport const forbidden: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: FORBIDDEN_ID,\n issue: [\n {\n severity: 'error',\n code: 'forbidden',\n details: {\n text: 'Forbidden',\n },\n },\n ],\n};\n\nexport const gone: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: GONE_ID,\n issue: [\n {\n severity: 'error',\n code: 'deleted',\n details: {\n text: 'Gone',\n },\n },\n ],\n};\n\nexport const tooManyRequests: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: TOO_MANY_REQUESTS_ID,\n issue: [\n {\n severity: 'error',\n code: 'throttled',\n details: {\n text: 'Too Many Requests',\n },\n },\n ],\n};\n\nexport function badRequest(details: string, expression?: string): OperationOutcome {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n severity: 'error',\n code: 'invalid',\n details: {\n text: details,\n },\n expression: expression ? [expression] : undefined,\n },\n ],\n };\n}\n\nexport function isOperationOutcome(value: unknown): value is OperationOutcome {\n return typeof value === 'object' && value !== null && (value as any).resourceType === 'OperationOutcome';\n}\n\nexport function isOk(outcome: OperationOutcome): boolean {\n return outcome.id === OK_ID || outcome.id === CREATED_ID || outcome.id === NOT_MODIFIED_ID;\n}\n\nexport function isNotFound(outcome: OperationOutcome): boolean {\n return outcome.id === NOT_FOUND_ID;\n}\n\nexport function isGone(outcome: OperationOutcome): boolean {\n return outcome.id === GONE_ID;\n}\n\nexport function getStatus(outcome: OperationOutcome): number {\n if (outcome.id === OK_ID) {\n return 200;\n } else if (outcome.id === CREATED_ID) {\n return 201;\n } else if (outcome.id === NOT_MODIFIED_ID) {\n return 304;\n } else if (outcome.id === UNAUTHORIZED_ID) {\n return 401;\n } else if (outcome.id === FORBIDDEN_ID) {\n return 403;\n } else if (outcome.id === NOT_FOUND_ID) {\n return 404;\n } else if (outcome.id === GONE_ID) {\n return 410;\n } else if (outcome.id === TOO_MANY_REQUESTS_ID) {\n return 429;\n } else {\n return 400;\n }\n}\n\n/**\n * Asserts that the operation completed successfully and that the resource is defined.\n * @param outcome The operation outcome.\n * @param resource The resource that may or may not have been returned.\n */\nexport function assertOk<T>(outcome: OperationOutcome, resource: T | undefined): asserts resource is T {\n if (!isOk(outcome) || resource === undefined) {\n throw new OperationOutcomeError(outcome);\n }\n}\n\nexport class OperationOutcomeError extends Error {\n readonly outcome: OperationOutcome;\n\n constructor(outcome: OperationOutcome) {\n super(outcome?.issue?.[0].details?.text);\n this.outcome = outcome;\n }\n}\n\n/**\n * Normalizes an error object into a displayable error string.\n * @param error The error value which could be a string, Error, OperationOutcome, or other unknown type.\n * @returns A display string for the error.\n */\nexport function normalizeErrorString(error: unknown): string {\n if (!error) {\n return 'Unknown error';\n }\n if (typeof error === 'string') {\n return error;\n }\n if (error instanceof Error) {\n return error.message;\n }\n if (isOperationOutcome(error)) {\n return error.issue?.[0]?.details?.text ?? 'Unknown error';\n }\n return JSON.stringify(error);\n}\n","/**\n * The ReadablePromise class wraps a request promise suitable for React Suspense.\n * See: https://blog.logrocket.com/react-suspense-data-fetching/#wrappromise-js\n * See: https://github.com/ovieokeh/suspense-data-fetching/blob/master/lib/api/wrapPromise.js\n */\nexport class ReadablePromise<T> implements Promise<T> {\n readonly [Symbol.toStringTag]: string = 'ReadablePromise';\n #suspender: Promise<T>;\n #status: 'pending' | 'error' | 'success' = 'pending';\n #response: T | undefined;\n #error: Error | undefined;\n\n constructor(requestPromise: Promise<T>) {\n this.#suspender = requestPromise.then(\n (res: T) => {\n this.#status = 'success';\n this.#response = res;\n return res;\n },\n (err: any) => {\n this.#status = 'error';\n this.#error = err;\n throw err;\n }\n );\n }\n\n /**\n * Returns true if the promise is pending.\n * @returns True if the Promise is pending.\n */\n isPending(): boolean {\n return this.#status === 'pending';\n }\n\n /**\n * Returns true if the promise resolved successfully.\n * @returns True if the Promise resolved successfully.\n */\n isOk(): boolean {\n return this.#status === 'success';\n }\n\n /**\n * Attempts to read the value of the promise.\n * If the promise is pending, this method will throw a promise.\n * If the promise rejected, this method will throw the rejection reason.\n * If the promise resolved, this method will return the resolved value.\n * @returns The resolved value of the Promise.\n */\n read(): T {\n switch (this.#status) {\n case 'pending':\n throw this.#suspender;\n case 'error':\n throw this.#error;\n default:\n return this.#response as T;\n }\n }\n\n /**\n * Attaches callbacks for the resolution and/or rejection of the Promise.\n * @param onfulfilled The callback to execute when the Promise is resolved.\n * @param onrejected The callback to execute when the Promise is rejected.\n * @returns A Promise for the completion of which ever callback is executed.\n */\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null\n ): Promise<TResult1 | TResult2> {\n return this.#suspender.then(onfulfilled, onrejected);\n }\n\n /**\n * Attaches a callback for only the rejection of the Promise.\n * @param onrejected The callback to execute when the Promise is rejected.\n * @returns A Promise for the completion of the callback.\n */\n catch<TResult = never>(\n onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null\n ): Promise<T | TResult> {\n return this.#suspender.catch(onrejected);\n }\n\n /**\n * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The\n * resolved value cannot be modified from the callback.\n * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).\n * @returns A Promise for the completion of the callback.\n */\n finally(onfinally?: (() => void) | undefined | null): Promise<T> {\n return this.#suspender.finally(onfinally);\n }\n}\n","import { stringify } from './utils';\n\n/**\n * The ClientStorage class is a utility class for storing strings and objects.\n *\n * When using MedplumClient in the browser, it will be backed by browser localStorage.\n *\n * When Using MedplumClient in the server, it will be backed by the MemoryStorage class.\n */\nexport class ClientStorage {\n readonly #storage: Storage;\n\n constructor() {\n this.#storage = typeof localStorage !== 'undefined' ? localStorage : new MemoryStorage();\n }\n\n clear(): void {\n this.#storage.clear();\n }\n\n getString(key: string): string | undefined {\n return this.#storage.getItem(key) || undefined;\n }\n\n setString(key: string, value: string | undefined): void {\n if (value) {\n this.#storage.setItem(key, value);\n } else {\n this.#storage.removeItem(key);\n }\n }\n\n getObject<T>(key: string): T | undefined {\n const str = this.getString(key);\n return str ? (JSON.parse(str) as T) : undefined;\n }\n\n setObject<T>(key: string, value: T): void {\n this.setString(key, value ? stringify(value) : undefined);\n }\n}\n\n/**\n * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.\n */\nexport class MemoryStorage implements Storage {\n #data: Map<string, string>;\n\n constructor() {\n this.#data = new Map<string, string>();\n }\n\n /**\n * Returns the number of key/value pairs.\n */\n get length(): number {\n return this.#data.size;\n }\n\n /**\n * Removes all key/value pairs, if there are any.\n */\n clear(): void {\n this.#data.clear();\n }\n\n /**\n * Returns the current value associated with the given key, or null if the given key does not exist.\n */\n getItem(key: string): string | null {\n return this.#data.get(key) ?? null;\n }\n\n /**\n * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.\n */\n setItem(key: string, value: string | null): void {\n if (value) {\n this.#data.set(key, value);\n } else {\n this.#data.delete(key);\n }\n }\n\n /**\n * Removes the key/value pair with the given key, if a key/value pair with the given key exists.\n */\n removeItem(key: string): void {\n this.#data.delete(key);\n }\n\n /**\n * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.\n */\n key(index: number): string | null {\n return Array.from(this.#data.keys())[index];\n }\n}\n","import {\n Bundle,\n BundleEntry,\n ElementDefinition,\n Resource,\n SearchParameter,\n StructureDefinition,\n} from '@medplum/fhirtypes';\nimport baseSchema from './base-schema.json';\nimport { SearchParameterDetails } from './searchparams';\nimport { capitalize } from './utils';\n\nexport interface TypedValue {\n readonly type: string;\n readonly value: any;\n}\n\n/**\n * List of property types.\n * http://www.hl7.org/fhir/valueset-defined-types.html\n * The list here includes additions found from StructureDefinition resources.\n */\nexport enum PropertyType {\n Address = 'Address',\n Age = 'Age',\n Annotation = 'Annotation',\n Attachment = 'Attachment',\n BackboneElement = 'BackboneElement',\n CodeableConcept = 'CodeableConcept',\n Coding = 'Coding',\n ContactDetail = 'ContactDetail',\n ContactPoint = 'ContactPoint',\n Contributor = 'Contributor',\n Count = 'Count',\n DataRequirement = 'DataRequirement',\n Distance = 'Distance',\n Dosage = 'Dosage',\n Duration = 'Duration',\n Expression = 'Expression',\n Extension = 'Extension',\n HumanName = 'HumanName',\n Identifier = 'Identifier',\n MarketingStatus = 'MarketingStatus',\n Meta = 'Meta',\n Money = 'Money',\n Narrative = 'Narrative',\n ParameterDefinition = 'ParameterDefinition',\n Period = 'Period',\n Population = 'Population',\n ProdCharacteristic = 'ProdCharacteristic',\n ProductShelfLife = 'ProductShelfLife',\n Quantity = 'Quantity',\n Range = 'Range',\n Ratio = 'Ratio',\n Reference = 'Reference',\n RelatedArtifact = 'RelatedArtifact',\n SampledData = 'SampledData',\n Signature = 'Signature',\n SubstanceAmount = 'SubstanceAmount',\n SystemString = 'http://hl7.org/fhirpath/System.String',\n Timing = 'Timing',\n TriggerDefinition = 'TriggerDefinition',\n UsageContext = 'UsageContext',\n base64Binary = 'base64Binary',\n boolean = 'boolean',\n canonical = 'canonical',\n code = 'code',\n date = 'date',\n dateTime = 'dateTime',\n decimal = 'decimal',\n id = 'id',\n instant = 'instant',\n integer = 'integer',\n markdown = 'markdown',\n oid = 'oid',\n positiveInt = 'positiveInt',\n string = 'string',\n time = 'time',\n unsignedInt = 'unsignedInt',\n uri = 'uri',\n url = 'url',\n uuid = 'uuid',\n}\n\n/**\n * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.\n *\n * StructureDefinition resources contain schema information for other resource types.\n * These schemas can be used to automatically generate user interface elements for\n * resources.\n *\n * However, a StructureDefinition resource is not optimized for realtime lookups. All\n * resource types, sub types, and property definitions are stored in a flat array of\n * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., \"Patient.name\")\n * requires a linear scan of all ElementDefinition objects\n *\n * A StructureDefinition resource contains information about one or more types.\n * For example, the \"Patient\" StructureDefinition includes \"Patient\", \"Patient_Contact\",\n * \"Patient_Communication\", and \"Patient_Link\". This is inefficient.\n *\n * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.\n * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.\n *\n * The hierarchy is:\n * IndexedStructureDefinition - top level for one resource type\n * TypeSchema - one per resource type and all contained BackboneElements\n * PropertySchema - one per property/field\n */\nexport interface IndexedStructureDefinition {\n types: { [resourceType: string]: TypeSchema };\n}\n\n/**\n * An indexed TypeSchema.\n *\n * Example: The IndexedStructureDefinition for \"Patient\" would include the following TypeSchemas:\n * 1) Patient\n * 2) Patient_Contact\n * 3) Patient_Communication\n * 4) Patient_Link\n */\nexport interface TypeSchema {\n structureDefinition: StructureDefinition;\n elementDefinition: ElementDefinition;\n display: string;\n properties: { [name: string]: ElementDefinition };\n searchParams?: { [code: string]: SearchParameter };\n searchParamsDetails?: { [code: string]: SearchParameterDetails };\n description?: string;\n parentType?: string;\n}\n\n/**\n * Creates a new empty IndexedStructureDefinition.\n * @returns The empty IndexedStructureDefinition.\n * @deprecated Use globalSchema\n */\nexport function createSchema(): IndexedStructureDefinition {\n return { types: {} };\n}\n\nfunction createTypeSchema(\n typeName: string,\n structureDefinition: StructureDefinition,\n elementDefinition: ElementDefinition\n): TypeSchema {\n return {\n structureDefinition,\n elementDefinition,\n display: typeName,\n description: elementDefinition.definition,\n properties: {},\n };\n}\n\n/**\n * Indexes a bundle of StructureDefinitions for faster lookup.\n * @param bundle A FHIR bundle StructureDefinition resources.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexStructureDefinitionBundle(bundle: Bundle): void {\n for (const entry of bundle.entry as BundleEntry[]) {\n const resource = entry.resource as Resource;\n if (resource.resourceType === 'StructureDefinition') {\n indexStructureDefinition(resource);\n }\n }\n}\n\n/**\n * Indexes a StructureDefinition for fast lookup.\n * @param structureDefinition The original StructureDefinition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexStructureDefinition(structureDefinition: StructureDefinition): void {\n const typeName = structureDefinition.name;\n if (!typeName) {\n return;\n }\n\n const elements = structureDefinition.snapshot?.element;\n if (elements) {\n // First pass, build types\n elements.forEach((element) => indexType(structureDefinition, element));\n\n // Second pass, build properties\n elements.forEach((element) => indexProperty(element));\n }\n}\n\n/**\n * Indexes TypeSchema from an ElementDefinition.\n * In the common case, there will be many ElementDefinition instances per TypeSchema.\n * Only the first occurrence is saved.\n * @param structureDefinition The parent type structure definition.\n * @param elementDefinition The element definition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nfunction indexType(structureDefinition: StructureDefinition, elementDefinition: ElementDefinition): void {\n const path = elementDefinition.path as string;\n const typeCode = elementDefinition.type?.[0]?.code;\n if (typeCode !== undefined && typeCode !== 'Element' && typeCode !== 'BackboneElement') {\n return;\n }\n const parts = path.split('.');\n const typeName = buildTypeName(parts);\n globalSchema.types[typeName] = createTypeSchema(typeName, structureDefinition, elementDefinition);\n globalSchema.types[typeName].parentType = buildTypeName(parts.slice(0, parts.length - 1));\n}\n\n/**\n * Indexes PropertySchema from an ElementDefinition.\n * @param element The input ElementDefinition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nfunction indexProperty(element: ElementDefinition): void {\n const path = element.path as string;\n const parts = path.split('.');\n if (parts.length === 1) {\n return;\n }\n const typeName = buildTypeName(parts.slice(0, parts.length - 1));\n const typeSchema = globalSchema.types[typeName];\n if (!typeSchema) {\n return;\n }\n const key = parts[parts.length - 1];\n typeSchema.properties[key] = element;\n}\n\n/**\n * Indexes a bundle of SearchParameter resources for faster lookup.\n * @param bundle A FHIR bundle SearchParameter resources.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexSearchParameterBundle(bundle: Bundle<SearchParameter>): void {\n for (const entry of bundle.entry as BundleEntry[]) {\n const resource = entry.resource as SearchParameter;\n if (resource.resourceType === 'SearchParameter') {\n indexSearchParameter(resource);\n }\n }\n}\n\n/**\n * Indexes a SearchParameter resource for fast lookup.\n * Indexes by SearchParameter.code, which is the query string parameter name.\n * @param searchParam The SearchParameter resource.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexSearchParameter(searchParam: SearchParameter): void {\n if (!searchParam.base) {\n return;\n }\n\n for (const resourceType of searchParam.base) {\n const typeSchema = globalSchema.types[resourceType];\n if (!typeSchema) {\n continue;\n }\n\n if (!typeSchema.searchParams) {\n typeSchema.searchParams = {\n _id: {\n base: [resourceType],\n code: '_id',\n type: 'token',\n expression: resourceType + '.id',\n } as SearchParameter,\n _lastUpdated: {\n base: [resourceType],\n code: '_lastUpdated',\n type: 'date',\n expression: resourceType + '.meta.lastUpdated',\n } as SearchParameter,\n _compartment: {\n base: [resourceType],\n code: '_compartment',\n type: 'reference',\n expression: resourceType + '.meta.compartment',\n } as SearchParameter,\n _profile: {\n base: [resourceType],\n code: '_profile',\n type: 'uri',\n expression: resourceType + '.meta.profile',\n } as SearchParameter,\n _security: {\n base: [resourceType],\n code: '_security',\n type: 'token',\n expression: resourceType + '.meta.security',\n } as SearchParameter,\n _source: {\n base: [resourceType],\n code: '_source',\n type: 'uri',\n expression: resourceType + '.meta.source',\n } as SearchParameter,\n _tag: {\n base: [resourceType],\n code: '_tag',\n type: 'token',\n expression: resourceType + '.meta.tag',\n } as SearchParameter,\n };\n }\n\n typeSchema.searchParams[searchParam.code as string] = searchParam;\n }\n}\n\n/**\n * Returns the type name for an ElementDefinition.\n * @param elementDefinition The element definition.\n * @returns The Medplum type name.\n */\nexport function getElementDefinitionTypeName(elementDefinition: ElementDefinition): string {\n const code = elementDefinition.type?.[0]?.code as string;\n return code === 'BackboneElement' || code === 'Element'\n ? buildTypeName(elementDefinition.path?.split('.') as string[])\n : code;\n}\n\nexport function buildTypeName(components: string[]): string {\n if (components.length === 1) {\n return components[0];\n }\n return components.map(capitalize).join('');\n}\n\nexport function getPropertyDisplayName(path: string): string {\n // Get the property name, which is the remainder after the last period\n // For example, for path \"Patient.birthDate\"\n // the property name is \"birthDate\"\n const propertyName = path.replaceAll('[x]', '').split('.').pop() as string;\n\n // Special case for ID\n if (propertyName === 'id') {\n return 'ID';\n }\n\n // Split by capital letters\n // Capitalize the first letter of each word\n // Join together with spaces in between\n // Then normalize whitespace to single space character\n // For example, for property name \"birthDate\",\n // the display name is \"Birth Date\".\n return propertyName\n .split(/(?=[A-Z])/)\n .map(capitalize)\n .join(' ')\n .replace('_', ' ')\n .replace(/\\s+/g, ' ');\n}\n\n/**\n * Returns an element definition by type and property name.\n * Handles content references.\n * @param typeName The type name.\n * @param propertyName The property name.\n * @returns The element definition if found.\n */\nexport function getElementDefinition(typeName: string, propertyName: string): ElementDefinition | undefined {\n const typeSchema = globalSchema.types[typeName];\n if (!typeSchema) {\n return undefined;\n }\n\n const property = typeSchema.properties[propertyName] ?? typeSchema.properties[propertyName + '[x]'];\n if (!property) {\n return undefined;\n }\n\n if (property.contentReference) {\n // Content references start with a \"#\"\n // Remove the \"#\" character\n const contentReference = property.contentReference.substring(1).split('.');\n const referencePropertyName = contentReference.pop() as string;\n const referenceTypeName = buildTypeName(contentReference);\n return getElementDefinition(referenceTypeName, referencePropertyName);\n }\n\n return property;\n}\n\n/**\n * Global schema singleton.\n */\nexport const globalSchema = baseSchema as unknown as IndexedStructureDefinition;\n","// PKCE auth based on:\n// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/\n\nimport {\n Binary,\n Bundle,\n BundleEntry,\n Communication,\n Device,\n Encounter,\n ExtractResource,\n OperationOutcome,\n Patient,\n Project,\n ProjectMembership,\n ProjectSecret,\n Reference,\n Resource,\n ResourceType,\n SearchParameter,\n StructureDefinition,\n UserConfiguration,\n ValueSet,\n} from '@medplum/fhirtypes';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n/** @ts-ignore */\nimport type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';\nimport { LRUCache } from './cache';\nimport { encryptSHA256, getRandomString } from './crypto';\nimport { EventTarget } from './eventtarget';\nimport { Hl7Message } from './hl7';\nimport { parseJWTPayload } from './jwt';\nimport { isOk } from './outcomes';\nimport { ReadablePromise } from './readablepromise';\nimport { ClientStorage } from './storage';\nimport { globalSchema, IndexedStructureDefinition, indexSearchParameter, indexStructureDefinition } from './types';\nimport { arrayBufferToBase64, createReference, ProfileResource } from './utils';\n\nexport const MEDPLUM_VERSION = process.env.MEDPLUM_VERSION;\n\nconst DEFAULT_BASE_URL = 'https://api.medplum.com/';\nconst DEFAULT_RESOURCE_CACHE_SIZE = 1000;\nconst DEFAULT_CACHE_TIME = 60000; // 60 seconds\nconst JSON_CONTENT_TYPE = 'application/json';\nconst FHIR_CONTENT_TYPE = 'application/fhir+json';\nconst PATCH_CONTENT_TYPE = 'application/json-patch+json';\n\nconst system: Device = { resourceType: 'Device', id: 'system', deviceName: [{ name: 'System' }] };\n\n/**\n * The MedplumClientOptions interface defines configuration options for MedplumClient.\n *\n * All configuration settings are optional.\n */\nexport interface MedplumClientOptions {\n /**\n * Base server URL.\n *\n * Default value is https://api.medplum.com/\n *\n * Use this to point to a custom Medplum deployment.\n */\n baseUrl?: string;\n\n /**\n * OAuth2 authorize URL.\n *\n * Default value is baseUrl + \"/oauth2/authorize\".\n *\n * Use this if you want to use a separate OAuth server.\n */\n authorizeUrl?: string;\n\n /**\n * OAuth2 token URL.\n *\n * Default value is baseUrl + \"/oauth2/token\".\n *\n * Use this if you want to use a separate OAuth server.\n */\n tokenUrl?: string;\n\n /**\n * OAuth2 logout URL.\n *\n * Default value is baseUrl + \"/oauth2/logout\".\n *\n * Use this if you want to use a separate OAuth server.\n */\n logoutUrl?: string;\n\n /**\n * The client ID.\n *\n * Client ID can be used for SMART-on-FHIR customization.\n */\n clientId?: string;\n\n /**\n * Number of resources to store in the cache.\n *\n * Default value is 1000.\n *\n * Consider using this for performance of displaying Patient or Practitioner resources.\n */\n resourceCacheSize?: number;\n\n /**\n * The length of time in milliseconds to cache resources.\n *\n * Default value is 10000 (10 seconds).\n *\n * Cache time of zero disables all caching.\n *\n * For any individual request, the cache behavior can be overridden by setting the cache property on request options.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache\n */\n cacheTime?: number;\n\n /**\n * The length of time in milliseconds to delay requests for auto batching.\n *\n * Auto batching attempts to group multiple requests together into a single batch request.\n *\n * Default value is 0, which disables auto batching.\n */\n autoBatchTime?: number;\n\n /**\n * Fetch implementation.\n *\n * Default is window.fetch (if available).\n *\n * For nodejs applications, consider the 'node-fetch' package.\n */\n fetch?: FetchLike;\n\n /**\n * Create PDF implementation.\n *\n * Default is none, and PDF generation is disabled.\n *\n * In browser environments, import the client-side pdfmake library.\n *\n * ```html\n * <script src=\"pdfmake.min.js\"></script>\n * <script>\n * async function createPdf(docDefinition, tableLayouts, fonts) {\n * return new Promise((resolve) => {\n * pdfMake.createPdf(docDefinition, tableLayouts, fonts).getBlob(resolve);\n * });\n * }\n * </script>\n * ```\n *\n * In nodejs applications:\n *\n * ```ts\n * import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';\n * function createPdf(\n * docDefinition: TDocumentDefinitions,\n * tableLayouts?: { [name: string]: CustomTableLayout },\n * fonts?: TFontDictionary\n * ): Promise<Buffer> {\n * return new Promise((resolve, reject) => {\n * const printer = new PdfPrinter(fonts || {});\n * const pdfDoc = printer.createPdfKitDocument(docDefinition, { tableLayouts });\n * const chunks: Uint8Array[] = [];\n * pdfDoc.on('data', (chunk: Uint8Array) => chunks.push(chunk));\n * pdfDoc.on('end', () => resolve(Buffer.concat(chunks)));\n * pdfDoc.on('error', reject);\n * pdfDoc.end();\n * });\n * }\n * ```\n */\n createPdf?: CreatePdfFunction;\n\n /**\n * Callback for when the client is unauthenticated.\n *\n * Default is do nothing.\n *\n * For client side applications, consider redirecting to a sign in page.\n */\n onUnauthenticated?: () => void;\n}\n\nexport interface FetchLike {\n (url: string, options?: any): Promise<any>;\n}\n\nexport interface CreatePdfFunction {\n (\n docDefinition: TDocumentDefinitions,\n tableLayouts?:\n | {\n [name: string]: CustomTableLayout;\n }\n | undefined,\n fonts?: TFontDictionary | undefined\n ): Promise<any>;\n}\n\nexport interface BaseLoginRequest {\n readonly projectId?: string;\n readonly clientId?: string;\n readonly resourceType?: string;\n readonly scope?: string;\n readonly nonce?: string;\n readonly codeChallenge?: string;\n readonly codeChallengeMethod?: string;\n readonly googleClientId?: string;\n readonly launch?: string;\n readonly redirectUri?: string;\n}\n\nexport interface EmailPasswordLoginRequest extends BaseLoginRequest {\n readonly email: string;\n readonly password: string;\n readonly remember?: boolean;\n}\n\nexport interface NewUserRequest {\n readonly firstName: string;\n readonly lastName: string;\n readonly email: string;\n readonly password: string;\n readonly recaptchaToken: string;\n readonly recaptchaSiteKey?: string;\n readonly remember?: boolean;\n readonly projectId?: string;\n}\n\nexport interface NewProjectRequest {\n readonly login: string;\n readonly projectName: string;\n}\n\nexport interface NewPatientRequest {\n readonly login: string;\n readonly projectId: string;\n}\n\nexport interface GoogleCredentialResponse {\n readonly clientId: string;\n readonly credential: string;\n}\n\nexport interface GoogleLoginRequest extends BaseLoginRequest {\n readonly googleClientId: string;\n readonly googleCredential: string;\n readonly createUser?: boolean;\n}\n\nexport interface LoginAuthenticationResponse {\n readonly login: string;\n readonly mfaRequired?: boolean;\n readonly code?: string;\n readonly memberships?: ProjectMembership[];\n}\n\nexport interface LoginProfileResponse {\n readonly login: string;\n readonly scope: string;\n}\n\nexport interface LoginScopeResponse {\n readonly login: string;\n readonly code: string;\n}\n\nexport interface LoginState {\n readonly project: Reference<Project>;\n readonly profile: Reference<ProfileResource>;\n readonly accessToken: string;\n readonly refreshToken: string;\n}\n\nexport interface TokenResponse {\n readonly token_type: string;\n readonly id_token: string;\n readonly access_token: string;\n readonly refresh_token: string;\n readonly expires_in: number;\n readonly project: Reference<Project>;\n readonly profile: Reference<ProfileResource>;\n}\n\nexport interface BotEvent<T = Resource | Hl7Message | string | Record<string, any>> {\n readonly contentType: string;\n readonly input: T;\n readonly secrets: Record<string, ProjectSecret>;\n}\n\n/**\n * JSONPatch patch operation.\n * Compatible with fast-json-patch and rfc6902 Operation.\n */\nexport interface PatchOperation {\n readonly op: 'add' | 'remove' | 'replace' | 'copy' | 'move' | 'test';\n readonly path: string;\n readonly value?: any;\n}\n\n/**\n * Email address definition.\n * Compatible with nodemailer Mail.Address.\n */\nexport interface MailAddress {\n readonly name: string;\n readonly address: string;\n}\n\n/**\n * Email attachment definition.\n * Compatible with nodemailer Mail.Options.\n */\nexport interface MailAttachment {\n /** String, Buffer or a Stream contents for the attachmentent */\n readonly content?: string;\n /** path to a file or an URL (data uris are allowed as well) if you want to stream the file instead of including it (better for larger attachments) */\n readonly path?: string;\n /** filename to be reported as the name of the attached file, use of unicode is allowed. If you do not want to use a filename, set this value as false, otherwise a filename is generated automatically */\n readonly filename?: string | false;\n /** optional content type for the attachment, if not set will be derived from the filename property */\n readonly contentType?: string;\n}\n\n/**\n * Email message definition.\n * Compatible with nodemailer Mail.Options.\n */\nexport interface MailOptions {\n /** The e-mail address of the sender. All e-mail addresses can be plain 'sender@server.com' or formatted 'Sender Name <sender@server.com>' */\n readonly from?: string | MailAddress;\n /** An e-mail address that will appear on the Sender: field */\n readonly sender?: string | MailAddress;\n /** Comma separated list or an array of recipients e-mail addresses that will appear on the To: field */\n readonly to?: string | MailAddress | string[] | MailAddress[];\n /** Comma separated list or an array of recipients e-mail addresses that will appear on the Cc: field */\n readonly cc?: string | MailAddress | string[] | MailAddress[];\n /** Comma separated list or an array of recipients e-mail addresses that will appear on the Bcc: field */\n readonly bcc?: string | MailAddress | string[] | MailAddress[];\n /** An e-mail address that will appear on the Reply-To: field */\n readonly replyTo?: string | MailAddress;\n /** The subject of the e-mail */\n readonly subject?: string;\n /** The plaintext version of the message */\n readonly text?: string;\n /** The HTML version of the message */\n readonly html?: string;\n /** An array of attachment objects */\n readonly attachments?: MailAttachment[];\n}\n\ninterface SchemaGraphQLResponse {\n readonly data: {\n readonly StructureDefinitionList: StructureDefinition[];\n readonly SearchParameterList: SearchParameter[];\n };\n}\n\ninterface RequestCacheEntry {\n readonly requestTime: number;\n readonly value: ReadablePromise<any>;\n}\n\ninterface AutoBatchEntry<T = any> {\n readonly method: string;\n readonly url: string;\n readonly options: RequestInit;\n readonly resolve: (value: T) => void;\n readonly reject: (reason: any) => void;\n}\n\n/**\n * The MedplumClient class provides a client for the Medplum FHIR server.\n *\n * The client can be used in the browser, in a NodeJS application, or in a Medplum Bot.\n *\n * The client provides helpful methods for common operations such as:\n * 1) Authenticating\n * 2) Creating resources\n * 2) Reading resources\n * 3) Updating resources\n * 5) Deleting resources\n * 6) Searching\n * 7) Making GraphQL queries\n *\n * Here is a quick example of how to use the client:\n *\n * ```typescript\n * import { MedplumClient } from '@medplum/core';\n * const medplum = new MedplumClient();\n * ```\n *\n * Create a `Patient`:\n *\n * ```typescript\n * const patient = await medplum.createResource({\n * resourceType: 'Patient',\n * name: [{\n * given: ['Alice'],\n * family: 'Smith'\n * }]\n * });\n * ```\n *\n * Read a `Patient` by ID:\n *\n * ```typescript\n * const patient = await medplum.readResource('Patient', '123');\n * console.log(patient.name[0].given[0]);\n * ```\n *\n * Search for a `Patient` by name:\n *\n * ```typescript\n * const bundle = await medplum.search('Patient', 'name=Alice');\n * console.log(bundle.total);\n * ```\n *\n * <head>\n * <meta name=\"algolia:pageRank\" content=\"100\" />\n * </head>\n\n */\nexport class MedplumClient extends EventTarget {\n readonly #fetch: FetchLike;\n readonly #createPdf?: CreatePdfFunction;\n readonly #storage: ClientStorage;\n readonly #requestCache: LRUCache<RequestCacheEntry>;\n readonly #cacheTime: number;\n readonly #baseUrl: string;\n readonly #fhirBaseUrl: string;\n readonly #authorizeUrl: string;\n readonly #tokenUrl: string;\n readonly #logoutUrl: string;\n readonly #onUnauthenticated?: () => void;\n readonly #autoBatchTime: number;\n readonly #autoBatchQueue: AutoBatchEntry[];\n #clientId?: string;\n #clientSecret?: string;\n #autoBatchTimerId?: any;\n #accessToken?: string;\n #refreshToken?: string;\n #refreshPromise?: Promise<any>;\n #profilePromise?: Promise<any>;\n #profile?: ProfileResource;\n #config?: UserConfiguration;\n\n constructor(options?: MedplumClientOptions) {\n super();\n\n if (options?.baseUrl) {\n if (!options.baseUrl.startsWith('http')) {\n throw new Error('Base URL must start with http or https');\n }\n }\n\n this.#fetch = options?.fetch || getDefaultFetch();\n this.#createPdf = options?.createPdf;\n this.#storage = new ClientStorage();\n this.#requestCache = new LRUCache(options?.resourceCacheSize ?? DEFAULT_RESOURCE_CACHE_SIZE);\n this.#cacheTime = options?.cacheTime ?? DEFAULT_CACHE_TIME;\n this.#baseUrl = ensureTrailingSlash(options?.baseUrl) || DEFAULT_BASE_URL;\n this.#fhirBaseUrl = this.#baseUrl + 'fhir/R4/';\n this.#clientId = options?.clientId || '';\n this.#authorizeUrl = options?.authorizeUrl || this.#baseUrl + 'oauth2/authorize';\n this.#tokenUrl = options?.tokenUrl || this.#baseUrl + 'oauth2/token';\n this.#logoutUrl = options?.logoutUrl || this.#baseUrl + 'oauth2/logout';\n this.#onUnauthenticated = options?.onUnauthenticated;\n this.#autoBatchTime = options?.autoBatchTime ?? 0;\n this.#autoBatchQueue = [];\n\n const activeLogin = this.getActiveLogin();\n if (activeLogin) {\n this.#accessToken = activeLogin.accessToken;\n this.#refreshToken = activeLogin.refreshToken;\n this.#refreshProfile().catch(console.log);\n }\n\n this.#setupStorageListener();\n }\n\n /**\n * Returns the current base URL for all API requests.\n * By default, this is set to `https://api.medplum.com/`.\n * This can be overridden by setting the `baseUrl` option when creating the client.\n * @category HTTP\n * @returns The current base URL for all API requests.\n */\n getBaseUrl(): string {\n return this.#baseUrl;\n }\n\n /**\n * Clears all auth state including local storage and session storage.\n * @category Authentication\n */\n clear(): void {\n this.#storage.clear();\n this.clearActiveLogin();\n }\n\n /**\n * Clears the active login from local storage.\n * Does not clear all local storage (such as other logins).\n * @category Authentication\n */\n clearActiveLogin(): void {\n this.#storage.setString('activeLogin', undefined);\n this.#requestCache.clear();\n this.#accessToken = undefined;\n this.#refreshToken = undefined;\n this.#profile = undefined;\n this.#config = undefined;\n this.dispatchEvent({ type: 'change' });\n }\n\n /**\n * Invalidates any cached values or cached requests for the given URL.\n * @category Caching\n * @param url The URL to invalidate.\n */\n invalidateUrl(url: URL | string): void {\n url = url.toString();\n this.#requestCache.delete(url);\n }\n\n /**\n * Invalidates all cached search results or cached requests for the given resourceType.\n * @category Caching\n * @param resourceType The resource type to invalidate.\n */\n invalidateSearches<K extends ResourceType>(resourceType: K): void {\n const url = 'fhir/R4/' + resourceType;\n for (const key of this.#requestCache.keys()) {\n if (key.endsWith(url) || key.includes(url + '?')) {\n this.#requestCache.delete(key);\n }\n }\n }\n\n /**\n * Makes an HTTP GET request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `readResource()`, `search()`, etc.\n *\n * @category HTTP\n * @param url The target URL.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n get<T = any>(url: URL | string, options: RequestInit = {}): ReadablePromise<T> {\n url = url.toString();\n const cached = this.#getCacheEntry(url, options);\n if (cached) {\n return cached.value;\n }\n\n let promise: Promise<T>;\n\n if (url.startsWith(this.#fhirBaseUrl) && this.#autoBatchTime > 0) {\n promise = new Promise<T>((resolve, reject) => {\n this.#autoBatchQueue.push({\n method: 'GET',\n url: (url as string).replace(this.#fhirBaseUrl, ''),\n options,\n resolve,\n reject,\n });\n if (!this.#autoBatchTimerId) {\n this.#autoBatchTimerId = setTimeout(() => this.#executeAutoBatch(), this.#autoBatchTime);\n }\n });\n } else {\n promise = this.#request<T>('GET', url, options);\n }\n\n const readablePromise = new ReadablePromise(promise);\n this.#setCacheEntry(url, readablePromise);\n return readablePromise;\n }\n\n /**\n * Makes an HTTP POST request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `createResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.\n * @param contentType The content type to be included in the \"Content-Type\" header.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n post(url: URL | string, body: any, contentType?: string, options: RequestInit = {}): Promise<any> {\n url = url.toString();\n if (body) {\n this.#setRequestBody(options, body);\n }\n if (contentType) {\n this.#setRequestContentType(options, contentType);\n }\n this.invalidateUrl(url);\n return this.#request('POST', url, options);\n }\n\n /**\n * Makes an HTTP PUT request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `updateResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.\n * @param contentType The content type to be included in the \"Content-Type\" header.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n put(url: URL | string, body: any, contentType?: string, options: RequestInit = {}): Promise<any> {\n url = url.toString();\n if (body) {\n this.#setRequestBody(options, body);\n }\n if (contentType) {\n this.#setRequestContentType(options, contentType);\n }\n this.invalidateUrl(url);\n return this.#request('PUT', url, options);\n }\n\n /**\n * Makes an HTTP PATCH request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `patchResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param operations Array of JSONPatch operations.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n patch(url: URL | string, operations: PatchOperation[], options: RequestInit = {}): Promise<any> {\n url = url.toString();\n this.#setRequestBody(options, operations);\n this.#setRequestContentType(options, PATCH_CONTENT_TYPE);\n this.invalidateUrl(url);\n return this.#request('PATCH', url, options);\n }\n\n /**\n * Makes an HTTP DELETE request to the specified URL.\n *\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `deleteResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n delete(url: URL | string, options: RequestInit = {}): Promise<any> {\n url = url.toString();\n this.invalidateUrl(url);\n return this.#request('DELETE', url, options);\n }\n\n /**\n * Initiates a new user flow.\n *\n * This method is part of the two different user registration flows:\n * 1) New Practitioner and new Project\n * 2) New Patient registration\n *\n * @category Authentication\n * @param newUserRequest Register request including email and password.\n * @returns Promise to the authentication response.\n */\n async startNewUser(newUserRequest: NewUserRequest): Promise<LoginAuthenticationResponse> {\n const { codeChallengeMethod, codeChallenge } = await this.startPkce();\n return this.post('auth/newuser', {\n ...newUserRequest,\n codeChallengeMethod,\n codeChallenge,\n }) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Initiates a new project flow.\n *\n * This requires a partial login from `startNewUser` or `startNewGoogleUser`.\n *\n * @param newProjectRequest Register request including email and password.\n * @returns Promise to the authentication response.\n */\n async startNewProject(newProjectRequest: NewProjectRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/newproject', newProjectRequest) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Initiates a new patient flow.\n *\n * This requires a partial login from `startNewUser` or `startNewGoogleUser`.\n *\n * @param newPatientRequest Register request including email and password.\n * @returns Promise to the authentication response.\n */\n async startNewPatient(newPatientRequest: NewPatientRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/newpatient', newPatientRequest) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Initiates a user login flow.\n * @category Authentication\n * @param loginRequest Login request including email and password.\n * @returns Promise to the authentication response.\n */\n async startLogin(loginRequest: EmailPasswordLoginRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/login', {\n ...(await this.ensureCodeChallenge(loginRequest)),\n clientId: loginRequest.clientId ?? this.#clientId,\n scope: loginRequest.scope,\n }) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Tries to sign in with Google authentication.\n * The response parameter is the result of a Google authentication.\n * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions\n * @category Authentication\n * @param loginRequest Login request including Google credential response.\n * @returns Promise to the authentication response.\n */\n async startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/google', {\n ...(await this.ensureCodeChallenge(loginRequest)),\n clientId: loginRequest.clientId ?? this.#clientId,\n scope: loginRequest.scope,\n }) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Returns the PKCE code challenge and method.\n * If the login request already includes a code challenge, it is returned.\n * Otherwise, a new PKCE code challenge is generated.\n * @category Authentication\n * @param loginRequest The original login request.\n * @returns The PKCE code challenge and method.\n */\n async ensureCodeChallenge<T extends BaseLoginRequest>(loginRequest: T): Promise<T> {\n if (loginRequest.codeChallenge) {\n return loginRequest;\n }\n return { ...loginRequest, ...(await this.startPkce()) };\n }\n\n /**\n * Signs out locally.\n * Does not invalidate tokens with the server.\n * @category Authentication\n */\n async signOut(): Promise<void> {\n await this.post(this.#logoutUrl, {});\n this.clear();\n }\n\n /**\n * Tries to sign in the user.\n * Returns true if the user is signed in.\n * This may result in navigating away to the sign in page.\n * @category Authentication\n * @param loginParams Optional login parameters.\n */\n async signInWithRedirect(loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource | void> {\n const urlParams = new URLSearchParams(window.location.search);\n const code = urlParams.get('code');\n if (!code) {\n await this.#requestAuthorization(loginParams);\n return undefined;\n } else {\n return this.processCode(code);\n }\n }\n\n /**\n * Tries to sign out the user.\n * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html\n * @category Authentication\n */\n signOutWithRedirect(): void {\n window.location.assign(this.#logoutUrl);\n }\n\n /**\n * Initiates sign in with an external identity provider.\n * @param authorizeUrl The external authorization URL.\n * @param clientId The external client ID.\n * @param redirectUri The external identity provider redirect URI.\n * @param baseLogin The Medplum login request.\n * @category Authentication\n */\n async signInWithExternalAuth(\n authorizeUrl: string,\n clientId: string,\n redirectUri: string,\n baseLogin: BaseLoginRequest\n ): Promise<void> {\n const loginRequest = await this.ensureCodeChallenge(baseLogin);\n window.location.assign(this.getExternalAuthRedirectUri(authorizeUrl, clientId, redirectUri, loginRequest));\n }\n\n /**\n * Builds the external identity provider redirect URI.\n * @param authorizeUrl The external authorization URL.\n * @param clientId The external client ID.\n * @param redirectUri The external identity provider redirect URI.\n * @param loginRequest The Medplum login request.\n * @returns The external identity provider redirect URI.\n * @category Authentication\n */\n getExternalAuthRedirectUri(\n authorizeUrl: string,\n clientId: string,\n redirectUri: string,\n loginRequest: BaseLoginRequest\n ): string {\n const url = new URL(authorizeUrl);\n url.searchParams.set('response_type', 'code');\n url.searchParams.set('client_id', clientId);\n url.searchParams.set('redirect_uri', redirectUri);\n url.searchParams.set('scope', 'openid profile email');\n url.searchParams.set('state', JSON.stringify(loginRequest));\n return url.toString();\n }\n\n /**\n * Builds a FHIR URL from a collection of URL path components.\n * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.\n * @category HTTP\n * @param path The path component of the URL.\n * @returns The well-formed FHIR URL.\n */\n fhirUrl(...path: string[]): URL {\n return new URL(this.#fhirBaseUrl + path.join('/'));\n }\n\n /**\n * Builds a FHIR search URL from a search query or structured query object.\n * @category HTTP\n * @category Search\n * @param query The FHIR search query or structured query object.\n * @returns The well-formed FHIR URL.\n */\n fhirSearchUrl(resourceType: ResourceType, query: URLSearchParams | string | undefined): URL {\n const url = this.fhirUrl(resourceType);\n if (query) {\n url.search = query.toString();\n }\n return url;\n }\n\n /**\n * Sends a FHIR search request.\n *\n * Example using a FHIR search string:\n *\n * ```typescript\n * const bundle = await client.search('Patient', 'name=Alice');\n * console.log(bundle);\n * ```\n *\n * The return value is a FHIR bundle:\n *\n * ```json\n * {\n * \"resourceType\": \"Bundle\",\n * \"type\": \"searchset\",\n * \"entry\": [\n * {\n * \"resource\": {\n * \"resourceType\": \"Patient\",\n * \"name\": [\n * {\n * \"given\": [\n * \"George\"\n * ],\n * \"family\": \"Washington\"\n * }\n * ],\n * }\n * }\n * ]\n * }\n * ```\n *\n * To query the count of a search, use the summary feature like so:\n *\n * ```typescript\n * const patients = medplum.search('Patient', '_summary=count');\n * ```\n *\n * See FHIR search for full details: https://www.hl7.org/fhir/search.html\n *\n * @category Search\n * @param resourceType The FHIR resource type.\n * @param query The search query as either a string or a structured search object.\n * @param options Optional fetch options.\n * @returns Promise to the search result bundle.\n */\n search<K extends ResourceType>(\n resourceType: K,\n query?: URLSearchParams | string,\n options: RequestInit = {}\n ): ReadablePromise<Bundle<ExtractResource<K>>> {\n const url = this.fhirSearchUrl(resourceType, query);\n const cacheKey = url.toString() + '-search';\n const cached = this.#getCacheEntry(cacheKey, options);\n if (cached) {\n return cached.value;\n }\n const promise = new ReadablePromise(\n (async () => {\n const bundle = await this.get<Bundle<ExtractResource<K>>>(url, options);\n if (bundle.entry) {\n for (const entry of bundle.entry) {\n this.#cacheResource(entry.resource);\n }\n }\n return bundle;\n })()\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Sends a FHIR search request for a single resource.\n *\n * This is a convenience method for `search()` that returns the first resource rather than a `Bundle`.\n *\n * Example using a FHIR search string:\n *\n * ```typescript\n * const patient = await client.searchOne('Patient', 'identifier=123');\n * console.log(patient);\n * ```\n *\n * The return value is the resource, if available; otherwise, undefined.\n *\n * See FHIR search for full details: https://www.hl7.org/fhir/search.html\n *\n * @category Search\n * @param resourceType The FHIR resource type.\n * @param query The search query as either a string or a structured search object.\n * @param options Optional fetch options.\n * @returns Promise to the search result bundle.\n */\n searchOne<K extends ResourceType>(\n resourceType: K,\n query?: URLSearchParams | string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K> | undefined> {\n const url = this.fhirSearchUrl(resourceType, query);\n url.searchParams.set('_count', '1');\n url.searchParams.sort();\n const cacheKey = url.toString() + '-searchOne';\n const cached = this.#getCacheEntry(cacheKey, options);\n if (cached) {\n return cached.value;\n }\n const promise = new ReadablePromise(\n this.search<K>(resourceType, url.searchParams, options).then((b) => b.entry?.[0]?.resource)\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Sends a FHIR search request for an array of resources.\n *\n * This is a convenience method for `search()` that returns the resources as an array rather than a `Bundle`.\n *\n * Example using a FHIR search string:\n *\n * ```typescript\n * const patients = await client.searchResources('Patient', 'name=Alice');\n * console.log(patients);\n * ```\n *\n * The return value is an array of resources.\n *\n * See FHIR search for full details: https://www.hl7.org/fhir/search.html\n *\n * @category Search\n * @param resourceType The FHIR resource type.\n * @param query The search query as either a string or a structured search object.\n * @param options Optional fetch options.\n * @returns Promise to the search result bundle.\n */\n searchResources<K extends ResourceType>(\n resourceType: K,\n query?: URLSearchParams | string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K>[]> {\n const url = this.fhirSearchUrl(resourceType, query);\n const cacheKey = url.toString() + '-searchResources';\n const cached = this.#getCacheEntry(cacheKey, options);\n if (cached) {\n return cached.value;\n }\n const promise = new ReadablePromise(\n this.search<K>(resourceType, query, options).then(\n (b) => b.entry?.map((e) => e.resource as ExtractResource<K>) ?? []\n )\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Searches a ValueSet resource using the \"expand\" operation.\n * See: https://www.hl7.org/fhir/operation-valueset-expand.html\n *\n * @category Search\n * @param system The ValueSet system url.\n * @param filter The search string.\n * @param options Optional fetch options.\n * @returns Promise to expanded ValueSet.\n */\n searchValueSet(system: string, filter: string, options: RequestInit = {}): ReadablePromise<ValueSet> {\n const url = this.fhirUrl('ValueSet', '$expand');\n url.searchParams.set('url', system);\n url.searchParams.set('filter', filter);\n return this.get(url.toString(), options);\n }\n\n /**\n * Returns a cached resource if it is available.\n * @category Caching\n * @param resourceType The FHIR resource type.\n * @param id The FHIR resource ID.\n * @returns The resource if it is available in the cache; undefined otherwise.\n */\n getCached<K extends ResourceType>(resourceType: K, id: string): ExtractResource<K> | undefined {\n const cached = this.#requestCache.get(this.fhirUrl(resourceType, id).toString())?.value;\n return cached && cached.isOk() ? (cached.read() as ExtractResource<K>) : undefined;\n }\n\n /**\n * Returns a cached resource if it is available.\n * @category Caching\n * @param resourceType The FHIR resource type.\n * @param id The FHIR resource ID.\n * @returns The resource if it is available in the cache; undefined otherwise.\n */\n getCachedReference<T extends Resource>(reference: Reference<T>): T | undefined {\n const refString = reference.reference as string;\n if (!refString) {\n return undefined;\n }\n if (refString === 'system') {\n return system as T;\n }\n const [resourceType, id] = refString.split('/');\n if (!resourceType || !id) {\n return undefined;\n }\n return this.getCached(resourceType as ResourceType, id) as T | undefined;\n }\n\n /**\n * Reads a resource by resource type and ID.\n *\n * Example:\n *\n * ```typescript\n * const patient = await medplum.readResource('Patient', '123');\n * console.log(patient);\n * ```\n *\n * See the FHIR \"read\" operation for full details: https://www.hl7.org/fhir/http.html#read\n *\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param options Optional fetch options.\n * @returns The resource if available; undefined otherwise.\n */\n readResource<K extends ResourceType>(\n resourceType: K,\n id: string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K>> {\n return this.get<ExtractResource<K>>(this.fhirUrl(resourceType, id), options);\n }\n\n /**\n * Reads a resource by `Reference`.\n *\n * This is a convenience method for `readResource()` that accepts a `Reference` object.\n *\n * Example:\n *\n * ```typescript\n * const serviceRequest = await medplum.readResource('ServiceRequest', '123');\n * const patient = await medplum.readReference(serviceRequest.subject);\n * console.log(patient);\n * ```\n *\n * See the FHIR \"read\" operation for full details: https://www.hl7.org/fhir/http.html#read\n *\n * @category Read\n * @param reference The FHIR reference object.\n * @param options Optional fetch options.\n * @returns The resource if available; undefined otherwise.\n */\n readReference<T extends Resource>(reference: Reference<T>, options: RequestInit = {}): ReadablePromise<T> {\n const refString = reference?.reference;\n if (!refString) {\n return new ReadablePromise(Promise.reject(new Error('Missing reference')));\n }\n if (refString === 'system') {\n return new ReadablePromise(Promise.resolve(system as unknown as T));\n }\n const [resourceType, id] = refString.split('/');\n if (!resourceType || !id) {\n return new ReadablePromise(Promise.reject(new Error('Invalid reference')));\n }\n return this.readResource(resourceType as ResourceType, id, options) as ReadablePromise<T>;\n }\n\n /**\n * Returns a cached schema for a resource type.\n * If the schema is not cached, returns undefined.\n * It is assumed that a client will call requestSchema before using this method.\n * @category Schema\n * @returns The schema if immediately available, undefined otherwise.\n * @deprecated Use globalSchema instead.\n */\n getSchema(): IndexedStructureDefinition {\n return globalSchema;\n }\n\n /**\n * Requests the schema for a resource type.\n * If the schema is already cached, the promise is resolved immediately.\n * @category Schema\n * @param resourceType The FHIR resource type.\n * @returns Promise to a schema with the requested resource type.\n */\n requestSchema(resourceType: string): Promise<IndexedStructureDefinition> {\n if (resourceType in globalSchema.types) {\n return Promise.resolve(globalSchema);\n }\n\n const cacheKey = resourceType + '-requestSchema';\n const cached = this.#getCacheEntry(cacheKey, undefined);\n if (cached) {\n return cached.value;\n }\n\n const promise = new ReadablePromise<IndexedStructureDefinition>(\n (async () => {\n const query = `{\n StructureDefinitionList(name: \"${resourceType}\") {\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: \"${resourceType}\", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\\s+/g, ' ');\n\n const response = (await this.graphql(query)) as SchemaGraphQLResponse;\n\n for (const structureDefinition of response.data.StructureDefinitionList) {\n indexStructureDefinition(structureDefinition);\n }\n\n for (const searchParameter of response.data.SearchParameterList) {\n indexSearchParameter(searchParameter);\n }\n\n return globalSchema;\n })()\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Reads resource history by resource type and ID.\n *\n * The return value is a bundle of all versions of the resource.\n *\n * Example:\n *\n * ```typescript\n * const history = await medplum.readHistory('Patient', '123');\n * console.log(history);\n * ```\n *\n * See the FHIR \"history\" operation for full details: https://www.hl7.org/fhir/http.html#history\n *\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param options Optional fetch options.\n * @returns Promise to the resource history.\n */\n readHistory<K extends ResourceType>(\n resourceType: K,\n id: string,\n options: RequestInit = {}\n ): ReadablePromise<Bundle<ExtractResource<K>>> {\n return this.get(this.fhirUrl(resourceType, id, '_history'), options);\n }\n\n /**\n * Reads a specific version of a resource by resource type, ID, and version ID.\n *\n * Example:\n *\n * ```typescript\n * const version = await medplum.readVersion('Patient', '123', '456');\n * console.log(version);\n * ```\n *\n * See the FHIR \"vread\" operation for full details: https://www.hl7.org/fhir/http.html#vread\n *\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param vid The version ID.\n * @param options Optional fetch options.\n * @returns The resource if available; undefined otherwise.\n */\n readVersion<K extends ResourceType>(\n resourceType: K,\n id: string,\n vid: string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K>> {\n return this.get(this.fhirUrl(resourceType, id, '_history', vid), options);\n }\n\n /**\n * Executes the Patient \"everything\" operation for a patient.\n *\n * Example:\n *\n * ```typescript\n * const bundle = await medplum.readPatientEverything('123');\n * console.log(bundle);\n * ```\n *\n * See the FHIR \"patient-everything\" operation for full details: https://hl7.org/fhir/operation-patient-everything.html\n *\n * @category Read\n * @param id The Patient Id\n * @param options Optional fetch options.\n * @returns A Bundle of all Resources related to the Patient\n */\n readPatientEverything(id: string, options: RequestInit = {}): ReadablePromise<Bundle> {\n return this.get(this.fhirUrl('Patient', id, '$everything'), options);\n }\n\n /**\n * Creates a new FHIR resource.\n *\n * The return value is the newly created resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createResource({\n * resourceType: 'Patient',\n * name: [{\n * family: 'Smith',\n * given: ['John']\n * }]\n * });\n * console.log(result.id);\n * ```\n *\n * See the FHIR \"create\" operation for full details: https://www.hl7.org/fhir/http.html#create\n *\n * @category Create\n * @param resource The FHIR resource to create.\n * @returns The result of the create operation.\n */\n createResource<T extends Resource>(resource: T): Promise<T> {\n if (!resource.resourceType) {\n throw new Error('Missing resourceType');\n }\n this.invalidateSearches(resource.resourceType);\n return this.post(this.fhirUrl(resource.resourceType), resource);\n }\n\n /**\n * Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.\n *\n * The return value is the existing resource or the newly created resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createResourceIfNoneExist(\n * {\n * resourceType: 'Patient',\n * identifier: [{\n * system: 'http://example.com/mrn',\n * value: '123'\n * }]\n * name: [{\n * family: 'Smith',\n * given: ['John']\n * }]\n * },\n * 'identifier=123'\n * );\n * console.log(result.id);\n * ```\n *\n * This method is syntactic sugar for:\n *\n * ```typescript\n * return searchOne(resourceType, query) ?? createResource(resource);\n * ```\n *\n * The query parameter only contains the search parameters (what would be in the URL following the \"?\").\n *\n * See the FHIR \"conditional create\" operation for full details: https://www.hl7.org/fhir/http.html#ccreate\n *\n * @category Create\n * @param resource The FHIR resource to create.\n * @param query The search query for an equivalent resource (should not include resource type or \"?\").\n * @returns The result of the create operation.\n */\n async createResourceIfNoneExist<T extends Resource>(resource: T, query: string): Promise<T> {\n return ((await this.searchOne(resource.resourceType, query)) ?? this.createResource(resource)) as Promise<T>;\n }\n\n /**\n * Creates a FHIR `Binary` resource with the provided data content.\n *\n * The return value is the newly created resource, including the ID and meta.\n *\n * The `data` parameter can be a string or a `File` object.\n *\n * A `File` object often comes from a `<input type=\"file\">` element.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createBinary(myFile, 'test.jpg', 'image/jpeg');\n * console.log(result.id);\n * ```\n *\n * See the FHIR \"create\" operation for full details: https://www.hl7.org/fhir/http.html#create\n *\n * @category Create\n * @param data The binary data to upload.\n * @param filename Optional filename for the binary.\n * @param contentType Content type for the binary.\n * @returns The result of the create operation.\n */\n createBinary(\n data: string | File | Blob | Uint8Array,\n filename: string | undefined,\n contentType: string,\n onProgress?: (e: ProgressEvent) => void\n ): Promise<Binary> {\n const url = this.fhirUrl('Binary');\n if (filename) {\n url.searchParams.set('_filename', filename);\n }\n\n if (onProgress) {\n return this.uploadwithProgress(url, data, contentType, onProgress);\n } else {\n return this.post(url, data, contentType);\n }\n }\n\n uploadwithProgress(\n url: URL,\n data: string | File | Blob | Uint8Array,\n contentType: string,\n onProgress: (e: ProgressEvent) => void\n ): Promise<any> {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.responseType = 'json';\n xhr.onabort = () => reject(new Error('Request aborted'));\n xhr.onerror = () => reject(new Error('Request error'));\n\n if (onProgress) {\n xhr.upload.onprogress = (e) => onProgress(e);\n xhr.upload.onload = (e) => onProgress(e);\n }\n\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve(xhr.response);\n } else {\n reject(new Error(xhr.statusText));\n }\n };\n\n xhr.open('POST', url);\n xhr.withCredentials = true;\n xhr.setRequestHeader('Authorization', 'Bearer ' + this.#accessToken);\n xhr.setRequestHeader('Cache-Control', 'no-cache, no-store, max-age=0');\n xhr.setRequestHeader('Content-Type', contentType);\n xhr.setRequestHeader('X-Medplum', 'extended');\n xhr.send(data);\n });\n }\n\n /**\n * Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.\n *\n * The return value is the newly created resource, including the ID and meta.\n *\n * The `docDefinition` parameter is a pdfmake document definition.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createPdf({\n * content: ['Hello world']\n * });\n * console.log(result.id);\n * ```\n *\n * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/\n *\n * @category Media\n * @param docDefinition The PDF document definition.\n * @returns The result of the create operation.\n */\n async createPdf(\n docDefinition: TDocumentDefinitions,\n filename?: string,\n tableLayouts?: { [name: string]: CustomTableLayout },\n fonts?: TFontDictionary\n ): Promise<Binary> {\n if (!this.#createPdf) {\n throw new Error('PDF creation not enabled');\n }\n const blob = await this.#createPdf(docDefinition, tableLayouts, fonts);\n return this.createBinary(blob, filename, 'application/pdf');\n }\n\n /**\n * Creates a FHIR `Communication` resource with the provided data content.\n *\n * This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.\n *\n * @category Create\n * @param resource The FHIR resource to comment on.\n * @param text The text of the comment.\n * @returns The result of the create operation.\n */\n createComment(resource: Resource, text: string): Promise<Communication> {\n const profile = this.getProfile();\n let encounter: Reference<Encounter> | undefined = undefined;\n let subject: Reference<Patient> | undefined = undefined;\n\n if (resource.resourceType === 'Encounter') {\n encounter = createReference(resource);\n subject = resource.subject as Reference<Patient> | undefined;\n }\n\n if (resource.resourceType === 'ServiceRequest') {\n encounter = resource.encounter;\n subject = resource.subject as Reference<Patient> | undefined;\n }\n\n if (resource.resourceType === 'Patient') {\n subject = createReference(resource);\n }\n\n return this.createResource<Communication>({\n resourceType: 'Communication',\n basedOn: [createReference(resource)],\n encounter,\n subject,\n sender: profile ? createReference(profile) : undefined,\n sent: new Date().toISOString(),\n payload: [{ contentString: text }],\n });\n }\n\n /**\n * Updates a FHIR resource.\n *\n * The return value is the updated resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.updateResource({\n * resourceType: 'Patient',\n * id: '123',\n * name: [{\n * family: 'Smith',\n * given: ['John']\n * }]\n * });\n * console.log(result.meta.versionId);\n * ```\n *\n * See the FHIR \"update\" operation for full details: https://www.hl7.org/fhir/http.html#update\n *\n * @category Write\n * @param resource The FHIR resource to update.\n * @returns The result of the update operation.\n */\n async updateResource<T extends Resource>(resource: T): Promise<T> {\n if (!resource.resourceType) {\n throw new Error('Missing resourceType');\n }\n if (!resource.id) {\n throw new Error('Missing id');\n }\n this.invalidateSearches(resource.resourceType);\n let result = await this.put(this.fhirUrl(resource.resourceType, resource.id), resource);\n if (!result) {\n // On 304 not modified, result will be undefined\n // Return the user input instead\n // return result ?? resource;\n result = resource;\n }\n this.#cacheResource(result);\n return result;\n }\n\n /**\n * Updates a FHIR resource using JSONPatch operations.\n *\n * The return value is the updated resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.patchResource('Patient', '123', [\n * {op: 'replace', path: '/name/0/family', value: 'Smith'},\n * ]);\n * console.log(result.meta.versionId);\n * ```\n *\n * See the FHIR \"update\" operation for full details: https://www.hl7.org/fhir/http.html#patch\n *\n * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902\n *\n * @category Write\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param operations The JSONPatch operations.\n * @returns The result of the patch operations.\n */\n patchResource<K extends ResourceType>(\n resourceType: K,\n id: string,\n operations: PatchOperation[]\n ): Promise<ExtractResource<K>> {\n this.invalidateSearches(resourceType);\n return this.patch(this.fhirUrl(resourceType, id), operations);\n }\n\n /**\n * Deletes a FHIR resource by resource type and ID.\n *\n * Example:\n *\n * ```typescript\n * await medplum.deleteResource('Patient', '123');\n * ```\n *\n * See the FHIR \"delete\" operation for full details: https://www.hl7.org/fhir/http.html#delete\n *\n * @category Delete\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @returns The result of the delete operation.\n */\n deleteResource(resourceType: ResourceType, id: string): Promise<any> {\n this.#deleteCacheEntry(this.fhirUrl(resourceType, id).toString());\n this.invalidateSearches(resourceType);\n return this.delete(this.fhirUrl(resourceType, id));\n }\n\n /**\n * Executes the validate operation with the provided resource.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.validateResource({\n * resourceType: 'Patient',\n * name: [{ given: ['Alice'], family: 'Smith' }],\n * });\n * ```\n *\n * See the FHIR \"$validate\" operation for full details: https://www.hl7.org/fhir/resource-operation-validate.html\n *\n * @param resource The FHIR resource.\n * @returns The validate operation outcome.\n */\n validateResource<T extends Resource>(resource: T): Promise<OperationOutcome> {\n return this.post(this.fhirUrl(resource.resourceType, '$validate'), resource);\n }\n\n /**\n * Executes a batch or transaction of FHIR operations.\n *\n * Example:\n *\n * ```typescript\n * await medplum.executeBatch({\n * \"resourceType\": \"Bundle\",\n * \"type\": \"transaction\",\n * \"entry\": [\n * {\n * \"fullUrl\": \"urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a\",\n * \"resource\": {\n * \"resourceType\": \"Patient\",\n * \"name\": [{ \"use\": \"official\", \"given\": [\"Alice\"], \"family\": \"Smith\" }],\n * \"gender\": \"female\",\n * \"birthDate\": \"1974-12-25\"\n * },\n * \"request\": {\n * \"method\": \"POST\",\n * \"url\": \"Patient\"\n * }\n * },\n * {\n * \"fullUrl\": \"urn:uuid:88f151c0-a954-468a-88bd-5ae15c08e059\",\n * \"resource\": {\n * \"resourceType\": \"Patient\",\n * \"identifier\": [{ \"system\": \"http:/example.org/fhir/ids\", \"value\": \"234234\" }],\n * \"name\": [{ \"use\": \"official\", \"given\": [\"Bob\"], \"family\": \"Jones\" }],\n * \"gender\": \"male\",\n * \"birthDate\": \"1974-12-25\"\n * },\n * \"request\": {\n * \"method\": \"POST\",\n * \"url\": \"Patient\",\n * \"ifNoneExist\": \"identifier=http:/example.org/fhir/ids|234234\"\n * }\n * }\n * ]\n * });\n * ```\n *\n * See The FHIR \"batch/transaction\" section for full details: https://hl7.org/fhir/http.html#transaction\n * @category Batch\n * @param bundle The FHIR batch/transaction bundle.\n * @returns The FHIR batch/transaction response bundle.\n */\n executeBatch(bundle: Bundle): Promise<Bundle> {\n return this.post('fhir/R4', bundle);\n }\n\n /**\n * Sends an email using the Medplum Email API.\n *\n * Builds the email using nodemailer MailComposer.\n *\n * Examples:\n *\n * Send a simple text email:\n *\n * ```typescript\n * await medplum.sendEmail({\n * to: 'alice@example.com',\n * cc: 'bob@example.com',\n * subject: 'Hello',\n * text: 'Hello Alice',\n * });\n * ```\n *\n * Send an email with a `Binary` attachment:\n *\n * ```typescript\n * await medplum.sendEmail({\n * to: 'alice@example.com',\n * subject: 'Email with attachment',\n * text: 'See the attached report',\n * attachments: [{\n * filename: 'report.pdf',\n * path: \"Binary/\" + binary.id\n * }]\n * });\n * ```\n *\n * See options here: https://nodemailer.com/extras/mailcomposer/\n * @category Media\n * @param options The MailComposer options.\n * @returns Promise to the operation outcome.\n */\n sendEmail(email: MailOptions): Promise<OperationOutcome> {\n return this.post('email/v1/send', email, 'application/json');\n }\n\n /**\n * Executes a GraphQL query.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.graphql(`{\n * Patient(id: \"123\") {\n * resourceType\n * id\n * name {\n * given\n * family\n * }\n * }\n * }`);\n * ```\n *\n * Advanced queries such as named operations and variable substitution are supported:\n *\n * ```typescript\n * const result = await medplum.graphql(\n * `query GetPatientById($patientId: ID!) {\n * Patient(id: $patientId) {\n * resourceType\n * id\n * name {\n * given\n * family\n * }\n * }\n * }`,\n * 'GetPatientById',\n * { patientId: '123' }\n * );\n * ```\n *\n * See the GraphQL documentation for more details: https://graphql.org/learn/\n *\n * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html\n *\n * @category Read\n * @param query The GraphQL query.\n * @param operationName Optional GraphQL operation name.\n * @param variables Optional GraphQL variables.\n * @param options Optional fetch options.\n * @returns The GraphQL result.\n */\n graphql(query: string, operationName?: string | null, variables?: any, options?: RequestInit): Promise<any> {\n return this.post(this.fhirUrl('$graphql'), { query, operationName, variables }, JSON_CONTENT_TYPE, options);\n }\n\n /**\n *\n * Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource\n * according to a graph definition\n\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param graphName `name` parameter of the GraphDefinition\n * @returns A Bundle\n */\n readResourceGraph<K extends ResourceType>(\n resourceType: K,\n id: string,\n graphName: string\n ): ReadablePromise<Bundle<Resource>> {\n return this.get<Bundle<Resource>>(`${this.fhirUrl(resourceType, id)}/$graph?graph=${graphName}`);\n }\n\n /**\n * @category Authentication\n * @returns The Login State\n */\n getActiveLogin(): LoginState | undefined {\n return this.#storage.getObject('activeLogin');\n }\n\n /**\n * @category Authentication\n */\n async setActiveLogin(login: LoginState): Promise<void> {\n this.clearActiveLogin();\n this.#accessToken = login.accessToken;\n this.#refreshToken = login.refreshToken;\n this.#storage.setObject('activeLogin', login);\n this.#addLogin(login);\n this.#refreshPromise = undefined;\n await this.#refreshProfile();\n }\n\n /**\n * @category Authentication\n */\n getAccessToken(): string | undefined {\n return this.#accessToken;\n }\n\n /**\n * @category Authentication\n */\n setAccessToken(accessToken: string): void {\n this.#accessToken = accessToken;\n this.#refreshToken = undefined;\n this.#profile = undefined;\n this.#config = undefined;\n }\n\n /**\n * @category Authentication\n */\n getLogins(): LoginState[] {\n return this.#storage.getObject<LoginState[]>('logins') ?? [];\n }\n\n #addLogin(newLogin: LoginState): void {\n const logins = this.getLogins().filter((login) => login.profile?.reference !== newLogin.profile?.reference);\n logins.push(newLogin);\n this.#storage.setObject('logins', logins);\n }\n\n async #refreshProfile(): Promise<ProfileResource | undefined> {\n this.#profilePromise = new Promise((resolve, reject) => {\n this.get('auth/me')\n .then((result) => {\n this.#profilePromise = undefined;\n this.#profile = result.profile;\n this.#config = result.config;\n this.dispatchEvent({ type: 'change' });\n resolve(this.#profile);\n })\n .catch(reject);\n });\n\n return this.#profilePromise;\n }\n\n /**\n * @category Authentication\n */\n isLoading(): boolean {\n return !!this.#profilePromise;\n }\n\n /**\n * @category User Profile\n */\n getProfile(): ProfileResource | undefined {\n return this.#profile;\n }\n\n /**\n * @category User Profile\n */\n async getProfileAsync(): Promise<ProfileResource | undefined> {\n if (this.#profilePromise) {\n await this.#profilePromise;\n }\n return this.getProfile();\n }\n\n /**\n * @category User Profile\n */\n getUserConfiguration(): UserConfiguration | undefined {\n return this.#config;\n }\n\n /**\n * Downloads the URL as a blob.\n *\n * @category Read\n * @param url The URL to request.\n * @returns Promise to the response body as a blob.\n */\n async download(url: URL | string, options: RequestInit = {}): Promise<Blob> {\n if (this.#refreshPromise) {\n await this.#refreshPromise;\n }\n this.#addFetchOptionsDefaults(options);\n const response = await this.#fetch(url.toString(), options);\n return response.blob();\n }\n\n //\n // Private helpers\n //\n\n /**\n * Returns the cache entry if available and not expired.\n * @param key The cache key to retrieve.\n * @param options Optional fetch options for cache settings.\n * @returns The cached entry if found.\n */\n #getCacheEntry(key: string, options: RequestInit | undefined): RequestCacheEntry | undefined {\n if (this.#cacheTime <= 0 || options?.cache === 'no-cache' || options?.cache === 'reload') {\n return undefined;\n }\n const entry = this.#requestCache.get(key);\n if (!entry || entry.requestTime + this.#cacheTime < Date.now()) {\n return undefined;\n }\n return entry;\n }\n\n /**\n * Adds a readable promise to the cache.\n * @param key The cache key to store.\n * @param value The readable promise to store.\n */\n #setCacheEntry(key: string, value: ReadablePromise<any>): void {\n if (this.#cacheTime > 0) {\n this.#requestCache.set(key, { requestTime: Date.now(), value });\n }\n }\n\n /**\n * Adds a concrete value as the cache entry for the given resource.\n * This is used in cases where the resource is loaded indirectly.\n * For example, when a resource is loaded as part of a Bundle.\n * @param resource The resource to cache.\n */\n #cacheResource(resource: Resource | undefined): void {\n if (resource?.id) {\n this.#setCacheEntry(\n this.fhirUrl(resource.resourceType, resource.id).toString(),\n new ReadablePromise(Promise.resolve(resource))\n );\n }\n }\n\n /**\n * Deletes a cache entry.\n * @param key The cache key to delete.\n */\n #deleteCacheEntry(key: string): void {\n if (this.#cacheTime > 0) {\n this.#requestCache.delete(key);\n }\n }\n\n /**\n * Makes an HTTP request.\n * @param {string} method\n * @param {string} url\n * @param {string=} contentType\n * @param {Object=} body\n */\n async #request<T>(method: string, url: string, options: RequestInit = {}): Promise<T> {\n if (this.#refreshPromise) {\n await this.#refreshPromise;\n }\n\n if (!url.startsWith('http')) {\n url = this.#baseUrl + url;\n }\n\n options.method = method;\n this.#addFetchOptionsDefaults(options);\n\n const response = await this.#fetchWithRetry(url, options);\n if (response.status === 401) {\n // Refresh and try again\n return this.#handleUnauthenticated(method, url, options);\n }\n\n if (response.status === 204 || response.status === 304) {\n // No content or change\n return undefined as unknown as T;\n }\n\n let obj: any = undefined;\n try {\n obj = await response.json();\n } catch (err) {\n console.error('Error parsing response', response.status, err);\n throw err;\n }\n\n if (response.status >= 400) {\n throw obj;\n }\n return obj;\n }\n\n async #fetchWithRetry(url: string, options: RequestInit): Promise<Response> {\n const maxRetries = 3;\n const retryDelay = 200;\n let response: Response | undefined = undefined;\n for (let retry = 0; retry < maxRetries; retry++) {\n response = (await this.#fetch(url, options)) as Response;\n if (response.status < 500) {\n return response;\n }\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n }\n return response as Response;\n }\n\n /**\n * Executes a batch of requests that were automatically batched together.\n */\n async #executeAutoBatch(): Promise<void> {\n // Get the current queue\n const entries = [...this.#autoBatchQueue];\n\n // Clear the queue\n this.#autoBatchQueue.length = 0;\n\n // Clear the timer\n this.#autoBatchTimerId = undefined;\n\n // If there is only one request in the batch, just execute it\n if (entries.length === 1) {\n const entry = entries[0];\n entry.resolve(await this.#request(entry.method, this.#fhirBaseUrl + entry.url, entry.options));\n return;\n }\n\n // Build the batch request\n const batch: Bundle = {\n resourceType: 'Bundle',\n type: 'batch',\n entry: entries.map(\n (e) =>\n ({\n request: {\n method: e.method,\n url: e.url,\n },\n resource: e.options.body ? (JSON.parse(e.options.body as string) as Resource) : undefined,\n } as BundleEntry)\n ),\n };\n\n // Execute the batch request\n const response = (await this.post('fhir/R4', batch)) as Bundle;\n\n // Process the response\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n const responseEntry = response.entry?.[i];\n if (responseEntry?.response?.outcome && !isOk(responseEntry.response.outcome as OperationOutcome)) {\n entry.reject(responseEntry.response.outcome);\n } else {\n entry.resolve(responseEntry?.resource);\n }\n }\n }\n\n /**\n * Adds default options to the fetch options.\n * @param options The options to add defaults to.\n */\n #addFetchOptionsDefaults(options: RequestInit): void {\n if (!options.headers) {\n options.headers = {};\n }\n\n const headers = options.headers as Record<string, string>;\n headers['X-Medplum'] = 'extended';\n\n if (!headers['Content-Type']) {\n headers['Content-Type'] = FHIR_CONTENT_TYPE;\n }\n\n if (this.#accessToken) {\n headers['Authorization'] = 'Bearer ' + this.#accessToken;\n }\n\n if (!options.cache) {\n options.cache = 'no-cache';\n }\n\n if (!options.credentials) {\n options.credentials = 'include';\n }\n }\n\n /**\n * Sets the \"Content-Type\" header on fetch options.\n * @param options The fetch options.\n * @param contentType The new content type to set.\n */\n #setRequestContentType(options: RequestInit, contentType: string): void {\n if (!options.headers) {\n options.headers = {};\n }\n const headers = options.headers as Record<string, string>;\n headers['Content-Type'] = contentType;\n }\n\n /**\n * Sets the body on fetch options.\n * @param options The fetch options.\n * @param data The new content body.\n */\n #setRequestBody(options: RequestInit, data: any): void {\n if (\n typeof data === 'string' ||\n (typeof Blob !== 'undefined' && data instanceof Blob) ||\n (typeof File !== 'undefined' && data instanceof File) ||\n (typeof Uint8Array !== 'undefined' && data instanceof Uint8Array)\n ) {\n options.body = data;\n } else if (data) {\n options.body = JSON.stringify(data);\n }\n }\n\n /**\n * Handles an unauthenticated response from the server.\n * First, tries to refresh the access token and retry the request.\n * Otherwise, calls unauthenticated callbacks and rejects.\n * @param method The HTTP method of the original request.\n * @param url The URL of the original request.\n * @param contentType The content type of the original request.\n * @param body The body of the original request.\n */\n #handleUnauthenticated(method: string, url: string, options: RequestInit): Promise<any> {\n if (this.#refresh()) {\n return this.#request(method, url, options);\n }\n this.clearActiveLogin();\n if (this.#onUnauthenticated) {\n this.#onUnauthenticated();\n }\n return Promise.reject(new Error('Unauthenticated'));\n }\n\n /**\n * Starts a new PKCE flow.\n * These PKCE values are stateful, and must survive redirects and page refreshes.\n */\n async startPkce(): Promise<{ codeChallengeMethod: string; codeChallenge: string }> {\n const pkceState = getRandomString();\n sessionStorage.setItem('pkceState', pkceState);\n\n const codeVerifier = getRandomString();\n sessionStorage.setItem('codeVerifier', codeVerifier);\n\n const arrayHash = await encryptSHA256(codeVerifier);\n const codeChallenge = arrayBufferToBase64(arrayHash).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n sessionStorage.setItem('codeChallenge', codeChallenge);\n\n return { codeChallengeMethod: 'S256', codeChallenge };\n }\n\n /**\n * Redirects the user to the login screen for authorization.\n * Clears all auth state including local storage and session storage.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint\n */\n async #requestAuthorization(loginParams?: Partial<BaseLoginRequest>): Promise<void> {\n const loginRequest = await this.ensureCodeChallenge(loginParams || {});\n const url = new URL(this.#authorizeUrl);\n url.searchParams.set('response_type', 'code');\n url.searchParams.set('state', sessionStorage.getItem('pkceState') as string);\n url.searchParams.set('client_id', loginRequest.clientId || (this.#clientId as string));\n url.searchParams.set('redirect_uri', loginRequest.redirectUri || getWindowOrigin());\n url.searchParams.set('code_challenge_method', loginRequest.codeChallengeMethod as string);\n url.searchParams.set('code_challenge', loginRequest.codeChallenge as string);\n url.searchParams.set('scope', loginRequest.scope || 'openid profile');\n window.location.assign(url.toString());\n }\n\n /**\n * Processes an OAuth authorization code.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest\n * @param code The authorization code received by URL parameter.\n */\n processCode(code: string): Promise<ProfileResource> {\n const formBody = new URLSearchParams();\n formBody.set('grant_type', 'authorization_code');\n formBody.set('client_id', this.#clientId as string);\n formBody.set('code', code);\n formBody.set('redirect_uri', getWindowOrigin());\n\n const codeVerifier = sessionStorage.getItem('codeVerifier');\n if (codeVerifier) {\n formBody.set('code_verifier', codeVerifier);\n }\n\n return this.#fetchTokens(formBody);\n }\n\n /**\n * Tries to refresh the auth tokens.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens\n */\n #refresh(): Promise<void> | undefined {\n if (this.#refreshPromise) {\n return this.#refreshPromise;\n }\n\n if (this.#refreshToken) {\n const formBody = new URLSearchParams();\n formBody.set('grant_type', 'refresh_token');\n formBody.set('client_id', this.#clientId as string);\n formBody.set('refresh_token', this.#refreshToken);\n this.#refreshPromise = this.#fetchTokens(formBody);\n return this.#refreshPromise;\n }\n\n if (this.#clientId && this.#clientSecret) {\n this.#refreshPromise = this.startClientLogin(this.#clientId, this.#clientSecret);\n return this.#refreshPromise;\n }\n\n return undefined;\n }\n\n /**\n * Starts a new OAuth2 client credentials flow.\n * See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4\n * @category Authentication\n * @param clientId The client ID.\n * @param clientSecret The client secret.\n * @returns Promise that resolves to the client profile.\n */\n async startClientLogin(clientId: string, clientSecret: string): Promise<ProfileResource> {\n this.#clientId = clientId;\n this.#clientSecret = clientSecret;\n\n const formBody = new URLSearchParams();\n formBody.set('grant_type', 'client_credentials');\n formBody.set('client_id', clientId);\n formBody.set('client_secret', clientSecret);\n return this.#fetchTokens(formBody);\n }\n\n /**\n * Makes a POST request to the tokens endpoint.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint\n * @param formBody Token parameters in URL encoded format.\n */\n async #fetchTokens(formBody: URLSearchParams): Promise<ProfileResource> {\n const response = await this.#fetch(this.#tokenUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: formBody,\n credentials: 'include',\n });\n if (!response.ok) {\n this.clearActiveLogin();\n throw new Error('Failed to fetch tokens');\n }\n const tokens = await response.json();\n await this.#verifyTokens(tokens);\n return this.getProfile() as ProfileResource;\n }\n\n /**\n * Verifies the tokens received from the auth server.\n * Validates the JWT against the JWKS.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint\n * @param tokens\n */\n async #verifyTokens(tokens: TokenResponse): Promise<void> {\n const token = tokens.access_token;\n\n // Verify token has not expired\n const tokenPayload = parseJWTPayload(token);\n if (Date.now() >= (tokenPayload.exp as number) * 1000) {\n this.clearActiveLogin();\n throw new Error('Token expired');\n }\n\n // Verify app_client_id\n if (this.#clientId && tokenPayload.client_id !== this.#clientId) {\n this.clearActiveLogin();\n throw new Error('Token was not issued for this audience');\n }\n\n return this.setActiveLogin({\n accessToken: token,\n refreshToken: tokens.refresh_token,\n project: tokens.project,\n profile: tokens.profile,\n });\n }\n\n /**\n * Sets up a listener for window storage events.\n * This synchronizes state across browser windows and browser tabs.\n */\n #setupStorageListener(): void {\n try {\n window.addEventListener('storage', (e: StorageEvent) => {\n if (e.key === null || e.key === 'activeLogin') {\n // Storage events fire when different tabs make changes.\n // On storage clear (key === null) or activeLogin change (key === 'activeLogin')\n // Refresh the page to ensure the active login is up to date.\n window.location.reload();\n }\n });\n } catch (err) {\n // Silently ignore if this environment does not support storage events\n }\n }\n}\n\n/**\n * Returns the current window if available.\n * All access to the current window should use this to support SSR such as Next.js.\n * @returns The current window or undefined if not available.\n */\nfunction getWindow(): Window | undefined {\n return typeof window === 'undefined' ? undefined : window;\n}\n\n/**\n * Returns the default fetch method.\n * The default fetch is currently only available in browser environments.\n * If you want to use SSR such as Next.js, you should pass a custom fetch function.\n * @returns The default fetch function for the current environment.\n */\nfunction getDefaultFetch(): FetchLike {\n const window = getWindow();\n if (!window) {\n throw new Error('Fetch not available in this environment');\n }\n return window.fetch.bind(window);\n}\n\n/**\n * Returns the base URL for the current page.\n * @category HTTP\n */\nfunction getWindowOrigin(): string {\n const window = getWindow();\n return window ? window.location.protocol + '//' + window.location.host + '/' : '';\n}\n\nfunction ensureTrailingSlash(url: string | undefined): string | undefined {\n if (!url) {\n return url;\n }\n return url.endsWith('/') ? url : url + '/';\n}\n","import { TypedValue } from '../types';\nimport { Token } from './tokenize';\n\nexport interface Atom {\n eval(context: TypedValue[]): TypedValue[];\n}\n\nexport abstract class PrefixOperatorAtom implements Atom {\n constructor(public readonly operator: string, public readonly child: Atom) {}\n\n abstract eval(context: TypedValue[]): TypedValue[];\n\n toString(): string {\n return `${this.operator}(${this.child.toString()})`;\n }\n}\n\nexport abstract class InfixOperatorAtom implements Atom {\n constructor(public readonly operator: string, public readonly left: Atom, public readonly right: Atom) {}\n\n abstract eval(context: TypedValue[]): TypedValue[];\n\n toString(): string {\n return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;\n }\n}\n\nexport interface PrefixParselet {\n parse(parser: Parser, token: Token): Atom;\n}\n\nexport interface InfixParselet {\n precedence: number;\n parse?(parser: Parser, left: Atom, token: Token): Atom;\n}\n\nexport class ParserBuilder {\n readonly #prefixParselets: Record<string, PrefixParselet> = {};\n readonly #infixParselets: Record<string, InfixParselet> = {};\n\n public registerInfix(tokenType: string, parselet: InfixParselet): ParserBuilder {\n this.#infixParselets[tokenType] = parselet;\n return this;\n }\n\n public registerPrefix(tokenType: string, parselet: PrefixParselet): ParserBuilder {\n this.#prefixParselets[tokenType] = parselet;\n return this;\n }\n\n public prefix(tokenType: string, precedence: number, builder: (token: Token, right: Atom) => Atom): ParserBuilder {\n return this.registerPrefix(tokenType, {\n parse(parser, token) {\n const right = parser.consumeAndParse(precedence);\n return builder(token, right);\n },\n });\n }\n\n public infixLeft(\n tokenType: string,\n precedence: number,\n builder: (left: Atom, token: Token, right: Atom) => Atom\n ): ParserBuilder {\n return this.registerInfix(tokenType, {\n parse(parser, left, token) {\n const right = parser.consumeAndParse(precedence);\n return builder(left, token, right);\n },\n precedence,\n });\n }\n\n public construct(input: Token[]): Parser {\n return new Parser(input, this.#prefixParselets, this.#infixParselets);\n }\n}\n\nexport class Parser {\n #tokens: Token[];\n #prefixParselets: Record<string, PrefixParselet>;\n #infixParselets: Record<string, InfixParselet>;\n\n constructor(\n tokens: Token[],\n prefixParselets: Record<string, PrefixParselet>,\n infixParselets: Record<string, InfixParselet>\n ) {\n this.#tokens = tokens;\n this.#prefixParselets = prefixParselets;\n this.#infixParselets = infixParselets;\n }\n\n hasMore(): boolean {\n return this.#tokens.length > 0;\n }\n\n match(expected: string): boolean {\n const token = this.peek();\n if (token?.id !== expected) {\n return false;\n }\n\n this.consume();\n return true;\n }\n\n consumeAndParse(precedence = Infinity): Atom {\n const token = this.consume();\n const prefix = this.#prefixParselets[token.id];\n if (!prefix) {\n throw Error(\n `Parse error at \"${token.value}\" (line ${token.line}, column ${token.column}). No matching prefix parselet.`\n );\n }\n\n let left = prefix.parse(this, token);\n\n while (precedence > this.getPrecedence()) {\n const next = this.consume();\n const infix = this.getInfixParselet(next) as InfixParselet;\n left = (infix.parse as (parser: Parser, left: Atom, token: Token) => Atom)(this, left, next);\n }\n\n return left;\n }\n\n getPrecedence(): number {\n const nextToken = this.peek();\n if (!nextToken) {\n return Infinity;\n }\n const parser = this.getInfixParselet(nextToken);\n if (parser) {\n return parser.precedence;\n }\n return Infinity;\n }\n\n consume(expectedId?: string, expectedValue?: string): Token {\n if (!this.#tokens.length) {\n throw Error('Cant consume unknown more tokens.');\n }\n if (expectedId && this.peek()?.id !== expectedId) {\n const actual = this.peek() as Token;\n throw Error(`Expected ${expectedId} but got \"${actual.id}\" at line ${actual.line} column ${actual.column}.`);\n }\n if (expectedValue && this.peek()?.value !== expectedValue) {\n const actual = this.peek() as Token;\n throw Error(\n `Expected \"${expectedValue}\" but got \"${actual.value}\" at line ${actual.line} column ${actual.column}.`\n );\n }\n return this.#tokens.shift() as Token;\n }\n\n peek(): Token | undefined {\n return this.#tokens.length > 0 ? this.#tokens[0] : undefined;\n }\n\n removeComments(): void {\n this.#tokens = this.#tokens.filter((t) => t.id !== 'Comment');\n }\n\n getInfixParselet(token: Token): InfixParselet | undefined {\n return this.#infixParselets[token.id === 'Symbol' ? token.value : token.id];\n }\n}\n","export interface Marker {\n index: number;\n line: number;\n column: number;\n}\n\nexport interface Token extends Marker {\n id: string;\n value: string;\n}\n\nconst STANDARD_UNITS = [\n 'year',\n 'years',\n 'month',\n 'months',\n 'week',\n 'weeks',\n 'day',\n 'days',\n 'hour',\n 'hours',\n 'minute',\n 'minutes',\n 'second',\n 'seconds',\n 'millisecond',\n 'milliseconds',\n];\n\nexport class Tokenizer {\n readonly #str: string;\n readonly #keywords: string[];\n readonly #operators: string[];\n readonly #result: Token[] = [];\n readonly #pos: Marker = { index: 0, line: 1, column: 0 };\n readonly #markStack: Marker[] = [];\n\n constructor(str: string, keywords: string[], operators: string[]) {\n this.#str = str;\n this.#keywords = keywords;\n this.#operators = operators;\n }\n\n tokenize(): Token[] {\n while (this.#pos.index < this.#str.length) {\n const token = this.#consumeToken();\n if (token) {\n this.#result.push(token);\n }\n }\n\n return this.#result;\n }\n\n #prevToken(): Token | undefined {\n return this.#result.slice(-1)[0];\n }\n\n #peekToken(): Token | undefined {\n this.#mark();\n const token = this.#consumeToken();\n this.#reset();\n return token;\n }\n\n #consumeToken(): Token | undefined {\n this.#consumeWhitespace();\n\n const c = this.#curr();\n if (!c) {\n return undefined;\n }\n\n this.#mark();\n\n const next = this.#peek();\n\n if (c === '/' && next === '*') {\n return this.#consumeMultiLineComment();\n }\n\n if (c === '/' && next === '/') {\n return this.#consumeSingleLineComment();\n }\n\n if (c === \"'\" || c === '\"') {\n return this.#consumeString(c);\n }\n\n if (c === '`') {\n return this.#consumeBacktickSymbol();\n }\n\n if (c === '@') {\n return this.#consumeDateTime();\n }\n\n if (c.match(/\\d/)) {\n return this.#consumeNumber();\n }\n\n if (c.match(/\\w/)) {\n return this.#consumeSymbol();\n }\n\n if (c === '$' && next.match(/\\w/)) {\n return this.#consumeSymbol();\n }\n\n return this.#consumeOperator();\n }\n\n #consumeWhitespace(): void {\n this.#consumeWhile(() => this.#curr().match(/\\s/));\n }\n\n #consumeMultiLineComment(): Token {\n const start = this.#pos.index;\n this.#consumeWhile(() => this.#curr() !== '*' || this.#peek() !== '/');\n this.#advance();\n this.#advance();\n return this.#buildToken('Comment', this.#str.substring(start, this.#pos.index));\n }\n\n #consumeSingleLineComment(): Token {\n return this.#buildToken(\n 'Comment',\n this.#consumeWhile(() => this.#curr() !== '\\n')\n );\n }\n\n #consumeString(endChar: string): Token {\n this.#advance();\n const result = this.#buildToken(\n 'String',\n this.#consumeWhile(() => this.#prev() === '\\\\' || this.#curr() !== endChar)\n );\n this.#advance();\n return result;\n }\n\n #consumeBacktickSymbol(): Token {\n this.#advance();\n const result = this.#buildToken(\n 'Symbol',\n this.#consumeWhile(() => this.#curr() !== '`')\n );\n this.#advance();\n return result;\n }\n\n #consumeDateTime(): Token {\n this.#advance(); // Consume \"@\"\n\n const start = this.#pos.index;\n this.#consumeWhile(() => this.#curr().match(/[\\d-]/));\n\n if (this.#curr() === 'T') {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/[\\d:]/));\n\n if (this.#curr() === '.' && this.#peek().match(/\\d/)) {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/\\d/));\n }\n\n if (this.#curr() === 'Z') {\n this.#advance();\n } else if (this.#curr() === '+' || this.#curr() === '-') {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/[\\d:]/));\n }\n }\n\n return this.#buildToken('DateTime', this.#str.substring(start, this.#pos.index));\n }\n\n #consumeNumber(): Token {\n const start = this.#pos.index;\n let id = 'Number';\n this.#consumeWhile(() => this.#curr().match(/\\d/));\n\n if (this.#curr() === '.' && this.#peek().match(/\\d/)) {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/\\d/));\n }\n\n if (this.#curr() === ' ') {\n if (isUnitToken(this.#peekToken())) {\n id = 'Quantity';\n this.#consumeToken();\n }\n }\n\n return this.#buildToken(id, this.#str.substring(start, this.#pos.index));\n }\n\n #consumeSymbol(): Token {\n const value = this.#consumeWhile(() => this.#curr().match(/[$\\w]/));\n if (this.#prevToken()?.value !== '.' && this.#keywords.includes(value)) {\n return this.#buildToken(value, value);\n }\n return this.#buildToken('Symbol', value);\n }\n\n #consumeOperator(): Token {\n const c = this.#curr();\n const next = this.#peek();\n const twoCharOp = c + next;\n\n if (this.#operators.includes(twoCharOp)) {\n this.#advance();\n this.#advance();\n return this.#buildToken(twoCharOp, twoCharOp);\n }\n\n this.#advance();\n return this.#buildToken(c, c);\n }\n\n #consumeWhile(condition: () => unknown): string {\n const start = this.#pos.index;\n\n while (this.#pos.index < this.#str.length && condition()) {\n this.#advance();\n }\n\n return this.#str.substring(start, this.#pos.index);\n }\n\n #curr(): string {\n return this.#str[this.#pos.index];\n }\n\n #prev(): string {\n return this.#str[this.#pos.index - 1] ?? '';\n }\n\n #peek(): string {\n return this.#str[this.#pos.index + 1] ?? '';\n }\n\n #mark(): void {\n this.#markStack.push({ ...this.#pos });\n }\n\n #reset(): void {\n const mark = this.#markStack.pop();\n if (!mark) {\n throw new Error('No mark to reset to');\n }\n this.#pos.index = mark.index;\n this.#pos.line = mark.line;\n this.#pos.column = mark.column;\n }\n\n #advance(): void {\n this.#pos.index++;\n if (this.#curr() === '\\n') {\n this.#pos.line++;\n this.#pos.column = 0;\n } else {\n this.#pos.column++;\n }\n }\n\n #buildToken(id: string, value: string): Token {\n const mark = this.#markStack.pop();\n if (!mark) {\n throw new Error('No mark for token');\n }\n return {\n id,\n value,\n ...mark,\n };\n }\n}\n\nfunction isUnitToken(token: Token | undefined): boolean {\n if (token) {\n if (token.id === 'String') {\n return true;\n }\n\n if (token.id === 'Symbol' && STANDARD_UNITS.includes(token.value)) {\n return true;\n }\n }\n\n return false;\n}\n","export function parseDateString(str: string): string {\n if (str.startsWith('T')) {\n // If a time string,\n // then normalize to full length.\n return str + 'T00:00:00.000Z'.substring(str.length);\n }\n\n if (str.length <= 10) {\n // If a local date (i.e., \"2021-01-01\"),\n // then return as-is.\n return str;\n }\n\n try {\n // Try to normalize to UTC\n return new Date(str).toISOString();\n } catch (e) {\n // Fallback to original input\n // This happens on unsupported time formats such as \"2021-01-01T12\"\n return str;\n }\n}\n","import { ElementDefinition, Period, Quantity, Resource } from '@medplum/fhirtypes';\nimport { buildTypeName, getElementDefinition, PropertyType, TypedValue } from '../types';\nimport { capitalize, isEmpty } from '../utils';\n\n/**\n * Returns a single element array with a typed boolean value.\n * @param value The primitive boolean value.\n * @returns Single element array with a typed boolean value.\n */\nexport function booleanToTypedValue(value: boolean): [TypedValue] {\n return [{ type: PropertyType.boolean, value }];\n}\n\n/**\n * Returns a \"best guess\" TypedValue for a given value.\n * @param value The unknown value to check.\n * @returns A \"best guess\" TypedValue for the given value.\n */\nexport function toTypedValue(value: unknown): TypedValue {\n if (value === null || value === undefined) {\n return { type: 'undefined', value: undefined };\n } else if (Number.isSafeInteger(value)) {\n return { type: PropertyType.integer, value };\n } else if (typeof value === 'number') {\n return { type: PropertyType.decimal, value };\n } else if (typeof value === 'boolean') {\n return { type: PropertyType.boolean, value };\n } else if (typeof value === 'string') {\n return { type: PropertyType.string, value };\n } else if (isQuantity(value)) {\n return { type: PropertyType.Quantity, value };\n } else if (typeof value === 'object' && 'resourceType' in value) {\n return { type: (value as Resource).resourceType, value };\n } else {\n return { type: PropertyType.BackboneElement, value };\n }\n}\n\n/**\n * Converts unknown object into a JavaScript boolean.\n * Note that this is different than the FHIRPath \"toBoolean\",\n * which has particular semantics around arrays, empty arrays, and type conversions.\n * @param obj Any value or array of values.\n * @returns The converted boolean value according to FHIRPath rules.\n */\nexport function toJsBoolean(obj: TypedValue[]): boolean {\n return obj.length === 0 ? false : !!obj[0].value;\n}\n\n/**\n * Returns the value of the property and the property type.\n * Some property definitions support multiple types.\n * For example, \"Observation.value[x]\" can be \"valueString\", \"valueInteger\", \"valueQuantity\", etc.\n * According to the spec, there can only be one property for a given element definition.\n * This function returns the value and the type.\n * @param input The base context (FHIR resource or backbone element).\n * @param path The property path.\n * @returns The value of the property and the property type.\n */\nexport function getTypedPropertyValue(input: TypedValue, path: string): TypedValue[] | TypedValue | undefined {\n if (!input?.value) {\n return undefined;\n }\n\n const elementDefinition = getElementDefinition(input.type, path);\n if (elementDefinition) {\n const typedResult = getTypedPropertyValueWithSchema(input, path, elementDefinition);\n if (typedResult) {\n return typedResult;\n }\n }\n\n return getTypedPropertyValueWithoutSchema(input, path);\n}\n\n/**\n * Returns the value of the property and the property type using a type schema.\n * @param input The base context (FHIR resource or backbone element).\n * @param path The property path.\n * @param property The property element definition.\n * @returns The value of the property and the property type.\n */\nfunction getTypedPropertyValueWithSchema(\n input: TypedValue,\n path: string,\n property: ElementDefinition\n): TypedValue[] | TypedValue | undefined {\n const types = property.type;\n if (!types || types.length === 0) {\n return undefined;\n }\n\n let resultValue: any = undefined;\n let resultType = 'undefined';\n\n if (types.length === 1) {\n resultValue = input.value[path];\n resultType = types[0].code as string;\n } else {\n for (const type of types) {\n const path2 = path.replace('[x]', '') + capitalize(type.code as string);\n if (path2 in input.value) {\n resultValue = input.value[path2];\n resultType = type.code as string;\n break;\n }\n }\n }\n\n if (isEmpty(resultValue)) {\n return undefined;\n }\n\n if (resultType === 'Element' || resultType === 'BackboneElement') {\n resultType = buildTypeName(property.path?.split('.') as string[]);\n }\n\n if (Array.isArray(resultValue)) {\n return resultValue.map((element) => toTypedValueWithType(element, resultType));\n } else {\n return toTypedValueWithType(resultValue, resultType);\n }\n}\n\nfunction toTypedValueWithType(value: any, type: string): TypedValue {\n if (type === 'Resource' && typeof value === 'object' && 'resourceType' in value) {\n type = value.resourceType;\n }\n return { type, value };\n}\n\n/**\n * Returns the value of the property and the property type using a type schema.\n * Note that because the type schema is not available, this function may be inaccurate.\n * In some cases, that is the desired behavior.\n * @param typedValue The base context (FHIR resource or backbone element).\n * @param path The property path.\n * @returns The value of the property and the property type.\n */\nfunction getTypedPropertyValueWithoutSchema(\n typedValue: TypedValue,\n path: string\n): TypedValue[] | TypedValue | undefined {\n const input = typedValue.value;\n if (!input || typeof input !== 'object') {\n return undefined;\n }\n\n let result: any = undefined;\n if (path in input) {\n result = (input as { [key: string]: unknown })[path];\n } else {\n // Only support property names that would be valid types\n // Examples:\n // value + valueString = ok, because \"string\" is valid\n // value + valueDecimal = ok, because \"decimal\" is valid\n // id + identifiier = not ok, because \"entifier\" is not a valid type\n // resource + resourceType = not ok, because \"type\" is not a valid type\n for (const propertyType in PropertyType) {\n const propertyName = path + capitalize(propertyType);\n if (propertyName in input) {\n result = (input as { [key: string]: unknown })[propertyName];\n break;\n }\n }\n }\n\n if (isEmpty(result)) {\n return undefined;\n }\n\n if (Array.isArray(result)) {\n return result.map(toTypedValue);\n } else {\n return toTypedValue(result);\n }\n}\n\n/**\n * Removes duplicates in array using FHIRPath equality rules.\n * @param arr The input array.\n * @returns The result array with duplicates removed.\n */\nexport function removeDuplicates(arr: TypedValue[]): TypedValue[] {\n const result: TypedValue[] = [];\n for (const i of arr) {\n let found = false;\n for (const j of result) {\n if (toJsBoolean(fhirPathEquals(i, j))) {\n found = true;\n break;\n }\n }\n if (!found) {\n result.push(i);\n }\n }\n return result;\n}\n\n/**\n * Returns a negated FHIRPath boolean expression.\n * @param input The input array.\n * @returns The negated type value array.\n */\nexport function fhirPathNot(input: TypedValue[]): TypedValue[] {\n return booleanToTypedValue(!toJsBoolean(input));\n}\n\n/**\n * Determines if two arrays are equal according to FHIRPath equality rules.\n * @param x The first array.\n * @param y The second array.\n * @returns FHIRPath true if the arrays are equal.\n */\nexport function fhirPathArrayEquals(x: TypedValue[], y: TypedValue[]): TypedValue[] {\n if (x.length === 0 || y.length === 0) {\n return [];\n }\n if (x.length !== y.length) {\n return booleanToTypedValue(false);\n }\n return booleanToTypedValue(x.every((val, index) => toJsBoolean(fhirPathEquals(val, y[index]))));\n}\n\n/**\n * Determines if two values are equal according to FHIRPath equality rules.\n * @param x The first value.\n * @param y The second value.\n * @returns True if equal.\n */\nexport function fhirPathEquals(x: TypedValue, y: TypedValue): TypedValue[] {\n const xValue = x.value;\n const yValue = y.value;\n if (typeof xValue === 'number' && typeof yValue === 'number') {\n return booleanToTypedValue(Math.abs(xValue - yValue) < 1e-8);\n }\n if (isQuantity(xValue) && isQuantity(yValue)) {\n return booleanToTypedValue(isQuantityEquivalent(xValue, yValue));\n }\n if (typeof xValue === 'object' && typeof yValue === 'object') {\n return booleanToTypedValue(deepEquals(x, y));\n }\n return booleanToTypedValue(xValue === yValue);\n}\n\n/**\n * Determines if two arrays are equivalent according to FHIRPath equality rules.\n * @param x The first array.\n * @param y The second array.\n * @returns FHIRPath true if the arrays are equivalent.\n */\nexport function fhirPathArrayEquivalent(x: TypedValue[], y: TypedValue[]): TypedValue[] {\n if (x.length === 0 && y.length === 0) {\n return booleanToTypedValue(true);\n }\n if (x.length !== y.length) {\n return booleanToTypedValue(false);\n }\n x.sort(fhirPathEquivalentCompare);\n y.sort(fhirPathEquivalentCompare);\n return booleanToTypedValue(x.every((val, index) => toJsBoolean(fhirPathEquivalent(val, y[index]))));\n}\n\n/**\n * Determines if two values are equivalent according to FHIRPath equality rules.\n * @param x The first value.\n * @param y The second value.\n * @returns True if equivalent.\n */\nexport function fhirPathEquivalent(x: TypedValue, y: TypedValue): TypedValue[] {\n const xValue = x.value;\n const yValue = y.value;\n if (typeof xValue === 'number' && typeof yValue === 'number') {\n // Use more generous threshold than equality\n // Decimal: values must be equal, comparison is done on values rounded to the precision of the least precise operand.\n // Trailing zeroes after the decimal are ignored in determining precision.\n return booleanToTypedValue(Math.abs(xValue - yValue) < 0.01);\n }\n if (isQuantity(xValue) && isQuantity(yValue)) {\n return booleanToTypedValue(isQuantityEquivalent(xValue, yValue));\n }\n if (typeof xValue === 'object' && typeof yValue === 'object') {\n return booleanToTypedValue(deepEquals(xValue, yValue));\n }\n if (typeof xValue === 'string' && typeof yValue === 'string') {\n // String: the strings must be the same, ignoring case and locale, and normalizing whitespace\n // (see String Equivalence for more details).\n return booleanToTypedValue(xValue.toLowerCase() === yValue.toLowerCase());\n }\n return booleanToTypedValue(xValue === yValue);\n}\n\n/**\n * Returns the sort order of two values for FHIRPath array equivalence.\n * @param x The first value.\n * @param y The second value.\n * @returns The sort order of the values.\n */\nfunction fhirPathEquivalentCompare(x: TypedValue, y: TypedValue): number {\n const xValue = x.value;\n const yValue = y.value;\n if (typeof xValue === 'number' && typeof yValue === 'number') {\n return xValue - yValue;\n }\n if (typeof xValue === 'string' && typeof yValue === 'string') {\n return xValue.localeCompare(yValue);\n }\n return 0;\n}\n\n/**\n * Determines if the typed value is the desired type.\n * @param typedValue The typed value to check.\n * @param desiredType The desired type name.\n * @returns True if the typed value is of the desired type.\n */\nexport function fhirPathIs(typedValue: TypedValue, desiredType: string): boolean {\n const { value } = typedValue;\n if (value === undefined || value === null) {\n return false;\n }\n\n switch (desiredType) {\n case 'Boolean':\n return typeof value === 'boolean';\n case 'Decimal':\n case 'Integer':\n return typeof value === 'number';\n case 'Date':\n return typeof value === 'string' && !!value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/);\n case 'DateTime':\n return typeof value === 'string' && !!value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?T/);\n case 'Time':\n return typeof value === 'string' && !!value.match(/^T\\d/);\n case 'Period':\n return isPeriod(value);\n case 'Quantity':\n return isQuantity(value);\n default:\n return typeof value === 'object' && value?.resourceType === desiredType;\n }\n}\n\n/**\n * Determines if the input is a Period object.\n * This is heuristic based, as we do not have strong typing at runtime.\n * @param input The input value.\n * @returns True if the input is a period.\n */\nexport function isPeriod(input: unknown): input is Period {\n return !!(input && typeof input === 'object' && 'start' in input);\n}\n\n/**\n * Determines if the input is a Quantity object.\n * This is heuristic based, as we do not have strong typing at runtime.\n * @param input The input value.\n * @returns True if the input is a quantity.\n */\nexport function isQuantity(input: unknown): input is Quantity {\n return !!(input && typeof input === 'object' && 'value' in input && typeof (input as Quantity).value === 'number');\n}\n\nexport function isQuantityEquivalent(x: Quantity, y: Quantity): boolean {\n return (\n Math.abs((x.value as number) - (y.value as number)) < 0.01 &&\n (x.unit === y.unit || x.code === y.code || x.unit === y.code || x.code === y.unit)\n );\n}\n\n/**\n * Resource equality.\n * See: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#4-deep-equality\n * @param object1 The first object.\n * @param object2 The second object.\n * @returns True if the objects are equal.\n */\nfunction deepEquals<T1 extends object, T2 extends object>(object1: T1, object2: T2): boolean {\n const keys1 = Object.keys(object1) as (keyof T1)[];\n const keys2 = Object.keys(object2) as (keyof T2)[];\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n const val1 = object1[key] as unknown;\n const val2 = object2[key as unknown as keyof T2] as unknown;\n if (isObject(val1) && isObject(val2)) {\n if (!deepEquals(val1, val2)) {\n return false;\n }\n } else {\n if (val1 !== val2) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction isObject(obj: unknown): obj is object {\n return obj !== null && typeof obj === 'object';\n}\n","import { Reference, Resource } from '@medplum/fhirtypes';\nimport { Atom } from '../fhirlexer';\nimport { PropertyType, TypedValue } from '../types';\nimport { calculateAge } from '../utils';\nimport { DotAtom, SymbolAtom } from './atoms';\nimport { parseDateString } from './date';\nimport { booleanToTypedValue, fhirPathIs, isQuantity, removeDuplicates, toJsBoolean, toTypedValue } from './utils';\n\n/*\n * Collection of FHIRPath\n * See: https://hl7.org/fhirpath/#functions\n */\n\nexport interface FhirPathFunction {\n (input: TypedValue[], ...args: Atom[]): TypedValue[];\n}\n\n/**\n * Temporary placholder for unimplemented methods.\n */\nconst stub: FhirPathFunction = (): [] => [];\n\nexport const functions: Record<string, FhirPathFunction> = {\n /*\n * 5.1 Existence\n * See: https://hl7.org/fhirpath/#existence\n */\n\n /**\n * Returns true if the input collection is empty ({ }) and false otherwise.\n *\n * See: https://hl7.org/fhirpath/#empty-boolean\n *\n * @param input The input collection.\n * @returns True if the input collection is empty ({ }) and false otherwise.\n */\n empty: (input: TypedValue[]): TypedValue[] => {\n return booleanToTypedValue(input.length === 0);\n },\n\n /**\n * Returns true if the collection has unknown elements, and false otherwise.\n * This is the opposite of empty(), and as such is a shorthand for empty().not().\n * If the input collection is empty ({ }), the result is false.\n *\n * The function can also take an optional criteria to be applied to the collection\n * prior to the determination of the exists. In this case, the function is shorthand\n * for where(criteria).exists().\n *\n * See: https://hl7.org/fhirpath/#existscriteria-expression-boolean\n *\n * @param input\n * @param criteria\n * @returns True if the collection has unknown elements, and false otherwise.\n */\n exists: (input: TypedValue[], criteria?: Atom): TypedValue[] => {\n if (criteria) {\n return booleanToTypedValue(input.filter((e) => toJsBoolean(criteria.eval([e]))).length > 0);\n } else {\n return booleanToTypedValue(input.length > 0);\n }\n },\n\n /**\n * Returns true if for every element in the input collection, criteria evaluates to true.\n * Otherwise, the result is false.\n *\n * If the input collection is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#allcriteria-expression-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if for every element in the input collection, criteria evaluates to true.\n */\n all: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return booleanToTypedValue(input.every((e) => toJsBoolean(criteria.eval([e]))));\n },\n\n /**\n * Takes a collection of Boolean values and returns true if all the items are true.\n * If unknown items are false, the result is false.\n * If the input is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#alltrue-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if all the items are true.\n */\n allTrue: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (!value.value) {\n return booleanToTypedValue(false);\n }\n }\n return booleanToTypedValue(true);\n },\n\n /**\n * Takes a collection of Boolean values and returns true if unknown of the items are true.\n * If all the items are false, or if the input is empty ({ }), the result is false.\n *\n * See: https://hl7.org/fhirpath/#anytrue-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if unknown of the items are true.\n */\n anyTrue: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (value.value) {\n return booleanToTypedValue(true);\n }\n }\n return booleanToTypedValue(false);\n },\n\n /**\n * Takes a collection of Boolean values and returns true if all the items are false.\n * If unknown items are true, the result is false.\n * If the input is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#allfalse-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if all the items are false.\n */\n allFalse: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (value.value) {\n return booleanToTypedValue(false);\n }\n }\n return booleanToTypedValue(true);\n },\n\n /**\n * Takes a collection of Boolean values and returns true if unknown of the items are false.\n * If all the items are true, or if the input is empty ({ }), the result is false.\n *\n * See: https://hl7.org/fhirpath/#anyfalse-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if for every element in the input collection, criteria evaluates to true.\n */\n anyFalse: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (!value.value) {\n return booleanToTypedValue(true);\n }\n }\n return booleanToTypedValue(false);\n },\n\n /**\n * Returns true if all items in the input collection are members of the collection passed\n * as the other argument. Membership is determined using the = (Equals) (=) operation.\n *\n * Conceptually, this function is evaluated by testing each element in the input collection\n * for membership in the other collection, with a default of true. This means that if the\n * input collection is empty ({ }), the result is true, otherwise if the other collection\n * is empty ({ }), the result is false.\n *\n * See: http://hl7.org/fhirpath/#subsetofother-collection-boolean\n */\n subsetOf: stub,\n\n /**\n * Returns true if all items in the collection passed as the other argument are members of\n * the input collection. Membership is determined using the = (Equals) (=) operation.\n *\n * Conceptually, this function is evaluated by testing each element in the other collection\n * for membership in the input collection, with a default of true. This means that if the\n * other collection is empty ({ }), the result is true, otherwise if the input collection\n * is empty ({ }), the result is false.\n *\n * See: http://hl7.org/fhirpath/#supersetofother-collection-boolean\n */\n supersetOf: stub,\n\n /**\n * Returns the integer count of the number of items in the input collection.\n * Returns 0 when the input collection is empty.\n *\n * See: https://hl7.org/fhirpath/#count-integer\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\n count: (input: TypedValue[]): TypedValue[] => {\n return [{ type: PropertyType.integer, value: input.length }];\n },\n\n /**\n * Returns a collection containing only the unique items in the input collection.\n * To determine whether two items are the same, the = (Equals) (=) operator is used,\n * as defined below.\n *\n * If the input collection is empty ({ }), the result is empty.\n *\n * Note that the order of elements in the input collection is not guaranteed to be\n * preserved in the result.\n *\n * See: https://hl7.org/fhirpath/#distinct-collection\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\n distinct: (input: TypedValue[]): TypedValue[] => {\n const result: TypedValue[] = [];\n for (const value of input) {\n if (!result.some((e) => e.value === value.value)) {\n result.push(value);\n }\n }\n return result;\n },\n\n /**\n * Returns true if all the items in the input collection are distinct.\n * To determine whether two items are distinct, the = (Equals) (=) operator is used,\n * as defined below.\n *\n * See: https://hl7.org/fhirpath/#isdistinct-boolean\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\n isDistinct: (input: TypedValue[]): TypedValue[] => {\n return booleanToTypedValue(input.length === functions.distinct(input).length);\n },\n\n /*\n * 5.2 Filtering and projection\n */\n\n /**\n * Returns a collection containing only those elements in the input collection\n * for which the stated criteria expression evaluates to true.\n * Elements for which the expression evaluates to false or empty ({ }) are not\n * included in the result.\n *\n * If the input collection is empty ({ }), the result is empty.\n *\n * If the result of evaluating the condition is other than a single boolean value,\n * the evaluation will end and signal an error to the calling environment,\n * consistent with singleton evaluation of collections behavior.\n *\n * See: https://hl7.org/fhirpath/#wherecriteria-expression-collection\n *\n * @param input The input collection.\n * @param condition The condition atom.\n * @returns A collection containing only those elements in the input collection for which the stated criteria expression evaluates to true.\n */\n where: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return input.filter((e) => toJsBoolean(criteria.eval([e])));\n },\n\n /**\n * Evaluates the projection expression for each item in the input collection.\n * The result of each evaluation is added to the output collection. If the\n * evaluation results in a collection with multiple items, all items are added\n * to the output collection (collections resulting from evaluation of projection\n * are flattened). This means that if the evaluation for an element results in\n * the empty collection ({ }), no element is added to the result, and that if\n * the input collection is empty ({ }), the result is empty as well.\n *\n * See: http://hl7.org/fhirpath/#selectprojection-expression-collection\n */\n select: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return input.map((e) => criteria.eval([e])).flat();\n },\n\n /**\n * A version of select that will repeat the projection and add it to the output\n * collection, as long as the projection yields new items (as determined by\n * the = (Equals) (=) operator).\n *\n * See: http://hl7.org/fhirpath/#repeatprojection-expression-collection\n */\n repeat: stub,\n\n /**\n * Returns a collection that contains all items in the input collection that\n * are of the given type or a subclass thereof. If the input collection is\n * empty ({ }), the result is empty. The type argument is an identifier that\n * must resolve to the name of a type in a model\n *\n * See: http://hl7.org/fhirpath/#oftypetype-type-specifier-collection\n */\n ofType: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return input.filter((e) => e.type === (criteria as SymbolAtom).name);\n },\n\n /*\n * 5.3 Subsetting\n */\n\n /**\n * Will return the single item in the input if there is just one item.\n * If the input collection is empty ({ }), the result is empty.\n * If there are multiple items, an error is signaled to the evaluation environment.\n * This function is useful for ensuring that an error is returned if an assumption\n * about cardinality is violated at run-time.\n *\n * See: https://hl7.org/fhirpath/#single-collection\n *\n * @param input The input collection.\n * @returns The single item in the input if there is just one item.\n */\n single: (input: TypedValue[]): TypedValue[] => {\n if (input.length > 1) {\n throw new Error('Expected input length one for single()');\n }\n return input.length === 0 ? [] : input.slice(0, 1);\n },\n\n /**\n * Returns a collection containing only the first item in the input collection.\n * This function is equivalent to item[0], so it will return an empty collection if the input collection has no items.\n *\n * See: https://hl7.org/fhirpath/#first-collection\n *\n * @param input The input collection.\n * @returns A collection containing only the first item in the input collection.\n */\n first: (input: TypedValue[]): TypedValue[] => {\n return input.length === 0 ? [] : input.slice(0, 1);\n },\n\n /**\n * Returns a collection containing only the last item in the input collection.\n * Will return an empty collection if the input collection has no items.\n *\n * See: https://hl7.org/fhirpath/#last-collection\n *\n * @param input The input collection.\n * @returns A collection containing only the last item in the input collection.\n */\n last: (input: TypedValue[]): TypedValue[] => {\n return input.length === 0 ? [] : input.slice(input.length - 1, input.length);\n },\n\n /**\n * Returns a collection containing all but the first item in the input collection.\n * Will return an empty collection if the input collection has no items, or only one item.\n *\n * See: https://hl7.org/fhirpath/#tail-collection\n *\n * @param input The input collection.\n * @returns A collection containing all but the first item in the input collection.\n */\n tail: (input: TypedValue[]): TypedValue[] => {\n return input.length === 0 ? [] : input.slice(1, input.length);\n },\n\n /**\n * Returns a collection containing all but the first num items in the input collection.\n * Will return an empty collection if there are no items remaining after the\n * indicated number of items have been skipped, or if the input collection is empty.\n * If num is less than or equal to zero, the input collection is simply returned.\n *\n * See: https://hl7.org/fhirpath/#skipnum-integer-collection\n *\n * @param input The input collection.\n * @returns A collection containing all but the first item in the input collection.\n */\n skip: (input: TypedValue[], num: Atom): TypedValue[] => {\n const numValue = num.eval(input)[0]?.value;\n if (typeof numValue !== 'number') {\n throw new Error('Expected a number for skip(num)');\n }\n if (numValue >= input.length) {\n return [];\n }\n if (numValue <= 0) {\n return input;\n }\n return input.slice(numValue, input.length);\n },\n\n /**\n * Returns a collection containing the first num items in the input collection,\n * or less if there are less than num items.\n * If num is less than or equal to 0, or if the input collection is empty ({ }),\n * take returns an empty collection.\n *\n * See: https://hl7.org/fhirpath/#takenum-integer-collection\n *\n * @param input The input collection.\n * @returns A collection containing the first num items in the input collection.\n */\n take: (input: TypedValue[], num: Atom): TypedValue[] => {\n const numValue = num.eval(input)[0]?.value;\n if (typeof numValue !== 'number') {\n throw new Error('Expected a number for take(num)');\n }\n if (numValue >= input.length) {\n return input;\n }\n if (numValue <= 0) {\n return [];\n }\n return input.slice(0, numValue);\n },\n\n /**\n * Returns the set of elements that are in both collections.\n * Duplicate items will be eliminated by this function.\n * Order of items is not guaranteed to be preserved in the result of this function.\n *\n * See: http://hl7.org/fhirpath/#intersectother-collection-collection\n */\n intersect: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n const result: TypedValue[] = [];\n for (const value of input) {\n if (!result.some((e) => e.value === value.value) && otherArray.some((e) => e.value === value.value)) {\n result.push(value);\n }\n }\n return result;\n },\n\n /**\n * Returns the set of elements that are not in the other collection.\n * Duplicate items will not be eliminated by this function, and order will be preserved.\n *\n * e.g. (1 | 2 | 3).exclude(2) returns (1 | 3).\n *\n * See: http://hl7.org/fhirpath/#excludeother-collection-collection\n */\n exclude: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n const result: TypedValue[] = [];\n for (const value of input) {\n if (!otherArray.some((e) => e.value === value.value)) {\n result.push(value);\n }\n }\n return result;\n },\n\n /*\n * 5.4. Combining\n *\n * See: https://hl7.org/fhirpath/#combining\n */\n\n /**\n * Merge the two collections into a single collection,\n * eliminating unknown duplicate values (using = (Equals) (=) to determine equality).\n * There is no expectation of order in the resulting collection.\n *\n * In other words, this function returns the distinct list of elements from both inputs.\n *\n * See: http://hl7.org/fhirpath/#unionother-collection\n */\n union: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n return removeDuplicates([...input, ...otherArray]);\n },\n\n /**\n * Merge the input and other collections into a single collection\n * without eliminating duplicate values. Combining an empty collection\n * with a non-empty collection will return the non-empty collection.\n *\n * There is no expectation of order in the resulting collection.\n *\n * See: http://hl7.org/fhirpath/#combineother-collection-collection\n */\n combine: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n return [...input, ...otherArray];\n },\n\n /*\n * 5.5. Conversion\n *\n * See: https://hl7.org/fhirpath/#conversion\n */\n\n /**\n * The iif function in FHIRPath is an immediate if,\n * also known as a conditional operator (such as C’s ? : operator).\n *\n * The criterion expression is expected to evaluate to a Boolean.\n *\n * If criterion is true, the function returns the value of the true-result argument.\n *\n * If criterion is false or an empty collection, the function returns otherwise-result,\n * unless the optional otherwise-result is not given, in which case the function returns an empty collection.\n *\n * Note that short-circuit behavior is expected in this function. In other words,\n * true-result should only be evaluated if the criterion evaluates to true,\n * and otherwise-result should only be evaluated otherwise. For implementations,\n * this means delaying evaluation of the arguments.\n *\n * @param input\n * @param criterion\n * @param trueResult\n * @param otherwiseResult\n * @returns\n */\n iif: (input: TypedValue[], criterion: Atom, trueResult: Atom, otherwiseResult?: Atom): TypedValue[] => {\n const evalResult = criterion.eval(input);\n if (evalResult.length > 1 || (evalResult.length === 1 && typeof evalResult[0].value !== 'boolean')) {\n throw new Error('Expected criterion to evaluate to a Boolean');\n }\n\n if (toJsBoolean(evalResult)) {\n return trueResult.eval(input);\n }\n\n if (otherwiseResult) {\n return otherwiseResult.eval(input);\n }\n\n return [];\n },\n\n /**\n * Converts an input collection to a boolean.\n *\n * If the input collection contains a single item, this function will return a single boolean if:\n * 1) the item is a Boolean\n * 2) the item is an Integer and is equal to one of the possible integer representations of Boolean values\n * 3) the item is a Decimal that is equal to one of the possible decimal representations of Boolean values\n * 4) the item is a String that is equal to one of the possible string representations of Boolean values\n *\n * If the item is not one the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#toboolean-boolean\n *\n * @param input\n * @returns\n */\n toBoolean: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.boolean, value }];\n }\n if (typeof value === 'number') {\n if (value === 0 || value === 1) {\n return booleanToTypedValue(!!value);\n }\n }\n if (typeof value === 'string') {\n const lowerStr = value.toLowerCase();\n if (['true', 't', 'yes', 'y', '1', '1.0'].includes(lowerStr)) {\n return booleanToTypedValue(true);\n }\n if (['false', 'f', 'no', 'n', '0', '0.0'].includes(lowerStr)) {\n return booleanToTypedValue(false);\n }\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Boolean\n * 2) the item is an Integer that is equal to one of the possible integer representations of Boolean values\n * 3) the item is a Decimal that is equal to one of the possible decimal representations of Boolean values\n * 4) the item is a String that is equal to one of the possible string representations of Boolean values\n *\n * If the item is not one of the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is false.\n *\n * Possible values for Integer, Decimal, and String are described in the toBoolean() function.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: http://hl7.org/fhirpath/#convertstoboolean-boolean\n *\n * @param input\n * @returns\n */\n convertsToBoolean: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toBoolean(input).length === 1);\n },\n\n /**\n * Returns the integer representation of the input.\n *\n * If the input collection contains a single item, this function will return a single integer if:\n * 1) the item is an Integer\n * 2) the item is a String and is convertible to an integer\n * 3) the item is a Boolean, where true results in a 1 and false results in a 0.\n *\n * If the item is not one the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to an integer (using the regex format (\\\\+|-)?\\d+), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tointeger-integer\n *\n * @param input The input collection.\n * @returns The string representation of the input.\n */\n toInteger: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'number') {\n return [{ type: PropertyType.integer, value }];\n }\n if (typeof value === 'string' && value.match(/^[+-]?\\d+$/)) {\n return [{ type: PropertyType.integer, value: parseInt(value, 10) }];\n }\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.integer, value: value ? 1 : 0 }];\n }\n return [];\n },\n\n /**\n * Returns true if the input can be converted to string.\n *\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is an Integer\n * 2) the item is a String and is convertible to an Integer\n * 3) the item is a Boolean\n * 4) If the item is not one of the above types, or the item is a String, but is not convertible to an Integer (using the regex format (\\\\+|-)?\\d+), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstointeger-boolean\n *\n * @param input The input collection.\n * @returns\n */\n convertsToInteger: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toInteger(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single date if:\n * 1) the item is a Date\n * 2) the item is a DateTime\n * 3) the item is a String and is convertible to a Date\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Date (using the format YYYY-MM-DD), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#todate-date\n */\n toDate: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'string' && value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/)) {\n return [{ type: PropertyType.date, value: parseDateString(value) }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Date\n * 2) the item is a DateTime\n * 3) the item is a String and is convertible to a Date\n *\n * If the item is not one of the above types, or is not convertible to a Date (using the format YYYY-MM-DD), the result is false.\n *\n * If the item contains a partial date (e.g. '2012-01'), the result is a partial date.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstodate-boolean\n */\n convertsToDate: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toDate(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single datetime if:\n * 1) the item is a DateTime\n * 2) the item is a Date, in which case the result is a DateTime with the year, month, and day of the Date, and the time components empty (not set to zero)\n * 3) the item is a String and is convertible to a DateTime\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is empty.\n *\n * If the item contains a partial datetime (e.g. '2012-01-01T10:00'), the result is a partial datetime.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n\n * See: https://hl7.org/fhirpath/#todatetime-datetime\n *\n * @param input\n * @returns\n */\n toDateTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'string' && value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/)) {\n return [{ type: PropertyType.dateTime, value: parseDateString(value) }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a DateTime\n * 2) the item is a Date\n * 3) the item is a String and is convertible to a DateTime\n *\n * If the item is not one of the above types, or is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstodatetime-boolean\n *\n * @param input\n * @returns\n */\n convertsToDateTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toDateTime(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single decimal if:\n * 1) the item is an Integer or Decimal\n * 2) the item is a String and is convertible to a Decimal\n * 3) the item is a Boolean, where true results in a 1.0 and false results in a 0.0.\n * 4) If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Decimal (using the regex format (\\\\+|-)?\\d+(\\.\\d+)?), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#decimal-conversion-functions\n *\n * @param input The input collection.\n * @returns\n */\n toDecimal: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'number') {\n return [{ type: PropertyType.decimal, value }];\n }\n if (typeof value === 'string' && value.match(/^-?\\d{1,9}(\\.\\d{1,9})?$/)) {\n return [{ type: PropertyType.decimal, value: parseFloat(value) }];\n }\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.decimal, value: value ? 1 : 0 }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will true if:\n * 1) the item is an Integer or Decimal\n * 2) the item is a String and is convertible to a Decimal\n * 3) the item is a Boolean\n *\n * If the item is not one of the above types, or is not convertible to a Decimal (using the regex format (\\\\+|-)?\\d+(\\.\\d+)?), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n\n * See: https://hl7.org/fhirpath/#convertstodecimal-boolean\n *\n * @param input The input collection.\n * @returns\n */\n convertsToDecimal: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toDecimal(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single quantity if:\n * 1) the item is an Integer, or Decimal, where the resulting quantity will have the default unit ('1')\n * 2) the item is a Quantity\n * 3) the item is a String and is convertible to a Quantity\n * 4) the item is a Boolean, where true results in the quantity 1.0 '1', and false results in the quantity 0.0 '1'\n *\n * If the item is not one of the above types, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#quantity-conversion-functions\n *\n * @param input The input collection.\n * @returns\n */\n toQuantity: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (isQuantity(value)) {\n return [{ type: PropertyType.Quantity, value }];\n }\n if (typeof value === 'number') {\n return [{ type: PropertyType.Quantity, value: { value, unit: '1' } }];\n }\n if (typeof value === 'string' && value.match(/^-?\\d{1,9}(\\.\\d{1,9})?/)) {\n return [{ type: PropertyType.Quantity, value: { value: parseFloat(value), unit: '1' } }];\n }\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.Quantity, value: { value: value ? 1 : 0, unit: '1' } }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is an Integer, Decimal, or Quantity\n * 2) the item is a String that is convertible to a Quantity\n * 3) the item is a Boolean\n *\n * If the item is not one of the above types, or is not convertible to a Quantity using the following regex format:\n *\n * (?'value'(\\+|-)?\\d+(\\.\\d+)?)\\s*('(?'unit'[^']+)'|(?'time'[a-zA-Z]+))?\n *\n * then the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the unit argument is provided, it must be the string representation of a UCUM code (or a FHIRPath calendar duration keyword), and is used to determine whether the input quantity can be converted to the given unit, according to the unit conversion rules specified by UCUM. If the input quantity can be converted, the result is true, otherwise, the result is false.\n *\n * See: https://hl7.org/fhirpath/#convertstoquantityunit-string-boolean\n *\n * @param input The input collection.\n * @returns\n */\n convertsToQuantity: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toQuantity(input).length === 1);\n },\n\n /**\n * Returns the string representation of the input.\n *\n * If the input collection contains a single item, this function will return a single String if:\n *\n * 1) the item in the input collection is a String\n * 2) the item in the input collection is an Integer, Decimal, Date, Time, DateTime, or Quantity the output will contain its String representation\n * 3) the item is a Boolean, where true results in 'true' and false in 'false'.\n *\n * If the item is not one of the above types, the result is false.\n *\n * See: https://hl7.org/fhirpath/#tostring-string\n *\n * @param input The input collection.\n * @returns The string representation of the input.\n */\n toString: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (value === null || value === undefined) {\n return [];\n }\n if (isQuantity(value)) {\n return [{ type: PropertyType.string, value: `${value.value} '${value.unit}'` }];\n }\n return [{ type: PropertyType.string, value: (value as boolean | number | string).toString() }];\n },\n\n /**\n * Returns true if the input can be converted to string.\n *\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a String\n * 2) the item is an Integer, Decimal, Date, Time, or DateTime\n * 3) the item is a Boolean\n * 4) the item is a Quantity\n *\n * If the item is not one of the above types, the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tostring-string\n *\n * @param input The input collection.\n * @returns\n */\n convertsToString: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue((functions.toString as unknown as FhirPathFunction)(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single time if:\n * 1) the item is a Time\n * 2) the item is a String and is convertible to a Time\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Time (using the format hh:mm:ss.fff(+|-)hh:mm), the result is empty.\n *\n * If the item contains a partial time (e.g. '10:00'), the result is a partial time.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#totime-time\n *\n * @param input\n * @returns\n */\n toTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'string') {\n const match = value.match(/^T?(\\d{2}(:\\d{2}(:\\d{2})?)?)/);\n if (match) {\n return [{ type: PropertyType.time, value: parseDateString('T' + match[1]) }];\n }\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Time\n * 2) the item is a String and is convertible to a Time\n *\n * If the item is not one of the above types, or is not convertible to a Time (using the format hh:mm:ss.fff(+|-)hh:mm), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstotime-boolean\n *\n * @param input\n * @returns\n */\n convertsToTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toTime(input).length === 1);\n },\n\n /*\n * 5.6. String Manipulation.\n *\n * See: https://hl7.org/fhirpath/#string-manipulation\n */\n\n /**\n * Returns the 0-based index of the first position substring is found in the input string, or -1 if it is not found.\n *\n * If substring is an empty string (''), the function returns 0.\n *\n * If the input or substring is empty ({ }), the result is empty ({ }).\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#indexofsubstring-string-integer\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n indexOf: (input: TypedValue[], substringAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, substring) => str.indexOf(substring as string), input, substringAtom);\n },\n\n /**\n * Returns the part of the string starting at position start (zero-based). If length is given, will return at most length number of characters from the input string.\n *\n * If start lies outside the length of the string, the function returns empty ({ }). If there are less remaining characters in the string than indicated by length, the function returns just the remaining characters.\n *\n * If the input or start is empty, the result is empty.\n *\n * If an empty length is provided, the behavior is the same as if length had not been provided.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n substring: (input: TypedValue[], startAtom: Atom, lengthAtom?: Atom): TypedValue[] => {\n return applyStringFunc(\n (str, start, length) => {\n const startIndex = start as number;\n const endIndex = length ? startIndex + (length as number) : str.length;\n return startIndex < 0 || startIndex >= str.length ? undefined : str.substring(startIndex, endIndex);\n },\n input,\n startAtom,\n lengthAtom\n );\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n startsWith: (input: TypedValue[], prefixAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, prefix) => str.startsWith(prefix as string), input, prefixAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n endsWith: (input: TypedValue[], suffixAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, suffix) => str.endsWith(suffix as string), input, suffixAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n contains: (input: TypedValue[], substringAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, substring) => str.includes(substring as string), input, substringAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n upper: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => str.toUpperCase(), input);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n lower: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => str.toLowerCase(), input);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n replace: (input: TypedValue[], patternAtom: Atom, substitionAtom: Atom): TypedValue[] => {\n return applyStringFunc(\n (str, pattern, substition) => str.replaceAll(pattern as string, substition as string),\n input,\n patternAtom,\n substitionAtom\n );\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n matches: (input: TypedValue[], regexAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, regex) => !!str.match(regex as string), input, regexAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n replaceMatches: (input: TypedValue[], regexAtom: Atom, substitionAtom: Atom): TypedValue[] => {\n return applyStringFunc(\n (str, pattern, substition) => str.replaceAll(pattern as string, substition as string),\n input,\n regexAtom,\n substitionAtom\n );\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n length: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => str.length, input);\n },\n\n /**\n * Returns the list of characters in the input string. If the input collection is empty ({ }), the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tochars-collection\n *\n * @param input The input collection.\n */\n toChars: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => (str ? str.split('') : undefined), input);\n },\n\n /*\n * 5.7. Math\n */\n\n /**\n * Returns the absolute value of the input. When taking the absolute value of a quantity, the unit is unchanged.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#abs-integer-decimal-quantity\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n abs: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.abs, input);\n },\n\n /**\n * Returns the first integer greater than or equal to the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#ceiling-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n ceiling: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.ceil, input);\n },\n\n /**\n * Returns e raised to the power of the input.\n *\n * If the input collection contains an Integer, it will be implicitly converted to a Decimal and the result will be a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#exp-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n exp: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.exp, input);\n },\n\n /**\n * Returns the first integer less than or equal to the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#floor-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n floor: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.floor, input);\n },\n\n /**\n * Returns the natural logarithm of the input (i.e. the logarithm base e).\n *\n * When used with an Integer, it will be implicitly converted to a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#ln-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n ln: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.log, input);\n },\n\n /**\n * Returns the logarithm base base of the input number.\n *\n * When used with Integers, the arguments will be implicitly converted to Decimal.\n *\n * If base is empty, the result is empty.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#logbase-decimal-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n log: (input: TypedValue[], baseAtom: Atom): TypedValue[] => {\n return applyMathFunc((value, base) => Math.log(value) / Math.log(base as number), input, baseAtom);\n },\n\n /**\n * Raises a number to the exponent power. If this function is used with Integers, the result is an Integer. If the function is used with Decimals, the result is a Decimal. If the function is used with a mixture of Integer and Decimal, the Integer is implicitly converted to a Decimal and the result is a Decimal.\n *\n * If the power cannot be represented (such as the -1 raised to the 0.5), the result is empty.\n *\n * If the input is empty, or exponent is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#powerexponent-integer-decimal-integer-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n power: (input: TypedValue[], expAtom: Atom): TypedValue[] => {\n return applyMathFunc(Math.pow as (x: number, ...args: unknown[]) => number, input, expAtom);\n },\n\n /**\n * Rounds the decimal to the nearest whole number using a traditional round (i.e. 0.5 or higher will round to 1). If specified, the precision argument determines the decimal place at which the rounding will occur. If not specified, the rounding will default to 0 decimal places.\n *\n * If specified, the number of digits of precision must be >= 0 or the evaluation will end and signal an error to the calling environment.\n *\n * If the input collection contains a single item of type Integer, it will be implicitly converted to a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#roundprecision-integer-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n round: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.round, input);\n },\n\n /**\n * Returns the square root of the input number as a Decimal.\n *\n * If the square root cannot be represented (such as the square root of -1), the result is empty.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * Note that this function is equivalent to raising a number of the power of 0.5 using the power() function.\n *\n * See: https://hl7.org/fhirpath/#sqrt-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n sqrt: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.sqrt, input);\n },\n\n /**\n * Returns the integer portion of the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#truncate-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n truncate: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc((x) => x | 0, input);\n },\n\n /*\n * 5.8. Tree navigation\n */\n\n children: stub,\n\n descendants: stub,\n\n /*\n * 5.9. Utility functions\n */\n\n /**\n * Adds a String representation of the input collection to the diagnostic log,\n * using the name argument as the name in the log. This log should be made available\n * to the user in some appropriate fashion. Does not change the input, so returns\n * the input collection as output.\n *\n * If the projection argument is used, the trace would log the result of evaluating\n * the project expression on the input, but still return the input to the trace\n * function unchanged.\n *\n * See: https://hl7.org/fhirpath/#tracename-string-projection-expression-collection\n *\n * @param input The input collection.\n * @param nameAtom The log name.\n */\n trace: (input: TypedValue[], nameAtom: Atom): TypedValue[] => {\n console.log('trace', input, nameAtom);\n return input;\n },\n\n /**\n * Returns the current date and time, including timezone offset.\n *\n * See: https://hl7.org/fhirpath/#now-datetime\n */\n now: (): TypedValue[] => {\n return [{ type: PropertyType.dateTime, value: new Date().toISOString() }];\n },\n\n /**\n * Returns the current time.\n *\n * See: https://hl7.org/fhirpath/#timeofday-time\n */\n timeOfDay: (): TypedValue[] => {\n return [{ type: PropertyType.time, value: new Date().toISOString().substring(11) }];\n },\n\n /**\n * Returns the current date.\n *\n * See: https://hl7.org/fhirpath/#today-date\n */\n today: (): TypedValue[] => {\n return [{ type: PropertyType.date, value: new Date().toISOString().substring(0, 10) }];\n },\n\n /**\n * Calculates the difference between two dates or date/times.\n *\n * This is not part of the official FHIRPath spec.\n *\n * IBM FHIR issue: https://github.com/IBM/FHIR/issues/1014\n * IBM FHIR PR: https://github.com/IBM/FHIR/pull/1023\n */\n between: (input: TypedValue[], startAtom: Atom, endAtom: Atom, unitsAtom: Atom): TypedValue[] => {\n const startDate = functions.toDateTime(startAtom.eval(input));\n if (startDate.length === 0) {\n throw new Error('Invalid start date');\n }\n const endDate = functions.toDateTime(endAtom.eval(input));\n if (endDate.length === 0) {\n throw new Error('Invalid end date');\n }\n const unit = unitsAtom.eval(input)[0]?.value as string;\n if (unit !== 'years' && unit !== 'months' && unit !== 'days') {\n throw new Error('Invalid units');\n }\n const age = calculateAge(startDate[0].value, endDate[0].value);\n return [{ type: PropertyType.Quantity, value: { value: age[unit], unit } }];\n },\n\n /*\n * 6.3 Types\n */\n\n /**\n * The is() function is supported for backwards compatibility with previous\n * implementations of FHIRPath. Just as with the is keyword, the type argument\n * is an identifier that must resolve to the name of a type in a model.\n *\n * For implementations with compile-time typing, this requires special-case\n * handling when processing the argument to treat it as a type specifier rather\n * than an identifier expression:\n *\n * @param input\n * @param typeAtom\n * @returns\n */\n is: (input: TypedValue[], typeAtom: Atom): TypedValue[] => {\n let typeName = '';\n if (typeAtom instanceof SymbolAtom) {\n typeName = typeAtom.name;\n } else if (typeAtom instanceof DotAtom) {\n typeName = (typeAtom.left as SymbolAtom).name + '.' + (typeAtom.right as SymbolAtom).name;\n }\n if (!typeName) {\n return [];\n }\n return input.map((value) => ({ type: PropertyType.boolean, value: fhirPathIs(value, typeName) }));\n },\n\n /*\n * 6.5 Boolean logic\n */\n\n /**\n * 6.5.3. not() : Boolean\n *\n * Returns true if the input collection evaluates to false, and false if it evaluates to true. Otherwise, the result is empty ({ }):\n *\n * @param input\n * @returns\n */\n not: (input: TypedValue[]): TypedValue[] => {\n return functions.toBoolean(input).map((value) => ({ type: PropertyType.boolean, value: !value.value }));\n },\n\n /*\n * Additional functions\n * See: https://hl7.org/fhir/fhirpath.html#functions\n */\n\n /**\n * For each item in the collection, if it is a string that is a uri (or canonical or url), locate the target of the reference, and add it to the resulting collection. If the item does not resolve to a resource, the item is ignored and nothing is added to the output collection.\n * The items in the collection may also represent a Reference, in which case the Reference.reference is resolved.\n * @param input The input collection.\n * @returns\n */\n resolve: (input: TypedValue[]): TypedValue[] => {\n return input\n .map((e) => {\n const value = e.value;\n let refStr: string | undefined;\n if (typeof value === 'string') {\n refStr = value;\n } else if (typeof value === 'object') {\n const ref = value as Reference;\n if (ref.resource) {\n return toTypedValue(ref.resource);\n }\n refStr = ref.reference;\n }\n if (!refStr) {\n return { type: PropertyType.BackboneElement, value: null };\n }\n const [resourceType, id] = refStr.split('/');\n return { type: PropertyType.BackboneElement, value: { resourceType, id } };\n })\n .filter((e) => !!e.value);\n },\n\n /**\n * The as operator can be used to treat a value as a specific type.\n * @param input The input value.\n * @returns The value as the specific type.\n */\n as: (input: TypedValue[]): TypedValue[] => {\n return input;\n },\n\n /*\n * 12. Formal Specifications\n */\n\n /**\n * Returns the type of the input.\n *\n * 12.2. Model Information\n *\n * The model information returned by the reflection function type() is specified as an\n * XML Schema document (xsd) and included in this specification at the following link:\n * https://hl7.org/fhirpath/modelinfo.xsd\n *\n * See: https://hl7.org/fhirpath/#model-information\n *\n * @param input The input collection.\n * @returns\n */\n type: (input: TypedValue[]): TypedValue[] => {\n return input.map(({ value }) => {\n if (typeof value === 'boolean') {\n return { type: PropertyType.BackboneElement, value: { namespace: 'System', name: 'Boolean' } };\n }\n if (typeof value === 'number') {\n return { type: PropertyType.BackboneElement, value: { namespace: 'System', name: 'Integer' } };\n }\n if (value && typeof value === 'object' && 'resourceType' in value) {\n return {\n type: PropertyType.BackboneElement,\n value: { namespace: 'FHIR', name: (value as Resource).resourceType },\n };\n }\n return { type: PropertyType.BackboneElement, value: null };\n });\n },\n\n conformsTo: (input: TypedValue[], systemAtom: Atom): TypedValue[] => {\n const system = systemAtom.eval(input)[0].value as string;\n if (!system.startsWith('http://hl7.org/fhir/StructureDefinition/')) {\n throw new Error('Expected a StructureDefinition URL');\n }\n const expectedResourceType = system.replace('http://hl7.org/fhir/StructureDefinition/', '');\n return input.map((value) => ({\n type: PropertyType.boolean,\n value: value.value?.resourceType === expectedResourceType,\n }));\n },\n};\n\n/*\n * Helper utilities\n */\n\nfunction applyStringFunc<T>(\n func: (str: string, ...args: unknown[]) => T | undefined,\n input: TypedValue[],\n ...argsAtoms: (Atom | undefined)[]\n): TypedValue[] {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value !== 'string') {\n throw new Error('String function cannot be called with non-string');\n }\n const result = func(value, ...argsAtoms.map((atom) => atom && atom.eval(input)?.[0]?.value));\n if (result === undefined) {\n return [];\n }\n if (Array.isArray(result)) {\n return result.map(toTypedValue);\n }\n return [toTypedValue(result)];\n}\n\nfunction applyMathFunc(\n func: (x: number, ...args: unknown[]) => number,\n input: TypedValue[],\n ...argsAtoms: Atom[]\n): TypedValue[] {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n const quantity = isQuantity(value);\n const numberInput = quantity ? value.value : value;\n if (typeof numberInput !== 'number') {\n throw new Error('Math function cannot be called with non-number');\n }\n const result = func(numberInput, ...argsAtoms.map((atom) => atom.eval(input)?.[0]?.value));\n const type = quantity ? PropertyType.Quantity : input[0].type;\n const returnValue = quantity ? { ...value, value: result } : result;\n return [{ type, value: returnValue }];\n}\n\nfunction validateInput(input: TypedValue[], count: number): TypedValue[] {\n if (input.length !== count) {\n throw new Error(`Expected ${count} arguments`);\n }\n for (const element of input) {\n if (element === null || element === undefined) {\n throw new Error('Expected non-null argument');\n }\n }\n return input;\n}\n","import { Resource } from '@medplum/fhirtypes';\nimport { Atom, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer';\nimport { PropertyType, TypedValue } from '../types';\nimport { functions } from './functions';\nimport {\n booleanToTypedValue,\n fhirPathArrayEquals,\n fhirPathArrayEquivalent,\n fhirPathIs,\n fhirPathNot,\n getTypedPropertyValue,\n isQuantity,\n removeDuplicates,\n toJsBoolean,\n toTypedValue,\n} from './utils';\n\nexport class FhirPathAtom implements Atom {\n constructor(public readonly original: string, public readonly child: Atom) {}\n\n eval(context: TypedValue[]): TypedValue[] {\n try {\n if (context.length > 0) {\n return context.map((e) => this.child.eval([e])).flat();\n } else {\n return this.child.eval([]);\n }\n } catch (error) {\n throw new Error(`FhirPathError on \"${this.original}\": ${error}`);\n }\n }\n\n toString(): string {\n return this.child.toString();\n }\n}\n\nexport class LiteralAtom implements Atom {\n constructor(public readonly value: TypedValue) {}\n eval(): TypedValue[] {\n return [this.value];\n }\n\n toString(): string {\n const value = this.value.value;\n if (typeof value === 'string') {\n return `'${value}'`;\n }\n return value.toString();\n }\n}\n\nexport class SymbolAtom implements Atom {\n constructor(public readonly name: string) {}\n eval(context: TypedValue[]): TypedValue[] {\n if (this.name === '$this') {\n return context;\n }\n return context\n .map((e) => this.#evalValue(e))\n .flat()\n .filter((e) => e?.value !== undefined) as TypedValue[];\n }\n\n #evalValue(typedValue: TypedValue): TypedValue[] | TypedValue | undefined {\n const input = typedValue.value;\n if (!input || typeof input !== 'object') {\n return undefined;\n }\n\n if ('resourceType' in input && (input as Resource).resourceType === this.name) {\n return typedValue;\n }\n\n return getTypedPropertyValue(typedValue, this.name);\n }\n\n toString(): string {\n return this.name;\n }\n}\n\nexport class EmptySetAtom implements Atom {\n eval(): [] {\n return [];\n }\n\n toString(): string {\n return '{}';\n }\n}\n\nexport class UnaryOperatorAtom extends PrefixOperatorAtom {\n constructor(operator: string, child: Atom, public readonly impl: (x: TypedValue[]) => TypedValue[]) {\n super(operator, child);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return this.impl(this.child.eval(context));\n }\n\n toString(): string {\n return this.child.toString();\n }\n}\n\nexport class AsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('as', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return functions.ofType(this.left.eval(context), this.right);\n }\n}\n\nexport class ArithemticOperatorAtom extends InfixOperatorAtom {\n constructor(\n operator: string,\n left: Atom,\n right: Atom,\n public readonly impl: (x: number, y: number) => number | boolean\n ) {\n super(operator, left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftEvalResult = this.left.eval(context);\n if (leftEvalResult.length !== 1) {\n return [];\n }\n const rightEvalResult = this.right.eval(context);\n if (rightEvalResult.length !== 1) {\n return [];\n }\n const leftValue = leftEvalResult[0].value;\n const rightValue = rightEvalResult[0].value;\n const leftNumber = isQuantity(leftValue) ? leftValue.value : leftValue;\n const rightNumber = isQuantity(rightValue) ? rightValue.value : rightValue;\n const result = this.impl(leftNumber, rightNumber);\n if (typeof result === 'boolean') {\n return booleanToTypedValue(result);\n } else if (isQuantity(leftValue)) {\n return [{ type: PropertyType.Quantity, value: { ...leftValue, value: result } }];\n } else {\n return [toTypedValue(result)];\n }\n }\n}\n\nexport class ConcatAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('&', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n const result = [...leftValue, ...rightValue];\n if (result.length > 0 && result.every((e) => typeof e.value === 'string')) {\n return [{ type: PropertyType.string, value: result.map((e) => e.value as string).join('') }];\n }\n return result;\n }\n}\n\nexport class ContainsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('contains', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return booleanToTypedValue(leftValue.some((e) => e.value === rightValue[0].value));\n }\n}\n\nexport class InAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('in', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return booleanToTypedValue(rightValue.some((e) => e.value === leftValue[0].value));\n }\n}\n\nexport class DotAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('.', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return this.right.eval(this.left.eval(context));\n }\n\n toString(): string {\n return `${this.left.toString()}.${this.right.toString()}`;\n }\n}\n\nexport class UnionAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('|', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftResult = this.left.eval(context);\n const rightResult = this.right.eval(context);\n return removeDuplicates([...leftResult, ...rightResult]);\n }\n}\n\nexport class EqualsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('=', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathArrayEquals(leftValue, rightValue);\n }\n}\n\nexport class NotEqualsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('!=', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathNot(fhirPathArrayEquals(leftValue, rightValue));\n }\n}\n\nexport class EquivalentAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('~', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathArrayEquivalent(leftValue, rightValue);\n }\n}\n\nexport class NotEquivalentAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('!~', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathNot(fhirPathArrayEquivalent(leftValue, rightValue));\n }\n}\n\nexport class IsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('is', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n if (leftValue.length !== 1) {\n return [];\n }\n const typeName = (this.right as SymbolAtom).name;\n return booleanToTypedValue(fhirPathIs(leftValue[0], typeName));\n }\n}\n\n/**\n * 6.5.1. and\n * Returns true if both operands evaluate to true,\n * false if either operand evaluates to false,\n * and the empty collection otherwise.\n */\nexport class AndAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('and', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (leftValue[0]?.value === true && rightValue[0]?.value === true) {\n return booleanToTypedValue(true);\n }\n if (leftValue[0]?.value === false || rightValue[0]?.value === false) {\n return booleanToTypedValue(false);\n }\n return [];\n }\n}\n\nexport class OrAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('or', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n if (toJsBoolean(leftValue)) {\n return leftValue;\n }\n\n const rightValue = this.right.eval(context);\n if (toJsBoolean(rightValue)) {\n return rightValue;\n }\n\n return [];\n }\n}\n\n/**\n * 6.5.4. xor\n * Returns true if exactly one of the operands evaluates to true,\n * false if either both operands evaluate to true or both operands evaluate to false,\n * and the empty collection otherwise.\n */\nexport class XorAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('xor', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftResult = this.left.eval(context);\n const rightResult = this.right.eval(context);\n if (leftResult.length === 0 && rightResult.length === 0) {\n return [];\n }\n const leftValue = leftResult.length === 0 ? null : leftResult[0].value;\n const rightValue = rightResult.length === 0 ? null : rightResult[0].value;\n if ((leftValue === true && rightValue !== true) || (leftValue !== true && rightValue === true)) {\n return booleanToTypedValue(true);\n }\n if ((leftValue === true && rightValue === true) || (leftValue === false && rightValue === false)) {\n return booleanToTypedValue(false);\n }\n return [];\n }\n}\n\nexport class FunctionAtom implements Atom {\n constructor(public readonly name: string, public readonly args: Atom[]) {}\n eval(context: TypedValue[]): TypedValue[] {\n const impl = functions[this.name];\n if (!impl) {\n throw new Error('Unrecognized function: ' + this.name);\n }\n return impl(context, ...this.args);\n }\n\n toString(): string {\n return `${this.name}(${this.args.map((arg) => arg.toString()).join(', ')})`;\n }\n}\n\nexport class IndexerAtom implements Atom {\n constructor(public readonly left: Atom, public readonly expr: Atom) {}\n eval(context: TypedValue[]): TypedValue[] {\n const evalResult = this.expr.eval(context);\n if (evalResult.length !== 1) {\n return [];\n }\n const index = evalResult[0].value;\n if (typeof index !== 'number') {\n throw new Error(`Invalid indexer expression: should return integer}`);\n }\n const leftResult = this.left.eval(context);\n if (!(index in leftResult)) {\n return [];\n }\n return [leftResult[index]];\n }\n\n toString(): string {\n return `${this.left.toString()}[${this.expr.toString()}]`;\n }\n}\n","import { Token, Tokenizer } from '../fhirlexer';\n\nexport const FHIRPATH_KEYWORDS = ['true', 'false'];\nexport const FHIRPATH_OPERATORS = ['!=', '!~', '<=', '>=', '{}', '->'];\n\nexport function tokenize(str: string): Token[] {\n return new Tokenizer(str, FHIRPATH_KEYWORDS, FHIRPATH_OPERATORS).tokenize();\n}\n","import { Quantity } from '@medplum/fhirtypes';\nimport { Atom, InfixParselet, Parser, ParserBuilder, PrefixParselet } from '../fhirlexer';\nimport { PropertyType, TypedValue } from '../types';\nimport {\n AndAtom,\n ArithemticOperatorAtom,\n AsAtom,\n ConcatAtom,\n ContainsAtom,\n DotAtom,\n EmptySetAtom,\n EqualsAtom,\n EquivalentAtom,\n FhirPathAtom,\n FunctionAtom,\n InAtom,\n IndexerAtom,\n IsAtom,\n LiteralAtom,\n NotEqualsAtom,\n NotEquivalentAtom,\n OrAtom,\n SymbolAtom,\n UnaryOperatorAtom,\n UnionAtom,\n XorAtom,\n} from './atoms';\nimport { parseDateString } from './date';\nimport { tokenize } from './tokenize';\nimport { toTypedValue } from './utils';\n\n/**\n * Operator precedence\n * See: https://hl7.org/fhirpath/#operator-precedence\n */\nexport const enum OperatorPrecedence {\n FunctionCall = 0,\n Dot = 1,\n Indexer = 2,\n UnaryAdd = 3,\n UnarySubtract = 3,\n Multiply = 4,\n Divide = 4,\n IntegerDivide = 4,\n Modulo = 4,\n Add = 5,\n Subtract = 5,\n Ampersand = 5,\n Is = 6,\n As = 6,\n Union = 7,\n GreaterThan = 8,\n GreaterThanOrEquals = 8,\n LessThan = 8,\n LessThanOrEquals = 8,\n Equals = 9,\n Equivalent = 9,\n NotEquals = 9,\n NotEquivalent = 9,\n In = 10,\n Contains = 10,\n And = 11,\n Xor = 12,\n Or = 12,\n Implies = 13,\n Arrow = 100,\n Semicolon = 200,\n}\n\nconst PARENTHESES_PARSELET: PrefixParselet = {\n parse(parser: Parser) {\n const expr = parser.consumeAndParse();\n if (!parser.match(')')) {\n throw new Error('Parse error: expected `)` got `' + parser.peek()?.value + '`');\n }\n return expr;\n },\n};\n\nconst INDEXER_PARSELET: InfixParselet = {\n parse(parser: Parser, left: Atom) {\n const expr = parser.consumeAndParse();\n if (!parser.match(']')) {\n throw new Error('Parse error: expected `]`');\n }\n return new IndexerAtom(left, expr);\n },\n\n precedence: OperatorPrecedence.Indexer,\n};\n\nconst FUNCTION_CALL_PARSELET: InfixParselet = {\n parse(parser: Parser, left: Atom) {\n if (!(left instanceof SymbolAtom)) {\n throw new Error('Unexpected parentheses');\n }\n\n const args = [];\n while (!parser.match(')')) {\n args.push(parser.consumeAndParse());\n parser.match(',');\n }\n\n return new FunctionAtom(left.name, args); //, functions[left.name]);\n },\n precedence: OperatorPrecedence.FunctionCall,\n};\n\nfunction parseQuantity(str: string): Quantity {\n const parts = str.split(' ');\n const value = parseFloat(parts[0]);\n let unit = parts[1];\n if (unit && unit.startsWith(\"'\") && unit.endsWith(\"'\")) {\n unit = unit.substring(1, unit.length - 1);\n } else {\n unit = '{' + unit + '}';\n }\n return { value, unit };\n}\n\nexport function initFhirPathParserBuilder(): ParserBuilder {\n return new ParserBuilder()\n .registerPrefix('String', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.string, value: token.value }),\n })\n .registerPrefix('DateTime', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.dateTime, value: parseDateString(token.value) }),\n })\n .registerPrefix('Quantity', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.Quantity, value: parseQuantity(token.value) }),\n })\n .registerPrefix('Number', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.decimal, value: parseFloat(token.value) }),\n })\n .registerPrefix('true', { parse: () => new LiteralAtom({ type: PropertyType.boolean, value: true }) })\n .registerPrefix('false', { parse: () => new LiteralAtom({ type: PropertyType.boolean, value: false }) })\n .registerPrefix('Symbol', { parse: (_, token) => new SymbolAtom(token.value) })\n .registerPrefix('{}', { parse: () => new EmptySetAtom() })\n .registerPrefix('(', PARENTHESES_PARSELET)\n .registerInfix('[', INDEXER_PARSELET)\n .registerInfix('(', FUNCTION_CALL_PARSELET)\n .prefix('+', OperatorPrecedence.UnaryAdd, (_, right) => new UnaryOperatorAtom('+', right, (x) => x))\n .prefix(\n '-',\n OperatorPrecedence.UnarySubtract,\n (_, right) => new ArithemticOperatorAtom('-', right, right, (_, y) => -y)\n )\n .infixLeft('.', OperatorPrecedence.Dot, (left, _, right) => new DotAtom(left, right))\n .infixLeft(\n '/',\n OperatorPrecedence.Divide,\n (left, _, right) => new ArithemticOperatorAtom('/', left, right, (x, y) => x / y)\n )\n .infixLeft(\n '*',\n OperatorPrecedence.Multiply,\n (left, _, right) => new ArithemticOperatorAtom('*', left, right, (x, y) => x * y)\n )\n .infixLeft(\n '+',\n OperatorPrecedence.Add,\n (left, _, right) => new ArithemticOperatorAtom('+', left, right, (x, y) => x + y)\n )\n .infixLeft(\n '-',\n OperatorPrecedence.Subtract,\n (left, _, right) => new ArithemticOperatorAtom('-', left, right, (x, y) => x - y)\n )\n .infixLeft('|', OperatorPrecedence.Union, (left, _, right) => new UnionAtom(left, right))\n .infixLeft('=', OperatorPrecedence.Equals, (left, _, right) => new EqualsAtom(left, right))\n .infixLeft('!=', OperatorPrecedence.Equals, (left, _, right) => new NotEqualsAtom(left, right))\n .infixLeft('~', OperatorPrecedence.Equivalent, (left, _, right) => new EquivalentAtom(left, right))\n .infixLeft('!~', OperatorPrecedence.NotEquivalent, (left, _, right) => new NotEquivalentAtom(left, right))\n .infixLeft(\n '<',\n OperatorPrecedence.LessThan,\n (left, _, right) => new ArithemticOperatorAtom('<', left, right, (x, y) => x < y)\n )\n .infixLeft(\n '<=',\n OperatorPrecedence.LessThanOrEquals,\n (left, _, right) => new ArithemticOperatorAtom('<=', left, right, (x, y) => x <= y)\n )\n .infixLeft(\n '>',\n OperatorPrecedence.GreaterThan,\n (left, _, right) => new ArithemticOperatorAtom('>', left, right, (x, y) => x > y)\n )\n .infixLeft(\n '>=',\n OperatorPrecedence.GreaterThanOrEquals,\n (left, _, right) => new ArithemticOperatorAtom('>=', left, right, (x, y) => x >= y)\n )\n .infixLeft('&', OperatorPrecedence.Ampersand, (left, _, right) => new ConcatAtom(left, right))\n .infixLeft('and', OperatorPrecedence.Is, (left, _, right) => new AndAtom(left, right))\n .infixLeft('as', OperatorPrecedence.Is, (left, _, right) => new AsAtom(left, right))\n .infixLeft('contains', OperatorPrecedence.Is, (left, _, right) => new ContainsAtom(left, right))\n .infixLeft(\n 'div',\n OperatorPrecedence.Is,\n (left, _, right) => new ArithemticOperatorAtom('div', left, right, (x, y) => (x / y) | 0)\n )\n .infixLeft('in', OperatorPrecedence.Is, (left, _, right) => new InAtom(left, right))\n .infixLeft('is', OperatorPrecedence.Is, (left, _, right) => new IsAtom(left, right))\n .infixLeft(\n 'mod',\n OperatorPrecedence.Is,\n (left, _, right) => new ArithemticOperatorAtom('mod', left, right, (x, y) => x % y)\n )\n .infixLeft('or', OperatorPrecedence.Is, (left, _, right) => new OrAtom(left, right))\n .infixLeft('xor', OperatorPrecedence.Is, (left, _, right) => new XorAtom(left, right));\n}\n\nconst fhirPathParserBuilder = initFhirPathParserBuilder();\n\n/**\n * Parses a FHIRPath expression into an AST.\n * The result can be used to evaluate the expression against a resource or other object.\n * This method is useful if you know that you will evaluate the same expression many times\n * against different resources.\n * @param input The FHIRPath expression to parse.\n * @returns The AST representing the expression.\n */\nexport function parseFhirPath(input: string): FhirPathAtom {\n return new FhirPathAtom(input, fhirPathParserBuilder.construct(tokenize(input)).consumeAndParse());\n}\n\n/**\n * Evaluates a FHIRPath expression against a resource or other object.\n * @param expression The FHIRPath expression to parse.\n * @param input The resource or object to evaluate the expression against.\n * @returns The result of the FHIRPath expression against the resource or object.\n */\nexport function evalFhirPath(expression: string, input: unknown): unknown[] {\n // eval requires a TypedValue array\n // As a convenience, we can accept array or non-array, and TypedValue or unknown value\n const array = Array.isArray(input) ? input : [input];\n for (let i = 0; i < array.length; i++) {\n const el = array[i];\n if (!(typeof el === 'object' && 'type' in el && 'value' in el)) {\n array[i] = toTypedValue(array[i]);\n }\n }\n return evalFhirPathTyped(expression, array).map((e) => e.value);\n}\n\n/**\n * Evaluates a FHIRPath expression against a resource or other object.\n * @param expression The FHIRPath expression to parse.\n * @param input The resource or object to evaluate the expression against.\n * @returns The result of the FHIRPath expression against the resource or object.\n */\nexport function evalFhirPathTyped(expression: string, input: TypedValue[]): TypedValue[] {\n return parseFhirPath(expression).eval(input);\n}\n","import { isStringArray } from './utils';\n\n/**\n * The Hl7Context class represents the parsing context for an HL7 message.\n *\n * MSH-1:\n * https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.1\n *\n * MSH-2:\n * https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.2\n *\n * See this tutorial on MSH, and why it's a bad idea to use anything other than the default values:\n * https://www.hl7soup.com/HL7TutorialMSH.html\n */\nexport class Hl7Context {\n constructor(\n public readonly segmentSeparator = '\\r',\n public readonly fieldSeparator = '|',\n public readonly componentSeparator = '^',\n public readonly repetitionSeparator = '~',\n public readonly escapeCharacter = '\\\\',\n public readonly subcomponentSeparator = '&'\n ) {}\n\n /**\n * Returns the MSH-2 field value based on the configured separators.\n * @returns The HL7 MSH-2 field value.\n */\n getMsh2(): string {\n return (\n this.fieldSeparator +\n this.componentSeparator +\n this.repetitionSeparator +\n this.escapeCharacter +\n this.subcomponentSeparator\n );\n }\n}\n\n/**\n * The Hl7Message class represents one HL7 message.\n * A message is a collection of segments.\n */\nexport class Hl7Message {\n readonly context: Hl7Context;\n readonly segments: Hl7Segment[];\n\n /**\n * Creates a new HL7 message.\n * @param segments The HL7 segments.\n * @param context Optional HL7 parsing context.\n */\n constructor(segments: Hl7Segment[], context = new Hl7Context()) {\n this.context = context;\n this.segments = segments;\n }\n\n /**\n * Returns an HL7 segment by index or by name.\n * @param index The HL7 segment index or name.\n * @returns The HL7 segment if found; otherwise, undefined.\n */\n get(index: number | string): Hl7Segment | undefined {\n if (typeof index === 'number') {\n return this.segments[index];\n }\n return this.segments.find((s) => s.name === index);\n }\n\n /**\n * Returns all HL7 segments of a given name.\n * @param name The HL7 segment name.\n * @returns An array of HL7 segments with the specified name.\n */\n getAll(name: string): Hl7Segment[] {\n return this.segments.filter((s) => s.name === name);\n }\n\n /**\n * Returns the HL7 message as a string.\n * @returns The HL7 message as a string.\n */\n toString(): string {\n return this.segments.map((s) => s.toString()).join(this.context.segmentSeparator);\n }\n\n /**\n * Returns an HL7 \"ACK\" (acknowledgement) message for this message.\n * @returns The HL7 \"ACK\" message.\n */\n buildAck(): Hl7Message {\n const now = new Date();\n const msh = this.get('MSH');\n const sendingApp = msh?.get(2)?.toString() || '';\n const sendingFacility = msh?.get(3)?.toString() || '';\n const receivingApp = msh?.get(4)?.toString() || '';\n const receivingFacility = msh?.get(5)?.toString() || '';\n const controlId = msh?.get(9)?.toString() || '';\n const versionId = msh?.get(12)?.toString() || '2.5.1';\n\n return new Hl7Message([\n new Hl7Segment(\n [\n 'MSH',\n this.context.getMsh2(),\n receivingApp,\n receivingFacility,\n sendingApp,\n sendingFacility,\n now.toISOString(),\n '',\n 'ACK',\n now.getTime().toString(),\n 'P',\n versionId,\n ],\n this.context\n ),\n new Hl7Segment(['MSA', 'AA', controlId, 'OK'], this.context),\n ]);\n }\n\n /**\n * Parses an HL7 message string into an Hl7Message object.\n * @param text The HL7 message text.\n * @returns The parsed HL7 message.\n */\n static parse(text: string): Hl7Message {\n if (!text.startsWith('MSH')) {\n const err = new Error('Invalid HL7 message');\n (err as any).type = 'entity.parse.failed';\n throw err;\n }\n const context = new Hl7Context(\n '\\r',\n text.charAt(3), // Field separator, recommended \"|\"\n text.charAt(4), // Component separator, recommended \"^\"\n text.charAt(5), // Repetition separator, recommended \"~\"\n text.charAt(6), // Escape character, recommended \"\\\"\n text.charAt(7) // Subcomponent separator, recommended \"&\"\n );\n return new Hl7Message(\n text.split(/[\\r\\n]+/).map((line) => Hl7Segment.parse(line, context)),\n context\n );\n }\n}\n\n/**\n * The Hl7Segment class represents one HL7 segment.\n * A segment is a collection of fields.\n * The name field is the first field.\n */\nexport class Hl7Segment {\n readonly context: Hl7Context;\n readonly name: string;\n readonly fields: Hl7Field[];\n\n /**\n * Creates a new HL7 segment.\n * @param fields The HL7 fields.\n * @param context Optional HL7 parsing context.\n */\n constructor(fields: Hl7Field[] | string[], context = new Hl7Context()) {\n this.context = context;\n if (isStringArray(fields)) {\n this.fields = fields.map((f) => Hl7Field.parse(f));\n } else {\n this.fields = fields;\n }\n this.name = this.fields[0].components[0][0];\n }\n\n /**\n * Returns an HL7 field by index.\n * @param index The HL7 field index.\n * @returns The HL7 field.\n */\n get(index: number): Hl7Field {\n return this.fields[index];\n }\n\n /**\n * Returns the HL7 segment as a string.\n * @returns The HL7 segment as a string.\n */\n toString(): string {\n return this.fields.map((f) => f.toString()).join(this.context.fieldSeparator);\n }\n\n /**\n * Parses an HL7 segment string into an Hl7Segment object.\n * @param text The HL7 segment text.\n * @param context Optional HL7 parsing context.\n * @returns The parsed HL7 segment.\n */\n static parse(text: string, context = new Hl7Context()): Hl7Segment {\n return new Hl7Segment(\n text.split(context.fieldSeparator).map((f) => Hl7Field.parse(f, context)),\n context\n );\n }\n}\n\n/**\n * The Hl7Field class represents one HL7 field.\n * A field is a collection of components.\n */\nexport class Hl7Field {\n readonly context: Hl7Context;\n readonly components: string[][];\n\n /**\n * Creates a new HL7 field.\n * @param components The HL7 components.\n * @param context Optional HL7 parsing context.\n */\n constructor(components: string[][], context = new Hl7Context()) {\n this.context = context;\n this.components = components;\n }\n\n /**\n * Returns an HL7 component by index.\n * @param component The component index.\n * @param subcomponent Optional subcomponent index.\n * @param repetition Optional repetition index.\n * @returns The string value of the specified component.\n */\n get(component: number, subcomponent?: number, repetition = 0): string {\n let value = this.components[repetition][component] || '';\n\n if (subcomponent !== undefined) {\n value = value.split(this.context.subcomponentSeparator)[subcomponent] || '';\n }\n\n return value;\n }\n\n /**\n * Returns the HL7 field as a string.\n * @returns The HL7 field as a string.\n */\n toString(): string {\n return this.components.map((r) => r.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);\n }\n\n /**\n * Parses an HL7 field string into an Hl7Field object.\n * @param text The HL7 field text.\n * @param context Optional HL7 parsing context.\n * @returns The parsed HL7 field.\n */\n static parse(text: string, context = new Hl7Context()): Hl7Field {\n return new Hl7Field(\n text.split(context.repetitionSeparator).map((r) => r.split(context.componentSeparator)),\n context\n );\n }\n}\n","import { ResourceType } from '@medplum/fhirtypes';\n\nexport const DEFAULT_SEARCH_COUNT = 20;\n\nexport interface SearchRequest {\n readonly resourceType: ResourceType;\n filters?: Filter[];\n sortRules?: SortRule[];\n offset?: number;\n count?: number;\n fields?: string[];\n name?: string;\n total?: 'none' | 'estimate' | 'accurate';\n revInclude?: string;\n}\n\nexport interface Filter {\n code: string;\n operator: Operator;\n value: string;\n unitSystem?: string;\n unitCode?: string;\n}\n\nexport interface SortRule {\n code: string;\n descending?: boolean;\n}\n\n/**\n * Search operators.\n * These operators represent \"modifiers\" and \"prefixes\" in FHIR search.\n * See: https://www.hl7.org/fhir/search.html\n */\nexport enum Operator {\n EQUALS = 'eq',\n NOT_EQUALS = 'ne',\n\n // Numbers\n GREATER_THAN = 'gt',\n LESS_THAN = 'lt',\n GREATER_THAN_OR_EQUALS = 'ge',\n LESS_THAN_OR_EQUALS = 'le',\n\n // Dates\n STARTS_AFTER = 'sa',\n ENDS_BEFORE = 'eb',\n APPROXIMATELY = 'ap',\n\n // String\n CONTAINS = 'contains',\n EXACT = 'exact',\n\n // Token\n TEXT = 'text',\n NOT = 'not',\n ABOVE = 'above',\n BELOW = 'below',\n IN = 'in',\n NOT_IN = 'not-in',\n OF_TYPE = 'of-type',\n\n // All\n MISSING = 'missing',\n}\n\nconst MODIFIER_OPERATORS: Operator[] = [\n Operator.CONTAINS,\n Operator.EXACT,\n Operator.TEXT,\n Operator.NOT,\n Operator.ABOVE,\n Operator.BELOW,\n Operator.IN,\n Operator.NOT_IN,\n Operator.OF_TYPE,\n Operator.MISSING,\n];\n\nconst PREFIX_OPERATORS: Operator[] = [\n Operator.NOT_EQUALS,\n Operator.GREATER_THAN,\n Operator.LESS_THAN,\n Operator.GREATER_THAN_OR_EQUALS,\n Operator.LESS_THAN_OR_EQUALS,\n Operator.STARTS_AFTER,\n Operator.ENDS_BEFORE,\n Operator.APPROXIMATELY,\n];\n\n/**\n * Parses a URL into a SearchRequest.\n *\n * See the FHIR search spec: http://hl7.org/fhir/r4/search.html\n *\n * @param url The URL to parse.\n * @returns Parsed search definition.\n */\nexport function parseSearchDefinition(url: string): SearchRequest {\n const location = new URL(url, 'https://example.com/');\n const resourceType = location.pathname\n .replace(/(^\\/)|(\\/$)/g, '') // Remove leading and trailing slashes\n .split('/')\n .pop() as ResourceType;\n const params = new URLSearchParams(location.search);\n let filters: Filter[] | undefined = undefined;\n let sortRules: SortRule[] | undefined = undefined;\n let fields: string[] | undefined = undefined;\n let offset = undefined;\n let count = undefined;\n let total = undefined;\n\n params.forEach((value, key) => {\n if (key === '_fields') {\n fields = value.split(',');\n } else if (key === '_offset') {\n offset = parseInt(value);\n } else if (key === '_count') {\n count = parseInt(value);\n } else if (key === '_total') {\n total = value;\n } else if (key === '_sort') {\n sortRules = sortRules || [];\n sortRules.push(parseSortRule(value));\n } else {\n filters = filters || [];\n filters.push(parseSearchFilter(key, value));\n }\n });\n\n return {\n resourceType,\n filters,\n fields,\n offset,\n count,\n total,\n sortRules,\n };\n}\n\n/**\n * Parses a URL query parameter into a sort rule.\n *\n * By default, the sort rule is the field name.\n *\n * Sort rules can be reversed into descending order by prefixing the field name with a minus sign.\n *\n * See sorting: http://hl7.org/fhir/r4/search.html#_sort\n *\n * @param value The URL parameter value.\n * @returns The parsed sort rule.\n */\nfunction parseSortRule(value: string): SortRule {\n if (value.startsWith('-')) {\n return { code: value.substring(1), descending: true };\n } else {\n return { code: value };\n }\n}\n\n/**\n * Parses a URL query parameter into a search filter.\n *\n * FHIR search filters can be specified as modifiers or prefixes.\n *\n * For string properties, modifiers are appended to the key, e.g. \"name:contains=eve\".\n *\n * For date and numeric properties, prefixes are prepended to the value, e.g. \"birthdate=gt2000\".\n *\n * See the FHIR search spec: http://hl7.org/fhir/r4/search.html\n *\n * @param key The URL parameter key.\n * @param value The URL parameter value.\n * @returns The parsed search filter.\n */\nfunction parseSearchFilter(key: string, value: string): Filter {\n let code = key;\n let operator = Operator.EQUALS;\n\n for (const modifier of MODIFIER_OPERATORS) {\n const modifierIndex = code.indexOf(':' + modifier);\n if (modifierIndex !== -1) {\n operator = modifier;\n code = code.substring(0, modifierIndex);\n }\n }\n\n for (const prefix of PREFIX_OPERATORS) {\n if (value.match(new RegExp('^' + prefix + '\\\\d'))) {\n operator = prefix;\n value = value.substring(prefix.length);\n }\n }\n\n return { code, operator, value };\n}\n\n/**\n * Formats a search definition object into a query string.\n * Note: The return value does not include the resource type.\n * @param {!SearchRequest} definition The search definition.\n * @returns Formatted URL.\n */\nexport function formatSearchQuery(definition: SearchRequest): string {\n const params: string[] = [];\n\n if (definition.fields) {\n params.push('_fields=' + definition.fields.join(','));\n }\n\n if (definition.filters) {\n definition.filters.forEach((filter) => params.push(formatFilter(filter)));\n }\n\n if (definition.sortRules && definition.sortRules.length > 0) {\n params.push(formatSortRules(definition.sortRules));\n }\n\n if (definition.offset !== undefined) {\n params.push('_offset=' + definition.offset);\n }\n\n if (definition.count !== undefined) {\n params.push('_count=' + definition.count);\n }\n\n if (definition.total !== undefined) {\n params.push('_total=' + definition.total);\n }\n\n if (params.length === 0) {\n return '';\n }\n\n params.sort();\n return '?' + params.join('&');\n}\n\nfunction formatFilter(filter: Filter): string {\n const modifier = MODIFIER_OPERATORS.includes(filter.operator) ? ':' + filter.operator : '';\n const prefix = PREFIX_OPERATORS.includes(filter.operator) ? filter.operator : '';\n return `${filter.code}${modifier}=${prefix}${encodeURIComponent(filter.value)}`;\n}\n\nfunction formatSortRules(sortRules: SortRule[] | undefined): string {\n if (!sortRules || sortRules.length === 0) {\n return '';\n }\n return '_sort=' + sortRules.map((sr) => (sr.descending ? '-' + sr.code : sr.code)).join(',');\n}\n","import { ElementDefinition, SearchParameter } from '@medplum/fhirtypes';\nimport { globalSchema, PropertyType } from './types';\nimport { capitalize } from './utils';\n\nexport enum SearchParameterType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n QUANTITY = 'QUANTITY',\n TEXT = 'TEXT',\n REFERENCE = 'REFERENCE',\n DATE = 'DATE',\n DATETIME = 'DATETIME',\n PERIOD = 'PERIOD',\n}\n\nexport interface SearchParameterDetails {\n readonly columnName: string;\n readonly type: SearchParameterType;\n readonly elementDefinition?: ElementDefinition;\n readonly array?: boolean;\n}\n\n/**\n * Returns the type details of a SearchParameter.\n *\n * The SearchParameter resource has a \"type\" parameter, but that is missing some critical information.\n *\n * For example:\n * 1) The \"date\" type includes \"date\", \"datetime\", and \"period\".\n * 2) The \"token\" type includes enums and booleans.\n * 3) Arrays/multiple values are not reflected at all.\n *\n * @param resourceType The root resource type.\n * @param searchParam The search parameter.\n * @returns The search parameter type details.\n */\nexport function getSearchParameterDetails(resourceType: string, searchParam: SearchParameter): SearchParameterDetails {\n let result: SearchParameterDetails | undefined =\n globalSchema.types[resourceType]?.searchParamsDetails?.[searchParam.code as string];\n if (!result) {\n result = buildSearchParamterDetails(resourceType, searchParam);\n }\n return result;\n}\n\nfunction setSearchParamterDetails(resourceType: string, code: string, details: SearchParameterDetails): void {\n const typeSchema = globalSchema.types[resourceType];\n if (!typeSchema.searchParamsDetails) {\n typeSchema.searchParamsDetails = {};\n }\n typeSchema.searchParamsDetails[code] = details;\n}\n\nfunction buildSearchParamterDetails(resourceType: string, searchParam: SearchParameter): SearchParameterDetails {\n if (searchParam.code === '_lastUpdated') {\n return { columnName: 'lastUpdated', type: SearchParameterType.DATETIME };\n }\n\n const code = searchParam.code as string;\n const columnName = convertCodeToColumnName(code);\n const expression = getExpressionForResourceType(resourceType, searchParam.expression as string)?.split('.');\n if (!expression) {\n // This happens on compound types\n // In the future, explore returning multiple column definitions\n return { columnName, type: SearchParameterType.TEXT };\n }\n\n const defaultType = getSearchParameterType(searchParam);\n let baseType = resourceType;\n let elementDefinition = undefined;\n let propertyType = undefined;\n let array = false;\n\n for (let i = 1; i < expression.length; i++) {\n const propertyName = expression[i];\n elementDefinition =\n globalSchema.types[baseType]?.properties?.[propertyName] ??\n globalSchema.types[baseType]?.properties?.[propertyName + '[x]'];\n if (!elementDefinition) {\n throw new Error(`Element definition not found for ${resourceType} ${searchParam.code}`);\n }\n\n if (elementDefinition.max === '*') {\n array = true;\n }\n\n propertyType = elementDefinition.type?.[0].code;\n if (!propertyType) {\n // This happens when one of parent properties uses contentReference\n // In the future, explore following the reference\n return { columnName, type: defaultType, array };\n }\n\n if (i < expression.length - 1) {\n if (propertyType === 'Element' || propertyType === 'BackboneElement') {\n baseType = baseType + capitalize(propertyName);\n } else {\n baseType = propertyType;\n }\n }\n }\n\n const type = getSearchParameterType(searchParam, propertyType as PropertyType);\n const result = { columnName, type, elementDefinition, array };\n setSearchParamterDetails(resourceType, code, result);\n return result;\n}\n\n/**\n * Converts a hyphen-delimited code to camelCase string.\n * @param code The search parameter code.\n * @returns The SQL column name.\n */\nfunction convertCodeToColumnName(code: string): string {\n return code.split('-').reduce((result, word, index) => result + (index ? capitalize(word) : word), '');\n}\n\nfunction getSearchParameterType(searchParam: SearchParameter, propertyType?: PropertyType): SearchParameterType {\n let type = SearchParameterType.TEXT;\n switch (searchParam.type) {\n case 'date':\n if (propertyType === PropertyType.dateTime || propertyType === PropertyType.instant) {\n type = SearchParameterType.DATETIME;\n } else {\n type = SearchParameterType.DATE;\n }\n break;\n case 'number':\n type = SearchParameterType.NUMBER;\n break;\n case 'quantity':\n type = SearchParameterType.QUANTITY;\n break;\n case 'reference':\n type = SearchParameterType.REFERENCE;\n break;\n case 'token':\n if (propertyType === 'boolean') {\n type = SearchParameterType.BOOLEAN;\n }\n break;\n }\n return type;\n}\n\nexport function getExpressionForResourceType(resourceType: string, expression: string): string | undefined {\n const expressions = expression.split(' | ');\n for (const e of expressions) {\n if (isIgnoredExpression(e)) {\n continue;\n }\n const simplified = simplifyExpression(e);\n if (simplified.startsWith(resourceType + '.')) {\n return simplified;\n }\n }\n return undefined;\n}\n\nfunction isIgnoredExpression(input: string): boolean {\n return input.includes(' as Period') || input.includes(' as SampledDate');\n}\n\nfunction simplifyExpression(input: string): string {\n let result = input.trim();\n\n if (result.startsWith('(') && result.endsWith(')')) {\n result = result.substring(1, result.length - 1);\n }\n\n if (result.includes('[0]')) {\n result = result.replaceAll('[0]', '');\n }\n\n const stopStrings = [' != ', ' as ', '.as(', '.exists(', '.where('];\n for (const stopString of stopStrings) {\n if (result.includes(stopString)) {\n result = result.substring(0, result.indexOf(stopString));\n }\n }\n\n return result;\n}\n","import { Reference, Resource, SearchParameter } from '@medplum/fhirtypes';\nimport { evalFhirPath } from './fhirpath';\nimport { Filter, Operator, SearchRequest } from './search';\nimport { getSearchParameterDetails, SearchParameterType } from './searchparams';\nimport { globalSchema } from './types';\n\n/**\n * Determines if the resource matches the search request.\n * @param resource The resource that was created or updated.\n * @param searchRequest The subscription criteria as a search request.\n * @returns True if the resource satisfies the search request.\n */\nexport function matchesSearchRequest(resource: Resource, searchRequest: SearchRequest): boolean {\n if (searchRequest.resourceType !== resource.resourceType) {\n return false;\n }\n if (searchRequest.filters) {\n for (const filter of searchRequest.filters) {\n if (!matchesSearchFilter(resource, searchRequest, filter)) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * Determines if the resource matches the search filter.\n * @param resource The resource that was created or updated.\n * @param filter One of the filters of a subscription criteria.\n * @returns True if the resource satisfies the search filter.\n */\nfunction matchesSearchFilter(resource: Resource, searchRequest: SearchRequest, filter: Filter): boolean {\n const searchParam = globalSchema.types[searchRequest.resourceType]?.searchParams?.[filter.code];\n switch (searchParam?.type) {\n case 'reference':\n return matchesReferenceFilter(resource, filter, searchParam);\n case 'string':\n return matchesStringFilter(resource, filter, searchParam);\n case 'token':\n return matchesTokenFilter(resource, filter, searchParam);\n case 'date':\n return matchesDateFilter(resource, filter, searchParam);\n }\n // Unknown search parameter or search parameter type\n // Default fail the check\n return false;\n}\n\nfunction matchesReferenceFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const values = evalFhirPath(searchParam.expression as string, resource) as (Reference | string)[];\n const negated = isNegated(filter.operator);\n\n if (filter.value === '' && values.length === 0) {\n // If the filter operator is \"equals\", then the filter matches.\n // If the filter operator is \"not equals\", then the filter does not match.\n return filter.operator === Operator.EQUALS;\n }\n\n // Normalize the values array into reference strings\n const references = values.map((value) => (typeof value === 'string' ? value : value.reference));\n\n for (const filterValue of filter.value.split(',')) {\n let match = references.includes(filterValue);\n if (!match && filter.code === '_compartment') {\n // Backwards compability for compartment search parameter\n // In previous versions, the resource type was not required in compartment values\n // So, \"123\" would match \"Patient/123\"\n // We need to maintain this behavior for backwards compatibility\n match = references.some((reference) => reference?.endsWith('/' + filterValue));\n }\n if (match) {\n return !negated;\n }\n }\n // If \"not equals\" and no matches, then return true\n // If \"equals\" and no matches, then return false\n return negated;\n}\n\nfunction matchesTokenFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const details = getSearchParameterDetails(resource.resourceType, searchParam);\n if (details.type === SearchParameterType.BOOLEAN) {\n return matchesBooleanFilter(resource, filter, searchParam);\n } else {\n return matchesStringFilter(resource, filter, searchParam);\n }\n}\n\nfunction matchesBooleanFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const values = evalFhirPath(searchParam.expression as string, resource);\n const expected = filter.value === 'true';\n const result = values.includes(expected);\n return isNegated(filter.operator) ? !result : result;\n}\n\nfunction matchesStringFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const resourceValues = evalFhirPath(searchParam.expression as string, resource);\n const filterValues = filter.value.split(',');\n const negated = isNegated(filter.operator);\n for (const resourceValue of resourceValues) {\n for (const filterValue of filterValues) {\n const match = matchesStringValue(resourceValue, filter.operator, filterValue);\n if (match) {\n return !negated;\n }\n }\n }\n // If \"not equals\" and no matches, then return true\n // If \"equals\" and no matches, then return false\n return negated;\n}\n\nfunction matchesStringValue(resourceValue: unknown, operator: Operator, filterValue: string): boolean {\n let str = '';\n if (resourceValue) {\n if (typeof resourceValue === 'string') {\n str = resourceValue;\n } else if (typeof resourceValue === 'object') {\n str = JSON.stringify(resourceValue);\n }\n }\n return str.toLowerCase().includes(filterValue.toLowerCase());\n}\n\nfunction matchesDateFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const resourceValues = evalFhirPath(searchParam.expression as string, resource);\n const filterValues = filter.value.split(',');\n const negated = isNegated(filter.operator);\n for (const resourceValue of resourceValues) {\n for (const filterValue of filterValues) {\n const match = matchesDateValue(resourceValue as string, filter.operator, filterValue);\n if (match) {\n return !negated;\n }\n }\n }\n // If \"not equals\" and no matches, then return true\n // If \"equals\" and no matches, then return false\n return negated;\n}\n\nfunction matchesDateValue(resourceValue: string, operator: Operator, filterValue: string): boolean {\n switch (operator) {\n case Operator.STARTS_AFTER:\n case Operator.GREATER_THAN:\n return resourceValue > filterValue;\n case Operator.GREATER_THAN_OR_EQUALS:\n return resourceValue >= filterValue;\n case Operator.ENDS_BEFORE:\n case Operator.LESS_THAN:\n return resourceValue < filterValue;\n case Operator.LESS_THAN_OR_EQUALS:\n return resourceValue <= filterValue;\n case Operator.EQUALS:\n case Operator.NOT_EQUALS:\n return resourceValue === filterValue;\n }\n return false;\n}\n\nfunction isNegated(operator: Operator): boolean {\n return operator === Operator.NOT_EQUALS || operator === Operator.NOT;\n}\n"],"names":["toPreciseInteger","deepEquals","isObject","PropertyType","Operator","SearchParameterType"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;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,EAAE,QAAkB,EAAE,WAAmB,EAAA;IACtF,IAAA,QAAQ,QAAQ;YACd,KAAKD,gBAAQ,CAAC,YAAY,CAAC;YAC3B,KAAKA,gBAAQ,CAAC,YAAY;gBACxB,OAAO,aAAa,GAAG,WAAW,CAAC;YACrC,KAAKA,gBAAQ,CAAC,sBAAsB;gBAClC,OAAO,aAAa,IAAI,WAAW,CAAC;YACtC,KAAKA,gBAAQ,CAAC,WAAW,CAAC;YAC1B,KAAKA,gBAAQ,CAAC,SAAS;gBACrB,OAAO,aAAa,GAAG,WAAW,CAAC;YACrC,KAAKA,gBAAQ,CAAC,mBAAmB;gBAC/B,OAAO,aAAa,IAAI,WAAW,CAAC;YACtC,KAAKA,gBAAQ,CAAC,MAAM,CAAC;YACrB,KAAKA,gBAAQ,CAAC,UAAU;gBACtB,OAAO,aAAa,KAAK,WAAW,CAAC;IACxC,KAAA;IACD,IAAA,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,SAAS,CAAC,QAAkB,EAAA;QACnC,OAAO,QAAQ,KAAKA,gBAAQ,CAAC,UAAU,IAAI,QAAQ,KAAKA,gBAAQ,CAAC,GAAG,CAAC;IACvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../node_modules/tslib/tslib.es6.js","../../src/cache.ts","../../src/format.ts","../../src/utils.ts","../../src/crypto.ts","../../src/eventtarget.ts","../../src/jwt.ts","../../src/outcomes.ts","../../src/readablepromise.ts","../../src/storage.ts","../../src/types.ts","../../src/client.ts","../../src/fhirlexer/parse.ts","../../src/fhirlexer/tokenize.ts","../../src/fhirpath/date.ts","../../src/fhirpath/utils.ts","../../src/fhirpath/functions.ts","../../src/fhirpath/atoms.ts","../../src/fhirpath/tokenize.ts","../../src/fhirpath/parse.ts","../../src/hl7.ts","../../src/search/details.ts","../../src/search/search.ts","../../src/search/match.ts","../../src/search/parse.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.push(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.push(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * LRU cache (least recently used)\n * Source: https://stackoverflow.com/a/46432113\n */\nexport class LRUCache<T> {\n readonly #max: number;\n readonly #cache: Map<string, T>;\n\n constructor(max = 10) {\n this.#max = max;\n this.#cache = new Map();\n }\n\n /**\n * Deletes all values from the cache.\n */\n clear(): void {\n this.#cache.clear();\n }\n\n /**\n * Returns the value for the given key.\n * @param key The key to retrieve.\n * @returns The value if found; undefined otherwise.\n */\n get(key: string): T | undefined {\n const item = this.#cache.get(key);\n if (item) {\n this.#cache.delete(key);\n this.#cache.set(key, item);\n }\n return item;\n }\n\n /**\n * Sets the value for the given key.\n * @param key The key to set.\n * @param val The value to set.\n */\n set(key: string, val: T): void {\n if (this.#cache.has(key)) {\n this.#cache.delete(key);\n } else if (this.#cache.size >= this.#max) {\n this.#cache.delete(this.#first());\n }\n this.#cache.set(key, val);\n }\n\n /**\n * Deletes the value for the given key.\n * @param key The key to delete.\n */\n delete(key: string): void {\n this.#cache.delete(key);\n }\n\n /**\n * Returns the list of all keys in the cache.\n * @returns The array of keys in the cache.\n */\n keys(): IterableIterator<string> {\n return this.#cache.keys();\n }\n\n #first(): string {\n // This works because the Map class maintains ordered keys.\n return this.#cache.keys().next().value;\n }\n}\n","import {\n Address,\n CodeableConcept,\n Coding,\n HumanName,\n Money,\n Observation,\n ObservationComponent,\n Period,\n Quantity,\n Range,\n Timing,\n} from '@medplum/fhirtypes';\nimport { capitalize } from './utils';\n\nexport interface AddressFormatOptions {\n all?: boolean;\n use?: boolean;\n lineSeparator?: string;\n}\n\nexport interface HumanNameFormatOptions {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n}\n\n/**\n * Formats a FHIR Address as a string.\n * @param address The address to format.\n * @param options Optional address format options.\n * @returns The formatted address string.\n */\nexport function formatAddress(address: Address, options?: AddressFormatOptions): string {\n const builder = [];\n\n if (address.line) {\n builder.push(...address.line);\n }\n\n if (address.city || address.state || address.postalCode) {\n const cityStateZip = [];\n if (address.city) {\n cityStateZip.push(address.city);\n }\n if (address.state) {\n cityStateZip.push(address.state);\n }\n if (address.postalCode) {\n cityStateZip.push(address.postalCode);\n }\n builder.push(cityStateZip.join(', '));\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(options?.lineSeparator || ', ').trim();\n}\n\n/**\n * Formats a FHIR HumanName as a string.\n * @param name The name to format.\n * @param options Optional name format options.\n * @returns The formatted name string.\n */\nexport function formatHumanName(name: HumanName, options?: HumanNameFormatOptions): string {\n const builder = [];\n\n if (name.prefix && options?.prefix !== false) {\n builder.push(...name.prefix);\n }\n\n if (name.given) {\n builder.push(...name.given);\n }\n\n if (name.family) {\n builder.push(name.family);\n }\n\n if (name.suffix && options?.suffix !== false) {\n builder.push(...name.suffix);\n }\n\n if (name.use && (options?.all || options?.use)) {\n builder.push('[' + name.use + ']');\n }\n\n return builder.join(' ').trim();\n}\n\n/**\n * Formats the given name portion of a FHIR HumanName element.\n * @param name The name to format.\n * @returns The formatted given name string.\n */\nexport function formatGivenName(name: HumanName): string {\n const builder: string[] = [];\n if (name.given) {\n builder.push(...name.given);\n }\n return builder.join(' ').trim();\n}\n\n/**\n * Formats the family name portion of a FHIR HumanName element.\n * @param name The name to format.\n * @returns The formatted family name string.\n */\nexport function formatFamilyName(name: HumanName): string {\n return name.family || '';\n}\n\n/**\n * Returns true if the given date object is a valid date.\n * Dates can be invalid if created by parsing an invalid string.\n * @param date A date object.\n * @returns Returns true if the date is a valid date.\n */\nexport function isValidDate(date: Date): boolean {\n return date instanceof Date && !isNaN(date.getTime());\n}\n\n/**\n * Formats a FHIR date string as a human readable string.\n * Handles missing values and invalid dates.\n * @param date The date to format.\n * @param locales Optional locales.\n * @param options Optional date format options.\n * @returns The formatted date string.\n */\nexport function formatDate(\n date: string | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!date) {\n return '';\n }\n const d = new Date(date);\n if (!isValidDate(d)) {\n return '';\n }\n d.setUTCHours(0, 0, 0, 0);\n return d.toLocaleDateString(locales, { timeZone: 'UTC', ...options });\n}\n\n/**\n * Formats a FHIR time string as a human readable string.\n * Handles missing values and invalid dates.\n * @param time The date to format.\n * @param locales Optional locales.\n * @param options Optional time format options.\n * @returns The formatted time string.\n */\nexport function formatTime(\n time: string | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!time) {\n return '';\n }\n const d = new Date('2000-01-01T' + time + 'Z');\n if (!isValidDate(d)) {\n return '';\n }\n return d.toLocaleTimeString(locales, options);\n}\n\n/**\n * Formats a FHIR dateTime string as a human readable string.\n * Handles missing values and invalid dates.\n * @param dateTime The dateTime to format.\n * @param locales Optional locales.\n * @param options Optional dateTime format options.\n * @returns The formatted dateTime string.\n */\nexport function formatDateTime(\n dateTime: string | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!dateTime) {\n return '';\n }\n const d = new Date(dateTime);\n if (!isValidDate(d)) {\n return '';\n }\n return d.toLocaleString(locales, options);\n}\n\n/**\n * Formats a FHIR Period as a human readable string.\n * @param period The period to format.\n * @param locales Optional locales.\n * @param options Optional period format options.\n * @returns The formatted period string.\n */\nexport function formatPeriod(\n period: Period | undefined,\n locales?: Intl.LocalesArgument,\n options?: Intl.DateTimeFormatOptions | undefined\n): string {\n if (!period || (!period.start && !period.end)) {\n return '';\n }\n return formatDateTime(period.start, locales, options) + ' - ' + formatDateTime(period.end, locales, options);\n}\n\nconst unitAdverbForm: Record<string, string> = {\n s: 'every second',\n min: 'every minute',\n h: 'hourly',\n d: 'daily',\n wk: 'weekly',\n mo: 'monthly',\n a: 'annually',\n};\n\nconst singularUnits: Record<string, string> = {\n s: 'second',\n min: 'minute',\n h: 'hour',\n d: 'day',\n wk: 'week',\n mo: 'month',\n a: 'year',\n};\n\nconst pluralUnits: Record<string, string> = {\n s: 'seconds',\n min: 'minutes',\n h: 'hours',\n d: 'days',\n wk: 'weeks',\n mo: 'months',\n a: 'years',\n};\n\n/**\n * Formats a FHIR Timing as a human readable string.\n * @param timing The timing to format.\n * @returns The formatted timing string.\n */\nexport function formatTiming(timing: Timing | undefined): string {\n if (!timing) {\n return '';\n }\n\n const builder: string[] = [];\n\n if (timing.repeat?.periodUnit) {\n const frequency = timing.repeat.frequency || 1;\n const period = timing.repeat.period || 1;\n const periodUnit = timing.repeat.periodUnit;\n\n if (frequency === 1 && period === 1) {\n builder.push(unitAdverbForm[periodUnit]);\n } else {\n if (frequency === 1) {\n builder.push('once');\n } else {\n builder.push(frequency + ' times');\n }\n\n if (period === 1) {\n builder.push('per ' + singularUnits[periodUnit]);\n } else {\n builder.push('per ' + period + ' ' + pluralUnits[periodUnit]);\n }\n }\n\n if (timing.repeat.dayOfWeek) {\n builder.push('on ' + timing.repeat.dayOfWeek.map(capitalize).join(', '));\n }\n\n if (timing.repeat.timeOfDay) {\n builder.push('at ' + timing.repeat.timeOfDay.map((t) => formatTime(t)).join(', '));\n }\n }\n\n if (timing.event) {\n builder.push(timing.event.map((d) => formatDateTime(d)).join(', '));\n }\n\n return capitalize(builder.join(' ').trim());\n}\n\n/**\n * Returns a human-readable string for a FHIR Range datatype, taking into account comparators and one-sided ranges\n * @param range A FHIR Range element\n * @param exclusive If true, one-sided ranges will be rendered with the '>' or '<' bounds rather than '>=' or '<='\n * @returns A human-readable string representation of the Range\n */\nexport function formatRange(range: Range | undefined, precision?: number, exclusive = false): string {\n if (exclusive && precision === undefined) {\n throw new Error('Precision must be specified for exclusive ranges');\n }\n\n const low = range?.low && { ...range.low };\n const high = range?.high && { ...range.high };\n if (!range || (low?.value === undefined && high?.value === undefined)) {\n return '';\n }\n\n if (range.low?.value !== undefined && range.high?.value === undefined) {\n if (exclusive && precision !== undefined) {\n range.low.value = preciseDecrement(range.low.value, precision);\n return `> ${formatQuantity(range.low, precision)}`;\n }\n return `>= ${formatQuantity(range.low, precision)}`;\n }\n\n if (range.low?.value === undefined && range.high?.value !== undefined) {\n if (exclusive && precision !== undefined) {\n range.high.value = preciseIncrement(range.high.value, precision);\n return `< ${formatQuantity(range.high, precision)}`;\n }\n return `<= ${formatQuantity(range.high, precision)}`;\n }\n\n if (low?.unit === high?.unit) {\n delete low?.unit;\n }\n return `${formatQuantity(low, precision)} - ${formatQuantity(high, precision)}`;\n}\n\n/**\n * Returns a human-readable string for a FHIR Quantity datatype, taking into account units and comparators\n * @param quantity A FHIR Quantity element\n * @returns A human-readable string representation of the Quantity\n */\nexport function formatQuantity(quantity: Quantity | undefined, precision?: number): string {\n if (!quantity) {\n return '';\n }\n\n const result = [];\n\n if (quantity.comparator) {\n result.push(quantity.comparator);\n result.push(' ');\n }\n\n if (quantity.value !== undefined) {\n if (precision !== undefined) {\n result.push(quantity.value.toFixed(precision));\n } else {\n result.push(quantity.value);\n }\n }\n\n if (quantity.unit) {\n if (quantity.unit !== '%' && result[result.length - 1] !== ' ') {\n result.push(' ');\n }\n result.push(quantity.unit);\n }\n\n return result.join('').trim();\n}\n\nexport function formatMoney(money: Money | undefined): string {\n if (money?.value === undefined) {\n return '';\n }\n\n return money.value.toLocaleString(undefined, {\n style: 'currency',\n currency: money.currency || 'USD',\n currencyDisplay: 'narrowSymbol',\n });\n}\n\n/**\n * Formats a CodeableConcept element as a string.\n * @param codeableConcept A FHIR CodeableConcept element\n * @returns The codeable concept as a string.\n */\nexport function formatCodeableConcept(codeableConcept: CodeableConcept | undefined): string {\n if (!codeableConcept) {\n return '';\n }\n if (codeableConcept.text) {\n return codeableConcept.text;\n }\n if (codeableConcept.coding) {\n return codeableConcept.coding.map((c) => formatCoding(c)).join(', ');\n }\n return '';\n}\n\n/**\n * Formats a Coding element as a string.\n * @param coding A FHIR Coding element\n * @returns The coding as a string.\n */\nexport function formatCoding(coding: Coding | undefined): string {\n return coding?.display || coding?.code || '';\n}\n\n/**\n * Formats a FHIR Observation resource value as a string.\n * @param obs A FHIR Observation resource.\n * @returns A human-readable string representation of the Observation.\n */\nexport function formatObservationValue(obs: Observation | ObservationComponent | undefined): string {\n if (!obs) {\n return '';\n }\n\n if ('component' in obs) {\n return (obs.component as ObservationComponent[]).map((c) => formatObservationValue(c)).join(' / ');\n }\n\n if (obs?.valueQuantity) {\n return formatQuantity(obs.valueQuantity);\n }\n\n if (obs.valueCodeableConcept) {\n return formatCodeableConcept(obs.valueCodeableConcept);\n }\n\n if (obs.valueString) {\n return obs.valueString;\n }\n\n return '';\n}\n\n/**\n * Returns the input number increased by the `n` units of the specified precision\n * @param a The input number\n * @param precision The precision in number of digits.\n * @param n (default 1) The number of units to add\n */\nfunction preciseIncrement(a: number, precision: number, n = 1): number {\n return (toPreciseInteger(a, precision) + n) * Math.pow(10, -precision);\n}\n\n/**\n * Returns the input number decreased by the `n` units of the specified precision\n * @param a The input number\n * @param precision The precision in number of digits.\n * @param n (default 1) The number of units to subtract\n */\nfunction preciseDecrement(a: number, precision: number, n = 1): number {\n return (toPreciseInteger(a, precision) - n) * Math.pow(10, -precision);\n}\n\n/**\n * Returns an integer representation of the number with the given precision.\n * For example, if precision is 2, then 1.2345 will be returned as 123.\n * @param a The number.\n * @param precision Optional precision in number of digits.\n * @returns The integer with the given precision.\n */\nfunction toPreciseInteger(a: number, precision?: number): number {\n if (precision === undefined) {\n return a;\n }\n return Math.round(a * Math.pow(10, precision));\n}\n","import {\n Attachment,\n CodeableConcept,\n Device,\n Extension,\n Identifier,\n ObservationDefinition,\n ObservationDefinitionQualifiedInterval,\n Patient,\n Practitioner,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer,\n Range,\n Reference,\n RelatedPerson,\n Resource,\n} from '@medplum/fhirtypes';\nimport { formatHumanName } from './format';\n\n/**\n * @internal\n */\nexport type ProfileResource = Patient | Practitioner | RelatedPerson;\n\n/**\n * Creates a reference resource.\n * @param resource The FHIR reesource.\n * @returns A reference resource.\n */\nexport function createReference<T extends Resource>(resource: T): Reference<T> {\n const reference = getReferenceString(resource);\n const display = getDisplayString(resource);\n return display === reference ? { reference } : { reference, display };\n}\n\n/**\n * Returns a reference string for a resource.\n * @param resource The FHIR resource.\n * @returns A reference string of the form resourceType/id.\n */\nexport function getReferenceString(resource: Resource): string {\n return resource.resourceType + '/' + resource.id;\n}\n\n/**\n * Returns the ID portion of a reference.\n * @param reference A FHIR reference.\n * @returns The ID portion of a reference.\n */\nexport function resolveId(reference: Reference | undefined): string | undefined {\n return reference?.reference?.split('/')[1];\n}\n\n/**\n * Returns true if the resource is a \"ProfileResource\".\n * @param resource The FHIR resource.\n * @returns True if the resource is a \"ProfileResource\".\n */\nexport function isProfileResource(resource: Resource): resource is ProfileResource {\n return (\n resource.resourceType === 'Patient' ||\n resource.resourceType === 'Practitioner' ||\n resource.resourceType === 'RelatedPerson'\n );\n}\n\n/**\n * Returns a display string for the resource.\n * @param resource The input resource.\n * @return Human friendly display string.\n */\nexport function getDisplayString(resource: Resource): string {\n if (isProfileResource(resource)) {\n const profileName = getProfileResourceDisplayString(resource);\n if (profileName) {\n return profileName;\n }\n }\n if (resource.resourceType === 'Device') {\n const deviceName = getDeviceDisplayString(resource);\n if (deviceName) {\n return deviceName;\n }\n }\n if (resource.resourceType === 'Observation') {\n if ('code' in resource && resource.code?.text) {\n return resource.code.text;\n }\n }\n if (resource.resourceType === 'User') {\n if (resource.email) {\n return resource.email;\n }\n }\n if ('name' in resource && resource.name && typeof resource.name === 'string') {\n return resource.name;\n }\n return getReferenceString(resource);\n}\n\n/**\n * Returns a display string for a profile resource if one is found.\n * @param resource The profile resource.\n * @returns The display name if one is found.\n */\nfunction getProfileResourceDisplayString(resource: ProfileResource): string | undefined {\n const names = resource.name;\n if (names && names.length > 0) {\n return formatHumanName(names[0]);\n }\n return undefined;\n}\n\n/**\n * Returns a display string for a device resource if one is found.\n * @param device The device resource.\n * @returns The display name if one is found.\n */\nfunction getDeviceDisplayString(device: Device): string | undefined {\n const names = device.deviceName;\n if (names && names.length > 0) {\n return names[0].name;\n }\n return undefined;\n}\n\n/**\n * Returns an image URL for the resource, if one is available.\n * @param resource The input resource.\n * @returns The image URL for the resource or undefined.\n */\nexport function getImageSrc(resource: Resource): string | undefined {\n if (!('photo' in resource)) {\n return undefined;\n }\n\n const photo = resource.photo;\n if (!photo) {\n return undefined;\n }\n\n if (Array.isArray(photo)) {\n for (const p of photo) {\n const url = getPhotoImageSrc(p);\n if (url) {\n return url;\n }\n }\n } else {\n return getPhotoImageSrc(photo);\n }\n\n return undefined;\n}\n\nfunction getPhotoImageSrc(photo: Attachment): string | undefined {\n if (photo.url && photo.contentType && photo.contentType.startsWith('image/')) {\n return photo.url;\n }\n return undefined;\n}\n\n/**\n * Returns a Date property as a Date.\n * When working with JSON objects, Dates are often serialized as ISO-8601 strings.\n * When that happens, we need to safely convert to a proper Date object.\n * @param date The date property value, which could be a string or a Date object.\n * @returns A Date object.\n */\nexport function getDateProperty(date: string | undefined): Date | undefined {\n return date ? new Date(date) : undefined;\n}\n\n/**\n * Calculates the age in years from the birth date.\n * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.\n * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.\n * @returns The age in years, months, and days.\n */\nexport function calculateAge(\n birthDateStr: string,\n endDateStr?: string\n): { years: number; months: number; days: number } {\n const startDate = new Date(birthDateStr);\n startDate.setUTCHours(0, 0, 0, 0);\n\n const endDate = endDateStr ? new Date(endDateStr) : new Date();\n endDate.setUTCHours(0, 0, 0, 0);\n\n const startYear = startDate.getUTCFullYear();\n const startMonth = startDate.getUTCMonth();\n const startDay = startDate.getUTCDate();\n\n const endYear = endDate.getUTCFullYear();\n const endMonth = endDate.getUTCMonth();\n const endDay = endDate.getUTCDate();\n\n let years = endYear - startYear;\n if (endMonth < startMonth || (endMonth === startMonth && endDay < startDay)) {\n years--;\n }\n\n let months = endYear * 12 + endMonth - (startYear * 12 + startMonth);\n if (endDay < startDay) {\n months--;\n }\n\n const days = Math.floor((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));\n\n return { years, months, days };\n}\n\n/**\n * Calculates the age string for display using the age appropriate units.\n * If the age is greater than or equal to 2 years, then the age is displayed in years.\n * If the age is greater than or equal to 1 month, then the age is displayed in months.\n * Otherwise, the age is displayed in days.\n * @param birthDateStr The birth date or start date in ISO-8601 format YYYY-MM-DD.\n * @param endDateStr Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.\n * @returns The age string.\n */\nexport function calculateAgeString(birthDateStr: string, endDateStr?: string): string | undefined {\n const { years, months, days } = calculateAge(birthDateStr, endDateStr);\n if (years >= 2) {\n return years.toString().padStart(3, '0') + 'Y';\n } else if (months >= 1) {\n return months.toString().padStart(3, '0') + 'M';\n } else {\n return days.toString().padStart(3, '0') + 'D';\n }\n}\n\n/**\n * Returns all questionnaire answers as a map by link ID.\n * @param response The questionnaire response resource.\n * @returns Questionnaire answers mapped by link ID.\n */\nexport function getQuestionnaireAnswers(\n response: QuestionnaireResponse\n): Record<string, QuestionnaireResponseItemAnswer> {\n const result: Record<string, QuestionnaireResponseItemAnswer> = {};\n buildQuestionnaireAnswerItems(response.item, result);\n return result;\n}\n\n/**\n * Recursively builds the questionnaire answer items map.\n * @param item The current questionnaire response item.\n * @param result The cumulative result map.\n */\nfunction buildQuestionnaireAnswerItems(\n items: QuestionnaireResponseItem[] | undefined,\n result: Record<string, QuestionnaireResponseItemAnswer>\n): void {\n if (items) {\n for (const item of items) {\n if (item.linkId && item.answer && item.answer.length > 0) {\n result[item.linkId] = item.answer[0];\n }\n buildQuestionnaireAnswerItems(item.item, result);\n }\n }\n}\n\n/**\n * Returns the resource identifier for the given system.\n *\n * If multiple identifiers exist with the same system, the first one is returned.\n *\n * If the system is not found, then returns undefined.\n *\n * @param resource The resource to check.\n * @param system The identifier system.\n * @returns The identifier value if found; otherwise undefined.\n */\nexport function getIdentifier(resource: Resource, system: string): string | undefined {\n const identifiers = (resource as any).identifier as Identifier[] | Identifier | undefined;\n if (!identifiers) {\n return undefined;\n }\n const array = Array.isArray(identifiers) ? identifiers : [identifiers];\n for (const identifier of array) {\n if (identifier.system === system) {\n return identifier.value;\n }\n }\n return undefined;\n}\n\n/**\n * Returns an extension value by extension URLs.\n * @param resource The base resource.\n * @param urls Array of extension URLs. Each entry represents a nested extension.\n * @returns The extension value if found; undefined otherwise.\n */\nexport function getExtensionValue(resource: any, ...urls: string[]): string | undefined {\n // Let curr be the current resource or extension. Extensions can be nested.\n let curr: any = resource;\n\n // For each of the urls, try to find a matching nested extension.\n for (let i = 0; i < urls.length && curr; i++) {\n curr = (curr?.extension as Extension[] | undefined)?.find((e) => e.url === urls[i]);\n }\n\n return curr?.valueString as string | undefined;\n}\n\n/**\n * Returns an extension by extension URLs.\n * @param resource The base resource.\n * @param urls Array of extension URLs. Each entry represents a nested extension.\n * @returns The extension object if found; undefined otherwise.\n */\nexport function getExtension(resource: any, ...urls: string[]): Extension | undefined {\n // Let curr be the current resource or extension. Extensions can be nested.\n let curr: any = resource;\n\n // For each of the urls, try to find a matching nested extension.\n for (let i = 0; i < urls.length && curr; i++) {\n curr = (curr?.extension as Extension[] | undefined)?.find((e) => e.url === urls[i]);\n }\n\n return curr as Extension | undefined;\n}\n\n/**\n * FHIR JSON stringify.\n * Removes properties with empty string values.\n * Removes objects with zero properties.\n * See: https://www.hl7.org/fhir/json.html\n * @param value The input value.\n * @param pretty Optional flag to pretty-print the JSON.\n * @returns The resulting JSON string.\n */\nexport function stringify(value: any, pretty?: boolean): string {\n return JSON.stringify(value, stringifyReplacer, pretty ? 2 : undefined);\n}\n\n/**\n * Evaluates JSON key/value pairs for FHIR JSON stringify.\n * Removes properties with empty string values.\n * Removes objects with zero properties.\n * @param {string} k Property key.\n * @param {*} v Property value.\n */\nfunction stringifyReplacer(k: string, v: any): any {\n return !isArrayKey(k) && isEmpty(v) ? undefined : v;\n}\n\n/**\n * Returns true if the key is an array key.\n * @param k The property key.\n * @returns True if the key is an array key.\n */\nfunction isArrayKey(k: string): boolean {\n return !!k.match(/\\d+$/);\n}\n\n/**\n * Returns true if the value is empty (null, undefined, empty string, or empty object).\n * @param v Any value.\n * @returns True if the value is an empty string or an empty object.\n */\nexport function isEmpty(v: any): boolean {\n if (v === null || v === undefined) {\n return true;\n }\n const t = typeof v;\n return (t === 'string' && v === '') || (t === 'object' && Object.keys(v).length === 0);\n}\n\n/**\n * Resource equality.\n * Ignores meta.versionId and meta.lastUpdated.\n * @param object1 The first object.\n * @param object2 The second object.\n * @returns True if the objects are equal.\n */\nexport function deepEquals(object1: unknown, object2: unknown, path?: string): boolean {\n if (object1 === object2) {\n return true;\n }\n if (isEmpty(object1) && isEmpty(object2)) {\n return true;\n }\n if (isEmpty(object1) || isEmpty(object2)) {\n return false;\n }\n if (Array.isArray(object1) && Array.isArray(object2)) {\n return deepEqualsArray(object1, object2);\n }\n if (Array.isArray(object1) || Array.isArray(object2)) {\n return false;\n }\n if (isObject(object1) && isObject(object2)) {\n return deepEqualsObject(object1, object2, path);\n }\n if (isObject(object1) || isObject(object2)) {\n return false;\n }\n return false;\n}\n\nfunction deepEqualsArray(array1: unknown[], array2: unknown[]): boolean {\n if (array1.length !== array2.length) {\n return false;\n }\n for (let i = 0; i < array1.length; i++) {\n if (!deepEquals(array1[i], array2[i])) {\n return false;\n }\n }\n return true;\n}\n\nfunction deepEqualsObject(\n object1: Record<string, unknown>,\n object2: Record<string, unknown>,\n path: string | undefined\n): boolean {\n const keySet = new Set<string>();\n Object.keys(object1).forEach((k) => keySet.add(k));\n Object.keys(object2).forEach((k) => keySet.add(k));\n if (path === 'meta') {\n keySet.delete('versionId');\n keySet.delete('lastUpdated');\n keySet.delete('author');\n }\n for (const key of keySet) {\n const val1 = object1[key];\n const val2 = object2[key];\n if (!deepEquals(val1, val2, key)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Creates a deep clone of the input value.\n *\n * Limitations:\n * - Only supports JSON primitives and arrays.\n * - Does not support Functions, lambdas, etc.\n * - Does not support circular references.\n *\n * See: https://web.dev/structured-clone/\n * See: https://stackoverflow.com/questions/40488190/how-is-structured-clone-algorithm-different-from-deep-copy\n *\n * @param input The input to clone.\n * @returns A deep clone of the input.\n */\nexport function deepClone<T>(input: T): T {\n return JSON.parse(JSON.stringify(input)) as T;\n}\n\n/**\n * Returns true if the input string is a UUID.\n * @param input The input string.\n * @returns True if the input string matches the UUID format.\n */\nexport function isUUID(input: string): boolean {\n return !!input.match(/^\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$/i);\n}\n\n/**\n * Returns true if the input is an object.\n * @param object The candidate object.\n * @returns True if the input is a non-null non-undefined object.\n */\nexport function isObject(obj: unknown): obj is Record<string, unknown> {\n return obj !== null && typeof obj === 'object';\n}\n\n/**\n * Returns true if the input array is an array of strings.\n * @param arr Input array.\n * @returns True if the input array is an array of strings.\n */\nexport function isStringArray(arr: any[]): arr is string[] {\n return arr.every((e) => typeof e === 'string');\n}\n\n// Precompute hex octets\n// See: https://stackoverflow.com/a/55200387\nconst byteToHex: string[] = [];\nfor (let n = 0; n < 256; n++) {\n byteToHex.push(n.toString(16).padStart(2, '0'));\n}\n\n/**\n * Converts an ArrayBuffer to hex string.\n * See: https://stackoverflow.com/a/55200387\n * @param arrayBuffer The input array buffer.\n * @returns The resulting hex string.\n */\nexport function arrayBufferToHex(arrayBuffer: ArrayBuffer): string {\n const bytes = new Uint8Array(arrayBuffer);\n const result: string[] = new Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n result[i] = byteToHex[bytes[i]];\n }\n return result.join('');\n}\n\n/**\n * Converts an ArrayBuffer to a base-64 encoded string.\n * @param arrayBuffer The input array buffer.\n * @returns The base-64 encoded string.\n */\nexport function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string {\n const bytes = new Uint8Array(arrayBuffer);\n const result: string[] = [];\n for (let i = 0; i < bytes.length; i++) {\n result[i] = String.fromCharCode(bytes[i]);\n }\n return window.btoa(result.join(''));\n}\n\nexport function capitalize(word: string): string {\n return word.charAt(0).toUpperCase() + word.substring(1);\n}\n\nexport function isLowerCase(c: string): boolean {\n return c === c.toLowerCase() && c !== c.toUpperCase();\n}\n\n/**\n * Tries to find a code string for a given system within a given codeable concept.\n * @param concept The codeable concept.\n * @param system The system string.\n * @returns The code if found; otherwise undefined.\n */\nexport function getCodeBySystem(concept: CodeableConcept, system: string): string | undefined {\n return concept?.coding?.find((coding) => coding.system === system)?.code;\n}\n\n/**\n * Sets a code for a given system within a given codeable concept.\n * @param concept The codeable concept.\n * @param system The system string.\n * @param code The code value.\n */\nexport function setCodeBySystem(concept: CodeableConcept, system: string, code: string): void {\n if (!concept.coding) {\n concept.coding = [];\n }\n const coding = concept.coding?.find((c) => c.system === system);\n if (coding) {\n coding.code = code;\n } else {\n concept.coding?.push({ system, code });\n }\n}\n\n/**\n * Tries to find an observation interval for the given patient and value.\n * @param definition The observation definition.\n * @param patient The patient.\n * @param value The observation value.\n * @returns The observation interval if found; otherwise undefined.\n */\nexport function findObservationInterval(\n definition: ObservationDefinition,\n patient: Patient,\n value: number,\n category?: 'reference' | 'critical' | 'absolute'\n): ObservationDefinitionQualifiedInterval | undefined {\n return definition.qualifiedInterval?.find(\n (interval) =>\n observationIntervalMatchesPatient(interval, patient) &&\n observationIntervalMatchesValue(interval, value, definition.quantitativeDetails?.decimalPrecision) &&\n (category === undefined || interval.category === category)\n );\n}\n\n/**\n * Tries to find an observation reference range for the given patient and condition names.\n * @param definition The observation definition.\n * @param patient The patient.\n * @param names The condition names.\n * @returns The observation interval if found; otherwise undefined.\n */\nexport function findObservationReferenceRange(\n definition: ObservationDefinition,\n patient: Patient,\n names: string[]\n): ObservationDefinitionQualifiedInterval | undefined {\n return definition.qualifiedInterval?.find(\n (interval) => observationIntervalMatchesPatient(interval, patient) && names.includes(interval.condition as string)\n );\n}\n\n/**\n * Returns true if the patient matches the observation interval.\n * @param interval The observation interval.\n * @param patient The patient.\n * @returns True if the patient matches the observation interval.\n */\nfunction observationIntervalMatchesPatient(\n interval: ObservationDefinitionQualifiedInterval,\n patient: Patient\n): boolean {\n return observationIntervalMatchesGender(interval, patient) && observationIntervalMatchesAge(interval, patient);\n}\n\n/**\n * Returns true if the patient gender matches the observation interval.\n * @param interval The observation interval.\n * @param patient The patient.\n * @returns True if the patient gender matches the observation interval.\n */\nfunction observationIntervalMatchesGender(interval: ObservationDefinitionQualifiedInterval, patient: Patient): boolean {\n return !interval.gender || interval.gender === patient.gender;\n}\n\n/**\n * Returns true if the patient age matches the observation interval.\n * @param interval The observation interval.\n * @param patient The patient.\n * @returns True if the patient age matches the observation interval.\n */\nfunction observationIntervalMatchesAge(interval: ObservationDefinitionQualifiedInterval, patient: Patient): boolean {\n return !interval.age || matchesRange(calculateAge(patient.birthDate as string).years, interval.age);\n}\n\n/**\n * Returns true if the value matches the observation interval.\n * @param interval The observation interval.\n * @param value The observation value.\n * @param precision Optional precision in number of digits.\n * @returns True if the value matches the observation interval.\n */\nfunction observationIntervalMatchesValue(\n interval: ObservationDefinitionQualifiedInterval,\n value: number,\n precision?: number\n): boolean {\n return !!interval.range && matchesRange(value, interval.range, precision);\n}\n\n/**\n * Returns true if the value is in the range accounting for precision.\n * @param value The numeric value.\n * @param range The numeric range.\n * @param precision Optional precision in number of digits.\n * @returns True if the value is within the range.\n */\nexport function matchesRange(value: number, range: Range, precision?: number): boolean {\n return (\n (range.low?.value === undefined || preciseGreaterThanOrEquals(value, range.low.value, precision)) &&\n (range.high?.value === undefined || preciseLessThanOrEquals(value, range.high.value, precision))\n );\n}\n\n/**\n * Returns the input number rounded to the specified number of digits.\n * @param a The input number.\n * @param precision The precision in number of digits.\n * @returns The number rounded to the specified number of digits.\n */\nexport function preciseRound(a: number, precision: number): number {\n return parseFloat(a.toFixed(precision));\n}\n\n/**\n * Returns true if the two numbers are equal to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the two numbers are equal to the given precision.\n */\nexport function preciseEquals(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) === toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is less than the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is less than the second number to the given precision.\n */\nexport function preciseLessThan(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) < toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is greater than the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is greater than the second number to the given precision.\n */\nexport function preciseGreaterThan(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) > toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is less than or equal to the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is less than or equal to the second number to the given precision.\n */\nexport function preciseLessThanOrEquals(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) <= toPreciseInteger(b, precision);\n}\n\n/**\n * Returns true if the first number is greater than or equal to the second number to the given precision.\n * @param a The first number.\n * @param b The second number.\n * @param precision Optional precision in number of digits.\n * @returns True if the first number is greater than or equal to the second number to the given precision.\n */\nexport function preciseGreaterThanOrEquals(a: number, b: number, precision?: number): boolean {\n return toPreciseInteger(a, precision) >= toPreciseInteger(b, precision);\n}\n\n/**\n * Returns an integer representation of the number with the given precision.\n * For example, if precision is 2, then 1.2345 will be returned as 123.\n * @param a The number.\n * @param precision Optional precision in number of digits.\n * @returns The integer with the given precision.\n */\nfunction toPreciseInteger(a: number, precision?: number): number {\n if (precision === undefined) {\n return a;\n }\n return Math.round(a * Math.pow(10, precision));\n}\n","import { arrayBufferToHex } from './utils';\n\n/**\n * Returns a cryptographically secure random string.\n */\nexport function getRandomString(): string {\n const randomItems = new Uint32Array(28);\n crypto.getRandomValues(randomItems);\n return arrayBufferToHex(randomItems.buffer);\n}\n\n/**\n * Encrypts a string with SHA256 encryption.\n * @param str\n */\nexport async function encryptSHA256(str: string): Promise<ArrayBuffer> {\n return crypto.subtle.digest('SHA-256', new TextEncoder().encode(str));\n}\n","/*\n * Based on: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget\n */\n\ninterface Event {\n readonly type: string;\n readonly defaultPrevented?: boolean;\n}\n\ntype EventListener = (e: Event) => void;\n\nexport class EventTarget {\n readonly #listeners: Record<string, EventListener[]>;\n\n constructor() {\n this.#listeners = {};\n }\n\n addEventListener(type: string, callback: EventListener): void {\n if (!this.#listeners[type]) {\n this.#listeners[type] = [];\n }\n this.#listeners[type].push(callback);\n }\n\n removeEventListeneer(type: string, callback: EventListener): void {\n const array = this.#listeners[type];\n if (!array) {\n return;\n }\n for (let i = 0; i < array.length; i++) {\n if (array[i] === callback) {\n array.splice(i, 1);\n return;\n }\n }\n }\n\n dispatchEvent(event: Event): boolean {\n const array = this.#listeners[event.type];\n if (array) {\n array.forEach((listener) => listener.call(this, event));\n }\n return !event.defaultPrevented;\n }\n}\n","/**\n * Decodes a section of a JWT.\n * See: https://tools.ietf.org/html/rfc7519\n * @param payload\n */\nfunction decodePayload(payload: string): Record<string, number | string> {\n const cleanedPayload = payload.replace(/-/g, '+').replace(/_/g, '/');\n const decodedPayload = decodeBase64(cleanedPayload);\n const uriEncodedPayload = Array.from(decodedPayload).reduce((acc, char) => {\n const uriEncodedChar = ('00' + char.charCodeAt(0).toString(16)).slice(-2);\n return `${acc}%${uriEncodedChar}`;\n }, '');\n const jsonPayload = decodeURIComponent(uriEncodedPayload);\n return JSON.parse(jsonPayload);\n}\n\nfunction decodeBase64(data: string): string {\n if (typeof window !== 'undefined') {\n return window.atob(data);\n }\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(data, 'base64').toString('binary');\n }\n throw new Error('Unable to decode base64');\n}\n\n/**\n * Parses the JWT payload.\n * @param token JWT token\n */\nexport function parseJWTPayload(token: string): Record<string, number | string> {\n const [_header, payload, _signature] = token.split('.');\n return decodePayload(payload);\n}\n","import { OperationOutcome } from '@medplum/fhirtypes';\n\nconst OK_ID = 'ok';\nconst CREATED_ID = 'created';\nconst GONE_ID = 'gone';\nconst NOT_MODIFIED_ID = 'not-modified';\nconst NOT_FOUND_ID = 'not-found';\nconst UNAUTHORIZED_ID = 'unauthorized';\nconst FORBIDDEN_ID = 'forbidden';\nconst TOO_MANY_REQUESTS_ID = 'too-many-requests';\n\nexport const allOk: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: OK_ID,\n issue: [\n {\n severity: 'information',\n code: 'informational',\n details: {\n text: 'All OK',\n },\n },\n ],\n};\n\nexport const created: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: CREATED_ID,\n issue: [\n {\n severity: 'information',\n code: 'informational',\n details: {\n text: 'Created',\n },\n },\n ],\n};\n\nexport const notModified: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: NOT_MODIFIED_ID,\n issue: [\n {\n severity: 'information',\n code: 'informational',\n details: {\n text: 'Not Modified',\n },\n },\n ],\n};\n\nexport const notFound: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: NOT_FOUND_ID,\n issue: [\n {\n severity: 'error',\n code: 'not-found',\n details: {\n text: 'Not found',\n },\n },\n ],\n};\n\nexport const unauthorized: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: UNAUTHORIZED_ID,\n issue: [\n {\n severity: 'error',\n code: 'login',\n details: {\n text: 'Unauthorized',\n },\n },\n ],\n};\n\nexport const forbidden: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: FORBIDDEN_ID,\n issue: [\n {\n severity: 'error',\n code: 'forbidden',\n details: {\n text: 'Forbidden',\n },\n },\n ],\n};\n\nexport const gone: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: GONE_ID,\n issue: [\n {\n severity: 'error',\n code: 'deleted',\n details: {\n text: 'Gone',\n },\n },\n ],\n};\n\nexport const tooManyRequests: OperationOutcome = {\n resourceType: 'OperationOutcome',\n id: TOO_MANY_REQUESTS_ID,\n issue: [\n {\n severity: 'error',\n code: 'throttled',\n details: {\n text: 'Too Many Requests',\n },\n },\n ],\n};\n\nexport function badRequest(details: string, expression?: string): OperationOutcome {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n severity: 'error',\n code: 'invalid',\n details: {\n text: details,\n },\n expression: expression ? [expression] : undefined,\n },\n ],\n };\n}\n\nexport function isOperationOutcome(value: unknown): value is OperationOutcome {\n return typeof value === 'object' && value !== null && (value as any).resourceType === 'OperationOutcome';\n}\n\nexport function isOk(outcome: OperationOutcome): boolean {\n return outcome.id === OK_ID || outcome.id === CREATED_ID || outcome.id === NOT_MODIFIED_ID;\n}\n\nexport function isNotFound(outcome: OperationOutcome): boolean {\n return outcome.id === NOT_FOUND_ID;\n}\n\nexport function isGone(outcome: OperationOutcome): boolean {\n return outcome.id === GONE_ID;\n}\n\nexport function getStatus(outcome: OperationOutcome): number {\n if (outcome.id === OK_ID) {\n return 200;\n } else if (outcome.id === CREATED_ID) {\n return 201;\n } else if (outcome.id === NOT_MODIFIED_ID) {\n return 304;\n } else if (outcome.id === UNAUTHORIZED_ID) {\n return 401;\n } else if (outcome.id === FORBIDDEN_ID) {\n return 403;\n } else if (outcome.id === NOT_FOUND_ID) {\n return 404;\n } else if (outcome.id === GONE_ID) {\n return 410;\n } else if (outcome.id === TOO_MANY_REQUESTS_ID) {\n return 429;\n } else {\n return 400;\n }\n}\n\n/**\n * Asserts that the operation completed successfully and that the resource is defined.\n * @param outcome The operation outcome.\n * @param resource The resource that may or may not have been returned.\n */\nexport function assertOk<T>(outcome: OperationOutcome, resource: T | undefined): asserts resource is T {\n if (!isOk(outcome) || resource === undefined) {\n throw new OperationOutcomeError(outcome);\n }\n}\n\nexport class OperationOutcomeError extends Error {\n readonly outcome: OperationOutcome;\n\n constructor(outcome: OperationOutcome, cause?: unknown) {\n super(outcome?.issue?.[0].details?.text);\n this.outcome = outcome;\n this.cause = cause;\n }\n}\n\n/**\n * Normalizes an error object into an OperationOutcome.\n * @param error The error value which could be a string, Error, OperationOutcome, or other unknown type.\n * @returns The normalized OperationOutcome.\n */\nexport function normalizeOperationOutcome(error: unknown): OperationOutcome {\n if (error instanceof OperationOutcomeError) {\n return error.outcome;\n }\n if (isOperationOutcome(error)) {\n return error;\n }\n return badRequest(normalizeErrorString(error));\n}\n\n/**\n * Normalizes an error object into a displayable error string.\n * @param error The error value which could be a string, Error, OperationOutcome, or other unknown type.\n * @returns A display string for the error.\n */\nexport function normalizeErrorString(error: unknown): string {\n if (!error) {\n return 'Unknown error';\n }\n if (typeof error === 'string') {\n return error;\n }\n if (error instanceof Error) {\n return error.message;\n }\n if (isOperationOutcome(error)) {\n return error.issue?.[0]?.details?.text ?? 'Unknown error';\n }\n return JSON.stringify(error);\n}\n","/**\n * The ReadablePromise class wraps a request promise suitable for React Suspense.\n * See: https://blog.logrocket.com/react-suspense-data-fetching/#wrappromise-js\n * See: https://github.com/ovieokeh/suspense-data-fetching/blob/master/lib/api/wrapPromise.js\n */\nexport class ReadablePromise<T> implements Promise<T> {\n readonly [Symbol.toStringTag]: string = 'ReadablePromise';\n #suspender: Promise<T>;\n #status: 'pending' | 'error' | 'success' = 'pending';\n #response: T | undefined;\n #error: Error | undefined;\n\n constructor(requestPromise: Promise<T>) {\n this.#suspender = requestPromise.then(\n (res: T) => {\n this.#status = 'success';\n this.#response = res;\n return res;\n },\n (err: any) => {\n this.#status = 'error';\n this.#error = err;\n throw err;\n }\n );\n }\n\n /**\n * Returns true if the promise is pending.\n * @returns True if the Promise is pending.\n */\n isPending(): boolean {\n return this.#status === 'pending';\n }\n\n /**\n * Returns true if the promise resolved successfully.\n * @returns True if the Promise resolved successfully.\n */\n isOk(): boolean {\n return this.#status === 'success';\n }\n\n /**\n * Attempts to read the value of the promise.\n * If the promise is pending, this method will throw a promise.\n * If the promise rejected, this method will throw the rejection reason.\n * If the promise resolved, this method will return the resolved value.\n * @returns The resolved value of the Promise.\n */\n read(): T {\n switch (this.#status) {\n case 'pending':\n throw this.#suspender;\n case 'error':\n throw this.#error;\n default:\n return this.#response as T;\n }\n }\n\n /**\n * Attaches callbacks for the resolution and/or rejection of the Promise.\n * @param onfulfilled The callback to execute when the Promise is resolved.\n * @param onrejected The callback to execute when the Promise is rejected.\n * @returns A Promise for the completion of which ever callback is executed.\n */\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null\n ): Promise<TResult1 | TResult2> {\n return this.#suspender.then(onfulfilled, onrejected);\n }\n\n /**\n * Attaches a callback for only the rejection of the Promise.\n * @param onrejected The callback to execute when the Promise is rejected.\n * @returns A Promise for the completion of the callback.\n */\n catch<TResult = never>(\n onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null\n ): Promise<T | TResult> {\n return this.#suspender.catch(onrejected);\n }\n\n /**\n * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The\n * resolved value cannot be modified from the callback.\n * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).\n * @returns A Promise for the completion of the callback.\n */\n finally(onfinally?: (() => void) | undefined | null): Promise<T> {\n return this.#suspender.finally(onfinally);\n }\n}\n","import { stringify } from './utils';\n\n/**\n * The ClientStorage class is a utility class for storing strings and objects.\n *\n * When using MedplumClient in the browser, it will be backed by browser localStorage.\n *\n * When Using MedplumClient in the server, it will be backed by the MemoryStorage class.\n */\nexport class ClientStorage {\n readonly #storage: Storage;\n\n constructor() {\n this.#storage = typeof localStorage !== 'undefined' ? localStorage : new MemoryStorage();\n }\n\n clear(): void {\n this.#storage.clear();\n }\n\n getString(key: string): string | undefined {\n return this.#storage.getItem(key) || undefined;\n }\n\n setString(key: string, value: string | undefined): void {\n if (value) {\n this.#storage.setItem(key, value);\n } else {\n this.#storage.removeItem(key);\n }\n }\n\n getObject<T>(key: string): T | undefined {\n const str = this.getString(key);\n return str ? (JSON.parse(str) as T) : undefined;\n }\n\n setObject<T>(key: string, value: T): void {\n this.setString(key, value ? stringify(value) : undefined);\n }\n}\n\n/**\n * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.\n */\nexport class MemoryStorage implements Storage {\n #data: Map<string, string>;\n\n constructor() {\n this.#data = new Map<string, string>();\n }\n\n /**\n * Returns the number of key/value pairs.\n */\n get length(): number {\n return this.#data.size;\n }\n\n /**\n * Removes all key/value pairs, if there are any.\n */\n clear(): void {\n this.#data.clear();\n }\n\n /**\n * Returns the current value associated with the given key, or null if the given key does not exist.\n */\n getItem(key: string): string | null {\n return this.#data.get(key) ?? null;\n }\n\n /**\n * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.\n */\n setItem(key: string, value: string | null): void {\n if (value) {\n this.#data.set(key, value);\n } else {\n this.#data.delete(key);\n }\n }\n\n /**\n * Removes the key/value pair with the given key, if a key/value pair with the given key exists.\n */\n removeItem(key: string): void {\n this.#data.delete(key);\n }\n\n /**\n * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.\n */\n key(index: number): string | null {\n return Array.from(this.#data.keys())[index];\n }\n}\n","import {\n Bundle,\n BundleEntry,\n ElementDefinition,\n Resource,\n SearchParameter,\n StructureDefinition,\n} from '@medplum/fhirtypes';\nimport baseSchema from './base-schema.json';\nimport { SearchParameterDetails } from './search/details';\nimport { capitalize } from './utils';\n\nexport interface TypedValue {\n readonly type: string;\n readonly value: any;\n}\n\n/**\n * List of property types.\n * http://www.hl7.org/fhir/valueset-defined-types.html\n * The list here includes additions found from StructureDefinition resources.\n */\nexport enum PropertyType {\n Address = 'Address',\n Age = 'Age',\n Annotation = 'Annotation',\n Attachment = 'Attachment',\n BackboneElement = 'BackboneElement',\n CodeableConcept = 'CodeableConcept',\n Coding = 'Coding',\n ContactDetail = 'ContactDetail',\n ContactPoint = 'ContactPoint',\n Contributor = 'Contributor',\n Count = 'Count',\n DataRequirement = 'DataRequirement',\n Distance = 'Distance',\n Dosage = 'Dosage',\n Duration = 'Duration',\n Expression = 'Expression',\n Extension = 'Extension',\n HumanName = 'HumanName',\n Identifier = 'Identifier',\n MarketingStatus = 'MarketingStatus',\n Meta = 'Meta',\n Money = 'Money',\n Narrative = 'Narrative',\n ParameterDefinition = 'ParameterDefinition',\n Period = 'Period',\n Population = 'Population',\n ProdCharacteristic = 'ProdCharacteristic',\n ProductShelfLife = 'ProductShelfLife',\n Quantity = 'Quantity',\n Range = 'Range',\n Ratio = 'Ratio',\n Reference = 'Reference',\n RelatedArtifact = 'RelatedArtifact',\n SampledData = 'SampledData',\n Signature = 'Signature',\n SubstanceAmount = 'SubstanceAmount',\n SystemString = 'http://hl7.org/fhirpath/System.String',\n Timing = 'Timing',\n TriggerDefinition = 'TriggerDefinition',\n UsageContext = 'UsageContext',\n base64Binary = 'base64Binary',\n boolean = 'boolean',\n canonical = 'canonical',\n code = 'code',\n date = 'date',\n dateTime = 'dateTime',\n decimal = 'decimal',\n id = 'id',\n instant = 'instant',\n integer = 'integer',\n markdown = 'markdown',\n oid = 'oid',\n positiveInt = 'positiveInt',\n string = 'string',\n time = 'time',\n unsignedInt = 'unsignedInt',\n uri = 'uri',\n url = 'url',\n uuid = 'uuid',\n}\n\n/**\n * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.\n *\n * StructureDefinition resources contain schema information for other resource types.\n * These schemas can be used to automatically generate user interface elements for\n * resources.\n *\n * However, a StructureDefinition resource is not optimized for realtime lookups. All\n * resource types, sub types, and property definitions are stored in a flat array of\n * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., \"Patient.name\")\n * requires a linear scan of all ElementDefinition objects\n *\n * A StructureDefinition resource contains information about one or more types.\n * For example, the \"Patient\" StructureDefinition includes \"Patient\", \"Patient_Contact\",\n * \"Patient_Communication\", and \"Patient_Link\". This is inefficient.\n *\n * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.\n * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.\n *\n * The hierarchy is:\n * IndexedStructureDefinition - top level for one resource type\n * TypeSchema - one per resource type and all contained BackboneElements\n * PropertySchema - one per property/field\n */\nexport interface IndexedStructureDefinition {\n types: { [resourceType: string]: TypeSchema };\n}\n\n/**\n * An indexed TypeSchema.\n *\n * Example: The IndexedStructureDefinition for \"Patient\" would include the following TypeSchemas:\n * 1) Patient\n * 2) Patient_Contact\n * 3) Patient_Communication\n * 4) Patient_Link\n */\nexport interface TypeSchema {\n structureDefinition: StructureDefinition;\n elementDefinition: ElementDefinition;\n display: string;\n properties: { [name: string]: ElementDefinition };\n searchParams?: { [code: string]: SearchParameter };\n searchParamsDetails?: { [code: string]: SearchParameterDetails };\n description?: string;\n parentType?: string;\n}\n\n/**\n * Indexes a bundle of StructureDefinitions for faster lookup.\n * @param bundle A FHIR bundle StructureDefinition resources.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexStructureDefinitionBundle(bundle: Bundle): void {\n for (const entry of bundle.entry as BundleEntry[]) {\n const resource = entry.resource as Resource;\n if (resource.resourceType === 'StructureDefinition') {\n indexStructureDefinition(resource);\n }\n }\n}\n\n/**\n * Indexes a StructureDefinition for fast lookup.\n * @param structureDefinition The original StructureDefinition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexStructureDefinition(structureDefinition: StructureDefinition): void {\n const typeName = structureDefinition.name;\n if (!typeName) {\n return;\n }\n\n const elements = structureDefinition.snapshot?.element;\n if (elements) {\n // First pass, build types\n elements.forEach((element) => indexType(structureDefinition, element));\n\n // Second pass, build properties\n elements.forEach((element) => indexProperty(element));\n }\n}\n\n/**\n * Indexes TypeSchema from an ElementDefinition.\n * In the common case, there will be many ElementDefinition instances per TypeSchema.\n * Only the first occurrence is saved.\n * @param structureDefinition The parent type structure definition.\n * @param elementDefinition The element definition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nfunction indexType(structureDefinition: StructureDefinition, elementDefinition: ElementDefinition): void {\n const path = elementDefinition.path as string;\n const typeCode = elementDefinition.type?.[0]?.code;\n if (typeCode !== undefined && typeCode !== 'Element' && typeCode !== 'BackboneElement') {\n return;\n }\n const parts = path.split('.');\n const typeName = buildTypeName(parts);\n let typeSchema = globalSchema.types[typeName];\n\n if (!typeSchema) {\n globalSchema.types[typeName] = typeSchema = {} as TypeSchema;\n }\n\n typeSchema.parentType = typeSchema.parentType || buildTypeName(parts.slice(0, parts.length - 1));\n typeSchema.display = typeSchema.display || typeName;\n typeSchema.structureDefinition = typeSchema.structureDefinition || structureDefinition;\n typeSchema.elementDefinition = typeSchema.elementDefinition || elementDefinition;\n typeSchema.description = typeSchema.description || elementDefinition.definition;\n typeSchema.properties = typeSchema.properties || {};\n}\n\n/**\n * Indexes PropertySchema from an ElementDefinition.\n * @param element The input ElementDefinition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nfunction indexProperty(element: ElementDefinition): void {\n const path = element.path as string;\n const parts = path.split('.');\n if (parts.length === 1) {\n return;\n }\n const typeName = buildTypeName(parts.slice(0, parts.length - 1));\n const typeSchema = globalSchema.types[typeName];\n if (!typeSchema) {\n return;\n }\n const key = parts[parts.length - 1];\n typeSchema.properties[key] = element;\n}\n\n/**\n * Indexes a bundle of SearchParameter resources for faster lookup.\n * @param bundle A FHIR bundle SearchParameter resources.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexSearchParameterBundle(bundle: Bundle<SearchParameter>): void {\n for (const entry of bundle.entry as BundleEntry[]) {\n const resource = entry.resource as SearchParameter;\n if (resource.resourceType === 'SearchParameter') {\n indexSearchParameter(resource);\n }\n }\n}\n\n/**\n * Indexes a SearchParameter resource for fast lookup.\n * Indexes by SearchParameter.code, which is the query string parameter name.\n * @param searchParam The SearchParameter resource.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexSearchParameter(searchParam: SearchParameter): void {\n if (!searchParam.base) {\n return;\n }\n\n for (const resourceType of searchParam.base) {\n const typeSchema = globalSchema.types[resourceType];\n if (!typeSchema) {\n continue;\n }\n\n if (!typeSchema.searchParams) {\n typeSchema.searchParams = {\n _id: {\n base: [resourceType],\n code: '_id',\n type: 'token',\n expression: resourceType + '.id',\n } as SearchParameter,\n _lastUpdated: {\n base: [resourceType],\n code: '_lastUpdated',\n type: 'date',\n expression: resourceType + '.meta.lastUpdated',\n } as SearchParameter,\n _compartment: {\n base: [resourceType],\n code: '_compartment',\n type: 'reference',\n expression: resourceType + '.meta.compartment',\n } as SearchParameter,\n _profile: {\n base: [resourceType],\n code: '_profile',\n type: 'uri',\n expression: resourceType + '.meta.profile',\n } as SearchParameter,\n _security: {\n base: [resourceType],\n code: '_security',\n type: 'token',\n expression: resourceType + '.meta.security',\n } as SearchParameter,\n _source: {\n base: [resourceType],\n code: '_source',\n type: 'uri',\n expression: resourceType + '.meta.source',\n } as SearchParameter,\n _tag: {\n base: [resourceType],\n code: '_tag',\n type: 'token',\n expression: resourceType + '.meta.tag',\n } as SearchParameter,\n };\n }\n\n typeSchema.searchParams[searchParam.code as string] = searchParam;\n }\n}\n\n/**\n * Returns the type name for an ElementDefinition.\n * @param elementDefinition The element definition.\n * @returns The Medplum type name.\n */\nexport function getElementDefinitionTypeName(elementDefinition: ElementDefinition): string {\n const code = elementDefinition.type?.[0]?.code as string;\n return code === 'BackboneElement' || code === 'Element'\n ? buildTypeName(elementDefinition.path?.split('.') as string[])\n : code;\n}\n\nexport function buildTypeName(components: string[]): string {\n if (components.length === 1) {\n return components[0];\n }\n return components.map(capitalize).join('');\n}\n\n/**\n * Returns true if the type schema is a DomainResource.\n * @param typeSchema The type schema to check.\n * @returns True if the type schema is a DomainResource.\n */\nexport function isResourceType(typeSchema: TypeSchema): boolean {\n return typeSchema.structureDefinition?.baseDefinition === 'http://hl7.org/fhir/StructureDefinition/DomainResource';\n}\n\n/**\n * Returns an array of all resource types.\n * Note that this is based on globalSchema, and will only return resource types that are currently in memory.\n * @returns An array of all resource types.\n */\nexport function getResourceTypes(): string[] {\n const result: string[] = [];\n for (const [resourceType, typeSchema] of Object.entries(globalSchema.types)) {\n if (isResourceType(typeSchema)) {\n result.push(resourceType);\n }\n }\n return result;\n}\n\n/**\n * Returns the type schema for the resource type.\n * @param resourceType The resource type.\n * @returns The type schema for the resource type.\n */\nexport function getResourceTypeSchema(resourceType: string): TypeSchema {\n return globalSchema.types[resourceType];\n}\n\n/**\n * Returns the search parameters for the resource type indexed by search code.\n * @param resourceType The resource type.\n * @returns The search parameters for the resource type indexed by search code.\n */\nexport function getSearchParameters(resourceType: string): Record<string, SearchParameter> | undefined {\n return globalSchema.types[resourceType].searchParams;\n}\n\n/**\n * Returns a human friendly display name for a FHIR element definition path.\n * @param path The FHIR element definition path.\n * @returns The best guess of the display name.\n */\nexport function getPropertyDisplayName(path: string): string {\n // Get the property name, which is the remainder after the last period\n // For example, for path \"Patient.birthDate\"\n // the property name is \"birthDate\"\n const propertyName = path.replaceAll('[x]', '').split('.').pop() as string;\n\n // Split by capital letters\n // Capitalize the first letter of each word\n // Join together with spaces in between\n // Then normalize whitespace to single space character\n // For example, for property name \"birthDate\",\n // the display name is \"Birth Date\".\n return propertyName\n .split(/(?=[A-Z])/)\n .map(capitalizeDisplayWord)\n .join(' ')\n .replace('_', ' ')\n .replace(/\\s+/g, ' ');\n}\n\nconst capitalizedWords = new Set(['ID', 'PKCE', 'JWKS', 'URI', 'URL']);\n\nfunction capitalizeDisplayWord(word: string): string {\n const upper = word.toUpperCase();\n if (capitalizedWords.has(upper)) {\n return upper;\n }\n return upper.charAt(0) + word.slice(1);\n}\n\n/**\n * Returns an element definition by type and property name.\n * Handles content references.\n * @param typeName The type name.\n * @param propertyName The property name.\n * @returns The element definition if found.\n */\nexport function getElementDefinition(typeName: string, propertyName: string): ElementDefinition | undefined {\n const typeSchema = globalSchema.types[typeName];\n if (!typeSchema) {\n return undefined;\n }\n\n const property = typeSchema.properties[propertyName] ?? typeSchema.properties[propertyName + '[x]'];\n if (!property) {\n return undefined;\n }\n\n if (property.contentReference) {\n // Content references start with a \"#\"\n // Remove the \"#\" character\n const contentReference = property.contentReference.substring(1).split('.');\n const referencePropertyName = contentReference.pop() as string;\n const referenceTypeName = buildTypeName(contentReference);\n return getElementDefinition(referenceTypeName, referencePropertyName);\n }\n\n return property;\n}\n\n/**\n * Global schema singleton.\n */\nexport const globalSchema = baseSchema as unknown as IndexedStructureDefinition;\n","// PKCE auth based on:\n// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/\n\nimport {\n Binary,\n Bundle,\n BundleEntry,\n Communication,\n Device,\n Encounter,\n ExtractResource,\n OperationOutcome,\n Patient,\n Project,\n ProjectMembership,\n ProjectSecret,\n Reference,\n Resource,\n ResourceType,\n SearchParameter,\n StructureDefinition,\n UserConfiguration,\n ValueSet,\n} from '@medplum/fhirtypes';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n/** @ts-ignore */\nimport type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';\nimport { LRUCache } from './cache';\nimport { encryptSHA256, getRandomString } from './crypto';\nimport { EventTarget } from './eventtarget';\nimport { Hl7Message } from './hl7';\nimport { parseJWTPayload } from './jwt';\nimport { isOk, normalizeOperationOutcome, OperationOutcomeError } from './outcomes';\nimport { ReadablePromise } from './readablepromise';\nimport { ClientStorage } from './storage';\nimport { globalSchema, IndexedStructureDefinition, indexSearchParameter, indexStructureDefinition } from './types';\nimport { arrayBufferToBase64, createReference, ProfileResource } from './utils';\n\nexport const MEDPLUM_VERSION = process.env.MEDPLUM_VERSION;\n\nconst DEFAULT_BASE_URL = 'https://api.medplum.com/';\nconst DEFAULT_RESOURCE_CACHE_SIZE = 1000;\nconst DEFAULT_CACHE_TIME = 60000; // 60 seconds\nconst JSON_CONTENT_TYPE = 'application/json';\nconst FHIR_CONTENT_TYPE = 'application/fhir+json';\nconst PATCH_CONTENT_TYPE = 'application/json-patch+json';\n\nconst system: Device = { resourceType: 'Device', id: 'system', deviceName: [{ name: 'System' }] };\n\n/**\n * The MedplumClientOptions interface defines configuration options for MedplumClient.\n *\n * All configuration settings are optional.\n */\nexport interface MedplumClientOptions {\n /**\n * Base server URL.\n *\n * Default value is https://api.medplum.com/\n *\n * Use this to point to a custom Medplum deployment.\n */\n baseUrl?: string;\n\n /**\n * OAuth2 authorize URL.\n *\n * Default value is baseUrl + \"/oauth2/authorize\".\n *\n * Use this if you want to use a separate OAuth server.\n */\n authorizeUrl?: string;\n\n /**\n * OAuth2 token URL.\n *\n * Default value is baseUrl + \"/oauth2/token\".\n *\n * Use this if you want to use a separate OAuth server.\n */\n tokenUrl?: string;\n\n /**\n * OAuth2 logout URL.\n *\n * Default value is baseUrl + \"/oauth2/logout\".\n *\n * Use this if you want to use a separate OAuth server.\n */\n logoutUrl?: string;\n\n /**\n * The client ID.\n *\n * Client ID can be used for SMART-on-FHIR customization.\n */\n clientId?: string;\n\n /**\n * Number of resources to store in the cache.\n *\n * Default value is 1000.\n *\n * Consider using this for performance of displaying Patient or Practitioner resources.\n */\n resourceCacheSize?: number;\n\n /**\n * The length of time in milliseconds to cache resources.\n *\n * Default value is 10000 (10 seconds).\n *\n * Cache time of zero disables all caching.\n *\n * For any individual request, the cache behavior can be overridden by setting the cache property on request options.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache\n */\n cacheTime?: number;\n\n /**\n * The length of time in milliseconds to delay requests for auto batching.\n *\n * Auto batching attempts to group multiple requests together into a single batch request.\n *\n * Default value is 0, which disables auto batching.\n */\n autoBatchTime?: number;\n\n /**\n * Fetch implementation.\n *\n * Default is window.fetch (if available).\n *\n * For Node.js applications, consider the 'node-fetch' package.\n */\n fetch?: FetchLike;\n\n /**\n * Create PDF implementation.\n *\n * Default is none, and PDF generation is disabled.\n *\n * In browser environments, import the client-side pdfmake library.\n *\n * ```html\n * <script src=\"pdfmake.min.js\"></script>\n * <script>\n * async function createPdf(docDefinition, tableLayouts, fonts) {\n * return new Promise((resolve) => {\n * pdfMake.createPdf(docDefinition, tableLayouts, fonts).getBlob(resolve);\n * });\n * }\n * </script>\n * ```\n *\n * In Node.js applications:\n *\n * ```ts\n * import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';\n * function createPdf(\n * docDefinition: TDocumentDefinitions,\n * tableLayouts?: { [name: string]: CustomTableLayout },\n * fonts?: TFontDictionary\n * ): Promise<Buffer> {\n * return new Promise((resolve, reject) => {\n * const printer = new PdfPrinter(fonts || {});\n * const pdfDoc = printer.createPdfKitDocument(docDefinition, { tableLayouts });\n * const chunks: Uint8Array[] = [];\n * pdfDoc.on('data', (chunk: Uint8Array) => chunks.push(chunk));\n * pdfDoc.on('end', () => resolve(Buffer.concat(chunks)));\n * pdfDoc.on('error', reject);\n * pdfDoc.end();\n * });\n * }\n * ```\n */\n createPdf?: CreatePdfFunction;\n\n /**\n * Callback for when the client is unauthenticated.\n *\n * Default is do nothing.\n *\n * For client side applications, consider redirecting to a sign in page.\n */\n onUnauthenticated?: () => void;\n}\n\nexport interface FetchLike {\n (url: string, options?: any): Promise<any>;\n}\n\nexport interface CreatePdfFunction {\n (\n docDefinition: TDocumentDefinitions,\n tableLayouts?:\n | {\n [name: string]: CustomTableLayout;\n }\n | undefined,\n fonts?: TFontDictionary | undefined\n ): Promise<any>;\n}\n\nexport interface BaseLoginRequest {\n readonly projectId?: string;\n readonly clientId?: string;\n readonly resourceType?: string;\n readonly scope?: string;\n readonly nonce?: string;\n readonly codeChallenge?: string;\n readonly codeChallengeMethod?: string;\n readonly googleClientId?: string;\n readonly launch?: string;\n readonly redirectUri?: string;\n}\n\nexport interface EmailPasswordLoginRequest extends BaseLoginRequest {\n readonly email: string;\n readonly password: string;\n readonly remember?: boolean;\n}\n\nexport interface NewUserRequest {\n readonly firstName: string;\n readonly lastName: string;\n readonly email: string;\n readonly password: string;\n readonly recaptchaToken: string;\n readonly recaptchaSiteKey?: string;\n readonly remember?: boolean;\n readonly projectId?: string;\n}\n\nexport interface NewProjectRequest {\n readonly login: string;\n readonly projectName: string;\n}\n\nexport interface NewPatientRequest {\n readonly login: string;\n readonly projectId: string;\n}\n\nexport interface GoogleCredentialResponse {\n readonly clientId: string;\n readonly credential: string;\n}\n\nexport interface GoogleLoginRequest extends BaseLoginRequest {\n readonly googleClientId: string;\n readonly googleCredential: string;\n readonly createUser?: boolean;\n}\n\nexport interface LoginAuthenticationResponse {\n readonly login: string;\n readonly mfaRequired?: boolean;\n readonly code?: string;\n readonly memberships?: ProjectMembership[];\n}\n\nexport interface LoginProfileResponse {\n readonly login: string;\n readonly scope: string;\n}\n\nexport interface LoginScopeResponse {\n readonly login: string;\n readonly code: string;\n}\n\nexport interface LoginState {\n readonly project: Reference<Project>;\n readonly profile: Reference<ProfileResource>;\n readonly accessToken: string;\n readonly refreshToken: string;\n}\n\nexport interface TokenResponse {\n readonly token_type: string;\n readonly id_token: string;\n readonly access_token: string;\n readonly refresh_token: string;\n readonly expires_in: number;\n readonly project: Reference<Project>;\n readonly profile: Reference<ProfileResource>;\n}\n\nexport interface BotEvent<T = Resource | Hl7Message | string | Record<string, any>> {\n readonly contentType: string;\n readonly input: T;\n readonly secrets: Record<string, ProjectSecret>;\n}\n\n/**\n * JSONPatch patch operation.\n * Compatible with fast-json-patch and rfc6902 Operation.\n */\nexport interface PatchOperation {\n readonly op: 'add' | 'remove' | 'replace' | 'copy' | 'move' | 'test';\n readonly path: string;\n readonly value?: any;\n}\n\n/**\n * Email address definition.\n * Compatible with nodemailer Mail.Address.\n */\nexport interface MailAddress {\n readonly name: string;\n readonly address: string;\n}\n\n/**\n * Email attachment definition.\n * Compatible with nodemailer Mail.Options.\n */\nexport interface MailAttachment {\n /** String, Buffer or a Stream contents for the attachmentent */\n readonly content?: string;\n /** path to a file or an URL (data uris are allowed as well) if you want to stream the file instead of including it (better for larger attachments) */\n readonly path?: string;\n /** filename to be reported as the name of the attached file, use of unicode is allowed. If you do not want to use a filename, set this value as false, otherwise a filename is generated automatically */\n readonly filename?: string | false;\n /** optional content type for the attachment, if not set will be derived from the filename property */\n readonly contentType?: string;\n}\n\n/**\n * Email message definition.\n * Compatible with nodemailer Mail.Options.\n */\nexport interface MailOptions {\n /** The e-mail address of the sender. All e-mail addresses can be plain 'sender@server.com' or formatted 'Sender Name <sender@server.com>' */\n readonly from?: string | MailAddress;\n /** An e-mail address that will appear on the Sender: field */\n readonly sender?: string | MailAddress;\n /** Comma separated list or an array of recipients e-mail addresses that will appear on the To: field */\n readonly to?: string | MailAddress | string[] | MailAddress[];\n /** Comma separated list or an array of recipients e-mail addresses that will appear on the Cc: field */\n readonly cc?: string | MailAddress | string[] | MailAddress[];\n /** Comma separated list or an array of recipients e-mail addresses that will appear on the Bcc: field */\n readonly bcc?: string | MailAddress | string[] | MailAddress[];\n /** An e-mail address that will appear on the Reply-To: field */\n readonly replyTo?: string | MailAddress;\n /** The subject of the e-mail */\n readonly subject?: string;\n /** The plaintext version of the message */\n readonly text?: string;\n /** The HTML version of the message */\n readonly html?: string;\n /** An array of attachment objects */\n readonly attachments?: MailAttachment[];\n}\n\ninterface SchemaGraphQLResponse {\n readonly data: {\n readonly StructureDefinitionList: StructureDefinition[];\n readonly SearchParameterList: SearchParameter[];\n };\n}\n\ninterface RequestCacheEntry {\n readonly requestTime: number;\n readonly value: ReadablePromise<any>;\n}\n\ninterface AutoBatchEntry<T = any> {\n readonly method: string;\n readonly url: string;\n readonly options: RequestInit;\n readonly resolve: (value: T) => void;\n readonly reject: (reason: any) => void;\n}\n\n/**\n * The MedplumClient class provides a client for the Medplum FHIR server.\n *\n * The client can be used in the browser, in a Node.js application, or in a Medplum Bot.\n *\n * The client provides helpful methods for common operations such as:\n * 1) Authenticating\n * 2) Creating resources\n * 2) Reading resources\n * 3) Updating resources\n * 5) Deleting resources\n * 6) Searching\n * 7) Making GraphQL queries\n *\n * Here is a quick example of how to use the client:\n *\n * ```typescript\n * import { MedplumClient } from '@medplum/core';\n * const medplum = new MedplumClient();\n * ```\n *\n * Create a `Patient`:\n *\n * ```typescript\n * const patient = await medplum.createResource({\n * resourceType: 'Patient',\n * name: [{\n * given: ['Alice'],\n * family: 'Smith'\n * }]\n * });\n * ```\n *\n * Read a `Patient` by ID:\n *\n * ```typescript\n * const patient = await medplum.readResource('Patient', '123');\n * console.log(patient.name[0].given[0]);\n * ```\n *\n * Search for a `Patient` by name:\n *\n * ```typescript\n * const bundle = await medplum.search('Patient', 'name=Alice');\n * console.log(bundle.total);\n * ```\n *\n * <head>\n * <meta name=\"algolia:pageRank\" content=\"100\" />\n * </head>\n\n */\nexport class MedplumClient extends EventTarget {\n readonly #fetch: FetchLike;\n readonly #createPdf?: CreatePdfFunction;\n readonly #storage: ClientStorage;\n readonly #requestCache: LRUCache<RequestCacheEntry>;\n readonly #cacheTime: number;\n readonly #baseUrl: string;\n readonly #fhirBaseUrl: string;\n readonly #authorizeUrl: string;\n readonly #tokenUrl: string;\n readonly #logoutUrl: string;\n readonly #onUnauthenticated?: () => void;\n readonly #autoBatchTime: number;\n readonly #autoBatchQueue: AutoBatchEntry[];\n #clientId?: string;\n #clientSecret?: string;\n #autoBatchTimerId?: any;\n #accessToken?: string;\n #refreshToken?: string;\n #refreshPromise?: Promise<any>;\n #profilePromise?: Promise<any>;\n #profile?: ProfileResource;\n #config?: UserConfiguration;\n\n constructor(options?: MedplumClientOptions) {\n super();\n\n if (options?.baseUrl) {\n if (!options.baseUrl.startsWith('http')) {\n throw new Error('Base URL must start with http or https');\n }\n }\n\n this.#fetch = options?.fetch || getDefaultFetch();\n this.#createPdf = options?.createPdf;\n this.#storage = new ClientStorage();\n this.#requestCache = new LRUCache(options?.resourceCacheSize ?? DEFAULT_RESOURCE_CACHE_SIZE);\n this.#cacheTime = options?.cacheTime ?? DEFAULT_CACHE_TIME;\n this.#baseUrl = ensureTrailingSlash(options?.baseUrl) || DEFAULT_BASE_URL;\n this.#fhirBaseUrl = this.#baseUrl + 'fhir/R4/';\n this.#clientId = options?.clientId || '';\n this.#authorizeUrl = options?.authorizeUrl || this.#baseUrl + 'oauth2/authorize';\n this.#tokenUrl = options?.tokenUrl || this.#baseUrl + 'oauth2/token';\n this.#logoutUrl = options?.logoutUrl || this.#baseUrl + 'oauth2/logout';\n this.#onUnauthenticated = options?.onUnauthenticated;\n this.#autoBatchTime = options?.autoBatchTime ?? 0;\n this.#autoBatchQueue = [];\n\n const activeLogin = this.getActiveLogin();\n if (activeLogin) {\n this.#accessToken = activeLogin.accessToken;\n this.#refreshToken = activeLogin.refreshToken;\n this.#refreshProfile().catch(console.log);\n }\n\n this.#setupStorageListener();\n }\n\n /**\n * Returns the current base URL for all API requests.\n * By default, this is set to `https://api.medplum.com/`.\n * This can be overridden by setting the `baseUrl` option when creating the client.\n * @category HTTP\n * @returns The current base URL for all API requests.\n */\n getBaseUrl(): string {\n return this.#baseUrl;\n }\n\n /**\n * Clears all auth state including local storage and session storage.\n * @category Authentication\n */\n clear(): void {\n this.#storage.clear();\n this.clearActiveLogin();\n }\n\n /**\n * Clears the active login from local storage.\n * Does not clear all local storage (such as other logins).\n * @category Authentication\n */\n clearActiveLogin(): void {\n this.#storage.setString('activeLogin', undefined);\n this.#requestCache.clear();\n this.#accessToken = undefined;\n this.#refreshToken = undefined;\n this.#profile = undefined;\n this.#config = undefined;\n this.dispatchEvent({ type: 'change' });\n }\n\n /**\n * Invalidates any cached values or cached requests for the given URL.\n * @category Caching\n * @param url The URL to invalidate.\n */\n invalidateUrl(url: URL | string): void {\n url = url.toString();\n this.#requestCache.delete(url);\n }\n\n /**\n * Invalidates all cached search results or cached requests for the given resourceType.\n * @category Caching\n * @param resourceType The resource type to invalidate.\n */\n invalidateSearches<K extends ResourceType>(resourceType: K): void {\n const url = 'fhir/R4/' + resourceType;\n for (const key of this.#requestCache.keys()) {\n if (key.endsWith(url) || key.includes(url + '?')) {\n this.#requestCache.delete(key);\n }\n }\n }\n\n /**\n * Makes an HTTP GET request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `readResource()`, `search()`, etc.\n *\n * @category HTTP\n * @param url The target URL.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n get<T = any>(url: URL | string, options: RequestInit = {}): ReadablePromise<T> {\n url = url.toString();\n const cached = this.#getCacheEntry(url, options);\n if (cached) {\n return cached.value;\n }\n\n let promise: Promise<T>;\n\n if (url.startsWith(this.#fhirBaseUrl) && this.#autoBatchTime > 0) {\n promise = new Promise<T>((resolve, reject) => {\n this.#autoBatchQueue.push({\n method: 'GET',\n url: (url as string).replace(this.#fhirBaseUrl, ''),\n options,\n resolve,\n reject,\n });\n if (!this.#autoBatchTimerId) {\n this.#autoBatchTimerId = setTimeout(() => this.#executeAutoBatch(), this.#autoBatchTime);\n }\n });\n } else {\n promise = this.#request<T>('GET', url, options);\n }\n\n const readablePromise = new ReadablePromise(promise);\n this.#setCacheEntry(url, readablePromise);\n return readablePromise;\n }\n\n /**\n * Makes an HTTP POST request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `createResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.\n * @param contentType The content type to be included in the \"Content-Type\" header.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n post(url: URL | string, body: any, contentType?: string, options: RequestInit = {}): Promise<any> {\n url = url.toString();\n if (body) {\n this.#setRequestBody(options, body);\n }\n if (contentType) {\n this.#setRequestContentType(options, contentType);\n }\n this.invalidateUrl(url);\n return this.#request('POST', url, options);\n }\n\n /**\n * Makes an HTTP PUT request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `updateResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.\n * @param contentType The content type to be included in the \"Content-Type\" header.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n put(url: URL | string, body: any, contentType?: string, options: RequestInit = {}): Promise<any> {\n url = url.toString();\n if (body) {\n this.#setRequestBody(options, body);\n }\n if (contentType) {\n this.#setRequestContentType(options, contentType);\n }\n this.invalidateUrl(url);\n return this.#request('PUT', url, options);\n }\n\n /**\n * Makes an HTTP PATCH request to the specified URL.\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `patchResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param operations Array of JSONPatch operations.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n patch(url: URL | string, operations: PatchOperation[], options: RequestInit = {}): Promise<any> {\n url = url.toString();\n this.#setRequestBody(options, operations);\n this.#setRequestContentType(options, PATCH_CONTENT_TYPE);\n this.invalidateUrl(url);\n return this.#request('PATCH', url, options);\n }\n\n /**\n * Makes an HTTP DELETE request to the specified URL.\n *\n *\n * This is a lower level method for custom requests.\n * For common operations, we recommend using higher level methods\n * such as `deleteResource()`.\n *\n * @category HTTP\n * @param url The target URL.\n * @param options Optional fetch options.\n * @returns Promise to the response content.\n */\n delete(url: URL | string, options: RequestInit = {}): Promise<any> {\n url = url.toString();\n this.invalidateUrl(url);\n return this.#request('DELETE', url, options);\n }\n\n /**\n * Initiates a new user flow.\n *\n * This method is part of the two different user registration flows:\n * 1) New Practitioner and new Project\n * 2) New Patient registration\n *\n * @category Authentication\n * @param newUserRequest Register request including email and password.\n * @returns Promise to the authentication response.\n */\n async startNewUser(newUserRequest: NewUserRequest): Promise<LoginAuthenticationResponse> {\n const { codeChallengeMethod, codeChallenge } = await this.startPkce();\n return this.post('auth/newuser', {\n ...newUserRequest,\n codeChallengeMethod,\n codeChallenge,\n }) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Initiates a new project flow.\n *\n * This requires a partial login from `startNewUser` or `startNewGoogleUser`.\n *\n * @param newProjectRequest Register request including email and password.\n * @returns Promise to the authentication response.\n */\n async startNewProject(newProjectRequest: NewProjectRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/newproject', newProjectRequest) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Initiates a new patient flow.\n *\n * This requires a partial login from `startNewUser` or `startNewGoogleUser`.\n *\n * @param newPatientRequest Register request including email and password.\n * @returns Promise to the authentication response.\n */\n async startNewPatient(newPatientRequest: NewPatientRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/newpatient', newPatientRequest) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Initiates a user login flow.\n * @category Authentication\n * @param loginRequest Login request including email and password.\n * @returns Promise to the authentication response.\n */\n async startLogin(loginRequest: EmailPasswordLoginRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/login', {\n ...(await this.ensureCodeChallenge(loginRequest)),\n clientId: loginRequest.clientId ?? this.#clientId,\n scope: loginRequest.scope,\n }) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Tries to sign in with Google authentication.\n * The response parameter is the result of a Google authentication.\n * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions\n * @category Authentication\n * @param loginRequest Login request including Google credential response.\n * @returns Promise to the authentication response.\n */\n async startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse> {\n return this.post('auth/google', {\n ...(await this.ensureCodeChallenge(loginRequest)),\n clientId: loginRequest.clientId ?? this.#clientId,\n scope: loginRequest.scope,\n }) as Promise<LoginAuthenticationResponse>;\n }\n\n /**\n * Returns the PKCE code challenge and method.\n * If the login request already includes a code challenge, it is returned.\n * Otherwise, a new PKCE code challenge is generated.\n * @category Authentication\n * @param loginRequest The original login request.\n * @returns The PKCE code challenge and method.\n */\n async ensureCodeChallenge<T extends BaseLoginRequest>(loginRequest: T): Promise<T> {\n if (loginRequest.codeChallenge) {\n return loginRequest;\n }\n return { ...loginRequest, ...(await this.startPkce()) };\n }\n\n /**\n * Signs out locally.\n * Does not invalidate tokens with the server.\n * @category Authentication\n */\n async signOut(): Promise<void> {\n await this.post(this.#logoutUrl, {});\n this.clear();\n }\n\n /**\n * Tries to sign in the user.\n * Returns true if the user is signed in.\n * This may result in navigating away to the sign in page.\n * @category Authentication\n * @param loginParams Optional login parameters.\n */\n async signInWithRedirect(loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource | void> {\n const urlParams = new URLSearchParams(window.location.search);\n const code = urlParams.get('code');\n if (!code) {\n await this.#requestAuthorization(loginParams);\n return undefined;\n } else {\n return this.processCode(code);\n }\n }\n\n /**\n * Tries to sign out the user.\n * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html\n * @category Authentication\n */\n signOutWithRedirect(): void {\n window.location.assign(this.#logoutUrl);\n }\n\n /**\n * Initiates sign in with an external identity provider.\n * @param authorizeUrl The external authorization URL.\n * @param clientId The external client ID.\n * @param redirectUri The external identity provider redirect URI.\n * @param baseLogin The Medplum login request.\n * @category Authentication\n */\n async signInWithExternalAuth(\n authorizeUrl: string,\n clientId: string,\n redirectUri: string,\n baseLogin: BaseLoginRequest\n ): Promise<void> {\n const loginRequest = await this.ensureCodeChallenge(baseLogin);\n window.location.assign(this.getExternalAuthRedirectUri(authorizeUrl, clientId, redirectUri, loginRequest));\n }\n\n /**\n * Builds the external identity provider redirect URI.\n * @param authorizeUrl The external authorization URL.\n * @param clientId The external client ID.\n * @param redirectUri The external identity provider redirect URI.\n * @param loginRequest The Medplum login request.\n * @returns The external identity provider redirect URI.\n * @category Authentication\n */\n getExternalAuthRedirectUri(\n authorizeUrl: string,\n clientId: string,\n redirectUri: string,\n loginRequest: BaseLoginRequest\n ): string {\n const url = new URL(authorizeUrl);\n url.searchParams.set('response_type', 'code');\n url.searchParams.set('client_id', clientId);\n url.searchParams.set('redirect_uri', redirectUri);\n url.searchParams.set('scope', 'openid profile email');\n url.searchParams.set('state', JSON.stringify(loginRequest));\n return url.toString();\n }\n\n /**\n * Builds a FHIR URL from a collection of URL path components.\n * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.\n * @category HTTP\n * @param path The path component of the URL.\n * @returns The well-formed FHIR URL.\n */\n fhirUrl(...path: string[]): URL {\n return new URL(this.#fhirBaseUrl + path.join('/'));\n }\n\n /**\n * Builds a FHIR search URL from a search query or structured query object.\n * @category HTTP\n * @category Search\n * @param query The FHIR search query or structured query object.\n * @returns The well-formed FHIR URL.\n */\n fhirSearchUrl(resourceType: ResourceType, query: URLSearchParams | string | undefined): URL {\n const url = this.fhirUrl(resourceType);\n if (query) {\n url.search = query.toString();\n }\n return url;\n }\n\n /**\n * Sends a FHIR search request.\n *\n * Example using a FHIR search string:\n *\n * ```typescript\n * const bundle = await client.search('Patient', 'name=Alice');\n * console.log(bundle);\n * ```\n *\n * The return value is a FHIR bundle:\n *\n * ```json\n * {\n * \"resourceType\": \"Bundle\",\n * \"type\": \"searchset\",\n * \"entry\": [\n * {\n * \"resource\": {\n * \"resourceType\": \"Patient\",\n * \"name\": [\n * {\n * \"given\": [\n * \"George\"\n * ],\n * \"family\": \"Washington\"\n * }\n * ],\n * }\n * }\n * ]\n * }\n * ```\n *\n * To query the count of a search, use the summary feature like so:\n *\n * ```typescript\n * const patients = medplum.search('Patient', '_summary=count');\n * ```\n *\n * See FHIR search for full details: https://www.hl7.org/fhir/search.html\n *\n * @category Search\n * @param resourceType The FHIR resource type.\n * @param query The search query as either a string or a structured search object.\n * @param options Optional fetch options.\n * @returns Promise to the search result bundle.\n */\n search<K extends ResourceType>(\n resourceType: K,\n query?: URLSearchParams | string,\n options: RequestInit = {}\n ): ReadablePromise<Bundle<ExtractResource<K>>> {\n const url = this.fhirSearchUrl(resourceType, query);\n const cacheKey = url.toString() + '-search';\n const cached = this.#getCacheEntry(cacheKey, options);\n if (cached) {\n return cached.value;\n }\n const promise = new ReadablePromise(\n (async () => {\n const bundle = await this.get<Bundle<ExtractResource<K>>>(url, options);\n if (bundle.entry) {\n for (const entry of bundle.entry) {\n this.#cacheResource(entry.resource);\n }\n }\n return bundle;\n })()\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Sends a FHIR search request for a single resource.\n *\n * This is a convenience method for `search()` that returns the first resource rather than a `Bundle`.\n *\n * Example using a FHIR search string:\n *\n * ```typescript\n * const patient = await client.searchOne('Patient', 'identifier=123');\n * console.log(patient);\n * ```\n *\n * The return value is the resource, if available; otherwise, undefined.\n *\n * See FHIR search for full details: https://www.hl7.org/fhir/search.html\n *\n * @category Search\n * @param resourceType The FHIR resource type.\n * @param query The search query as either a string or a structured search object.\n * @param options Optional fetch options.\n * @returns Promise to the search result bundle.\n */\n searchOne<K extends ResourceType>(\n resourceType: K,\n query?: URLSearchParams | string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K> | undefined> {\n const url = this.fhirSearchUrl(resourceType, query);\n url.searchParams.set('_count', '1');\n url.searchParams.sort();\n const cacheKey = url.toString() + '-searchOne';\n const cached = this.#getCacheEntry(cacheKey, options);\n if (cached) {\n return cached.value;\n }\n const promise = new ReadablePromise(\n this.search<K>(resourceType, url.searchParams, options).then((b) => b.entry?.[0]?.resource)\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Sends a FHIR search request for an array of resources.\n *\n * This is a convenience method for `search()` that returns the resources as an array rather than a `Bundle`.\n *\n * Example using a FHIR search string:\n *\n * ```typescript\n * const patients = await client.searchResources('Patient', 'name=Alice');\n * console.log(patients);\n * ```\n *\n * The return value is an array of resources.\n *\n * See FHIR search for full details: https://www.hl7.org/fhir/search.html\n *\n * @category Search\n * @param resourceType The FHIR resource type.\n * @param query The search query as either a string or a structured search object.\n * @param options Optional fetch options.\n * @returns Promise to the search result bundle.\n */\n searchResources<K extends ResourceType>(\n resourceType: K,\n query?: URLSearchParams | string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K>[]> {\n const url = this.fhirSearchUrl(resourceType, query);\n const cacheKey = url.toString() + '-searchResources';\n const cached = this.#getCacheEntry(cacheKey, options);\n if (cached) {\n return cached.value;\n }\n const promise = new ReadablePromise(\n this.search<K>(resourceType, query, options).then(\n (b) => b.entry?.map((e) => e.resource as ExtractResource<K>) ?? []\n )\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Searches a ValueSet resource using the \"expand\" operation.\n * See: https://www.hl7.org/fhir/operation-valueset-expand.html\n *\n * @category Search\n * @param system The ValueSet system url.\n * @param filter The search string.\n * @param options Optional fetch options.\n * @returns Promise to expanded ValueSet.\n */\n searchValueSet(system: string, filter: string, options: RequestInit = {}): ReadablePromise<ValueSet> {\n const url = this.fhirUrl('ValueSet', '$expand');\n url.searchParams.set('url', system);\n url.searchParams.set('filter', filter);\n return this.get(url.toString(), options);\n }\n\n /**\n * Returns a cached resource if it is available.\n * @category Caching\n * @param resourceType The FHIR resource type.\n * @param id The FHIR resource ID.\n * @returns The resource if it is available in the cache; undefined otherwise.\n */\n getCached<K extends ResourceType>(resourceType: K, id: string): ExtractResource<K> | undefined {\n const cached = this.#requestCache.get(this.fhirUrl(resourceType, id).toString())?.value;\n return cached && cached.isOk() ? (cached.read() as ExtractResource<K>) : undefined;\n }\n\n /**\n * Returns a cached resource if it is available.\n * @category Caching\n * @param resourceType The FHIR resource type.\n * @param id The FHIR resource ID.\n * @returns The resource if it is available in the cache; undefined otherwise.\n */\n getCachedReference<T extends Resource>(reference: Reference<T>): T | undefined {\n const refString = reference.reference as string;\n if (!refString) {\n return undefined;\n }\n if (refString === 'system') {\n return system as T;\n }\n const [resourceType, id] = refString.split('/');\n if (!resourceType || !id) {\n return undefined;\n }\n return this.getCached(resourceType as ResourceType, id) as T | undefined;\n }\n\n /**\n * Reads a resource by resource type and ID.\n *\n * Example:\n *\n * ```typescript\n * const patient = await medplum.readResource('Patient', '123');\n * console.log(patient);\n * ```\n *\n * See the FHIR \"read\" operation for full details: https://www.hl7.org/fhir/http.html#read\n *\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param options Optional fetch options.\n * @returns The resource if available; undefined otherwise.\n */\n readResource<K extends ResourceType>(\n resourceType: K,\n id: string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K>> {\n return this.get<ExtractResource<K>>(this.fhirUrl(resourceType, id), options);\n }\n\n /**\n * Reads a resource by `Reference`.\n *\n * This is a convenience method for `readResource()` that accepts a `Reference` object.\n *\n * Example:\n *\n * ```typescript\n * const serviceRequest = await medplum.readResource('ServiceRequest', '123');\n * const patient = await medplum.readReference(serviceRequest.subject);\n * console.log(patient);\n * ```\n *\n * See the FHIR \"read\" operation for full details: https://www.hl7.org/fhir/http.html#read\n *\n * @category Read\n * @param reference The FHIR reference object.\n * @param options Optional fetch options.\n * @returns The resource if available; undefined otherwise.\n */\n readReference<T extends Resource>(reference: Reference<T>, options: RequestInit = {}): ReadablePromise<T> {\n const refString = reference?.reference;\n if (!refString) {\n return new ReadablePromise(Promise.reject(new Error('Missing reference')));\n }\n if (refString === 'system') {\n return new ReadablePromise(Promise.resolve(system as unknown as T));\n }\n const [resourceType, id] = refString.split('/');\n if (!resourceType || !id) {\n return new ReadablePromise(Promise.reject(new Error('Invalid reference')));\n }\n return this.readResource(resourceType as ResourceType, id, options) as ReadablePromise<T>;\n }\n\n /**\n * Returns a cached schema for a resource type.\n * If the schema is not cached, returns undefined.\n * It is assumed that a client will call requestSchema before using this method.\n * @category Schema\n * @returns The schema if immediately available, undefined otherwise.\n * @deprecated Use globalSchema instead.\n */\n getSchema(): IndexedStructureDefinition {\n return globalSchema;\n }\n\n /**\n * Requests the schema for a resource type.\n * If the schema is already cached, the promise is resolved immediately.\n * @category Schema\n * @param resourceType The FHIR resource type.\n * @returns Promise to a schema with the requested resource type.\n */\n requestSchema(resourceType: string): Promise<IndexedStructureDefinition> {\n if (resourceType in globalSchema.types) {\n return Promise.resolve(globalSchema);\n }\n\n const cacheKey = resourceType + '-requestSchema';\n const cached = this.#getCacheEntry(cacheKey, undefined);\n if (cached) {\n return cached.value;\n }\n\n const promise = new ReadablePromise<IndexedStructureDefinition>(\n (async () => {\n const query = `{\n StructureDefinitionList(name: \"${resourceType}\") {\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: \"${resourceType}\", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\\s+/g, ' ');\n\n const response = (await this.graphql(query)) as SchemaGraphQLResponse;\n\n for (const structureDefinition of response.data.StructureDefinitionList) {\n indexStructureDefinition(structureDefinition);\n }\n\n for (const searchParameter of response.data.SearchParameterList) {\n indexSearchParameter(searchParameter);\n }\n\n return globalSchema;\n })()\n );\n this.#setCacheEntry(cacheKey, promise);\n return promise;\n }\n\n /**\n * Reads resource history by resource type and ID.\n *\n * The return value is a bundle of all versions of the resource.\n *\n * Example:\n *\n * ```typescript\n * const history = await medplum.readHistory('Patient', '123');\n * console.log(history);\n * ```\n *\n * See the FHIR \"history\" operation for full details: https://www.hl7.org/fhir/http.html#history\n *\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param options Optional fetch options.\n * @returns Promise to the resource history.\n */\n readHistory<K extends ResourceType>(\n resourceType: K,\n id: string,\n options: RequestInit = {}\n ): ReadablePromise<Bundle<ExtractResource<K>>> {\n return this.get(this.fhirUrl(resourceType, id, '_history'), options);\n }\n\n /**\n * Reads a specific version of a resource by resource type, ID, and version ID.\n *\n * Example:\n *\n * ```typescript\n * const version = await medplum.readVersion('Patient', '123', '456');\n * console.log(version);\n * ```\n *\n * See the FHIR \"vread\" operation for full details: https://www.hl7.org/fhir/http.html#vread\n *\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param vid The version ID.\n * @param options Optional fetch options.\n * @returns The resource if available; undefined otherwise.\n */\n readVersion<K extends ResourceType>(\n resourceType: K,\n id: string,\n vid: string,\n options: RequestInit = {}\n ): ReadablePromise<ExtractResource<K>> {\n return this.get(this.fhirUrl(resourceType, id, '_history', vid), options);\n }\n\n /**\n * Executes the Patient \"everything\" operation for a patient.\n *\n * Example:\n *\n * ```typescript\n * const bundle = await medplum.readPatientEverything('123');\n * console.log(bundle);\n * ```\n *\n * See the FHIR \"patient-everything\" operation for full details: https://hl7.org/fhir/operation-patient-everything.html\n *\n * @category Read\n * @param id The Patient Id\n * @param options Optional fetch options.\n * @returns A Bundle of all Resources related to the Patient\n */\n readPatientEverything(id: string, options: RequestInit = {}): ReadablePromise<Bundle> {\n return this.get(this.fhirUrl('Patient', id, '$everything'), options);\n }\n\n /**\n * Creates a new FHIR resource.\n *\n * The return value is the newly created resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createResource({\n * resourceType: 'Patient',\n * name: [{\n * family: 'Smith',\n * given: ['John']\n * }]\n * });\n * console.log(result.id);\n * ```\n *\n * See the FHIR \"create\" operation for full details: https://www.hl7.org/fhir/http.html#create\n *\n * @category Create\n * @param resource The FHIR resource to create.\n * @returns The result of the create operation.\n */\n createResource<T extends Resource>(resource: T): Promise<T> {\n if (!resource.resourceType) {\n throw new Error('Missing resourceType');\n }\n this.invalidateSearches(resource.resourceType);\n return this.post(this.fhirUrl(resource.resourceType), resource);\n }\n\n /**\n * Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.\n *\n * The return value is the existing resource or the newly created resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createResourceIfNoneExist(\n * {\n * resourceType: 'Patient',\n * identifier: [{\n * system: 'http://example.com/mrn',\n * value: '123'\n * }]\n * name: [{\n * family: 'Smith',\n * given: ['John']\n * }]\n * },\n * 'identifier=123'\n * );\n * console.log(result.id);\n * ```\n *\n * This method is syntactic sugar for:\n *\n * ```typescript\n * return searchOne(resourceType, query) ?? createResource(resource);\n * ```\n *\n * The query parameter only contains the search parameters (what would be in the URL following the \"?\").\n *\n * See the FHIR \"conditional create\" operation for full details: https://www.hl7.org/fhir/http.html#ccreate\n *\n * @category Create\n * @param resource The FHIR resource to create.\n * @param query The search query for an equivalent resource (should not include resource type or \"?\").\n * @returns The result of the create operation.\n */\n async createResourceIfNoneExist<T extends Resource>(resource: T, query: string): Promise<T> {\n return ((await this.searchOne(resource.resourceType, query)) ?? this.createResource(resource)) as Promise<T>;\n }\n\n /**\n * Creates a FHIR `Binary` resource with the provided data content.\n *\n * The return value is the newly created resource, including the ID and meta.\n *\n * The `data` parameter can be a string or a `File` object.\n *\n * A `File` object often comes from a `<input type=\"file\">` element.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createBinary(myFile, 'test.jpg', 'image/jpeg');\n * console.log(result.id);\n * ```\n *\n * See the FHIR \"create\" operation for full details: https://www.hl7.org/fhir/http.html#create\n *\n * @category Create\n * @param data The binary data to upload.\n * @param filename Optional filename for the binary.\n * @param contentType Content type for the binary.\n * @returns The result of the create operation.\n */\n createBinary(\n data: string | File | Blob | Uint8Array,\n filename: string | undefined,\n contentType: string,\n onProgress?: (e: ProgressEvent) => void\n ): Promise<Binary> {\n const url = this.fhirUrl('Binary');\n if (filename) {\n url.searchParams.set('_filename', filename);\n }\n\n if (onProgress) {\n return this.uploadwithProgress(url, data, contentType, onProgress);\n } else {\n return this.post(url, data, contentType);\n }\n }\n\n uploadwithProgress(\n url: URL,\n data: string | File | Blob | Uint8Array,\n contentType: string,\n onProgress: (e: ProgressEvent) => void\n ): Promise<any> {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.responseType = 'json';\n xhr.onabort = () => reject(new Error('Request aborted'));\n xhr.onerror = () => reject(new Error('Request error'));\n\n if (onProgress) {\n xhr.upload.onprogress = (e) => onProgress(e);\n xhr.upload.onload = (e) => onProgress(e);\n }\n\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve(xhr.response);\n } else {\n reject(new Error(xhr.statusText));\n }\n };\n\n xhr.open('POST', url);\n xhr.withCredentials = true;\n xhr.setRequestHeader('Authorization', 'Bearer ' + this.#accessToken);\n xhr.setRequestHeader('Cache-Control', 'no-cache, no-store, max-age=0');\n xhr.setRequestHeader('Content-Type', contentType);\n xhr.setRequestHeader('X-Medplum', 'extended');\n xhr.send(data);\n });\n }\n\n /**\n * Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.\n *\n * The return value is the newly created resource, including the ID and meta.\n *\n * The `docDefinition` parameter is a pdfmake document definition.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.createPdf({\n * content: ['Hello world']\n * });\n * console.log(result.id);\n * ```\n *\n * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/\n *\n * @category Media\n * @param docDefinition The PDF document definition.\n * @returns The result of the create operation.\n */\n async createPdf(\n docDefinition: TDocumentDefinitions,\n filename?: string,\n tableLayouts?: { [name: string]: CustomTableLayout },\n fonts?: TFontDictionary\n ): Promise<Binary> {\n if (!this.#createPdf) {\n throw new Error('PDF creation not enabled');\n }\n const blob = await this.#createPdf(docDefinition, tableLayouts, fonts);\n return this.createBinary(blob, filename, 'application/pdf');\n }\n\n /**\n * Creates a FHIR `Communication` resource with the provided data content.\n *\n * This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.\n *\n * @category Create\n * @param resource The FHIR resource to comment on.\n * @param text The text of the comment.\n * @returns The result of the create operation.\n */\n createComment(resource: Resource, text: string): Promise<Communication> {\n const profile = this.getProfile();\n let encounter: Reference<Encounter> | undefined = undefined;\n let subject: Reference<Patient> | undefined = undefined;\n\n if (resource.resourceType === 'Encounter') {\n encounter = createReference(resource);\n subject = resource.subject as Reference<Patient> | undefined;\n }\n\n if (resource.resourceType === 'ServiceRequest') {\n encounter = resource.encounter;\n subject = resource.subject as Reference<Patient> | undefined;\n }\n\n if (resource.resourceType === 'Patient') {\n subject = createReference(resource);\n }\n\n return this.createResource<Communication>({\n resourceType: 'Communication',\n basedOn: [createReference(resource)],\n encounter,\n subject,\n sender: profile ? createReference(profile) : undefined,\n sent: new Date().toISOString(),\n payload: [{ contentString: text }],\n });\n }\n\n /**\n * Updates a FHIR resource.\n *\n * The return value is the updated resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.updateResource({\n * resourceType: 'Patient',\n * id: '123',\n * name: [{\n * family: 'Smith',\n * given: ['John']\n * }]\n * });\n * console.log(result.meta.versionId);\n * ```\n *\n * See the FHIR \"update\" operation for full details: https://www.hl7.org/fhir/http.html#update\n *\n * @category Write\n * @param resource The FHIR resource to update.\n * @returns The result of the update operation.\n */\n async updateResource<T extends Resource>(resource: T): Promise<T> {\n if (!resource.resourceType) {\n throw new Error('Missing resourceType');\n }\n if (!resource.id) {\n throw new Error('Missing id');\n }\n this.invalidateSearches(resource.resourceType);\n let result = await this.put(this.fhirUrl(resource.resourceType, resource.id), resource);\n if (!result) {\n // On 304 not modified, result will be undefined\n // Return the user input instead\n // return result ?? resource;\n result = resource;\n }\n this.#cacheResource(result);\n return result;\n }\n\n /**\n * Updates a FHIR resource using JSONPatch operations.\n *\n * The return value is the updated resource, including the ID and meta.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.patchResource('Patient', '123', [\n * {op: 'replace', path: '/name/0/family', value: 'Smith'},\n * ]);\n * console.log(result.meta.versionId);\n * ```\n *\n * See the FHIR \"update\" operation for full details: https://www.hl7.org/fhir/http.html#patch\n *\n * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902\n *\n * @category Write\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param operations The JSONPatch operations.\n * @returns The result of the patch operations.\n */\n patchResource<K extends ResourceType>(\n resourceType: K,\n id: string,\n operations: PatchOperation[]\n ): Promise<ExtractResource<K>> {\n this.invalidateSearches(resourceType);\n return this.patch(this.fhirUrl(resourceType, id), operations);\n }\n\n /**\n * Deletes a FHIR resource by resource type and ID.\n *\n * Example:\n *\n * ```typescript\n * await medplum.deleteResource('Patient', '123');\n * ```\n *\n * See the FHIR \"delete\" operation for full details: https://www.hl7.org/fhir/http.html#delete\n *\n * @category Delete\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @returns The result of the delete operation.\n */\n deleteResource(resourceType: ResourceType, id: string): Promise<any> {\n this.#deleteCacheEntry(this.fhirUrl(resourceType, id).toString());\n this.invalidateSearches(resourceType);\n return this.delete(this.fhirUrl(resourceType, id));\n }\n\n /**\n * Executes the validate operation with the provided resource.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.validateResource({\n * resourceType: 'Patient',\n * name: [{ given: ['Alice'], family: 'Smith' }],\n * });\n * ```\n *\n * See the FHIR \"$validate\" operation for full details: https://www.hl7.org/fhir/resource-operation-validate.html\n *\n * @param resource The FHIR resource.\n * @returns The validate operation outcome.\n */\n validateResource<T extends Resource>(resource: T): Promise<OperationOutcome> {\n return this.post(this.fhirUrl(resource.resourceType, '$validate'), resource);\n }\n\n /**\n * Executes a batch or transaction of FHIR operations.\n *\n * Example:\n *\n * ```typescript\n * await medplum.executeBatch({\n * \"resourceType\": \"Bundle\",\n * \"type\": \"transaction\",\n * \"entry\": [\n * {\n * \"fullUrl\": \"urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a\",\n * \"resource\": {\n * \"resourceType\": \"Patient\",\n * \"name\": [{ \"use\": \"official\", \"given\": [\"Alice\"], \"family\": \"Smith\" }],\n * \"gender\": \"female\",\n * \"birthDate\": \"1974-12-25\"\n * },\n * \"request\": {\n * \"method\": \"POST\",\n * \"url\": \"Patient\"\n * }\n * },\n * {\n * \"fullUrl\": \"urn:uuid:88f151c0-a954-468a-88bd-5ae15c08e059\",\n * \"resource\": {\n * \"resourceType\": \"Patient\",\n * \"identifier\": [{ \"system\": \"http:/example.org/fhir/ids\", \"value\": \"234234\" }],\n * \"name\": [{ \"use\": \"official\", \"given\": [\"Bob\"], \"family\": \"Jones\" }],\n * \"gender\": \"male\",\n * \"birthDate\": \"1974-12-25\"\n * },\n * \"request\": {\n * \"method\": \"POST\",\n * \"url\": \"Patient\",\n * \"ifNoneExist\": \"identifier=http:/example.org/fhir/ids|234234\"\n * }\n * }\n * ]\n * });\n * ```\n *\n * See The FHIR \"batch/transaction\" section for full details: https://hl7.org/fhir/http.html#transaction\n * @category Batch\n * @param bundle The FHIR batch/transaction bundle.\n * @returns The FHIR batch/transaction response bundle.\n */\n executeBatch(bundle: Bundle): Promise<Bundle> {\n return this.post('fhir/R4', bundle);\n }\n\n /**\n * Sends an email using the Medplum Email API.\n *\n * Builds the email using nodemailer MailComposer.\n *\n * Examples:\n *\n * Send a simple text email:\n *\n * ```typescript\n * await medplum.sendEmail({\n * to: 'alice@example.com',\n * cc: 'bob@example.com',\n * subject: 'Hello',\n * text: 'Hello Alice',\n * });\n * ```\n *\n * Send an email with a `Binary` attachment:\n *\n * ```typescript\n * await medplum.sendEmail({\n * to: 'alice@example.com',\n * subject: 'Email with attachment',\n * text: 'See the attached report',\n * attachments: [{\n * filename: 'report.pdf',\n * path: \"Binary/\" + binary.id\n * }]\n * });\n * ```\n *\n * See options here: https://nodemailer.com/extras/mailcomposer/\n * @category Media\n * @param options The MailComposer options.\n * @returns Promise to the operation outcome.\n */\n sendEmail(email: MailOptions): Promise<OperationOutcome> {\n return this.post('email/v1/send', email, 'application/json');\n }\n\n /**\n * Executes a GraphQL query.\n *\n * Example:\n *\n * ```typescript\n * const result = await medplum.graphql(`{\n * Patient(id: \"123\") {\n * resourceType\n * id\n * name {\n * given\n * family\n * }\n * }\n * }`);\n * ```\n *\n * Advanced queries such as named operations and variable substitution are supported:\n *\n * ```typescript\n * const result = await medplum.graphql(\n * `query GetPatientById($patientId: ID!) {\n * Patient(id: $patientId) {\n * resourceType\n * id\n * name {\n * given\n * family\n * }\n * }\n * }`,\n * 'GetPatientById',\n * { patientId: '123' }\n * );\n * ```\n *\n * See the GraphQL documentation for more details: https://graphql.org/learn/\n *\n * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html\n *\n * @category Read\n * @param query The GraphQL query.\n * @param operationName Optional GraphQL operation name.\n * @param variables Optional GraphQL variables.\n * @param options Optional fetch options.\n * @returns The GraphQL result.\n */\n graphql(query: string, operationName?: string | null, variables?: any, options?: RequestInit): Promise<any> {\n return this.post(this.fhirUrl('$graphql'), { query, operationName, variables }, JSON_CONTENT_TYPE, options);\n }\n\n /**\n *\n * Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource\n * according to a graph definition\n\n * @category Read\n * @param resourceType The FHIR resource type.\n * @param id The resource ID.\n * @param graphName `name` parameter of the GraphDefinition\n * @returns A Bundle\n */\n readResourceGraph<K extends ResourceType>(\n resourceType: K,\n id: string,\n graphName: string\n ): ReadablePromise<Bundle<Resource>> {\n return this.get<Bundle<Resource>>(`${this.fhirUrl(resourceType, id)}/$graph?graph=${graphName}`);\n }\n\n /**\n * @category Authentication\n * @returns The Login State\n */\n getActiveLogin(): LoginState | undefined {\n return this.#storage.getObject('activeLogin');\n }\n\n /**\n * @category Authentication\n */\n async setActiveLogin(login: LoginState): Promise<void> {\n this.clearActiveLogin();\n this.#accessToken = login.accessToken;\n this.#refreshToken = login.refreshToken;\n this.#storage.setObject('activeLogin', login);\n this.#addLogin(login);\n this.#refreshPromise = undefined;\n await this.#refreshProfile();\n }\n\n /**\n * @category Authentication\n */\n getAccessToken(): string | undefined {\n return this.#accessToken;\n }\n\n /**\n * @category Authentication\n */\n setAccessToken(accessToken: string): void {\n this.#accessToken = accessToken;\n this.#refreshToken = undefined;\n this.#profile = undefined;\n this.#config = undefined;\n }\n\n /**\n * @category Authentication\n */\n getLogins(): LoginState[] {\n return this.#storage.getObject<LoginState[]>('logins') ?? [];\n }\n\n #addLogin(newLogin: LoginState): void {\n const logins = this.getLogins().filter((login) => login.profile?.reference !== newLogin.profile?.reference);\n logins.push(newLogin);\n this.#storage.setObject('logins', logins);\n }\n\n async #refreshProfile(): Promise<ProfileResource | undefined> {\n this.#profilePromise = new Promise((resolve, reject) => {\n this.get('auth/me')\n .then((result) => {\n this.#profilePromise = undefined;\n this.#profile = result.profile;\n this.#config = result.config;\n this.dispatchEvent({ type: 'change' });\n resolve(this.#profile);\n })\n .catch(reject);\n });\n\n return this.#profilePromise;\n }\n\n /**\n * @category Authentication\n */\n isLoading(): boolean {\n return !!this.#profilePromise;\n }\n\n /**\n * @category User Profile\n */\n getProfile(): ProfileResource | undefined {\n return this.#profile;\n }\n\n /**\n * @category User Profile\n */\n async getProfileAsync(): Promise<ProfileResource | undefined> {\n if (this.#profilePromise) {\n await this.#profilePromise;\n }\n return this.getProfile();\n }\n\n /**\n * @category User Profile\n */\n getUserConfiguration(): UserConfiguration | undefined {\n return this.#config;\n }\n\n /**\n * Downloads the URL as a blob.\n *\n * @category Read\n * @param url The URL to request.\n * @returns Promise to the response body as a blob.\n */\n async download(url: URL | string, options: RequestInit = {}): Promise<Blob> {\n if (this.#refreshPromise) {\n await this.#refreshPromise;\n }\n this.#addFetchOptionsDefaults(options);\n const response = await this.#fetch(url.toString(), options);\n return response.blob();\n }\n\n //\n // Private helpers\n //\n\n /**\n * Returns the cache entry if available and not expired.\n * @param key The cache key to retrieve.\n * @param options Optional fetch options for cache settings.\n * @returns The cached entry if found.\n */\n #getCacheEntry(key: string, options: RequestInit | undefined): RequestCacheEntry | undefined {\n if (this.#cacheTime <= 0 || options?.cache === 'no-cache' || options?.cache === 'reload') {\n return undefined;\n }\n const entry = this.#requestCache.get(key);\n if (!entry || entry.requestTime + this.#cacheTime < Date.now()) {\n return undefined;\n }\n return entry;\n }\n\n /**\n * Adds a readable promise to the cache.\n * @param key The cache key to store.\n * @param value The readable promise to store.\n */\n #setCacheEntry(key: string, value: ReadablePromise<any>): void {\n if (this.#cacheTime > 0) {\n this.#requestCache.set(key, { requestTime: Date.now(), value });\n }\n }\n\n /**\n * Adds a concrete value as the cache entry for the given resource.\n * This is used in cases where the resource is loaded indirectly.\n * For example, when a resource is loaded as part of a Bundle.\n * @param resource The resource to cache.\n */\n #cacheResource(resource: Resource | undefined): void {\n if (resource?.id) {\n this.#setCacheEntry(\n this.fhirUrl(resource.resourceType, resource.id).toString(),\n new ReadablePromise(Promise.resolve(resource))\n );\n }\n }\n\n /**\n * Deletes a cache entry.\n * @param key The cache key to delete.\n */\n #deleteCacheEntry(key: string): void {\n if (this.#cacheTime > 0) {\n this.#requestCache.delete(key);\n }\n }\n\n /**\n * Makes an HTTP request.\n * @param {string} method\n * @param {string} url\n * @param {string=} contentType\n * @param {Object=} body\n */\n async #request<T>(method: string, url: string, options: RequestInit = {}): Promise<T> {\n if (this.#refreshPromise) {\n await this.#refreshPromise;\n }\n\n if (!url.startsWith('http')) {\n url = this.#baseUrl + url;\n }\n\n options.method = method;\n this.#addFetchOptionsDefaults(options);\n\n const response = await this.#fetchWithRetry(url, options);\n if (response.status === 401) {\n // Refresh and try again\n return this.#handleUnauthenticated(method, url, options);\n }\n\n if (response.status === 204 || response.status === 304) {\n // No content or change\n return undefined as unknown as T;\n }\n\n let obj: any = undefined;\n try {\n obj = await response.json();\n } catch (err) {\n console.error('Error parsing response', response.status, err);\n throw err;\n }\n\n if (response.status >= 400) {\n throw new OperationOutcomeError(normalizeOperationOutcome(obj));\n }\n return obj;\n }\n\n async #fetchWithRetry(url: string, options: RequestInit): Promise<Response> {\n const maxRetries = 3;\n const retryDelay = 200;\n let response: Response | undefined = undefined;\n for (let retry = 0; retry < maxRetries; retry++) {\n response = (await this.#fetch(url, options)) as Response;\n if (response.status < 500) {\n return response;\n }\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n }\n return response as Response;\n }\n\n /**\n * Executes a batch of requests that were automatically batched together.\n */\n async #executeAutoBatch(): Promise<void> {\n // Get the current queue\n const entries = [...this.#autoBatchQueue];\n\n // Clear the queue\n this.#autoBatchQueue.length = 0;\n\n // Clear the timer\n this.#autoBatchTimerId = undefined;\n\n // If there is only one request in the batch, just execute it\n if (entries.length === 1) {\n const entry = entries[0];\n entry.resolve(await this.#request(entry.method, this.#fhirBaseUrl + entry.url, entry.options));\n return;\n }\n\n // Build the batch request\n const batch: Bundle = {\n resourceType: 'Bundle',\n type: 'batch',\n entry: entries.map(\n (e) =>\n ({\n request: {\n method: e.method,\n url: e.url,\n },\n resource: e.options.body ? (JSON.parse(e.options.body as string) as Resource) : undefined,\n } as BundleEntry)\n ),\n };\n\n // Execute the batch request\n const response = (await this.post('fhir/R4', batch)) as Bundle;\n\n // Process the response\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n const responseEntry = response.entry?.[i];\n if (responseEntry?.response?.outcome && !isOk(responseEntry.response.outcome)) {\n entry.reject(new OperationOutcomeError(responseEntry.response.outcome));\n } else {\n entry.resolve(responseEntry?.resource);\n }\n }\n }\n\n /**\n * Adds default options to the fetch options.\n * @param options The options to add defaults to.\n */\n #addFetchOptionsDefaults(options: RequestInit): void {\n if (!options.headers) {\n options.headers = {};\n }\n\n const headers = options.headers as Record<string, string>;\n headers['X-Medplum'] = 'extended';\n\n if (!headers['Content-Type']) {\n headers['Content-Type'] = FHIR_CONTENT_TYPE;\n }\n\n if (this.#accessToken) {\n headers['Authorization'] = 'Bearer ' + this.#accessToken;\n }\n\n if (!options.cache) {\n options.cache = 'no-cache';\n }\n\n if (!options.credentials) {\n options.credentials = 'include';\n }\n }\n\n /**\n * Sets the \"Content-Type\" header on fetch options.\n * @param options The fetch options.\n * @param contentType The new content type to set.\n */\n #setRequestContentType(options: RequestInit, contentType: string): void {\n if (!options.headers) {\n options.headers = {};\n }\n const headers = options.headers as Record<string, string>;\n headers['Content-Type'] = contentType;\n }\n\n /**\n * Sets the body on fetch options.\n * @param options The fetch options.\n * @param data The new content body.\n */\n #setRequestBody(options: RequestInit, data: any): void {\n if (\n typeof data === 'string' ||\n (typeof Blob !== 'undefined' && data instanceof Blob) ||\n (typeof File !== 'undefined' && data instanceof File) ||\n (typeof Uint8Array !== 'undefined' && data instanceof Uint8Array)\n ) {\n options.body = data;\n } else if (data) {\n options.body = JSON.stringify(data);\n }\n }\n\n /**\n * Handles an unauthenticated response from the server.\n * First, tries to refresh the access token and retry the request.\n * Otherwise, calls unauthenticated callbacks and rejects.\n * @param method The HTTP method of the original request.\n * @param url The URL of the original request.\n * @param contentType The content type of the original request.\n * @param body The body of the original request.\n */\n #handleUnauthenticated(method: string, url: string, options: RequestInit): Promise<any> {\n if (this.#refresh()) {\n return this.#request(method, url, options);\n }\n this.clearActiveLogin();\n if (this.#onUnauthenticated) {\n this.#onUnauthenticated();\n }\n return Promise.reject(new Error('Unauthenticated'));\n }\n\n /**\n * Starts a new PKCE flow.\n * These PKCE values are stateful, and must survive redirects and page refreshes.\n * @category Authentication\n */\n async startPkce(): Promise<{ codeChallengeMethod: string; codeChallenge: string }> {\n const pkceState = getRandomString();\n sessionStorage.setItem('pkceState', pkceState);\n\n const codeVerifier = getRandomString();\n sessionStorage.setItem('codeVerifier', codeVerifier);\n\n const arrayHash = await encryptSHA256(codeVerifier);\n const codeChallenge = arrayBufferToBase64(arrayHash).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n sessionStorage.setItem('codeChallenge', codeChallenge);\n\n return { codeChallengeMethod: 'S256', codeChallenge };\n }\n\n /**\n * Redirects the user to the login screen for authorization.\n * Clears all auth state including local storage and session storage.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint\n */\n async #requestAuthorization(loginParams?: Partial<BaseLoginRequest>): Promise<void> {\n const loginRequest = await this.ensureCodeChallenge(loginParams || {});\n const url = new URL(this.#authorizeUrl);\n url.searchParams.set('response_type', 'code');\n url.searchParams.set('state', sessionStorage.getItem('pkceState') as string);\n url.searchParams.set('client_id', loginRequest.clientId || (this.#clientId as string));\n url.searchParams.set('redirect_uri', loginRequest.redirectUri || getWindowOrigin());\n url.searchParams.set('code_challenge_method', loginRequest.codeChallengeMethod as string);\n url.searchParams.set('code_challenge', loginRequest.codeChallenge as string);\n url.searchParams.set('scope', loginRequest.scope || 'openid profile');\n window.location.assign(url.toString());\n }\n\n /**\n * Processes an OAuth authorization code.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest\n * @param code The authorization code received by URL parameter.\n * @category Authentication\n */\n processCode(code: string): Promise<ProfileResource> {\n const formBody = new URLSearchParams();\n formBody.set('grant_type', 'authorization_code');\n formBody.set('client_id', this.#clientId as string);\n formBody.set('code', code);\n formBody.set('redirect_uri', getWindowOrigin());\n\n if (typeof sessionStorage !== 'undefined') {\n const codeVerifier = sessionStorage.getItem('codeVerifier');\n if (codeVerifier) {\n formBody.set('code_verifier', codeVerifier);\n }\n }\n\n return this.#fetchTokens(formBody);\n }\n\n /**\n * Tries to refresh the auth tokens.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens\n */\n #refresh(): Promise<void> | undefined {\n if (this.#refreshPromise) {\n return this.#refreshPromise;\n }\n\n if (this.#refreshToken) {\n const formBody = new URLSearchParams();\n formBody.set('grant_type', 'refresh_token');\n formBody.set('client_id', this.#clientId as string);\n formBody.set('refresh_token', this.#refreshToken);\n this.#refreshPromise = this.#fetchTokens(formBody);\n return this.#refreshPromise;\n }\n\n if (this.#clientId && this.#clientSecret) {\n this.#refreshPromise = this.startClientLogin(this.#clientId, this.#clientSecret);\n return this.#refreshPromise;\n }\n\n return undefined;\n }\n\n /**\n * Starts a new OAuth2 client credentials flow.\n * See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4\n * @category Authentication\n * @param clientId The client ID.\n * @param clientSecret The client secret.\n * @returns Promise that resolves to the client profile.\n */\n async startClientLogin(clientId: string, clientSecret: string): Promise<ProfileResource> {\n this.#clientId = clientId;\n this.#clientSecret = clientSecret;\n\n const formBody = new URLSearchParams();\n formBody.set('grant_type', 'client_credentials');\n formBody.set('client_id', clientId);\n formBody.set('client_secret', clientSecret);\n return this.#fetchTokens(formBody);\n }\n\n /**\n * Makes a POST request to the tokens endpoint.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint\n * @param formBody Token parameters in URL encoded format.\n */\n async #fetchTokens(formBody: URLSearchParams): Promise<ProfileResource> {\n const response = await this.#fetch(this.#tokenUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: formBody,\n credentials: 'include',\n });\n if (!response.ok) {\n this.clearActiveLogin();\n throw new Error('Failed to fetch tokens');\n }\n const tokens = await response.json();\n await this.#verifyTokens(tokens);\n return this.getProfile() as ProfileResource;\n }\n\n /**\n * Verifies the tokens received from the auth server.\n * Validates the JWT against the JWKS.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint\n * @param tokens\n */\n async #verifyTokens(tokens: TokenResponse): Promise<void> {\n const token = tokens.access_token;\n\n // Verify token has not expired\n const tokenPayload = parseJWTPayload(token);\n if (Date.now() >= (tokenPayload.exp as number) * 1000) {\n this.clearActiveLogin();\n throw new Error('Token expired');\n }\n\n // Verify app_client_id\n if (this.#clientId && tokenPayload.client_id !== this.#clientId) {\n this.clearActiveLogin();\n throw new Error('Token was not issued for this audience');\n }\n\n return this.setActiveLogin({\n accessToken: token,\n refreshToken: tokens.refresh_token,\n project: tokens.project,\n profile: tokens.profile,\n });\n }\n\n /**\n * Sets up a listener for window storage events.\n * This synchronizes state across browser windows and browser tabs.\n */\n #setupStorageListener(): void {\n try {\n window.addEventListener('storage', (e: StorageEvent) => {\n if (e.key === null || e.key === 'activeLogin') {\n // Storage events fire when different tabs make changes.\n // On storage clear (key === null) or activeLogin change (key === 'activeLogin')\n // Refresh the page to ensure the active login is up to date.\n window.location.reload();\n }\n });\n } catch (err) {\n // Silently ignore if this environment does not support storage events\n }\n }\n}\n\n/**\n * Returns the default fetch method.\n * The default fetch is currently only available in browser environments.\n * If you want to use SSR such as Next.js, you should pass a custom fetch function.\n * @returns The default fetch function for the current environment.\n */\nfunction getDefaultFetch(): FetchLike {\n if (!globalThis.fetch) {\n throw new Error('Fetch not available in this environment');\n }\n return globalThis.fetch.bind(globalThis);\n}\n\n/**\n * Returns the base URL for the current page.\n * @category HTTP\n */\nfunction getWindowOrigin(): string {\n if (typeof window === 'undefined') {\n return '';\n }\n return window.location.protocol + '//' + window.location.host + '/';\n}\n\nfunction ensureTrailingSlash(url: string | undefined): string | undefined {\n if (!url) {\n return url;\n }\n return url.endsWith('/') ? url : url + '/';\n}\n","import { TypedValue } from '../types';\nimport { Token } from './tokenize';\n\nexport interface Atom {\n eval(context: TypedValue[]): TypedValue[];\n}\n\nexport abstract class PrefixOperatorAtom implements Atom {\n constructor(public readonly operator: string, public readonly child: Atom) {}\n\n abstract eval(context: TypedValue[]): TypedValue[];\n\n toString(): string {\n return `${this.operator}(${this.child.toString()})`;\n }\n}\n\nexport abstract class InfixOperatorAtom implements Atom {\n constructor(public readonly operator: string, public readonly left: Atom, public readonly right: Atom) {}\n\n abstract eval(context: TypedValue[]): TypedValue[];\n\n toString(): string {\n return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;\n }\n}\n\nexport interface PrefixParselet {\n parse(parser: Parser, token: Token): Atom;\n}\n\nexport interface InfixParselet {\n precedence: number;\n parse?(parser: Parser, left: Atom, token: Token): Atom;\n}\n\nexport class ParserBuilder {\n readonly #prefixParselets: Record<string, PrefixParselet> = {};\n readonly #infixParselets: Record<string, InfixParselet> = {};\n\n public registerInfix(tokenType: string, parselet: InfixParselet): ParserBuilder {\n this.#infixParselets[tokenType] = parselet;\n return this;\n }\n\n public registerPrefix(tokenType: string, parselet: PrefixParselet): ParserBuilder {\n this.#prefixParselets[tokenType] = parselet;\n return this;\n }\n\n public prefix(tokenType: string, precedence: number, builder: (token: Token, right: Atom) => Atom): ParserBuilder {\n return this.registerPrefix(tokenType, {\n parse(parser, token) {\n const right = parser.consumeAndParse(precedence);\n return builder(token, right);\n },\n });\n }\n\n public infixLeft(\n tokenType: string,\n precedence: number,\n builder: (left: Atom, token: Token, right: Atom) => Atom\n ): ParserBuilder {\n return this.registerInfix(tokenType, {\n parse(parser, left, token) {\n const right = parser.consumeAndParse(precedence);\n return builder(left, token, right);\n },\n precedence,\n });\n }\n\n public construct(input: Token[]): Parser {\n return new Parser(input, this.#prefixParselets, this.#infixParselets);\n }\n}\n\nexport class Parser {\n #tokens: Token[];\n #prefixParselets: Record<string, PrefixParselet>;\n #infixParselets: Record<string, InfixParselet>;\n\n constructor(\n tokens: Token[],\n prefixParselets: Record<string, PrefixParselet>,\n infixParselets: Record<string, InfixParselet>\n ) {\n this.#tokens = tokens;\n this.#prefixParselets = prefixParselets;\n this.#infixParselets = infixParselets;\n }\n\n hasMore(): boolean {\n return this.#tokens.length > 0;\n }\n\n match(expected: string): boolean {\n const token = this.peek();\n if (token?.id !== expected) {\n return false;\n }\n\n this.consume();\n return true;\n }\n\n consumeAndParse(precedence = Infinity): Atom {\n const token = this.consume();\n const prefix = this.#prefixParselets[token.id];\n if (!prefix) {\n throw Error(\n `Parse error at \"${token.value}\" (line ${token.line}, column ${token.column}). No matching prefix parselet.`\n );\n }\n\n let left = prefix.parse(this, token);\n\n while (precedence > this.getPrecedence()) {\n const next = this.consume();\n const infix = this.getInfixParselet(next) as InfixParselet;\n left = (infix.parse as (parser: Parser, left: Atom, token: Token) => Atom)(this, left, next);\n }\n\n return left;\n }\n\n getPrecedence(): number {\n const nextToken = this.peek();\n if (!nextToken) {\n return Infinity;\n }\n const parser = this.getInfixParselet(nextToken);\n if (parser) {\n return parser.precedence;\n }\n return Infinity;\n }\n\n consume(expectedId?: string, expectedValue?: string): Token {\n if (!this.#tokens.length) {\n throw Error('Cant consume unknown more tokens.');\n }\n if (expectedId && this.peek()?.id !== expectedId) {\n const actual = this.peek() as Token;\n throw Error(`Expected ${expectedId} but got \"${actual.id}\" at line ${actual.line} column ${actual.column}.`);\n }\n if (expectedValue && this.peek()?.value !== expectedValue) {\n const actual = this.peek() as Token;\n throw Error(\n `Expected \"${expectedValue}\" but got \"${actual.value}\" at line ${actual.line} column ${actual.column}.`\n );\n }\n return this.#tokens.shift() as Token;\n }\n\n peek(): Token | undefined {\n return this.#tokens.length > 0 ? this.#tokens[0] : undefined;\n }\n\n removeComments(): void {\n this.#tokens = this.#tokens.filter((t) => t.id !== 'Comment');\n }\n\n getInfixParselet(token: Token): InfixParselet | undefined {\n return this.#infixParselets[token.id === 'Symbol' ? token.value : token.id];\n }\n}\n","export interface Marker {\n index: number;\n line: number;\n column: number;\n}\n\nexport interface Token extends Marker {\n id: string;\n value: string;\n}\n\nconst STANDARD_UNITS = [\n 'year',\n 'years',\n 'month',\n 'months',\n 'week',\n 'weeks',\n 'day',\n 'days',\n 'hour',\n 'hours',\n 'minute',\n 'minutes',\n 'second',\n 'seconds',\n 'millisecond',\n 'milliseconds',\n];\n\nexport class Tokenizer {\n readonly #str: string;\n readonly #keywords: string[];\n readonly #operators: string[];\n readonly #result: Token[] = [];\n readonly #pos: Marker = { index: 0, line: 1, column: 0 };\n readonly #markStack: Marker[] = [];\n\n constructor(str: string, keywords: string[], operators: string[]) {\n this.#str = str;\n this.#keywords = keywords;\n this.#operators = operators;\n }\n\n tokenize(): Token[] {\n while (this.#pos.index < this.#str.length) {\n const token = this.#consumeToken();\n if (token) {\n this.#result.push(token);\n }\n }\n\n return this.#result;\n }\n\n #prevToken(): Token | undefined {\n return this.#result.slice(-1)[0];\n }\n\n #peekToken(): Token | undefined {\n this.#mark();\n const token = this.#consumeToken();\n this.#reset();\n return token;\n }\n\n #consumeToken(): Token | undefined {\n this.#consumeWhitespace();\n\n const c = this.#curr();\n if (!c) {\n return undefined;\n }\n\n this.#mark();\n\n const next = this.#peek();\n\n if (c === '/' && next === '*') {\n return this.#consumeMultiLineComment();\n }\n\n if (c === '/' && next === '/') {\n return this.#consumeSingleLineComment();\n }\n\n if (c === \"'\" || c === '\"') {\n return this.#consumeString(c);\n }\n\n if (c === '`') {\n return this.#consumeBacktickSymbol();\n }\n\n if (c === '@') {\n return this.#consumeDateTime();\n }\n\n if (c.match(/\\d/)) {\n return this.#consumeNumber();\n }\n\n if (c.match(/\\w/)) {\n return this.#consumeSymbol();\n }\n\n if (c === '$' && next.match(/\\w/)) {\n return this.#consumeSymbol();\n }\n\n return this.#consumeOperator();\n }\n\n #consumeWhitespace(): void {\n this.#consumeWhile(() => this.#curr().match(/\\s/));\n }\n\n #consumeMultiLineComment(): Token {\n const start = this.#pos.index;\n this.#consumeWhile(() => this.#curr() !== '*' || this.#peek() !== '/');\n this.#advance();\n this.#advance();\n return this.#buildToken('Comment', this.#str.substring(start, this.#pos.index));\n }\n\n #consumeSingleLineComment(): Token {\n return this.#buildToken(\n 'Comment',\n this.#consumeWhile(() => this.#curr() !== '\\n')\n );\n }\n\n #consumeString(endChar: string): Token {\n this.#advance();\n const result = this.#buildToken(\n 'String',\n this.#consumeWhile(() => this.#prev() === '\\\\' || this.#curr() !== endChar)\n );\n this.#advance();\n return result;\n }\n\n #consumeBacktickSymbol(): Token {\n this.#advance();\n const result = this.#buildToken(\n 'Symbol',\n this.#consumeWhile(() => this.#curr() !== '`')\n );\n this.#advance();\n return result;\n }\n\n #consumeDateTime(): Token {\n this.#advance(); // Consume \"@\"\n\n const start = this.#pos.index;\n this.#consumeWhile(() => this.#curr().match(/[\\d-]/));\n\n if (this.#curr() === 'T') {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/[\\d:]/));\n\n if (this.#curr() === '.' && this.#peek().match(/\\d/)) {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/\\d/));\n }\n\n if (this.#curr() === 'Z') {\n this.#advance();\n } else if (this.#curr() === '+' || this.#curr() === '-') {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/[\\d:]/));\n }\n }\n\n return this.#buildToken('DateTime', this.#str.substring(start, this.#pos.index));\n }\n\n #consumeNumber(): Token {\n const start = this.#pos.index;\n let id = 'Number';\n this.#consumeWhile(() => this.#curr().match(/\\d/));\n\n if (this.#curr() === '.' && this.#peek().match(/\\d/)) {\n this.#advance();\n this.#consumeWhile(() => this.#curr().match(/\\d/));\n }\n\n if (this.#curr() === ' ') {\n if (isUnitToken(this.#peekToken())) {\n id = 'Quantity';\n this.#consumeToken();\n }\n }\n\n return this.#buildToken(id, this.#str.substring(start, this.#pos.index));\n }\n\n #consumeSymbol(): Token {\n const value = this.#consumeWhile(() => this.#curr().match(/[$\\w]/));\n if (this.#prevToken()?.value !== '.' && this.#keywords.includes(value)) {\n return this.#buildToken(value, value);\n }\n return this.#buildToken('Symbol', value);\n }\n\n #consumeOperator(): Token {\n const c = this.#curr();\n const next = this.#peek();\n const twoCharOp = c + next;\n\n if (this.#operators.includes(twoCharOp)) {\n this.#advance();\n this.#advance();\n return this.#buildToken(twoCharOp, twoCharOp);\n }\n\n this.#advance();\n return this.#buildToken(c, c);\n }\n\n #consumeWhile(condition: () => unknown): string {\n const start = this.#pos.index;\n\n while (this.#pos.index < this.#str.length && condition()) {\n this.#advance();\n }\n\n return this.#str.substring(start, this.#pos.index);\n }\n\n #curr(): string {\n return this.#str[this.#pos.index];\n }\n\n #prev(): string {\n return this.#str[this.#pos.index - 1] ?? '';\n }\n\n #peek(): string {\n return this.#str[this.#pos.index + 1] ?? '';\n }\n\n #mark(): void {\n this.#markStack.push({ ...this.#pos });\n }\n\n #reset(): void {\n const mark = this.#markStack.pop();\n if (!mark) {\n throw new Error('No mark to reset to');\n }\n this.#pos.index = mark.index;\n this.#pos.line = mark.line;\n this.#pos.column = mark.column;\n }\n\n #advance(): void {\n this.#pos.index++;\n if (this.#curr() === '\\n') {\n this.#pos.line++;\n this.#pos.column = 0;\n } else {\n this.#pos.column++;\n }\n }\n\n #buildToken(id: string, value: string): Token {\n const mark = this.#markStack.pop();\n if (!mark) {\n throw new Error('No mark for token');\n }\n return {\n id,\n value,\n ...mark,\n };\n }\n}\n\nfunction isUnitToken(token: Token | undefined): boolean {\n if (token) {\n if (token.id === 'String') {\n return true;\n }\n\n if (token.id === 'Symbol' && STANDARD_UNITS.includes(token.value)) {\n return true;\n }\n }\n\n return false;\n}\n","export function parseDateString(str: string): string {\n if (str.startsWith('T')) {\n // If a time string,\n // then normalize to full length.\n return str + 'T00:00:00.000Z'.substring(str.length);\n }\n\n if (str.length <= 10) {\n // If a local date (i.e., \"2021-01-01\"),\n // then return as-is.\n return str;\n }\n\n try {\n // Try to normalize to UTC\n return new Date(str).toISOString();\n } catch (e) {\n // Fallback to original input\n // This happens on unsupported time formats such as \"2021-01-01T12\"\n return str;\n }\n}\n","import { ElementDefinition, Period, Quantity, Resource } from '@medplum/fhirtypes';\nimport { buildTypeName, getElementDefinition, PropertyType, TypedValue } from '../types';\nimport { capitalize, isEmpty } from '../utils';\n\n/**\n * Returns a single element array with a typed boolean value.\n * @param value The primitive boolean value.\n * @returns Single element array with a typed boolean value.\n */\nexport function booleanToTypedValue(value: boolean): [TypedValue] {\n return [{ type: PropertyType.boolean, value }];\n}\n\n/**\n * Returns a \"best guess\" TypedValue for a given value.\n * @param value The unknown value to check.\n * @returns A \"best guess\" TypedValue for the given value.\n */\nexport function toTypedValue(value: unknown): TypedValue {\n if (value === null || value === undefined) {\n return { type: 'undefined', value: undefined };\n } else if (Number.isSafeInteger(value)) {\n return { type: PropertyType.integer, value };\n } else if (typeof value === 'number') {\n return { type: PropertyType.decimal, value };\n } else if (typeof value === 'boolean') {\n return { type: PropertyType.boolean, value };\n } else if (typeof value === 'string') {\n return { type: PropertyType.string, value };\n } else if (isQuantity(value)) {\n return { type: PropertyType.Quantity, value };\n } else if (typeof value === 'object' && 'resourceType' in value) {\n return { type: (value as Resource).resourceType, value };\n } else {\n return { type: PropertyType.BackboneElement, value };\n }\n}\n\n/**\n * Converts unknown object into a JavaScript boolean.\n * Note that this is different than the FHIRPath \"toBoolean\",\n * which has particular semantics around arrays, empty arrays, and type conversions.\n * @param obj Any value or array of values.\n * @returns The converted boolean value according to FHIRPath rules.\n */\nexport function toJsBoolean(obj: TypedValue[]): boolean {\n return obj.length === 0 ? false : !!obj[0].value;\n}\n\n/**\n * Returns the value of the property and the property type.\n * Some property definitions support multiple types.\n * For example, \"Observation.value[x]\" can be \"valueString\", \"valueInteger\", \"valueQuantity\", etc.\n * According to the spec, there can only be one property for a given element definition.\n * This function returns the value and the type.\n * @param input The base context (FHIR resource or backbone element).\n * @param path The property path.\n * @returns The value of the property and the property type.\n */\nexport function getTypedPropertyValue(input: TypedValue, path: string): TypedValue[] | TypedValue | undefined {\n if (!input?.value) {\n return undefined;\n }\n\n const elementDefinition = getElementDefinition(input.type, path);\n if (elementDefinition) {\n const typedResult = getTypedPropertyValueWithSchema(input, path, elementDefinition);\n if (typedResult) {\n return typedResult;\n }\n }\n\n return getTypedPropertyValueWithoutSchema(input, path);\n}\n\n/**\n * Returns the value of the property and the property type using a type schema.\n * @param input The base context (FHIR resource or backbone element).\n * @param path The property path.\n * @param property The property element definition.\n * @returns The value of the property and the property type.\n */\nfunction getTypedPropertyValueWithSchema(\n input: TypedValue,\n path: string,\n property: ElementDefinition\n): TypedValue[] | TypedValue | undefined {\n const types = property.type;\n if (!types || types.length === 0) {\n return undefined;\n }\n\n let resultValue: any = undefined;\n let resultType = 'undefined';\n\n if (types.length === 1) {\n resultValue = input.value[path];\n resultType = types[0].code as string;\n } else {\n for (const type of types) {\n const path2 = path.replace('[x]', '') + capitalize(type.code as string);\n if (path2 in input.value) {\n resultValue = input.value[path2];\n resultType = type.code as string;\n break;\n }\n }\n }\n\n if (isEmpty(resultValue)) {\n return undefined;\n }\n\n if (resultType === 'Element' || resultType === 'BackboneElement') {\n resultType = buildTypeName(property.path?.split('.') as string[]);\n }\n\n if (Array.isArray(resultValue)) {\n return resultValue.map((element) => toTypedValueWithType(element, resultType));\n } else {\n return toTypedValueWithType(resultValue, resultType);\n }\n}\n\nfunction toTypedValueWithType(value: any, type: string): TypedValue {\n if (type === 'Resource' && typeof value === 'object' && 'resourceType' in value) {\n type = value.resourceType;\n }\n return { type, value };\n}\n\n/**\n * Returns the value of the property and the property type using a type schema.\n * Note that because the type schema is not available, this function may be inaccurate.\n * In some cases, that is the desired behavior.\n * @param typedValue The base context (FHIR resource or backbone element).\n * @param path The property path.\n * @returns The value of the property and the property type.\n */\nfunction getTypedPropertyValueWithoutSchema(\n typedValue: TypedValue,\n path: string\n): TypedValue[] | TypedValue | undefined {\n const input = typedValue.value;\n if (!input || typeof input !== 'object') {\n return undefined;\n }\n\n let result: any = undefined;\n if (path in input) {\n result = (input as { [key: string]: unknown })[path];\n } else {\n // Only support property names that would be valid types\n // Examples:\n // value + valueString = ok, because \"string\" is valid\n // value + valueDecimal = ok, because \"decimal\" is valid\n // id + identifiier = not ok, because \"entifier\" is not a valid type\n // resource + resourceType = not ok, because \"type\" is not a valid type\n for (const propertyType in PropertyType) {\n const propertyName = path + capitalize(propertyType);\n if (propertyName in input) {\n result = (input as { [key: string]: unknown })[propertyName];\n break;\n }\n }\n }\n\n if (isEmpty(result)) {\n return undefined;\n }\n\n if (Array.isArray(result)) {\n return result.map(toTypedValue);\n } else {\n return toTypedValue(result);\n }\n}\n\n/**\n * Removes duplicates in array using FHIRPath equality rules.\n * @param arr The input array.\n * @returns The result array with duplicates removed.\n */\nexport function removeDuplicates(arr: TypedValue[]): TypedValue[] {\n const result: TypedValue[] = [];\n for (const i of arr) {\n let found = false;\n for (const j of result) {\n if (toJsBoolean(fhirPathEquals(i, j))) {\n found = true;\n break;\n }\n }\n if (!found) {\n result.push(i);\n }\n }\n return result;\n}\n\n/**\n * Returns a negated FHIRPath boolean expression.\n * @param input The input array.\n * @returns The negated type value array.\n */\nexport function fhirPathNot(input: TypedValue[]): TypedValue[] {\n return booleanToTypedValue(!toJsBoolean(input));\n}\n\n/**\n * Determines if two arrays are equal according to FHIRPath equality rules.\n * @param x The first array.\n * @param y The second array.\n * @returns FHIRPath true if the arrays are equal.\n */\nexport function fhirPathArrayEquals(x: TypedValue[], y: TypedValue[]): TypedValue[] {\n if (x.length === 0 || y.length === 0) {\n return [];\n }\n if (x.length !== y.length) {\n return booleanToTypedValue(false);\n }\n return booleanToTypedValue(x.every((val, index) => toJsBoolean(fhirPathEquals(val, y[index]))));\n}\n\n/**\n * Determines if two values are equal according to FHIRPath equality rules.\n * @param x The first value.\n * @param y The second value.\n * @returns True if equal.\n */\nexport function fhirPathEquals(x: TypedValue, y: TypedValue): TypedValue[] {\n const xValue = x.value;\n const yValue = y.value;\n if (typeof xValue === 'number' && typeof yValue === 'number') {\n return booleanToTypedValue(Math.abs(xValue - yValue) < 1e-8);\n }\n if (isQuantity(xValue) && isQuantity(yValue)) {\n return booleanToTypedValue(isQuantityEquivalent(xValue, yValue));\n }\n if (typeof xValue === 'object' && typeof yValue === 'object') {\n return booleanToTypedValue(deepEquals(x, y));\n }\n return booleanToTypedValue(xValue === yValue);\n}\n\n/**\n * Determines if two arrays are equivalent according to FHIRPath equality rules.\n * @param x The first array.\n * @param y The second array.\n * @returns FHIRPath true if the arrays are equivalent.\n */\nexport function fhirPathArrayEquivalent(x: TypedValue[], y: TypedValue[]): TypedValue[] {\n if (x.length === 0 && y.length === 0) {\n return booleanToTypedValue(true);\n }\n if (x.length !== y.length) {\n return booleanToTypedValue(false);\n }\n x.sort(fhirPathEquivalentCompare);\n y.sort(fhirPathEquivalentCompare);\n return booleanToTypedValue(x.every((val, index) => toJsBoolean(fhirPathEquivalent(val, y[index]))));\n}\n\n/**\n * Determines if two values are equivalent according to FHIRPath equality rules.\n * @param x The first value.\n * @param y The second value.\n * @returns True if equivalent.\n */\nexport function fhirPathEquivalent(x: TypedValue, y: TypedValue): TypedValue[] {\n const xValue = x.value;\n const yValue = y.value;\n if (typeof xValue === 'number' && typeof yValue === 'number') {\n // Use more generous threshold than equality\n // Decimal: values must be equal, comparison is done on values rounded to the precision of the least precise operand.\n // Trailing zeroes after the decimal are ignored in determining precision.\n return booleanToTypedValue(Math.abs(xValue - yValue) < 0.01);\n }\n if (isQuantity(xValue) && isQuantity(yValue)) {\n return booleanToTypedValue(isQuantityEquivalent(xValue, yValue));\n }\n if (typeof xValue === 'object' && typeof yValue === 'object') {\n return booleanToTypedValue(deepEquals(xValue, yValue));\n }\n if (typeof xValue === 'string' && typeof yValue === 'string') {\n // String: the strings must be the same, ignoring case and locale, and normalizing whitespace\n // (see String Equivalence for more details).\n return booleanToTypedValue(xValue.toLowerCase() === yValue.toLowerCase());\n }\n return booleanToTypedValue(xValue === yValue);\n}\n\n/**\n * Returns the sort order of two values for FHIRPath array equivalence.\n * @param x The first value.\n * @param y The second value.\n * @returns The sort order of the values.\n */\nfunction fhirPathEquivalentCompare(x: TypedValue, y: TypedValue): number {\n const xValue = x.value;\n const yValue = y.value;\n if (typeof xValue === 'number' && typeof yValue === 'number') {\n return xValue - yValue;\n }\n if (typeof xValue === 'string' && typeof yValue === 'string') {\n return xValue.localeCompare(yValue);\n }\n return 0;\n}\n\n/**\n * Determines if the typed value is the desired type.\n * @param typedValue The typed value to check.\n * @param desiredType The desired type name.\n * @returns True if the typed value is of the desired type.\n */\nexport function fhirPathIs(typedValue: TypedValue, desiredType: string): boolean {\n const { value } = typedValue;\n if (value === undefined || value === null) {\n return false;\n }\n\n switch (desiredType) {\n case 'Boolean':\n return typeof value === 'boolean';\n case 'Decimal':\n case 'Integer':\n return typeof value === 'number';\n case 'Date':\n return typeof value === 'string' && !!value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/);\n case 'DateTime':\n return typeof value === 'string' && !!value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?T/);\n case 'Time':\n return typeof value === 'string' && !!value.match(/^T\\d/);\n case 'Period':\n return isPeriod(value);\n case 'Quantity':\n return isQuantity(value);\n default:\n return typeof value === 'object' && value?.resourceType === desiredType;\n }\n}\n\n/**\n * Determines if the input is a Period object.\n * This is heuristic based, as we do not have strong typing at runtime.\n * @param input The input value.\n * @returns True if the input is a period.\n */\nexport function isPeriod(input: unknown): input is Period {\n return !!(input && typeof input === 'object' && 'start' in input);\n}\n\n/**\n * Determines if the input is a Quantity object.\n * This is heuristic based, as we do not have strong typing at runtime.\n * @param input The input value.\n * @returns True if the input is a quantity.\n */\nexport function isQuantity(input: unknown): input is Quantity {\n return !!(input && typeof input === 'object' && 'value' in input && typeof (input as Quantity).value === 'number');\n}\n\nexport function isQuantityEquivalent(x: Quantity, y: Quantity): boolean {\n return (\n Math.abs((x.value as number) - (y.value as number)) < 0.01 &&\n (x.unit === y.unit || x.code === y.code || x.unit === y.code || x.code === y.unit)\n );\n}\n\n/**\n * Resource equality.\n * See: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#4-deep-equality\n * @param object1 The first object.\n * @param object2 The second object.\n * @returns True if the objects are equal.\n */\nfunction deepEquals<T1 extends object, T2 extends object>(object1: T1, object2: T2): boolean {\n const keys1 = Object.keys(object1) as (keyof T1)[];\n const keys2 = Object.keys(object2) as (keyof T2)[];\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n const val1 = object1[key] as unknown;\n const val2 = object2[key as unknown as keyof T2] as unknown;\n if (isObject(val1) && isObject(val2)) {\n if (!deepEquals(val1, val2)) {\n return false;\n }\n } else {\n if (val1 !== val2) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction isObject(obj: unknown): obj is object {\n return obj !== null && typeof obj === 'object';\n}\n","import { Reference, Resource } from '@medplum/fhirtypes';\nimport { Atom } from '../fhirlexer';\nimport { PropertyType, TypedValue } from '../types';\nimport { calculateAge } from '../utils';\nimport { DotAtom, SymbolAtom } from './atoms';\nimport { parseDateString } from './date';\nimport { booleanToTypedValue, fhirPathIs, isQuantity, removeDuplicates, toJsBoolean, toTypedValue } from './utils';\n\n/*\n * Collection of FHIRPath\n * See: https://hl7.org/fhirpath/#functions\n */\n\nexport interface FhirPathFunction {\n (input: TypedValue[], ...args: Atom[]): TypedValue[];\n}\n\n/**\n * Temporary placholder for unimplemented methods.\n */\nconst stub: FhirPathFunction = (): [] => [];\n\nexport const functions: Record<string, FhirPathFunction> = {\n /*\n * 5.1 Existence\n * See: https://hl7.org/fhirpath/#existence\n */\n\n /**\n * Returns true if the input collection is empty ({ }) and false otherwise.\n *\n * See: https://hl7.org/fhirpath/#empty-boolean\n *\n * @param input The input collection.\n * @returns True if the input collection is empty ({ }) and false otherwise.\n */\n empty: (input: TypedValue[]): TypedValue[] => {\n return booleanToTypedValue(input.length === 0);\n },\n\n /**\n * Returns true if the collection has unknown elements, and false otherwise.\n * This is the opposite of empty(), and as such is a shorthand for empty().not().\n * If the input collection is empty ({ }), the result is false.\n *\n * The function can also take an optional criteria to be applied to the collection\n * prior to the determination of the exists. In this case, the function is shorthand\n * for where(criteria).exists().\n *\n * See: https://hl7.org/fhirpath/#existscriteria-expression-boolean\n *\n * @param input\n * @param criteria\n * @returns True if the collection has unknown elements, and false otherwise.\n */\n exists: (input: TypedValue[], criteria?: Atom): TypedValue[] => {\n if (criteria) {\n return booleanToTypedValue(input.filter((e) => toJsBoolean(criteria.eval([e]))).length > 0);\n } else {\n return booleanToTypedValue(input.length > 0);\n }\n },\n\n /**\n * Returns true if for every element in the input collection, criteria evaluates to true.\n * Otherwise, the result is false.\n *\n * If the input collection is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#allcriteria-expression-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if for every element in the input collection, criteria evaluates to true.\n */\n all: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return booleanToTypedValue(input.every((e) => toJsBoolean(criteria.eval([e]))));\n },\n\n /**\n * Takes a collection of Boolean values and returns true if all the items are true.\n * If unknown items are false, the result is false.\n * If the input is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#alltrue-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if all the items are true.\n */\n allTrue: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (!value.value) {\n return booleanToTypedValue(false);\n }\n }\n return booleanToTypedValue(true);\n },\n\n /**\n * Takes a collection of Boolean values and returns true if unknown of the items are true.\n * If all the items are false, or if the input is empty ({ }), the result is false.\n *\n * See: https://hl7.org/fhirpath/#anytrue-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if unknown of the items are true.\n */\n anyTrue: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (value.value) {\n return booleanToTypedValue(true);\n }\n }\n return booleanToTypedValue(false);\n },\n\n /**\n * Takes a collection of Boolean values and returns true if all the items are false.\n * If unknown items are true, the result is false.\n * If the input is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#allfalse-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if all the items are false.\n */\n allFalse: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (value.value) {\n return booleanToTypedValue(false);\n }\n }\n return booleanToTypedValue(true);\n },\n\n /**\n * Takes a collection of Boolean values and returns true if unknown of the items are false.\n * If all the items are true, or if the input is empty ({ }), the result is false.\n *\n * See: https://hl7.org/fhirpath/#anyfalse-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if for every element in the input collection, criteria evaluates to true.\n */\n anyFalse: (input: TypedValue[]): TypedValue[] => {\n for (const value of input) {\n if (!value.value) {\n return booleanToTypedValue(true);\n }\n }\n return booleanToTypedValue(false);\n },\n\n /**\n * Returns true if all items in the input collection are members of the collection passed\n * as the other argument. Membership is determined using the = (Equals) (=) operation.\n *\n * Conceptually, this function is evaluated by testing each element in the input collection\n * for membership in the other collection, with a default of true. This means that if the\n * input collection is empty ({ }), the result is true, otherwise if the other collection\n * is empty ({ }), the result is false.\n *\n * See: http://hl7.org/fhirpath/#subsetofother-collection-boolean\n */\n subsetOf: stub,\n\n /**\n * Returns true if all items in the collection passed as the other argument are members of\n * the input collection. Membership is determined using the = (Equals) (=) operation.\n *\n * Conceptually, this function is evaluated by testing each element in the other collection\n * for membership in the input collection, with a default of true. This means that if the\n * other collection is empty ({ }), the result is true, otherwise if the input collection\n * is empty ({ }), the result is false.\n *\n * See: http://hl7.org/fhirpath/#supersetofother-collection-boolean\n */\n supersetOf: stub,\n\n /**\n * Returns the integer count of the number of items in the input collection.\n * Returns 0 when the input collection is empty.\n *\n * See: https://hl7.org/fhirpath/#count-integer\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\n count: (input: TypedValue[]): TypedValue[] => {\n return [{ type: PropertyType.integer, value: input.length }];\n },\n\n /**\n * Returns a collection containing only the unique items in the input collection.\n * To determine whether two items are the same, the = (Equals) (=) operator is used,\n * as defined below.\n *\n * If the input collection is empty ({ }), the result is empty.\n *\n * Note that the order of elements in the input collection is not guaranteed to be\n * preserved in the result.\n *\n * See: https://hl7.org/fhirpath/#distinct-collection\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\n distinct: (input: TypedValue[]): TypedValue[] => {\n const result: TypedValue[] = [];\n for (const value of input) {\n if (!result.some((e) => e.value === value.value)) {\n result.push(value);\n }\n }\n return result;\n },\n\n /**\n * Returns true if all the items in the input collection are distinct.\n * To determine whether two items are distinct, the = (Equals) (=) operator is used,\n * as defined below.\n *\n * See: https://hl7.org/fhirpath/#isdistinct-boolean\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\n isDistinct: (input: TypedValue[]): TypedValue[] => {\n return booleanToTypedValue(input.length === functions.distinct(input).length);\n },\n\n /*\n * 5.2 Filtering and projection\n */\n\n /**\n * Returns a collection containing only those elements in the input collection\n * for which the stated criteria expression evaluates to true.\n * Elements for which the expression evaluates to false or empty ({ }) are not\n * included in the result.\n *\n * If the input collection is empty ({ }), the result is empty.\n *\n * If the result of evaluating the condition is other than a single boolean value,\n * the evaluation will end and signal an error to the calling environment,\n * consistent with singleton evaluation of collections behavior.\n *\n * See: https://hl7.org/fhirpath/#wherecriteria-expression-collection\n *\n * @param input The input collection.\n * @param condition The condition atom.\n * @returns A collection containing only those elements in the input collection for which the stated criteria expression evaluates to true.\n */\n where: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return input.filter((e) => toJsBoolean(criteria.eval([e])));\n },\n\n /**\n * Evaluates the projection expression for each item in the input collection.\n * The result of each evaluation is added to the output collection. If the\n * evaluation results in a collection with multiple items, all items are added\n * to the output collection (collections resulting from evaluation of projection\n * are flattened). This means that if the evaluation for an element results in\n * the empty collection ({ }), no element is added to the result, and that if\n * the input collection is empty ({ }), the result is empty as well.\n *\n * See: http://hl7.org/fhirpath/#selectprojection-expression-collection\n */\n select: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return input.map((e) => criteria.eval([e])).flat();\n },\n\n /**\n * A version of select that will repeat the projection and add it to the output\n * collection, as long as the projection yields new items (as determined by\n * the = (Equals) (=) operator).\n *\n * See: http://hl7.org/fhirpath/#repeatprojection-expression-collection\n */\n repeat: stub,\n\n /**\n * Returns a collection that contains all items in the input collection that\n * are of the given type or a subclass thereof. If the input collection is\n * empty ({ }), the result is empty. The type argument is an identifier that\n * must resolve to the name of a type in a model\n *\n * See: http://hl7.org/fhirpath/#oftypetype-type-specifier-collection\n */\n ofType: (input: TypedValue[], criteria: Atom): TypedValue[] => {\n return input.filter((e) => e.type === (criteria as SymbolAtom).name);\n },\n\n /*\n * 5.3 Subsetting\n */\n\n /**\n * Will return the single item in the input if there is just one item.\n * If the input collection is empty ({ }), the result is empty.\n * If there are multiple items, an error is signaled to the evaluation environment.\n * This function is useful for ensuring that an error is returned if an assumption\n * about cardinality is violated at run-time.\n *\n * See: https://hl7.org/fhirpath/#single-collection\n *\n * @param input The input collection.\n * @returns The single item in the input if there is just one item.\n */\n single: (input: TypedValue[]): TypedValue[] => {\n if (input.length > 1) {\n throw new Error('Expected input length one for single()');\n }\n return input.length === 0 ? [] : input.slice(0, 1);\n },\n\n /**\n * Returns a collection containing only the first item in the input collection.\n * This function is equivalent to item[0], so it will return an empty collection if the input collection has no items.\n *\n * See: https://hl7.org/fhirpath/#first-collection\n *\n * @param input The input collection.\n * @returns A collection containing only the first item in the input collection.\n */\n first: (input: TypedValue[]): TypedValue[] => {\n return input.length === 0 ? [] : input.slice(0, 1);\n },\n\n /**\n * Returns a collection containing only the last item in the input collection.\n * Will return an empty collection if the input collection has no items.\n *\n * See: https://hl7.org/fhirpath/#last-collection\n *\n * @param input The input collection.\n * @returns A collection containing only the last item in the input collection.\n */\n last: (input: TypedValue[]): TypedValue[] => {\n return input.length === 0 ? [] : input.slice(input.length - 1, input.length);\n },\n\n /**\n * Returns a collection containing all but the first item in the input collection.\n * Will return an empty collection if the input collection has no items, or only one item.\n *\n * See: https://hl7.org/fhirpath/#tail-collection\n *\n * @param input The input collection.\n * @returns A collection containing all but the first item in the input collection.\n */\n tail: (input: TypedValue[]): TypedValue[] => {\n return input.length === 0 ? [] : input.slice(1, input.length);\n },\n\n /**\n * Returns a collection containing all but the first num items in the input collection.\n * Will return an empty collection if there are no items remaining after the\n * indicated number of items have been skipped, or if the input collection is empty.\n * If num is less than or equal to zero, the input collection is simply returned.\n *\n * See: https://hl7.org/fhirpath/#skipnum-integer-collection\n *\n * @param input The input collection.\n * @returns A collection containing all but the first item in the input collection.\n */\n skip: (input: TypedValue[], num: Atom): TypedValue[] => {\n const numValue = num.eval(input)[0]?.value;\n if (typeof numValue !== 'number') {\n throw new Error('Expected a number for skip(num)');\n }\n if (numValue >= input.length) {\n return [];\n }\n if (numValue <= 0) {\n return input;\n }\n return input.slice(numValue, input.length);\n },\n\n /**\n * Returns a collection containing the first num items in the input collection,\n * or less if there are less than num items.\n * If num is less than or equal to 0, or if the input collection is empty ({ }),\n * take returns an empty collection.\n *\n * See: https://hl7.org/fhirpath/#takenum-integer-collection\n *\n * @param input The input collection.\n * @returns A collection containing the first num items in the input collection.\n */\n take: (input: TypedValue[], num: Atom): TypedValue[] => {\n const numValue = num.eval(input)[0]?.value;\n if (typeof numValue !== 'number') {\n throw new Error('Expected a number for take(num)');\n }\n if (numValue >= input.length) {\n return input;\n }\n if (numValue <= 0) {\n return [];\n }\n return input.slice(0, numValue);\n },\n\n /**\n * Returns the set of elements that are in both collections.\n * Duplicate items will be eliminated by this function.\n * Order of items is not guaranteed to be preserved in the result of this function.\n *\n * See: http://hl7.org/fhirpath/#intersectother-collection-collection\n */\n intersect: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n const result: TypedValue[] = [];\n for (const value of input) {\n if (!result.some((e) => e.value === value.value) && otherArray.some((e) => e.value === value.value)) {\n result.push(value);\n }\n }\n return result;\n },\n\n /**\n * Returns the set of elements that are not in the other collection.\n * Duplicate items will not be eliminated by this function, and order will be preserved.\n *\n * e.g. (1 | 2 | 3).exclude(2) returns (1 | 3).\n *\n * See: http://hl7.org/fhirpath/#excludeother-collection-collection\n */\n exclude: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n const result: TypedValue[] = [];\n for (const value of input) {\n if (!otherArray.some((e) => e.value === value.value)) {\n result.push(value);\n }\n }\n return result;\n },\n\n /*\n * 5.4. Combining\n *\n * See: https://hl7.org/fhirpath/#combining\n */\n\n /**\n * Merge the two collections into a single collection,\n * eliminating unknown duplicate values (using = (Equals) (=) to determine equality).\n * There is no expectation of order in the resulting collection.\n *\n * In other words, this function returns the distinct list of elements from both inputs.\n *\n * See: http://hl7.org/fhirpath/#unionother-collection\n */\n union: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n return removeDuplicates([...input, ...otherArray]);\n },\n\n /**\n * Merge the input and other collections into a single collection\n * without eliminating duplicate values. Combining an empty collection\n * with a non-empty collection will return the non-empty collection.\n *\n * There is no expectation of order in the resulting collection.\n *\n * See: http://hl7.org/fhirpath/#combineother-collection-collection\n */\n combine: (input: TypedValue[], other: Atom): TypedValue[] => {\n if (!other) {\n return input;\n }\n const otherArray = other.eval(input);\n return [...input, ...otherArray];\n },\n\n /*\n * 5.5. Conversion\n *\n * See: https://hl7.org/fhirpath/#conversion\n */\n\n /**\n * The iif function in FHIRPath is an immediate if,\n * also known as a conditional operator (such as C’s ? : operator).\n *\n * The criterion expression is expected to evaluate to a Boolean.\n *\n * If criterion is true, the function returns the value of the true-result argument.\n *\n * If criterion is false or an empty collection, the function returns otherwise-result,\n * unless the optional otherwise-result is not given, in which case the function returns an empty collection.\n *\n * Note that short-circuit behavior is expected in this function. In other words,\n * true-result should only be evaluated if the criterion evaluates to true,\n * and otherwise-result should only be evaluated otherwise. For implementations,\n * this means delaying evaluation of the arguments.\n *\n * @param input\n * @param criterion\n * @param trueResult\n * @param otherwiseResult\n * @returns\n */\n iif: (input: TypedValue[], criterion: Atom, trueResult: Atom, otherwiseResult?: Atom): TypedValue[] => {\n const evalResult = criterion.eval(input);\n if (evalResult.length > 1 || (evalResult.length === 1 && typeof evalResult[0].value !== 'boolean')) {\n throw new Error('Expected criterion to evaluate to a Boolean');\n }\n\n if (toJsBoolean(evalResult)) {\n return trueResult.eval(input);\n }\n\n if (otherwiseResult) {\n return otherwiseResult.eval(input);\n }\n\n return [];\n },\n\n /**\n * Converts an input collection to a boolean.\n *\n * If the input collection contains a single item, this function will return a single boolean if:\n * 1) the item is a Boolean\n * 2) the item is an Integer and is equal to one of the possible integer representations of Boolean values\n * 3) the item is a Decimal that is equal to one of the possible decimal representations of Boolean values\n * 4) the item is a String that is equal to one of the possible string representations of Boolean values\n *\n * If the item is not one the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#toboolean-boolean\n *\n * @param input\n * @returns\n */\n toBoolean: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.boolean, value }];\n }\n if (typeof value === 'number') {\n if (value === 0 || value === 1) {\n return booleanToTypedValue(!!value);\n }\n }\n if (typeof value === 'string') {\n const lowerStr = value.toLowerCase();\n if (['true', 't', 'yes', 'y', '1', '1.0'].includes(lowerStr)) {\n return booleanToTypedValue(true);\n }\n if (['false', 'f', 'no', 'n', '0', '0.0'].includes(lowerStr)) {\n return booleanToTypedValue(false);\n }\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Boolean\n * 2) the item is an Integer that is equal to one of the possible integer representations of Boolean values\n * 3) the item is a Decimal that is equal to one of the possible decimal representations of Boolean values\n * 4) the item is a String that is equal to one of the possible string representations of Boolean values\n *\n * If the item is not one of the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is false.\n *\n * Possible values for Integer, Decimal, and String are described in the toBoolean() function.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: http://hl7.org/fhirpath/#convertstoboolean-boolean\n *\n * @param input\n * @returns\n */\n convertsToBoolean: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toBoolean(input).length === 1);\n },\n\n /**\n * Returns the integer representation of the input.\n *\n * If the input collection contains a single item, this function will return a single integer if:\n * 1) the item is an Integer\n * 2) the item is a String and is convertible to an integer\n * 3) the item is a Boolean, where true results in a 1 and false results in a 0.\n *\n * If the item is not one the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to an integer (using the regex format (\\\\+|-)?\\d+), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tointeger-integer\n *\n * @param input The input collection.\n * @returns The string representation of the input.\n */\n toInteger: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'number') {\n return [{ type: PropertyType.integer, value }];\n }\n if (typeof value === 'string' && value.match(/^[+-]?\\d+$/)) {\n return [{ type: PropertyType.integer, value: parseInt(value, 10) }];\n }\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.integer, value: value ? 1 : 0 }];\n }\n return [];\n },\n\n /**\n * Returns true if the input can be converted to string.\n *\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is an Integer\n * 2) the item is a String and is convertible to an Integer\n * 3) the item is a Boolean\n * 4) If the item is not one of the above types, or the item is a String, but is not convertible to an Integer (using the regex format (\\\\+|-)?\\d+), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstointeger-boolean\n *\n * @param input The input collection.\n * @returns\n */\n convertsToInteger: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toInteger(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single date if:\n * 1) the item is a Date\n * 2) the item is a DateTime\n * 3) the item is a String and is convertible to a Date\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Date (using the format YYYY-MM-DD), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#todate-date\n */\n toDate: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'string' && value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/)) {\n return [{ type: PropertyType.date, value: parseDateString(value) }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Date\n * 2) the item is a DateTime\n * 3) the item is a String and is convertible to a Date\n *\n * If the item is not one of the above types, or is not convertible to a Date (using the format YYYY-MM-DD), the result is false.\n *\n * If the item contains a partial date (e.g. '2012-01'), the result is a partial date.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstodate-boolean\n */\n convertsToDate: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toDate(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single datetime if:\n * 1) the item is a DateTime\n * 2) the item is a Date, in which case the result is a DateTime with the year, month, and day of the Date, and the time components empty (not set to zero)\n * 3) the item is a String and is convertible to a DateTime\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is empty.\n *\n * If the item contains a partial datetime (e.g. '2012-01-01T10:00'), the result is a partial datetime.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n\n * See: https://hl7.org/fhirpath/#todatetime-datetime\n *\n * @param input\n * @returns\n */\n toDateTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'string' && value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/)) {\n return [{ type: PropertyType.dateTime, value: parseDateString(value) }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a DateTime\n * 2) the item is a Date\n * 3) the item is a String and is convertible to a DateTime\n *\n * If the item is not one of the above types, or is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstodatetime-boolean\n *\n * @param input\n * @returns\n */\n convertsToDateTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toDateTime(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single decimal if:\n * 1) the item is an Integer or Decimal\n * 2) the item is a String and is convertible to a Decimal\n * 3) the item is a Boolean, where true results in a 1.0 and false results in a 0.0.\n * 4) If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Decimal (using the regex format (\\\\+|-)?\\d+(\\.\\d+)?), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#decimal-conversion-functions\n *\n * @param input The input collection.\n * @returns\n */\n toDecimal: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'number') {\n return [{ type: PropertyType.decimal, value }];\n }\n if (typeof value === 'string' && value.match(/^-?\\d{1,9}(\\.\\d{1,9})?$/)) {\n return [{ type: PropertyType.decimal, value: parseFloat(value) }];\n }\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.decimal, value: value ? 1 : 0 }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will true if:\n * 1) the item is an Integer or Decimal\n * 2) the item is a String and is convertible to a Decimal\n * 3) the item is a Boolean\n *\n * If the item is not one of the above types, or is not convertible to a Decimal (using the regex format (\\\\+|-)?\\d+(\\.\\d+)?), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n\n * See: https://hl7.org/fhirpath/#convertstodecimal-boolean\n *\n * @param input The input collection.\n * @returns\n */\n convertsToDecimal: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toDecimal(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single quantity if:\n * 1) the item is an Integer, or Decimal, where the resulting quantity will have the default unit ('1')\n * 2) the item is a Quantity\n * 3) the item is a String and is convertible to a Quantity\n * 4) the item is a Boolean, where true results in the quantity 1.0 '1', and false results in the quantity 0.0 '1'\n *\n * If the item is not one of the above types, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#quantity-conversion-functions\n *\n * @param input The input collection.\n * @returns\n */\n toQuantity: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (isQuantity(value)) {\n return [{ type: PropertyType.Quantity, value }];\n }\n if (typeof value === 'number') {\n return [{ type: PropertyType.Quantity, value: { value, unit: '1' } }];\n }\n if (typeof value === 'string' && value.match(/^-?\\d{1,9}(\\.\\d{1,9})?/)) {\n return [{ type: PropertyType.Quantity, value: { value: parseFloat(value), unit: '1' } }];\n }\n if (typeof value === 'boolean') {\n return [{ type: PropertyType.Quantity, value: { value: value ? 1 : 0, unit: '1' } }];\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is an Integer, Decimal, or Quantity\n * 2) the item is a String that is convertible to a Quantity\n * 3) the item is a Boolean\n *\n * If the item is not one of the above types, or is not convertible to a Quantity using the following regex format:\n *\n * (?'value'(\\+|-)?\\d+(\\.\\d+)?)\\s*('(?'unit'[^']+)'|(?'time'[a-zA-Z]+))?\n *\n * then the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the unit argument is provided, it must be the string representation of a UCUM code (or a FHIRPath calendar duration keyword), and is used to determine whether the input quantity can be converted to the given unit, according to the unit conversion rules specified by UCUM. If the input quantity can be converted, the result is true, otherwise, the result is false.\n *\n * See: https://hl7.org/fhirpath/#convertstoquantityunit-string-boolean\n *\n * @param input The input collection.\n * @returns\n */\n convertsToQuantity: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toQuantity(input).length === 1);\n },\n\n /**\n * Returns the string representation of the input.\n *\n * If the input collection contains a single item, this function will return a single String if:\n *\n * 1) the item in the input collection is a String\n * 2) the item in the input collection is an Integer, Decimal, Date, Time, DateTime, or Quantity the output will contain its String representation\n * 3) the item is a Boolean, where true results in 'true' and false in 'false'.\n *\n * If the item is not one of the above types, the result is false.\n *\n * See: https://hl7.org/fhirpath/#tostring-string\n *\n * @param input The input collection.\n * @returns The string representation of the input.\n */\n toString: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (value === null || value === undefined) {\n return [];\n }\n if (isQuantity(value)) {\n return [{ type: PropertyType.string, value: `${value.value} '${value.unit}'` }];\n }\n return [{ type: PropertyType.string, value: (value as boolean | number | string).toString() }];\n },\n\n /**\n * Returns true if the input can be converted to string.\n *\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a String\n * 2) the item is an Integer, Decimal, Date, Time, or DateTime\n * 3) the item is a Boolean\n * 4) the item is a Quantity\n *\n * If the item is not one of the above types, the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tostring-string\n *\n * @param input The input collection.\n * @returns\n */\n convertsToString: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue((functions.toString as unknown as FhirPathFunction)(input).length === 1);\n },\n\n /**\n * If the input collection contains a single item, this function will return a single time if:\n * 1) the item is a Time\n * 2) the item is a String and is convertible to a Time\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Time (using the format hh:mm:ss.fff(+|-)hh:mm), the result is empty.\n *\n * If the item contains a partial time (e.g. '10:00'), the result is a partial time.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#totime-time\n *\n * @param input\n * @returns\n */\n toTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value === 'string') {\n const match = value.match(/^T?(\\d{2}(:\\d{2}(:\\d{2})?)?)/);\n if (match) {\n return [{ type: PropertyType.time, value: parseDateString('T' + match[1]) }];\n }\n }\n return [];\n },\n\n /**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Time\n * 2) the item is a String and is convertible to a Time\n *\n * If the item is not one of the above types, or is not convertible to a Time (using the format hh:mm:ss.fff(+|-)hh:mm), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstotime-boolean\n *\n * @param input\n * @returns\n */\n convertsToTime: (input: TypedValue[]): TypedValue[] => {\n if (input.length === 0) {\n return [];\n }\n return booleanToTypedValue(functions.toTime(input).length === 1);\n },\n\n /*\n * 5.6. String Manipulation.\n *\n * See: https://hl7.org/fhirpath/#string-manipulation\n */\n\n /**\n * Returns the 0-based index of the first position substring is found in the input string, or -1 if it is not found.\n *\n * If substring is an empty string (''), the function returns 0.\n *\n * If the input or substring is empty ({ }), the result is empty ({ }).\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#indexofsubstring-string-integer\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n indexOf: (input: TypedValue[], substringAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, substring) => str.indexOf(substring as string), input, substringAtom);\n },\n\n /**\n * Returns the part of the string starting at position start (zero-based). If length is given, will return at most length number of characters from the input string.\n *\n * If start lies outside the length of the string, the function returns empty ({ }). If there are less remaining characters in the string than indicated by length, the function returns just the remaining characters.\n *\n * If the input or start is empty, the result is empty.\n *\n * If an empty length is provided, the behavior is the same as if length had not been provided.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n substring: (input: TypedValue[], startAtom: Atom, lengthAtom?: Atom): TypedValue[] => {\n return applyStringFunc(\n (str, start, length) => {\n const startIndex = start as number;\n const endIndex = length ? startIndex + (length as number) : str.length;\n return startIndex < 0 || startIndex >= str.length ? undefined : str.substring(startIndex, endIndex);\n },\n input,\n startAtom,\n lengthAtom\n );\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n startsWith: (input: TypedValue[], prefixAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, prefix) => str.startsWith(prefix as string), input, prefixAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n endsWith: (input: TypedValue[], suffixAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, suffix) => str.endsWith(suffix as string), input, suffixAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n contains: (input: TypedValue[], substringAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, substring) => str.includes(substring as string), input, substringAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n upper: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => str.toUpperCase(), input);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n lower: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => str.toLowerCase(), input);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n replace: (input: TypedValue[], patternAtom: Atom, substitionAtom: Atom): TypedValue[] => {\n return applyStringFunc(\n (str, pattern, substition) => str.replaceAll(pattern as string, substition as string),\n input,\n patternAtom,\n substitionAtom\n );\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n matches: (input: TypedValue[], regexAtom: Atom): TypedValue[] => {\n return applyStringFunc((str, regex) => !!str.match(regex as string), input, regexAtom);\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n replaceMatches: (input: TypedValue[], regexAtom: Atom, substitionAtom: Atom): TypedValue[] => {\n return applyStringFunc(\n (str, pattern, substition) => str.replaceAll(pattern as string, substition as string),\n input,\n regexAtom,\n substitionAtom\n );\n },\n\n /**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\n length: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => str.length, input);\n },\n\n /**\n * Returns the list of characters in the input string. If the input collection is empty ({ }), the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tochars-collection\n *\n * @param input The input collection.\n */\n toChars: (input: TypedValue[]): TypedValue[] => {\n return applyStringFunc((str) => (str ? str.split('') : undefined), input);\n },\n\n /*\n * 5.7. Math\n */\n\n /**\n * Returns the absolute value of the input. When taking the absolute value of a quantity, the unit is unchanged.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#abs-integer-decimal-quantity\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n abs: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.abs, input);\n },\n\n /**\n * Returns the first integer greater than or equal to the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#ceiling-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n ceiling: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.ceil, input);\n },\n\n /**\n * Returns e raised to the power of the input.\n *\n * If the input collection contains an Integer, it will be implicitly converted to a Decimal and the result will be a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#exp-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n exp: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.exp, input);\n },\n\n /**\n * Returns the first integer less than or equal to the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#floor-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n floor: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.floor, input);\n },\n\n /**\n * Returns the natural logarithm of the input (i.e. the logarithm base e).\n *\n * When used with an Integer, it will be implicitly converted to a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#ln-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n ln: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.log, input);\n },\n\n /**\n * Returns the logarithm base base of the input number.\n *\n * When used with Integers, the arguments will be implicitly converted to Decimal.\n *\n * If base is empty, the result is empty.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#logbase-decimal-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n log: (input: TypedValue[], baseAtom: Atom): TypedValue[] => {\n return applyMathFunc((value, base) => Math.log(value) / Math.log(base as number), input, baseAtom);\n },\n\n /**\n * Raises a number to the exponent power. If this function is used with Integers, the result is an Integer. If the function is used with Decimals, the result is a Decimal. If the function is used with a mixture of Integer and Decimal, the Integer is implicitly converted to a Decimal and the result is a Decimal.\n *\n * If the power cannot be represented (such as the -1 raised to the 0.5), the result is empty.\n *\n * If the input is empty, or exponent is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#powerexponent-integer-decimal-integer-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n power: (input: TypedValue[], expAtom: Atom): TypedValue[] => {\n return applyMathFunc(Math.pow as (x: number, ...args: unknown[]) => number, input, expAtom);\n },\n\n /**\n * Rounds the decimal to the nearest whole number using a traditional round (i.e. 0.5 or higher will round to 1). If specified, the precision argument determines the decimal place at which the rounding will occur. If not specified, the rounding will default to 0 decimal places.\n *\n * If specified, the number of digits of precision must be >= 0 or the evaluation will end and signal an error to the calling environment.\n *\n * If the input collection contains a single item of type Integer, it will be implicitly converted to a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#roundprecision-integer-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n round: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.round, input);\n },\n\n /**\n * Returns the square root of the input number as a Decimal.\n *\n * If the square root cannot be represented (such as the square root of -1), the result is empty.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * Note that this function is equivalent to raising a number of the power of 0.5 using the power() function.\n *\n * See: https://hl7.org/fhirpath/#sqrt-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n sqrt: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc(Math.sqrt, input);\n },\n\n /**\n * Returns the integer portion of the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#truncate-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\n truncate: (input: TypedValue[]): TypedValue[] => {\n return applyMathFunc((x) => x | 0, input);\n },\n\n /*\n * 5.8. Tree navigation\n */\n\n children: stub,\n\n descendants: stub,\n\n /*\n * 5.9. Utility functions\n */\n\n /**\n * Adds a String representation of the input collection to the diagnostic log,\n * using the name argument as the name in the log. This log should be made available\n * to the user in some appropriate fashion. Does not change the input, so returns\n * the input collection as output.\n *\n * If the projection argument is used, the trace would log the result of evaluating\n * the project expression on the input, but still return the input to the trace\n * function unchanged.\n *\n * See: https://hl7.org/fhirpath/#tracename-string-projection-expression-collection\n *\n * @param input The input collection.\n * @param nameAtom The log name.\n */\n trace: (input: TypedValue[], nameAtom: Atom): TypedValue[] => {\n console.log('trace', input, nameAtom);\n return input;\n },\n\n /**\n * Returns the current date and time, including timezone offset.\n *\n * See: https://hl7.org/fhirpath/#now-datetime\n */\n now: (): TypedValue[] => {\n return [{ type: PropertyType.dateTime, value: new Date().toISOString() }];\n },\n\n /**\n * Returns the current time.\n *\n * See: https://hl7.org/fhirpath/#timeofday-time\n */\n timeOfDay: (): TypedValue[] => {\n return [{ type: PropertyType.time, value: new Date().toISOString().substring(11) }];\n },\n\n /**\n * Returns the current date.\n *\n * See: https://hl7.org/fhirpath/#today-date\n */\n today: (): TypedValue[] => {\n return [{ type: PropertyType.date, value: new Date().toISOString().substring(0, 10) }];\n },\n\n /**\n * Calculates the difference between two dates or date/times.\n *\n * This is not part of the official FHIRPath spec.\n *\n * IBM FHIR issue: https://github.com/IBM/FHIR/issues/1014\n * IBM FHIR PR: https://github.com/IBM/FHIR/pull/1023\n */\n between: (input: TypedValue[], startAtom: Atom, endAtom: Atom, unitsAtom: Atom): TypedValue[] => {\n const startDate = functions.toDateTime(startAtom.eval(input));\n if (startDate.length === 0) {\n throw new Error('Invalid start date');\n }\n const endDate = functions.toDateTime(endAtom.eval(input));\n if (endDate.length === 0) {\n throw new Error('Invalid end date');\n }\n const unit = unitsAtom.eval(input)[0]?.value as string;\n if (unit !== 'years' && unit !== 'months' && unit !== 'days') {\n throw new Error('Invalid units');\n }\n const age = calculateAge(startDate[0].value, endDate[0].value);\n return [{ type: PropertyType.Quantity, value: { value: age[unit], unit } }];\n },\n\n /*\n * 6.3 Types\n */\n\n /**\n * The is() function is supported for backwards compatibility with previous\n * implementations of FHIRPath. Just as with the is keyword, the type argument\n * is an identifier that must resolve to the name of a type in a model.\n *\n * For implementations with compile-time typing, this requires special-case\n * handling when processing the argument to treat it as a type specifier rather\n * than an identifier expression:\n *\n * @param input\n * @param typeAtom\n * @returns\n */\n is: (input: TypedValue[], typeAtom: Atom): TypedValue[] => {\n let typeName = '';\n if (typeAtom instanceof SymbolAtom) {\n typeName = typeAtom.name;\n } else if (typeAtom instanceof DotAtom) {\n typeName = (typeAtom.left as SymbolAtom).name + '.' + (typeAtom.right as SymbolAtom).name;\n }\n if (!typeName) {\n return [];\n }\n return input.map((value) => ({ type: PropertyType.boolean, value: fhirPathIs(value, typeName) }));\n },\n\n /*\n * 6.5 Boolean logic\n */\n\n /**\n * 6.5.3. not() : Boolean\n *\n * Returns true if the input collection evaluates to false, and false if it evaluates to true. Otherwise, the result is empty ({ }):\n *\n * @param input\n * @returns\n */\n not: (input: TypedValue[]): TypedValue[] => {\n return functions.toBoolean(input).map((value) => ({ type: PropertyType.boolean, value: !value.value }));\n },\n\n /*\n * Additional functions\n * See: https://hl7.org/fhir/fhirpath.html#functions\n */\n\n /**\n * For each item in the collection, if it is a string that is a uri (or canonical or url), locate the target of the reference, and add it to the resulting collection. If the item does not resolve to a resource, the item is ignored and nothing is added to the output collection.\n * The items in the collection may also represent a Reference, in which case the Reference.reference is resolved.\n * @param input The input collection.\n * @returns\n */\n resolve: (input: TypedValue[]): TypedValue[] => {\n return input\n .map((e) => {\n const value = e.value;\n let refStr: string | undefined;\n if (typeof value === 'string') {\n refStr = value;\n } else if (typeof value === 'object') {\n const ref = value as Reference;\n if (ref.resource) {\n return toTypedValue(ref.resource);\n }\n refStr = ref.reference;\n }\n if (!refStr) {\n return { type: PropertyType.BackboneElement, value: null };\n }\n const [resourceType, id] = refStr.split('/');\n return { type: PropertyType.BackboneElement, value: { resourceType, id } };\n })\n .filter((e) => !!e.value);\n },\n\n /**\n * The as operator can be used to treat a value as a specific type.\n * @param input The input value.\n * @returns The value as the specific type.\n */\n as: (input: TypedValue[]): TypedValue[] => {\n return input;\n },\n\n /*\n * 12. Formal Specifications\n */\n\n /**\n * Returns the type of the input.\n *\n * 12.2. Model Information\n *\n * The model information returned by the reflection function type() is specified as an\n * XML Schema document (xsd) and included in this specification at the following link:\n * https://hl7.org/fhirpath/modelinfo.xsd\n *\n * See: https://hl7.org/fhirpath/#model-information\n *\n * @param input The input collection.\n * @returns\n */\n type: (input: TypedValue[]): TypedValue[] => {\n return input.map(({ value }) => {\n if (typeof value === 'boolean') {\n return { type: PropertyType.BackboneElement, value: { namespace: 'System', name: 'Boolean' } };\n }\n if (typeof value === 'number') {\n return { type: PropertyType.BackboneElement, value: { namespace: 'System', name: 'Integer' } };\n }\n if (value && typeof value === 'object' && 'resourceType' in value) {\n return {\n type: PropertyType.BackboneElement,\n value: { namespace: 'FHIR', name: (value as Resource).resourceType },\n };\n }\n return { type: PropertyType.BackboneElement, value: null };\n });\n },\n\n conformsTo: (input: TypedValue[], systemAtom: Atom): TypedValue[] => {\n const system = systemAtom.eval(input)[0].value as string;\n if (!system.startsWith('http://hl7.org/fhir/StructureDefinition/')) {\n throw new Error('Expected a StructureDefinition URL');\n }\n const expectedResourceType = system.replace('http://hl7.org/fhir/StructureDefinition/', '');\n return input.map((value) => ({\n type: PropertyType.boolean,\n value: value.value?.resourceType === expectedResourceType,\n }));\n },\n};\n\n/*\n * Helper utilities\n */\n\nfunction applyStringFunc<T>(\n func: (str: string, ...args: unknown[]) => T | undefined,\n input: TypedValue[],\n ...argsAtoms: (Atom | undefined)[]\n): TypedValue[] {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n if (typeof value !== 'string') {\n throw new Error('String function cannot be called with non-string');\n }\n const result = func(value, ...argsAtoms.map((atom) => atom && atom.eval(input)?.[0]?.value));\n if (result === undefined) {\n return [];\n }\n if (Array.isArray(result)) {\n return result.map(toTypedValue);\n }\n return [toTypedValue(result)];\n}\n\nfunction applyMathFunc(\n func: (x: number, ...args: unknown[]) => number,\n input: TypedValue[],\n ...argsAtoms: Atom[]\n): TypedValue[] {\n if (input.length === 0) {\n return [];\n }\n const [{ value }] = validateInput(input, 1);\n const quantity = isQuantity(value);\n const numberInput = quantity ? value.value : value;\n if (typeof numberInput !== 'number') {\n throw new Error('Math function cannot be called with non-number');\n }\n const result = func(numberInput, ...argsAtoms.map((atom) => atom.eval(input)?.[0]?.value));\n const type = quantity ? PropertyType.Quantity : input[0].type;\n const returnValue = quantity ? { ...value, value: result } : result;\n return [{ type, value: returnValue }];\n}\n\nfunction validateInput(input: TypedValue[], count: number): TypedValue[] {\n if (input.length !== count) {\n throw new Error(`Expected ${count} arguments`);\n }\n for (const element of input) {\n if (element === null || element === undefined) {\n throw new Error('Expected non-null argument');\n }\n }\n return input;\n}\n","import { Resource } from '@medplum/fhirtypes';\nimport { Atom, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer';\nimport { PropertyType, TypedValue } from '../types';\nimport { functions } from './functions';\nimport {\n booleanToTypedValue,\n fhirPathArrayEquals,\n fhirPathArrayEquivalent,\n fhirPathIs,\n fhirPathNot,\n getTypedPropertyValue,\n isQuantity,\n removeDuplicates,\n toJsBoolean,\n toTypedValue,\n} from './utils';\n\nexport class FhirPathAtom implements Atom {\n constructor(public readonly original: string, public readonly child: Atom) {}\n\n eval(context: TypedValue[]): TypedValue[] {\n try {\n if (context.length > 0) {\n return context.map((e) => this.child.eval([e])).flat();\n } else {\n return this.child.eval([]);\n }\n } catch (error) {\n throw new Error(`FhirPathError on \"${this.original}\": ${error}`);\n }\n }\n\n toString(): string {\n return this.child.toString();\n }\n}\n\nexport class LiteralAtom implements Atom {\n constructor(public readonly value: TypedValue) {}\n eval(): TypedValue[] {\n return [this.value];\n }\n\n toString(): string {\n const value = this.value.value;\n if (typeof value === 'string') {\n return `'${value}'`;\n }\n return value.toString();\n }\n}\n\nexport class SymbolAtom implements Atom {\n constructor(public readonly name: string) {}\n eval(context: TypedValue[]): TypedValue[] {\n if (this.name === '$this') {\n return context;\n }\n return context\n .map((e) => this.#evalValue(e))\n .flat()\n .filter((e) => e?.value !== undefined) as TypedValue[];\n }\n\n #evalValue(typedValue: TypedValue): TypedValue[] | TypedValue | undefined {\n const input = typedValue.value;\n if (!input || typeof input !== 'object') {\n return undefined;\n }\n\n if ('resourceType' in input && (input as Resource).resourceType === this.name) {\n return typedValue;\n }\n\n return getTypedPropertyValue(typedValue, this.name);\n }\n\n toString(): string {\n return this.name;\n }\n}\n\nexport class EmptySetAtom implements Atom {\n eval(): [] {\n return [];\n }\n\n toString(): string {\n return '{}';\n }\n}\n\nexport class UnaryOperatorAtom extends PrefixOperatorAtom {\n constructor(operator: string, child: Atom, public readonly impl: (x: TypedValue[]) => TypedValue[]) {\n super(operator, child);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return this.impl(this.child.eval(context));\n }\n\n toString(): string {\n return this.child.toString();\n }\n}\n\nexport class AsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('as', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return functions.ofType(this.left.eval(context), this.right);\n }\n}\n\nexport class ArithemticOperatorAtom extends InfixOperatorAtom {\n constructor(\n operator: string,\n left: Atom,\n right: Atom,\n public readonly impl: (x: number, y: number) => number | boolean\n ) {\n super(operator, left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftEvalResult = this.left.eval(context);\n if (leftEvalResult.length !== 1) {\n return [];\n }\n const rightEvalResult = this.right.eval(context);\n if (rightEvalResult.length !== 1) {\n return [];\n }\n const leftValue = leftEvalResult[0].value;\n const rightValue = rightEvalResult[0].value;\n const leftNumber = isQuantity(leftValue) ? leftValue.value : leftValue;\n const rightNumber = isQuantity(rightValue) ? rightValue.value : rightValue;\n const result = this.impl(leftNumber, rightNumber);\n if (typeof result === 'boolean') {\n return booleanToTypedValue(result);\n } else if (isQuantity(leftValue)) {\n return [{ type: PropertyType.Quantity, value: { ...leftValue, value: result } }];\n } else {\n return [toTypedValue(result)];\n }\n }\n}\n\nexport class ConcatAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('&', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n const result = [...leftValue, ...rightValue];\n if (result.length > 0 && result.every((e) => typeof e.value === 'string')) {\n return [{ type: PropertyType.string, value: result.map((e) => e.value as string).join('') }];\n }\n return result;\n }\n}\n\nexport class ContainsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('contains', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return booleanToTypedValue(leftValue.some((e) => e.value === rightValue[0].value));\n }\n}\n\nexport class InAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('in', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return booleanToTypedValue(rightValue.some((e) => e.value === leftValue[0].value));\n }\n}\n\nexport class DotAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('.', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return this.right.eval(this.left.eval(context));\n }\n\n toString(): string {\n return `${this.left.toString()}.${this.right.toString()}`;\n }\n}\n\nexport class UnionAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('|', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftResult = this.left.eval(context);\n const rightResult = this.right.eval(context);\n return removeDuplicates([...leftResult, ...rightResult]);\n }\n}\n\nexport class EqualsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('=', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathArrayEquals(leftValue, rightValue);\n }\n}\n\nexport class NotEqualsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('!=', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathNot(fhirPathArrayEquals(leftValue, rightValue));\n }\n}\n\nexport class EquivalentAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('~', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathArrayEquivalent(leftValue, rightValue);\n }\n}\n\nexport class NotEquivalentAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('!~', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathNot(fhirPathArrayEquivalent(leftValue, rightValue));\n }\n}\n\nexport class IsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('is', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n if (leftValue.length !== 1) {\n return [];\n }\n const typeName = (this.right as SymbolAtom).name;\n return booleanToTypedValue(fhirPathIs(leftValue[0], typeName));\n }\n}\n\n/**\n * 6.5.1. and\n * Returns true if both operands evaluate to true,\n * false if either operand evaluates to false,\n * and the empty collection otherwise.\n */\nexport class AndAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('and', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (leftValue[0]?.value === true && rightValue[0]?.value === true) {\n return booleanToTypedValue(true);\n }\n if (leftValue[0]?.value === false || rightValue[0]?.value === false) {\n return booleanToTypedValue(false);\n }\n return [];\n }\n}\n\nexport class OrAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('or', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n if (toJsBoolean(leftValue)) {\n return leftValue;\n }\n\n const rightValue = this.right.eval(context);\n if (toJsBoolean(rightValue)) {\n return rightValue;\n }\n\n return [];\n }\n}\n\n/**\n * 6.5.4. xor\n * Returns true if exactly one of the operands evaluates to true,\n * false if either both operands evaluate to true or both operands evaluate to false,\n * and the empty collection otherwise.\n */\nexport class XorAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('xor', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftResult = this.left.eval(context);\n const rightResult = this.right.eval(context);\n if (leftResult.length === 0 && rightResult.length === 0) {\n return [];\n }\n const leftValue = leftResult.length === 0 ? null : leftResult[0].value;\n const rightValue = rightResult.length === 0 ? null : rightResult[0].value;\n if ((leftValue === true && rightValue !== true) || (leftValue !== true && rightValue === true)) {\n return booleanToTypedValue(true);\n }\n if ((leftValue === true && rightValue === true) || (leftValue === false && rightValue === false)) {\n return booleanToTypedValue(false);\n }\n return [];\n }\n}\n\nexport class FunctionAtom implements Atom {\n constructor(public readonly name: string, public readonly args: Atom[]) {}\n eval(context: TypedValue[]): TypedValue[] {\n const impl = functions[this.name];\n if (!impl) {\n throw new Error('Unrecognized function: ' + this.name);\n }\n return impl(context, ...this.args);\n }\n\n toString(): string {\n return `${this.name}(${this.args.map((arg) => arg.toString()).join(', ')})`;\n }\n}\n\nexport class IndexerAtom implements Atom {\n constructor(public readonly left: Atom, public readonly expr: Atom) {}\n eval(context: TypedValue[]): TypedValue[] {\n const evalResult = this.expr.eval(context);\n if (evalResult.length !== 1) {\n return [];\n }\n const index = evalResult[0].value;\n if (typeof index !== 'number') {\n throw new Error(`Invalid indexer expression: should return integer}`);\n }\n const leftResult = this.left.eval(context);\n if (!(index in leftResult)) {\n return [];\n }\n return [leftResult[index]];\n }\n\n toString(): string {\n return `${this.left.toString()}[${this.expr.toString()}]`;\n }\n}\n","import { Token, Tokenizer } from '../fhirlexer';\n\nexport const FHIRPATH_KEYWORDS = ['true', 'false'];\nexport const FHIRPATH_OPERATORS = ['!=', '!~', '<=', '>=', '{}', '->'];\n\nexport function tokenize(str: string): Token[] {\n return new Tokenizer(str, FHIRPATH_KEYWORDS, FHIRPATH_OPERATORS).tokenize();\n}\n","import { Quantity } from '@medplum/fhirtypes';\nimport { Atom, InfixParselet, Parser, ParserBuilder, PrefixParselet } from '../fhirlexer';\nimport { PropertyType, TypedValue } from '../types';\nimport {\n AndAtom,\n ArithemticOperatorAtom,\n AsAtom,\n ConcatAtom,\n ContainsAtom,\n DotAtom,\n EmptySetAtom,\n EqualsAtom,\n EquivalentAtom,\n FhirPathAtom,\n FunctionAtom,\n InAtom,\n IndexerAtom,\n IsAtom,\n LiteralAtom,\n NotEqualsAtom,\n NotEquivalentAtom,\n OrAtom,\n SymbolAtom,\n UnaryOperatorAtom,\n UnionAtom,\n XorAtom,\n} from './atoms';\nimport { parseDateString } from './date';\nimport { tokenize } from './tokenize';\nimport { toTypedValue } from './utils';\n\n/**\n * Operator precedence\n * See: https://hl7.org/fhirpath/#operator-precedence\n */\nexport const enum OperatorPrecedence {\n FunctionCall = 0,\n Dot = 1,\n Indexer = 2,\n UnaryAdd = 3,\n UnarySubtract = 3,\n Multiply = 4,\n Divide = 4,\n IntegerDivide = 4,\n Modulo = 4,\n Add = 5,\n Subtract = 5,\n Ampersand = 5,\n Is = 6,\n As = 6,\n Union = 7,\n GreaterThan = 8,\n GreaterThanOrEquals = 8,\n LessThan = 8,\n LessThanOrEquals = 8,\n Equals = 9,\n Equivalent = 9,\n NotEquals = 9,\n NotEquivalent = 9,\n In = 10,\n Contains = 10,\n And = 11,\n Xor = 12,\n Or = 12,\n Implies = 13,\n Arrow = 100,\n Semicolon = 200,\n}\n\nconst PARENTHESES_PARSELET: PrefixParselet = {\n parse(parser: Parser) {\n const expr = parser.consumeAndParse();\n if (!parser.match(')')) {\n throw new Error('Parse error: expected `)` got `' + parser.peek()?.value + '`');\n }\n return expr;\n },\n};\n\nconst INDEXER_PARSELET: InfixParselet = {\n parse(parser: Parser, left: Atom) {\n const expr = parser.consumeAndParse();\n if (!parser.match(']')) {\n throw new Error('Parse error: expected `]`');\n }\n return new IndexerAtom(left, expr);\n },\n\n precedence: OperatorPrecedence.Indexer,\n};\n\nconst FUNCTION_CALL_PARSELET: InfixParselet = {\n parse(parser: Parser, left: Atom) {\n if (!(left instanceof SymbolAtom)) {\n throw new Error('Unexpected parentheses');\n }\n\n const args = [];\n while (!parser.match(')')) {\n args.push(parser.consumeAndParse());\n parser.match(',');\n }\n\n return new FunctionAtom(left.name, args); //, functions[left.name]);\n },\n precedence: OperatorPrecedence.FunctionCall,\n};\n\nfunction parseQuantity(str: string): Quantity {\n const parts = str.split(' ');\n const value = parseFloat(parts[0]);\n let unit = parts[1];\n if (unit && unit.startsWith(\"'\") && unit.endsWith(\"'\")) {\n unit = unit.substring(1, unit.length - 1);\n } else {\n unit = '{' + unit + '}';\n }\n return { value, unit };\n}\n\nexport function initFhirPathParserBuilder(): ParserBuilder {\n return new ParserBuilder()\n .registerPrefix('String', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.string, value: token.value }),\n })\n .registerPrefix('DateTime', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.dateTime, value: parseDateString(token.value) }),\n })\n .registerPrefix('Quantity', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.Quantity, value: parseQuantity(token.value) }),\n })\n .registerPrefix('Number', {\n parse: (_, token) => new LiteralAtom({ type: PropertyType.decimal, value: parseFloat(token.value) }),\n })\n .registerPrefix('true', { parse: () => new LiteralAtom({ type: PropertyType.boolean, value: true }) })\n .registerPrefix('false', { parse: () => new LiteralAtom({ type: PropertyType.boolean, value: false }) })\n .registerPrefix('Symbol', { parse: (_, token) => new SymbolAtom(token.value) })\n .registerPrefix('{}', { parse: () => new EmptySetAtom() })\n .registerPrefix('(', PARENTHESES_PARSELET)\n .registerInfix('[', INDEXER_PARSELET)\n .registerInfix('(', FUNCTION_CALL_PARSELET)\n .prefix('+', OperatorPrecedence.UnaryAdd, (_, right) => new UnaryOperatorAtom('+', right, (x) => x))\n .prefix(\n '-',\n OperatorPrecedence.UnarySubtract,\n (_, right) => new ArithemticOperatorAtom('-', right, right, (_, y) => -y)\n )\n .infixLeft('.', OperatorPrecedence.Dot, (left, _, right) => new DotAtom(left, right))\n .infixLeft(\n '/',\n OperatorPrecedence.Divide,\n (left, _, right) => new ArithemticOperatorAtom('/', left, right, (x, y) => x / y)\n )\n .infixLeft(\n '*',\n OperatorPrecedence.Multiply,\n (left, _, right) => new ArithemticOperatorAtom('*', left, right, (x, y) => x * y)\n )\n .infixLeft(\n '+',\n OperatorPrecedence.Add,\n (left, _, right) => new ArithemticOperatorAtom('+', left, right, (x, y) => x + y)\n )\n .infixLeft(\n '-',\n OperatorPrecedence.Subtract,\n (left, _, right) => new ArithemticOperatorAtom('-', left, right, (x, y) => x - y)\n )\n .infixLeft('|', OperatorPrecedence.Union, (left, _, right) => new UnionAtom(left, right))\n .infixLeft('=', OperatorPrecedence.Equals, (left, _, right) => new EqualsAtom(left, right))\n .infixLeft('!=', OperatorPrecedence.Equals, (left, _, right) => new NotEqualsAtom(left, right))\n .infixLeft('~', OperatorPrecedence.Equivalent, (left, _, right) => new EquivalentAtom(left, right))\n .infixLeft('!~', OperatorPrecedence.NotEquivalent, (left, _, right) => new NotEquivalentAtom(left, right))\n .infixLeft(\n '<',\n OperatorPrecedence.LessThan,\n (left, _, right) => new ArithemticOperatorAtom('<', left, right, (x, y) => x < y)\n )\n .infixLeft(\n '<=',\n OperatorPrecedence.LessThanOrEquals,\n (left, _, right) => new ArithemticOperatorAtom('<=', left, right, (x, y) => x <= y)\n )\n .infixLeft(\n '>',\n OperatorPrecedence.GreaterThan,\n (left, _, right) => new ArithemticOperatorAtom('>', left, right, (x, y) => x > y)\n )\n .infixLeft(\n '>=',\n OperatorPrecedence.GreaterThanOrEquals,\n (left, _, right) => new ArithemticOperatorAtom('>=', left, right, (x, y) => x >= y)\n )\n .infixLeft('&', OperatorPrecedence.Ampersand, (left, _, right) => new ConcatAtom(left, right))\n .infixLeft('and', OperatorPrecedence.Is, (left, _, right) => new AndAtom(left, right))\n .infixLeft('as', OperatorPrecedence.Is, (left, _, right) => new AsAtom(left, right))\n .infixLeft('contains', OperatorPrecedence.Is, (left, _, right) => new ContainsAtom(left, right))\n .infixLeft(\n 'div',\n OperatorPrecedence.Is,\n (left, _, right) => new ArithemticOperatorAtom('div', left, right, (x, y) => (x / y) | 0)\n )\n .infixLeft('in', OperatorPrecedence.Is, (left, _, right) => new InAtom(left, right))\n .infixLeft('is', OperatorPrecedence.Is, (left, _, right) => new IsAtom(left, right))\n .infixLeft(\n 'mod',\n OperatorPrecedence.Is,\n (left, _, right) => new ArithemticOperatorAtom('mod', left, right, (x, y) => x % y)\n )\n .infixLeft('or', OperatorPrecedence.Is, (left, _, right) => new OrAtom(left, right))\n .infixLeft('xor', OperatorPrecedence.Is, (left, _, right) => new XorAtom(left, right));\n}\n\nconst fhirPathParserBuilder = initFhirPathParserBuilder();\n\n/**\n * Parses a FHIRPath expression into an AST.\n * The result can be used to evaluate the expression against a resource or other object.\n * This method is useful if you know that you will evaluate the same expression many times\n * against different resources.\n * @param input The FHIRPath expression to parse.\n * @returns The AST representing the expression.\n */\nexport function parseFhirPath(input: string): FhirPathAtom {\n return new FhirPathAtom(input, fhirPathParserBuilder.construct(tokenize(input)).consumeAndParse());\n}\n\n/**\n * Evaluates a FHIRPath expression against a resource or other object.\n * @param expression The FHIRPath expression to parse.\n * @param input The resource or object to evaluate the expression against.\n * @returns The result of the FHIRPath expression against the resource or object.\n */\nexport function evalFhirPath(expression: string, input: unknown): unknown[] {\n // eval requires a TypedValue array\n // As a convenience, we can accept array or non-array, and TypedValue or unknown value\n const array = Array.isArray(input) ? input : [input];\n for (let i = 0; i < array.length; i++) {\n const el = array[i];\n if (!(typeof el === 'object' && 'type' in el && 'value' in el)) {\n array[i] = toTypedValue(array[i]);\n }\n }\n return evalFhirPathTyped(expression, array).map((e) => e.value);\n}\n\n/**\n * Evaluates a FHIRPath expression against a resource or other object.\n * @param expression The FHIRPath expression to parse.\n * @param input The resource or object to evaluate the expression against.\n * @returns The result of the FHIRPath expression against the resource or object.\n */\nexport function evalFhirPathTyped(expression: string, input: TypedValue[]): TypedValue[] {\n return parseFhirPath(expression).eval(input);\n}\n","import { isStringArray } from './utils';\n\n/**\n * The Hl7Context class represents the parsing context for an HL7 message.\n *\n * MSH-1:\n * https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.1\n *\n * MSH-2:\n * https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.2\n *\n * See this tutorial on MSH, and why it's a bad idea to use anything other than the default values:\n * https://www.hl7soup.com/HL7TutorialMSH.html\n */\nexport class Hl7Context {\n constructor(\n public readonly segmentSeparator = '\\r',\n public readonly fieldSeparator = '|',\n public readonly componentSeparator = '^',\n public readonly repetitionSeparator = '~',\n public readonly escapeCharacter = '\\\\',\n public readonly subcomponentSeparator = '&'\n ) {}\n\n /**\n * Returns the MSH-2 field value based on the configured separators.\n * @returns The HL7 MSH-2 field value.\n */\n getMsh2(): string {\n return (\n this.fieldSeparator +\n this.componentSeparator +\n this.repetitionSeparator +\n this.escapeCharacter +\n this.subcomponentSeparator\n );\n }\n}\n\n/**\n * The Hl7Message class represents one HL7 message.\n * A message is a collection of segments.\n */\nexport class Hl7Message {\n readonly context: Hl7Context;\n readonly segments: Hl7Segment[];\n\n /**\n * Creates a new HL7 message.\n * @param segments The HL7 segments.\n * @param context Optional HL7 parsing context.\n */\n constructor(segments: Hl7Segment[], context = new Hl7Context()) {\n this.context = context;\n this.segments = segments;\n }\n\n /**\n * Returns an HL7 segment by index or by name.\n * @param index The HL7 segment index or name.\n * @returns The HL7 segment if found; otherwise, undefined.\n */\n get(index: number | string): Hl7Segment | undefined {\n if (typeof index === 'number') {\n return this.segments[index];\n }\n return this.segments.find((s) => s.name === index);\n }\n\n /**\n * Returns all HL7 segments of a given name.\n * @param name The HL7 segment name.\n * @returns An array of HL7 segments with the specified name.\n */\n getAll(name: string): Hl7Segment[] {\n return this.segments.filter((s) => s.name === name);\n }\n\n /**\n * Returns the HL7 message as a string.\n * @returns The HL7 message as a string.\n */\n toString(): string {\n return this.segments.map((s) => s.toString()).join(this.context.segmentSeparator);\n }\n\n /**\n * Returns an HL7 \"ACK\" (acknowledgement) message for this message.\n * @returns The HL7 \"ACK\" message.\n */\n buildAck(): Hl7Message {\n const now = new Date();\n const msh = this.get('MSH');\n const sendingApp = msh?.get(2)?.toString() || '';\n const sendingFacility = msh?.get(3)?.toString() || '';\n const receivingApp = msh?.get(4)?.toString() || '';\n const receivingFacility = msh?.get(5)?.toString() || '';\n const controlId = msh?.get(9)?.toString() || '';\n const versionId = msh?.get(12)?.toString() || '2.5.1';\n\n return new Hl7Message([\n new Hl7Segment(\n [\n 'MSH',\n this.context.getMsh2(),\n receivingApp,\n receivingFacility,\n sendingApp,\n sendingFacility,\n now.toISOString(),\n '',\n 'ACK',\n now.getTime().toString(),\n 'P',\n versionId,\n ],\n this.context\n ),\n new Hl7Segment(['MSA', 'AA', controlId, 'OK'], this.context),\n ]);\n }\n\n /**\n * Parses an HL7 message string into an Hl7Message object.\n * @param text The HL7 message text.\n * @returns The parsed HL7 message.\n */\n static parse(text: string): Hl7Message {\n if (!text.startsWith('MSH')) {\n const err = new Error('Invalid HL7 message');\n (err as any).type = 'entity.parse.failed';\n throw err;\n }\n const context = new Hl7Context(\n '\\r',\n text.charAt(3), // Field separator, recommended \"|\"\n text.charAt(4), // Component separator, recommended \"^\"\n text.charAt(5), // Repetition separator, recommended \"~\"\n text.charAt(6), // Escape character, recommended \"\\\"\n text.charAt(7) // Subcomponent separator, recommended \"&\"\n );\n return new Hl7Message(\n text.split(/[\\r\\n]+/).map((line) => Hl7Segment.parse(line, context)),\n context\n );\n }\n}\n\n/**\n * The Hl7Segment class represents one HL7 segment.\n * A segment is a collection of fields.\n * The name field is the first field.\n */\nexport class Hl7Segment {\n readonly context: Hl7Context;\n readonly name: string;\n readonly fields: Hl7Field[];\n\n /**\n * Creates a new HL7 segment.\n * @param fields The HL7 fields.\n * @param context Optional HL7 parsing context.\n */\n constructor(fields: Hl7Field[] | string[], context = new Hl7Context()) {\n this.context = context;\n if (isStringArray(fields)) {\n this.fields = fields.map((f) => Hl7Field.parse(f));\n } else {\n this.fields = fields;\n }\n this.name = this.fields[0].components[0][0];\n }\n\n /**\n * Returns an HL7 field by index.\n * @param index The HL7 field index.\n * @returns The HL7 field.\n */\n get(index: number): Hl7Field {\n return this.fields[index];\n }\n\n /**\n * Returns the HL7 segment as a string.\n * @returns The HL7 segment as a string.\n */\n toString(): string {\n return this.fields.map((f) => f.toString()).join(this.context.fieldSeparator);\n }\n\n /**\n * Parses an HL7 segment string into an Hl7Segment object.\n * @param text The HL7 segment text.\n * @param context Optional HL7 parsing context.\n * @returns The parsed HL7 segment.\n */\n static parse(text: string, context = new Hl7Context()): Hl7Segment {\n return new Hl7Segment(\n text.split(context.fieldSeparator).map((f) => Hl7Field.parse(f, context)),\n context\n );\n }\n}\n\n/**\n * The Hl7Field class represents one HL7 field.\n * A field is a collection of components.\n */\nexport class Hl7Field {\n readonly context: Hl7Context;\n readonly components: string[][];\n\n /**\n * Creates a new HL7 field.\n * @param components The HL7 components.\n * @param context Optional HL7 parsing context.\n */\n constructor(components: string[][], context = new Hl7Context()) {\n this.context = context;\n this.components = components;\n }\n\n /**\n * Returns an HL7 component by index.\n * @param component The component index.\n * @param subcomponent Optional subcomponent index.\n * @param repetition Optional repetition index.\n * @returns The string value of the specified component.\n */\n get(component: number, subcomponent?: number, repetition = 0): string {\n let value = this.components[repetition][component] || '';\n\n if (subcomponent !== undefined) {\n value = value.split(this.context.subcomponentSeparator)[subcomponent] || '';\n }\n\n return value;\n }\n\n /**\n * Returns the HL7 field as a string.\n * @returns The HL7 field as a string.\n */\n toString(): string {\n return this.components.map((r) => r.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);\n }\n\n /**\n * Parses an HL7 field string into an Hl7Field object.\n * @param text The HL7 field text.\n * @param context Optional HL7 parsing context.\n * @returns The parsed HL7 field.\n */\n static parse(text: string, context = new Hl7Context()): Hl7Field {\n return new Hl7Field(\n text.split(context.repetitionSeparator).map((r) => r.split(context.componentSeparator)),\n context\n );\n }\n}\n","import { ElementDefinition, SearchParameter } from '@medplum/fhirtypes';\nimport { buildTypeName, getElementDefinition, globalSchema, PropertyType } from '../types';\nimport { capitalize } from '../utils';\n\nexport enum SearchParameterType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n QUANTITY = 'QUANTITY',\n TEXT = 'TEXT',\n REFERENCE = 'REFERENCE',\n DATE = 'DATE',\n DATETIME = 'DATETIME',\n PERIOD = 'PERIOD',\n}\n\nexport interface SearchParameterDetails {\n readonly columnName: string;\n readonly type: SearchParameterType;\n readonly elementDefinition?: ElementDefinition;\n readonly array?: boolean;\n}\n\n/**\n * Returns the type details of a SearchParameter.\n *\n * The SearchParameter resource has a \"type\" parameter, but that is missing some critical information.\n *\n * For example:\n * 1) The \"date\" type includes \"date\", \"datetime\", and \"period\".\n * 2) The \"token\" type includes enums and booleans.\n * 3) Arrays/multiple values are not reflected at all.\n *\n * @param resourceType The root resource type.\n * @param searchParam The search parameter.\n * @returns The search parameter type details.\n */\nexport function getSearchParameterDetails(resourceType: string, searchParam: SearchParameter): SearchParameterDetails {\n let result: SearchParameterDetails | undefined =\n globalSchema.types[resourceType]?.searchParamsDetails?.[searchParam.code as string];\n if (!result) {\n result = buildSearchParamterDetails(resourceType, searchParam);\n }\n return result;\n}\n\nfunction setSearchParamterDetails(resourceType: string, code: string, details: SearchParameterDetails): void {\n const typeSchema = globalSchema.types[resourceType];\n if (!typeSchema.searchParamsDetails) {\n typeSchema.searchParamsDetails = {};\n }\n typeSchema.searchParamsDetails[code] = details;\n}\n\nfunction buildSearchParamterDetails(resourceType: string, searchParam: SearchParameter): SearchParameterDetails {\n const code = searchParam.code as string;\n const columnName = convertCodeToColumnName(code);\n const expression = getExpressionForResourceType(resourceType, searchParam.expression as string)?.split('.');\n if (!expression) {\n // This happens on compound types\n // In the future, explore returning multiple column definitions\n return { columnName, type: SearchParameterType.TEXT };\n }\n\n const defaultType = getSearchParameterType(searchParam);\n let baseType = resourceType;\n let elementDefinition = undefined;\n let propertyType = undefined;\n let array = false;\n\n for (let i = 1; i < expression.length; i++) {\n const propertyName = expression[i];\n elementDefinition = getElementDefinition(baseType, propertyName);\n if (!elementDefinition) {\n throw new Error(`Element definition not found for ${resourceType} ${searchParam.code}`);\n }\n\n if (elementDefinition.max === '*') {\n array = true;\n }\n\n propertyType = elementDefinition.type?.[0].code;\n if (!propertyType) {\n // This happens when one of parent properties uses contentReference\n // In the future, explore following the reference\n return { columnName, type: defaultType, array };\n }\n\n if (i < expression.length - 1) {\n if (isBackboneElement(propertyType)) {\n baseType = buildTypeName(elementDefinition.path?.split('.') as string[]);\n } else {\n baseType = propertyType;\n }\n }\n }\n\n const type = getSearchParameterType(searchParam, propertyType as PropertyType);\n const result = { columnName, type, elementDefinition, array };\n setSearchParamterDetails(resourceType, code, result);\n return result;\n}\n\nfunction isBackboneElement(propertyType: string): boolean {\n return propertyType === 'Element' || propertyType === 'BackboneElement';\n}\n\n/**\n * Converts a hyphen-delimited code to camelCase string.\n * @param code The search parameter code.\n * @returns The SQL column name.\n */\nfunction convertCodeToColumnName(code: string): string {\n return code.split('-').reduce((result, word, index) => result + (index ? capitalize(word) : word), '');\n}\n\nfunction getSearchParameterType(searchParam: SearchParameter, propertyType?: PropertyType): SearchParameterType {\n let type = SearchParameterType.TEXT;\n switch (searchParam.type) {\n case 'date':\n if (propertyType === PropertyType.dateTime || propertyType === PropertyType.instant) {\n type = SearchParameterType.DATETIME;\n } else {\n type = SearchParameterType.DATE;\n }\n break;\n case 'number':\n type = SearchParameterType.NUMBER;\n break;\n case 'quantity':\n type = SearchParameterType.QUANTITY;\n break;\n case 'reference':\n type = SearchParameterType.REFERENCE;\n break;\n case 'token':\n if (propertyType === 'boolean') {\n type = SearchParameterType.BOOLEAN;\n }\n break;\n }\n return type;\n}\n\nexport function getExpressionForResourceType(resourceType: string, expression: string): string | undefined {\n const expressions = expression.split(' | ');\n for (const e of expressions) {\n if (isIgnoredExpression(e)) {\n continue;\n }\n const simplified = simplifyExpression(e);\n if (simplified.startsWith(resourceType + '.')) {\n return simplified;\n }\n }\n return undefined;\n}\n\nfunction isIgnoredExpression(input: string): boolean {\n return input.includes(' as Period') || input.includes(' as SampledDate');\n}\n\nfunction simplifyExpression(input: string): string {\n let result = input.trim();\n\n if (result.startsWith('(') && result.endsWith(')')) {\n result = result.substring(1, result.length - 1);\n }\n\n if (result.includes('[0]')) {\n result = result.replaceAll('[0]', '');\n }\n\n const stopStrings = [' != ', ' as ', '.as(', '.exists(', '.where('];\n for (const stopString of stopStrings) {\n if (result.includes(stopString)) {\n result = result.substring(0, result.indexOf(stopString));\n }\n }\n\n return result;\n}\n","import { ResourceType } from '@medplum/fhirtypes';\n\nexport const DEFAULT_SEARCH_COUNT = 20;\n\nexport interface SearchRequest {\n readonly resourceType: ResourceType;\n filters?: Filter[];\n sortRules?: SortRule[];\n offset?: number;\n count?: number;\n fields?: string[];\n name?: string;\n total?: 'none' | 'estimate' | 'accurate';\n revInclude?: string;\n}\n\nexport interface Filter {\n code: string;\n operator: Operator;\n value: string;\n unitSystem?: string;\n unitCode?: string;\n}\n\nexport interface SortRule {\n code: string;\n descending?: boolean;\n}\n\n/**\n * Search operators.\n * These operators represent \"modifiers\" and \"prefixes\" in FHIR search.\n * See: https://www.hl7.org/fhir/search.html\n */\nexport enum Operator {\n EQUALS = 'eq',\n NOT_EQUALS = 'ne',\n\n // Numbers\n GREATER_THAN = 'gt',\n LESS_THAN = 'lt',\n GREATER_THAN_OR_EQUALS = 'ge',\n LESS_THAN_OR_EQUALS = 'le',\n\n // Dates\n STARTS_AFTER = 'sa',\n ENDS_BEFORE = 'eb',\n APPROXIMATELY = 'ap',\n\n // String\n CONTAINS = 'contains',\n EXACT = 'exact',\n\n // Token\n TEXT = 'text',\n NOT = 'not',\n ABOVE = 'above',\n BELOW = 'below',\n IN = 'in',\n NOT_IN = 'not-in',\n OF_TYPE = 'of-type',\n\n // All\n MISSING = 'missing',\n}\n\nconst MODIFIER_OPERATORS: Operator[] = [\n Operator.CONTAINS,\n Operator.EXACT,\n Operator.TEXT,\n Operator.NOT,\n Operator.ABOVE,\n Operator.BELOW,\n Operator.IN,\n Operator.NOT_IN,\n Operator.OF_TYPE,\n Operator.MISSING,\n];\n\nconst PREFIX_OPERATORS: Operator[] = [\n Operator.NOT_EQUALS,\n Operator.GREATER_THAN,\n Operator.LESS_THAN,\n Operator.GREATER_THAN_OR_EQUALS,\n Operator.LESS_THAN_OR_EQUALS,\n Operator.STARTS_AFTER,\n Operator.ENDS_BEFORE,\n Operator.APPROXIMATELY,\n];\n\n/**\n * Parses a URL into a SearchRequest.\n *\n * See the FHIR search spec: http://hl7.org/fhir/r4/search.html\n *\n * @param url The URL to parse.\n * @returns Parsed search definition.\n */\nexport function parseSearchDefinition(url: string): SearchRequest {\n const location = new URL(url, 'https://example.com/');\n const resourceType = location.pathname\n .replace(/(^\\/)|(\\/$)/g, '') // Remove leading and trailing slashes\n .split('/')\n .pop() as ResourceType;\n const params = new URLSearchParams(location.search);\n let filters: Filter[] | undefined = undefined;\n let sortRules: SortRule[] | undefined = undefined;\n let fields: string[] | undefined = undefined;\n let offset = undefined;\n let count = undefined;\n let total = undefined;\n\n params.forEach((value, key) => {\n if (key === '_fields') {\n fields = value.split(',');\n } else if (key === '_offset') {\n offset = parseInt(value);\n } else if (key === '_count') {\n count = parseInt(value);\n } else if (key === '_total') {\n total = value;\n } else if (key === '_sort') {\n sortRules = sortRules || [];\n sortRules.push(parseSortRule(value));\n } else {\n filters = filters || [];\n filters.push(parseSearchFilter(key, value));\n }\n });\n\n return {\n resourceType,\n filters,\n fields,\n offset,\n count,\n total,\n sortRules,\n };\n}\n\n/**\n * Parses a URL query parameter into a sort rule.\n *\n * By default, the sort rule is the field name.\n *\n * Sort rules can be reversed into descending order by prefixing the field name with a minus sign.\n *\n * See sorting: http://hl7.org/fhir/r4/search.html#_sort\n *\n * @param value The URL parameter value.\n * @returns The parsed sort rule.\n */\nfunction parseSortRule(value: string): SortRule {\n if (value.startsWith('-')) {\n return { code: value.substring(1), descending: true };\n } else {\n return { code: value };\n }\n}\n\n/**\n * Parses a URL query parameter into a search filter.\n *\n * FHIR search filters can be specified as modifiers or prefixes.\n *\n * For string properties, modifiers are appended to the key, e.g. \"name:contains=eve\".\n *\n * For date and numeric properties, prefixes are prepended to the value, e.g. \"birthdate=gt2000\".\n *\n * See the FHIR search spec: http://hl7.org/fhir/r4/search.html\n *\n * @param key The URL parameter key.\n * @param value The URL parameter value.\n * @returns The parsed search filter.\n */\nfunction parseSearchFilter(key: string, value: string): Filter {\n let code = key;\n let operator = Operator.EQUALS;\n\n for (const modifier of MODIFIER_OPERATORS) {\n const modifierIndex = code.indexOf(':' + modifier);\n if (modifierIndex !== -1) {\n operator = modifier;\n code = code.substring(0, modifierIndex);\n }\n }\n\n for (const prefix of PREFIX_OPERATORS) {\n if (value.match(new RegExp('^' + prefix + '\\\\d'))) {\n operator = prefix;\n value = value.substring(prefix.length);\n }\n }\n\n return { code, operator, value };\n}\n\n/**\n * Formats a search definition object into a query string.\n * Note: The return value does not include the resource type.\n * @param {!SearchRequest} definition The search definition.\n * @returns Formatted URL.\n */\nexport function formatSearchQuery(definition: SearchRequest): string {\n const params: string[] = [];\n\n if (definition.fields) {\n params.push('_fields=' + definition.fields.join(','));\n }\n\n if (definition.filters) {\n definition.filters.forEach((filter) => params.push(formatFilter(filter)));\n }\n\n if (definition.sortRules && definition.sortRules.length > 0) {\n params.push(formatSortRules(definition.sortRules));\n }\n\n if (definition.offset !== undefined) {\n params.push('_offset=' + definition.offset);\n }\n\n if (definition.count !== undefined) {\n params.push('_count=' + definition.count);\n }\n\n if (definition.total !== undefined) {\n params.push('_total=' + definition.total);\n }\n\n if (params.length === 0) {\n return '';\n }\n\n params.sort();\n return '?' + params.join('&');\n}\n\nfunction formatFilter(filter: Filter): string {\n const modifier = MODIFIER_OPERATORS.includes(filter.operator) ? ':' + filter.operator : '';\n const prefix = PREFIX_OPERATORS.includes(filter.operator) ? filter.operator : '';\n return `${filter.code}${modifier}=${prefix}${encodeURIComponent(filter.value)}`;\n}\n\nfunction formatSortRules(sortRules: SortRule[]): string {\n return '_sort=' + sortRules.map((sr) => (sr.descending ? '-' + sr.code : sr.code)).join(',');\n}\n","import { Reference, Resource, SearchParameter } from '@medplum/fhirtypes';\nimport { evalFhirPath } from '../fhirpath';\nimport { globalSchema } from '../types';\nimport { getSearchParameterDetails, SearchParameterType } from './details';\nimport { Filter, Operator, SearchRequest } from './search';\n\n/**\n * Determines if the resource matches the search request.\n * @param resource The resource that was created or updated.\n * @param searchRequest The subscription criteria as a search request.\n * @returns True if the resource satisfies the search request.\n */\nexport function matchesSearchRequest(resource: Resource, searchRequest: SearchRequest): boolean {\n if (searchRequest.resourceType !== resource.resourceType) {\n return false;\n }\n if (searchRequest.filters) {\n for (const filter of searchRequest.filters) {\n if (!matchesSearchFilter(resource, searchRequest, filter)) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * Determines if the resource matches the search filter.\n * @param resource The resource that was created or updated.\n * @param filter One of the filters of a subscription criteria.\n * @returns True if the resource satisfies the search filter.\n */\nfunction matchesSearchFilter(resource: Resource, searchRequest: SearchRequest, filter: Filter): boolean {\n const searchParam = globalSchema.types[searchRequest.resourceType]?.searchParams?.[filter.code];\n switch (searchParam?.type) {\n case 'reference':\n return matchesReferenceFilter(resource, filter, searchParam);\n case 'string':\n return matchesStringFilter(resource, filter, searchParam);\n case 'token':\n return matchesTokenFilter(resource, filter, searchParam);\n case 'date':\n return matchesDateFilter(resource, filter, searchParam);\n }\n // Unknown search parameter or search parameter type\n // Default fail the check\n return false;\n}\n\nfunction matchesReferenceFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const values = evalFhirPath(searchParam.expression as string, resource) as (Reference | string)[];\n const negated = isNegated(filter.operator);\n\n if (filter.value === '' && values.length === 0) {\n // If the filter operator is \"equals\", then the filter matches.\n // If the filter operator is \"not equals\", then the filter does not match.\n return filter.operator === Operator.EQUALS;\n }\n\n // Normalize the values array into reference strings\n const references = values.map((value) => (typeof value === 'string' ? value : value.reference));\n\n for (const filterValue of filter.value.split(',')) {\n let match = references.includes(filterValue);\n if (!match && filter.code === '_compartment') {\n // Backwards compability for compartment search parameter\n // In previous versions, the resource type was not required in compartment values\n // So, \"123\" would match \"Patient/123\"\n // We need to maintain this behavior for backwards compatibility\n match = references.some((reference) => reference?.endsWith('/' + filterValue));\n }\n if (match) {\n return !negated;\n }\n }\n // If \"not equals\" and no matches, then return true\n // If \"equals\" and no matches, then return false\n return negated;\n}\n\nfunction matchesTokenFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const details = getSearchParameterDetails(resource.resourceType, searchParam);\n if (details.type === SearchParameterType.BOOLEAN) {\n return matchesBooleanFilter(resource, filter, searchParam);\n } else {\n return matchesStringFilter(resource, filter, searchParam, true);\n }\n}\n\nfunction matchesBooleanFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const values = evalFhirPath(searchParam.expression as string, resource);\n const expected = filter.value === 'true';\n const result = values.includes(expected);\n return isNegated(filter.operator) ? !result : result;\n}\n\nfunction matchesStringFilter(\n resource: Resource,\n filter: Filter,\n searchParam: SearchParameter,\n asToken?: boolean\n): boolean {\n const resourceValues = evalFhirPath(searchParam.expression as string, resource);\n const filterValues = filter.value.split(',');\n const negated = isNegated(filter.operator);\n for (const resourceValue of resourceValues) {\n for (const filterValue of filterValues) {\n const match = matchesStringValue(resourceValue, filter.operator, filterValue, asToken);\n if (match) {\n return !negated;\n }\n }\n }\n // If \"not equals\" and no matches, then return true\n // If \"equals\" and no matches, then return false\n return negated;\n}\n\nfunction matchesStringValue(\n resourceValue: unknown,\n operator: Operator,\n filterValue: string,\n asToken?: boolean\n): boolean {\n if (asToken && filterValue.includes('|')) {\n const [system, code] = filterValue.split('|');\n return (\n matchesStringValue(resourceValue, operator, system, false) &&\n (!code || matchesStringValue(resourceValue, operator, code, false))\n );\n }\n let str = '';\n if (resourceValue) {\n if (typeof resourceValue === 'string') {\n str = resourceValue;\n } else if (typeof resourceValue === 'object') {\n str = JSON.stringify(resourceValue);\n }\n }\n return str.toLowerCase().includes(filterValue.toLowerCase());\n}\n\nfunction matchesDateFilter(resource: Resource, filter: Filter, searchParam: SearchParameter): boolean {\n const resourceValues = evalFhirPath(searchParam.expression as string, resource);\n const filterValues = filter.value.split(',');\n const negated = isNegated(filter.operator);\n for (const resourceValue of resourceValues) {\n for (const filterValue of filterValues) {\n const match = matchesDateValue(resourceValue as string, filter.operator, filterValue);\n if (match) {\n return !negated;\n }\n }\n }\n // If \"not equals\" and no matches, then return true\n // If \"equals\" and no matches, then return false\n return negated;\n}\n\nfunction matchesDateValue(resourceValue: string, operator: Operator, filterValue: string): boolean {\n switch (operator) {\n case Operator.STARTS_AFTER:\n case Operator.GREATER_THAN:\n return resourceValue > filterValue;\n case Operator.GREATER_THAN_OR_EQUALS:\n return resourceValue >= filterValue;\n case Operator.ENDS_BEFORE:\n case Operator.LESS_THAN:\n return resourceValue < filterValue;\n case Operator.LESS_THAN_OR_EQUALS:\n return resourceValue <= filterValue;\n case Operator.EQUALS:\n case Operator.NOT_EQUALS:\n return resourceValue === filterValue;\n }\n return false;\n}\n\nfunction isNegated(operator: Operator): boolean {\n return operator === Operator.NOT_EQUALS || operator === Operator.NOT;\n}\n","import { ResourceType, SearchParameter } from '@medplum/fhirtypes';\nimport { URL } from 'url';\nimport { globalSchema } from '../types';\nimport { Filter, Operator, SearchRequest, SortRule } from './search';\n\n/**\n * Parses a FHIR search query.\n * See: https://www.hl7.org/fhir/search.html\n */\n\n/**\n * For the ordered parameter types of number, date, and quantity,\n * a prefix to the parameter value may be used to control the nature\n * of the matching.\n * See: https://www.hl7.org/fhir/search.html#prefix\n */\nconst prefixMap: Record<string, Operator> = {\n eq: Operator.EQUALS,\n ne: Operator.NOT_EQUALS,\n lt: Operator.LESS_THAN,\n le: Operator.LESS_THAN_OR_EQUALS,\n gt: Operator.GREATER_THAN,\n ge: Operator.GREATER_THAN_OR_EQUALS,\n sa: Operator.STARTS_AFTER,\n eb: Operator.ENDS_BEFORE,\n ap: Operator.APPROXIMATELY,\n};\n\n/**\n * Parameter names may specify a modifier as a suffix.\n * The modifiers are separated from the parameter name by a colon.\n * See: https://www.hl7.org/fhir/search.html#modifiers\n */\nconst modifierMap: Record<string, Operator> = {\n contains: Operator.CONTAINS,\n exact: Operator.EXACT,\n above: Operator.ABOVE,\n below: Operator.BELOW,\n text: Operator.TEXT,\n not: Operator.NOT,\n in: Operator.IN,\n 'not-in': Operator.NOT_IN,\n 'of-type': Operator.OF_TYPE,\n};\n\n/**\n * Parses a search URL into a search request.\n * @param resourceType The FHIR resource type.\n * @param query The collection of query string parameters.\n * @returns A parsed SearchRequest.\n */\nexport function parseSearchRequest(\n resourceType: ResourceType,\n query: Record<string, string[] | string | undefined>\n): SearchRequest {\n return new SearchParser(resourceType, query);\n}\n\n/**\n * Parses a search URL into a search request.\n * @param url The search URL.\n * @returns A parsed SearchRequest.\n */\nexport function parseSearchUrl(url: URL): SearchRequest {\n const resourceType = url.pathname.split('/').pop() as ResourceType;\n return new SearchParser(resourceType, Object.fromEntries(url.searchParams.entries()));\n}\n\nclass SearchParser implements SearchRequest {\n readonly resourceType: ResourceType;\n readonly filters: Filter[];\n readonly sortRules: SortRule[];\n count?: number;\n offset?: number;\n total?: 'none' | 'estimate' | 'accurate';\n revInclude?: string;\n\n constructor(resourceType: ResourceType, query: Record<string, string[] | string | undefined>) {\n this.resourceType = resourceType;\n this.filters = [];\n this.sortRules = [];\n\n for (const [key, value] of Object.entries(query)) {\n if (Array.isArray(value)) {\n value.forEach((element) => this.#parseKeyValue(key, element));\n } else {\n this.#parseKeyValue(key, value ?? '');\n }\n }\n }\n\n #parseKeyValue(key: string, value: string): void {\n let code;\n let modifier;\n\n const colonIndex = key.indexOf(':');\n if (colonIndex >= 0) {\n code = key.substring(0, colonIndex);\n modifier = key.substring(colonIndex + 1);\n } else {\n code = key;\n modifier = '';\n }\n\n switch (code) {\n case '_sort':\n this.#parseSortRule(value);\n break;\n\n case '_count':\n this.count = parseInt(value);\n break;\n\n case '_offset':\n this.offset = parseInt(value);\n break;\n\n case '_total':\n this.total = value as 'none' | 'estimate' | 'accurate';\n break;\n\n case '_summary':\n this.total = 'estimate';\n this.count = 0;\n break;\n\n case '_revinclude':\n this.revInclude = value;\n break;\n\n default: {\n const param = globalSchema.types[this.resourceType]?.searchParams?.[code];\n if (param) {\n this.#parseParameter(param, modifier, value);\n } else {\n this.#parseUnknownParameter(code, modifier, value);\n }\n }\n }\n }\n\n #parseSortRule(value: string): void {\n for (const field of value.split(',')) {\n let code;\n let descending = false;\n if (field.startsWith('-')) {\n code = field.substring(1);\n descending = true;\n } else {\n code = field;\n }\n this.sortRules.push({ code, descending });\n }\n }\n\n #parseParameter(searchParam: SearchParameter, modifier: string, value: string): void {\n if (modifier === 'missing') {\n this.filters.push({\n code: searchParam.code as string,\n operator: Operator.MISSING,\n value,\n });\n return;\n }\n switch (searchParam.type) {\n case 'number':\n case 'date':\n this.#parsePrefixType(searchParam, value);\n break;\n case 'string':\n case 'token':\n case 'uri':\n this.#parseModifierType(searchParam, modifier, value);\n break;\n case 'reference':\n this.#parseReference(searchParam, value);\n break;\n case 'quantity':\n this.#parseQuantity(searchParam, value);\n break;\n }\n }\n\n #parsePrefixType(param: SearchParameter, input: string): void {\n const { operator, value } = parsePrefix(input);\n this.filters.push({\n code: param.code as string,\n operator,\n value,\n });\n }\n\n #parseModifierType(param: SearchParameter, modifier: string, value: string): void {\n this.filters.push({\n code: param.code as string,\n operator: parseModifier(modifier),\n value,\n });\n }\n\n #parseReference(param: SearchParameter, value: string): void {\n this.filters.push({\n code: param.code as string,\n operator: Operator.EQUALS,\n value: value,\n });\n }\n\n #parseQuantity(param: SearchParameter, input: string): void {\n const [prefixNumber, unitSystem, unitCode] = input.split('|');\n const { operator, value } = parsePrefix(prefixNumber);\n this.filters.push({\n code: param.code as string,\n operator,\n value,\n unitSystem,\n unitCode,\n });\n }\n\n #parseUnknownParameter(code: string, modifier: string, value: string): void {\n let operator = Operator.EQUALS;\n if (modifier) {\n operator = modifier as Operator;\n } else {\n for (const prefix of Object.keys(prefixMap)) {\n if (value.match(new RegExp('^' + prefix + '\\\\d'))) {\n operator = prefix as Operator;\n value = value.substring(prefix.length);\n }\n }\n }\n\n this.filters.push({\n code,\n operator,\n value,\n });\n }\n}\n\nfunction parsePrefix(input: string): { operator: Operator; value: string } {\n const prefix = input.substring(0, 2);\n if (prefix in prefixMap) {\n return { operator: prefixMap[prefix], value: input.substring(2) };\n }\n return { operator: Operator.EQUALS, value: input };\n}\n\nfunction parseModifier(modifier: string): Operator {\n return modifierMap[modifier] || Operator.EQUALS;\n}\n"],"names":["toPreciseInteger","deepEquals","isObject","PropertyType","SearchParameterType","Operator"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;I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