@medplum/core 2.0.4 → 2.0.5
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 +35 -21
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +10 -17
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/outcomes.mjs +17 -2
- package/dist/esm/outcomes.mjs.map +1 -1
- package/dist/esm/search/match.mjs +9 -4
- package/dist/esm/search/match.mjs.map +1 -1
- package/dist/{esm → types}/outcomes.d.ts +7 -1
- package/package.json +4 -4
- package/tsconfig.build.json +9 -0
- package/dist/cjs/outcomes.d.ts +0 -31
- package/dist/esm/cache.d.ts +0 -34
- package/dist/esm/client.d.ts +0 -1218
- package/dist/esm/crypto.d.ts +0 -9
- package/dist/esm/eventtarget.d.ts +0 -13
- package/dist/esm/fhirlexer/index.d.ts +0 -2
- package/dist/esm/fhirlexer/parse.d.ts +0 -47
- package/dist/esm/fhirlexer/tokenize.d.ts +0 -14
- package/dist/esm/fhirmapper/parse.d.ts +0 -7
- package/dist/esm/fhirmapper/tokenize.d.ts +0 -2
- package/dist/esm/fhirpath/atoms.d.ts +0 -120
- package/dist/esm/fhirpath/date.d.ts +0 -1
- package/dist/esm/fhirpath/functions.d.ts +0 -6
- package/dist/esm/fhirpath/index.d.ts +0 -4
- package/dist/esm/fhirpath/parse.d.ts +0 -64
- package/dist/esm/fhirpath/tokenize.d.ts +0 -4
- package/dist/esm/fhirpath/utils.d.ts +0 -95
- package/dist/esm/format.d.ts +0 -118
- package/dist/esm/hl7.d.ts +0 -136
- package/dist/esm/index.d.ts +0 -14
- package/dist/esm/jwt.d.ts +0 -5
- package/dist/esm/readablepromise.d.ts +0 -48
- package/dist/esm/search/details.d.ts +0 -33
- package/dist/esm/search/match.d.ts +0 -9
- package/dist/esm/search/parse.d.ts +0 -17
- package/dist/esm/search/search.d.ts +0 -66
- package/dist/esm/storage.d.ts +0 -47
- package/dist/esm/types.d.ts +0 -200
- package/dist/esm/utils.d.ts +0 -259
- /package/dist/{cjs → types}/cache.d.ts +0 -0
- /package/dist/{cjs → types}/client.d.ts +0 -0
- /package/dist/{cjs → types}/crypto.d.ts +0 -0
- /package/dist/{cjs → types}/eventtarget.d.ts +0 -0
- /package/dist/{cjs → types}/fhirlexer/index.d.ts +0 -0
- /package/dist/{cjs → types}/fhirlexer/parse.d.ts +0 -0
- /package/dist/{cjs → types}/fhirlexer/tokenize.d.ts +0 -0
- /package/dist/{cjs → types}/fhirmapper/parse.d.ts +0 -0
- /package/dist/{cjs → types}/fhirmapper/tokenize.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/atoms.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/date.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/functions.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/index.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/parse.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/tokenize.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/utils.d.ts +0 -0
- /package/dist/{cjs → types}/format.d.ts +0 -0
- /package/dist/{cjs → types}/hl7.d.ts +0 -0
- /package/dist/{cjs → types}/index.d.ts +0 -0
- /package/dist/{cjs → types}/jwt.d.ts +0 -0
- /package/dist/{cjs → types}/readablepromise.d.ts +0 -0
- /package/dist/{cjs → types}/search/details.d.ts +0 -0
- /package/dist/{cjs → types}/search/match.d.ts +0 -0
- /package/dist/{cjs → types}/search/parse.d.ts +0 -0
- /package/dist/{cjs → types}/search/search.d.ts +0 -0
- /package/dist/{cjs → types}/storage.d.ts +0 -0
- /package/dist/{cjs → types}/types.d.ts +0 -0
- /package/dist/{cjs → types}/utils.d.ts +0 -0
package/dist/esm/client.d.ts
DELETED
|
@@ -1,1218 +0,0 @@
|
|
|
1
|
-
import { Binary, Bundle, Communication, ExtractResource, OperationOutcome, Project, ProjectMembership, ProjectSecret, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
2
|
-
/** @ts-ignore */
|
|
3
|
-
import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
|
|
4
|
-
import { EventTarget } from './eventtarget';
|
|
5
|
-
import { Hl7Message } from './hl7';
|
|
6
|
-
import { ReadablePromise } from './readablepromise';
|
|
7
|
-
import { IndexedStructureDefinition } from './types';
|
|
8
|
-
import { ProfileResource } from './utils';
|
|
9
|
-
export declare const MEDPLUM_VERSION: string | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* The MedplumClientOptions interface defines configuration options for MedplumClient.
|
|
12
|
-
*
|
|
13
|
-
* All configuration settings are optional.
|
|
14
|
-
*/
|
|
15
|
-
export interface MedplumClientOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Base server URL.
|
|
18
|
-
*
|
|
19
|
-
* Default value is https://api.medplum.com/
|
|
20
|
-
*
|
|
21
|
-
* Use this to point to a custom Medplum deployment.
|
|
22
|
-
*/
|
|
23
|
-
baseUrl?: string;
|
|
24
|
-
/**
|
|
25
|
-
* OAuth2 authorize URL.
|
|
26
|
-
*
|
|
27
|
-
* Default value is baseUrl + "/oauth2/authorize".
|
|
28
|
-
*
|
|
29
|
-
* Use this if you want to use a separate OAuth server.
|
|
30
|
-
*/
|
|
31
|
-
authorizeUrl?: string;
|
|
32
|
-
/**
|
|
33
|
-
* OAuth2 token URL.
|
|
34
|
-
*
|
|
35
|
-
* Default value is baseUrl + "/oauth2/token".
|
|
36
|
-
*
|
|
37
|
-
* Use this if you want to use a separate OAuth server.
|
|
38
|
-
*/
|
|
39
|
-
tokenUrl?: string;
|
|
40
|
-
/**
|
|
41
|
-
* OAuth2 logout URL.
|
|
42
|
-
*
|
|
43
|
-
* Default value is baseUrl + "/oauth2/logout".
|
|
44
|
-
*
|
|
45
|
-
* Use this if you want to use a separate OAuth server.
|
|
46
|
-
*/
|
|
47
|
-
logoutUrl?: string;
|
|
48
|
-
/**
|
|
49
|
-
* The client ID.
|
|
50
|
-
*
|
|
51
|
-
* Client ID can be used for SMART-on-FHIR customization.
|
|
52
|
-
*/
|
|
53
|
-
clientId?: string;
|
|
54
|
-
/**
|
|
55
|
-
* Number of resources to store in the cache.
|
|
56
|
-
*
|
|
57
|
-
* Default value is 1000.
|
|
58
|
-
*
|
|
59
|
-
* Consider using this for performance of displaying Patient or Practitioner resources.
|
|
60
|
-
*/
|
|
61
|
-
resourceCacheSize?: number;
|
|
62
|
-
/**
|
|
63
|
-
* The length of time in milliseconds to cache resources.
|
|
64
|
-
*
|
|
65
|
-
* Default value is 10000 (10 seconds).
|
|
66
|
-
*
|
|
67
|
-
* Cache time of zero disables all caching.
|
|
68
|
-
*
|
|
69
|
-
* For any individual request, the cache behavior can be overridden by setting the cache property on request options.
|
|
70
|
-
*
|
|
71
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache
|
|
72
|
-
*/
|
|
73
|
-
cacheTime?: number;
|
|
74
|
-
/**
|
|
75
|
-
* The length of time in milliseconds to delay requests for auto batching.
|
|
76
|
-
*
|
|
77
|
-
* Auto batching attempts to group multiple requests together into a single batch request.
|
|
78
|
-
*
|
|
79
|
-
* Default value is 0, which disables auto batching.
|
|
80
|
-
*/
|
|
81
|
-
autoBatchTime?: number;
|
|
82
|
-
/**
|
|
83
|
-
* Fetch implementation.
|
|
84
|
-
*
|
|
85
|
-
* Default is window.fetch (if available).
|
|
86
|
-
*
|
|
87
|
-
* For Node.js applications, consider the 'node-fetch' package.
|
|
88
|
-
*/
|
|
89
|
-
fetch?: FetchLike;
|
|
90
|
-
/**
|
|
91
|
-
* Create PDF implementation.
|
|
92
|
-
*
|
|
93
|
-
* Default is none, and PDF generation is disabled.
|
|
94
|
-
*
|
|
95
|
-
* In browser environments, import the client-side pdfmake library.
|
|
96
|
-
*
|
|
97
|
-
* ```html
|
|
98
|
-
* <script src="pdfmake.min.js"></script>
|
|
99
|
-
* <script>
|
|
100
|
-
* async function createPdf(docDefinition, tableLayouts, fonts) {
|
|
101
|
-
* return new Promise((resolve) => {
|
|
102
|
-
* pdfMake.createPdf(docDefinition, tableLayouts, fonts).getBlob(resolve);
|
|
103
|
-
* });
|
|
104
|
-
* }
|
|
105
|
-
* </script>
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* In Node.js applications:
|
|
109
|
-
*
|
|
110
|
-
* ```ts
|
|
111
|
-
* import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
|
|
112
|
-
* function createPdf(
|
|
113
|
-
* docDefinition: TDocumentDefinitions,
|
|
114
|
-
* tableLayouts?: { [name: string]: CustomTableLayout },
|
|
115
|
-
* fonts?: TFontDictionary
|
|
116
|
-
* ): Promise<Buffer> {
|
|
117
|
-
* return new Promise((resolve, reject) => {
|
|
118
|
-
* const printer = new PdfPrinter(fonts || {});
|
|
119
|
-
* const pdfDoc = printer.createPdfKitDocument(docDefinition, { tableLayouts });
|
|
120
|
-
* const chunks: Uint8Array[] = [];
|
|
121
|
-
* pdfDoc.on('data', (chunk: Uint8Array) => chunks.push(chunk));
|
|
122
|
-
* pdfDoc.on('end', () => resolve(Buffer.concat(chunks)));
|
|
123
|
-
* pdfDoc.on('error', reject);
|
|
124
|
-
* pdfDoc.end();
|
|
125
|
-
* });
|
|
126
|
-
* }
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
createPdf?: CreatePdfFunction;
|
|
130
|
-
/**
|
|
131
|
-
* Callback for when the client is unauthenticated.
|
|
132
|
-
*
|
|
133
|
-
* Default is do nothing.
|
|
134
|
-
*
|
|
135
|
-
* For client side applications, consider redirecting to a sign in page.
|
|
136
|
-
*/
|
|
137
|
-
onUnauthenticated?: () => void;
|
|
138
|
-
}
|
|
139
|
-
export interface FetchLike {
|
|
140
|
-
(url: string, options?: any): Promise<any>;
|
|
141
|
-
}
|
|
142
|
-
export interface CreatePdfFunction {
|
|
143
|
-
(docDefinition: TDocumentDefinitions, tableLayouts?: {
|
|
144
|
-
[name: string]: CustomTableLayout;
|
|
145
|
-
} | undefined, fonts?: TFontDictionary | undefined): Promise<any>;
|
|
146
|
-
}
|
|
147
|
-
export interface BaseLoginRequest {
|
|
148
|
-
readonly projectId?: string;
|
|
149
|
-
readonly clientId?: string;
|
|
150
|
-
readonly resourceType?: string;
|
|
151
|
-
readonly scope?: string;
|
|
152
|
-
readonly nonce?: string;
|
|
153
|
-
readonly codeChallenge?: string;
|
|
154
|
-
readonly codeChallengeMethod?: string;
|
|
155
|
-
readonly googleClientId?: string;
|
|
156
|
-
readonly launch?: string;
|
|
157
|
-
readonly redirectUri?: string;
|
|
158
|
-
}
|
|
159
|
-
export interface EmailPasswordLoginRequest extends BaseLoginRequest {
|
|
160
|
-
readonly email: string;
|
|
161
|
-
readonly password: string;
|
|
162
|
-
readonly remember?: boolean;
|
|
163
|
-
}
|
|
164
|
-
export interface NewUserRequest {
|
|
165
|
-
readonly firstName: string;
|
|
166
|
-
readonly lastName: string;
|
|
167
|
-
readonly email: string;
|
|
168
|
-
readonly password: string;
|
|
169
|
-
readonly recaptchaToken: string;
|
|
170
|
-
readonly recaptchaSiteKey?: string;
|
|
171
|
-
readonly remember?: boolean;
|
|
172
|
-
readonly projectId?: string;
|
|
173
|
-
}
|
|
174
|
-
export interface NewProjectRequest {
|
|
175
|
-
readonly login: string;
|
|
176
|
-
readonly projectName: string;
|
|
177
|
-
}
|
|
178
|
-
export interface NewPatientRequest {
|
|
179
|
-
readonly login: string;
|
|
180
|
-
readonly projectId: string;
|
|
181
|
-
}
|
|
182
|
-
export interface GoogleCredentialResponse {
|
|
183
|
-
readonly clientId: string;
|
|
184
|
-
readonly credential: string;
|
|
185
|
-
}
|
|
186
|
-
export interface GoogleLoginRequest extends BaseLoginRequest {
|
|
187
|
-
readonly googleClientId: string;
|
|
188
|
-
readonly googleCredential: string;
|
|
189
|
-
readonly createUser?: boolean;
|
|
190
|
-
}
|
|
191
|
-
export interface LoginAuthenticationResponse {
|
|
192
|
-
readonly login: string;
|
|
193
|
-
readonly mfaRequired?: boolean;
|
|
194
|
-
readonly code?: string;
|
|
195
|
-
readonly memberships?: ProjectMembership[];
|
|
196
|
-
}
|
|
197
|
-
export interface LoginProfileResponse {
|
|
198
|
-
readonly login: string;
|
|
199
|
-
readonly scope: string;
|
|
200
|
-
}
|
|
201
|
-
export interface LoginScopeResponse {
|
|
202
|
-
readonly login: string;
|
|
203
|
-
readonly code: string;
|
|
204
|
-
}
|
|
205
|
-
export interface LoginState {
|
|
206
|
-
readonly project: Reference<Project>;
|
|
207
|
-
readonly profile: Reference<ProfileResource>;
|
|
208
|
-
readonly accessToken: string;
|
|
209
|
-
readonly refreshToken: string;
|
|
210
|
-
}
|
|
211
|
-
export interface TokenResponse {
|
|
212
|
-
readonly token_type: string;
|
|
213
|
-
readonly id_token: string;
|
|
214
|
-
readonly access_token: string;
|
|
215
|
-
readonly refresh_token: string;
|
|
216
|
-
readonly expires_in: number;
|
|
217
|
-
readonly project: Reference<Project>;
|
|
218
|
-
readonly profile: Reference<ProfileResource>;
|
|
219
|
-
}
|
|
220
|
-
export interface BotEvent<T = Resource | Hl7Message | string | Record<string, any>> {
|
|
221
|
-
readonly contentType: string;
|
|
222
|
-
readonly input: T;
|
|
223
|
-
readonly secrets: Record<string, ProjectSecret>;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* JSONPatch patch operation.
|
|
227
|
-
* Compatible with fast-json-patch and rfc6902 Operation.
|
|
228
|
-
*/
|
|
229
|
-
export interface PatchOperation {
|
|
230
|
-
readonly op: 'add' | 'remove' | 'replace' | 'copy' | 'move' | 'test';
|
|
231
|
-
readonly path: string;
|
|
232
|
-
readonly value?: any;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Email address definition.
|
|
236
|
-
* Compatible with nodemailer Mail.Address.
|
|
237
|
-
*/
|
|
238
|
-
export interface MailAddress {
|
|
239
|
-
readonly name: string;
|
|
240
|
-
readonly address: string;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Email attachment definition.
|
|
244
|
-
* Compatible with nodemailer Mail.Options.
|
|
245
|
-
*/
|
|
246
|
-
export interface MailAttachment {
|
|
247
|
-
/** String, Buffer or a Stream contents for the attachmentent */
|
|
248
|
-
readonly content?: string;
|
|
249
|
-
/** 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) */
|
|
250
|
-
readonly path?: string;
|
|
251
|
-
/** 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 */
|
|
252
|
-
readonly filename?: string | false;
|
|
253
|
-
/** optional content type for the attachment, if not set will be derived from the filename property */
|
|
254
|
-
readonly contentType?: string;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Email message definition.
|
|
258
|
-
* Compatible with nodemailer Mail.Options.
|
|
259
|
-
*/
|
|
260
|
-
export interface MailOptions {
|
|
261
|
-
/** The e-mail address of the sender. All e-mail addresses can be plain 'sender@server.com' or formatted 'Sender Name <sender@server.com>' */
|
|
262
|
-
readonly from?: string | MailAddress;
|
|
263
|
-
/** An e-mail address that will appear on the Sender: field */
|
|
264
|
-
readonly sender?: string | MailAddress;
|
|
265
|
-
/** Comma separated list or an array of recipients e-mail addresses that will appear on the To: field */
|
|
266
|
-
readonly to?: string | MailAddress | string[] | MailAddress[];
|
|
267
|
-
/** Comma separated list or an array of recipients e-mail addresses that will appear on the Cc: field */
|
|
268
|
-
readonly cc?: string | MailAddress | string[] | MailAddress[];
|
|
269
|
-
/** Comma separated list or an array of recipients e-mail addresses that will appear on the Bcc: field */
|
|
270
|
-
readonly bcc?: string | MailAddress | string[] | MailAddress[];
|
|
271
|
-
/** An e-mail address that will appear on the Reply-To: field */
|
|
272
|
-
readonly replyTo?: string | MailAddress;
|
|
273
|
-
/** The subject of the e-mail */
|
|
274
|
-
readonly subject?: string;
|
|
275
|
-
/** The plaintext version of the message */
|
|
276
|
-
readonly text?: string;
|
|
277
|
-
/** The HTML version of the message */
|
|
278
|
-
readonly html?: string;
|
|
279
|
-
/** An array of attachment objects */
|
|
280
|
-
readonly attachments?: MailAttachment[];
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* The MedplumClient class provides a client for the Medplum FHIR server.
|
|
284
|
-
*
|
|
285
|
-
* The client can be used in the browser, in a Node.js application, or in a Medplum Bot.
|
|
286
|
-
*
|
|
287
|
-
* The client provides helpful methods for common operations such as:
|
|
288
|
-
* 1) Authenticating
|
|
289
|
-
* 2) Creating resources
|
|
290
|
-
* 2) Reading resources
|
|
291
|
-
* 3) Updating resources
|
|
292
|
-
* 5) Deleting resources
|
|
293
|
-
* 6) Searching
|
|
294
|
-
* 7) Making GraphQL queries
|
|
295
|
-
*
|
|
296
|
-
* Here is a quick example of how to use the client:
|
|
297
|
-
*
|
|
298
|
-
* ```typescript
|
|
299
|
-
* import { MedplumClient } from '@medplum/core';
|
|
300
|
-
* const medplum = new MedplumClient();
|
|
301
|
-
* ```
|
|
302
|
-
*
|
|
303
|
-
* Create a `Patient`:
|
|
304
|
-
*
|
|
305
|
-
* ```typescript
|
|
306
|
-
* const patient = await medplum.createResource({
|
|
307
|
-
* resourceType: 'Patient',
|
|
308
|
-
* name: [{
|
|
309
|
-
* given: ['Alice'],
|
|
310
|
-
* family: 'Smith'
|
|
311
|
-
* }]
|
|
312
|
-
* });
|
|
313
|
-
* ```
|
|
314
|
-
*
|
|
315
|
-
* Read a `Patient` by ID:
|
|
316
|
-
*
|
|
317
|
-
* ```typescript
|
|
318
|
-
* const patient = await medplum.readResource('Patient', '123');
|
|
319
|
-
* console.log(patient.name[0].given[0]);
|
|
320
|
-
* ```
|
|
321
|
-
*
|
|
322
|
-
* Search for a `Patient` by name:
|
|
323
|
-
*
|
|
324
|
-
* ```typescript
|
|
325
|
-
* const bundle = await medplum.search('Patient', 'name=Alice');
|
|
326
|
-
* console.log(bundle.total);
|
|
327
|
-
* ```
|
|
328
|
-
*
|
|
329
|
-
* <head>
|
|
330
|
-
* <meta name="algolia:pageRank" content="100" />
|
|
331
|
-
* </head>
|
|
332
|
-
|
|
333
|
-
*/
|
|
334
|
-
export declare class MedplumClient extends EventTarget {
|
|
335
|
-
#private;
|
|
336
|
-
constructor(options?: MedplumClientOptions);
|
|
337
|
-
/**
|
|
338
|
-
* Returns the current base URL for all API requests.
|
|
339
|
-
* By default, this is set to `https://api.medplum.com/`.
|
|
340
|
-
* This can be overridden by setting the `baseUrl` option when creating the client.
|
|
341
|
-
* @category HTTP
|
|
342
|
-
* @returns The current base URL for all API requests.
|
|
343
|
-
*/
|
|
344
|
-
getBaseUrl(): string;
|
|
345
|
-
/**
|
|
346
|
-
* Clears all auth state including local storage and session storage.
|
|
347
|
-
* @category Authentication
|
|
348
|
-
*/
|
|
349
|
-
clear(): void;
|
|
350
|
-
/**
|
|
351
|
-
* Clears the active login from local storage.
|
|
352
|
-
* Does not clear all local storage (such as other logins).
|
|
353
|
-
* @category Authentication
|
|
354
|
-
*/
|
|
355
|
-
clearActiveLogin(): void;
|
|
356
|
-
/**
|
|
357
|
-
* Invalidates any cached values or cached requests for the given URL.
|
|
358
|
-
* @category Caching
|
|
359
|
-
* @param url The URL to invalidate.
|
|
360
|
-
*/
|
|
361
|
-
invalidateUrl(url: URL | string): void;
|
|
362
|
-
/**
|
|
363
|
-
* Invalidates all cached search results or cached requests for the given resourceType.
|
|
364
|
-
* @category Caching
|
|
365
|
-
* @param resourceType The resource type to invalidate.
|
|
366
|
-
*/
|
|
367
|
-
invalidateSearches<K extends ResourceType>(resourceType: K): void;
|
|
368
|
-
/**
|
|
369
|
-
* Makes an HTTP GET request to the specified URL.
|
|
370
|
-
*
|
|
371
|
-
* This is a lower level method for custom requests.
|
|
372
|
-
* For common operations, we recommend using higher level methods
|
|
373
|
-
* such as `readResource()`, `search()`, etc.
|
|
374
|
-
*
|
|
375
|
-
* @category HTTP
|
|
376
|
-
* @param url The target URL.
|
|
377
|
-
* @param options Optional fetch options.
|
|
378
|
-
* @returns Promise to the response content.
|
|
379
|
-
*/
|
|
380
|
-
get<T = any>(url: URL | string, options?: RequestInit): ReadablePromise<T>;
|
|
381
|
-
/**
|
|
382
|
-
* Makes an HTTP POST request to the specified URL.
|
|
383
|
-
*
|
|
384
|
-
* This is a lower level method for custom requests.
|
|
385
|
-
* For common operations, we recommend using higher level methods
|
|
386
|
-
* such as `createResource()`.
|
|
387
|
-
*
|
|
388
|
-
* @category HTTP
|
|
389
|
-
* @param url The target URL.
|
|
390
|
-
* @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
|
|
391
|
-
* @param contentType The content type to be included in the "Content-Type" header.
|
|
392
|
-
* @param options Optional fetch options.
|
|
393
|
-
* @returns Promise to the response content.
|
|
394
|
-
*/
|
|
395
|
-
post(url: URL | string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
396
|
-
/**
|
|
397
|
-
* Makes an HTTP PUT request to the specified URL.
|
|
398
|
-
*
|
|
399
|
-
* This is a lower level method for custom requests.
|
|
400
|
-
* For common operations, we recommend using higher level methods
|
|
401
|
-
* such as `updateResource()`.
|
|
402
|
-
*
|
|
403
|
-
* @category HTTP
|
|
404
|
-
* @param url The target URL.
|
|
405
|
-
* @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
|
|
406
|
-
* @param contentType The content type to be included in the "Content-Type" header.
|
|
407
|
-
* @param options Optional fetch options.
|
|
408
|
-
* @returns Promise to the response content.
|
|
409
|
-
*/
|
|
410
|
-
put(url: URL | string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
411
|
-
/**
|
|
412
|
-
* Makes an HTTP PATCH request to the specified URL.
|
|
413
|
-
*
|
|
414
|
-
* This is a lower level method for custom requests.
|
|
415
|
-
* For common operations, we recommend using higher level methods
|
|
416
|
-
* such as `patchResource()`.
|
|
417
|
-
*
|
|
418
|
-
* @category HTTP
|
|
419
|
-
* @param url The target URL.
|
|
420
|
-
* @param operations Array of JSONPatch operations.
|
|
421
|
-
* @param options Optional fetch options.
|
|
422
|
-
* @returns Promise to the response content.
|
|
423
|
-
*/
|
|
424
|
-
patch(url: URL | string, operations: PatchOperation[], options?: RequestInit): Promise<any>;
|
|
425
|
-
/**
|
|
426
|
-
* Makes an HTTP DELETE request to the specified URL.
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
* This is a lower level method for custom requests.
|
|
430
|
-
* For common operations, we recommend using higher level methods
|
|
431
|
-
* such as `deleteResource()`.
|
|
432
|
-
*
|
|
433
|
-
* @category HTTP
|
|
434
|
-
* @param url The target URL.
|
|
435
|
-
* @param options Optional fetch options.
|
|
436
|
-
* @returns Promise to the response content.
|
|
437
|
-
*/
|
|
438
|
-
delete(url: URL | string, options?: RequestInit): Promise<any>;
|
|
439
|
-
/**
|
|
440
|
-
* Initiates a new user flow.
|
|
441
|
-
*
|
|
442
|
-
* This method is part of the two different user registration flows:
|
|
443
|
-
* 1) New Practitioner and new Project
|
|
444
|
-
* 2) New Patient registration
|
|
445
|
-
*
|
|
446
|
-
* @category Authentication
|
|
447
|
-
* @param newUserRequest Register request including email and password.
|
|
448
|
-
* @returns Promise to the authentication response.
|
|
449
|
-
*/
|
|
450
|
-
startNewUser(newUserRequest: NewUserRequest): Promise<LoginAuthenticationResponse>;
|
|
451
|
-
/**
|
|
452
|
-
* Initiates a new project flow.
|
|
453
|
-
*
|
|
454
|
-
* This requires a partial login from `startNewUser` or `startNewGoogleUser`.
|
|
455
|
-
*
|
|
456
|
-
* @param newProjectRequest Register request including email and password.
|
|
457
|
-
* @returns Promise to the authentication response.
|
|
458
|
-
*/
|
|
459
|
-
startNewProject(newProjectRequest: NewProjectRequest): Promise<LoginAuthenticationResponse>;
|
|
460
|
-
/**
|
|
461
|
-
* Initiates a new patient flow.
|
|
462
|
-
*
|
|
463
|
-
* This requires a partial login from `startNewUser` or `startNewGoogleUser`.
|
|
464
|
-
*
|
|
465
|
-
* @param newPatientRequest Register request including email and password.
|
|
466
|
-
* @returns Promise to the authentication response.
|
|
467
|
-
*/
|
|
468
|
-
startNewPatient(newPatientRequest: NewPatientRequest): Promise<LoginAuthenticationResponse>;
|
|
469
|
-
/**
|
|
470
|
-
* Initiates a user login flow.
|
|
471
|
-
* @category Authentication
|
|
472
|
-
* @param loginRequest Login request including email and password.
|
|
473
|
-
* @returns Promise to the authentication response.
|
|
474
|
-
*/
|
|
475
|
-
startLogin(loginRequest: EmailPasswordLoginRequest): Promise<LoginAuthenticationResponse>;
|
|
476
|
-
/**
|
|
477
|
-
* Tries to sign in with Google authentication.
|
|
478
|
-
* The response parameter is the result of a Google authentication.
|
|
479
|
-
* See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
|
|
480
|
-
* @category Authentication
|
|
481
|
-
* @param loginRequest Login request including Google credential response.
|
|
482
|
-
* @returns Promise to the authentication response.
|
|
483
|
-
*/
|
|
484
|
-
startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse>;
|
|
485
|
-
/**
|
|
486
|
-
* Returns the PKCE code challenge and method.
|
|
487
|
-
* If the login request already includes a code challenge, it is returned.
|
|
488
|
-
* Otherwise, a new PKCE code challenge is generated.
|
|
489
|
-
* @category Authentication
|
|
490
|
-
* @param loginRequest The original login request.
|
|
491
|
-
* @returns The PKCE code challenge and method.
|
|
492
|
-
*/
|
|
493
|
-
ensureCodeChallenge<T extends BaseLoginRequest>(loginRequest: T): Promise<T>;
|
|
494
|
-
/**
|
|
495
|
-
* Signs out locally.
|
|
496
|
-
* Does not invalidate tokens with the server.
|
|
497
|
-
* @category Authentication
|
|
498
|
-
*/
|
|
499
|
-
signOut(): Promise<void>;
|
|
500
|
-
/**
|
|
501
|
-
* Tries to sign in the user.
|
|
502
|
-
* Returns true if the user is signed in.
|
|
503
|
-
* This may result in navigating away to the sign in page.
|
|
504
|
-
* @category Authentication
|
|
505
|
-
* @param loginParams Optional login parameters.
|
|
506
|
-
*/
|
|
507
|
-
signInWithRedirect(loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource | void>;
|
|
508
|
-
/**
|
|
509
|
-
* Tries to sign out the user.
|
|
510
|
-
* See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
|
|
511
|
-
* @category Authentication
|
|
512
|
-
*/
|
|
513
|
-
signOutWithRedirect(): void;
|
|
514
|
-
/**
|
|
515
|
-
* Initiates sign in with an external identity provider.
|
|
516
|
-
* @param authorizeUrl The external authorization URL.
|
|
517
|
-
* @param clientId The external client ID.
|
|
518
|
-
* @param redirectUri The external identity provider redirect URI.
|
|
519
|
-
* @param baseLogin The Medplum login request.
|
|
520
|
-
* @category Authentication
|
|
521
|
-
*/
|
|
522
|
-
signInWithExternalAuth(authorizeUrl: string, clientId: string, redirectUri: string, baseLogin: BaseLoginRequest): Promise<void>;
|
|
523
|
-
/**
|
|
524
|
-
* Builds the external identity provider redirect URI.
|
|
525
|
-
* @param authorizeUrl The external authorization URL.
|
|
526
|
-
* @param clientId The external client ID.
|
|
527
|
-
* @param redirectUri The external identity provider redirect URI.
|
|
528
|
-
* @param loginRequest The Medplum login request.
|
|
529
|
-
* @returns The external identity provider redirect URI.
|
|
530
|
-
* @category Authentication
|
|
531
|
-
*/
|
|
532
|
-
getExternalAuthRedirectUri(authorizeUrl: string, clientId: string, redirectUri: string, loginRequest: BaseLoginRequest): string;
|
|
533
|
-
/**
|
|
534
|
-
* Builds a FHIR URL from a collection of URL path components.
|
|
535
|
-
* For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
|
|
536
|
-
* @category HTTP
|
|
537
|
-
* @param path The path component of the URL.
|
|
538
|
-
* @returns The well-formed FHIR URL.
|
|
539
|
-
*/
|
|
540
|
-
fhirUrl(...path: string[]): URL;
|
|
541
|
-
/**
|
|
542
|
-
* Builds a FHIR search URL from a search query or structured query object.
|
|
543
|
-
* @category HTTP
|
|
544
|
-
* @category Search
|
|
545
|
-
* @param query The FHIR search query or structured query object.
|
|
546
|
-
* @returns The well-formed FHIR URL.
|
|
547
|
-
*/
|
|
548
|
-
fhirSearchUrl(resourceType: ResourceType, query: URLSearchParams | string | undefined): URL;
|
|
549
|
-
/**
|
|
550
|
-
* Sends a FHIR search request.
|
|
551
|
-
*
|
|
552
|
-
* Example using a FHIR search string:
|
|
553
|
-
*
|
|
554
|
-
* ```typescript
|
|
555
|
-
* const bundle = await client.search('Patient', 'name=Alice');
|
|
556
|
-
* console.log(bundle);
|
|
557
|
-
* ```
|
|
558
|
-
*
|
|
559
|
-
* The return value is a FHIR bundle:
|
|
560
|
-
*
|
|
561
|
-
* ```json
|
|
562
|
-
* {
|
|
563
|
-
* "resourceType": "Bundle",
|
|
564
|
-
* "type": "searchset",
|
|
565
|
-
* "entry": [
|
|
566
|
-
* {
|
|
567
|
-
* "resource": {
|
|
568
|
-
* "resourceType": "Patient",
|
|
569
|
-
* "name": [
|
|
570
|
-
* {
|
|
571
|
-
* "given": [
|
|
572
|
-
* "George"
|
|
573
|
-
* ],
|
|
574
|
-
* "family": "Washington"
|
|
575
|
-
* }
|
|
576
|
-
* ],
|
|
577
|
-
* }
|
|
578
|
-
* }
|
|
579
|
-
* ]
|
|
580
|
-
* }
|
|
581
|
-
* ```
|
|
582
|
-
*
|
|
583
|
-
* To query the count of a search, use the summary feature like so:
|
|
584
|
-
*
|
|
585
|
-
* ```typescript
|
|
586
|
-
* const patients = medplum.search('Patient', '_summary=count');
|
|
587
|
-
* ```
|
|
588
|
-
*
|
|
589
|
-
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
590
|
-
*
|
|
591
|
-
* @category Search
|
|
592
|
-
* @param resourceType The FHIR resource type.
|
|
593
|
-
* @param query The search query as either a string or a structured search object.
|
|
594
|
-
* @param options Optional fetch options.
|
|
595
|
-
* @returns Promise to the search result bundle.
|
|
596
|
-
*/
|
|
597
|
-
search<K extends ResourceType>(resourceType: K, query?: URLSearchParams | string, options?: RequestInit): ReadablePromise<Bundle<ExtractResource<K>>>;
|
|
598
|
-
/**
|
|
599
|
-
* Sends a FHIR search request for a single resource.
|
|
600
|
-
*
|
|
601
|
-
* This is a convenience method for `search()` that returns the first resource rather than a `Bundle`.
|
|
602
|
-
*
|
|
603
|
-
* Example using a FHIR search string:
|
|
604
|
-
*
|
|
605
|
-
* ```typescript
|
|
606
|
-
* const patient = await client.searchOne('Patient', 'identifier=123');
|
|
607
|
-
* console.log(patient);
|
|
608
|
-
* ```
|
|
609
|
-
*
|
|
610
|
-
* The return value is the resource, if available; otherwise, undefined.
|
|
611
|
-
*
|
|
612
|
-
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
613
|
-
*
|
|
614
|
-
* @category Search
|
|
615
|
-
* @param resourceType The FHIR resource type.
|
|
616
|
-
* @param query The search query as either a string or a structured search object.
|
|
617
|
-
* @param options Optional fetch options.
|
|
618
|
-
* @returns Promise to the search result bundle.
|
|
619
|
-
*/
|
|
620
|
-
searchOne<K extends ResourceType>(resourceType: K, query?: URLSearchParams | string, options?: RequestInit): ReadablePromise<ExtractResource<K> | undefined>;
|
|
621
|
-
/**
|
|
622
|
-
* Sends a FHIR search request for an array of resources.
|
|
623
|
-
*
|
|
624
|
-
* This is a convenience method for `search()` that returns the resources as an array rather than a `Bundle`.
|
|
625
|
-
*
|
|
626
|
-
* Example using a FHIR search string:
|
|
627
|
-
*
|
|
628
|
-
* ```typescript
|
|
629
|
-
* const patients = await client.searchResources('Patient', 'name=Alice');
|
|
630
|
-
* console.log(patients);
|
|
631
|
-
* ```
|
|
632
|
-
*
|
|
633
|
-
* The return value is an array of resources.
|
|
634
|
-
*
|
|
635
|
-
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
636
|
-
*
|
|
637
|
-
* @category Search
|
|
638
|
-
* @param resourceType The FHIR resource type.
|
|
639
|
-
* @param query The search query as either a string or a structured search object.
|
|
640
|
-
* @param options Optional fetch options.
|
|
641
|
-
* @returns Promise to the search result bundle.
|
|
642
|
-
*/
|
|
643
|
-
searchResources<K extends ResourceType>(resourceType: K, query?: URLSearchParams | string, options?: RequestInit): ReadablePromise<ExtractResource<K>[]>;
|
|
644
|
-
/**
|
|
645
|
-
* Searches a ValueSet resource using the "expand" operation.
|
|
646
|
-
* See: https://www.hl7.org/fhir/operation-valueset-expand.html
|
|
647
|
-
*
|
|
648
|
-
* @category Search
|
|
649
|
-
* @param system The ValueSet system url.
|
|
650
|
-
* @param filter The search string.
|
|
651
|
-
* @param options Optional fetch options.
|
|
652
|
-
* @returns Promise to expanded ValueSet.
|
|
653
|
-
*/
|
|
654
|
-
searchValueSet(system: string, filter: string, options?: RequestInit): ReadablePromise<ValueSet>;
|
|
655
|
-
/**
|
|
656
|
-
* Returns a cached resource if it is available.
|
|
657
|
-
* @category Caching
|
|
658
|
-
* @param resourceType The FHIR resource type.
|
|
659
|
-
* @param id The FHIR resource ID.
|
|
660
|
-
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
661
|
-
*/
|
|
662
|
-
getCached<K extends ResourceType>(resourceType: K, id: string): ExtractResource<K> | undefined;
|
|
663
|
-
/**
|
|
664
|
-
* Returns a cached resource if it is available.
|
|
665
|
-
* @category Caching
|
|
666
|
-
* @param resourceType The FHIR resource type.
|
|
667
|
-
* @param id The FHIR resource ID.
|
|
668
|
-
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
669
|
-
*/
|
|
670
|
-
getCachedReference<T extends Resource>(reference: Reference<T>): T | undefined;
|
|
671
|
-
/**
|
|
672
|
-
* Reads a resource by resource type and ID.
|
|
673
|
-
*
|
|
674
|
-
* Example:
|
|
675
|
-
*
|
|
676
|
-
* ```typescript
|
|
677
|
-
* const patient = await medplum.readResource('Patient', '123');
|
|
678
|
-
* console.log(patient);
|
|
679
|
-
* ```
|
|
680
|
-
*
|
|
681
|
-
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
682
|
-
*
|
|
683
|
-
* @category Read
|
|
684
|
-
* @param resourceType The FHIR resource type.
|
|
685
|
-
* @param id The resource ID.
|
|
686
|
-
* @param options Optional fetch options.
|
|
687
|
-
* @returns The resource if available; undefined otherwise.
|
|
688
|
-
*/
|
|
689
|
-
readResource<K extends ResourceType>(resourceType: K, id: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
|
|
690
|
-
/**
|
|
691
|
-
* Reads a resource by `Reference`.
|
|
692
|
-
*
|
|
693
|
-
* This is a convenience method for `readResource()` that accepts a `Reference` object.
|
|
694
|
-
*
|
|
695
|
-
* Example:
|
|
696
|
-
*
|
|
697
|
-
* ```typescript
|
|
698
|
-
* const serviceRequest = await medplum.readResource('ServiceRequest', '123');
|
|
699
|
-
* const patient = await medplum.readReference(serviceRequest.subject);
|
|
700
|
-
* console.log(patient);
|
|
701
|
-
* ```
|
|
702
|
-
*
|
|
703
|
-
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
704
|
-
*
|
|
705
|
-
* @category Read
|
|
706
|
-
* @param reference The FHIR reference object.
|
|
707
|
-
* @param options Optional fetch options.
|
|
708
|
-
* @returns The resource if available; undefined otherwise.
|
|
709
|
-
*/
|
|
710
|
-
readReference<T extends Resource>(reference: Reference<T>, options?: RequestInit): ReadablePromise<T>;
|
|
711
|
-
/**
|
|
712
|
-
* Returns a cached schema for a resource type.
|
|
713
|
-
* If the schema is not cached, returns undefined.
|
|
714
|
-
* It is assumed that a client will call requestSchema before using this method.
|
|
715
|
-
* @category Schema
|
|
716
|
-
* @returns The schema if immediately available, undefined otherwise.
|
|
717
|
-
* @deprecated Use globalSchema instead.
|
|
718
|
-
*/
|
|
719
|
-
getSchema(): IndexedStructureDefinition;
|
|
720
|
-
/**
|
|
721
|
-
* Requests the schema for a resource type.
|
|
722
|
-
* If the schema is already cached, the promise is resolved immediately.
|
|
723
|
-
* @category Schema
|
|
724
|
-
* @param resourceType The FHIR resource type.
|
|
725
|
-
* @returns Promise to a schema with the requested resource type.
|
|
726
|
-
*/
|
|
727
|
-
requestSchema(resourceType: string): Promise<IndexedStructureDefinition>;
|
|
728
|
-
/**
|
|
729
|
-
* Reads resource history by resource type and ID.
|
|
730
|
-
*
|
|
731
|
-
* The return value is a bundle of all versions of the resource.
|
|
732
|
-
*
|
|
733
|
-
* Example:
|
|
734
|
-
*
|
|
735
|
-
* ```typescript
|
|
736
|
-
* const history = await medplum.readHistory('Patient', '123');
|
|
737
|
-
* console.log(history);
|
|
738
|
-
* ```
|
|
739
|
-
*
|
|
740
|
-
* See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
|
|
741
|
-
*
|
|
742
|
-
* @category Read
|
|
743
|
-
* @param resourceType The FHIR resource type.
|
|
744
|
-
* @param id The resource ID.
|
|
745
|
-
* @param options Optional fetch options.
|
|
746
|
-
* @returns Promise to the resource history.
|
|
747
|
-
*/
|
|
748
|
-
readHistory<K extends ResourceType>(resourceType: K, id: string, options?: RequestInit): ReadablePromise<Bundle<ExtractResource<K>>>;
|
|
749
|
-
/**
|
|
750
|
-
* Reads a specific version of a resource by resource type, ID, and version ID.
|
|
751
|
-
*
|
|
752
|
-
* Example:
|
|
753
|
-
*
|
|
754
|
-
* ```typescript
|
|
755
|
-
* const version = await medplum.readVersion('Patient', '123', '456');
|
|
756
|
-
* console.log(version);
|
|
757
|
-
* ```
|
|
758
|
-
*
|
|
759
|
-
* See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
|
|
760
|
-
*
|
|
761
|
-
* @category Read
|
|
762
|
-
* @param resourceType The FHIR resource type.
|
|
763
|
-
* @param id The resource ID.
|
|
764
|
-
* @param vid The version ID.
|
|
765
|
-
* @param options Optional fetch options.
|
|
766
|
-
* @returns The resource if available; undefined otherwise.
|
|
767
|
-
*/
|
|
768
|
-
readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
|
|
769
|
-
/**
|
|
770
|
-
* Executes the Patient "everything" operation for a patient.
|
|
771
|
-
*
|
|
772
|
-
* Example:
|
|
773
|
-
*
|
|
774
|
-
* ```typescript
|
|
775
|
-
* const bundle = await medplum.readPatientEverything('123');
|
|
776
|
-
* console.log(bundle);
|
|
777
|
-
* ```
|
|
778
|
-
*
|
|
779
|
-
* See the FHIR "patient-everything" operation for full details: https://hl7.org/fhir/operation-patient-everything.html
|
|
780
|
-
*
|
|
781
|
-
* @category Read
|
|
782
|
-
* @param id The Patient Id
|
|
783
|
-
* @param options Optional fetch options.
|
|
784
|
-
* @returns A Bundle of all Resources related to the Patient
|
|
785
|
-
*/
|
|
786
|
-
readPatientEverything(id: string, options?: RequestInit): ReadablePromise<Bundle>;
|
|
787
|
-
/**
|
|
788
|
-
* Creates a new FHIR resource.
|
|
789
|
-
*
|
|
790
|
-
* The return value is the newly created resource, including the ID and meta.
|
|
791
|
-
*
|
|
792
|
-
* Example:
|
|
793
|
-
*
|
|
794
|
-
* ```typescript
|
|
795
|
-
* const result = await medplum.createResource({
|
|
796
|
-
* resourceType: 'Patient',
|
|
797
|
-
* name: [{
|
|
798
|
-
* family: 'Smith',
|
|
799
|
-
* given: ['John']
|
|
800
|
-
* }]
|
|
801
|
-
* });
|
|
802
|
-
* console.log(result.id);
|
|
803
|
-
* ```
|
|
804
|
-
*
|
|
805
|
-
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
806
|
-
*
|
|
807
|
-
* @category Create
|
|
808
|
-
* @param resource The FHIR resource to create.
|
|
809
|
-
* @returns The result of the create operation.
|
|
810
|
-
*/
|
|
811
|
-
createResource<T extends Resource>(resource: T): Promise<T>;
|
|
812
|
-
/**
|
|
813
|
-
* Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.
|
|
814
|
-
*
|
|
815
|
-
* The return value is the existing resource or the newly created resource, including the ID and meta.
|
|
816
|
-
*
|
|
817
|
-
* Example:
|
|
818
|
-
*
|
|
819
|
-
* ```typescript
|
|
820
|
-
* const result = await medplum.createResourceIfNoneExist(
|
|
821
|
-
* {
|
|
822
|
-
* resourceType: 'Patient',
|
|
823
|
-
* identifier: [{
|
|
824
|
-
* system: 'http://example.com/mrn',
|
|
825
|
-
* value: '123'
|
|
826
|
-
* }]
|
|
827
|
-
* name: [{
|
|
828
|
-
* family: 'Smith',
|
|
829
|
-
* given: ['John']
|
|
830
|
-
* }]
|
|
831
|
-
* },
|
|
832
|
-
* 'identifier=123'
|
|
833
|
-
* );
|
|
834
|
-
* console.log(result.id);
|
|
835
|
-
* ```
|
|
836
|
-
*
|
|
837
|
-
* This method is syntactic sugar for:
|
|
838
|
-
*
|
|
839
|
-
* ```typescript
|
|
840
|
-
* return searchOne(resourceType, query) ?? createResource(resource);
|
|
841
|
-
* ```
|
|
842
|
-
*
|
|
843
|
-
* The query parameter only contains the search parameters (what would be in the URL following the "?").
|
|
844
|
-
*
|
|
845
|
-
* See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
|
|
846
|
-
*
|
|
847
|
-
* @category Create
|
|
848
|
-
* @param resource The FHIR resource to create.
|
|
849
|
-
* @param query The search query for an equivalent resource (should not include resource type or "?").
|
|
850
|
-
* @returns The result of the create operation.
|
|
851
|
-
*/
|
|
852
|
-
createResourceIfNoneExist<T extends Resource>(resource: T, query: string): Promise<T>;
|
|
853
|
-
/**
|
|
854
|
-
* Creates a FHIR `Binary` resource with the provided data content.
|
|
855
|
-
*
|
|
856
|
-
* The return value is the newly created resource, including the ID and meta.
|
|
857
|
-
*
|
|
858
|
-
* The `data` parameter can be a string or a `File` object.
|
|
859
|
-
*
|
|
860
|
-
* A `File` object often comes from a `<input type="file">` element.
|
|
861
|
-
*
|
|
862
|
-
* Example:
|
|
863
|
-
*
|
|
864
|
-
* ```typescript
|
|
865
|
-
* const result = await medplum.createBinary(myFile, 'test.jpg', 'image/jpeg');
|
|
866
|
-
* console.log(result.id);
|
|
867
|
-
* ```
|
|
868
|
-
*
|
|
869
|
-
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
870
|
-
*
|
|
871
|
-
* @category Create
|
|
872
|
-
* @param data The binary data to upload.
|
|
873
|
-
* @param filename Optional filename for the binary.
|
|
874
|
-
* @param contentType Content type for the binary.
|
|
875
|
-
* @returns The result of the create operation.
|
|
876
|
-
*/
|
|
877
|
-
createBinary(data: string | File | Blob | Uint8Array, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void): Promise<Binary>;
|
|
878
|
-
uploadwithProgress(url: URL, data: string | File | Blob | Uint8Array, contentType: string, onProgress: (e: ProgressEvent) => void): Promise<any>;
|
|
879
|
-
/**
|
|
880
|
-
* Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
|
|
881
|
-
*
|
|
882
|
-
* The return value is the newly created resource, including the ID and meta.
|
|
883
|
-
*
|
|
884
|
-
* The `docDefinition` parameter is a pdfmake document definition.
|
|
885
|
-
*
|
|
886
|
-
* Example:
|
|
887
|
-
*
|
|
888
|
-
* ```typescript
|
|
889
|
-
* const result = await medplum.createPdf({
|
|
890
|
-
* content: ['Hello world']
|
|
891
|
-
* });
|
|
892
|
-
* console.log(result.id);
|
|
893
|
-
* ```
|
|
894
|
-
*
|
|
895
|
-
* See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
|
|
896
|
-
*
|
|
897
|
-
* @category Media
|
|
898
|
-
* @param docDefinition The PDF document definition.
|
|
899
|
-
* @returns The result of the create operation.
|
|
900
|
-
*/
|
|
901
|
-
createPdf(docDefinition: TDocumentDefinitions, filename?: string, tableLayouts?: {
|
|
902
|
-
[name: string]: CustomTableLayout;
|
|
903
|
-
}, fonts?: TFontDictionary): Promise<Binary>;
|
|
904
|
-
/**
|
|
905
|
-
* Creates a FHIR `Communication` resource with the provided data content.
|
|
906
|
-
*
|
|
907
|
-
* This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.
|
|
908
|
-
*
|
|
909
|
-
* @category Create
|
|
910
|
-
* @param resource The FHIR resource to comment on.
|
|
911
|
-
* @param text The text of the comment.
|
|
912
|
-
* @returns The result of the create operation.
|
|
913
|
-
*/
|
|
914
|
-
createComment(resource: Resource, text: string): Promise<Communication>;
|
|
915
|
-
/**
|
|
916
|
-
* Updates a FHIR resource.
|
|
917
|
-
*
|
|
918
|
-
* The return value is the updated resource, including the ID and meta.
|
|
919
|
-
*
|
|
920
|
-
* Example:
|
|
921
|
-
*
|
|
922
|
-
* ```typescript
|
|
923
|
-
* const result = await medplum.updateResource({
|
|
924
|
-
* resourceType: 'Patient',
|
|
925
|
-
* id: '123',
|
|
926
|
-
* name: [{
|
|
927
|
-
* family: 'Smith',
|
|
928
|
-
* given: ['John']
|
|
929
|
-
* }]
|
|
930
|
-
* });
|
|
931
|
-
* console.log(result.meta.versionId);
|
|
932
|
-
* ```
|
|
933
|
-
*
|
|
934
|
-
* See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
|
|
935
|
-
*
|
|
936
|
-
* @category Write
|
|
937
|
-
* @param resource The FHIR resource to update.
|
|
938
|
-
* @returns The result of the update operation.
|
|
939
|
-
*/
|
|
940
|
-
updateResource<T extends Resource>(resource: T): Promise<T>;
|
|
941
|
-
/**
|
|
942
|
-
* Updates a FHIR resource using JSONPatch operations.
|
|
943
|
-
*
|
|
944
|
-
* The return value is the updated resource, including the ID and meta.
|
|
945
|
-
*
|
|
946
|
-
* Example:
|
|
947
|
-
*
|
|
948
|
-
* ```typescript
|
|
949
|
-
* const result = await medplum.patchResource('Patient', '123', [
|
|
950
|
-
* {op: 'replace', path: '/name/0/family', value: 'Smith'},
|
|
951
|
-
* ]);
|
|
952
|
-
* console.log(result.meta.versionId);
|
|
953
|
-
* ```
|
|
954
|
-
*
|
|
955
|
-
* See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#patch
|
|
956
|
-
*
|
|
957
|
-
* See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
|
|
958
|
-
*
|
|
959
|
-
* @category Write
|
|
960
|
-
* @param resourceType The FHIR resource type.
|
|
961
|
-
* @param id The resource ID.
|
|
962
|
-
* @param operations The JSONPatch operations.
|
|
963
|
-
* @returns The result of the patch operations.
|
|
964
|
-
*/
|
|
965
|
-
patchResource<K extends ResourceType>(resourceType: K, id: string, operations: PatchOperation[]): Promise<ExtractResource<K>>;
|
|
966
|
-
/**
|
|
967
|
-
* Deletes a FHIR resource by resource type and ID.
|
|
968
|
-
*
|
|
969
|
-
* Example:
|
|
970
|
-
*
|
|
971
|
-
* ```typescript
|
|
972
|
-
* await medplum.deleteResource('Patient', '123');
|
|
973
|
-
* ```
|
|
974
|
-
*
|
|
975
|
-
* See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
|
|
976
|
-
*
|
|
977
|
-
* @category Delete
|
|
978
|
-
* @param resourceType The FHIR resource type.
|
|
979
|
-
* @param id The resource ID.
|
|
980
|
-
* @returns The result of the delete operation.
|
|
981
|
-
*/
|
|
982
|
-
deleteResource(resourceType: ResourceType, id: string): Promise<any>;
|
|
983
|
-
/**
|
|
984
|
-
* Executes the validate operation with the provided resource.
|
|
985
|
-
*
|
|
986
|
-
* Example:
|
|
987
|
-
*
|
|
988
|
-
* ```typescript
|
|
989
|
-
* const result = await medplum.validateResource({
|
|
990
|
-
* resourceType: 'Patient',
|
|
991
|
-
* name: [{ given: ['Alice'], family: 'Smith' }],
|
|
992
|
-
* });
|
|
993
|
-
* ```
|
|
994
|
-
*
|
|
995
|
-
* See the FHIR "$validate" operation for full details: https://www.hl7.org/fhir/resource-operation-validate.html
|
|
996
|
-
*
|
|
997
|
-
* @param resource The FHIR resource.
|
|
998
|
-
* @returns The validate operation outcome.
|
|
999
|
-
*/
|
|
1000
|
-
validateResource<T extends Resource>(resource: T): Promise<OperationOutcome>;
|
|
1001
|
-
/**
|
|
1002
|
-
* Executes a batch or transaction of FHIR operations.
|
|
1003
|
-
*
|
|
1004
|
-
* Example:
|
|
1005
|
-
*
|
|
1006
|
-
* ```typescript
|
|
1007
|
-
* await medplum.executeBatch({
|
|
1008
|
-
* "resourceType": "Bundle",
|
|
1009
|
-
* "type": "transaction",
|
|
1010
|
-
* "entry": [
|
|
1011
|
-
* {
|
|
1012
|
-
* "fullUrl": "urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a",
|
|
1013
|
-
* "resource": {
|
|
1014
|
-
* "resourceType": "Patient",
|
|
1015
|
-
* "name": [{ "use": "official", "given": ["Alice"], "family": "Smith" }],
|
|
1016
|
-
* "gender": "female",
|
|
1017
|
-
* "birthDate": "1974-12-25"
|
|
1018
|
-
* },
|
|
1019
|
-
* "request": {
|
|
1020
|
-
* "method": "POST",
|
|
1021
|
-
* "url": "Patient"
|
|
1022
|
-
* }
|
|
1023
|
-
* },
|
|
1024
|
-
* {
|
|
1025
|
-
* "fullUrl": "urn:uuid:88f151c0-a954-468a-88bd-5ae15c08e059",
|
|
1026
|
-
* "resource": {
|
|
1027
|
-
* "resourceType": "Patient",
|
|
1028
|
-
* "identifier": [{ "system": "http:/example.org/fhir/ids", "value": "234234" }],
|
|
1029
|
-
* "name": [{ "use": "official", "given": ["Bob"], "family": "Jones" }],
|
|
1030
|
-
* "gender": "male",
|
|
1031
|
-
* "birthDate": "1974-12-25"
|
|
1032
|
-
* },
|
|
1033
|
-
* "request": {
|
|
1034
|
-
* "method": "POST",
|
|
1035
|
-
* "url": "Patient",
|
|
1036
|
-
* "ifNoneExist": "identifier=http:/example.org/fhir/ids|234234"
|
|
1037
|
-
* }
|
|
1038
|
-
* }
|
|
1039
|
-
* ]
|
|
1040
|
-
* });
|
|
1041
|
-
* ```
|
|
1042
|
-
*
|
|
1043
|
-
* See The FHIR "batch/transaction" section for full details: https://hl7.org/fhir/http.html#transaction
|
|
1044
|
-
* @category Batch
|
|
1045
|
-
* @param bundle The FHIR batch/transaction bundle.
|
|
1046
|
-
* @returns The FHIR batch/transaction response bundle.
|
|
1047
|
-
*/
|
|
1048
|
-
executeBatch(bundle: Bundle): Promise<Bundle>;
|
|
1049
|
-
/**
|
|
1050
|
-
* Sends an email using the Medplum Email API.
|
|
1051
|
-
*
|
|
1052
|
-
* Builds the email using nodemailer MailComposer.
|
|
1053
|
-
*
|
|
1054
|
-
* Examples:
|
|
1055
|
-
*
|
|
1056
|
-
* Send a simple text email:
|
|
1057
|
-
*
|
|
1058
|
-
* ```typescript
|
|
1059
|
-
* await medplum.sendEmail({
|
|
1060
|
-
* to: 'alice@example.com',
|
|
1061
|
-
* cc: 'bob@example.com',
|
|
1062
|
-
* subject: 'Hello',
|
|
1063
|
-
* text: 'Hello Alice',
|
|
1064
|
-
* });
|
|
1065
|
-
* ```
|
|
1066
|
-
*
|
|
1067
|
-
* Send an email with a `Binary` attachment:
|
|
1068
|
-
*
|
|
1069
|
-
* ```typescript
|
|
1070
|
-
* await medplum.sendEmail({
|
|
1071
|
-
* to: 'alice@example.com',
|
|
1072
|
-
* subject: 'Email with attachment',
|
|
1073
|
-
* text: 'See the attached report',
|
|
1074
|
-
* attachments: [{
|
|
1075
|
-
* filename: 'report.pdf',
|
|
1076
|
-
* path: "Binary/" + binary.id
|
|
1077
|
-
* }]
|
|
1078
|
-
* });
|
|
1079
|
-
* ```
|
|
1080
|
-
*
|
|
1081
|
-
* See options here: https://nodemailer.com/extras/mailcomposer/
|
|
1082
|
-
* @category Media
|
|
1083
|
-
* @param options The MailComposer options.
|
|
1084
|
-
* @returns Promise to the operation outcome.
|
|
1085
|
-
*/
|
|
1086
|
-
sendEmail(email: MailOptions): Promise<OperationOutcome>;
|
|
1087
|
-
/**
|
|
1088
|
-
* Executes a GraphQL query.
|
|
1089
|
-
*
|
|
1090
|
-
* Example:
|
|
1091
|
-
*
|
|
1092
|
-
* ```typescript
|
|
1093
|
-
* const result = await medplum.graphql(`{
|
|
1094
|
-
* Patient(id: "123") {
|
|
1095
|
-
* resourceType
|
|
1096
|
-
* id
|
|
1097
|
-
* name {
|
|
1098
|
-
* given
|
|
1099
|
-
* family
|
|
1100
|
-
* }
|
|
1101
|
-
* }
|
|
1102
|
-
* }`);
|
|
1103
|
-
* ```
|
|
1104
|
-
*
|
|
1105
|
-
* Advanced queries such as named operations and variable substitution are supported:
|
|
1106
|
-
*
|
|
1107
|
-
* ```typescript
|
|
1108
|
-
* const result = await medplum.graphql(
|
|
1109
|
-
* `query GetPatientById($patientId: ID!) {
|
|
1110
|
-
* Patient(id: $patientId) {
|
|
1111
|
-
* resourceType
|
|
1112
|
-
* id
|
|
1113
|
-
* name {
|
|
1114
|
-
* given
|
|
1115
|
-
* family
|
|
1116
|
-
* }
|
|
1117
|
-
* }
|
|
1118
|
-
* }`,
|
|
1119
|
-
* 'GetPatientById',
|
|
1120
|
-
* { patientId: '123' }
|
|
1121
|
-
* );
|
|
1122
|
-
* ```
|
|
1123
|
-
*
|
|
1124
|
-
* See the GraphQL documentation for more details: https://graphql.org/learn/
|
|
1125
|
-
*
|
|
1126
|
-
* See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
|
|
1127
|
-
*
|
|
1128
|
-
* @category Read
|
|
1129
|
-
* @param query The GraphQL query.
|
|
1130
|
-
* @param operationName Optional GraphQL operation name.
|
|
1131
|
-
* @param variables Optional GraphQL variables.
|
|
1132
|
-
* @param options Optional fetch options.
|
|
1133
|
-
* @returns The GraphQL result.
|
|
1134
|
-
*/
|
|
1135
|
-
graphql(query: string, operationName?: string | null, variables?: any, options?: RequestInit): Promise<any>;
|
|
1136
|
-
/**
|
|
1137
|
-
*
|
|
1138
|
-
* Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource
|
|
1139
|
-
* according to a graph definition
|
|
1140
|
-
|
|
1141
|
-
* @category Read
|
|
1142
|
-
* @param resourceType The FHIR resource type.
|
|
1143
|
-
* @param id The resource ID.
|
|
1144
|
-
* @param graphName `name` parameter of the GraphDefinition
|
|
1145
|
-
* @returns A Bundle
|
|
1146
|
-
*/
|
|
1147
|
-
readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string): ReadablePromise<Bundle<Resource>>;
|
|
1148
|
-
/**
|
|
1149
|
-
* @category Authentication
|
|
1150
|
-
* @returns The Login State
|
|
1151
|
-
*/
|
|
1152
|
-
getActiveLogin(): LoginState | undefined;
|
|
1153
|
-
/**
|
|
1154
|
-
* @category Authentication
|
|
1155
|
-
*/
|
|
1156
|
-
setActiveLogin(login: LoginState): Promise<void>;
|
|
1157
|
-
/**
|
|
1158
|
-
* @category Authentication
|
|
1159
|
-
*/
|
|
1160
|
-
getAccessToken(): string | undefined;
|
|
1161
|
-
/**
|
|
1162
|
-
* @category Authentication
|
|
1163
|
-
*/
|
|
1164
|
-
setAccessToken(accessToken: string): void;
|
|
1165
|
-
/**
|
|
1166
|
-
* @category Authentication
|
|
1167
|
-
*/
|
|
1168
|
-
getLogins(): LoginState[];
|
|
1169
|
-
/**
|
|
1170
|
-
* @category Authentication
|
|
1171
|
-
*/
|
|
1172
|
-
isLoading(): boolean;
|
|
1173
|
-
/**
|
|
1174
|
-
* @category User Profile
|
|
1175
|
-
*/
|
|
1176
|
-
getProfile(): ProfileResource | undefined;
|
|
1177
|
-
/**
|
|
1178
|
-
* @category User Profile
|
|
1179
|
-
*/
|
|
1180
|
-
getProfileAsync(): Promise<ProfileResource | undefined>;
|
|
1181
|
-
/**
|
|
1182
|
-
* @category User Profile
|
|
1183
|
-
*/
|
|
1184
|
-
getUserConfiguration(): UserConfiguration | undefined;
|
|
1185
|
-
/**
|
|
1186
|
-
* Downloads the URL as a blob.
|
|
1187
|
-
*
|
|
1188
|
-
* @category Read
|
|
1189
|
-
* @param url The URL to request.
|
|
1190
|
-
* @returns Promise to the response body as a blob.
|
|
1191
|
-
*/
|
|
1192
|
-
download(url: URL | string, options?: RequestInit): Promise<Blob>;
|
|
1193
|
-
/**
|
|
1194
|
-
* Starts a new PKCE flow.
|
|
1195
|
-
* These PKCE values are stateful, and must survive redirects and page refreshes.
|
|
1196
|
-
* @category Authentication
|
|
1197
|
-
*/
|
|
1198
|
-
startPkce(): Promise<{
|
|
1199
|
-
codeChallengeMethod: string;
|
|
1200
|
-
codeChallenge: string;
|
|
1201
|
-
}>;
|
|
1202
|
-
/**
|
|
1203
|
-
* Processes an OAuth authorization code.
|
|
1204
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
|
|
1205
|
-
* @param code The authorization code received by URL parameter.
|
|
1206
|
-
* @category Authentication
|
|
1207
|
-
*/
|
|
1208
|
-
processCode(code: string): Promise<ProfileResource>;
|
|
1209
|
-
/**
|
|
1210
|
-
* Starts a new OAuth2 client credentials flow.
|
|
1211
|
-
* See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
|
|
1212
|
-
* @category Authentication
|
|
1213
|
-
* @param clientId The client ID.
|
|
1214
|
-
* @param clientSecret The client secret.
|
|
1215
|
-
* @returns Promise that resolves to the client profile.
|
|
1216
|
-
*/
|
|
1217
|
-
startClientLogin(clientId: string, clientSecret: string): Promise<ProfileResource>;
|
|
1218
|
-
}
|