@medplum/core 0.9.0 → 0.9.1
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/index.js +174 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -15
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +165 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -15
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/client.d.ts +1 -1
- package/dist/types/hl7.d.ts +43 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils.d.ts +26 -1
- package/package.json +2 -2
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -92
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +0 -52
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/classes/LegacyRepositoryClient.html +0 -71
- package/docs/classes/MedplumClient.html +0 -324
- package/docs/classes/OperationOutcomeError.html +0 -6
- package/docs/enums/Operator.html +0 -5
- package/docs/enums/PropertyType.html +0 -5
- package/docs/enums/SearchParameterType.html +0 -1
- package/docs/index.html +0 -89
- package/docs/interfaces/AddressFormatOptions.html +0 -1
- package/docs/interfaces/FetchLike.html +0 -1
- package/docs/interfaces/Filter.html +0 -1
- package/docs/interfaces/GoogleCredentialResponse.html +0 -1
- package/docs/interfaces/HumanNameFormatOptions.html +0 -1
- package/docs/interfaces/IndexedStructureDefinition.html +0 -19
- package/docs/interfaces/LoginAuthenticationResponse.html +0 -1
- package/docs/interfaces/LoginProfileResponse.html +0 -1
- package/docs/interfaces/LoginScopeResponse.html +0 -1
- package/docs/interfaces/LoginState.html +0 -1
- package/docs/interfaces/MedplumClientOptions.html +0 -33
- package/docs/interfaces/RegisterRequest.html +0 -1
- package/docs/interfaces/SearchParameterDetails.html +0 -1
- package/docs/interfaces/SearchRequest.html +0 -1
- package/docs/interfaces/SortRule.html +0 -1
- package/docs/interfaces/TokenResponse.html +0 -1
- package/docs/interfaces/TypeSchema.html +0 -10
- package/docs/modules.html +0 -138
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.medplum = global.medplum || {}, global.medplum.core = {})));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/******************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
9
9
|
|
|
10
10
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -315,6 +315,47 @@
|
|
|
315
315
|
return days.toString().padStart(3, '0') + 'D';
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Returns all questionnaire answers as a map by link ID.
|
|
320
|
+
* @param response The questionnaire response resource.
|
|
321
|
+
* @returns Questionnaire answers mapped by link ID.
|
|
322
|
+
*/
|
|
323
|
+
function getQuestionnaireAnswers(response) {
|
|
324
|
+
const result = {};
|
|
325
|
+
buildQuestionnaireAnswerItems(response.item, result);
|
|
326
|
+
return result;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Recursively builds the questionnaire answer items map.
|
|
330
|
+
* @param item The current questionnaire response item.
|
|
331
|
+
* @param result The cumulative result map.
|
|
332
|
+
*/
|
|
333
|
+
function buildQuestionnaireAnswerItems(items, result) {
|
|
334
|
+
if (items) {
|
|
335
|
+
for (const item of items) {
|
|
336
|
+
if (item.linkId && item.answer && item.answer.length > 0) {
|
|
337
|
+
result[item.linkId] = item.answer[0];
|
|
338
|
+
}
|
|
339
|
+
buildQuestionnaireAnswerItems(item.item, result);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Returns an extension value by extension URLs.
|
|
345
|
+
* @param resource The base resource.
|
|
346
|
+
* @param urls Array of extension URLs. Each entry represents a nested extension.
|
|
347
|
+
* @returns The extension value if found; undefined otherwise.
|
|
348
|
+
*/
|
|
349
|
+
function getExtensionValue(resource, ...urls) {
|
|
350
|
+
var _a;
|
|
351
|
+
// Let curr be the current resource or extension. Extensions can be nested.
|
|
352
|
+
let curr = resource;
|
|
353
|
+
// For each of the urls, try to find a matching nested extension.
|
|
354
|
+
for (let i = 0; i < urls.length && curr; i++) {
|
|
355
|
+
curr = (_a = curr === null || curr === void 0 ? void 0 : curr.extension) === null || _a === void 0 ? void 0 : _a.find((e) => e.url === urls[i]);
|
|
356
|
+
}
|
|
357
|
+
return curr === null || curr === void 0 ? void 0 : curr.valueString;
|
|
358
|
+
}
|
|
318
359
|
/**
|
|
319
360
|
* FHIR JSON stringify.
|
|
320
361
|
* Removes properties with empty string values.
|
|
@@ -391,8 +432,21 @@
|
|
|
391
432
|
}
|
|
392
433
|
return true;
|
|
393
434
|
}
|
|
394
|
-
|
|
395
|
-
|
|
435
|
+
/**
|
|
436
|
+
* Returns true if the input is an object.
|
|
437
|
+
* @param object The candidate object.
|
|
438
|
+
* @returns True if the input is a non-null non-undefined object.
|
|
439
|
+
*/
|
|
440
|
+
function isObject(obj) {
|
|
441
|
+
return obj !== null && typeof obj === 'object';
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Returns true if the input array is an array of strings.
|
|
445
|
+
* @param arr Input array.
|
|
446
|
+
* @returns True if the input array is an array of strings.
|
|
447
|
+
*/
|
|
448
|
+
function isStringArray(arr) {
|
|
449
|
+
return arr.every((e) => typeof e === 'string');
|
|
396
450
|
}
|
|
397
451
|
// Precompute hex octets
|
|
398
452
|
// See: https://stackoverflow.com/a/55200387
|
|
@@ -2221,6 +2275,113 @@
|
|
|
2221
2275
|
return window.location.protocol + '//' + window.location.host + '/';
|
|
2222
2276
|
}
|
|
2223
2277
|
|
|
2278
|
+
const SEGMENT_SEPARATOR = '\r';
|
|
2279
|
+
const FIELD_SEPARATOR = '|';
|
|
2280
|
+
const COMPONENT_SEPARATOR = '^';
|
|
2281
|
+
/**
|
|
2282
|
+
* The Hl7Message class represents one HL7 message.
|
|
2283
|
+
* A message is a collection of segments.
|
|
2284
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2285
|
+
*/
|
|
2286
|
+
class Hl7Message {
|
|
2287
|
+
constructor(segments) {
|
|
2288
|
+
this.segments = segments;
|
|
2289
|
+
}
|
|
2290
|
+
get(index) {
|
|
2291
|
+
if (typeof index === 'number') {
|
|
2292
|
+
return this.segments[index];
|
|
2293
|
+
}
|
|
2294
|
+
return this.segments.find((s) => s.name === index);
|
|
2295
|
+
}
|
|
2296
|
+
getAll(name) {
|
|
2297
|
+
return this.segments.filter((s) => s.name === name);
|
|
2298
|
+
}
|
|
2299
|
+
toString() {
|
|
2300
|
+
return this.segments.map((s) => s.toString()).join(SEGMENT_SEPARATOR);
|
|
2301
|
+
}
|
|
2302
|
+
buildAck() {
|
|
2303
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2304
|
+
const now = new Date();
|
|
2305
|
+
const msh = this.get('MSH');
|
|
2306
|
+
const sendingApp = ((_a = msh === null || msh === void 0 ? void 0 : msh.get(2)) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
2307
|
+
const sendingFacility = ((_b = msh === null || msh === void 0 ? void 0 : msh.get(3)) === null || _b === void 0 ? void 0 : _b.toString()) || '';
|
|
2308
|
+
const receivingApp = ((_c = msh === null || msh === void 0 ? void 0 : msh.get(4)) === null || _c === void 0 ? void 0 : _c.toString()) || '';
|
|
2309
|
+
const receivingFacility = ((_d = msh === null || msh === void 0 ? void 0 : msh.get(5)) === null || _d === void 0 ? void 0 : _d.toString()) || '';
|
|
2310
|
+
const controlId = ((_e = msh === null || msh === void 0 ? void 0 : msh.get(9)) === null || _e === void 0 ? void 0 : _e.toString()) || '';
|
|
2311
|
+
const versionId = ((_f = msh === null || msh === void 0 ? void 0 : msh.get(12)) === null || _f === void 0 ? void 0 : _f.toString()) || '2.5.1';
|
|
2312
|
+
return new Hl7Message([
|
|
2313
|
+
new Hl7Segment([
|
|
2314
|
+
'MSH',
|
|
2315
|
+
'^~\\&',
|
|
2316
|
+
receivingApp,
|
|
2317
|
+
receivingFacility,
|
|
2318
|
+
sendingApp,
|
|
2319
|
+
sendingFacility,
|
|
2320
|
+
now.toISOString(),
|
|
2321
|
+
'',
|
|
2322
|
+
'ACK',
|
|
2323
|
+
now.getTime().toString(),
|
|
2324
|
+
'P',
|
|
2325
|
+
versionId,
|
|
2326
|
+
]),
|
|
2327
|
+
new Hl7Segment(['MSA', 'AA', controlId, 'OK']),
|
|
2328
|
+
]);
|
|
2329
|
+
}
|
|
2330
|
+
static parse(text) {
|
|
2331
|
+
if (!text.startsWith('MSH|^~\\&')) {
|
|
2332
|
+
const err = new Error('Invalid HL7 message');
|
|
2333
|
+
err.type = 'entity.parse.failed';
|
|
2334
|
+
throw err;
|
|
2335
|
+
}
|
|
2336
|
+
return new Hl7Message(text.split(/[\r\n]+/).map((line) => Hl7Segment.parse(line)));
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* The Hl7Segment class represents one HL7 segment.
|
|
2341
|
+
* A segment is a collection of fields.
|
|
2342
|
+
* The name field is the first field.
|
|
2343
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2344
|
+
*/
|
|
2345
|
+
class Hl7Segment {
|
|
2346
|
+
constructor(fields) {
|
|
2347
|
+
if (isStringArray(fields)) {
|
|
2348
|
+
this.fields = fields.map((f) => Hl7Field.parse(f));
|
|
2349
|
+
}
|
|
2350
|
+
else {
|
|
2351
|
+
this.fields = fields;
|
|
2352
|
+
}
|
|
2353
|
+
this.name = this.fields[0].components[0];
|
|
2354
|
+
}
|
|
2355
|
+
get(index) {
|
|
2356
|
+
return this.fields[index];
|
|
2357
|
+
}
|
|
2358
|
+
toString() {
|
|
2359
|
+
return this.fields.map((f) => f.toString()).join(FIELD_SEPARATOR);
|
|
2360
|
+
}
|
|
2361
|
+
static parse(text) {
|
|
2362
|
+
return new Hl7Segment(text.split(FIELD_SEPARATOR).map((f) => Hl7Field.parse(f)));
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* The Hl7Field class represents one HL7 field.
|
|
2367
|
+
* A field is a collection of components.
|
|
2368
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2369
|
+
*/
|
|
2370
|
+
class Hl7Field {
|
|
2371
|
+
constructor(components) {
|
|
2372
|
+
this.components = components;
|
|
2373
|
+
}
|
|
2374
|
+
get(index) {
|
|
2375
|
+
return this.components[index];
|
|
2376
|
+
}
|
|
2377
|
+
toString() {
|
|
2378
|
+
return this.components.join(COMPONENT_SEPARATOR);
|
|
2379
|
+
}
|
|
2380
|
+
static parse(text) {
|
|
2381
|
+
return new Hl7Field(text.split(COMPONENT_SEPARATOR));
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2224
2385
|
var _LegacyRepositoryClient_client;
|
|
2225
2386
|
/**
|
|
2226
2387
|
* The LegacyRepositoryClient is a supplementary API client that matches the legacy "Repository" API.
|
|
@@ -2550,9 +2711,15 @@
|
|
|
2550
2711
|
return result;
|
|
2551
2712
|
}
|
|
2552
2713
|
|
|
2714
|
+
exports.COMPONENT_SEPARATOR = COMPONENT_SEPARATOR;
|
|
2715
|
+
exports.FIELD_SEPARATOR = FIELD_SEPARATOR;
|
|
2716
|
+
exports.Hl7Field = Hl7Field;
|
|
2717
|
+
exports.Hl7Message = Hl7Message;
|
|
2718
|
+
exports.Hl7Segment = Hl7Segment;
|
|
2553
2719
|
exports.LegacyRepositoryClient = LegacyRepositoryClient;
|
|
2554
2720
|
exports.MedplumClient = MedplumClient;
|
|
2555
2721
|
exports.OperationOutcomeError = OperationOutcomeError;
|
|
2722
|
+
exports.SEGMENT_SEPARATOR = SEGMENT_SEPARATOR;
|
|
2556
2723
|
exports.accessDenied = accessDenied;
|
|
2557
2724
|
exports.allOk = allOk;
|
|
2558
2725
|
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
@@ -2576,8 +2743,10 @@
|
|
|
2576
2743
|
exports.getDateProperty = getDateProperty;
|
|
2577
2744
|
exports.getDisplayString = getDisplayString;
|
|
2578
2745
|
exports.getExpressionForResourceType = getExpressionForResourceType;
|
|
2746
|
+
exports.getExtensionValue = getExtensionValue;
|
|
2579
2747
|
exports.getImageSrc = getImageSrc;
|
|
2580
2748
|
exports.getPropertyDisplayName = getPropertyDisplayName;
|
|
2749
|
+
exports.getQuestionnaireAnswers = getQuestionnaireAnswers;
|
|
2581
2750
|
exports.getReferenceString = getReferenceString;
|
|
2582
2751
|
exports.getSearchParameterDetails = getSearchParameterDetails;
|
|
2583
2752
|
exports.getStatus = getStatus;
|
|
@@ -2587,8 +2756,10 @@
|
|
|
2587
2756
|
exports.isGone = isGone;
|
|
2588
2757
|
exports.isLowerCase = isLowerCase;
|
|
2589
2758
|
exports.isNotFound = isNotFound;
|
|
2759
|
+
exports.isObject = isObject;
|
|
2590
2760
|
exports.isOk = isOk;
|
|
2591
2761
|
exports.isProfileResource = isProfileResource;
|
|
2762
|
+
exports.isStringArray = isStringArray;
|
|
2592
2763
|
exports.notFound = notFound;
|
|
2593
2764
|
exports.notModified = notModified;
|
|
2594
2765
|
exports.parseSearchDefinition = parseSearchDefinition;
|