@medplum/core 1.0.1 → 1.0.3

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.
@@ -1,7 +1,8 @@
1
- import { Address, HumanName, Period, Timing, Range, Quantity } from '@medplum/fhirtypes';
1
+ import { Address, CodeableConcept, Coding, HumanName, Observation, ObservationComponent, Period, Quantity, Range, Timing } from '@medplum/fhirtypes';
2
2
  export interface AddressFormatOptions {
3
3
  all?: boolean;
4
4
  use?: boolean;
5
+ lineSeparator?: string;
5
6
  }
6
7
  export interface HumanNameFormatOptions {
7
8
  all?: boolean;
@@ -9,25 +10,108 @@ export interface HumanNameFormatOptions {
9
10
  suffix?: boolean;
10
11
  use?: boolean;
11
12
  }
13
+ /**
14
+ * Formats a FHIR Address as a string.
15
+ * @param address The address to format.
16
+ * @param options Optional address format options.
17
+ * @returns The formatted address string.
18
+ */
12
19
  export declare function formatAddress(address: Address, options?: AddressFormatOptions): string;
20
+ /**
21
+ * Formats a FHIR HumanName as a string.
22
+ * @param name The name to format.
23
+ * @param options Optional name format options.
24
+ * @returns The formatted name string.
25
+ */
13
26
  export declare function formatHumanName(name: HumanName, options?: HumanNameFormatOptions): string;
27
+ /**
28
+ * Formats the given name portion of a FHIR HumanName element.
29
+ * @param name The name to format.
30
+ * @returns The formatted given name string.
31
+ */
14
32
  export declare function formatGivenName(name: HumanName): string;
33
+ /**
34
+ * Formats the family name portion of a FHIR HumanName element.
35
+ * @param name The name to format.
36
+ * @returns The formatted family name string.
37
+ */
15
38
  export declare function formatFamilyName(name: HumanName): string;
39
+ /**
40
+ * Returns true if the given date object is a valid date.
41
+ * Dates can be invalid if created by parsing an invalid string.
42
+ * @param date A date object.
43
+ * @returns Returns true if the date is a valid date.
44
+ */
16
45
  export declare function isValidDate(date: Date): boolean;
17
- export declare function formatDate(date: string | undefined, options?: Intl.DateTimeFormatOptions): string;
18
- export declare function formatTime(time: string | undefined, options?: Intl.DateTimeFormatOptions): string;
19
- export declare function formatDateTime(dateTime: string | undefined, options?: Intl.DateTimeFormatOptions): string;
20
- export declare function formatPeriod(period: Period | undefined): string;
46
+ /**
47
+ * Formats a FHIR date string as a human readable string.
48
+ * Handles missing values and invalid dates.
49
+ * @param date The date to format.
50
+ * @param locales Optional locales.
51
+ * @param options Optional date format options.
52
+ * @returns The formatted date string.
53
+ */
54
+ export declare function formatDate(date: string | undefined, locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
55
+ /**
56
+ * Formats a FHIR time string as a human readable string.
57
+ * Handles missing values and invalid dates.
58
+ * @param time The date to format.
59
+ * @param locales Optional locales.
60
+ * @param options Optional time format options.
61
+ * @returns The formatted time string.
62
+ */
63
+ export declare function formatTime(time: string | undefined, locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
64
+ /**
65
+ * Formats a FHIR dateTime string as a human readable string.
66
+ * Handles missing values and invalid dates.
67
+ * @param dateTime The dateTime to format.
68
+ * @param locales Optional locales.
69
+ * @param options Optional dateTime format options.
70
+ * @returns The formatted dateTime string.
71
+ */
72
+ export declare function formatDateTime(dateTime: string | undefined, locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
73
+ /**
74
+ * Formats a FHIR Period as a human readable string.
75
+ * @param period The period to format.
76
+ * @param locales Optional locales.
77
+ * @param options Optional period format options.
78
+ * @returns The formatted period string.
79
+ */
80
+ export declare function formatPeriod(period: Period | undefined, locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
81
+ /**
82
+ * Formats a FHIR Timing as a human readable string.
83
+ * @param timing The timing to format.
84
+ * @returns The formatted timing string.
85
+ */
21
86
  export declare function formatTiming(timing: Timing | undefined): string;
22
87
  /**
23
88
  * Returns a human-readable string for a FHIR Range datatype, taking into account comparators and one-sided ranges
24
89
  * @param range A FHIR Range element
90
+ * @param exclusive If true, one-sided ranges will be rendered with the '>' or '<' bounds rather than '>=' or '<='
25
91
  * @returns A human-readable string representation of the Range
26
92
  */
27
- export declare function formatRange(range: Range | undefined): string;
93
+ export declare function formatRange(range: Range | undefined, precision?: number, exclusive?: boolean): string;
28
94
  /**
29
95
  * Returns a human-readable string for a FHIR Quantity datatype, taking into account units and comparators
30
96
  * @param quantity A FHIR Quantity element
31
97
  * @returns A human-readable string representation of the Quantity
32
98
  */
33
99
  export declare function formatQuantity(quantity: Quantity | undefined, precision?: number): string;
100
+ /**
101
+ * Formats a CodeableConcept element as a string.
102
+ * @param codeableConcept A FHIR CodeableConcept element
103
+ * @returns The codeable concept as a string.
104
+ */
105
+ export declare function formatCodeableConcept(codeableConcept: CodeableConcept | undefined): string;
106
+ /**
107
+ * Formats a Coding element as a string.
108
+ * @param coding A FHIR Coding element
109
+ * @returns The coding as a string.
110
+ */
111
+ export declare function formatCoding(coding: Coding | undefined): string;
112
+ /**
113
+ * Formats a FHIR Observation resource value as a string.
114
+ * @param obs A FHIR Observation resource.
115
+ * @returns A human-readable string representation of the Observation.
116
+ */
117
+ export declare function formatObservationValue(obs: Observation | ObservationComponent | undefined): string;
@@ -1,24 +1,40 @@
1
1
  import { capitalize } from './utils.js';
2
2
 
3
+ /**
4
+ * Formats a FHIR Address as a string.
5
+ * @param address The address to format.
6
+ * @param options Optional address format options.
7
+ * @returns The formatted address string.
8
+ */
3
9
  function formatAddress(address, options) {
4
10
  const builder = [];
5
11
  if (address.line) {
6
12
  builder.push(...address.line);
7
13
  }
8
- if (address.city) {
9
- builder.push(address.city);
10
- }
11
- if (address.state) {
12
- builder.push(address.state);
13
- }
14
- if (address.postalCode) {
15
- builder.push(address.postalCode);
14
+ if (address.city || address.state || address.postalCode) {
15
+ const cityStateZip = [];
16
+ if (address.city) {
17
+ cityStateZip.push(address.city);
18
+ }
19
+ if (address.state) {
20
+ cityStateZip.push(address.state);
21
+ }
22
+ if (address.postalCode) {
23
+ cityStateZip.push(address.postalCode);
24
+ }
25
+ builder.push(cityStateZip.join(', '));
16
26
  }
17
27
  if (address.use && ((options === null || options === void 0 ? void 0 : options.all) || (options === null || options === void 0 ? void 0 : options.use))) {
18
28
  builder.push('[' + address.use + ']');
19
29
  }
20
- return builder.join(', ').trim();
30
+ return builder.join((options === null || options === void 0 ? void 0 : options.lineSeparator) || ', ').trim();
21
31
  }
32
+ /**
33
+ * Formats a FHIR HumanName as a string.
34
+ * @param name The name to format.
35
+ * @param options Optional name format options.
36
+ * @returns The formatted name string.
37
+ */
22
38
  function formatHumanName(name, options) {
23
39
  const builder = [];
24
40
  if (name.prefix && (options === null || options === void 0 ? void 0 : options.prefix) !== false) {
@@ -38,6 +54,11 @@ function formatHumanName(name, options) {
38
54
  }
39
55
  return builder.join(' ').trim();
40
56
  }
57
+ /**
58
+ * Formats the given name portion of a FHIR HumanName element.
59
+ * @param name The name to format.
60
+ * @returns The formatted given name string.
61
+ */
41
62
  function formatGivenName(name) {
42
63
  const builder = [];
43
64
  if (name.given) {
@@ -45,13 +66,32 @@ function formatGivenName(name) {
45
66
  }
46
67
  return builder.join(' ').trim();
47
68
  }
69
+ /**
70
+ * Formats the family name portion of a FHIR HumanName element.
71
+ * @param name The name to format.
72
+ * @returns The formatted family name string.
73
+ */
48
74
  function formatFamilyName(name) {
49
75
  return name.family || '';
50
76
  }
77
+ /**
78
+ * Returns true if the given date object is a valid date.
79
+ * Dates can be invalid if created by parsing an invalid string.
80
+ * @param date A date object.
81
+ * @returns Returns true if the date is a valid date.
82
+ */
51
83
  function isValidDate(date) {
52
84
  return date instanceof Date && !isNaN(date.getTime());
53
85
  }
54
- function formatDate(date, options) {
86
+ /**
87
+ * Formats a FHIR date string as a human readable string.
88
+ * Handles missing values and invalid dates.
89
+ * @param date The date to format.
90
+ * @param locales Optional locales.
91
+ * @param options Optional date format options.
92
+ * @returns The formatted date string.
93
+ */
94
+ function formatDate(date, locales, options) {
55
95
  if (!date) {
56
96
  return '';
57
97
  }
@@ -59,9 +99,18 @@ function formatDate(date, options) {
59
99
  if (!isValidDate(d)) {
60
100
  return '';
61
101
  }
62
- return d.toLocaleDateString(undefined, options);
102
+ d.setUTCHours(0, 0, 0, 0);
103
+ return d.toLocaleDateString(locales, Object.assign({ timeZone: 'UTC' }, options));
63
104
  }
64
- function formatTime(time, options) {
105
+ /**
106
+ * Formats a FHIR time string as a human readable string.
107
+ * Handles missing values and invalid dates.
108
+ * @param time The date to format.
109
+ * @param locales Optional locales.
110
+ * @param options Optional time format options.
111
+ * @returns The formatted time string.
112
+ */
113
+ function formatTime(time, locales, options) {
65
114
  if (!time) {
66
115
  return '';
67
116
  }
@@ -69,9 +118,17 @@ function formatTime(time, options) {
69
118
  if (!isValidDate(d)) {
70
119
  return '';
71
120
  }
72
- return d.toLocaleTimeString(undefined, options);
121
+ return d.toLocaleTimeString(locales, options);
73
122
  }
74
- function formatDateTime(dateTime, options) {
123
+ /**
124
+ * Formats a FHIR dateTime string as a human readable string.
125
+ * Handles missing values and invalid dates.
126
+ * @param dateTime The dateTime to format.
127
+ * @param locales Optional locales.
128
+ * @param options Optional dateTime format options.
129
+ * @returns The formatted dateTime string.
130
+ */
131
+ function formatDateTime(dateTime, locales, options) {
75
132
  if (!dateTime) {
76
133
  return '';
77
134
  }
@@ -79,13 +136,20 @@ function formatDateTime(dateTime, options) {
79
136
  if (!isValidDate(d)) {
80
137
  return '';
81
138
  }
82
- return d.toLocaleString(undefined, options);
139
+ return d.toLocaleString(locales, options);
83
140
  }
84
- function formatPeriod(period) {
141
+ /**
142
+ * Formats a FHIR Period as a human readable string.
143
+ * @param period The period to format.
144
+ * @param locales Optional locales.
145
+ * @param options Optional period format options.
146
+ * @returns The formatted period string.
147
+ */
148
+ function formatPeriod(period, locales, options) {
85
149
  if (!period || (!period.start && !period.end)) {
86
150
  return '';
87
151
  }
88
- return formatDateTime(period.start) + ' - ' + formatDateTime(period.end);
152
+ return formatDateTime(period.start, locales, options) + ' - ' + formatDateTime(period.end, locales, options);
89
153
  }
90
154
  const unitAdverbForm = {
91
155
  s: 'every second',
@@ -114,6 +178,11 @@ const pluralUnits = {
114
178
  mo: 'months',
115
179
  a: 'years',
116
180
  };
181
+ /**
182
+ * Formats a FHIR Timing as a human readable string.
183
+ * @param timing The timing to format.
184
+ * @returns The formatted timing string.
185
+ */
117
186
  function formatTiming(timing) {
118
187
  var _a;
119
188
  if (!timing) {
@@ -156,20 +225,37 @@ function formatTiming(timing) {
156
225
  /**
157
226
  * Returns a human-readable string for a FHIR Range datatype, taking into account comparators and one-sided ranges
158
227
  * @param range A FHIR Range element
228
+ * @param exclusive If true, one-sided ranges will be rendered with the '>' or '<' bounds rather than '>=' or '<='
159
229
  * @returns A human-readable string representation of the Range
160
230
  */
161
- function formatRange(range) {
162
- var _a, _b, _c, _d, _e, _f;
163
- if (!range || (((_a = range.low) === null || _a === void 0 ? void 0 : _a.value) === undefined && ((_b = range.high) === null || _b === void 0 ? void 0 : _b.value) === undefined)) {
231
+ function formatRange(range, precision, exclusive = false) {
232
+ var _a, _b, _c, _d;
233
+ if (exclusive && precision === undefined) {
234
+ throw new Error('Precision must be specified for exclusive ranges');
235
+ }
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)) {
164
239
  return '';
165
240
  }
166
- 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) {
167
- return `>= ${formatQuantity(range.low)}`;
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) {
242
+ if (exclusive && precision !== undefined) {
243
+ range.low.value = preciseDecrement(range.low.value, precision);
244
+ return `> ${formatQuantity(range.low, precision)}`;
245
+ }
246
+ return `>= ${formatQuantity(range.low, precision)}`;
247
+ }
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) {
249
+ if (exclusive && precision !== undefined) {
250
+ range.high.value = preciseIncrement(range.high.value, precision);
251
+ return `< ${formatQuantity(range.high, precision)}`;
252
+ }
253
+ return `<= ${formatQuantity(range.high, precision)}`;
168
254
  }
169
- if (((_e = range.low) === null || _e === void 0 ? void 0 : _e.value) === undefined && ((_f = range.high) === null || _f === void 0 ? void 0 : _f.value) !== undefined) {
170
- return `<= ${formatQuantity(range.high)}`;
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;
171
257
  }
172
- return `${formatQuantity(range.low)} - ${formatQuantity(range.high)}`;
258
+ return `${formatQuantity(low, precision)} - ${formatQuantity(high, precision)}`;
173
259
  }
174
260
  /**
175
261
  * Returns a human-readable string for a FHIR Quantity datatype, taking into account units and comparators
@@ -201,6 +287,85 @@ function formatQuantity(quantity, precision) {
201
287
  }
202
288
  return result.join('').trim();
203
289
  }
290
+ /**
291
+ * Formats a CodeableConcept element as a string.
292
+ * @param codeableConcept A FHIR CodeableConcept element
293
+ * @returns The codeable concept as a string.
294
+ */
295
+ function formatCodeableConcept(codeableConcept) {
296
+ if (!codeableConcept) {
297
+ return '';
298
+ }
299
+ if (codeableConcept.text) {
300
+ return codeableConcept.text;
301
+ }
302
+ if (codeableConcept.coding) {
303
+ return codeableConcept.coding.map((c) => formatCoding(c)).join(', ');
304
+ }
305
+ return '';
306
+ }
307
+ /**
308
+ * Formats a Coding element as a string.
309
+ * @param coding A FHIR Coding element
310
+ * @returns The coding as a string.
311
+ */
312
+ function formatCoding(coding) {
313
+ return (coding === null || coding === void 0 ? void 0 : coding.display) || (coding === null || coding === void 0 ? void 0 : coding.code) || '';
314
+ }
315
+ /**
316
+ * Formats a FHIR Observation resource value as a string.
317
+ * @param obs A FHIR Observation resource.
318
+ * @returns A human-readable string representation of the Observation.
319
+ */
320
+ function formatObservationValue(obs) {
321
+ if (!obs) {
322
+ return '';
323
+ }
324
+ if ('component' in obs) {
325
+ return obs.component.map((c) => formatObservationValue(c)).join(' / ');
326
+ }
327
+ if (obs === null || obs === void 0 ? void 0 : obs.valueQuantity) {
328
+ return formatQuantity(obs.valueQuantity);
329
+ }
330
+ if (obs.valueCodeableConcept) {
331
+ return formatCodeableConcept(obs.valueCodeableConcept);
332
+ }
333
+ if (obs.valueString) {
334
+ return obs.valueString;
335
+ }
336
+ return '';
337
+ }
338
+ /**
339
+ * Returns the input number increased by the `n` units of the specified precision
340
+ * @param a The input number
341
+ * @param precision The precision in number of digits.
342
+ * @param n (default 1) The number of units to add
343
+ */
344
+ function preciseIncrement(a, precision, n = 1) {
345
+ return (toPreciseInteger(a, precision) + n) * Math.pow(10, -precision);
346
+ }
347
+ /**
348
+ * Returns the input number decreased by the `n` units of the specified precision
349
+ * @param a The input number
350
+ * @param precision The precision in number of digits.
351
+ * @param n (default 1) The number of units to subtract
352
+ */
353
+ function preciseDecrement(a, precision, n = 1) {
354
+ return (toPreciseInteger(a, precision) - n) * Math.pow(10, -precision);
355
+ }
356
+ /**
357
+ * Returns an integer representation of the number with the given precision.
358
+ * For example, if precision is 2, then 1.2345 will be returned as 123.
359
+ * @param a The number.
360
+ * @param precision Optional precision in number of digits.
361
+ * @returns The integer with the given precision.
362
+ */
363
+ function toPreciseInteger(a, precision) {
364
+ if (precision === undefined) {
365
+ return a;
366
+ }
367
+ return Math.round(a * Math.pow(10, precision));
368
+ }
204
369
 
205
- export { formatAddress, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate };
370
+ export { formatAddress, formatCodeableConcept, formatCoding, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatObservationValue, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate };
206
371
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sources":["../../src/format.ts"],"sourcesContent":["import { Address, HumanName, Period, Timing, Range, Quantity } from '@medplum/fhirtypes';\nimport { capitalize } from './utils';\n\nexport interface AddressFormatOptions {\n all?: boolean;\n use?: boolean;\n}\n\nexport interface HumanNameFormatOptions {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n}\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) {\n builder.push(address.city);\n }\n\n if (address.state) {\n builder.push(address.state);\n }\n\n if (address.postalCode) {\n builder.push(address.postalCode);\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(', ').trim();\n}\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\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\nexport function formatFamilyName(name: HumanName): string {\n return name.family || '';\n}\n\nexport function isValidDate(date: Date): boolean {\n return date instanceof Date && !isNaN(date.getTime());\n}\n\nexport function formatDate(date: string | undefined, options?: Intl.DateTimeFormatOptions): string {\n if (!date) {\n return '';\n }\n const d = new Date(date);\n if (!isValidDate(d)) {\n return '';\n }\n return d.toLocaleDateString(undefined, options);\n}\n\nexport function formatTime(time: string | undefined, options?: Intl.DateTimeFormatOptions): 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(undefined, options);\n}\n\nexport function formatDateTime(dateTime: string | undefined, options?: Intl.DateTimeFormatOptions): string {\n if (!dateTime) {\n return '';\n }\n const d = new Date(dateTime);\n if (!isValidDate(d)) {\n return '';\n }\n return d.toLocaleString(undefined, options);\n}\n\nexport function formatPeriod(period: Period | undefined): string {\n if (!period || (!period.start && !period.end)) {\n return '';\n }\n return formatDateTime(period.start) + ' - ' + formatDateTime(period.end);\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\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 * @returns A human-readable string representation of the Range\n */\nexport function formatRange(range: Range | undefined): string {\n if (!range || (range.low?.value === undefined && range.high?.value === undefined)) {\n return '';\n }\n\n if (range.low?.value !== undefined && range.high?.value === undefined) {\n return `>= ${formatQuantity(range.low)}`;\n }\n\n if (range.low?.value === undefined && range.high?.value !== undefined) {\n return `<= ${formatQuantity(range.high)}`;\n }\n\n return `${formatQuantity(range.low)} - ${formatQuantity(range.high)}`;\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"],"names":[],"mappings":";;AAegB,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,EAAE;AAChB,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5B,KAAA;IAED,IAAI,OAAO,CAAC,KAAK,EAAE;AACjB,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7B,KAAA;IAED,IAAI,OAAO,C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C,IAAI,CAAC,EAAE,CAAC;AACxE,CAAC;AAED;;;;AAIG;AACa,SAAA,cAAc,CAAC,QAA8B,EAAE,SAAkB,EAAA;IAC/E,IAAI,CAAC,QAAQ,EAAE;AACb,QAAA,OAAO,EAAE,CAAC;AACX,KAAA;IAED,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,IAAI,QAAQ,CAAC,UAAU,EAAE;AACvB,QAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACjC,QAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClB,KAAA;AAED,IAAA,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;QAChC,IAAI,SAAS,KAAK,SAAS,EAAE;AAC3B,YAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;AAChD,SAAA;AAAM,aAAA;AACL,YAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7B,SAAA;AACF,KAAA;IAED,IAAI,QAAQ,CAAC,IAAI,EAAE;AACjB,QAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;AAC9D,YAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClB,SAAA;AACD,QAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC5B,KAAA;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAChC;;;;"}
1
+ {"version":3,"file":"format.js","sources":["../../src/format.ts"],"sourcesContent":["import {\n Address,\n CodeableConcept,\n Coding,\n HumanName,\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\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":";;AA2BA;;;;;AAKG;AACa,SAAA,aAAa,CAAC,OAAgB,EAAE,OAA8B,EAAA;IAC5E,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,IA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,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;;;;"}
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ export { AndAtom, ArithemticOperatorAtom, AsAtom, ConcatAtom, ContainsAtom, DotA
4
4
  export { evalFhirPath, evalFhirPathTyped, initFhirPathParserBuilder, parseFhirPath } from './fhirpath/parse.js';
5
5
  export { FHIRPATH_KEYWORDS, FHIRPATH_OPERATORS, tokenize } from './fhirpath/tokenize.js';
6
6
  export { booleanToTypedValue, fhirPathArrayEquals, fhirPathArrayEquivalent, fhirPathEquals, fhirPathEquivalent, fhirPathIs, fhirPathNot, getTypedPropertyValue, isPeriod, isQuantity, isQuantityEquivalent, removeDuplicates, toJsBoolean, toTypedValue } from './fhirpath/utils.js';
7
- export { formatAddress, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate } from './format.js';
7
+ export { formatAddress, formatCodeableConcept, formatCoding, formatDate, formatDateTime, formatFamilyName, formatGivenName, formatHumanName, formatObservationValue, formatPeriod, formatQuantity, formatRange, formatTime, formatTiming, isValidDate } from './format.js';
8
8
  export { Hl7Context, Hl7Field, Hl7Message, Hl7Segment } from './hl7.js';
9
9
  export { parseJWTPayload } from './jwt.js';
10
10
  export { matchesSearchRequest } from './match.js';