@medplum/core 0.9.5 → 0.9.8
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/README.md +3 -23
- package/cody-pdf-test.js +32 -0
- package/dist/cjs/index.js +2992 -240
- 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/cjs/package.json +1 -0
- package/dist/esm/index.js +2987 -239
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/package.json +1 -0
- package/dist/types/cache.d.ts +22 -0
- package/dist/types/client.d.ts +202 -81
- package/dist/types/fhirpath/atoms.d.ts +148 -0
- package/dist/types/fhirpath/date.d.ts +1 -0
- package/dist/types/fhirpath/functions.d.ts +5 -0
- package/dist/types/fhirpath/index.d.ts +2 -0
- package/dist/types/fhirpath/parse.d.ts +17 -0
- package/dist/types/fhirpath/tokenize.d.ts +5 -0
- package/dist/types/fhirpath/utils.d.ts +84 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/pdf.d.ts +5 -0
- package/dist/types/utils.d.ts +12 -0
- package/document.pdf +0 -0
- package/package.json +10 -3
- package/test.pdf +1 -0
- package/test2.pdf +1 -0
- package/test3.pdf.txt +1 -0
- package/test4.pdf +1 -0
- package/test5.pdf +0 -0
- package/test7-2.pdf +1 -0
- package/test7.pdf +1 -0
- package/test8-2.pdf +0 -0
- package/{dist/types/fix-ro-iddentifiers.d.ts → test8.pdf} +0 -0
- package/wget-log +6 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|
package/dist/types/cache.d.ts
CHANGED
|
@@ -5,8 +5,30 @@
|
|
|
5
5
|
export declare class LRUCache<T> {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(max?: number);
|
|
8
|
+
/**
|
|
9
|
+
* Deletes all values from the cache.
|
|
10
|
+
*/
|
|
8
11
|
clear(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the value for the given key.
|
|
14
|
+
* @param key The key to retrieve.
|
|
15
|
+
* @returns The value if found; undefined otherwise.
|
|
16
|
+
*/
|
|
9
17
|
get(key: string): T | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the value for the given key.
|
|
20
|
+
* @param key The key to set.
|
|
21
|
+
* @param val The value to set.
|
|
22
|
+
*/
|
|
10
23
|
set(key: string, val: T): void;
|
|
24
|
+
/**
|
|
25
|
+
* Deletes the value for the given key.
|
|
26
|
+
* @param key The key to delete.
|
|
27
|
+
*/
|
|
11
28
|
delete(key: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the list of all keys in the cache.
|
|
31
|
+
* @returns The array of keys in the cache.
|
|
32
|
+
*/
|
|
33
|
+
keys(): IterableIterator<string>;
|
|
12
34
|
}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,57 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Binary, Bundle, Communication, OperationOutcome, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
3
|
+
import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
|
|
3
4
|
import { EventTarget } from './eventtarget';
|
|
4
5
|
import { Hl7Message } from './hl7';
|
|
5
6
|
import { ReadablePromise } from './readablepromise';
|
|
6
7
|
import { SearchRequest } from './search';
|
|
7
8
|
import { IndexedStructureDefinition } from './types';
|
|
8
9
|
import { ProfileResource } from './utils';
|
|
10
|
+
/**
|
|
11
|
+
* The MedplumClientOptions interface defines configuration options for MedplumClient.
|
|
12
|
+
*
|
|
13
|
+
* All configuration settings are optional.
|
|
14
|
+
*/
|
|
9
15
|
export interface MedplumClientOptions {
|
|
10
|
-
/**
|
|
11
|
-
* The client ID.
|
|
12
|
-
* Optional. Default is to defer to the server to use the default client.
|
|
13
|
-
* Use this to use a specific client for SMART-on-FHIR.
|
|
14
|
-
*/
|
|
15
|
-
clientId?: string;
|
|
16
16
|
/**
|
|
17
17
|
* Base server URL.
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* Default value is "https://api.medplum.com/".
|
|
20
|
+
*
|
|
19
21
|
* Use this to point to a custom Medplum deployment.
|
|
20
22
|
*/
|
|
21
23
|
baseUrl?: string;
|
|
22
24
|
/**
|
|
23
25
|
* OAuth2 authorize URL.
|
|
24
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* Default value is baseUrl + "/oauth2/authorize".
|
|
28
|
+
*
|
|
25
29
|
* Use this if you want to use a separate OAuth server.
|
|
26
30
|
*/
|
|
27
31
|
authorizeUrl?: string;
|
|
28
32
|
/**
|
|
29
33
|
* OAuth2 token URL.
|
|
30
|
-
*
|
|
34
|
+
*
|
|
35
|
+
* Default value is baseUrl + "/oauth2/token".
|
|
36
|
+
*
|
|
31
37
|
* Use this if you want to use a separate OAuth server.
|
|
32
38
|
*/
|
|
33
39
|
tokenUrl?: string;
|
|
34
40
|
/**
|
|
35
41
|
* OAuth2 logout URL.
|
|
36
|
-
*
|
|
42
|
+
*
|
|
43
|
+
* Default value is baseUrl + "/oauth2/logout".
|
|
44
|
+
*
|
|
37
45
|
* Use this if you want to use a separate OAuth server.
|
|
38
46
|
*/
|
|
39
47
|
logoutUrl?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The client ID.
|
|
50
|
+
*
|
|
51
|
+
* Client ID can be used for SMART-on-FHIR customization.
|
|
52
|
+
*/
|
|
53
|
+
clientId?: string;
|
|
40
54
|
/**
|
|
41
55
|
* Number of resources to store in the cache.
|
|
42
|
-
*
|
|
56
|
+
*
|
|
57
|
+
* Default value is 1000.
|
|
58
|
+
*
|
|
43
59
|
* Consider using this for performance of displaying Patient or Practitioner resources.
|
|
44
60
|
*/
|
|
45
61
|
resourceCacheSize?: number;
|
|
46
62
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
63
|
+
* Fetch implementation.
|
|
64
|
+
*
|
|
65
|
+
* Default is window.fetch (if available).
|
|
66
|
+
*
|
|
49
67
|
* For nodejs applications, consider the 'node-fetch' package.
|
|
50
68
|
*/
|
|
51
69
|
fetch?: FetchLike;
|
|
52
70
|
/**
|
|
53
|
-
*
|
|
71
|
+
* Callback for when the client is unauthenticated.
|
|
72
|
+
*
|
|
54
73
|
* Default is do nothing.
|
|
74
|
+
*
|
|
55
75
|
* For client side applications, consider redirecting to a sign in page.
|
|
56
76
|
*/
|
|
57
77
|
onUnauthenticated?: () => void;
|
|
@@ -59,6 +79,12 @@ export interface MedplumClientOptions {
|
|
|
59
79
|
export interface FetchLike {
|
|
60
80
|
(url: string, options?: any): Promise<any>;
|
|
61
81
|
}
|
|
82
|
+
export interface LoginRequest {
|
|
83
|
+
readonly email: string;
|
|
84
|
+
readonly password: string;
|
|
85
|
+
readonly remember?: boolean;
|
|
86
|
+
readonly projectId?: string;
|
|
87
|
+
}
|
|
62
88
|
export interface RegisterRequest {
|
|
63
89
|
readonly firstName: string;
|
|
64
90
|
readonly lastName: string;
|
|
@@ -104,6 +130,63 @@ export interface BotEvent {
|
|
|
104
130
|
readonly contentType: string;
|
|
105
131
|
readonly input: Resource | Hl7Message | string;
|
|
106
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* JSONPatch patch operation.
|
|
135
|
+
* Compatible with fast-json-patch Operation.
|
|
136
|
+
*/
|
|
137
|
+
export interface PatchOperation {
|
|
138
|
+
readonly op: string;
|
|
139
|
+
readonly path: string;
|
|
140
|
+
readonly value?: any;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Email address definition.
|
|
144
|
+
* Compatible with nodemailer Mail.Address.
|
|
145
|
+
*/
|
|
146
|
+
export interface MailAddress {
|
|
147
|
+
readonly name: string;
|
|
148
|
+
readonly address: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Email attachment definition.
|
|
152
|
+
* Compatible with nodemailer Mail.Options.
|
|
153
|
+
*/
|
|
154
|
+
export interface MailAttachment {
|
|
155
|
+
/** String, Buffer or a Stream contents for the attachmentent */
|
|
156
|
+
readonly content?: string;
|
|
157
|
+
/** path to a file or an URL (data uris are allowed as well) if you want to stream the file instead of including it (better for larger attachments) */
|
|
158
|
+
readonly path?: string;
|
|
159
|
+
/** filename to be reported as the name of the attached file, use of unicode is allowed. If you do not want to use a filename, set this value as false, otherwise a filename is generated automatically */
|
|
160
|
+
readonly filename?: string | false;
|
|
161
|
+
/** optional content type for the attachment, if not set will be derived from the filename property */
|
|
162
|
+
readonly contentType?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Email message definition.
|
|
166
|
+
* Compatible with nodemailer Mail.Options.
|
|
167
|
+
*/
|
|
168
|
+
export interface MailOptions {
|
|
169
|
+
/** The e-mail address of the sender. All e-mail addresses can be plain 'sender@server.com' or formatted 'Sender Name <sender@server.com>' */
|
|
170
|
+
readonly from?: string | MailAddress;
|
|
171
|
+
/** An e-mail address that will appear on the Sender: field */
|
|
172
|
+
readonly sender?: string | MailAddress;
|
|
173
|
+
/** Comma separated list or an array of recipients e-mail addresses that will appear on the To: field */
|
|
174
|
+
readonly to?: string | MailAddress | string[] | MailAddress[];
|
|
175
|
+
/** Comma separated list or an array of recipients e-mail addresses that will appear on the Cc: field */
|
|
176
|
+
readonly cc?: string | MailAddress | string[] | MailAddress[];
|
|
177
|
+
/** Comma separated list or an array of recipients e-mail addresses that will appear on the Bcc: field */
|
|
178
|
+
readonly bcc?: string | MailAddress | string[] | MailAddress[];
|
|
179
|
+
/** An e-mail address that will appear on the Reply-To: field */
|
|
180
|
+
readonly replyTo?: string | MailAddress;
|
|
181
|
+
/** The subject of the e-mail */
|
|
182
|
+
readonly subject?: string;
|
|
183
|
+
/** The plaintext version of the message */
|
|
184
|
+
readonly text?: string;
|
|
185
|
+
/** The HTML version of the message */
|
|
186
|
+
readonly html?: string;
|
|
187
|
+
/** An array of attachment objects */
|
|
188
|
+
readonly attachments?: MailAttachment[];
|
|
189
|
+
}
|
|
107
190
|
/**
|
|
108
191
|
* The MedplumClient class provides a client for the Medplum FHIR server.
|
|
109
192
|
*
|
|
@@ -150,15 +233,31 @@ export interface BotEvent {
|
|
|
150
233
|
* const bundle = await medplum.search('Patient?name=Alice');
|
|
151
234
|
* console.log(bundle.total);
|
|
152
235
|
* ```
|
|
153
|
-
*
|
|
154
236
|
*/
|
|
155
237
|
export declare class MedplumClient extends EventTarget {
|
|
156
238
|
#private;
|
|
157
239
|
constructor(options?: MedplumClientOptions);
|
|
240
|
+
/**
|
|
241
|
+
* Returns the current base URL for all API requests.
|
|
242
|
+
* By default, this is set to `https://api.medplum.com/`.
|
|
243
|
+
* This can be overridden by setting the `baseUrl` option when creating the client.
|
|
244
|
+
* @returns The current base URL for all API requests.
|
|
245
|
+
*/
|
|
246
|
+
getBaseUrl(): string;
|
|
158
247
|
/**
|
|
159
248
|
* Clears all auth state including local storage and session storage.
|
|
160
249
|
*/
|
|
161
250
|
clear(): void;
|
|
251
|
+
/**
|
|
252
|
+
* Invalidates any cached values or cached requests for the given URL.
|
|
253
|
+
* @param url The URL to invalidate.
|
|
254
|
+
*/
|
|
255
|
+
invalidateUrl(url: URL | string): void;
|
|
256
|
+
/**
|
|
257
|
+
* Invalidates all cached search results or cached requests for the given resourceType.
|
|
258
|
+
* @param resourceType The resource type to invalidate.
|
|
259
|
+
*/
|
|
260
|
+
invalidateSearches(resourceType: string): void;
|
|
162
261
|
/**
|
|
163
262
|
* Makes an HTTP GET request to the specified URL.
|
|
164
263
|
*
|
|
@@ -170,7 +269,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
170
269
|
* @param options Optional fetch options.
|
|
171
270
|
* @returns Promise to the response content.
|
|
172
271
|
*/
|
|
173
|
-
get<T = any>(url: string, options?: RequestInit): ReadablePromise<T>;
|
|
272
|
+
get<T = any>(url: URL | string, options?: RequestInit): ReadablePromise<T>;
|
|
174
273
|
/**
|
|
175
274
|
* Makes an HTTP POST request to the specified URL.
|
|
176
275
|
*
|
|
@@ -184,7 +283,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
184
283
|
* @param options Optional fetch options.
|
|
185
284
|
* @returns Promise to the response content.
|
|
186
285
|
*/
|
|
187
|
-
post(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
286
|
+
post(url: URL | string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
188
287
|
/**
|
|
189
288
|
* Makes an HTTP PUT request to the specified URL.
|
|
190
289
|
*
|
|
@@ -198,7 +297,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
198
297
|
* @param options Optional fetch options.
|
|
199
298
|
* @returns Promise to the response content.
|
|
200
299
|
*/
|
|
201
|
-
put(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
300
|
+
put(url: URL | string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
202
301
|
/**
|
|
203
302
|
* Makes an HTTP PATCH request to the specified URL.
|
|
204
303
|
*
|
|
@@ -211,7 +310,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
211
310
|
* @param options Optional fetch options.
|
|
212
311
|
* @returns Promise to the response content.
|
|
213
312
|
*/
|
|
214
|
-
patch(url: string, operations:
|
|
313
|
+
patch(url: URL | string, operations: PatchOperation[], options?: RequestInit): Promise<any>;
|
|
215
314
|
/**
|
|
216
315
|
* Makes an HTTP DELETE request to the specified URL.
|
|
217
316
|
*
|
|
@@ -223,7 +322,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
223
322
|
* @param options Optional fetch options.
|
|
224
323
|
* @returns Promise to the response content.
|
|
225
324
|
*/
|
|
226
|
-
delete(url: string, options?: RequestInit): Promise<any>;
|
|
325
|
+
delete(url: URL | string, options?: RequestInit): Promise<any>;
|
|
227
326
|
/**
|
|
228
327
|
* Tries to register a new user.
|
|
229
328
|
* @param request The registration request.
|
|
@@ -232,12 +331,10 @@ export declare class MedplumClient extends EventTarget {
|
|
|
232
331
|
register(request: RegisterRequest): Promise<void>;
|
|
233
332
|
/**
|
|
234
333
|
* Initiates a user login flow.
|
|
235
|
-
* @param
|
|
236
|
-
* @param password The password of the user.
|
|
237
|
-
* @param remember Optional flag to remember the user.
|
|
334
|
+
* @param loginRequest Login request including email and password.
|
|
238
335
|
* @returns Promise to the authentication response.
|
|
239
336
|
*/
|
|
240
|
-
startLogin(
|
|
337
|
+
startLogin(loginRequest: LoginRequest): Promise<LoginAuthenticationResponse>;
|
|
241
338
|
/**
|
|
242
339
|
* Tries to sign in with Google authentication.
|
|
243
340
|
* The response parameter is the result of a Google authentication.
|
|
@@ -268,7 +365,13 @@ export declare class MedplumClient extends EventTarget {
|
|
|
268
365
|
* @param path The path component of the URL.
|
|
269
366
|
* @returns The well-formed FHIR URL.
|
|
270
367
|
*/
|
|
271
|
-
fhirUrl(...path: string[]):
|
|
368
|
+
fhirUrl(...path: string[]): URL;
|
|
369
|
+
/**
|
|
370
|
+
* Builds a FHIR search URL from a search query or structured query object.
|
|
371
|
+
* @param query The FHIR search query or structured query object.
|
|
372
|
+
* @returns The well-formed FHIR URL.
|
|
373
|
+
*/
|
|
374
|
+
fhirSearchUrl(query: string | SearchRequest): URL;
|
|
272
375
|
/**
|
|
273
376
|
* Sends a FHIR search request.
|
|
274
377
|
*
|
|
@@ -323,7 +426,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
323
426
|
* @param query The search query as either a string or a structured search object.
|
|
324
427
|
* @returns Promise to the search result bundle.
|
|
325
428
|
*/
|
|
326
|
-
search<T extends Resource>(query: string | SearchRequest, options?: RequestInit):
|
|
429
|
+
search<T extends Resource>(query: string | SearchRequest, options?: RequestInit): ReadablePromise<Bundle<T>>;
|
|
327
430
|
/**
|
|
328
431
|
* Sends a FHIR search request for a single resource.
|
|
329
432
|
*
|
|
@@ -343,7 +446,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
343
446
|
* @param query The search query as either a string or a structured search object.
|
|
344
447
|
* @returns Promise to the search result bundle.
|
|
345
448
|
*/
|
|
346
|
-
searchOne<T extends Resource>(query: string | SearchRequest, options?: RequestInit):
|
|
449
|
+
searchOne<T extends Resource>(query: string | SearchRequest, options?: RequestInit): ReadablePromise<T | undefined>;
|
|
347
450
|
/**
|
|
348
451
|
* Sends a FHIR search request for an array of resources.
|
|
349
452
|
*
|
|
@@ -363,7 +466,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
363
466
|
* @param query The search query as either a string or a structured search object.
|
|
364
467
|
* @returns Promise to the search result bundle.
|
|
365
468
|
*/
|
|
366
|
-
searchResources<T extends Resource>(query: string | SearchRequest, options?: RequestInit):
|
|
469
|
+
searchResources<T extends Resource>(query: string | SearchRequest, options?: RequestInit): ReadablePromise<T[]>;
|
|
367
470
|
/**
|
|
368
471
|
* Searches a ValueSet resource using the "expand" operation.
|
|
369
472
|
* See: https://www.hl7.org/fhir/operation-valueset-expand.html
|
|
@@ -371,7 +474,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
371
474
|
* @param filter The search string.
|
|
372
475
|
* @returns Promise to expanded ValueSet.
|
|
373
476
|
*/
|
|
374
|
-
searchValueSet(system: string, filter: string, options?: RequestInit):
|
|
477
|
+
searchValueSet(system: string, filter: string, options?: RequestInit): ReadablePromise<ValueSet>;
|
|
375
478
|
/**
|
|
376
479
|
* Returns a cached resource if it is available.
|
|
377
480
|
* @param resourceType The FHIR resource type.
|
|
@@ -403,25 +506,6 @@ export declare class MedplumClient extends EventTarget {
|
|
|
403
506
|
* @returns The resource if available; undefined otherwise.
|
|
404
507
|
*/
|
|
405
508
|
readResource<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
|
|
406
|
-
/**
|
|
407
|
-
* Reads a resource by resource type and ID using the in-memory resource cache.
|
|
408
|
-
*
|
|
409
|
-
* If the resource is not available in the cache, it will be read from the server.
|
|
410
|
-
*
|
|
411
|
-
* Example:
|
|
412
|
-
*
|
|
413
|
-
* ```typescript
|
|
414
|
-
* const patient = await medplum.readCached('Patient', '123');
|
|
415
|
-
* console.log(patient);
|
|
416
|
-
* ```
|
|
417
|
-
*
|
|
418
|
-
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
419
|
-
*
|
|
420
|
-
* @param resourceType The FHIR resource type.
|
|
421
|
-
* @param id The resource ID.
|
|
422
|
-
* @returns The resource if available; undefined otherwise.
|
|
423
|
-
*/
|
|
424
|
-
readCached<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
|
|
425
509
|
/**
|
|
426
510
|
* Reads a resource by `Reference`.
|
|
427
511
|
*
|
|
@@ -441,27 +525,6 @@ export declare class MedplumClient extends EventTarget {
|
|
|
441
525
|
* @returns The resource if available; undefined otherwise.
|
|
442
526
|
*/
|
|
443
527
|
readReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
|
|
444
|
-
/**
|
|
445
|
-
* Reads a resource by `Reference` using the in-memory resource cache.
|
|
446
|
-
*
|
|
447
|
-
* This is a convenience method for `readResource()` that accepts a `Reference` object.
|
|
448
|
-
*
|
|
449
|
-
* If the resource is not available in the cache, it will be read from the server.
|
|
450
|
-
*
|
|
451
|
-
* Example:
|
|
452
|
-
*
|
|
453
|
-
* ```typescript
|
|
454
|
-
* const serviceRequest = await medplum.readResource('ServiceRequest', '123');
|
|
455
|
-
* const patient = await medplum.readCachedReference(serviceRequest.subject);
|
|
456
|
-
* console.log(patient);
|
|
457
|
-
* ```
|
|
458
|
-
*
|
|
459
|
-
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
460
|
-
*
|
|
461
|
-
* @param reference The FHIR reference object.
|
|
462
|
-
* @returns The resource if available; undefined otherwise.
|
|
463
|
-
*/
|
|
464
|
-
readCachedReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
|
|
465
528
|
/**
|
|
466
529
|
* Returns a cached schema for a resource type.
|
|
467
530
|
* If the schema is not cached, returns undefined.
|
|
@@ -493,9 +556,9 @@ export declare class MedplumClient extends EventTarget {
|
|
|
493
556
|
*
|
|
494
557
|
* @param resourceType The FHIR resource type.
|
|
495
558
|
* @param id The resource ID.
|
|
496
|
-
* @returns
|
|
559
|
+
* @returns Promise to the resource history.
|
|
497
560
|
*/
|
|
498
|
-
readHistory<T extends Resource>(resourceType: string, id: string):
|
|
561
|
+
readHistory<T extends Resource>(resourceType: string, id: string): ReadablePromise<Bundle<T>>;
|
|
499
562
|
/**
|
|
500
563
|
* Reads a specific version of a resource by resource type, ID, and version ID.
|
|
501
564
|
*
|
|
@@ -512,8 +575,8 @@ export declare class MedplumClient extends EventTarget {
|
|
|
512
575
|
* @param id The resource ID.
|
|
513
576
|
* @returns The resource if available; undefined otherwise.
|
|
514
577
|
*/
|
|
515
|
-
readVersion<T extends Resource>(resourceType: string, id: string, vid: string):
|
|
516
|
-
readPatientEverything(id: string):
|
|
578
|
+
readVersion<T extends Resource>(resourceType: string, id: string, vid: string): ReadablePromise<T>;
|
|
579
|
+
readPatientEverything(id: string): ReadablePromise<Bundle>;
|
|
517
580
|
/**
|
|
518
581
|
* Creates a new FHIR resource.
|
|
519
582
|
*
|
|
@@ -600,7 +663,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
600
663
|
* @param contentType Content type for the binary.
|
|
601
664
|
* @returns The result of the create operation.
|
|
602
665
|
*/
|
|
603
|
-
createBinary(data: string | File, filename: string | undefined, contentType: string): Promise<Binary>;
|
|
666
|
+
createBinary(data: string | File | Blob | Buffer, filename: string | undefined, contentType: string): Promise<Binary>;
|
|
604
667
|
/**
|
|
605
668
|
* Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
|
|
606
669
|
*
|
|
@@ -619,10 +682,22 @@ export declare class MedplumClient extends EventTarget {
|
|
|
619
682
|
*
|
|
620
683
|
* See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
|
|
621
684
|
*
|
|
622
|
-
* @param docDefinition The
|
|
685
|
+
* @param docDefinition The PDF document definition.
|
|
686
|
+
* @returns The result of the create operation.
|
|
687
|
+
*/
|
|
688
|
+
createPdf(docDefinition: TDocumentDefinitions, filename?: string, tableLayouts?: {
|
|
689
|
+
[name: string]: CustomTableLayout;
|
|
690
|
+
}, fonts?: TFontDictionary): Promise<Binary>;
|
|
691
|
+
/**
|
|
692
|
+
* Creates a FHIR `Communication` resource with the provided data content.
|
|
693
|
+
*
|
|
694
|
+
* This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.
|
|
695
|
+
*
|
|
696
|
+
* @param resource The FHIR resource to comment on.
|
|
697
|
+
* @param text The text of the comment.
|
|
623
698
|
* @returns The result of the create operation.
|
|
624
699
|
*/
|
|
625
|
-
|
|
700
|
+
createComment(resource: Resource, text: string): Promise<Communication>;
|
|
626
701
|
/**
|
|
627
702
|
* Updates a FHIR resource.
|
|
628
703
|
*
|
|
@@ -671,7 +746,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
671
746
|
* @param operations The JSONPatch operations.
|
|
672
747
|
* @returns The result of the patch operations.
|
|
673
748
|
*/
|
|
674
|
-
patchResource<T extends Resource>(resourceType: string, id: string, operations:
|
|
749
|
+
patchResource<T extends Resource>(resourceType: string, id: string, operations: PatchOperation[]): Promise<T>;
|
|
675
750
|
/**
|
|
676
751
|
* Deletes a FHIR resource by resource type and ID.
|
|
677
752
|
*
|
|
@@ -688,9 +763,48 @@ export declare class MedplumClient extends EventTarget {
|
|
|
688
763
|
* @returns The result of the delete operation.
|
|
689
764
|
*/
|
|
690
765
|
deleteResource(resourceType: string, id: string): Promise<any>;
|
|
766
|
+
/**
|
|
767
|
+
* Sends an email using the Medplum Email API.
|
|
768
|
+
*
|
|
769
|
+
* Builds the email using nodemailer MailComposer.
|
|
770
|
+
*
|
|
771
|
+
* Examples:
|
|
772
|
+
*
|
|
773
|
+
* Send a simple text email:
|
|
774
|
+
*
|
|
775
|
+
* ```typescript
|
|
776
|
+
* await medplum.sendEmail({
|
|
777
|
+
* to: 'alice@example.com',
|
|
778
|
+
* cc: 'bob@example.com',
|
|
779
|
+
* subject: 'Hello',
|
|
780
|
+
* text: 'Hello Alice',
|
|
781
|
+
* });
|
|
782
|
+
* ```
|
|
783
|
+
*
|
|
784
|
+
* Send an email with a `Binary` attachment:
|
|
785
|
+
*
|
|
786
|
+
* ```typescript
|
|
787
|
+
* await medplum.sendEmail({
|
|
788
|
+
* to: 'alice@example.com',
|
|
789
|
+
* subject: 'Email with attachment',
|
|
790
|
+
* text: 'See the attached report',
|
|
791
|
+
* attachments: [{
|
|
792
|
+
* filename: 'report.pdf',
|
|
793
|
+
* path: "Binary/" + binary.id
|
|
794
|
+
* }]
|
|
795
|
+
* });
|
|
796
|
+
* ```
|
|
797
|
+
*
|
|
798
|
+
* See options here: https://nodemailer.com/extras/mailcomposer/
|
|
799
|
+
*
|
|
800
|
+
* @param options The MailComposer options.
|
|
801
|
+
* @returns Promise to the operation outcome.
|
|
802
|
+
*/
|
|
803
|
+
sendEmail(email: MailOptions): Promise<OperationOutcome>;
|
|
691
804
|
graphql(query: string, options?: RequestInit): Promise<any>;
|
|
692
805
|
getActiveLogin(): LoginState | undefined;
|
|
693
806
|
setActiveLogin(login: LoginState): Promise<void>;
|
|
807
|
+
getAccessToken(): string | undefined;
|
|
694
808
|
setAccessToken(accessToken: string): void;
|
|
695
809
|
getLogins(): LoginState[];
|
|
696
810
|
isLoading(): boolean;
|
|
@@ -702,12 +816,19 @@ export declare class MedplumClient extends EventTarget {
|
|
|
702
816
|
* @param url The URL to request.
|
|
703
817
|
* @returns Promise to the response body as a blob.
|
|
704
818
|
*/
|
|
705
|
-
download(url: string, options?: RequestInit): Promise<Blob>;
|
|
819
|
+
download(url: URL | string, options?: RequestInit): Promise<Blob>;
|
|
706
820
|
/**
|
|
707
821
|
* Processes an OAuth authorization code.
|
|
708
822
|
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
|
|
709
823
|
* @param code The authorization code received by URL parameter.
|
|
710
824
|
*/
|
|
711
825
|
processCode(code: string): Promise<ProfileResource>;
|
|
712
|
-
|
|
826
|
+
/**
|
|
827
|
+
* Starts a new OAuth2 client credentials flow.
|
|
828
|
+
* See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
|
|
829
|
+
* @param clientId The client ID.
|
|
830
|
+
* @param clientSecret The client secret.
|
|
831
|
+
* @returns Promise that resolves to the client profile.
|
|
832
|
+
*/
|
|
833
|
+
startClientLogin(clientId: string, clientSecret: string): Promise<ProfileResource>;
|
|
713
834
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { PropertyType } from '../types';
|
|
2
|
+
export interface TypedValue {
|
|
3
|
+
readonly type: PropertyType;
|
|
4
|
+
readonly value: any;
|
|
5
|
+
}
|
|
6
|
+
export interface Atom {
|
|
7
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
8
|
+
}
|
|
9
|
+
export declare class FhirPathAtom implements Atom {
|
|
10
|
+
readonly original: string;
|
|
11
|
+
readonly child: Atom;
|
|
12
|
+
constructor(original: string, child: Atom);
|
|
13
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
14
|
+
}
|
|
15
|
+
export declare class LiteralAtom implements Atom {
|
|
16
|
+
readonly value: TypedValue;
|
|
17
|
+
constructor(value: TypedValue);
|
|
18
|
+
eval(): TypedValue[];
|
|
19
|
+
}
|
|
20
|
+
export declare class SymbolAtom implements Atom {
|
|
21
|
+
#private;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
constructor(name: string);
|
|
24
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
25
|
+
}
|
|
26
|
+
export declare class EmptySetAtom implements Atom {
|
|
27
|
+
eval(): [];
|
|
28
|
+
}
|
|
29
|
+
export declare class UnaryOperatorAtom implements Atom {
|
|
30
|
+
readonly child: Atom;
|
|
31
|
+
readonly impl: (x: TypedValue[]) => TypedValue[];
|
|
32
|
+
constructor(child: Atom, impl: (x: TypedValue[]) => TypedValue[]);
|
|
33
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
34
|
+
}
|
|
35
|
+
export declare class AsAtom implements Atom {
|
|
36
|
+
readonly left: Atom;
|
|
37
|
+
readonly right: Atom;
|
|
38
|
+
constructor(left: Atom, right: Atom);
|
|
39
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
40
|
+
}
|
|
41
|
+
export declare class ArithemticOperatorAtom implements Atom {
|
|
42
|
+
readonly left: Atom;
|
|
43
|
+
readonly right: Atom;
|
|
44
|
+
readonly impl: (x: number, y: number) => number | boolean;
|
|
45
|
+
constructor(left: Atom, right: Atom, impl: (x: number, y: number) => number | boolean);
|
|
46
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
47
|
+
}
|
|
48
|
+
export declare class ConcatAtom implements Atom {
|
|
49
|
+
readonly left: Atom;
|
|
50
|
+
readonly right: Atom;
|
|
51
|
+
constructor(left: Atom, right: Atom);
|
|
52
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
53
|
+
}
|
|
54
|
+
export declare class ContainsAtom implements Atom {
|
|
55
|
+
readonly left: Atom;
|
|
56
|
+
readonly right: Atom;
|
|
57
|
+
constructor(left: Atom, right: Atom);
|
|
58
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
59
|
+
}
|
|
60
|
+
export declare class InAtom implements Atom {
|
|
61
|
+
readonly left: Atom;
|
|
62
|
+
readonly right: Atom;
|
|
63
|
+
constructor(left: Atom, right: Atom);
|
|
64
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
65
|
+
}
|
|
66
|
+
export declare class DotAtom implements Atom {
|
|
67
|
+
readonly left: Atom;
|
|
68
|
+
readonly right: Atom;
|
|
69
|
+
constructor(left: Atom, right: Atom);
|
|
70
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
71
|
+
}
|
|
72
|
+
export declare class UnionAtom implements Atom {
|
|
73
|
+
readonly left: Atom;
|
|
74
|
+
readonly right: Atom;
|
|
75
|
+
constructor(left: Atom, right: Atom);
|
|
76
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
77
|
+
}
|
|
78
|
+
export declare class EqualsAtom implements Atom {
|
|
79
|
+
readonly left: Atom;
|
|
80
|
+
readonly right: Atom;
|
|
81
|
+
constructor(left: Atom, right: Atom);
|
|
82
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
83
|
+
}
|
|
84
|
+
export declare class NotEqualsAtom implements Atom {
|
|
85
|
+
readonly left: Atom;
|
|
86
|
+
readonly right: Atom;
|
|
87
|
+
constructor(left: Atom, right: Atom);
|
|
88
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
89
|
+
}
|
|
90
|
+
export declare class EquivalentAtom implements Atom {
|
|
91
|
+
readonly left: Atom;
|
|
92
|
+
readonly right: Atom;
|
|
93
|
+
constructor(left: Atom, right: Atom);
|
|
94
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
95
|
+
}
|
|
96
|
+
export declare class NotEquivalentAtom implements Atom {
|
|
97
|
+
readonly left: Atom;
|
|
98
|
+
readonly right: Atom;
|
|
99
|
+
constructor(left: Atom, right: Atom);
|
|
100
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
101
|
+
}
|
|
102
|
+
export declare class IsAtom implements Atom {
|
|
103
|
+
readonly left: Atom;
|
|
104
|
+
readonly right: Atom;
|
|
105
|
+
constructor(left: Atom, right: Atom);
|
|
106
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 6.5.1. and
|
|
110
|
+
* Returns true if both operands evaluate to true, false if either operand evaluates to false, and the empty collection ({ }) otherwise.
|
|
111
|
+
*/
|
|
112
|
+
export declare class AndAtom implements Atom {
|
|
113
|
+
readonly left: Atom;
|
|
114
|
+
readonly right: Atom;
|
|
115
|
+
constructor(left: Atom, right: Atom);
|
|
116
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
117
|
+
}
|
|
118
|
+
export declare class OrAtom implements Atom {
|
|
119
|
+
readonly left: Atom;
|
|
120
|
+
readonly right: Atom;
|
|
121
|
+
constructor(left: Atom, right: Atom);
|
|
122
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 6.5.4. xor
|
|
126
|
+
* Returns true if exactly one of the operands evaluates to true,
|
|
127
|
+
* false if either both operands evaluate to true or both operands evaluate to false,
|
|
128
|
+
* and the empty collection ({ }) otherwise:
|
|
129
|
+
*/
|
|
130
|
+
export declare class XorAtom implements Atom {
|
|
131
|
+
readonly left: Atom;
|
|
132
|
+
readonly right: Atom;
|
|
133
|
+
constructor(left: Atom, right: Atom);
|
|
134
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
135
|
+
}
|
|
136
|
+
export declare class FunctionAtom implements Atom {
|
|
137
|
+
readonly name: string;
|
|
138
|
+
readonly args: Atom[];
|
|
139
|
+
readonly impl: (context: TypedValue[], ...a: Atom[]) => TypedValue[];
|
|
140
|
+
constructor(name: string, args: Atom[], impl: (context: TypedValue[], ...a: Atom[]) => TypedValue[]);
|
|
141
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
142
|
+
}
|
|
143
|
+
export declare class IndexerAtom implements Atom {
|
|
144
|
+
readonly left: Atom;
|
|
145
|
+
readonly expr: Atom;
|
|
146
|
+
constructor(left: Atom, expr: Atom);
|
|
147
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
148
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseDateString(str: string): string;
|