@medplum/core 2.0.21 → 2.0.23

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.
Files changed (58) hide show
  1. package/dist/cjs/index.cjs +720 -494
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.min.cjs +1 -1
  4. package/dist/esm/client.mjs +197 -114
  5. package/dist/esm/client.mjs.map +1 -1
  6. package/dist/esm/crypto.mjs +3 -1
  7. package/dist/esm/crypto.mjs.map +1 -1
  8. package/dist/esm/fhirlexer/parse.mjs.map +1 -1
  9. package/dist/esm/fhirlexer/tokenize.mjs +2 -2
  10. package/dist/esm/fhirlexer/tokenize.mjs.map +1 -1
  11. package/dist/esm/fhirpath/atoms.mjs +63 -56
  12. package/dist/esm/fhirpath/atoms.mjs.map +1 -1
  13. package/dist/esm/fhirpath/functions.mjs +370 -252
  14. package/dist/esm/fhirpath/functions.mjs.map +1 -1
  15. package/dist/esm/fhirpath/parse.mjs +4 -2
  16. package/dist/esm/fhirpath/parse.mjs.map +1 -1
  17. package/dist/esm/format.mjs +6 -4
  18. package/dist/esm/format.mjs.map +1 -1
  19. package/dist/esm/hl7.mjs +1 -1
  20. package/dist/esm/hl7.mjs.map +1 -1
  21. package/dist/esm/index.min.mjs +1 -1
  22. package/dist/esm/index.mjs +2 -1
  23. package/dist/esm/index.mjs.map +1 -1
  24. package/dist/esm/jwt.mjs +4 -2
  25. package/dist/esm/jwt.mjs.map +1 -1
  26. package/dist/esm/outcomes.mjs +14 -11
  27. package/dist/esm/outcomes.mjs.map +1 -1
  28. package/dist/esm/schema.mjs +4 -10
  29. package/dist/esm/schema.mjs.map +1 -1
  30. package/dist/esm/search/details.mjs +4 -5
  31. package/dist/esm/search/details.mjs.map +1 -1
  32. package/dist/esm/search/match.mjs +1 -0
  33. package/dist/esm/search/match.mjs.map +1 -1
  34. package/dist/esm/search/search.mjs +1 -1
  35. package/dist/esm/search/search.mjs.map +1 -1
  36. package/dist/esm/storage.mjs +8 -0
  37. package/dist/esm/storage.mjs.map +1 -1
  38. package/dist/esm/types.mjs +1 -0
  39. package/dist/esm/types.mjs.map +1 -1
  40. package/dist/esm/utils.mjs +8 -7
  41. package/dist/esm/utils.mjs.map +1 -1
  42. package/dist/types/client.d.ts +128 -69
  43. package/dist/types/crypto.d.ts +3 -1
  44. package/dist/types/fhirlexer/parse.d.ts +7 -3
  45. package/dist/types/fhirpath/atoms.d.ts +21 -21
  46. package/dist/types/fhirpath/functions.d.ts +2 -2
  47. package/dist/types/fhirpath/parse.d.ts +2 -1
  48. package/dist/types/hl7.d.ts +1 -1
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/jwt.d.ts +2 -1
  51. package/dist/types/outcomes.d.ts +7 -1
  52. package/dist/types/schema.d.ts +4 -10
  53. package/dist/types/search/details.d.ts +0 -1
  54. package/dist/types/search/search.d.ts +1 -1
  55. package/dist/types/storage.d.ts +8 -0
  56. package/dist/types/typeschema/types.d.ts +0 -1
  57. package/dist/types/utils.d.ts +5 -12
  58. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
