@medplum/core 1.0.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +9 -7
  2. package/dist/cjs/client.d.ts +22 -6
  3. package/dist/cjs/format.d.ts +2 -1
  4. package/dist/cjs/{index.js → index.cjs} +355 -376
  5. package/dist/cjs/index.cjs.map +1 -0
  6. package/dist/cjs/index.min.cjs +1 -0
  7. package/dist/cjs/search.d.ts +2 -1
  8. package/dist/cjs/utils.d.ts +8 -1
  9. package/dist/esm/{base-schema.json.js → base-schema.json.mjs} +1 -1
  10. package/dist/esm/{base-schema.json.js.map → base-schema.json.mjs.map} +1 -1
  11. package/dist/esm/{cache.js → cache.mjs} +2 -2
  12. package/dist/esm/cache.mjs.map +1 -0
  13. package/dist/esm/client.d.ts +22 -6
  14. package/dist/esm/{client.js → client.mjs} +256 -260
  15. package/dist/esm/client.mjs.map +1 -0
  16. package/dist/esm/{crypto.js → crypto.mjs} +4 -7
  17. package/dist/esm/crypto.mjs.map +1 -0
  18. package/dist/esm/{eventtarget.js → eventtarget.mjs} +2 -2
  19. package/dist/esm/eventtarget.mjs.map +1 -0
  20. package/dist/esm/fhirlexer/{parse.js → parse.mjs} +5 -6
  21. package/dist/esm/fhirlexer/parse.mjs.map +1 -0
  22. package/dist/esm/fhirlexer/{tokenize.js → tokenize.mjs} +11 -11
  23. package/dist/esm/fhirlexer/tokenize.mjs.map +1 -0
  24. package/dist/esm/fhirpath/{atoms.js → atoms.mjs} +11 -12
  25. package/dist/esm/fhirpath/atoms.mjs.map +1 -0
  26. package/dist/esm/fhirpath/{date.js → date.mjs} +1 -1
  27. package/dist/esm/fhirpath/date.mjs.map +1 -0
  28. package/dist/esm/fhirpath/{functions.js → functions.mjs} +16 -22
  29. package/dist/esm/fhirpath/functions.mjs.map +1 -0
  30. package/dist/esm/fhirpath/{parse.js → parse.mjs} +9 -10
  31. package/dist/esm/fhirpath/parse.mjs.map +1 -0
  32. package/dist/esm/fhirpath/{tokenize.js → tokenize.mjs} +3 -3
  33. package/dist/esm/fhirpath/tokenize.mjs.map +1 -0
  34. package/dist/esm/fhirpath/{utils.js → utils.mjs} +6 -7
  35. package/dist/esm/fhirpath/utils.mjs.map +1 -0
  36. package/dist/esm/format.d.ts +2 -1
  37. package/dist/esm/{format.js → format.mjs} +29 -21
  38. package/dist/esm/format.mjs.map +1 -0
  39. package/dist/esm/{hl7.js → hl7.mjs} +8 -9
  40. package/dist/esm/hl7.mjs.map +1 -0
  41. package/dist/esm/index.min.mjs +1 -0
  42. package/dist/esm/{index.js → index.mjs} +17 -17
  43. package/dist/esm/index.mjs.map +1 -0
  44. package/dist/esm/{jwt.js → jwt.mjs} +1 -1
  45. package/dist/esm/jwt.mjs.map +1 -0
  46. package/dist/esm/{match.js → match.mjs} +12 -13
  47. package/dist/esm/match.mjs.map +1 -0
  48. package/dist/esm/node_modules/tslib/{tslib.es6.js → tslib.es6.mjs} +2 -12
  49. package/dist/esm/node_modules/tslib/tslib.es6.mjs.map +1 -0
  50. package/dist/esm/{outcomes.js → outcomes.mjs} +3 -5
  51. package/dist/esm/outcomes.mjs.map +1 -0
  52. package/dist/esm/{readablepromise.js → readablepromise.mjs} +2 -2
  53. package/dist/esm/readablepromise.mjs.map +1 -0
  54. package/dist/esm/search.d.ts +2 -1
  55. package/dist/esm/{search.js → search.mjs} +1 -1
  56. package/dist/esm/search.mjs.map +1 -0
  57. package/dist/esm/{searchparams.js → searchparams.mjs} +8 -9
  58. package/dist/esm/searchparams.mjs.map +1 -0
  59. package/dist/esm/{storage.js → storage.mjs} +4 -5
  60. package/dist/esm/storage.mjs.map +1 -0
  61. package/dist/esm/{types.js → types.mjs} +6 -9
  62. package/dist/esm/types.mjs.map +1 -0
  63. package/dist/esm/utils.d.ts +8 -1
  64. package/dist/esm/{utils.js → utils.mjs} +31 -27
  65. package/dist/esm/utils.mjs.map +1 -0
  66. package/package.json +5 -5
  67. package/rollup.config.mjs +6 -7
  68. package/dist/cjs/fhirmapper/testall.d.ts +0 -1
  69. package/dist/cjs/index.js.map +0 -1
  70. package/dist/cjs/index.min.js +0 -2
  71. package/dist/cjs/index.min.js.map +0 -1
  72. package/dist/esm/cache.js.map +0 -1
  73. package/dist/esm/client.js.map +0 -1
  74. package/dist/esm/crypto.js.map +0 -1
  75. package/dist/esm/eventtarget.js.map +0 -1
  76. package/dist/esm/fhirlexer/parse.js.map +0 -1
  77. package/dist/esm/fhirlexer/tokenize.js.map +0 -1
  78. package/dist/esm/fhirmapper/testall.d.ts +0 -1
  79. package/dist/esm/fhirpath/atoms.js.map +0 -1
  80. package/dist/esm/fhirpath/date.js.map +0 -1
  81. package/dist/esm/fhirpath/functions.js.map +0 -1
  82. package/dist/esm/fhirpath/parse.js.map +0 -1
  83. package/dist/esm/fhirpath/tokenize.js.map +0 -1
  84. package/dist/esm/fhirpath/utils.js.map +0 -1
  85. package/dist/esm/format.js.map +0 -1
  86. package/dist/esm/hl7.js.map +0 -1
  87. package/dist/esm/index.js.map +0 -1
  88. package/dist/esm/index.min.js +0 -2
  89. package/dist/esm/index.min.js.map +0 -1
  90. package/dist/esm/jwt.js.map +0 -1
  91. package/dist/esm/match.js.map +0 -1
  92. package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
  93. package/dist/esm/outcomes.js.map +0 -1
  94. package/dist/esm/readablepromise.js.map +0 -1
  95. package/dist/esm/search.js.map +0 -1
  96. package/dist/esm/searchparams.js.map +0 -1
  97. package/dist/esm/storage.js.map +0 -1
  98. package/dist/esm/types.js.map +0 -1
  99. package/dist/esm/utils.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { capitalize } from './utils.js';
1
+ import { capitalize } from './utils.mjs';
2
2
 
3
3
  /**
4
4
  * Formats a FHIR Address as a string.
@@ -24,10 +24,10 @@ function formatAddress(address, options) {
24
24
  }
25
25
  builder.push(cityStateZip.join(', '));
26
26
  }
27
- if (address.use && ((options === null || options === void 0 ? void 0 : options.all) || (options === null || options === void 0 ? void 0 : options.use))) {
27
+ if (address.use && (options?.all || options?.use)) {
28
28
  builder.push('[' + address.use + ']');
29
29
  }
30
- return builder.join((options === null || options === void 0 ? void 0 : options.lineSeparator) || ', ').trim();
30
+ return builder.join(options?.lineSeparator || ', ').trim();
31
31
  }
32
32
  /**
33
33
  * Formats a FHIR HumanName as a string.
@@ -37,7 +37,7 @@ function formatAddress(address, options) {
37
37
  */
