@medplum/core 2.0.28 → 2.0.30
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.cjs +4 -4
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/esm/index.mjs +4 -4
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/bundle.d.ts +11 -0
- package/dist/types/client.d.ts +25 -5
- package/dist/types/contenttype.d.ts +18 -0
- package/dist/types/crypto.d.ts +8 -0
- package/dist/types/eventtarget.d.ts +12 -0
- package/dist/types/hl7.d.ts +25 -6
- package/dist/types/index.d.ts +5 -2
- package/dist/types/outcomes.d.ts +4 -0
- package/dist/types/schema.d.ts +0 -1
- package/dist/types/search/search.d.ts +1 -0
- package/dist/types/typeschema/types.d.ts +12 -1
- package/dist/types/utils.d.ts +8 -1
- package/package.json +1 -1
package/dist/types/bundle.d.ts
CHANGED
|
@@ -9,3 +9,14 @@ import { Bundle } from '@medplum/fhirtypes';
|
|
|
9
9
|
* @returns transaction type bundle
|
|
10
10
|
*/
|
|
11
11
|
export declare function convertToTransactionBundle(bundle: Bundle): Bundle;
|
|
12
|
+
/**
|
|
13
|
+
* Topologically sorts a `batch` or `transaction` bundle to improve reference resolution.
|
|
14
|
+
* The bundle is sorted such that a resource is created _before_ references to that resource appear in the bundle.
|
|
15
|
+
*
|
|
16
|
+
* In the event of cycles, this function will first create a POST request for each resource in the cycle, and then will
|
|
17
|
+
* append a PUT request to the bundle. This ensures that each resources in the cycle is visited twice, and all
|
|
18
|
+
* references can be resolved
|
|
19
|
+
* @param bundle Input bundle with type `batch` or `transaction`
|
|
20
|
+
* @returns Bundle of the same type, with Bundle.entry reordered
|
|
21
|
+
*/
|
|
22
|
+
export declare function reorderBundle(bundle: Bundle): Bundle;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AccessPolicy, Attachment, Binary, BulkDataExport, Bundle, Communication, ExtractResource, Identifier, Media, OperationOutcome, Project, ProjectMembership, ProjectMembershipAccess, ProjectSecret, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
2
2
|
/** @ts-ignore */
|
|
3
3
|
import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
|
|
4
|
+
import { EventTarget } from './eventtarget';
|
|
4
5
|
import { Hl7Message } from './hl7';
|
|
5
6
|
import { ReadablePromise } from './readablepromise';
|
|
6
7
|
import { ClientStorage } from './storage';
|
|
@@ -107,6 +108,14 @@ export interface MedplumClientOptions {
|
|
|
107
108
|
* For Node.js applications, consider the 'node-fetch' package.
|
|
108
109
|
*/
|
|
109
110
|
fetch?: FetchLike;
|
|
111
|
+
/**
|
|
112
|
+
* The profile name.
|
|
113
|
+
*
|
|
114
|
+
* This is for handling multiple profiles to access different FHIR Servers
|
|
115
|
+
*
|
|
116
|
+
* If undefined, the default profile is "default".
|
|
117
|
+
*/
|
|
118
|
+
profile?: string;
|
|
110
119
|
/**
|
|
111
120
|
* Storage implementation.
|
|
112
121
|
*
|
|
@@ -292,6 +301,10 @@ export interface PatchOperation {
|
|
|
292
301
|
readonly path: string;
|
|
293
302
|
readonly value?: any;
|
|
294
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Source for a FHIR Binary.
|
|
306
|
+
*/
|
|
307
|
+
export type BinarySource = string | File | Blob | Uint8Array;
|
|
295
308
|
/**
|
|
296
309
|
* Email address definition.
|
|
297
310
|
* Compatible with nodemailer Mail.Address.
|
|
@@ -1020,7 +1033,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1020
1033
|
* @param onProgress Optional callback for progress events.
|
|
1021
1034
|
* @returns The result of the create operation.
|
|
1022
1035
|
*/
|
|
1023
|
-
createAttachment(data:
|
|
1036
|
+
createAttachment(data: BinarySource, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void): Promise<Attachment>;
|
|
1024
1037
|
/**
|
|
1025
1038
|
* Creates a FHIR `Binary` resource with the provided data content.
|
|
1026
1039
|
*
|
|
@@ -1045,8 +1058,8 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1045
1058
|
* @param onProgress Optional callback for progress events.
|
|
1046
1059
|
* @returns The result of the create operation.
|
|
1047
1060
|
*/
|
|
1048
|
-
createBinary(data:
|
|
1049
|
-
uploadwithProgress(url: URL, data:
|
|
1061
|
+
createBinary(data: BinarySource, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void): Promise<Binary>;
|
|
1062
|
+
uploadwithProgress(url: URL, data: BinarySource, contentType: string, onProgress: (e: ProgressEvent) => void): Promise<any>;
|
|
1050
1063
|
/**
|
|
1051
1064
|
* Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
|
|
1052
1065
|
*
|
|
@@ -1415,9 +1428,16 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1415
1428
|
*/
|
|
1416
1429
|
getAccessPolicy(): AccessPolicy | undefined;
|
|
1417
1430
|
/**
|
|
1418
|
-
*
|
|
1431
|
+
* Translates/normalizes a URL so that it can be directly used with `MedplumClient.fetch`.
|
|
1432
|
+
* Especially useful for translating `Binary/{id}` URLs to FHIR paths.
|
|
1433
|
+
* @param url A valid URL within the `MedplumClient` context.
|
|
1434
|
+
* @returns URL as a string that can be used with `MedplumClient.fetch`
|
|
1435
|
+
*/
|
|
1436
|
+
normalizeFetchUrl(url: URL | string): string;
|
|
1437
|
+
/**
|
|
1438
|
+
* Downloads the URL as a blob. Can accept binary URLs in the form of `Binary/{id}` as well.
|
|
1419
1439
|
* @category Read
|
|
1420
|
-
* @param url The URL to request.
|
|
1440
|
+
* @param url The URL to request. Can be a standard URL or one in the form of `Binary/{id}`.
|
|
1421
1441
|
* @param options Optional fetch request init options.
|
|
1422
1442
|
* @returns Promise to the response body as a blob.
|
|
1423
1443
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content type constants.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ContentType: {
|
|
5
|
+
CSS: string;
|
|
6
|
+
FAVICON: string;
|
|
7
|
+
FHIR_JSON: string;
|
|
8
|
+
FORM_URL_ENCODED: string;
|
|
9
|
+
HL7_V2: string;
|
|
10
|
+
HTML: string;
|
|
11
|
+
JAVASCRIPT: string;
|
|
12
|
+
JSON: string;
|
|
13
|
+
JSON_PATCH: string;
|
|
14
|
+
PNG: string;
|
|
15
|
+
SVG: string;
|
|
16
|
+
TEXT: string;
|
|
17
|
+
TYPESCRIPT: string;
|
|
18
|
+
};
|
package/dist/types/crypto.d.ts
CHANGED
|
@@ -9,3 +9,11 @@ export declare function getRandomString(): string;
|
|
|
9
9
|
* @returns The encrypted value in an ArrayBuffer.
|
|
10
10
|
*/
|
|
11
11
|
export declare function encryptSHA256(str: string): Promise<ArrayBuffer>;
|
|
12
|
+
/**
|
|
13
|
+
* Cross platform random UUID generator
|
|
14
|
+
* Note that this is not intended for production use, but rather for testing
|
|
15
|
+
* This should be replaced when crypto.randomUUID is fully supported
|
|
16
|
+
* See: https://stackoverflow.com/revisions/2117523/28
|
|
17
|
+
* @returns A random UUID.
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateId(): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Event {
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly defaultPrevented?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export type EventListener = (e: Event) => void;
|
|
6
|
+
export declare class EventTarget {
|
|
7
|
+
private readonly listeners;
|
|
8
|
+
constructor();
|
|
9
|
+
addEventListener(type: string, callback: EventListener): void;
|
|
10
|
+
removeEventListener(type: string, callback: EventListener): void;
|
|
11
|
+
dispatchEvent(event: Event): boolean;
|
|
12
|
+
}
|
package/dist/types/hl7.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export declare class Hl7Context {
|
|
|
18
18
|
readonly escapeCharacter: string;
|
|
19
19
|
readonly subcomponentSeparator: string;
|
|
20
20
|
constructor(segmentSeparator?: string, fieldSeparator?: string, componentSeparator?: string, repetitionSeparator?: string, escapeCharacter?: string, subcomponentSeparator?: string);
|
|
21
|
+
/**
|
|
22
|
+
* Returns the MSH-1 field value based on the configured separators.
|
|
23
|
+
* @returns The HL7 MSH-1 field value.
|
|
24
|
+
*/
|
|
25
|
+
getMsh1(): string;
|
|
21
26
|
/**
|
|
22
27
|
* Returns the MSH-2 field value based on the configured separators.
|
|
23
28
|
* @returns The HL7 MSH-2 field value.
|
|
@@ -209,15 +214,29 @@ export declare class Hl7Field {
|
|
|
209
214
|
*/
|
|
210
215
|
static parse(text: string, context?: Hl7Context): Hl7Field;
|
|
211
216
|
}
|
|
212
|
-
interface Hl7DateParseOptions {
|
|
213
|
-
|
|
217
|
+
export interface Hl7DateParseOptions {
|
|
218
|
+
/**
|
|
219
|
+
* Default timezone offset.
|
|
220
|
+
* Example: "-0500"
|
|
221
|
+
*/
|
|
214
222
|
tzOffset?: string;
|
|
215
223
|
}
|
|
216
224
|
/**
|
|
217
225
|
* Returns a formatted string representing the date in ISO-8601 format.
|
|
218
|
-
*
|
|
219
|
-
*
|
|
226
|
+
*
|
|
227
|
+
* HL7-Definition V2
|
|
228
|
+
* Specifies a point in time using a 24-hour clock notation.
|
|
229
|
+
*
|
|
230
|
+
* Format: YYYY[MM[DD[HH[MM[SS[. S[S[S[S]]]]]]]]][+/-ZZZZ].
|
|
231
|
+
*
|
|
232
|
+
* @param hl7DateTime Date/time string.
|
|
233
|
+
* @param options Optional parsing options.
|
|
220
234
|
* @returns The date in ISO-8601 format.
|
|
221
235
|
*/
|
|
222
|
-
export declare function
|
|
223
|
-
|
|
236
|
+
export declare function parseHl7DateTime(hl7DateTime: string | undefined, options?: Hl7DateParseOptions): string | undefined;
|
|
237
|
+
/**
|
|
238
|
+
* Formats an ISO date/time string into an HL7 date/time string.
|
|
239
|
+
* @param isoDate The ISO date/time string.
|
|
240
|
+
* @returns The HL7 date/time string.
|
|
241
|
+
*/
|
|
242
|
+
export declare function formatHl7DateTime(isoDate: Date | string): string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export * from './bundle';
|
|
|
4
4
|
export * from './cache';
|
|
5
5
|
export * from './client';
|
|
6
6
|
export * from './config';
|
|
7
|
+
export * from './contenttype';
|
|
8
|
+
export * from './crypto';
|
|
9
|
+
export * from './eventtarget';
|
|
7
10
|
export * from './fhirlexer';
|
|
8
11
|
export * from './fhirmapper';
|
|
9
12
|
export * from './fhirpath';
|
|
@@ -20,6 +23,6 @@ export * from './search/search';
|
|
|
20
23
|
export * from './sftp';
|
|
21
24
|
export * from './storage';
|
|
22
25
|
export * from './types';
|
|
26
|
+
export * from './typeschema/types';
|
|
27
|
+
export * from './typeschema/validation';
|
|
23
28
|
export * from './utils';
|
|
24
|
-
export { loadDataTypes } from './typeschema/types';
|
|
25
|
-
export { validate } from './typeschema/validation';
|
package/dist/types/outcomes.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { OperationOutcome, OperationOutcomeIssue } from '@medplum/fhirtypes';
|
|
2
|
+
import { Constraint } from './typeschema/types';
|
|
2
3
|
export declare const allOk: OperationOutcome;
|
|
3
4
|
export declare const created: OperationOutcome;
|
|
4
5
|
export declare const notModified: OperationOutcome;
|
|
@@ -51,3 +52,6 @@ export declare function operationOutcomeToString(outcome: OperationOutcome): str
|
|
|
51
52
|
* @returns The string representation of the operation outcome issue.
|
|
52
53
|
*/
|
|
53
54
|
export declare function operationOutcomeIssueToString(issue: OperationOutcomeIssue): string;
|
|
55
|
+
export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue;
|
|
56
|
+
export declare function createConstraintIssue(expression: string, constraint: Constraint): OperationOutcomeIssue;
|
|
57
|
+
export declare function createProcessingIssue(expression: string, message: string, err: Error, data?: Record<string, any>): OperationOutcomeIssue;
|
package/dist/types/schema.d.ts
CHANGED
|
@@ -144,4 +144,3 @@ export declare class FhirSchemaValidator<T extends Resource> {
|
|
|
144
144
|
* @param issues Output list of issues.
|
|
145
145
|
*/
|
|
146
146
|
export declare function checkForNull(value: unknown, path: string, issues: OperationOutcomeIssue[]): void;
|
|
147
|
-
export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bundle, StructureDefinition } from '@medplum/fhirtypes';
|
|
1
|
+
import { Bundle, StructureDefinition, Resource } from '@medplum/fhirtypes';
|
|
2
2
|
import { TypedValue } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Internal representation of a non-primitive FHIR type, suitable for use in resource validation
|
|
@@ -8,6 +8,8 @@ export interface InternalTypeSchema {
|
|
|
8
8
|
fields: Record<string, ElementValidator>;
|
|
9
9
|
constraints: Constraint[];
|
|
10
10
|
innerTypes: InternalTypeSchema[];
|
|
11
|
+
summaryProperties?: Set<string>;
|
|
12
|
+
mandatoryProperties?: Set<string>;
|
|
11
13
|
}
|
|
12
14
|
export interface ElementValidator {
|
|
13
15
|
min: number;
|
|
@@ -56,3 +58,12 @@ export interface SliceDiscriminator {
|
|
|
56
58
|
export declare function parseStructureDefinition(sd: StructureDefinition): InternalTypeSchema;
|
|
57
59
|
export declare function loadDataTypes(bundle: Bundle<StructureDefinition>): void;
|
|
58
60
|
export declare function getDataType(type: string): InternalTypeSchema;
|
|
61
|
+
/**
|
|
62
|
+
* Construct the subset of a resource containing a minimum set of fields. The returned resource is not guaranteed
|
|
63
|
+
* to contain only the provided properties, and may contain others (e.g. `resourceType` and `id`)
|
|
64
|
+
*
|
|
65
|
+
* @param resource The resource to subset
|
|
66
|
+
* @param properties The minimum properties to include in the subset
|
|
67
|
+
* @returns The modified resource, containing the listed properties and possibly other mandatory ones
|
|
68
|
+
*/
|
|
69
|
+
export declare function subsetResource<T extends Resource>(resource: T | undefined, properties: string[]): T | undefined;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeableConcept, Extension, ObservationDefinition, ObservationDefinitionQualifiedInterval, Patient, Practitioner, QuestionnaireResponse, QuestionnaireResponseItemAnswer, Range, Reference, RelatedPerson, Resource } from '@medplum/fhirtypes';
|
|
1
|
+
import { CodeableConcept, Extension, ObservationDefinition, ObservationDefinitionQualifiedInterval, Patient, Practitioner, QuestionnaireResponse, QuestionnaireResponseItemAnswer, Range, Reference, RelatedPerson, Resource, ResourceType } from '@medplum/fhirtypes';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
@@ -28,6 +28,13 @@ export declare function getReferenceString(resource: Resource): string;
|
|
|
28
28
|
* @returns The ID portion of a reference.
|
|
29
29
|
*/
|
|
30
30
|
export declare function resolveId(reference: Reference | undefined): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Parses a reference and returns a tuple of [ResourceType, ID].
|
|
33
|
+
* @param reference A reference to a FHIR resource.
|
|
34
|
+
* @returns A tuple containing the `ResourceType` and the ID of the resource or `undefined` when `undefined` or an invalid reference is passed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseReference(reference: Reference): [ResourceType, string] | undefined;
|
|
37
|
+
export declare function parseReference(reference: undefined): undefined;
|
|
31
38
|
/**
|
|
32
39
|
* Returns true if the resource is a "ProfileResource".
|
|
33
40
|
* @param resource The FHIR resource.
|