- import { Atom, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer';
1
+ import { Atom, AtomContext, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer';
2
2
  import { TypedValue } from '../types';
3
3
  export declare class FhirPathAtom implements Atom {
4
4
  readonly original: string;
5
5
  readonly child: Atom;
6
6
  constructor(original: string, child: Atom);
7
- eval(context: TypedValue[]): TypedValue[];
7
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
8
8
  toString(): string;
9
9
  }
10
10
  export declare class LiteralAtom implements Atom {
@@ -16,7 +16,7 @@ export declare class LiteralAtom implements Atom {
16
16
  export declare class SymbolAtom implements Atom {
17
17
  readonly name: string;
18
18
  constructor(name: string);
19
- eval(context: TypedValue[]): TypedValue[];
19
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
20
20
  private evalValue;
21
21
  toString(): string;
22
22
  }
@@ -27,58 +27,58 @@ export declare class EmptySetAtom implements Atom {
27
27
  export declare class UnaryOperatorAtom extends PrefixOperatorAtom {
28
28
  readonly impl: (x: TypedValue[]) => TypedValue[];
29
29
  constructor(operator: string, child: Atom, impl: (x: TypedValue[]) => TypedValue[]);
30
- eval(context: TypedValue[]): TypedValue[];
30
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
31
31
  toString(): string;
32
32
  }
33
33
  export declare class AsAtom extends InfixOperatorAtom {
34
34
  constructor(left: Atom, right: Atom);
35
- eval(context: TypedValue[]): TypedValue[];
35
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
36
36
  }
37
37
  export declare class ArithemticOperatorAtom extends InfixOperatorAtom {
38
38
  readonly impl: (x: number, y: number) => number | boolean;
39
39
  constructor(operator: string, left: Atom, right: Atom, impl: (x: number, y: number) => number | boolean);
40
- eval(context: TypedValue[]): TypedValue[];
40
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
41
41
  }
42
42
  export declare class ConcatAtom extends InfixOperatorAtom {
43
43
  constructor(left: Atom, right: Atom);
44
- eval(context: TypedValue[]): TypedValue[];
44
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
45
45
  }
46
46
  export declare class ContainsAtom extends InfixOperatorAtom {
47
47
  constructor(left: Atom, right: Atom);
48
- eval(context: TypedValue[]): TypedValue[];
48
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
49
49
  }
50
50
  export declare class InAtom extends InfixOperatorAtom {
51
51
  constructor(left: Atom, right: Atom);
52
- eval(context: TypedValue[]): TypedValue[];
52
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
53
53
  }
54
54
  export declare class DotAtom extends InfixOperatorAtom {
55
55
  constructor(left: Atom, right: Atom);
56
- eval(context: TypedValue[]): TypedValue[];
56
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
57
57
  toString(): string;
58
58
  }
59
59
  export declare class UnionAtom extends InfixOperatorAtom {
60
60
  constructor(left: Atom, right: Atom);
61
- eval(context: TypedValue[]): TypedValue[];
61
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
62
62
  }
63
63
  export declare class EqualsAtom extends InfixOperatorAtom {
64
64
  constructor(left: Atom, right: Atom);
65
- eval(context: TypedValue[]): TypedValue[];
65
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
66
66
  }
67
67
  export declare class NotEqualsAtom extends InfixOperatorAtom {
68
68
  constructor(left: Atom, right: Atom);
69
- eval(context: TypedValue[]): TypedValue[];
69
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
70
70
  }
71
71
  export declare class EquivalentAtom extends InfixOperatorAtom {
72
72
  constructor(left: Atom, right: Atom);
73
- eval(context: TypedValue[]): TypedValue[];
73
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
74
74
  }
75
75
  export declare class NotEquivalentAtom extends InfixOperatorAtom {
76
76
  constructor(left: Atom, right: Atom);
77
- eval(context: TypedValue[]): TypedValue[];
77
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
78
78
  }
79
79
  export declare class IsAtom extends InfixOperatorAtom {
80
80
  constructor(left: Atom, right: Atom);
81
- eval(context: TypedValue[]): TypedValue[];
81
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
82
82
  }
83
83
  /**
84
84
  * 6.5.1. and
@@ -88,11 +88,11 @@ export declare class IsAtom extends InfixOperatorAtom {
88
88
  */
89
89
  export declare class AndAtom extends InfixOperatorAtom {
90
90
  constructor(left: Atom, right: Atom);
91
- eval(context: TypedValue[]): TypedValue[];
91
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
92
92
  }
93
93
  export declare class OrAtom extends InfixOperatorAtom {
94
94
  constructor(left: Atom, right: Atom);
95
- eval(context: TypedValue[]): TypedValue[];
95
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
96
96
  }
97
97
  /**
98
98
  * 6.5.4. xor
@@ -102,19 +102,19 @@ export declare class OrAtom extends InfixOperatorAtom {
102
102
  */
103
103
  export declare class XorAtom extends InfixOperatorAtom {
104
104
  constructor(left: Atom, right: Atom);
105
- eval(context: TypedValue[]): TypedValue[];
105
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
106
106
  }
107
107
  export declare class FunctionAtom implements Atom {
108
108
  readonly name: string;
109
109
  readonly args: Atom[];
110
110
  constructor(name: string, args: Atom[]);
111
- eval(context: TypedValue[]): TypedValue[];
111
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
112
112
  toString(): string;
113
113
  }
114
114
  export declare class IndexerAtom implements Atom {
115
115
  readonly left: Atom;
116
116
  readonly expr: Atom;
117
117
  constructor(left: Atom, expr: Atom);
118
- eval(context: TypedValue[]): TypedValue[];
118
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
119
119
  toString(): string;
120
120
  }
@@ -1,6 +1,6 @@
1
- import { Atom } from '../fhirlexer';
1
+ import { Atom, AtomContext } from '../fhirlexer';
2
2
  import { TypedValue } from '../types';
3
3
  export interface FhirPathFunction {
4
- (input: TypedValue[], ...args: Atom[]): TypedValue[];
4
+ (context: AtomContext, input: TypedValue[], ...args: Atom[]): TypedValue[];
5
5
  }
6
6
  export declare const functions: Record<string, FhirPathFunction>;
@@ -59,6 +59,7 @@ export declare function evalFhirPath(expression: string, input: unknown): unknow
59
59
  * Evaluates a FHIRPath expression against a resource or other object.
60
60
  * @param expression The FHIRPath expression to parse.
61
61
  * @param input The resource or object to evaluate the expression against.
62
+ * @param variables A map of variables for eval input.
62
63
  * @returns The result of the FHIRPath expression against the resource or object.
63
64
  */
64
- export declare function evalFhirPathTyped(expression: string, input: TypedValue[]): TypedValue[];
65
+ export declare function evalFhirPathTyped(expression: string, input: TypedValue[], variables?: Record<string, TypedValue>): TypedValue[];
@@ -142,7 +142,7 @@ interface Hl7DateParseOptions {
142
142
  * Returns a formatted string representing the date in ISO-8601 format.
143
143
  * @param hl7Date Date string.
144
144
  * @param options Optional configuration Object
145
- * @returns
145
+ * @returns The date in ISO-8601 format.
146
146
  */
147
147
  export declare function parseHl7Date(hl7Date: string | undefined, options?: Hl7DateParseOptions): string | undefined;
148
148
  export {};
@@ -1,3 +1,4 @@
1
+ export * from './base64';
1
2
  export * from './bundle';
2
3
  export * from './cache';
3
4
  export * from './client';
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Parses the JWT payload.
3
- * @param token JWT token
3
+ * @param token JWT token.
4
+ * @returns Collection of key value claims in the JWT payload.
4
5
  */
5
6
  export declare function parseJWTPayload(token: string): Record<string, number | string>;
@@ -1,4 +1,4 @@
1
- import { OperationOutcome } from '@medplum/fhirtypes';
1
+ import { OperationOutcome, OperationOutcomeIssue } from '@medplum/fhirtypes';
2
2
  export declare const allOk: OperationOutcome;
3
3
  export declare const created: OperationOutcome;
4
4
  export declare const notModified: OperationOutcome;
@@ -43,3 +43,9 @@ export declare function normalizeErrorString(error: unknown): string;
43
43
  * @returns The string representation of the operation outcome.
44
44
  */
45
45
  export declare function operationOutcomeToString(outcome: OperationOutcome): string;
46
+ /**
47
+ * Returns a string represenation of the operation outcome issue.
48
+ * @param issue The operation outcome issue.
49
+ * @returns The string representation of the operation outcome issue.
50
+ */
51
+ export declare function operationOutcomeIssueToString(issue: OperationOutcomeIssue): string;
@@ -27,7 +27,6 @@ import { OperationOutcomeIssue, Resource } from '@medplum/fhirtypes';
27
27
  * const medplum = new MedplumClient();
28
28
  * await medplum.requestSchema('Patient');
29
29
  * ```
30
- *
31
30
  * @param resourceType The candidate resource type string.
32
31
  * @returns True if the resource type is a valid FHIR resource type.
33
32
  */
@@ -62,9 +61,7 @@ export declare function isResourceType(resourceType: string): boolean;
62
61
  * const medplum = new MedplumClient();
63
62
  * await medplum.requestSchema('Patient');
64
63
  * ```
65
- *
66
64
  * @param resourceType The candidate resource type string.
67
- * @returns True if the resource type is a valid FHIR resource type.
68
65
  */
69
66
  export declare function validateResourceType(resourceType: string): void;
70
67
  /**
@@ -97,9 +94,7 @@ export declare function validateResourceType(resourceType: string): void;
97
94
  * const medplum = new MedplumClient();
98
95
  * await medplum.requestSchema('Patient');
99
96
  * ```
100
- *
101
- * @param resourceType The candidate resource type string.
102
- * @returns True if the resource type is a valid FHIR resource type.
97
+ * @param resource The candidate resource.
103
98
  */
104
99
  export declare function validateResource<T extends Resource>(resource: T): void;
105
100
  export declare class FhirSchemaValidator<T extends Resource> {
@@ -131,10 +126,10 @@ export declare class FhirSchemaValidator<T extends Resource> {
131
126
  * 2) a JSON property with _ prepended to the name of the element, which, if present, contains the value's id and/or extensions
132
127
  *
133
128
  * See: https://hl7.org/fhir/json.html#primitive
134
- *
135
129
  * @param path The path to the property
136
- * @param key
137
- * @param typedValue
130
+ * @param key The key in the current typed value.
131
+ * @param typedValue The current typed value.
132
+ * @returns True if the primitive element is valid.
138
133
  */
139
134
  private checkPrimitiveElement;
140
135
  private createIssue;
@@ -143,7 +138,6 @@ export declare class FhirSchemaValidator<T extends Resource> {
143
138
  * Recursively checks for null values in an object.
144
139
  *
145
140
  * Note that "null" is a special value in JSON that is not allowed in FHIR.
146
- *
147
141
  * @param value Input value of any type.
148
142
  * @param path Path string to the value for OperationOutcome.
149
143
  * @param issues Output list of issues.
@@ -26,7 +26,6 @@ export interface SearchParameterDetails {
26
26
  * 1) The "date" type includes "date", "datetime", and "period".
27
27
  * 2) The "token" type includes enums and booleans.
28
28
  * 3) Arrays/multiple values are not reflected at all.
29
- *
30
29
  * @param resourceType The root resource type.
31
30
  * @param searchParam The search parameter.
32
31
  * @returns The search parameter type details.
@@ -79,7 +79,7 @@ export declare function parseSearchDefinition<T extends Resource = Resource>(url
79
79
  /**
80
80
  * Formats a search definition object into a query string.
81
81
  * Note: The return value does not include the resource type.
82
- * @param {!SearchRequest} definition The search definition.
82
+ * @param definition The search definition.
83
83
  * @returns Formatted URL.
84
84
  */
85
85
  export declare function formatSearchQuery(definition: SearchRequest): string;
@@ -22,6 +22,7 @@ export declare class MemoryStorage implements Storage {
22
22
  constructor();
23
23
  /**
24
24
  * Returns the number of key/value pairs.
25
+ * @returns The number of key/value pairs.
25
26
  */
26
27
  get length(): number;
27
28
  /**
@@ -30,18 +31,25 @@ export declare class MemoryStorage implements Storage {
30
31
  clear(): void;
31
32
  /**
32
33
  * Returns the current value associated with the given key, or null if the given key does not exist.
34
+ * @param key The specified storage key.
35
+ * @returns The current value associated with the given key, or null if the given key does not exist.
33
36
  */
34
37
  getItem(key: string): string | null;
35
38
  /**
36
39
  * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
40
+ * @param key The storage key.
41
+ * @param value The new value.
37
42
  */
38
43
  setItem(key: string, value: string | null): void;
39
44
  /**
40
45
  * Removes the key/value pair with the given key, if a key/value pair with the given key exists.
46
+ * @param key The storage key.
41
47
  */
42
48
  removeItem(key: string): void;
43
49
  /**
44
50
  * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
51
+ * @param index The numeric index.
52
+ * @returns The nth key.
45
53
  */
46
54
  key(index: number): string | null;
47
55
  }
@@ -48,7 +48,6 @@ export interface SliceDiscriminator {
48
48
  /**
49
49
  * Parses a StructureDefinition resource into an internal schema better suited for
50
50
  * programmatic validation and usage in internal systems
51
- *
52
51
  * @param sd The StructureDefinition resource to parse
53
52
  * @returns The parsed schema for the given resource type
54
53
  * @experimental
@@ -1,15 +1,8 @@
1
- import { CodeableConcept, Extension, ObservationDefinition, ObservationDefinitionQualifiedInterval, Patient, Practitioner, ProjectMembership, QuestionnaireResponse, QuestionnaireResponseItemAnswer, Range, Reference, RelatedPerson, Resource } from '@medplum/fhirtypes';
1
+ import { CodeableConcept, Extension, ObservationDefinition, ObservationDefinitionQualifiedInterval, Patient, Practitioner, QuestionnaireResponse, QuestionnaireResponseItemAnswer, Range, Reference, RelatedPerson, Resource } from '@medplum/fhirtypes';
2
2
  /**
3
3
  * @internal
4
4
  */
5
5
  export type ProfileResource = Patient | Practitioner | RelatedPerson;
6
- /**
7
- * @internal
8
- */
9
- export interface InviteResult {
10
- profile: ProfileResource;
11
- membership: ProjectMembership;
12
- }
13
6
  interface Code {
14
7
  code?: CodeableConcept;
15
8
  }
@@ -44,7 +37,7 @@ export declare function isProfileResource(resource: Resource): resource is Profi
44
37
  /**
45
38
  * Returns a display string for the resource.
46
39
  * @param resource The input resource.
47
- * @return Human friendly display string.
40
+ * @returns Human friendly display string.
48
41
  */
49
42
  export declare function getDisplayString(resource: Resource): string;
50
43
  /**
@@ -94,7 +87,6 @@ export declare function getQuestionnaireAnswers(response: QuestionnaireResponse)
94
87
  * If multiple identifiers exist with the same system, the first one is returned.
95
88
  *
96
89
  * If the system is not found, then returns undefined.
97
- *
98
90
  * @param resource The resource to check.
99
91
  * @param system The identifier system.
100
92
  * @returns The identifier value if found; otherwise undefined.
@@ -135,6 +127,7 @@ export declare function isEmpty(v: any): boolean;
135
127
  * Ignores meta.versionId and meta.lastUpdated.
136
128
  * @param object1 The first object.
137
129
  * @param object2 The second object.
130
+ * @param path Optional path string.
138
131
  * @returns True if the objects are equal.
139
132
  */
140
133
  export declare function deepEquals(object1: unknown, object2: unknown, path?: string): boolean;
@@ -148,7 +141,6 @@ export declare function deepEquals(object1: unknown, object2: unknown, path?: st
148
141
  *
149
142
  * See: https://web.dev/structured-clone/
150
143
  * See: https://stackoverflow.com/questions/40488190/how-is-structured-clone-algorithm-different-from-deep-copy
151
- *
152
144
  * @param input The input to clone.
153
145
  * @returns A deep clone of the input.
154
146
  */
@@ -161,7 +153,7 @@ export declare function deepClone<T>(input: T): T;
161
153
  export declare function isUUID(input: string): boolean;
162
154
  /**
163
155
  * Returns true if the input is an object.
164
- * @param object The candidate object.
156
+ * @param obj The candidate object.
165
157
  * @returns True if the input is a non-null non-undefined object.
166
158
  */
167
159
  export declare function isObject(obj: unknown): obj is Record<string, unknown>;
@@ -205,6 +197,7 @@ export declare function setCodeBySystem(concept: CodeableConcept, system: string
205
197
  * @param definition The observation definition.
206
198
  * @param patient The patient.
207
199
  * @param value The observation value.
200
+ * @param category Optional interval category restriction.
208
201
  * @returns The observation interval if found; otherwise undefined.
209
202
  */
210
203
  export declare function findObservationInterval(definition: ObservationDefinition, patient: Patient, value: number, category?: 'reference' | 'critical' | 'absolute'): ObservationDefinitionQualifiedInterval | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "2.0.21",
3
+ "version": "2.0.23",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",