@medplum/core 0.9.7 → 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.
@@ -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,4 +1,6 @@
1
+ /// <reference types="node" />
1
2
  import { Binary, Bundle, Communication, OperationOutcome, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
3
+ import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
2
4
  import { EventTarget } from './eventtarget';
3
5
  import { Hl7Message } from './hl7';
4
6
  import { ReadablePromise } from './readablepromise';
@@ -246,6 +248,16 @@ export declare class MedplumClient extends EventTarget {
246
248
  * Clears all auth state including local storage and session storage.
247
249
  */
248
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;
249
261
  /**
250
262
  * Makes an HTTP GET request to the specified URL.
251
263
  *
@@ -354,6 +366,12 @@ export declare class MedplumClient extends EventTarget {
354
366
  * @returns The well-formed FHIR URL.
355
367
  */
356
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;
357
375
  /**
358
376
  * Sends a FHIR search request.
359
377
  *
@@ -488,25 +506,6 @@ export declare class MedplumClient extends EventTarget {
488
506
  * @returns The resource if available; undefined otherwise.
489
507
  */
490
508
  readResource<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
491
- /**
492
- * Reads a resource by resource type and ID using the in-memory resource cache.
493
- *
494
- * If the resource is not available in the cache, it will be read from the server.
495
- *
496
- * Example:
497
- *
498
- * ```typescript
499
- * const patient = await medplum.readCached('Patient', '123');
500
- * console.log(patient);
501
- * ```
502
- *
503
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
504
- *
505
- * @param resourceType The FHIR resource type.
506
- * @param id The resource ID.
507
- * @returns The resource if available; undefined otherwise.
508
- */
509
- readCached<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
510
509
  /**
511
510
  * Reads a resource by `Reference`.
512
511
  *
@@ -526,27 +525,6 @@ export declare class MedplumClient extends EventTarget {
526
525
  * @returns The resource if available; undefined otherwise.
527
526
  */
528
527
  readReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
529
- /**
530
- * Reads a resource by `Reference` using the in-memory resource cache.
531
- *
532
- * This is a convenience method for `readResource()` that accepts a `Reference` object.
533
- *
534
- * If the resource is not available in the cache, it will be read from the server.
535
- *
536
- * Example:
537
- *
538
- * ```typescript
539
- * const serviceRequest = await medplum.readResource('ServiceRequest', '123');
540
- * const patient = await medplum.readCachedReference(serviceRequest.subject);
541
- * console.log(patient);
542
- * ```
543
- *
544
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
545
- *
546
- * @param reference The FHIR reference object.
547
- * @returns The resource if available; undefined otherwise.
548
- */
549
- readCachedReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
550
528
  /**
551
529
  * Returns a cached schema for a resource type.
552
530
  * If the schema is not cached, returns undefined.
@@ -685,7 +663,7 @@ export declare class MedplumClient extends EventTarget {
685
663
  * @param contentType Content type for the binary.
686
664
  * @returns The result of the create operation.
687
665
  */
688
- 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>;
689
667
  /**
690
668
  * Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
691
669
  *
@@ -704,10 +682,12 @@ export declare class MedplumClient extends EventTarget {
704
682
  *
705
683
  * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
706
684
  *
707
- * @param docDefinition The FHIR resource to create.
685
+ * @param docDefinition The PDF document definition.
708
686
  * @returns The result of the create operation.
709
687
  */
710
- 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>;
711
691
  /**
712
692
  * Creates a FHIR `Communication` resource with the provided data content.
713
693
  *
@@ -1,111 +1,109 @@
1
- import { Quantity } from '@medplum/fhirtypes';
1
+ import { PropertyType } from '../types';
2
+ export interface TypedValue {
3
+ readonly type: PropertyType;
4
+ readonly value: any;
5
+ }
2
6
  export interface Atom {
3
- eval(context: unknown): unknown;
7
+ eval(context: TypedValue[]): TypedValue[];
4
8
  }
5
9
  export declare class FhirPathAtom implements Atom {
6
10
  readonly original: string;
7
11
  readonly child: Atom;
8
12
  constructor(original: string, child: Atom);
9
- eval(context: unknown): unknown[];
13
+ eval(context: TypedValue[]): TypedValue[];
10
14
  }
11
15
  export declare class LiteralAtom implements Atom {
12
- readonly value: Quantity | boolean | number | string;
13
- constructor(value: Quantity | boolean | number | string);
14
- eval(): unknown;
16
+ readonly value: TypedValue;
17
+ constructor(value: TypedValue);
18
+ eval(): TypedValue[];
15
19
  }
16
20
  export declare class SymbolAtom implements Atom {
21
+ #private;
17
22
  readonly name: string;
18
23
  constructor(name: string);
19
- eval(context: unknown): unknown;
24
+ eval(context: TypedValue[]): TypedValue[];
20
25
  }
21
26
  export declare class EmptySetAtom implements Atom {
22
27
  eval(): [];
23
28
  }
24
29
  export declare class UnaryOperatorAtom implements Atom {
25
30
  readonly child: Atom;
26
- readonly impl: (x: unknown) => unknown;
27
- constructor(child: Atom, impl: (x: unknown) => unknown);
28
- eval(context: unknown): unknown;
31
+ readonly impl: (x: TypedValue[]) => TypedValue[];
32
+ constructor(child: Atom, impl: (x: TypedValue[]) => TypedValue[]);
33
+ eval(context: TypedValue[]): TypedValue[];
29
34
  }
30
35
  export declare class AsAtom implements Atom {
31
36
  readonly left: Atom;
32
37
  readonly right: Atom;
33
38
  constructor(left: Atom, right: Atom);
34
- eval(context: unknown): unknown;
39
+ eval(context: TypedValue[]): TypedValue[];
35
40
  }
36
41
  export declare class ArithemticOperatorAtom implements Atom {
37
42
  readonly left: Atom;
38
43
  readonly right: Atom;
39
- readonly impl: (x: number, y: number) => number;
40
- constructor(left: Atom, right: Atom, impl: (x: number, y: number) => number);
41
- eval(context: unknown): unknown;
42
- }
43
- export declare class ComparisonOperatorAtom implements Atom {
44
- readonly left: Atom;
45
- readonly right: Atom;
46
- readonly impl: (x: number, y: number) => boolean;
47
- constructor(left: Atom, right: Atom, impl: (x: number, y: number) => boolean);
48
- eval(context: unknown): unknown;
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[];
49
47
  }
50
48
  export declare class ConcatAtom implements Atom {
51
49
  readonly left: Atom;
52
50
  readonly right: Atom;
53
51
  constructor(left: Atom, right: Atom);
54
- eval(context: unknown): unknown;
52
+ eval(context: TypedValue[]): TypedValue[];
55
53
  }
56
54
  export declare class ContainsAtom implements Atom {
57
55
  readonly left: Atom;
58
56
  readonly right: Atom;
59
57
  constructor(left: Atom, right: Atom);
60
- eval(context: unknown): unknown;
58
+ eval(context: TypedValue[]): TypedValue[];
61
59
  }
62
60
  export declare class InAtom implements Atom {
63
61
  readonly left: Atom;
64
62
  readonly right: Atom;
65
63
  constructor(left: Atom, right: Atom);
66
- eval(context: unknown): unknown;
64
+ eval(context: TypedValue[]): TypedValue[];
67
65
  }
68
66
  export declare class DotAtom implements Atom {
69
67
  readonly left: Atom;
70
68
  readonly right: Atom;
71
69
  constructor(left: Atom, right: Atom);
72
- eval(context: unknown): unknown;
70
+ eval(context: TypedValue[]): TypedValue[];
73
71
  }
74
72
  export declare class UnionAtom implements Atom {
75
73
  readonly left: Atom;
76
74
  readonly right: Atom;
77
75
  constructor(left: Atom, right: Atom);
78
- eval(context: unknown): unknown;
76
+ eval(context: TypedValue[]): TypedValue[];
79
77
  }
80
78
  export declare class EqualsAtom implements Atom {
81
79
  readonly left: Atom;
82
80
  readonly right: Atom;
83
81
  constructor(left: Atom, right: Atom);
84
- eval(context: unknown): unknown;
82
+ eval(context: TypedValue[]): TypedValue[];
85
83
  }
86
84
  export declare class NotEqualsAtom implements Atom {
87
85
  readonly left: Atom;
88
86
  readonly right: Atom;
89
87
  constructor(left: Atom, right: Atom);
90
- eval(context: unknown): unknown;
88
+ eval(context: TypedValue[]): TypedValue[];
91
89
  }
92
90
  export declare class EquivalentAtom implements Atom {
93
91
  readonly left: Atom;
94
92
  readonly right: Atom;
95
93
  constructor(left: Atom, right: Atom);
96
- eval(context: unknown): unknown;
94
+ eval(context: TypedValue[]): TypedValue[];
97
95
  }
98
96
  export declare class NotEquivalentAtom implements Atom {
99
97
  readonly left: Atom;
100
98
  readonly right: Atom;
101
99
  constructor(left: Atom, right: Atom);
102
- eval(context: unknown): unknown;
100
+ eval(context: TypedValue[]): TypedValue[];
103
101
  }
104
102
  export declare class IsAtom implements Atom {
105
103
  readonly left: Atom;
106
104
  readonly right: Atom;
107
105
  constructor(left: Atom, right: Atom);
108
- eval(context: unknown): unknown;
106
+ eval(context: TypedValue[]): TypedValue[];
109
107
  }
110
108
  /**
111
109
  * 6.5.1. and
@@ -115,13 +113,13 @@ export declare class AndAtom implements Atom {
115
113
  readonly left: Atom;
116
114
  readonly right: Atom;
117
115
  constructor(left: Atom, right: Atom);
118
- eval(context: unknown): unknown;
116
+ eval(context: TypedValue[]): TypedValue[];
119
117
  }
120
118
  export declare class OrAtom implements Atom {
121
119
  readonly left: Atom;
122
120
  readonly right: Atom;
123
121
  constructor(left: Atom, right: Atom);
124
- eval(context: unknown): unknown;
122
+ eval(context: TypedValue[]): TypedValue[];
125
123
  }
126
124
  /**
127
125
  * 6.5.4. xor
@@ -133,18 +131,18 @@ export declare class XorAtom implements Atom {
133
131
  readonly left: Atom;
134
132
  readonly right: Atom;
135
133
  constructor(left: Atom, right: Atom);
136
- eval(context: unknown): unknown;
134
+ eval(context: TypedValue[]): TypedValue[];
137
135
  }
138
136
  export declare class FunctionAtom implements Atom {
139
137
  readonly name: string;
140
138
  readonly args: Atom[];
141
- readonly impl: (context: unknown[], ...a: Atom[]) => unknown[];
142
- constructor(name: string, args: Atom[], impl: (context: unknown[], ...a: Atom[]) => unknown[]);
143
- eval(context: unknown): unknown;
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[];
144
142
  }
145
143
  export declare class IndexerAtom implements Atom {
146
144
  readonly left: Atom;
147
145
  readonly expr: Atom;
148
146
  constructor(left: Atom, expr: Atom);
149
- eval(context: unknown): unknown;
147
+ eval(context: TypedValue[]): TypedValue[];
150
148
  }