@medplum/core 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/fhirmapper/testall.d.ts +1 -0
- package/dist/cjs/format.d.ts +88 -5
- package/dist/cjs/index.js +138 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/client.js +1 -1
- package/dist/esm/fhirmapper/testall.d.ts +1 -0
- package/dist/esm/format.d.ts +88 -5
- package/dist/esm/format.js +135 -18
- package/dist/esm/format.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cjs/format.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Address, HumanName, Period,
|
|
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,15 +10,79 @@ 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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
@@ -32,3 +97,21 @@ export declare function formatRange(range: Range | undefined, precision?: number
|
|
|
32
97
|
* @returns A human-readable string representation of the Quantity
|
|
33
98
|
*/
|
|
34
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;
|
package/dist/cjs/index.js
CHANGED
|
@@ -108,25 +108,41 @@
|
|
|
108
108
|
return __classPrivateFieldGet(this, _LRUCache_cache, "f").keys().next().value;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Formats a FHIR Address as a string.
|
|
113
|
+
* @param address The address to format.
|
|
114
|
+
* @param options Optional address format options.
|
|
115
|
+
* @returns The formatted address string.
|
|
116
|
+
*/
|
|
111
117
|
function formatAddress(address, options) {
|
|
112
118
|
const builder = [];
|
|
113
119
|
if (address.line) {
|
|
114
120
|
builder.push(...address.line);
|
|
115
121
|
}
|
|
116
|
-
if (address.city) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
if (address.city || address.state || address.postalCode) {
|
|
123
|
+
const cityStateZip = [];
|
|
124
|
+
if (address.city) {
|
|
125
|
+
cityStateZip.push(address.city);
|
|
126
|
+
}
|
|
127
|
+
if (address.state) {
|
|
128
|
+
cityStateZip.push(address.state);
|
|
129
|
+
}
|
|
130
|
+
if (address.postalCode) {
|
|
131
|
+
cityStateZip.push(address.postalCode);
|
|
132
|
+
}
|
|
133
|
+
builder.push(cityStateZip.join(', '));
|
|
124
134
|
}
|
|
125
135
|
if (address.use && ((options === null || options === void 0 ? void 0 : options.all) || (options === null || options === void 0 ? void 0 : options.use))) {
|
|
126
136
|
builder.push('[' + address.use + ']');
|
|
127
137
|
}
|
|
128
|
-
return builder.join(', ').trim();
|
|
138
|
+
return builder.join((options === null || options === void 0 ? void 0 : options.lineSeparator) || ', ').trim();
|
|
129
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Formats a FHIR HumanName as a string.
|
|
142
|
+
* @param name The name to format.
|
|
143
|
+
* @param options Optional name format options.
|
|
144
|
+
* @returns The formatted name string.
|
|
145
|
+
*/
|
|
130
146
|
function formatHumanName(name, options) {
|
|
131
147
|
const builder = [];
|
|
132
148
|
if (name.prefix && (options === null || options === void 0 ? void 0 : options.prefix) !== false) {
|
|
@@ -146,6 +162,11 @@
|
|
|
146
162
|
}
|
|
147
163
|
return builder.join(' ').trim();
|
|
148
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Formats the given name portion of a FHIR HumanName element.
|
|
167
|
+
* @param name The name to format.
|
|
168
|
+
* @returns The formatted given name string.
|
|
169
|
+
*/
|
|
149
170
|
function formatGivenName(name) {
|
|
150
171
|
const builder = [];
|
|
151
172
|
if (name.given) {
|
|
@@ -153,13 +174,32 @@
|
|
|
153
174
|
}
|
|
154
175
|
return builder.join(' ').trim();
|
|
155
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Formats the family name portion of a FHIR HumanName element.
|
|
179
|
+
* @param name The name to format.
|
|
180
|
+
* @returns The formatted family name string.
|
|
181
|
+
*/
|
|
156
182
|
function formatFamilyName(name) {
|
|
157
183
|
return name.family || '';
|
|
158
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Returns true if the given date object is a valid date.
|
|
187
|
+
* Dates can be invalid if created by parsing an invalid string.
|
|
188
|
+
* @param date A date object.
|
|
189
|
+
* @returns Returns true if the date is a valid date.
|
|
190
|
+
*/
|
|
159
191
|
function isValidDate(date) {
|
|
160
192
|
return date instanceof Date && !isNaN(date.getTime());
|
|
161
193
|
}
|
|
162
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Formats a FHIR date string as a human readable string.
|
|
196
|
+
* Handles missing values and invalid dates.
|
|
197
|
+
* @param date The date to format.
|
|
198
|
+
* @param locales Optional locales.
|
|
199
|
+
* @param options Optional date format options.
|
|
200
|
+
* @returns The formatted date string.
|
|
201
|
+
*/
|
|
202
|
+
function formatDate(date, locales, options) {
|
|
163
203
|
if (!date) {
|
|
164
204
|
return '';
|
|
165
205
|
}
|
|
@@ -167,9 +207,18 @@
|
|
|
167
207
|
if (!isValidDate(d)) {
|
|
168
208
|
return '';
|
|
169
209
|
}
|
|
170
|
-
|
|
210
|
+
d.setUTCHours(0, 0, 0, 0);
|
|
211
|
+
return d.toLocaleDateString(locales, Object.assign({ timeZone: 'UTC' }, options));
|
|
171
212
|
}
|
|
172
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Formats a FHIR time string as a human readable string.
|
|
215
|
+
* Handles missing values and invalid dates.
|
|
216
|
+
* @param time The date to format.
|
|
217
|
+
* @param locales Optional locales.
|
|
218
|
+
* @param options Optional time format options.
|
|
219
|
+
* @returns The formatted time string.
|
|
220
|
+
*/
|
|
221
|
+
function formatTime(time, locales, options) {
|
|
173
222
|
if (!time) {
|
|
174
223
|
return '';
|
|
175
224
|
}
|
|
@@ -177,9 +226,17 @@
|
|
|
177
226
|
if (!isValidDate(d)) {
|
|
178
227
|
return '';
|
|
179
228
|
}
|
|
180
|
-
return d.toLocaleTimeString(
|
|
229
|
+
return d.toLocaleTimeString(locales, options);
|
|
181
230
|
}
|
|
182
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Formats a FHIR dateTime string as a human readable string.
|
|
233
|
+
* Handles missing values and invalid dates.
|
|
234
|
+
* @param dateTime The dateTime to format.
|
|
235
|
+
* @param locales Optional locales.
|
|
236
|
+
* @param options Optional dateTime format options.
|
|
237
|
+
* @returns The formatted dateTime string.
|
|
238
|
+
*/
|
|
239
|
+
function formatDateTime(dateTime, locales, options) {
|
|
183
240
|
if (!dateTime) {
|
|
184
241
|
return '';
|
|
185
242
|
}
|
|
@@ -187,13 +244,20 @@
|
|
|
187
244
|
if (!isValidDate(d)) {
|
|
188
245
|
return '';
|
|
189
246
|
}
|
|
190
|
-
return d.toLocaleString(
|
|
247
|
+
return d.toLocaleString(locales, options);
|
|
191
248
|
}
|
|
192
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Formats a FHIR Period as a human readable string.
|
|
251
|
+
* @param period The period to format.
|
|
252
|
+
* @param locales Optional locales.
|
|
253
|
+
* @param options Optional period format options.
|
|
254
|
+
* @returns The formatted period string.
|
|
255
|
+
*/
|
|
256
|
+
function formatPeriod(period, locales, options) {
|
|
193
257
|
if (!period || (!period.start && !period.end)) {
|
|
194
258
|
return '';
|
|
195
259
|
}
|
|
196
|
-
return formatDateTime(period.start) + ' - ' + formatDateTime(period.end);
|
|
260
|
+
return formatDateTime(period.start, locales, options) + ' - ' + formatDateTime(period.end, locales, options);
|
|
197
261
|
}
|
|
198
262
|
const unitAdverbForm = {
|
|
199
263
|
s: 'every second',
|
|
@@ -222,6 +286,11 @@
|
|
|
222
286
|
mo: 'months',
|
|
223
287
|
a: 'years',
|
|
224
288
|
};
|
|
289
|
+
/**
|
|
290
|
+
* Formats a FHIR Timing as a human readable string.
|
|
291
|
+
* @param timing The timing to format.
|
|
292
|
+
* @returns The formatted timing string.
|
|
293
|
+
*/
|
|
225
294
|
function formatTiming(timing) {
|
|
226
295
|
var _a;
|
|
227
296
|
if (!timing) {
|
|
@@ -326,6 +395,54 @@
|
|
|
326
395
|
}
|
|
327
396
|
return result.join('').trim();
|
|
328
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* Formats a CodeableConcept element as a string.
|
|
400
|
+
* @param codeableConcept A FHIR CodeableConcept element
|
|
401
|
+
* @returns The codeable concept as a string.
|
|
402
|
+
*/
|
|
403
|
+
function formatCodeableConcept(codeableConcept) {
|
|
404
|
+
if (!codeableConcept) {
|
|
405
|
+
return '';
|
|
406
|
+
}
|
|
407
|
+
if (codeableConcept.text) {
|
|
408
|
+
return codeableConcept.text;
|
|
409
|
+
}
|
|
410
|
+
if (codeableConcept.coding) {
|
|
411
|
+
return codeableConcept.coding.map((c) => formatCoding(c)).join(', ');
|
|
412
|
+
}
|
|
413
|
+
return '';
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Formats a Coding element as a string.
|
|
417
|
+
* @param coding A FHIR Coding element
|
|
418
|
+
* @returns The coding as a string.
|
|
419
|
+
*/
|
|
420
|
+
function formatCoding(coding) {
|
|
421
|
+
return (coding === null || coding === void 0 ? void 0 : coding.display) || (coding === null || coding === void 0 ? void 0 : coding.code) || '';
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Formats a FHIR Observation resource value as a string.
|
|
425
|
+
* @param obs A FHIR Observation resource.
|
|
426
|
+
* @returns A human-readable string representation of the Observation.
|
|
427
|
+
*/
|
|
428
|
+
function formatObservationValue(obs) {
|
|
429
|
+
if (!obs) {
|
|
430
|
+
return '';
|
|
431
|
+
}
|
|
432
|
+
if ('component' in obs) {
|
|
433
|
+
return obs.component.map((c) => formatObservationValue(c)).join(' / ');
|
|
434
|
+
}
|
|
435
|
+
if (obs === null || obs === void 0 ? void 0 : obs.valueQuantity) {
|
|
436
|
+
return formatQuantity(obs.valueQuantity);
|
|
437
|
+
}
|
|
438
|
+
if (obs.valueCodeableConcept) {
|
|
439
|
+
return formatCodeableConcept(obs.valueCodeableConcept);
|
|
440
|
+
}
|
|
441
|
+
if (obs.valueString) {
|
|
442
|
+
return obs.valueString;
|
|
443
|
+
}
|
|
444
|
+
return '';
|
|
445
|
+
}
|
|
329
446
|
/**
|
|
330
447
|
* Returns the input number increased by the `n` units of the specified precision
|
|
331
448
|
* @param a The input number
|
|
@@ -6370,7 +6487,7 @@
|
|
|
6370
6487
|
// PKCE auth based on:
|
|
6371
6488
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
6372
6489
|
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_clientId, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_request, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
|
|
6373
|
-
const MEDPLUM_VERSION = "1.0.
|
|
6490
|
+
const MEDPLUM_VERSION = "1.0.4-6dbdb7f6";
|
|
6374
6491
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
6375
6492
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
6376
6493
|
const DEFAULT_CACHE_TIME = 60000; // 60 seconds
|
|
@@ -11592,11 +11709,14 @@
|
|
|
11592
11709
|
exports.findObservationReferenceRange = findObservationReferenceRange;
|
|
11593
11710
|
exports.forbidden = forbidden;
|
|
11594
11711
|
exports.formatAddress = formatAddress;
|
|
11712
|
+
exports.formatCodeableConcept = formatCodeableConcept;
|
|
11713
|
+
exports.formatCoding = formatCoding;
|
|
11595
11714
|
exports.formatDate = formatDate;
|
|
11596
11715
|
exports.formatDateTime = formatDateTime;
|
|
11597
11716
|
exports.formatFamilyName = formatFamilyName;
|
|
11598
11717
|
exports.formatGivenName = formatGivenName;
|
|
11599
11718
|
exports.formatHumanName = formatHumanName;
|
|
11719
|
+
exports.formatObservationValue = formatObservationValue;
|
|
11600
11720
|
exports.formatPeriod = formatPeriod;
|
|
11601
11721
|
exports.formatQuantity = formatQuantity;
|
|
11602
11722
|
exports.formatRange = formatRange;
|