@medplum/core 2.0.20 → 2.0.22
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 +448 -289
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +199 -101
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/crypto.mjs +3 -1
- package/dist/esm/crypto.mjs.map +1 -1
- package/dist/esm/fhirpath/functions.mjs +179 -129
- package/dist/esm/fhirpath/functions.mjs.map +1 -1
- package/dist/esm/format.mjs +6 -4
- package/dist/esm/format.mjs.map +1 -1
- package/dist/esm/hl7.mjs +1 -1
- package/dist/esm/hl7.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/jwt.mjs +4 -2
- package/dist/esm/jwt.mjs.map +1 -1
- package/dist/esm/schema.mjs +4 -10
- package/dist/esm/schema.mjs.map +1 -1
- package/dist/esm/search/details.mjs +0 -1
- package/dist/esm/search/details.mjs.map +1 -1
- package/dist/esm/search/match.mjs +1 -0
- package/dist/esm/search/match.mjs.map +1 -1
- package/dist/esm/search/search.mjs +2 -2
- package/dist/esm/search/search.mjs.map +1 -1
- package/dist/esm/sftp.mjs +0 -1
- package/dist/esm/sftp.mjs.map +1 -1
- package/dist/esm/storage.mjs +8 -0
- package/dist/esm/storage.mjs.map +1 -1
- package/dist/esm/types.mjs +1 -0
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/utils.mjs +8 -7
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/types/client.d.ts +89 -65
- package/dist/types/config.d.ts +7 -3
- package/dist/types/crypto.d.ts +3 -1
- package/dist/types/hl7.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jwt.d.ts +2 -1
- package/dist/types/schema.d.ts +4 -10
- package/dist/types/search/details.d.ts +0 -1
- package/dist/types/search/search.d.ts +1 -1
- package/dist/types/storage.d.ts +8 -0
- package/dist/types/typeschema/types.d.ts +55 -0
- package/dist/types/utils.d.ts +4 -4
- package/package.json +1 -1
package/dist/types/schema.d.ts
CHANGED
|
@@ -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
|
|
82
|
+
* @param definition The search definition.
|
|
83
83
|
* @returns Formatted URL.
|
|
84
84
|
*/
|
|
85
85
|
export declare function formatSearchQuery(definition: SearchRequest): string;
|
package/dist/types/storage.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ResourceType, StructureDefinition } from '@medplum/fhirtypes';
|
|
2
|
+
import { TypedValue } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal representation of a non-primitive FHIR type, suitable for use in resource validation
|
|
5
|
+
*/
|
|
6
|
+
export interface InternalTypeSchema {
|
|
7
|
+
name: ResourceType;
|
|
8
|
+
fields: Record<string, ElementValidator>;
|
|
9
|
+
constraints: Constraint[];
|
|
10
|
+
}
|
|
11
|
+
export interface ElementValidator {
|
|
12
|
+
min: number;
|
|
13
|
+
max: number;
|
|
14
|
+
isArray: boolean;
|
|
15
|
+
constraints: Constraint[];
|
|
16
|
+
type: ElementType[];
|
|
17
|
+
slicing?: SlicingRules;
|
|
18
|
+
fixed?: TypedValue;
|
|
19
|
+
pattern?: TypedValue;
|
|
20
|
+
binding?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ElementType {
|
|
23
|
+
code: string;
|
|
24
|
+
targetProfile: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface Constraint {
|
|
27
|
+
key: string;
|
|
28
|
+
severity: 'error' | 'warning';
|
|
29
|
+
expression: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SlicingRules {
|
|
33
|
+
discriminator: SliceDiscriminator[];
|
|
34
|
+
ordered: boolean;
|
|
35
|
+
rule?: 'open' | 'closed' | 'openAtEnd';
|
|
36
|
+
slices: SliceDefinition[];
|
|
37
|
+
}
|
|
38
|
+
export interface SliceDefinition {
|
|
39
|
+
name: string;
|
|
40
|
+
fields: Record<string, ElementValidator>;
|
|
41
|
+
min: number;
|
|
42
|
+
max: number;
|
|
43
|
+
}
|
|
44
|
+
export interface SliceDiscriminator {
|
|
45
|
+
path: string;
|
|
46
|
+
type: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parses a StructureDefinition resource into an internal schema better suited for
|
|
50
|
+
* programmatic validation and usage in internal systems
|
|
51
|
+
* @param sd The StructureDefinition resource to parse
|
|
52
|
+
* @returns The parsed schema for the given resource type
|
|
53
|
+
* @experimental
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseStructureDefinition(sd: StructureDefinition): InternalTypeSchema;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare function isProfileResource(resource: Resource): resource is Profi
|
|
|
44
44
|
/**
|
|
45
45
|
* Returns a display string for the resource.
|
|
46
46
|
* @param resource The input resource.
|
|
47
|
-
* @
|
|
47
|
+
* @returns Human friendly display string.
|
|
48
48
|
*/
|
|
49
49
|
export declare function getDisplayString(resource: Resource): string;
|
|
50
50
|
/**
|
|
@@ -94,7 +94,6 @@ export declare function getQuestionnaireAnswers(response: QuestionnaireResponse)
|
|
|
94
94
|
* If multiple identifiers exist with the same system, the first one is returned.
|
|
95
95
|
*
|
|
96
96
|
* If the system is not found, then returns undefined.
|
|
97
|
-
*
|
|
98
97
|
* @param resource The resource to check.
|
|
99
98
|
* @param system The identifier system.
|
|
100
99
|
* @returns The identifier value if found; otherwise undefined.
|
|
@@ -135,6 +134,7 @@ export declare function isEmpty(v: any): boolean;
|
|
|
135
134
|
* Ignores meta.versionId and meta.lastUpdated.
|
|
136
135
|
* @param object1 The first object.
|
|
137
136
|
* @param object2 The second object.
|
|
137
|
+
* @param path Optional path string.
|
|
138
138
|
* @returns True if the objects are equal.
|
|
139
139
|
*/
|
|
140
140
|
export declare function deepEquals(object1: unknown, object2: unknown, path?: string): boolean;
|
|
@@ -148,7 +148,6 @@ export declare function deepEquals(object1: unknown, object2: unknown, path?: st
|
|
|
148
148
|
*
|
|
149
149
|
* See: https://web.dev/structured-clone/
|
|
150
150
|
* See: https://stackoverflow.com/questions/40488190/how-is-structured-clone-algorithm-different-from-deep-copy
|
|
151
|
-
*
|
|
152
151
|
* @param input The input to clone.
|
|
153
152
|
* @returns A deep clone of the input.
|
|
154
153
|
*/
|
|
@@ -161,7 +160,7 @@ export declare function deepClone<T>(input: T): T;
|
|
|
161
160
|
export declare function isUUID(input: string): boolean;
|
|
162
161
|
/**
|
|
163
162
|
* Returns true if the input is an object.
|
|
164
|
-
* @param
|
|
163
|
+
* @param obj The candidate object.
|
|
165
164
|
* @returns True if the input is a non-null non-undefined object.
|
|
166
165
|
*/
|
|
167
166
|
export declare function isObject(obj: unknown): obj is Record<string, unknown>;
|
|
@@ -205,6 +204,7 @@ export declare function setCodeBySystem(concept: CodeableConcept, system: string
|
|
|
205
204
|
* @param definition The observation definition.
|
|
206
205
|
* @param patient The patient.
|
|
207
206
|
* @param value The observation value.
|
|
207
|
+
* @param category Optional interval category restriction.
|
|
208
208
|
* @returns The observation interval if found; otherwise undefined.
|
|
209
209
|
*/
|
|
210
210
|
export declare function findObservationInterval(definition: ObservationDefinition, patient: Patient, value: number, category?: 'reference' | 'critical' | 'absolute'): ObservationDefinitionQualifiedInterval | undefined;
|