38
38
  function formatHumanName(name, options) {
39
39
  const builder = [];
40
- if (name.prefix && (options === null || options === void 0 ? void 0 : options.prefix) !== false) {
40
+ if (name.prefix && options?.prefix !== false) {
41
41
  builder.push(...name.prefix);
42
42
  }
43
43
  if (name.given) {
@@ -46,10 +46,10 @@ function formatHumanName(name, options) {
46
46
  if (name.family) {
47
47
  builder.push(name.family);
48
48
  }
49
- if (name.suffix && (options === null || options === void 0 ? void 0 : options.suffix) !== false) {
49
+ if (name.suffix && options?.suffix !== false) {
50
50
  builder.push(...name.suffix);
51
51
  }
52
- if (name.use && ((options === null || options === void 0 ? void 0 : options.all) || (options === null || options === void 0 ? void 0 : options.use))) {
52
+ if (name.use && (options?.all || options?.use)) {
53
53
  builder.push('[' + name.use + ']');
54
54
  }
55
55
  return builder.join(' ').trim();
@@ -100,7 +100,7 @@ function formatDate(date, locales, options) {
100
100
  return '';
101
101
  }
102
102
  d.setUTCHours(0, 0, 0, 0);
103
- return d.toLocaleDateString(locales, Object.assign({ timeZone: 'UTC' }, options));
103
+ return d.toLocaleDateString(locales, { timeZone: 'UTC', ...options });
104
104
  }
105
105
  /**
106
106
  * Formats a FHIR time string as a human readable string.
@@ -184,12 +184,11 @@ const pluralUnits = {
184
184
  * @returns The formatted timing string.
185
185
  */
186
186
  function formatTiming(timing) {
187
- var _a;
188
187
  if (!timing) {
189
188
  return '';
190
189
  }
191
190
  const builder = [];
192
- if ((_a = timing.repeat) === null || _a === void 0 ? void 0 : _a.periodUnit) {
191
+ if (timing.repeat?.periodUnit) {
193
192
  const frequency = timing.repeat.frequency || 1;
194
193
  const period = timing.repeat.period || 1;
195
194
  const periodUnit = timing.repeat.periodUnit;
@@ -229,31 +228,30 @@ function formatTiming(timing) {
229
228
  * @returns A human-readable string representation of the Range
230
229
  */
231
230
  function formatRange(range, precision, exclusive = false) {
232
- var _a, _b, _c, _d;
233
231
  if (exclusive && precision === undefined) {
234
232
  throw new Error('Precision must be specified for exclusive ranges');
235
233
  }
236
- const low = (range === null || range === void 0 ? void 0 : range.low) && Object.assign({}, range.low);
237
- const high = (range === null || range === void 0 ? void 0 : range.high) && Object.assign({}, range.high);
238
- if (!range || ((low === null || low === void 0 ? void 0 : low.value) === undefined && (high === null || high === void 0 ? void 0 : high.value) === undefined)) {
234
+ const low = range?.low && { ...range.low };
235
+ const high = range?.high && { ...range.high };
236
+ if (!range || (low?.value === undefined && high?.value === undefined)) {
239
237
  return '';
240
238
  }
241
- if (((_a = range.low) === null || _a === void 0 ? void 0 : _a.value) !== undefined && ((_b = range.high) === null || _b === void 0 ? void 0 : _b.value) === undefined) {
239
+ if (range.low?.value !== undefined && range.high?.value === undefined) {
242
240
  if (exclusive && precision !== undefined) {
243
241
  range.low.value = preciseDecrement(range.low.value, precision);
244
242
  return `> ${formatQuantity(range.low, precision)}`;
245
243
  }
246
244
  return `>= ${formatQuantity(range.low, precision)}`;
247
245
  }
248
- if (((_c = range.low) === null || _c === void 0 ? void 0 : _c.value) === undefined && ((_d = range.high) === null || _d === void 0 ? void 0 : _d.value) !== undefined) {
246
+ if (range.low?.value === undefined && range.high?.value !== undefined) {
249
247
  if (exclusive && precision !== undefined) {
250
248
  range.high.value = preciseIncrement(range.high.value, precision);
251
249
  return `< ${formatQuantity(range.high, precision)}`;
252
250
  }
253
251
  return `<= ${formatQuantity(range.high, precision)}`;
254
252
  }
255
- if ((low === null || low === void 0 ? void 0 : low.unit) === (high === null || high === void 0 ? void 0 : high.unit)) {
256
- low === null || low === void 0 ? true : delete low.unit;
253
+ if (low?.unit === high?.unit) {
254
+ delete low?.unit;
257
255
  }
258
256
  return `${formatQuantity(low, precision)} - ${formatQuantity(high, precision)}`;
259
257
  }
@@ -287,6 +285,16 @@ function formatQuantity(quantity, precision) {
287
285
  }
288
286
  return result.join('').trim();
289
287
  }
288
+ function formatMoney(money) {
289
+ if (money?.value === undefined) {
290
+ return '';
291
+ }
292
+ return money.value.toLocaleString(undefined, {
293
+ style: 'currency',
294
+ currency: money.currency || 'USD',
295
+ currencyDisplay: 'narrowSymbol',
296
+ });
297
+ }
290
298
  /**
291
299
  * Formats a CodeableConcept element as a string.
292
300
  * @param codeableConcept A FHIR CodeableConcept element
@@ -310,7 +318,7 @@ function formatCodeableConcept(codeableConcept) {
310
318
  * @returns The coding as a string.
311
319
  */
312
320
  function formatCoding(coding) {
313
- return (coding === null || coding === void 0 ? void 0 : coding.display) || (coding === null || coding === void 0 ? void 0 : coding.code) || '';
321
+ return coding?.display || coding?.code || '';
314
322
  }
315
323
  /**
316
324
  * Formats a FHIR Observation resource value as a string.
@@ -324,7 +332,7 @@ function formatObservationValue(obs) {
324
332
  if ('component' in obs) {
325
333
  return obs.component.map((c) => formatObservationValue(c)).join(' / ');
326
334
  }
327
- if (obs === null || obs === void 0 ? void 0 : obs.valueQuantity) {
335
+ if (obs?.valueQuantity) {
328
336
  return formatQuantity(obs.valueQuantity);
329
337
  }
330
338
  if (obs.valueCodeableConcept) {
@@ -367,5 +375,5 @@ function toPreciseInteger(a, precision) {
367
375
  return Math.round(a * Math.pow(10, precision));
368
376
  }
369
377
 
370
- export { formatAddress, formatCodeableConcept, formatCoding, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatObservationValue, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate };
371
- //# sourceMappingURL=format.js.map
378
+ export { formatAddress, formatCodeableConcept, formatCoding, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatMoney, formatObservationValue, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate };
379
+ //# sourceMappingURL=format.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.mjs","sources":["../../src/format.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AA4BA;;;;;AAKG;AACa,SAAA,aAAa,CAAC,OAAgB,EAAE,OAA8B,EAAA;IAC5E,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/B,KAAA;IAED,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE;QACvD,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,IAAI,OAAO,CAAC,IAAI,EAAE;AAChB,YAAA,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACjC,SAAA;QACD,IAAI,OAAO,CAAC,KAAK,EAAE;AACjB,YAAA,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAClC,SAAA;QACD,IAAI,OAAO,CAAC,UAAU,EAAE;AACtB,YAAA,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACvC,SAAA;QACD,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACvC,KAAA;AAED,IAAA,IAAI,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,CAAC,EAAE;QACjD,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AACvC,KAAA;AAED,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,IAAI,IAAI,CAAC,CAAC,I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AED,IAAI,GAAG,EAAE,aAAa,EAAE;AACtB,QAAA,OAAO,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAC1C,KAAA;IAED,IAAI,GAAG,CAAC,oBAAoB,EAAE;AAC5B,QAAA,OAAO,qBAAqB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AACxD,KAAA;IAED,IAAI,GAAG,CAAC,WAAW,EAAE;QACnB,OAAO,GAAG,CAAC,WAAW,CAAC;AACxB,KAAA;AAED,IAAA,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;AAKG;AACH,SAAS,gBAAgB,CAAC,CAAS,EAAE,SAAiB,EAAE,CAAC,GAAG,CAAC,EAAA;IAC3D,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;AACzE,CAAC;AAED;;;;;AAKG;AACH,SAAS,gBAAgB,CAAC,CAAS,EAAE,SAAiB,EAAE,CAAC,GAAG,CAAC,EAAA;IAC3D,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;AAMG;AACH,SAAS,gBAAgB,CAAC,CAAS,EAAE,SAAkB,EAAA;IACrD,IAAI,SAAS,KAAK,SAAS,EAAE;AAC3B,QAAA,OAAO,CAAC,CAAC;AACV,KAAA;AACD,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AACjD;;;;"}
@@ -1,4 +1,4 @@
1
- import { isStringArray } from './utils.js';
1
+ import { isStringArray } from './utils.mjs';
2
2
 
3
3
  /**
4
4
  * The Hl7Context class represents the parsing context for an HL7 message.
@@ -78,15 +78,14 @@ class Hl7Message {
78
78
  * @returns The HL7 "ACK" message.
79
79
  */
80
80
  buildAck() {
81
- var _a, _b, _c, _d, _e, _f;
82
81
  const now = new Date();
83
82
  const msh = this.get('MSH');
84
- const sendingApp = ((_a = msh === null || msh === void 0 ? void 0 : msh.get(2)) === null || _a === void 0 ? void 0 : _a.toString()) || '';
85
- const sendingFacility = ((_b = msh === null || msh === void 0 ? void 0 : msh.get(3)) === null || _b === void 0 ? void 0 : _b.toString()) || '';
86
- const receivingApp = ((_c = msh === null || msh === void 0 ? void 0 : msh.get(4)) === null || _c === void 0 ? void 0 : _c.toString()) || '';
87
- const receivingFacility = ((_d = msh === null || msh === void 0 ? void 0 : msh.get(5)) === null || _d === void 0 ? void 0 : _d.toString()) || '';
88
- const controlId = ((_e = msh === null || msh === void 0 ? void 0 : msh.get(9)) === null || _e === void 0 ? void 0 : _e.toString()) || '';
89
- const versionId = ((_f = msh === null || msh === void 0 ? void 0 : msh.get(12)) === null || _f === void 0 ? void 0 : _f.toString()) || '2.5.1';
83
+ const sendingApp = msh?.get(2)?.toString() || '';
84
+ const sendingFacility = msh?.get(3)?.toString() || '';
85
+ const receivingApp = msh?.get(4)?.toString() || '';
86
+ const receivingFacility = msh?.get(5)?.toString() || '';
87
+ const controlId = msh?.get(9)?.toString() || '';
88
+ const versionId = msh?.get(12)?.toString() || '2.5.1';
90
89
  return new Hl7Message([
91
90
  new Hl7Segment([
92
91
  'MSH',
@@ -218,4 +217,4 @@ class Hl7Field {
218
217
  }
219
218
 
220
219
  export { Hl7Context, Hl7Field, Hl7Message, Hl7Segment };
221
- //# sourceMappingURL=hl7.js.map
220
+ //# sourceMappingURL=hl7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hl7.mjs","sources":["../../src/hl7.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAEA;;;;;;;;;;;AAWG;MACU,UAAU,CAAA;AACrB,IAAA,WAAA,CACkB,mBAAmB,IAAI,EACvB,cAAiB,GAAA,GAAG,EACpB,kBAAqB,GAA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,CAAC,SAAiB,EAAE,YAAqB,EAAE,UAAU,GAAG,CAAC,EAAA;AAC1D,QAAA,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAEzD,IAAI,YAAY,KAAK,SAAS,EAAE;AAC9B,YAAA,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;AAC7E,SAAA;AAED,QAAA,OAAO,KAAK,CAAC;KACd;AAED;;;AAGG;IACH,QAAQ,GAAA;AACN,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;KACnH;AAED;;;;;AAKG;IACH,OAAO,KAAK,CAAC,IAAY,EAAE,OAAO,GAAG,IAAI,UAAU,EAAE,EAAA;AACnD,QAAA,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,EACvF,OAAO,CACR,CAAC;KACH;AACF;;;;"}
@@ -0,0 +1 @@
1
+ function e(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function t(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}var n,i,o,r;class a{constructor(e=10){n.add(this),i.set(this,void 0),o.set(this,void 0),t(this,i,e,"f"),t(this,o,new Map,"f")}clear(){e(this,o,"f").clear()}get(t){const n=e(this,o,"f").get(t);return n&&(e(this,o,"f").delete(t),e(this,o,"f").set(t,n)),n}set(t,a){e(this,o,"f").has(t)?e(this,o,"f").delete(t):e(this,o,"f").size>=e(this,i,"f")&&e(this,o,"f").delete(e(this,n,"m",r).call(this)),e(this,o,"f").set(t,a)}delete(t){e(this,o,"f").delete(t)}keys(){return e(this,o,"f").keys()}}function s(e,t){const n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),n.push(t.join(", "))}return e.use&&(t?.all||t?.use)&&n.push("["+e.use+"]"),n.join(t?.lineSeparator||", ").trim()}function c(e,t){const n=[];return e.prefix&&!1!==t?.prefix&&n.push(...e.prefix),e.given&&n.push(...e.given),e.family&&n.push(e.family),e.suffix&&!1!==t?.suffix&&n.push(...e.suffix),e.use&&(t?.all||t?.use)&&n.push("["+e.use+"]"),n.join(" ").trim()}function d(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()}function l(e){return e.family||""}function u(e){return e instanceof Date&&!isNaN(e.getTime())}function m(e,t,n){if(!e)return"";const i=new Date(e);return u(i)?(i.setUTCHours(0,0,0,0),i.toLocaleDateString(t,{timeZone:"UTC",...n})):""}function p(e,t,n){if(!e)return"";const i=new Date("2000-01-01T"+e+"Z");return u(i)?i.toLocaleTimeString(t,n):""}function h(e,t,n){if(!e)return"";const i=new Date(e);return u(i)?i.toLocaleString(t,n):""}function f(e,t,n){return e&&(e.start||e.end)?h(e.start,t,n)+" - "+h(e.end,t,n):""}i=new WeakMap,o=new WeakMap,n=new WeakSet,r=function(){return e(this,o,"f").keys().next().value};const y={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},g={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},x={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function v(e){if(!e)return"";const t=[];if(e.repeat?.periodUnit){const n=e.repeat.frequency||1,i=e.repeat.period||1,o=e.repeat.periodUnit;1===n&&1===i?t.push(y[o]):(1===n?t.push("once"):t.push(n+" times"),1===i?t.push("per "+g[o]):t.push("per "+i+" "+x[o])),e.repeat.dayOfWeek&&t.push("on "+e.repeat.dayOfWeek.map(K).join(", ")),e.repeat.timeOfDay&&t.push("at "+e.repeat.timeOfDay.map((e=>p(e))).join(", "))}return e.event&&t.push(e.event.map((e=>h(e))).join(", ")),K(t.join(" ").trim())}function w(e,t,n=!1){if(n&&void 0===t)throw new Error("Precision must be specified for exclusive ranges");const i=e?.low&&{...e.low},o=e?.high&&{...e.high};return!e||void 0===i?.value&&void 0===o?.value?"":void 0!==e.low?.value&&void 0===e.high?.value?n&&void 0!==t?(e.low.value=function(e,t,n=1){return(C(e,t)-n)*Math.pow(10,-t)}(e.low.value,t),`> ${S(e.low,t)}`):`>= ${S(e.low,t)}`:void 0===e.low?.value&&void 0!==e.high?.value?n&&void 0!==t?(e.high.value=function(e,t,n=1){return(C(e,t)+n)*Math.pow(10,-t)}(e.high.value,t),`< ${S(e.high,t)}`):`<= ${S(e.high,t)}`:(i?.unit===o?.unit&&delete i?.unit,`${S(i,t)} - ${S(o,t)}`)}function S(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),void 0!==e.value&&(void 0!==t?n.push(e.value.toFixed(t)):n.push(e.value)),e.unit&&("%"!==e.unit&&" "!==n[n.length-1]&&n.push(" "),n.push(e.unit)),n.join("").trim()}function E(e){return void 0===e?.value?"":e.value.toLocaleString(void 0,{style:"currency",currency:e.currency||"USD",currencyDisplay:"narrowSymbol"})}function T(e){return e?e.text?e.text:e.coding?e.coding.map((e=>b(e))).join(", "):"":""}function b(e){return e?.display||e?.code||""}function D(e){return e?"component"in e?e.component.map((e=>D(e))).join(" / "):e?.valueQuantity?S(e.valueQuantity):e.valueCodeableConcept?T(e.valueCodeableConcept):e.valueString?e.valueString:"":""}function C(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function A(e){const t=P(e),n=M(e);return n===t?{reference:t}:{reference:t,display:n}}function P(e){return e.resourceType+"/"+e.id}function R(e){return e?.reference?.split("/")[1]}function k(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function M(e){if(k(e)){const t=function(e){const t=e.name;if(t&&t.length>0)return c(t[0]);return}(e);if(t)return t}if("Device"===e.resourceType){const t=function(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name;return}(e);if(t)return t}return"Observation"===e.resourceType&&"code"in e&&e.code?.text?e.code.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:P(e)}function I(e){if(!("photo"in e))return;const t=e.photo;if(t){if(!Array.isArray(t))return L(t);for(const e of t){const t=L(e);if(t)return t}}}function L(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function U(e){return e?new Date(e):void 0}function O(e,t){const n=new Date(e);n.setUTCHours(0,0,0,0);const i=t?new Date(t):new Date;i.setUTCHours(0,0,0,0);const o=n.getUTCFullYear(),r=n.getUTCMonth(),a=n.getUTCDate(),s=i.getUTCFullYear(),c=i.getUTCMonth(),d=i.getUTCDate();let l=s-o;(c<r||c===r&&d<a)&&l--;let u=12*s+c-(12*o+r);d<a&&u--;return{years:l,months:u,days:Math.floor((i.getTime()-n.getTime())/864e5)}}function N(e,t){const{years:n,months:i,days:o}=O(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":i>=1?i.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"}function _(e){const t={};return j(e.item,t),t}function j(e,t){if(e)for(const n of e)n.linkId&&n.answer&&n.answer.length>0&&(t[n.linkId]=n.answer[0]),j(n.item,t)}function Q(e,t){const n=e.identifier;if(!n)return;const i=Array.isArray(n)?n:[n];for(const e of i)if(e.system===t)return e.value}function W(e,...t){let n=e;for(let e=0;e<t.length&&n;e++)n=n?.extension?.find((n=>n.url===t[e]));return n?.valueString}function B(e,...t){let n=e;for(let e=0;e<t.length&&n;e++)n=n?.extension?.find((n=>n.url===t[e]));return n}function $(e,t){return JSON.stringify(e,q,t?2:void 0)}function q(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&F(t)?void 0:t}function F(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function H(e,t,n){return e===t||(!(!F(e)||!F(t))||!F(e)&&!F(t)&&(Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!H(e[n],t[n]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(V(e)&&V(t)?function(e,t,n){const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e))),"meta"===n&&(i.delete("versionId"),i.delete("lastUpdated"),i.delete("author"));for(const n of i){if(!H(e[n],t[n],n))return!1}return!0}(e,t,n):(V(e)||V(t),!1))))}function z(e){return JSON.parse(JSON.stringify(e))}function G(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)}function V(e){return null!==e&&"object"==typeof e}function X(e){return e.every((e=>"string"==typeof e))}const Y=[];for(let e=0;e<256;e++)Y.push(e.toString(16).padStart(2,"0"));function J(e){const t=new Uint8Array(e),n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=Y[t[e]];return n.join("")}function Z(e){const t=new Uint8Array(e),n=[];for(let e=0;e<t.length;e++)n[e]=String.fromCharCode(t[e]);return window.btoa(n.join(""))}function K(e){return e.charAt(0).toUpperCase()+e.substring(1)}function ee(e){return e===e.toLowerCase()&&e!==e.toUpperCase()}function te(e,t){return e?.coding?.find((e=>e.system===t))?.code}function ne(e,t,n){e.coding||(e.coding=[]);const i=e.coding?.find((e=>e.system===t));i?i.code=n:e.coding?.push({system:t,code:n})}function ie(e,t,n,i){return e.qualifiedInterval?.find((o=>re(o,t)&&function(e,t,n){return!!e.range&&ae(t,e.range,n)}(o,n,e.quantitativeDetails?.decimalPrecision)&&(void 0===i||o.category===i)))}function oe(e,t,n){return e.qualifiedInterval?.find((e=>re(e,t)&&n.includes(e.condition)))}function re(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||ae(O(t.birthDate).years,e.age)}(e,t)}function ae(e,t,n){return(void 0===t.low?.value||me(e,t.low.value,n))&&(void 0===t.high?.value||ue(e,t.high.value,n))}function se(e,t){return parseFloat(e.toFixed(t))}function ce(e,t,n){return pe(e,n)===pe(t,n)}function de(e,t,n){return pe(e,n)<pe(t,n)}function le(e,t,n){return pe(e,n)>pe(t,n)}function ue(e,t,n){return pe(e,n)<=pe(t,n)}function me(e,t,n){return pe(e,n)>=pe(t,n)}function pe(e,t){return void 0===t?e:Math.round(e*Math.pow(10,t))}function he(){const e=new Uint32Array(28);return crypto.getRandomValues(e),J(e.buffer)}var fe,ye,ge,xe,ve,we,Se,Ee;class Te{constructor(){fe.set(this,void 0),t(this,fe,{},"f")}addEventListener(t,n){e(this,fe,"f")[t]||(e(this,fe,"f")[t]=[]),e(this,fe,"f")[t].push(n)}removeEventListeneer(t,n){const i=e(this,fe,"f")[t];if(i)for(let e=0;e<i.length;e++)if(i[e]===n)return void i.splice(e,1)}dispatchEvent(t){const n=e(this,fe,"f")[t.type];return n&&n.forEach((e=>e.call(this,t))),!t.defaultPrevented}}function be(e){const t=function(e){if("undefined"!=typeof window)return window.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}(e.replace(/-/g,"+").replace(/_/g,"/")),n=Array.from(t).reduce(((e,t)=>`${e}%${("00"+t.charCodeAt(0).toString(16)).slice(-2)}`),""),i=decodeURIComponent(n);return JSON.parse(i)}function De(e){const[t,n,i]=e.split(".");return be(n)}fe=new WeakMap;class Ce{constructor(e){this[we]="ReadablePromise",ye.set(this,void 0),ge.set(this,"pending"),xe.set(this,void 0),ve.set(this,void 0),t(this,ye,e.then((e=>(t(this,ge,"success","f"),t(this,xe,e,"f"),e)),(e=>{throw t(this,ge,"error","f"),t(this,ve,e,"f"),e})),"f")}isPending(){return"pending"===e(this,ge,"f")}isOk(){return"success"===e(this,ge,"f")}read(){switch(e(this,ge,"f")){case"pending":throw e(this,ye,"f");case"error":throw e(this,ve,"f");default:return e(this,xe,"f")}}then(t,n){return e(this,ye,"f").then(t,n)}catch(t){return e(this,ye,"f").catch(t)}finally(t){return e(this,ye,"f").finally(t)}}ye=new WeakMap,ge=new WeakMap,xe=new WeakMap,ve=new WeakMap,we=Symbol.toStringTag;class Ae{constructor(){Se.set(this,void 0),t(this,Se,"undefined"!=typeof localStorage?localStorage:new Pe,"f")}clear(){e(this,Se,"f").clear()}getString(t){return e(this,Se,"f").getItem(t)||void 0}setString(t,n){n?e(this,Se,"f").setItem(t,n):e(this,Se,"f").removeItem(t)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?$(t):void 0)}}Se=new WeakMap;class Pe{constructor(){Ee.set(this,void 0),t(this,Ee,new Map,"f")}get length(){return e(this,Ee,"f").size}clear(){e(this,Ee,"f").clear()}getItem(t){return e(this,Ee,"f").get(t)??null}setItem(t,n){n?e(this,Ee,"f").set(t,n):e(this,Ee,"f").delete(t)}removeItem(t){e(this,Ee,"f").delete(t)}key(t){return Array.from(e(this,Ee,"f").keys())[t]}}Ee=new WeakMap;var Re,ke={types:{Element:{display:"Element",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]}}},BackboneElement:{display:"BackboneElement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]}}},Address:{display:"Address",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},line:{min:0,max:"*",type:[{code:"string"}]},city:{min:0,max:"1",type:[{code:"string"}]},district:{min:0,max:"1",type:[{code:"string"}]},state:{min:0,max:"1",type:[{code:"string"}]},postalCode:{min:0,max:"1",type:[{code:"string"}]},country:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Age:{display:"Age",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Annotation:{display:"Annotation",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"author[x]":{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{min:0,max:"1",type:[{code:"dateTime"}]},text:{min:1,max:"1",type:[{code:"markdown"}]}}},Attachment:{display:"Attachment",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},contentType:{min:0,max:"1",type:[{code:"code"}]},language:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]},url:{min:0,max:"1",type:[{code:"url"}]},size:{min:0,max:"1",type:[{code:"unsignedInt"}]},hash:{min:0,max:"1",type:[{code:"base64Binary"}]},title:{min:0,max:"1",type:[{code:"string"}]},creation:{min:0,max:"1",type:[{code:"dateTime"}]}}},CodeableConcept:{display:"CodeableConcept",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},coding:{min:0,max:"*",type:[{code:"Coding"}]},text:{min:0,max:"1",type:[{code:"string"}]}}},Coding:{display:"Coding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"uri"}]},version:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"1",type:[{code:"code"}]},display:{min:0,max:"1",type:[{code:"string"}]},userSelected:{min:0,max:"1",type:[{code:"boolean"}]}}},ContactDetail:{display:"ContactDetail",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"string"}]},telecom:{min:0,max:"*",type:[{code:"ContactPoint"}]}}},ContactPoint:{display:"ContactPoint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"code"}]},value:{min:0,max:"1",type:[{code:"string"}]},use:{min:0,max:"1",type:[{code:"code"}]},rank:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Contributor:{display:"Contributor",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:1,max:"1",type:[{code:"string"}]},contact:{min:0,max:"*",type:[{code:"ContactDetail"}]}}},Count:{display:"Count",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},DataRequirement:{display:"DataRequirement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{min:0,max:"1",type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{min:0,max:"*",type:[{code:"string"}]},codeFilter:{min:0,max:"*",type:[{code:"Element"}]},dateFilter:{min:0,max:"*",type:[{code:"Element"}]},limit:{min:0,max:"1",type:[{code:"positiveInt"}]},sort:{min:0,max:"*",type:[{code:"Element"}]}}},DataRequirementCodeFilter:{display:"DataRequirementCodeFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{min:0,max:"*",type:[{code:"Coding"}]}},parentType:"DataRequirement"},DataRequirementDateFilter:{display:"DataRequirementDateFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}},parentType:"DataRequirement"},DataRequirementSort:{display:"DataRequirementSort",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},direction:{min:1,max:"1",type:[{code:"code"}]}},parentType:"DataRequirement"},Distance:{display:"Distance",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Dosage:{display:"Dosage",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},sequence:{min:0,max:"1",type:[{code:"integer"}]},text:{min:0,max:"1",type:[{code:"string"}]},additionalInstruction:{min:0,max:"*",type:[{code:"CodeableConcept"}]},patientInstruction:{min:0,max:"1",type:[{code:"string"}]},timing:{min:0,max:"1",type:[{code:"Timing"}]},"asNeeded[x]":{min:0,max:"1",type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{min:0,max:"1",type:[{code:"CodeableConcept"}]},route:{min:0,max:"1",type:[{code:"CodeableConcept"}]},method:{min:0,max:"1",type:[{code:"CodeableConcept"}]},doseAndRate:{min:0,max:"*",type:[{code:"Element"}]},maxDosePerPeriod:{min:0,max:"1",type:[{code:"Ratio"}]},maxDosePerAdministration:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},DosageDoseAndRate:{display:"DosageDoseAndRate",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},"dose[x]":{min:0,max:"1",type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{min:0,max:"1",type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}},parentType:"Dosage"},Duration:{display:"Duration",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},ElementDefinition:{display:"ElementDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},representation:{min:0,max:"*",type:[{code:"code"}]},sliceName:{min:0,max:"1",type:[{code:"string"}]},sliceIsConstraining:{min:0,max:"1",type:[{code:"boolean"}]},label:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"*",type:[{code:"Coding"}]},slicing:{min:0,max:"1",type:[{code:"Element"}]},short:{min:0,max:"1",type:[{code:"string"}]},definition:{min:0,max:"1",type:[{code:"markdown"}]},comment:{min:0,max:"1",type:[{code:"markdown"}]},requirements:{min:0,max:"1",type:[{code:"markdown"}]},alias:{min:0,max:"*",type:[{code:"string"}]},min:{min:0,max:"1",type:[{code:"unsignedInt"}]},max:{min:0,max:"1",type:[{code:"string"}]},base:{min:0,max:"1",type:[{code:"Element"}]},contentReference:{min:0,max:"1",type:[{code:"uri"}]},type:{min:0,max:"*",type:[{code:"Element"}]},"defaultValue[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{min:0,max:"1",type:[{code:"markdown"}]},orderMeaning:{min:0,max:"1",type:[{code:"string"}]},"fixed[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{min:0,max:"*",type:[{code:"Element"}]},"minValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{min:0,max:"1",type:[{code:"integer"}]},condition:{min:0,max:"*",type:[{code:"id"}]},constraint:{min:0,max:"*",type:[{code:"Element"}]},mustSupport:{min:0,max:"1",type:[{code:"boolean"}]},isModifier:{min:0,max:"1",type:[{code:"boolean"}]},isModifierReason:{min:0,max:"1",type:[{code:"string"}]},isSummary:{min:0,max:"1",type:[{code:"boolean"}]},binding:{min:0,max:"1",type:[{code:"Element"}]},mapping:{min:0,max:"*",type:[{code:"Element"}]}}},ElementDefinitionSlicing:{display:"ElementDefinitionSlicing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},discriminator:{min:0,max:"*",type:[{code:"Element"}]},description:{min:0,max:"1",type:[{code:"string"}]},ordered:{min:0,max:"1",type:[{code:"boolean"}]},rules:{min:1,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionSlicingDiscriminator:{display:"ElementDefinitionSlicingDiscriminator",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},path:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinitionSlicing"},ElementDefinitionBase:{display:"ElementDefinitionBase",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},min:{min:1,max:"1",type:[{code:"unsignedInt"}]},max:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},ElementDefinitionType:{display:"ElementDefinitionType",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{min:0,max:"*",type:[{code:"code"}]},versioning:{min:0,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionExample:{display:"ElementDefinitionExample",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},label:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:1,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}},parentType:"ElementDefinition"},ElementDefinitionConstraint:{display:"ElementDefinitionConstraint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},key:{min:1,max:"1",type:[{code:"id"}]},requirements:{min:0,max:"1",type:[{code:"string"}]},severity:{min:1,max:"1",type:[{code:"code"}]},human:{min:1,max:"1",type:[{code:"string"}]},expression:{min:0,max:"1",type:[{code:"string"}]},xpath:{min:0,max:"1",type:[{code:"string"}]},source:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}},parentType:"ElementDefinition"},ElementDefinitionBinding:{display:"ElementDefinitionBinding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},strength:{min:1,max:"1",type:[{code:"code"}]},description:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}},parentType:"ElementDefinition"},ElementDefinitionMapping:{display:"ElementDefinitionMapping",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},identity:{min:1,max:"1",type:[{code:"id"}]},language:{min:0,max:"1",type:[{code:"code"}]},map:{min:1,max:"1",type:[{code:"string"}]},comment:{min:0,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},Expression:{display:"Expression",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},description:{min:0,max:"1",type:[{code:"string"}]},name:{min:0,max:"1",type:[{code:"id"}]},language:{min:1,max:"1",type:[{code:"code"}]},expression:{min:0,max:"1",type:[{code:"string"}]},reference:{min:0,max:"1",type:[{code:"uri"}]}}},Extension:{display:"Extension",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},url:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},HumanName:{display:"HumanName",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},family:{min:0,max:"1",type:[{code:"string"}]},given:{min:0,max:"*",type:[{code:"string"}]},prefix:{min:0,max:"*",type:[{code:"string"}]},suffix:{min:0,max:"*",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Identifier:{display:"Identifier",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},system:{min:0,max:"1",type:[{code:"uri"}]},value:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]},assigner:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},MarketingStatus:{display:"MarketingStatus",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},country:{min:1,max:"1",type:[{code:"CodeableConcept"}]},jurisdiction:{min:0,max:"1",type:[{code:"CodeableConcept"}]},status:{min:1,max:"1",type:[{code:"CodeableConcept"}]},dateRange:{min:1,max:"1",type:[{code:"Period"}]},restoreDate:{min:0,max:"1",type:[{code:"dateTime"}]}}},Meta:{display:"Meta",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},versionId:{min:0,max:"1",type:[{code:"id"}]},lastUpdated:{min:0,max:"1",type:[{code:"instant"}]},source:{min:0,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{min:0,max:"*",type:[{code:"Coding"}]},tag:{min:0,max:"*",type:[{code:"Coding"}]},project:{min:0,max:"1",type:[{code:"uri"}]},author:{min:0,max:"1",type:[{code:"Reference"}]},account:{min:0,max:"1",type:[{code:"Reference"}]}}},Money:{display:"Money",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},currency:{min:0,max:"1",type:[{code:"code"}]}}},Narrative:{display:"Narrative",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},status:{min:1,max:"1",type:[{code:"code"}]},div:{min:1,max:"1",type:[{code:"xhtml"}]}}},ParameterDefinition:{display:"ParameterDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"code"}]},use:{min:1,max:"1",type:[{code:"code"}]},min:{min:0,max:"1",type:[{code:"integer"}]},max:{min:0,max:"1",type:[{code:"string"}]},documentation:{min:0,max:"1",type:[{code:"string"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},Period:{display:"Period",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},start:{min:0,max:"1",type:[{code:"dateTime"}]},end:{min:0,max:"1",type:[{code:"dateTime"}]}}},Population:{display:"Population",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"age[x]":{min:0,max:"1",type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{min:0,max:"1",type:[{code:"CodeableConcept"}]},race:{min:0,max:"1",type:[{code:"CodeableConcept"}]},physiologicalCondition:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProdCharacteristic:{display:"ProdCharacteristic",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},height:{min:0,max:"1",type:[{code:"Quantity"}]},width:{min:0,max:"1",type:[{code:"Quantity"}]},depth:{min:0,max:"1",type:[{code:"Quantity"}]},weight:{min:0,max:"1",type:[{code:"Quantity"}]},nominalVolume:{min:0,max:"1",type:[{code:"Quantity"}]},externalDiameter:{min:0,max:"1",type:[{code:"Quantity"}]},shape:{min:0,max:"1",type:[{code:"string"}]},color:{min:0,max:"*",type:[{code:"string"}]},imprint:{min:0,max:"*",type:[{code:"string"}]},image:{min:0,max:"*",type:[{code:"Attachment"}]},scoring:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProductShelfLife:{display:"ProductShelfLife",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},type:{min:1,max:"1",type:[{code:"CodeableConcept"}]},period:{min:1,max:"1",type:[{code:"Quantity"}]},specialPrecautionsForStorage:{min:0,max:"*",type:[{code:"CodeableConcept"}]}}},Quantity:{display:"Quantity",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"0",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Range:{display:"Range",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},low:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Ratio:{display:"Ratio",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},numerator:{min:0,max:"1",type:[{code:"Quantity"}]},denominator:{min:0,max:"1",type:[{code:"Quantity"}]}}},Reference:{display:"Reference",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},reference:{min:0,max:"1",type:[{code:"string"}]},type:{min:0,max:"1",type:[{code:"uri"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},display:{min:0,max:"1",type:[{code:"string"}]}}},RelatedArtifact:{display:"RelatedArtifact",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},label:{min:0,max:"1",type:[{code:"string"}]},display:{min:0,max:"1",type:[{code:"string"}]},citation:{min:0,max:"1",type:[{code:"markdown"}]},url:{min:0,max:"1",type:[{code:"url"}]},document:{min:0,max:"1",type:[{code:"Attachment"}]},resource:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},SampledData:{display:"SampledData",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},origin:{min:1,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,max:"1",type:[{code:"decimal"}]},factor:{min:0,max:"1",type:[{code:"decimal"}]},lowerLimit:{min:0,max:"1",type:[{code:"decimal"}]},upperLimit:{min:0,max:"1",type:[{code:"decimal"}]},dimensions:{min:1,max:"1",type:[{code:"positiveInt"}]},data:{min:0,max:"1",type:[{code:"string"}]}}},Signature:{display:"Signature",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"*",type:[{code:"Coding"}]},when:{min:1,max:"1",type:[{code:"instant"}]},who:{min:1,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{min:0,max:"1",type:[{code:"code"}]},sigFormat:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]}}},SubstanceAmount:{display:"SubstanceAmount",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"amount[x]":{min:0,max:"1",type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{min:0,max:"1",type:[{code:"CodeableConcept"}]},amountText:{min:0,max:"1",type:[{code:"string"}]},referenceRange:{min:0,max:"1",type:[{code:"Element"}]}}},SubstanceAmountReferenceRange:{display:"SubstanceAmountReferenceRange",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},lowLimit:{min:0,max:"1",type:[{code:"Quantity"}]},highLimit:{min:0,max:"1",type:[{code:"Quantity"}]}},parentType:"SubstanceAmount"},Timing:{display:"Timing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},event:{min:0,max:"*",type:[{code:"dateTime"}]},repeat:{min:0,max:"1",type:[{code:"Element"}]},code:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},TimingRepeat:{display:"TimingRepeat",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"bounds[x]":{min:0,max:"1",type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{min:0,max:"1",type:[{code:"positiveInt"}]},countMax:{min:0,max:"1",type:[{code:"positiveInt"}]},duration:{min:0,max:"1",type:[{code:"decimal"}]},durationMax:{min:0,max:"1",type:[{code:"decimal"}]},durationUnit:{min:0,max:"1",type:[{code:"code"}]},frequency:{min:0,max:"1",type:[{code:"positiveInt"}]},frequencyMax:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"decimal"}]},periodMax:{min:0,max:"1",type:[{code:"decimal"}]},periodUnit:{min:0,max:"1",type:[{code:"code"}]},dayOfWeek:{min:0,max:"*",type:[{code:"code"}]},timeOfDay:{min:0,max:"*",type:[{code:"time"}]},when:{min:0,max:"*",type:[{code:"code"}]},offset:{min:0,max:"1",type:[{code:"unsignedInt"}]}},parentType:"Timing"},TriggerDefinition:{display:"TriggerDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:0,max:"1",type:[{code:"string"}]},"timing[x]":{min:0,max:"1",type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{min:0,max:"*",type:[{code:"DataRequirement"}]},condition:{min:0,max:"1",type:[{code:"Expression"}]}}},UsageContext:{display:"UsageContext",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"Coding"}]},"value[x]":{min:1,max:"1",type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}}}};function Me(){return{types:{}}}function Ie(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&Le(e)}}function Le(e){if(!e.name)return;const t=e.snapshot?.element;t&&(t.forEach((t=>function(e,t){const n=t.path,i=t.type?.[0]?.code;if(void 0!==i&&"Element"!==i&&"BackboneElement"!==i)return;const o=n.split("."),r=Ne(o);Qe.types[r]=function(e,t,n){return{structureDefinition:t,elementDefinition:n,display:e,description:n.definition,properties:{}}}(r,e,t),Qe.types[r].parentType=Ne(o.slice(0,o.length-1))}(e,t))),t.forEach((e=>function(e){const t=e.path,n=t.split(".");if(1===n.length)return;const i=Ne(n.slice(0,n.length-1)),o=Qe.types[i];if(!o)return;const r=n[n.length-1];o.properties[r]=e}(e))))}function Ue(e){for(const t of e.entry){const e=t.resource;"SearchParameter"===e.resourceType&&Oe(e)}}function Oe(e){if(e.base)for(const t of e.base){const n=Qe.types[t];n&&(n.searchParams||(n.searchParams={_id:{base:[t],code:"_id",type:"token",expression:t+".id"},_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"},_compartment:{base:[t],code:"_compartment",type:"reference",expression:t+".meta.compartment"}}),n.searchParams[e.code]=e)}}function Ne(e){return 1===e.length?e[0]:e.map(K).join("")}function _e(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(K).join(" ").replace("_"," ").replace(/\s+/g," ")}function je(e,t){const n=Qe.types[e];if(!n)return;const i=n.properties[t]??n.properties[t+"[x]"];if(i){if(i.contentReference){const e=i.contentReference.substring(1).split("."),t=e.pop();return je(Ne(e),t)}return i}}!function(e){e.Address="Address",e.Age="Age",e.Annotation="Annotation",e.Attachment="Attachment",e.BackboneElement="BackboneElement",e.CodeableConcept="CodeableConcept",e.Coding="Coding",e.ContactDetail="ContactDetail",e.ContactPoint="ContactPoint",e.Contributor="Contributor",e.Count="Count",e.DataRequirement="DataRequirement",e.Distance="Distance",e.Dosage="Dosage",e.Duration="Duration",e.Expression="Expression",e.Extension="Extension",e.HumanName="HumanName",e.Identifier="Identifier",e.MarketingStatus="MarketingStatus",e.Meta="Meta",e.Money="Money",e.Narrative="Narrative",e.ParameterDefinition="ParameterDefinition",e.Period="Period",e.Population="Population",e.ProdCharacteristic="ProdCharacteristic",e.ProductShelfLife="ProductShelfLife",e.Quantity="Quantity",e.Range="Range",e.Ratio="Ratio",e.Reference="Reference",e.RelatedArtifact="RelatedArtifact",e.SampledData="SampledData",e.Signature="Signature",e.SubstanceAmount="SubstanceAmount",e.SystemString="http://hl7.org/fhirpath/System.String",e.Timing="Timing",e.TriggerDefinition="TriggerDefinition",e.UsageContext="UsageContext",e.base64Binary="base64Binary",e.boolean="boolean",e.canonical="canonical",e.code="code",e.date="date",e.dateTime="dateTime",e.decimal="decimal",e.id="id",e.instant="instant",e.integer="integer",e.markdown="markdown",e.oid="oid",e.positiveInt="positiveInt",e.string="string",e.time="time",e.unsignedInt="unsignedInt",e.uri="uri",e.url="url",e.uuid="uuid"}(Re||(Re={}));const Qe=ke;var We,Be,$e,qe,Fe,He,ze,Ge,Ve,Xe,Ye,Je,Ze,Ke,et,tt,nt,it,ot,rt,at,st,ct,dt,lt,ut,mt,pt,ht,ft,yt,gt,xt;const vt="2.0.0-7fe99080";class wt extends Te{constructor(n){if(super(),We.add(this),Be.set(this,void 0),$e.set(this,void 0),qe.set(this,void 0),Fe.set(this,void 0),He.set(this,void 0),ze.set(this,void 0),Ge.set(this,void 0),Ve.set(this,void 0),Xe.set(this,void 0),Ye.set(this,void 0),Je.set(this,void 0),Ze.set(this,void 0),Ke.set(this,void 0),et.set(this,void 0),tt.set(this,void 0),nt.set(this,void 0),it.set(this,void 0),ot.set(this,void 0),n?.baseUrl&&!n.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");t(this,Be,n?.fetch||window.fetch.bind(window),"f"),t(this,$e,n?.createPdf,"f"),t(this,qe,new Ae,"f"),t(this,Fe,new a(n?.resourceCacheSize??1e3),"f"),t(this,He,n?.cacheTime??6e4,"f"),t(this,ze,function(e){if(!e)return e;return e.endsWith("/")?e:e+"/"}(n?.baseUrl)||"https://api.medplum.com/","f"),t(this,Je,n?.clientId||"","f"),t(this,Ge,n?.authorizeUrl||e(this,ze,"f")+"oauth2/authorize","f"),t(this,Ve,n?.tokenUrl||e(this,ze,"f")+"oauth2/token","f"),t(this,Xe,n?.logoutUrl||e(this,ze,"f")+"oauth2/logout","f"),t(this,Ye,n?.onUnauthenticated,"f");const i=this.getActiveLogin();i&&(t(this,Ke,i.accessToken,"f"),t(this,et,i.refreshToken,"f"),e(this,We,"m",at).call(this).catch(console.log)),e(this,We,"m",xt).call(this)}getBaseUrl(){return e(this,ze,"f")}clear(){e(this,qe,"f").clear(),this.clearActiveLogin()}clearActiveLogin(){e(this,qe,"f").setString("activeLogin",void 0),e(this,Fe,"f").clear(),t(this,Ke,void 0,"f"),t(this,et,void 0,"f"),t(this,it,void 0,"f"),t(this,ot,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(t){t=t.toString(),e(this,Fe,"f").delete(t)}invalidateSearches(t){const n="fhir/R4/"+t;for(const t of e(this,Fe,"f").keys())(t.endsWith(n)||t.includes(n+"?"))&&e(this,Fe,"f").delete(t)}get(t,n={}){t=t.toString();const i=e(this,We,"m",st).call(this,t,n);if(i)return i.value;const o=new Ce(e(this,We,"m",dt).call(this,"GET",t,n));return e(this,We,"m",ct).call(this,t,o),o}post(t,n,i,o={}){return t=t.toString(),n&&e(this,We,"m",mt).call(this,o,n),i&&e(this,We,"m",ut).call(this,o,i),this.invalidateUrl(t),e(this,We,"m",dt).call(this,"POST",t,o)}put(t,n,i,o={}){return t=t.toString(),n&&e(this,We,"m",mt).call(this,o,n),i&&e(this,We,"m",ut).call(this,o,i),this.invalidateUrl(t),e(this,We,"m",dt).call(this,"PUT",t,o)}patch(t,n,i={}){return t=t.toString(),e(this,We,"m",mt).call(this,i,n),e(this,We,"m",ut).call(this,i,"application/json-patch+json"),this.invalidateUrl(t),e(this,We,"m",dt).call(this,"PATCH",t,i)}delete(t,n={}){return t=t.toString(),this.invalidateUrl(t),e(this,We,"m",dt).call(this,"DELETE",t,n)}async startNewUser(e){const{codeChallengeMethod:t,codeChallenge:n}=await this.startPkce();return this.post("auth/newuser",{...e,codeChallengeMethod:t,codeChallenge:n})}async startNewProject(e){return this.post("auth/newproject",e)}async startNewPatient(e){return this.post("auth/newpatient",e)}async startLogin(t){return this.post("auth/login",{...await this.ensureCodeChallenge(t),clientId:t.clientId??e(this,Je,"f"),scope:t.scope})}async startGoogleLogin(t){return this.post("auth/google",{...await this.ensureCodeChallenge(t),clientId:t.clientId??e(this,Je,"f"),scope:t.scope})}async ensureCodeChallenge(e){return e.codeChallenge?e:{...e,...await this.startPkce()}}signOut(){this.clear()}async signInWithRedirect(t){const n=new URLSearchParams(window.location.search).get("code");return n?this.processCode(n):void await e(this,We,"m",ht).call(this,t)}signOutWithRedirect(){window.location.assign(e(this,Xe,"f"))}fhirUrl(...t){return new URL(e(this,ze,"f")+"fhir/R4/"+t.join("/"))}fhirSearchUrl(e,t){const n=this.fhirUrl(e);return t&&(n.search=t.toString()),n}search(e,t,n={}){return this.get(this.fhirSearchUrl(e,t),n)}searchOne(t,n,i={}){const o=this.fhirSearchUrl(t,n);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=e(this,We,"m",st).call(this,r,i);if(a)return a.value;const s=new Ce(this.search(t,o.searchParams,i).then((e=>e.entry?.[0]?.resource)));return e(this,We,"m",ct).call(this,r,s),s}searchResources(t,n,i={}){const o=this.fhirSearchUrl(t,n).toString()+"-searchResources",r=e(this,We,"m",st).call(this,o,i);if(r)return r.value;const a=new Ce(this.search(t,n,i).then((e=>e.entry?.map((e=>e.resource))??[])));return e(this,We,"m",ct).call(this,o,a),a}searchValueSet(e,t,n={}){const i=this.fhirUrl("ValueSet","$expand");return i.searchParams.set("url",e),i.searchParams.set("filter",t),this.get(i.toString(),n)}getCached(t,n){const i=e(this,Fe,"f").get(this.fhirUrl(t,n).toString())?.value;return i&&i.isOk()?i.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[n,i]=t.split("/");return n&&i?this.getCached(n,i):void 0}readResource(e,t,n={}){return this.get(this.fhirUrl(e,t),n)}readReference(e,t={}){const n=e?.reference;if(!n)return new Ce(Promise.reject(new Error("Missing reference")));const[i,o]=n.split("/");return i&&o?this.readResource(i,o,t):new Ce(Promise.reject(new Error("Invalid reference")))}getSchema(){return Qe}async requestSchema(e){if(e in Qe.types)return Qe;const t=`{\n StructureDefinitionList(name: "${e}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${e}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),n=await this.graphql(t);for(const e of n.data.StructureDefinitionList)Le(e);for(const e of n.data.SearchParameterList)Oe(e);return Qe}readHistory(e,t,n={}){return this.get(this.fhirUrl(e,t,"_history"),n)}readVersion(e,t,n,i={}){return this.get(this.fhirUrl(e,t,"_history",n),i)}readPatientEverything(e,t={}){return this.get(this.fhirUrl("Patient",e,"$everything"),t)}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}async createResourceIfNoneExist(e,t){return await this.searchOne(e.resourceType,t)??this.createResource(e)}createBinary(e,t,n,i){const o=this.fhirUrl("Binary");return t&&o.searchParams.set("_filename",t),i?this.uploadwithProgress(o,e,n,i):this.post(o,e,n)}uploadwithProgress(t,n,i,o){return new Promise(((r,a)=>{const s=new XMLHttpRequest;s.responseType="json",s.onabort=()=>a(new Error("Request aborted")),s.onerror=()=>a(new Error("Request error")),o&&(s.upload.onprogress=e=>o(e),s.upload.onload=e=>o(e)),s.onload=()=>{s.status>=200&&s.status<300?r(s.response):a(new Error(s.statusText))},s.open("POST",t),s.withCredentials=!0,s.setRequestHeader("Authorization","Bearer "+e(this,Ke,"f")),s.setRequestHeader("Cache-Control","no-cache, no-store, max-age=0"),s.setRequestHeader("Content-Type",i),s.setRequestHeader("X-Medplum","extended"),s.send(n)}))}async createPdf(t,n,i,o){if(!e(this,$e,"f"))throw new Error("PDF creation not enabled");const r=await e(this,$e,"f").call(this,t,i,o);return this.createBinary(r,n,"application/pdf")}createComment(e,t){const n=this.getProfile();let i,o;return"Encounter"===e.resourceType&&(i=A(e),o=e.subject),"ServiceRequest"===e.resourceType&&(i=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=A(e)),this.createResource({resourceType:"Communication",basedOn:[A(e)],encounter:i,subject:o,sender:n?A(n):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}async updateResource(e){if(!e.resourceType)throw new Error("Missing resourceType");if(!e.id)throw new Error("Missing id");this.invalidateSearches(e.resourceType);return await this.put(this.fhirUrl(e.resourceType,e.id),e)??e}patchResource(e,t,n){return this.invalidateSearches(e),this.patch(this.fhirUrl(e,t),n)}deleteResource(e,t){return this.invalidateSearches(e),this.delete(this.fhirUrl(e,t))}validateResource(e){return this.post(this.fhirUrl(e.resourceType,"$validate"),e)}executeBatch(e){return this.post("fhir/R4",e)}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t,n,i){return this.post(this.fhirUrl("$graphql"),{query:e,operationName:t,variables:n},"application/json",i)}readResourceGraph(e,t,n){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${n}`)}getActiveLogin(){return e(this,qe,"f").getObject("activeLogin")}async setActiveLogin(n){this.clearActiveLogin(),t(this,Ke,n.accessToken,"f"),t(this,et,n.refreshToken,"f"),e(this,qe,"f").setObject("activeLogin",n),e(this,We,"m",rt).call(this,n),t(this,tt,void 0,"f"),await e(this,We,"m",at).call(this)}getAccessToken(){return e(this,Ke,"f")}setAccessToken(e){t(this,Ke,e,"f"),t(this,et,void 0,"f"),t(this,it,void 0,"f"),t(this,ot,void 0,"f")}getLogins(){return e(this,qe,"f").getObject("logins")??[]}isLoading(){return!!e(this,nt,"f")}getProfile(){return e(this,it,"f")}async getProfileAsync(){return e(this,nt,"f")&&await e(this,nt,"f"),this.getProfile()}getUserConfiguration(){return e(this,ot,"f")}async download(t,n={}){e(this,tt,"f")&&await e(this,tt,"f"),e(this,We,"m",lt).call(this,n);return(await e(this,Be,"f").call(this,t.toString(),n)).blob()}async startPkce(){const e=he();sessionStorage.setItem("pkceState",e);const t=he();sessionStorage.setItem("codeVerifier",t);const n=Z(await async function(e){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}(t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return sessionStorage.setItem("codeChallenge",n),{codeChallengeMethod:"S256",codeChallenge:n}}processCode(t){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("client_id",e(this,Je,"f")),n.set("code",t),n.set("redirect_uri",St());const i=sessionStorage.getItem("codeVerifier");return i&&n.set("code_verifier",i),e(this,We,"m",yt).call(this,n)}async startClientLogin(n,i){t(this,Je,n,"f"),t(this,Ze,i,"f");const o=new URLSearchParams;return o.set("grant_type","client_credentials"),o.set("client_id",n),o.set("client_secret",i),e(this,We,"m",yt).call(this,o)}}function St(){return window.location.protocol+"//"+window.location.host+"/"}var Et,Tt,bt,Dt,Ct,At,Pt,Rt,kt,Mt,It,Lt,Ut,Ot,Nt,_t,jt,Qt,Wt,Bt,$t,qt,Ft,Ht,zt,Gt,Vt,Xt,Yt,Jt,Zt,Kt;Be=new WeakMap,$e=new WeakMap,qe=new WeakMap,Fe=new WeakMap,He=new WeakMap,ze=new WeakMap,Ge=new WeakMap,Ve=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Ke=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,it=new WeakMap,ot=new WeakMap,We=new WeakSet,rt=function(t){const n=this.getLogins().filter((e=>e.profile?.reference!==t.profile?.reference));n.push(t),e(this,qe,"f").setObject("logins",n)},at=async function(){return t(this,nt,new Promise(((n,i)=>{this.get("auth/me").then((i=>{t(this,nt,void 0,"f"),t(this,it,i.profile,"f"),t(this,ot,i.config,"f"),this.dispatchEvent({type:"change"}),n(e(this,it,"f"))})).catch(i)})),"f"),e(this,nt,"f")},st=function(t,n){if(e(this,He,"f")<=0||"no-cache"===n?.cache||"reload"===n?.cache)return;const i=e(this,Fe,"f").get(t);return!i||i.requestTime+e(this,He,"f")<Date.now()?void 0:i},ct=function(t,n){e(this,He,"f")>0&&e(this,Fe,"f").set(t,{requestTime:Date.now(),value:n})},dt=async function(t,n,i={}){e(this,tt,"f")&&await e(this,tt,"f"),n.startsWith("http")||(n=e(this,ze,"f")+n),i.method=t,e(this,We,"m",lt).call(this,i);const o=await e(this,Be,"f").call(this,n,i);if(401===o.status)return e(this,We,"m",pt).call(this,t,n,i);if(204===o.status||304===o.status)return;const r=await o.json();if(o.status>=400)throw r;return r},lt=function(t){t.headers||(t.headers={});const n=t.headers;n["X-Medplum"]="extended",n["Content-Type"]||(n["Content-Type"]="application/fhir+json"),e(this,Ke,"f")&&(n.Authorization="Bearer "+e(this,Ke,"f")),t.cache||(t.cache="no-cache"),t.credentials||(t.credentials="include")},ut=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},mt=function(e,t){"string"==typeof t||"undefined"!=typeof Blob&&t instanceof Blob||"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Uint8Array&&t instanceof Uint8Array?e.body=t:t&&(e.body=JSON.stringify(t))},pt=function(t,n,i){return e(this,We,"m",ft).call(this)?e(this,We,"m",dt).call(this,t,n,i):(this.clearActiveLogin(),e(this,Ye,"f")&&e(this,Ye,"f").call(this),Promise.reject(new Error("Unauthenticated")))},ht=async function(t){const n=await this.ensureCodeChallenge(t||{}),i=new URL(e(this,Ge,"f"));i.searchParams.set("response_type","code"),i.searchParams.set("state",sessionStorage.getItem("pkceState")),i.searchParams.set("client_id",n.clientId||e(this,Je,"f")),i.searchParams.set("redirect_uri",n.redirectUri||St()),i.searchParams.set("code_challenge_method",n.codeChallengeMethod),i.searchParams.set("code_challenge",n.codeChallenge),i.searchParams.set("scope",n.scope||"openid profile"),window.location.assign(i.toString())},ft=function(){if(e(this,tt,"f"))return e(this,tt,"f");if(e(this,et,"f")){const n=new URLSearchParams;return n.set("grant_type","refresh_token"),n.set("client_id",e(this,Je,"f")),n.set("refresh_token",e(this,et,"f")),t(this,tt,e(this,We,"m",yt).call(this,n),"f"),e(this,tt,"f")}return e(this,Je,"f")&&e(this,Ze,"f")?(t(this,tt,this.startClientLogin(e(this,Je,"f"),e(this,Ze,"f")),"f"),e(this,tt,"f")):void 0},yt=async function(t){const n=await e(this,Be,"f").call(this,e(this,Ve,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t,credentials:"include"});if(!n.ok)throw this.clearActiveLogin(),new Error("Failed to fetch tokens");const i=await n.json();return await e(this,We,"m",gt).call(this,i),this.getProfile()},gt=async function(t){const n=t.access_token,i=De(n);if(Date.now()>=1e3*i.exp)throw this.clearActiveLogin(),new Error("Token expired");if(e(this,Je,"f")&&i.client_id!==e(this,Je,"f"))throw this.clearActiveLogin(),new Error("Token was not issued for this audience");return this.setActiveLogin({accessToken:n,refreshToken:t.refresh_token,project:t.project,profile:t.profile})},xt=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};class en{constructor(e,t){this.operator=e,this.child=t}toString(){return`${this.operator}(${this.child.toString()})`}}class tn{constructor(e,t,n){this.operator=e,this.left=t,this.right=n}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}class nn{constructor(){Et.set(this,{}),Tt.set(this,{})}registerInfix(t,n){return e(this,Tt,"f")[t]=n,this}registerPrefix(t,n){return e(this,Et,"f")[t]=n,this}prefix(e,t,n){return this.registerPrefix(e,{parse(e,i){const o=e.consumeAndParse(t);return n(i,o)}})}infixLeft(e,t,n){return this.registerInfix(e,{parse(e,i,o){const r=e.consumeAndParse(t);return n(i,o,r)},precedence:t})}construct(t){return new on(t,e(this,Et,"f"),e(this,Tt,"f"))}}Et=new WeakMap,Tt=new WeakMap;class on{constructor(e,n,i){bt.set(this,void 0),Dt.set(this,void 0),Ct.set(this,void 0),t(this,bt,e,"f"),t(this,Dt,n,"f"),t(this,Ct,i,"f")}hasMore(){return e(this,bt,"f").length>0}match(e){return this.peek()?.id===e&&(this.consume(),!0)}consumeAndParse(t=1/0){const n=this.consume(),i=e(this,Dt,"f")[n.id];if(!i)throw Error(`Parse error at "${n.value}" (line ${n.line}, column ${n.column}). No matching prefix parselet.`);let o=i.parse(this,n);for(;t>this.getPrecedence();){const e=this.consume();o=this.getInfixParselet(e).parse(this,o,e)}return o}getPrecedence(){const e=this.peek();if(!e)return 1/0;const t=this.getInfixParselet(e);return t?t.precedence:1/0}consume(t,n){if(!e(this,bt,"f").length)throw Error("Cant consume unknown more tokens.");if(t&&this.peek()?.id!==t){const e=this.peek();throw Error(`Expected ${t} but got "${e.id}" at line ${e.line} column ${e.column}.`)}if(n&&this.peek()?.value!==n){const e=this.peek();throw Error(`Expected "${n}" but got "${e.value}" at line ${e.line} column ${e.column}.`)}return e(this,bt,"f").shift()}peek(){return e(this,bt,"f").length>0?e(this,bt,"f")[0]:void 0}removeComments(){t(this,bt,e(this,bt,"f").filter((e=>"Comment"!==e.id)),"f")}getInfixParselet(t){return e(this,Ct,"f")["Symbol"===t.id?t.value:t.id]}}bt=new WeakMap,Dt=new WeakMap,Ct=new WeakMap;const rn=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class an{constructor(e,n,i){At.add(this),Pt.set(this,void 0),Rt.set(this,void 0),kt.set(this,void 0),Mt.set(this,[]),It.set(this,{index:0,line:1,column:0}),Lt.set(this,[]),t(this,Pt,e,"f"),t(this,Rt,n,"f"),t(this,kt,i,"f")}tokenize(){for(;e(this,It,"f").index<e(this,Pt,"f").length;){const t=e(this,At,"m",Nt).call(this);t&&e(this,Mt,"f").push(t)}return e(this,Mt,"f")}}function sn(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch(t){return e}}function cn(e){return[{type:Re.boolean,value:e}]}function dn(e){return null==e?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:Re.integer,value:e}:"number"==typeof e?{type:Re.decimal,value:e}:"boolean"==typeof e?{type:Re.boolean,value:e}:"string"==typeof e?{type:Re.string,value:e}:En(e)?{type:Re.Quantity,value:e}:"object"==typeof e&&"resourceType"in e?{type:e.resourceType,value:e}:{type:Re.BackboneElement,value:e}}function ln(e){return 0!==e.length&&!!e[0].value}function un(e,t){if(!e?.value)return;const n=je(e.type,t);if(n){const i=function(e,t,n){const i=n.type;if(!i||0===i.length)return;let o,r="undefined";if(1===i.length)o=e.value[t],r=i[0].code;else for(const n of i){const i=t.replace("[x]","")+K(n.code);if(i in e.value){o=e.value[i],r=n.code;break}}if(F(o))return;"Element"!==r&&"BackboneElement"!==r||(r=Ne(n.path?.split(".")));return Array.isArray(o)?o.map((e=>mn(e,r))):mn(o,r)}(e,t,n);if(i)return i}return function(e,t){const n=e.value;if(!n||"object"!=typeof n)return;let i;if(t in n)i=n[t];else for(const e in Re){const o=t+K(e);if(o in n){i=n[o];break}}if(F(i))return;return Array.isArray(i)?i.map(dn):dn(i)}(e,t)}function mn(e,t){return"Resource"===t&&"object"==typeof e&&"resourceType"in e&&(t=e.resourceType),{type:t,value:e}}function pn(e){const t=[];for(const n of e){let e=!1;for(const i of t)if(ln(yn(n,i))){e=!0;break}e||t.push(n)}return t}function hn(e){return cn(!ln(e))}function fn(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?cn(!1):cn(e.every(((e,n)=>ln(yn(e,t[n])))))}function yn(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?cn(Math.abs(n-i)<1e-8):En(n)&&En(i)?cn(Tn(n,i)):cn("object"==typeof n&&"object"==typeof i?bn(e,t):n===i)}function gn(e,t){return 0===e.length&&0===t.length?cn(!0):e.length!==t.length?cn(!1):(e.sort(vn),t.sort(vn),cn(e.every(((e,n)=>ln(xn(e,t[n]))))))}function xn(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?cn(Math.abs(n-i)<.01):En(n)&&En(i)?cn(Tn(n,i)):cn("object"==typeof n&&"object"==typeof i?bn(n,i):"string"==typeof n&&"string"==typeof i?n.toLowerCase()===i.toLowerCase():n===i)}function vn(e,t){const n=e.value,i=t.value;return"number"==typeof n&&"number"==typeof i?n-i:"string"==typeof n&&"string"==typeof i?n.localeCompare(i):0}function wn(e,t){const{value:n}=e;if(null==n)return!1;switch(t){case"Boolean":return"boolean"==typeof n;case"Decimal":case"Integer":return"number"==typeof n;case"Date":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof n&&!!n.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof n&&!!n.match(/^T\d/);case"Period":return Sn(n);case"Quantity":return En(n);default:return"object"==typeof n&&n?.resourceType===t}}function Sn(e){return!(!e||"object"!=typeof e||!("start"in e))}function En(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function Tn(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function bn(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){const n=e[i],o=t[i];if(Dn(n)&&Dn(o)){if(!bn(n,o))return!1}else if(n!==o)return!1}return!0}function Dn(e){return null!==e&&"object"==typeof e}Pt=new WeakMap,Rt=new WeakMap,kt=new WeakMap,Mt=new WeakMap,It=new WeakMap,Lt=new WeakMap,At=new WeakSet,Ut=function(){return e(this,Mt,"f").slice(-1)[0]},Ot=function(){e(this,At,"m",Yt).call(this);const t=e(this,At,"m",Nt).call(this);return e(this,At,"m",Jt).call(this),t},Nt=function(){e(this,At,"m",_t).call(this);const t=e(this,At,"m",Gt).call(this);if(!t)return;e(this,At,"m",Yt).call(this);const n=e(this,At,"m",Xt).call(this);return"/"===t&&"*"===n?e(this,At,"m",jt).call(this):"/"===t&&"/"===n?e(this,At,"m",Qt).call(this):"'"===t||'"'===t?e(this,At,"m",Wt).call(this,t):"`"===t?e(this,At,"m",Bt).call(this):"@"===t?e(this,At,"m",$t).call(this):t.match(/\d/)?e(this,At,"m",qt).call(this):t.match(/\w/)||"$"===t&&n.match(/\w/)?e(this,At,"m",Ft).call(this):e(this,At,"m",Ht).call(this)},_t=function(){e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/\s/)))},jt=function(){const t=e(this,It,"f").index;return e(this,At,"m",zt).call(this,(()=>"*"!==e(this,At,"m",Gt).call(this)||"/"!==e(this,At,"m",Xt).call(this))),e(this,At,"m",Zt).call(this),e(this,At,"m",Zt).call(this),e(this,At,"m",Kt).call(this,"Comment",e(this,Pt,"f").substring(t,e(this,It,"f").index))},Qt=function(){return e(this,At,"m",Kt).call(this,"Comment",e(this,At,"m",zt).call(this,(()=>"\n"!==e(this,At,"m",Gt).call(this))))},Wt=function(t){e(this,At,"m",Zt).call(this);const n=e(this,At,"m",Kt).call(this,"String",e(this,At,"m",zt).call(this,(()=>"\\"===e(this,At,"m",Vt).call(this)||e(this,At,"m",Gt).call(this)!==t)));return e(this,At,"m",Zt).call(this),n},Bt=function(){e(this,At,"m",Zt).call(this);const t=e(this,At,"m",Kt).call(this,"Symbol",e(this,At,"m",zt).call(this,(()=>"`"!==e(this,At,"m",Gt).call(this))));return e(this,At,"m",Zt).call(this),t},$t=function(){e(this,At,"m",Zt).call(this);const t=e(this,It,"f").index;return e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/[\d-]/))),"T"===e(this,At,"m",Gt).call(this)&&(e(this,At,"m",Zt).call(this),e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/[\d:]/))),"."===e(this,At,"m",Gt).call(this)&&e(this,At,"m",Xt).call(this).match(/\d/)&&(e(this,At,"m",Zt).call(this),e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/\d/)))),"Z"===e(this,At,"m",Gt).call(this)?e(this,At,"m",Zt).call(this):"+"!==e(this,At,"m",Gt).call(this)&&"-"!==e(this,At,"m",Gt).call(this)||(e(this,At,"m",Zt).call(this),e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/[\d:]/))))),e(this,At,"m",Kt).call(this,"DateTime",e(this,Pt,"f").substring(t,e(this,It,"f").index))},qt=function(){const t=e(this,It,"f").index;let n="Number";return e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/\d/))),"."===e(this,At,"m",Gt).call(this)&&e(this,At,"m",Xt).call(this).match(/\d/)&&(e(this,At,"m",Zt).call(this),e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/\d/))))," "===e(this,At,"m",Gt).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&rn.includes(e.value))return!0}return!1}(e(this,At,"m",Ot).call(this))&&(n="Quantity",e(this,At,"m",Nt).call(this)),e(this,At,"m",Kt).call(this,n,e(this,Pt,"f").substring(t,e(this,It,"f").index))},Ft=function(){const t=e(this,At,"m",zt).call(this,(()=>e(this,At,"m",Gt).call(this).match(/[$\w]/)));return"."!==e(this,At,"m",Ut).call(this)?.value&&e(this,Rt,"f").includes(t)?e(this,At,"m",Kt).call(this,t,t):e(this,At,"m",Kt).call(this,"Symbol",t)},Ht=function(){const t=e(this,At,"m",Gt).call(this),n=t+e(this,At,"m",Xt).call(this);return e(this,kt,"f").includes(n)?(e(this,At,"m",Zt).call(this),e(this,At,"m",Zt).call(this),e(this,At,"m",Kt).call(this,n,n)):(e(this,At,"m",Zt).call(this),e(this,At,"m",Kt).call(this,t,t))},zt=function(t){const n=e(this,It,"f").index;for(;e(this,It,"f").index<e(this,Pt,"f").length&&t();)e(this,At,"m",Zt).call(this);return e(this,Pt,"f").substring(n,e(this,It,"f").index)},Gt=function(){return e(this,Pt,"f")[e(this,It,"f").index]},Vt=function(){return e(this,Pt,"f")[e(this,It,"f").index-1]??""},Xt=function(){return e(this,Pt,"f")[e(this,It,"f").index+1]??""},Yt=function(){e(this,Lt,"f").push({...e(this,It,"f")})},Jt=function(){const t=e(this,Lt,"f").pop();if(!t)throw new Error("No mark to reset to");e(this,It,"f").index=t.index,e(this,It,"f").line=t.line,e(this,It,"f").column=t.column},Zt=function(){e(this,It,"f").index++,"\n"===e(this,At,"m",Gt).call(this)?(e(this,It,"f").line++,e(this,It,"f").column=0):e(this,It,"f").column++},Kt=function(t,n){const i=e(this,Lt,"f").pop();if(!i)throw new Error("No mark for token");return{id:t,value:n,...i}};const Cn=()=>[],An={empty:e=>cn(0===e.length),exists:(e,t)=>cn(t?e.filter((e=>ln(t.eval([e])))).length>0:e.length>0),all:(e,t)=>cn(e.every((e=>ln(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return cn(!1);return cn(!0)},anyTrue:e=>{for(const t of e)if(t.value)return cn(!0);return cn(!1)},allFalse:e=>{for(const t of e)if(t.value)return cn(!1);return cn(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return cn(!0);return cn(!1)},subsetOf:Cn,supersetOf:Cn,count:e=>[{type:Re.integer,value:e.length}],distinct:e=>{const t=[];for(const n of e)t.some((e=>e.value===n.value))||t.push(n);return t},isDistinct:e=>cn(e.length===An.distinct(e).length),where:(e,t)=>e.filter((e=>ln(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:Cn,ofType:(e,t)=>e.filter((e=>e.type===t.name)),single:e=>{if(e.length>1)throw new Error("Expected input length one for single()");return 0===e.length?[]:e.slice(0,1)},first:e=>0===e.length?[]:e.slice(0,1),last:e=>0===e.length?[]:e.slice(e.length-1,e.length),tail:e=>0===e.length?[]:e.slice(1,e.length),skip:(e,t)=>{const n=t.eval(e)[0]?.value;if("number"!=typeof n)throw new Error("Expected a number for skip(num)");return n>=e.length?[]:n<=0?e:e.slice(n,e.length)},take:(e,t)=>{const n=t.eval(e)[0]?.value;if("number"!=typeof n)throw new Error("Expected a number for take(num)");return n>=e.length?e:n<=0?[]:e.slice(0,n)},intersect:(e,t)=>{if(!t)return e;const n=t.eval(e),i=[];for(const t of e)!i.some((e=>e.value===t.value))&&n.some((e=>e.value===t.value))&&i.push(t);return i},exclude:(e,t)=>{if(!t)return e;const n=t.eval(e),i=[];for(const t of e)n.some((e=>e.value===t.value))||i.push(t);return i},union:(e,t)=>{if(!t)return e;const n=t.eval(e);return pn([...e,...n])},combine:(e,t)=>{if(!t)return e;const n=t.eval(e);return[...e,...n]},iif:(e,t,n,i)=>{const o=t.eval(e);if(o.length>1||1===o.length&&"boolean"!=typeof o[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return ln(o)?n.eval(e):i?i.eval(e):[]},toBoolean:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);if("boolean"==typeof t)return[{type:Re.boolean,value:t}];if("number"==typeof t&&(0===t||1===t))return cn(!!t);if("string"==typeof t){const e=t.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return cn(!0);if(["false","f","no","n","0","0.0"].includes(e))return cn(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:cn(1===An.toBoolean(e).length),toInteger:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);return"number"==typeof t?[{type:Re.integer,value:t}]:"string"==typeof t&&t.match(/^[+-]?\d+$/)?[{type:Re.integer,value:parseInt(t,10)}]:"boolean"==typeof t?[{type:Re.integer,value:t?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:cn(1===An.toInteger(e).length),toDate:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:Re.date,value:sn(t)}]:[]},convertsToDate:e=>0===e.length?[]:cn(1===An.toDate(e).length),toDateTime:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);return"string"==typeof t&&t.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:Re.dateTime,value:sn(t)}]:[]},convertsToDateTime:e=>0===e.length?[]:cn(1===An.toDateTime(e).length),toDecimal:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);return"number"==typeof t?[{type:Re.decimal,value:t}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:Re.decimal,value:parseFloat(t)}]:"boolean"==typeof t?[{type:Re.decimal,value:t?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:cn(1===An.toDecimal(e).length),toQuantity:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);return En(t)?[{type:Re.Quantity,value:t}]:"number"==typeof t?[{type:Re.Quantity,value:{value:t,unit:"1"}}]:"string"==typeof t&&t.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:Re.Quantity,value:{value:parseFloat(t),unit:"1"}}]:"boolean"==typeof t?[{type:Re.Quantity,value:{value:t?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:cn(1===An.toQuantity(e).length),toString:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);return null==t?[]:En(t)?[{type:Re.string,value:`${t.value} '${t.unit}'`}]:[{type:Re.string,value:t.toString()}]},convertsToString:e=>0===e.length?[]:cn(1===An.toString(e).length),toTime:e=>{if(0===e.length)return[];const[{value:t}]=kn(e,1);if("string"==typeof t){const e=t.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(e)return[{type:Re.time,value:sn("T"+e[1])}]}return[]},convertsToTime:e=>0===e.length?[]:cn(1===An.toTime(e).length),indexOf:(e,t)=>Pn(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,n)=>Pn(((e,t,n)=>{const i=t,o=n?i+n:e.length;return i<0||i>=e.length?void 0:e.substring(i,o)}),e,t,n),startsWith:(e,t)=>Pn(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>Pn(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>Pn(((e,t)=>e.includes(t)),e,t),upper:e=>Pn((e=>e.toUpperCase()),e),lower:e=>Pn((e=>e.toLowerCase()),e),replace:(e,t,n)=>Pn(((e,t,n)=>e.replaceAll(t,n)),e,t,n),matches:(e,t)=>Pn(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,n)=>Pn(((e,t,n)=>e.replaceAll(t,n)),e,t,n),length:e=>Pn((e=>e.length),e),toChars:e=>Pn((e=>e?e.split(""):void 0),e),abs:e=>Rn(Math.abs,e),ceiling:e=>Rn(Math.ceil,e),exp:e=>Rn(Math.exp,e),floor:e=>Rn(Math.floor,e),ln:e=>Rn(Math.log,e),log:(e,t)=>Rn(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>Rn(Math.pow,e,t),round:e=>Rn(Math.round,e),sqrt:e=>Rn(Math.sqrt,e),truncate:e=>Rn((e=>0|e),e),children:Cn,descendants:Cn,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:Re.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:Re.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:Re.date,value:(new Date).toISOString().substring(0,10)}],between:(e,t,n,i)=>{const o=An.toDateTime(t.eval(e));if(0===o.length)throw new Error("Invalid start date");const r=An.toDateTime(n.eval(e));if(0===r.length)throw new Error("Invalid end date");const a=i.eval(e)[0]?.value;if("years"!==a&&"months"!==a&&"days"!==a)throw new Error("Invalid units");const s=O(o[0].value,r[0].value);return[{type:Re.Quantity,value:{value:s[a],unit:a}}]},is:(e,t)=>{let n="";return t instanceof On?n=t.name:t instanceof qn&&(n=t.left.name+"."+t.right.name),n?e.map((e=>({type:Re.boolean,value:wn(e,n)}))):[]},not:e=>An.toBoolean(e).map((e=>({type:Re.boolean,value:!e.value}))),resolve:e=>e.map((e=>{const t=e.value;let n;if("string"==typeof t)n=t;else if("object"==typeof t){const e=t;if(e.resource)return dn(e.resource);n=e.reference}if(!n)return{type:Re.BackboneElement,value:null};const[i,o]=n.split("/");return{type:Re.BackboneElement,value:{resourceType:i,id:o}}})).filter((e=>!!e.value)),as:e=>e,type:e=>e.map((({value:e})=>"boolean"==typeof e?{type:Re.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof e?{type:Re.BackboneElement,value:{namespace:"System",name:"Integer"}}:e&&"object"==typeof e&&"resourceType"in e?{type:Re.BackboneElement,value:{namespace:"FHIR",name:e.resourceType}}:{type:Re.BackboneElement,value:null})),conformsTo:(e,t)=>{const n=t.eval(e)[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const i=n.replace("http://hl7.org/fhir/StructureDefinition/","");return e.map((e=>({type:Re.boolean,value:e.value?.resourceType===i})))}};function Pn(e,t,...n){if(0===t.length)return[];const[{value:i}]=kn(t,1);if("string"!=typeof i)throw new Error("String function cannot be called with non-string");const o=e(i,...n.map((e=>e&&e.eval(t)?.[0]?.value)));return void 0===o?[]:Array.isArray(o)?o.map(dn):[dn(o)]}function Rn(e,t,...n){if(0===t.length)return[];const[{value:i}]=kn(t,1),o=En(i),r=o?i.value:i;if("number"!=typeof r)throw new Error("Math function cannot be called with non-number");const a=e(r,...n.map((e=>e.eval(t)?.[0]?.value)));return[{type:o?Re.Quantity:t[0].type,value:o?{...i,value:a}:a}]}function kn(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const t of e)if(null==t)throw new Error("Expected non-null argument");return e}var Mn,In;class Ln{constructor(e,t){this.original=e,this.child=t}eval(e){try{return e.length>0?e.map((e=>this.child.eval([e]))).flat():this.child.eval([])}catch(e){throw new Error(`FhirPathError on "${this.original}": ${e}`)}}toString(){return this.child.toString()}}class Un{constructor(e){this.value=e}eval(){return[this.value]}toString(){const e=this.value.value;return"string"==typeof e?`'${e}'`:e.toString()}}class On{constructor(e){this.name=e,Mn.add(this)}eval(t){return"$this"===this.name?t:t.map((t=>e(this,Mn,"m",In).call(this,t))).flat().filter((e=>void 0!==e?.value))}toString(){return this.name}}Mn=new WeakSet,In=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:un(e,this.name)};class Nn{eval(){return[]}toString(){return"{}"}}class _n extends en{constructor(e,t,n){super(e,t),this.impl=n}eval(e){return this.impl(this.child.eval(e))}toString(){return this.child.toString()}}class jn extends tn{constructor(e,t){super("as",e,t)}eval(e){return An.ofType(this.left.eval(e),this.right)}}class Qn extends tn{constructor(e,t,n,i){super(e,t,n),this.impl=i}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const n=this.right.eval(e);if(1!==n.length)return[];const i=t[0].value,o=n[0].value,r=En(i)?i.value:i,a=En(o)?o.value:o,s=this.impl(r,a);return"boolean"==typeof s?cn(s):En(i)?[{type:Re.Quantity,value:{...i,value:s}}]:[dn(s)]}}class Wn extends tn{constructor(e,t){super("&",e,t)}eval(e){const t=[...this.left.eval(e),...this.right.eval(e)];return t.length>0&&t.every((e=>"string"==typeof e.value))?[{type:Re.string,value:t.map((e=>e.value)).join("")}]:t}}class Bn extends tn{constructor(e,t){super("contains",e,t)}eval(e){const t=this.left.eval(e),n=this.right.eval(e);return cn(t.some((e=>e.value===n[0].value)))}}class $n extends tn{constructor(e,t){super("in",e,t)}eval(e){const t=this.left.eval(e);return cn(this.right.eval(e).some((e=>e.value===t[0].value)))}}class qn extends tn{constructor(e,t){super(".",e,t)}eval(e){return this.right.eval(this.left.eval(e))}toString(){return`${this.left.toString()}.${this.right.toString()}`}}class Fn extends tn{constructor(e,t){super("|",e,t)}eval(e){return pn([...this.left.eval(e),...this.right.eval(e)])}}class Hn extends tn{constructor(e,t){super("=",e,t)}eval(e){return fn(this.left.eval(e),this.right.eval(e))}}class zn extends tn{constructor(e,t){super("!=",e,t)}eval(e){return hn(fn(this.left.eval(e),this.right.eval(e)))}}class Gn extends tn{constructor(e,t){super("~",e,t)}eval(e){return gn(this.left.eval(e),this.right.eval(e))}}class Vn extends tn{constructor(e,t){super("!~",e,t)}eval(e){return hn(gn(this.left.eval(e),this.right.eval(e)))}}class Xn extends tn{constructor(e,t){super("is",e,t)}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const n=this.right.name;return cn(wn(t[0],n))}}class Yn extends tn{constructor(e,t){super("and",e,t)}eval(e){const t=this.left.eval(e),n=this.right.eval(e);return!0===t[0]?.value&&!0===n[0]?.value?cn(!0):!1===t[0]?.value||!1===n[0]?.value?cn(!1):[]}}class Jn extends tn{constructor(e,t){super("or",e,t)}eval(e){const t=this.left.eval(e);if(ln(t))return t;const n=this.right.eval(e);return ln(n)?n:[]}}class Zn extends tn{constructor(e,t){super("xor",e,t)}eval(e){const t=this.left.eval(e),n=this.right.eval(e);if(0===t.length&&0===n.length)return[];const i=0===t.length?null:t[0].value,o=0===n.length?null:n[0].value;return!0===i&&!0!==o||!0!==i&&!0===o?cn(!0):!0===i&&!0===o||!1===i&&!1===o?cn(!1):[]}}class Kn{constructor(e,t){this.name=e,this.args=t}eval(e){const t=An[this.name];if(!t)throw new Error("Unrecognized function: "+this.name);return t(e,...this.args)}toString(){return`${this.name}(${this.args.map((e=>e.toString())).join(", ")})`}}class ei{constructor(e,t){this.left=e,this.expr=t}eval(e){const t=this.expr.eval(e);if(1!==t.length)return[];const n=t[0].value;if("number"!=typeof n)throw new Error("Invalid indexer expression: should return integer}");const i=this.left.eval(e);return n in i?[i[n]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}}const ti=["true","false"],ni=["!=","!~","<=",">=","{}","->"];function ii(e){return new an(e,ti,ni).tokenize()}const oi={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)` got `"+e.peek()?.value+"`");return t}},ri={parse(e,t){const n=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new ei(t,n)},precedence:2},ai={parse(e,t){if(!(t instanceof On))throw new Error("Unexpected parentheses");const n=[];for(;!e.match(")");)n.push(e.consumeAndParse()),e.match(",");return new Kn(t.name,n)},precedence:0};function si(e){const t=e.split(" "),n=parseFloat(t[0]);let i=t[1];return i=i&&i.startsWith("'")&&i.endsWith("'")?i.substring(1,i.length-1):"{"+i+"}",{value:n,unit:i}}function ci(){return(new nn).registerPrefix("String",{parse:(e,t)=>new Un({type:Re.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new Un({type:Re.dateTime,value:sn(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new Un({type:Re.Quantity,value:si(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new Un({type:Re.decimal,value:parseFloat(t.value)})}).registerPrefix("true",{parse:()=>new Un({type:Re.boolean,value:!0})}).registerPrefix("false",{parse:()=>new Un({type:Re.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new On(t.value)}).registerPrefix("{}",{parse:()=>new Nn}).registerPrefix("(",oi).registerInfix("[",ri).registerInfix("(",ai).prefix("+",3,((e,t)=>new _n("+",t,(e=>e)))).prefix("-",3,((e,t)=>new Qn("-",t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,n)=>new qn(e,n))).infixLeft("/",4,((e,t,n)=>new Qn("/",e,n,((e,t)=>e/t)))).infixLeft("*",4,((e,t,n)=>new Qn("*",e,n,((e,t)=>e*t)))).infixLeft("+",5,((e,t,n)=>new Qn("+",e,n,((e,t)=>e+t)))).infixLeft("-",5,((e,t,n)=>new Qn("-",e,n,((e,t)=>e-t)))).infixLeft("|",7,((e,t,n)=>new Fn(e,n))).infixLeft("=",9,((e,t,n)=>new Hn(e,n))).infixLeft("!=",9,((e,t,n)=>new zn(e,n))).infixLeft("~",9,((e,t,n)=>new Gn(e,n))).infixLeft("!~",9,((e,t,n)=>new Vn(e,n))).infixLeft("<",8,((e,t,n)=>new Qn("<",e,n,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,n)=>new Qn("<=",e,n,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,n)=>new Qn(">",e,n,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,n)=>new Qn(">=",e,n,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,n)=>new Wn(e,n))).infixLeft("and",6,((e,t,n)=>new Yn(e,n))).infixLeft("as",6,((e,t,n)=>new jn(e,n))).infixLeft("contains",6,((e,t,n)=>new Bn(e,n))).infixLeft("div",6,((e,t,n)=>new Qn("div",e,n,((e,t)=>e/t|0)))).infixLeft("in",6,((e,t,n)=>new $n(e,n))).infixLeft("is",6,((e,t,n)=>new Xn(e,n))).infixLeft("mod",6,((e,t,n)=>new Qn("mod",e,n,((e,t)=>e%t)))).infixLeft("or",6,((e,t,n)=>new Jn(e,n))).infixLeft("xor",6,((e,t,n)=>new Zn(e,n)))}const di=ci();function li(e){return new Ln(e,di.construct(ii(e)).consumeAndParse())}function ui(e,t){const n=Array.isArray(t)?t:[t];for(let e=0;e<n.length;e++){const t=n[e];"object"==typeof t&&"type"in t&&"value"in t||(n[e]=dn(n[e]))}return mi(e,n).map((e=>e.value))}function mi(e,t){return li(e).eval(t)}class pi{constructor(e="\r",t="|",n="^",i="~",o="\\",r="&"){this.segmentSeparator=e,this.fieldSeparator=t,this.componentSeparator=n,this.repetitionSeparator=i,this.escapeCharacter=o,this.subcomponentSeparator=r}getMsh2(){return this.fieldSeparator+this.componentSeparator+this.repetitionSeparator+this.escapeCharacter+this.subcomponentSeparator}}class hi{constructor(e,t=new pi){this.context=t,this.segments=e}get(e){return"number"==typeof e?this.segments[e]:this.segments.find((t=>t.name===e))}getAll(e){return this.segments.filter((t=>t.name===e))}toString(){return this.segments.map((e=>e.toString())).join(this.context.segmentSeparator)}buildAck(){const e=new Date,t=this.get("MSH"),n=t?.get(2)?.toString()||"",i=t?.get(3)?.toString()||"",o=t?.get(4)?.toString()||"",r=t?.get(5)?.toString()||"",a=t?.get(9)?.toString()||"",s=t?.get(12)?.toString()||"2.5.1";return new hi([new fi(["MSH",this.context.getMsh2(),o,r,n,i,e.toISOString(),"","ACK",e.getTime().toString(),"P",s],this.context),new fi(["MSA","AA",a,"OK"],this.context)])}static parse(e){if(!e.startsWith("MSH")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}const t=new pi("\r",e.charAt(3),e.charAt(4),e.charAt(5),e.charAt(6),e.charAt(7));return new hi(e.split(/[\r\n]+/).map((e=>fi.parse(e,t))),t)}}class fi{constructor(e,t=new pi){this.context=t,X(e)?this.fields=e.map((e=>yi.parse(e))):this.fields=e,this.name=this.fields[0].components[0][0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join(this.context.fieldSeparator)}static parse(e,t=new pi){return new fi(e.split(t.fieldSeparator).map((e=>yi.parse(e,t))),t)}}class yi{constructor(e,t=new pi){this.context=t,this.components=e}get(e,t,n=0){let i=this.components[n][e]||"";return void 0!==t&&(i=i.split(this.context.subcomponentSeparator)[t]||""),i}toString(){return this.components.map((e=>e.join(this.context.componentSeparator))).join(this.context.repetitionSeparator)}static parse(e,t=new pi){return new yi(e.split(t.repetitionSeparator).map((e=>e.split(t.componentSeparator))),t)}}const gi=20;var xi;!function(e){e.EQUALS="eq",e.NOT_EQUALS="ne",e.GREATER_THAN="gt",e.LESS_THAN="lt",e.GREATER_THAN_OR_EQUALS="ge",e.LESS_THAN_OR_EQUALS="le",e.STARTS_AFTER="sa",e.ENDS_BEFORE="eb",e.APPROXIMATELY="ap",e.CONTAINS="contains",e.EXACT="exact",e.TEXT="text",e.NOT="not",e.ABOVE="above",e.BELOW="below",e.IN="in",e.NOT_IN="not-in",e.OF_TYPE="of-type",e.MISSING="missing"}(xi||(xi={}));const vi=[xi.CONTAINS,xi.EXACT,xi.TEXT,xi.NOT,xi.ABOVE,xi.BELOW,xi.IN,xi.NOT_IN,xi.OF_TYPE,xi.MISSING],wi=[xi.NOT_EQUALS,xi.GREATER_THAN,xi.LESS_THAN,xi.GREATER_THAN_OR_EQUALS,xi.LESS_THAN_OR_EQUALS,xi.STARTS_AFTER,xi.ENDS_BEFORE,xi.APPROXIMATELY];function Si(e){const t=new URL(e,"https://example.com/"),n=t.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let i,o,r,a,s,c;return new URLSearchParams(t.search).forEach(((e,t)=>{"_fields"===t?r=e.split(","):"_offset"===t?a=parseInt(e):"_count"===t?s=parseInt(e):"_total"===t?c=e:"_sort"===t?(o=o||[],o.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(e))):(i=i||[],i.push(function(e,t){let n=e,i=xi.EQUALS;for(const e of vi){const t=n.indexOf(":"+e);-1!==t&&(i=e,n=n.substring(0,t))}for(const e of wi)t.match(new RegExp("^"+e+"\\d"))&&(i=e,t=t.substring(e.length));return{code:n,operator:i,value:t}}(t,e)))})),{resourceType:n,filters:i,fields:r,offset:a,count:s,total:c,sortRules:o}}function Ei(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=vi.includes(e.operator)?":"+e.operator:"",n=wi.includes(e.operator)?e.operator:"";return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))}var Ti;function bi(e,t){let n=Qe.types[e]?.searchParamsDetails?.[t.code];return n||(n=function(e,t){if("_lastUpdated"===t.code)return{columnName:"lastUpdated",type:Ti.DATETIME};const n=t.code,i=function(e){return e.split("-").reduce(((e,t,n)=>e+(n?K(t):t)),"")}(n),o=Ci(e,t.expression)?.split(".");if(!o)return{columnName:i,type:Ti.TEXT};const r=Di(t);let a,s,c=e,d=!1;for(let n=1;n<o.length;n++){const l=o[n];if(a=Qe.types[c]?.properties?.[l]??Qe.types[c]?.properties?.[l+"[x]"],!a)throw new Error(`Element definition not found for ${e} ${t.code}`);if("*"===a.max&&(d=!0),s=a.type?.[0].code,!s)return{columnName:i,type:r,array:d};n<o.length-1&&("Element"===s||"BackboneElement"===s?c+=K(l):c=s)}const l=Di(t,s),u={columnName:i,type:l,elementDefinition:a,array:d};return function(e,t,n){const i=Qe.types[e];i.searchParamsDetails||(i.searchParamsDetails={});i.searchParamsDetails[t]=n}(e,n,u),u}(e,t)),n}function Di(e,t){let n=Ti.TEXT;switch(e.type){case"date":n=t===Re.dateTime||t===Re.instant?Ti.DATETIME:Ti.DATE;break;case"number":n=Ti.NUMBER;break;case"quantity":n=Ti.QUANTITY;break;case"reference":n=Ti.REFERENCE;break;case"token":"boolean"===t&&(n=Ti.BOOLEAN)}return n}function Ci(e,t){const n=t.split(" | ");for(const t of n){if((i=t).includes(" as Period")||i.includes(" as SampledDate"))continue;const n=Ai(t);if(n.startsWith(e+"."))return n}var i}function Ai(e){let t=e.trim();t.startsWith("(")&&t.endsWith(")")&&(t=t.substring(1,t.length-1)),t.includes("[0]")&&(t=t.replaceAll("[0]",""));const n=[" != "," as ",".as(",".exists(",".where("];for(const e of n)t.includes(e)&&(t=t.substring(0,t.indexOf(e)));return t}function Pi(e,t){if(t.resourceType!==e.resourceType)return!1;if(t.filters)for(const n of t.filters)if(!Ri(e,t,n))return!1;return!0}function Ri(e,t,n){const i=Qe.types[t.resourceType]?.searchParams?.[n.code];switch(i?.type){case"reference":return function(e,t,n){const i=ui(n.expression,e),o=Li(t.operator);if(""===t.value&&0===i.length)return t.operator===xi.EQUALS;const r=i.map((e=>"string"==typeof e?e:e.reference));for(const e of t.value.split(",")){let n=r.includes(e);if(n||"_compartment"!==t.code||(n=r.some((t=>t?.endsWith("/"+e)))),n)return!o}return o}(e,n,i);case"string":return ki(e,n,i);case"token":return function(e,t,n){const i=bi(e.resourceType,n);return i.type===Ti.BOOLEAN?function(e,t,n){const i=ui(n.expression,e),o="true"===t.value,r=i.includes(o);return Li(t.operator)?!r:r}(e,t,n):ki(e,t,n)}(e,n,i);case"date":return function(e,t,n){const i=ui(n.expression,e),o=t.value.split(","),r=Li(t.operator);for(const e of i)for(const n of o){if(Ii(e,t.operator,n))return!r}return r}(e,n,i)}return!1}function ki(e,t,n){const i=ui(n.expression,e),o=t.value.split(","),r=Li(t.operator);for(const e of i)for(const n of o){if(Mi(e,t.operator,n))return!r}return r}function Mi(e,t,n){let i="";return e&&("string"==typeof e?i=e:"object"==typeof e&&(i=JSON.stringify(e))),i.toLowerCase().includes(n.toLowerCase())}function Ii(e,t,n){switch(t){case xi.STARTS_AFTER:case xi.GREATER_THAN:return e>n;case xi.GREATER_THAN_OR_EQUALS:return e>=n;case xi.ENDS_BEFORE:case xi.LESS_THAN:return e<n;case xi.LESS_THAN_OR_EQUALS:return e<=n;case xi.EQUALS:case xi.NOT_EQUALS:return e===n}return!1}function Li(e){return e===xi.NOT_EQUALS||e===xi.NOT}!function(e){e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.QUANTITY="QUANTITY",e.TEXT="TEXT",e.REFERENCE="REFERENCE",e.DATE="DATE",e.DATETIME="DATETIME",e.PERIOD="PERIOD"}(Ti||(Ti={}));const Ui="ok",Oi="created",Ni="gone",_i="not-modified",ji="not-found",Qi="unauthorized",Wi="forbidden",Bi="too-many-requests",$i={resourceType:"OperationOutcome",id:Ui,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},qi={resourceType:"OperationOutcome",id:Oi,issue:[{severity:"information",code:"informational",details:{text:"Created"}}]},Fi={resourceType:"OperationOutcome",id:_i,issue:[{severity:"information",code:"informational",details:{text:"Not Modified"}}]},Hi={resourceType:"OperationOutcome",id:ji,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},zi={resourceType:"OperationOutcome",id:Qi,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Gi={resourceType:"OperationOutcome",id:Wi,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]},Vi={resourceType:"OperationOutcome",id:Ni,issue:[{severity:"error",code:"deleted",details:{text:"Gone"}}]},Xi={resourceType:"OperationOutcome",id:Bi,issue:[{severity:"error",code:"throttled",details:{text:"Too Many Requests"}}]};function Yi(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}}function Ji(e){return e.id===Ui||e.id===Oi||e.id===_i}function Zi(e){return e.id===ji}function Ki(e){return e.id===Ni}function eo(e){return e.id===Ui?200:e.id===Oi?201:e.id===_i?304:e.id===Qi?401:e.id===Wi?403:e.id===ji?404:e.id===Ni?410:e.id===Bi?429:400}function to(e,t){if(!Ji(e)||void 0===t)throw new no(e)}class no extends Error{constructor(e){super(e?.issue?.[0].details?.text),this.outcome=e}}function io(e){if(!e)return"Unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message;if("object"==typeof e&&"resourceType"in e){return e.issue?.[0]?.details?.text??"Unknown error"}return JSON.stringify(e)}export{Yn as AndAtom,Qn as ArithemticOperatorAtom,jn as AsAtom,Wn as ConcatAtom,Bn as ContainsAtom,gi as DEFAULT_SEARCH_COUNT,qn as DotAtom,Nn as EmptySetAtom,Hn as EqualsAtom,Gn as EquivalentAtom,ti as FHIRPATH_KEYWORDS,ni as FHIRPATH_OPERATORS,Ln as FhirPathAtom,Kn as FunctionAtom,pi as Hl7Context,yi as Hl7Field,hi as Hl7Message,fi as Hl7Segment,$n as InAtom,ei as IndexerAtom,Xn as IsAtom,a as LRUCache,Un as LiteralAtom,vt as MEDPLUM_VERSION,wt as MedplumClient,zn as NotEqualsAtom,Vn as NotEquivalentAtom,no as OperationOutcomeError,xi as Operator,Jn as OrAtom,Re as PropertyType,Ce as ReadablePromise,Ti as SearchParameterType,On as SymbolAtom,_n as UnaryOperatorAtom,Fn as UnionAtom,Zn as XorAtom,$i as allOk,Z as arrayBufferToBase64,J as arrayBufferToHex,to as assertOk,Yi as badRequest,cn as booleanToTypedValue,Ne as buildTypeName,O as calculateAge,N as calculateAgeString,K as capitalize,A as createReference,Me as createSchema,qi as created,z as deepClone,H as deepEquals,ui as evalFhirPath,mi as evalFhirPathTyped,fn as fhirPathArrayEquals,gn as fhirPathArrayEquivalent,yn as fhirPathEquals,xn as fhirPathEquivalent,wn as fhirPathIs,hn as fhirPathNot,ie as findObservationInterval,oe as findObservationReferenceRange,Gi as forbidden,s as formatAddress,T as formatCodeableConcept,b as formatCoding,m as formatDate,h as formatDateTime,l as formatFamilyName,d as formatGivenName,c as formatHumanName,E as formatMoney,D as formatObservationValue,f as formatPeriod,S as formatQuantity,w as formatRange,Ei as formatSearchQuery,p as formatTime,v as formatTiming,te as getCodeBySystem,U as getDateProperty,M as getDisplayString,je as getElementDefinition,Ci as getExpressionForResourceType,B as getExtension,W as getExtensionValue,Q as getIdentifier,I as getImageSrc,_e as getPropertyDisplayName,_ as getQuestionnaireAnswers,P as getReferenceString,bi as getSearchParameterDetails,eo as getStatus,un as getTypedPropertyValue,Qe as globalSchema,Vi as gone,Oe as indexSearchParameter,Ue as indexSearchParameterBundle,Le as indexStructureDefinition,Ie as indexStructureDefinitionBundle,ci as initFhirPathParserBuilder,F as isEmpty,Ki as isGone,ee as isLowerCase,Zi as isNotFound,V as isObject,Ji as isOk,Sn as isPeriod,k as isProfileResource,En as isQuantity,Tn as isQuantityEquivalent,X as isStringArray,G as isUUID,u as isValidDate,ae as matchesRange,Pi as matchesSearchRequest,io as normalizeErrorString,Hi as notFound,Fi as notModified,li as parseFhirPath,De as parseJWTPayload,Si as parseSearchDefinition,ce as preciseEquals,le as preciseGreaterThan,me as preciseGreaterThanOrEquals,de as preciseLessThan,ue as preciseLessThanOrEquals,se as preciseRound,pn as removeDuplicates,R as resolveId,ne as setCodeBySystem,$ as stringify,ln as toJsBoolean,dn as toTypedValue,ii as tokenize,Xi as tooManyRequests,zi as unauthorized};
@@ -1,17 +1,17 @@
1
- export { LRUCache } from './cache.js';
2
- export { MEDPLUM_VERSION, MedplumClient } from './client.js';
3
- export { AndAtom, ArithemticOperatorAtom, AsAtom, ConcatAtom, ContainsAtom, DotAtom, EmptySetAtom, EqualsAtom, EquivalentAtom, FhirPathAtom, FunctionAtom, InAtom, IndexerAtom, IsAtom, LiteralAtom, NotEqualsAtom, NotEquivalentAtom, OrAtom, SymbolAtom, UnaryOperatorAtom, UnionAtom, XorAtom } from './fhirpath/atoms.js';
4
- export { evalFhirPath, evalFhirPathTyped, initFhirPathParserBuilder, parseFhirPath } from './fhirpath/parse.js';
5
- export { FHIRPATH_KEYWORDS, FHIRPATH_OPERATORS, tokenize } from './fhirpath/tokenize.js';
6
- export { booleanToTypedValue, fhirPathArrayEquals, fhirPathArrayEquivalent, fhirPathEquals, fhirPathEquivalent, fhirPathIs, fhirPathNot, getTypedPropertyValue, isPeriod, isQuantity, isQuantityEquivalent, removeDuplicates, toJsBoolean, toTypedValue } from './fhirpath/utils.js';
7
- export { formatAddress, formatCodeableConcept, formatCoding, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatObservationValue, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate } from './format.js';
8
- export { Hl7Context, Hl7Field, Hl7Message, Hl7Segment } from './hl7.js';
9
- export { parseJWTPayload } from './jwt.js';
10
- export { matchesSearchRequest } from './match.js';
11
- export { OperationOutcomeError, allOk, assertOk, badRequest, created, forbidden, getStatus, gone, isGone, isNotFound, isOk, normalizeErrorString, notFound, notModified, tooManyRequests, unauthorized } from './outcomes.js';
12
- export { ReadablePromise } from './readablepromise.js';
13
- export { DEFAULT_SEARCH_COUNT, Operator, formatSearchQuery, parseSearchDefinition } from './search.js';
14
- export { SearchParameterType, getExpressionForResourceType, getSearchParameterDetails } from './searchparams.js';
15
- export { PropertyType, buildTypeName, createSchema, getElementDefinition, getPropertyDisplayName, globalSchema, indexSearchParameter, indexSearchParameterBundle, indexStructureDefinition, indexStructureDefinitionBundle } from './types.js';
16
- export { arrayBufferToBase64, arrayBufferToHex, calculateAge, calculateAgeString, capitalize, createReference, deepClone, deepEquals, findObservationInterval, findObservationReferenceRange, getCodeBySystem, getDateProperty, getDisplayString, getExtensionValue, getIdentifier, getImageSrc, getQuestionnaireAnswers, getReferenceString, isEmpty, isLowerCase, isObject, isProfileResource, isStringArray, isUUID, matchesRange, preciseEquals, preciseGreaterThan, preciseGreaterThanOrEquals, preciseLessThan, preciseLessThanOrEquals, preciseRound, resolveId, setCodeBySystem, stringify } from './utils.js';
17
- //# sourceMappingURL=index.js.map
1
+ export { LRUCache } from './cache.mjs';
2
+ export { MEDPLUM_VERSION, MedplumClient } from './client.mjs';
3
+ export { AndAtom, ArithemticOperatorAtom, AsAtom, ConcatAtom, ContainsAtom, DotAtom, EmptySetAtom, EqualsAtom, EquivalentAtom, FhirPathAtom, FunctionAtom, InAtom, IndexerAtom, IsAtom, LiteralAtom, NotEqualsAtom, NotEquivalentAtom, OrAtom, SymbolAtom, UnaryOperatorAtom, UnionAtom, XorAtom } from './fhirpath/atoms.mjs';
4
+ export { evalFhirPath, evalFhirPathTyped, initFhirPathParserBuilder, parseFhirPath } from './fhirpath/parse.mjs';
5
+ export { FHIRPATH_KEYWORDS, FHIRPATH_OPERATORS, tokenize } from './fhirpath/tokenize.mjs';
6
+ export { booleanToTypedValue, fhirPathArrayEquals, fhirPathArrayEquivalent, fhirPathEquals, fhirPathEquivalent, fhirPathIs, fhirPathNot, getTypedPropertyValue, isPeriod, isQuantity, isQuantityEquivalent, removeDuplicates, toJsBoolean, toTypedValue } from './fhirpath/utils.mjs';
7
+ export { formatAddress, formatCodeableConcept, formatCoding, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatMoney, formatObservationValue, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate } from './format.mjs';
8
+ export { Hl7Context, Hl7Field, Hl7Message, Hl7Segment } from './hl7.mjs';
9
+ export { parseJWTPayload } from './jwt.mjs';
10
+ export { matchesSearchRequest } from './match.mjs';
11
+ export { OperationOutcomeError, allOk, assertOk, badRequest, created, forbidden, getStatus, gone, isGone, isNotFound, isOk, normalizeErrorString, notFound, notModified, tooManyRequests, unauthorized } from './outcomes.mjs';
12
+ export { ReadablePromise } from './readablepromise.mjs';
13
+ export { DEFAULT_SEARCH_COUNT, Operator, formatSearchQuery, parseSearchDefinition } from './search.mjs';
14
+ export { SearchParameterType, getExpressionForResourceType, getSearchParameterDetails } from './searchparams.mjs';
15
+ export { PropertyType, buildTypeName, createSchema, getElementDefinition, getPropertyDisplayName, globalSchema, indexSearchParameter, indexSearchParameterBundle, indexStructureDefinition, indexStructureDefinitionBundle } from './types.mjs';
16
+ export { arrayBufferToBase64, arrayBufferToHex, calculateAge, calculateAgeString, capitalize, createReference, deepClone, deepEquals, findObservationInterval, findObservationReferenceRange, getCodeBySystem, getDateProperty, getDisplayString, getExtension, getExtensionValue, getIdentifier, getImageSrc, getQuestionnaireAnswers, getReferenceString, isEmpty, isLowerCase, isObject, isProfileResource, isStringArray, isUUID, matchesRange, preciseEquals, preciseGreaterThan, preciseGreaterThanOrEquals, preciseLessThan, preciseLessThanOrEquals, preciseRound, resolveId, setCodeBySystem, stringify } from './utils.mjs';
17
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}