@medplum/core 0.9.6 → 0.9.9

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.
@@ -0,0 +1 @@
1
+ {"type": "module"}
@@ -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
  }
@@ -1,58 +1,77 @@
1
- import { Binary, Bundle, OperationOutcome, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
2
- import type { Operation } from 'fast-json-patch';
3
- import type Mail from 'nodemailer/lib/mailer';
1
+ import { Binary, Bundle, Communication, OperationOutcome, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
2
+ /** @ts-ignore */
3
+ import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
4
4
  import { EventTarget } from './eventtarget';
5
5
  import { Hl7Message } from './hl7';
6
6
  import { ReadablePromise } from './readablepromise';
7
7
  import { SearchRequest } from './search';
8
8
  import { IndexedStructureDefinition } from './types';
9
9
  import { ProfileResource } from './utils';
10
+ /**
11
+ * The MedplumClientOptions interface defines configuration options for MedplumClient.
12
+ *
13
+ * All configuration settings are optional.
14
+ */
10
15
  export interface MedplumClientOptions {
11
- /**
12
- * The client ID.
13
- * Optional. Default is to defer to the server to use the default client.
14
- * Use this to use a specific client for SMART-on-FHIR.
15
- */
16
- clientId?: string;
17
16
  /**
18
17
  * Base server URL.
19
- * Optional. Default value is "https://api.medplum.com/".
18
+ *
19
+ * Default value is "https://api.medplum.com/".
20
+ *
20
21
  * Use this to point to a custom Medplum deployment.
21
22
  */
22
23
  baseUrl?: string;
23
24
  /**
24
25
  * OAuth2 authorize URL.
25
- * Optional. Default value is baseUrl + "/oauth2/authorize".
26
+ *
27
+ * Default value is baseUrl + "/oauth2/authorize".
28
+ *
26
29
  * Use this if you want to use a separate OAuth server.
27
30
  */
28
31
  authorizeUrl?: string;
29
32
  /**
30
33
  * OAuth2 token URL.
31
- * Optional. Default value is baseUrl + "/oauth2/token".
34
+ *
35
+ * Default value is baseUrl + "/oauth2/token".
36
+ *
32
37
  * Use this if you want to use a separate OAuth server.
33
38
  */
34
39
  tokenUrl?: string;
35
40
  /**
36
41
  * OAuth2 logout URL.
37
- * Optional. Default value is baseUrl + "/oauth2/logout".
42
+ *
43
+ * Default value is baseUrl + "/oauth2/logout".
44
+ *
38
45
  * Use this if you want to use a separate OAuth server.
39
46
  */
40
47
  logoutUrl?: string;
48
+ /**
49
+ * The client ID.
50
+ *
51
+ * Client ID can be used for SMART-on-FHIR customization.
52
+ */
53
+ clientId?: string;
41
54
  /**
42
55
  * Number of resources to store in the cache.
43
- * Optional. Default value is 1000.
56
+ *
57
+ * Default value is 1000.
58
+ *
44
59
  * Consider using this for performance of displaying Patient or Practitioner resources.
45
60
  */
46
61
  resourceCacheSize?: number;
47
62
  /**
48
- * Optional fetch implementation.
49
- * Optional. Default is window.fetch.
63
+ * Fetch implementation.
64
+ *
65
+ * Default is window.fetch (if available).
66
+ *
50
67
  * For nodejs applications, consider the 'node-fetch' package.
51
68
  */
52
69
  fetch?: FetchLike;
53
70
  /**
54
- * Optional callback for when the client is unauthenticated.
71
+ * Callback for when the client is unauthenticated.
72
+ *
55
73
  * Default is do nothing.
74
+ *
56
75
  * For client side applications, consider redirecting to a sign in page.
57
76
  */
58
77
  onUnauthenticated?: () => void;
@@ -111,6 +130,63 @@ export interface BotEvent {
111
130
  readonly contentType: string;
112
131
  readonly input: Resource | Hl7Message | string;
113
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
+ }
114
190
  /**
115
191
  * The MedplumClient class provides a client for the Medplum FHIR server.
116
192
  *
@@ -157,15 +233,31 @@ export interface BotEvent {
157
233
  * const bundle = await medplum.search('Patient?name=Alice');
158
234
  * console.log(bundle.total);
159
235
  * ```
160
- *
161
236
  */
162
237
  export declare class MedplumClient extends EventTarget {
163
238
  #private;
164
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;
165
247
  /**
166
248
  * Clears all auth state including local storage and session storage.
167
249
  */
168
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;
169
261
  /**
170
262
  * Makes an HTTP GET request to the specified URL.
171
263
  *
@@ -177,7 +269,7 @@ export declare class MedplumClient extends EventTarget {
177
269
  * @param options Optional fetch options.
178
270
  * @returns Promise to the response content.
179
271
  */
180
- get<T = any>(url: string, options?: RequestInit): ReadablePromise<T>;
272
+ get<T = any>(url: URL | string, options?: RequestInit): ReadablePromise<T>;
181
273
  /**
182
274
  * Makes an HTTP POST request to the specified URL.
183
275
  *
@@ -191,7 +283,7 @@ export declare class MedplumClient extends EventTarget {
191
283
  * @param options Optional fetch options.
192
284
  * @returns Promise to the response content.
193
285
  */
194
- post(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
286
+ post(url: URL | string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
195
287
  /**
196
288
  * Makes an HTTP PUT request to the specified URL.
197
289
  *
@@ -205,7 +297,7 @@ export declare class MedplumClient extends EventTarget {
205
297
  * @param options Optional fetch options.
206
298
  * @returns Promise to the response content.
207
299
  */
208
- put(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
300
+ put(url: URL | string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
209
301
  /**
210
302
  * Makes an HTTP PATCH request to the specified URL.
211
303
  *
@@ -218,7 +310,7 @@ export declare class MedplumClient extends EventTarget {
218
310
  * @param options Optional fetch options.
219
311
  * @returns Promise to the response content.
220
312
  */
221
- patch(url: string, operations: Operation[], options?: RequestInit): Promise<any>;
313
+ patch(url: URL | string, operations: PatchOperation[], options?: RequestInit): Promise<any>;
222
314
  /**
223
315
  * Makes an HTTP DELETE request to the specified URL.
224
316
  *
@@ -230,7 +322,7 @@ export declare class MedplumClient extends EventTarget {
230
322
  * @param options Optional fetch options.
231
323
  * @returns Promise to the response content.
232
324
  */
233
- delete(url: string, options?: RequestInit): Promise<any>;
325
+ delete(url: URL | string, options?: RequestInit): Promise<any>;
234
326
  /**
235
327
  * Tries to register a new user.
236
328
  * @param request The registration request.
@@ -273,7 +365,13 @@ export declare class MedplumClient extends EventTarget {
273
365
  * @param path The path component of the URL.
274
366
  * @returns The well-formed FHIR URL.
275
367
  */
276
- fhirUrl(...path: string[]): 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;
277
375
  /**
278
376
  * Sends a FHIR search request.
279
377
  *
@@ -328,7 +426,7 @@ export declare class MedplumClient extends EventTarget {
328
426
  * @param query The search query as either a string or a structured search object.
329
427
  * @returns Promise to the search result bundle.
330
428
  */
331
- search<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<Bundle<T>>;
429
+ search<T extends Resource>(query: string | SearchRequest, options?: RequestInit): ReadablePromise<Bundle<T>>;
332
430
  /**
333
431
  * Sends a FHIR search request for a single resource.
334
432
  *
@@ -348,7 +446,7 @@ export declare class MedplumClient extends EventTarget {
348
446
  * @param query The search query as either a string or a structured search object.
349
447
  * @returns Promise to the search result bundle.
350
448
  */
351
- searchOne<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T | undefined>;
449
+ searchOne<T extends Resource>(query: string | SearchRequest, options?: RequestInit): ReadablePromise<T | undefined>;
352
450
  /**
353
451
  * Sends a FHIR search request for an array of resources.
354
452
  *
@@ -368,7 +466,7 @@ export declare class MedplumClient extends EventTarget {
368
466
  * @param query The search query as either a string or a structured search object.
369
467
  * @returns Promise to the search result bundle.
370
468
  */
371
- searchResources<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T[]>;
469
+ searchResources<T extends Resource>(query: string | SearchRequest, options?: RequestInit): ReadablePromise<T[]>;
372
470
  /**
373
471
  * Searches a ValueSet resource using the "expand" operation.
374
472
  * See: https://www.hl7.org/fhir/operation-valueset-expand.html
@@ -376,7 +474,7 @@ export declare class MedplumClient extends EventTarget {
376
474
  * @param filter The search string.
377
475
  * @returns Promise to expanded ValueSet.
378
476
  */
379
- searchValueSet(system: string, filter: string, options?: RequestInit): Promise<ValueSet>;
477
+ searchValueSet(system: string, filter: string, options?: RequestInit): ReadablePromise<ValueSet>;
380
478
  /**
381
479
  * Returns a cached resource if it is available.
382
480
  * @param resourceType The FHIR resource type.
@@ -408,25 +506,6 @@ export declare class MedplumClient extends EventTarget {
408
506
  * @returns The resource if available; undefined otherwise.
409
507
  */
410
508
  readResource<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
411
- /**
412
- * Reads a resource by resource type and ID using the in-memory resource cache.
413
- *
414
- * If the resource is not available in the cache, it will be read from the server.
415
- *
416
- * Example:
417
- *
418
- * ```typescript
419
- * const patient = await medplum.readCached('Patient', '123');
420
- * console.log(patient);
421
- * ```
422
- *
423
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
424
- *
425
- * @param resourceType The FHIR resource type.
426
- * @param id The resource ID.
427
- * @returns The resource if available; undefined otherwise.
428
- */
429
- readCached<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
430
509
  /**
431
510
  * Reads a resource by `Reference`.
432
511
  *
@@ -446,27 +525,6 @@ export declare class MedplumClient extends EventTarget {
446
525
  * @returns The resource if available; undefined otherwise.
447
526
  */
448
527
  readReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
449
- /**
450
- * Reads a resource by `Reference` using the in-memory resource cache.
451
- *
452
- * This is a convenience method for `readResource()` that accepts a `Reference` object.
453
- *
454
- * If the resource is not available in the cache, it will be read from the server.
455
- *
456
- * Example:
457
- *
458
- * ```typescript
459
- * const serviceRequest = await medplum.readResource('ServiceRequest', '123');
460
- * const patient = await medplum.readCachedReference(serviceRequest.subject);
461
- * console.log(patient);
462
- * ```
463
- *
464
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
465
- *
466
- * @param reference The FHIR reference object.
467
- * @returns The resource if available; undefined otherwise.
468
- */
469
- readCachedReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
470
528
  /**
471
529
  * Returns a cached schema for a resource type.
472
530
  * If the schema is not cached, returns undefined.
@@ -498,9 +556,9 @@ export declare class MedplumClient extends EventTarget {
498
556
  *
499
557
  * @param resourceType The FHIR resource type.
500
558
  * @param id The resource ID.
501
- * @returns The resource if available; undefined otherwise.
559
+ * @returns Promise to the resource history.
502
560
  */
503
- readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>;
561
+ readHistory<T extends Resource>(resourceType: string, id: string): ReadablePromise<Bundle<T>>;
504
562
  /**
505
563
  * Reads a specific version of a resource by resource type, ID, and version ID.
506
564
  *
@@ -517,8 +575,8 @@ export declare class MedplumClient extends EventTarget {
517
575
  * @param id The resource ID.
518
576
  * @returns The resource if available; undefined otherwise.
519
577
  */
520
- readVersion<T extends Resource>(resourceType: string, id: string, vid: string): Promise<T>;
521
- readPatientEverything(id: string): Promise<Bundle>;
578
+ readVersion<T extends Resource>(resourceType: string, id: string, vid: string): ReadablePromise<T>;
579
+ readPatientEverything(id: string): ReadablePromise<Bundle>;
522
580
  /**
523
581
  * Creates a new FHIR resource.
524
582
  *
@@ -605,7 +663,7 @@ export declare class MedplumClient extends EventTarget {
605
663
  * @param contentType Content type for the binary.
606
664
  * @returns The result of the create operation.
607
665
  */
608
- createBinary(data: string | File, filename: string | undefined, contentType: string): Promise<Binary>;
666
+ createBinary(data: string | File | Blob | Uint8Array, filename: string | undefined, contentType: string): Promise<Binary>;
609
667
  /**
610
668
  * Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
611
669
  *
@@ -624,10 +682,22 @@ export declare class MedplumClient extends EventTarget {
624
682
  *
625
683
  * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
626
684
  *
627
- * @param docDefinition The FHIR resource to create.
685
+ * @param docDefinition The PDF document definition.
628
686
  * @returns The result of the create operation.
629
687
  */
630
- createPdf(docDefinition: Record<string, unknown>, filename?: string): Promise<Binary>;
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.
698
+ * @returns The result of the create operation.
699
+ */
700
+ createComment(resource: Resource, text: string): Promise<Communication>;
631
701
  /**
632
702
  * Updates a FHIR resource.
633
703
  *
@@ -676,7 +746,7 @@ export declare class MedplumClient extends EventTarget {
676
746
  * @param operations The JSONPatch operations.
677
747
  * @returns The result of the patch operations.
678
748
  */
679
- patchResource<T extends Resource>(resourceType: string, id: string, operations: Operation[]): Promise<T>;
749
+ patchResource<T extends Resource>(resourceType: string, id: string, operations: PatchOperation[]): Promise<T>;
680
750
  /**
681
751
  * Deletes a FHIR resource by resource type and ID.
682
752
  *
@@ -730,10 +800,11 @@ export declare class MedplumClient extends EventTarget {
730
800
  * @param options The MailComposer options.
731
801
  * @returns Promise to the operation outcome.
732
802
  */
733
- sendEmail(email: Mail.Options): Promise<OperationOutcome>;
803
+ sendEmail(email: MailOptions): Promise<OperationOutcome>;
734
804
  graphql(query: string, options?: RequestInit): Promise<any>;
735
805
  getActiveLogin(): LoginState | undefined;
736
806
  setActiveLogin(login: LoginState): Promise<void>;
807
+ getAccessToken(): string | undefined;
737
808
  setAccessToken(accessToken: string): void;
738
809
  getLogins(): LoginState[];
739
810
  isLoading(): boolean;
@@ -745,12 +816,19 @@ export declare class MedplumClient extends EventTarget {
745
816
  * @param url The URL to request.
746
817
  * @returns Promise to the response body as a blob.
747
818
  */
748
- download(url: string, options?: RequestInit): Promise<Blob>;
819
+ download(url: URL | string, options?: RequestInit): Promise<Blob>;
749
820
  /**
750
821
  * Processes an OAuth authorization code.
751
822
  * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
752
823
  * @param code The authorization code received by URL parameter.
753
824
  */
754
825
  processCode(code: string): Promise<ProfileResource>;
755
- clientCredentials(clientId: string, clientSecret: string): Promise<ProfileResource>;
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>;
756
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;
@@ -0,0 +1,5 @@
1
+ import { Atom, TypedValue } from './atoms';
2
+ export interface FhirPathFunction {
3
+ (input: TypedValue[], ...args: Atom[]): TypedValue[];
4
+ }
5
+ export declare const functions: Record<string, FhirPathFunction>;
@@ -0,0 +1,2 @@
1
+ export * from './parse';
2
+ export * from './tokenize';
@@ -0,0 +1,17 @@
1
+ import { FhirPathAtom } from './atoms';
2
+ /**
3
+ * Parses a FHIRPath expression into an AST.
4
+ * The result can be used to evaluate the expression against a resource or other object.
5
+ * This method is useful if you know that you will evaluate the same expression many times
6
+ * against different resources.
7
+ * @param input The FHIRPath expression to parse.
8
+ * @returns The AST representing the expression.
9
+ */
10
+ export declare function parseFhirPath(input: string): FhirPathAtom;
11
+ /**
12
+ * Evaluates a FHIRPath expression against a resource or other object.
13
+ * @param input The FHIRPath expression to parse.
14
+ * @param context The resource or object to evaluate the expression against.
15
+ * @returns The result of the FHIRPath expression against the resource or object.
16
+ */
17
+ export declare function evalFhirPath(input: string, context: unknown): unknown[];
@@ -0,0 +1,5 @@
1
+ export interface Token {
2
+ id: string;
3
+ value: string;
4
+ }
5
+ export declare function tokenize(str: string): Token[];