@medplum/core 2.0.5 → 2.0.7
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 +872 -27
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +7 -6
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/fhirlexer/tokenize.mjs +13 -4
- package/dist/esm/fhirlexer/tokenize.mjs.map +1 -1
- package/dist/esm/fhirmapper/parse.mjs +317 -0
- package/dist/esm/fhirmapper/parse.mjs.map +1 -0
- package/dist/esm/fhirmapper/tokenize.mjs +15 -0
- package/dist/esm/fhirmapper/tokenize.mjs.map +1 -0
- package/dist/esm/fhirpath/atoms.mjs +2 -2
- package/dist/esm/fhirpath/atoms.mjs.map +1 -1
- package/dist/esm/fhirpath/functions.mjs +2 -2
- package/dist/esm/fhirpath/functions.mjs.map +1 -1
- package/dist/esm/fhirpath/utils.mjs +4 -4
- package/dist/esm/fhirpath/utils.mjs.map +1 -1
- package/dist/esm/filter/parse.mjs +51 -0
- package/dist/esm/filter/parse.mjs.map +1 -0
- package/dist/esm/filter/tokenize.mjs +18 -0
- package/dist/esm/filter/tokenize.mjs.map +1 -0
- package/dist/esm/filter/types.mjs +34 -0
- package/dist/esm/filter/types.mjs.map +1 -0
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +8 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/node_modules/tslib/tslib.es6.mjs.map +1 -1
- package/dist/esm/outcomes.mjs +15 -1
- package/dist/esm/outcomes.mjs.map +1 -1
- package/dist/esm/schema.mjs +397 -0
- package/dist/esm/schema.mjs.map +1 -0
- package/dist/esm/search/details.mjs +1 -1
- package/dist/esm/search/details.mjs.map +1 -1
- package/dist/esm/types.mjs +34 -8
- package/dist/esm/types.mjs.map +1 -1
- package/dist/types/client.d.ts +20 -8
- package/dist/types/fhirlexer/tokenize.d.ts +5 -1
- package/dist/types/fhirmapper/index.d.ts +1 -0
- package/dist/types/filter/index.d.ts +2 -0
- package/dist/types/filter/parse.d.ts +7 -0
- package/dist/types/filter/tokenize.d.ts +2 -0
- package/dist/types/filter/types.d.ts +31 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/outcomes.d.ts +1 -0
- package/dist/types/schema.d.ts +120 -0
- package/dist/types/types.d.ts +19 -5
- package/package.json +1 -1
- package/tsconfig.build.json +0 -9
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { OperationOutcomeIssue, Resource } from '@medplum/fhirtypes';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given string is a valid FHIR resource type.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* isResourceType('Patient'); // true
|
|
7
|
+
* isResourceType('XYZ'); // false
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Note that this depends on globalSchema, which is populated by the StructureDefinition loader.
|
|
11
|
+
*
|
|
12
|
+
* In a server context, you can load all schema definitions:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { indexStructureDefinitionBundle } from '@medplum/core';
|
|
16
|
+
* import { readJson } from '@medplum/definitions';
|
|
17
|
+
* import { Bundle } from '@medplum/fhirtypes';
|
|
18
|
+
*
|
|
19
|
+
* indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* In a client context, you can load the schema definitions using MedplumClient:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { MedplumClient } from '@medplum/core';
|
|
26
|
+
*
|
|
27
|
+
* const medplum = new MedplumClient();
|
|
28
|
+
* await medplum.requestSchema('Patient');
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param resourceType The candidate resource type string.
|
|
32
|
+
* @returns True if the resource type is a valid FHIR resource type.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isResourceType(resourceType: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Validates that the given string is a valid FHIR resource type.
|
|
37
|
+
* On success, silently returns void.
|
|
38
|
+
* On failure, throws an OperationOutcomeError.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* validateResourceType('Patient'); // nothing
|
|
42
|
+
* validateResourceType('XYZ'); // throws OperationOutcomeError
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Note that this depends on globalSchema, which is populated by the StructureDefinition loader.
|
|
46
|
+
*
|
|
47
|
+
* In a server context, you can load all schema definitions:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { indexStructureDefinitionBundle } from '@medplum/core';
|
|
51
|
+
* import { readJson } from '@medplum/definitions';
|
|
52
|
+
* import { Bundle } from '@medplum/fhirtypes';
|
|
53
|
+
*
|
|
54
|
+
* indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* In a client context, you can load the schema definitions using MedplumClient:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { MedplumClient } from '@medplum/core';
|
|
61
|
+
*
|
|
62
|
+
* const medplum = new MedplumClient();
|
|
63
|
+
* await medplum.requestSchema('Patient');
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param resourceType The candidate resource type string.
|
|
67
|
+
* @returns True if the resource type is a valid FHIR resource type.
|
|
68
|
+
*/
|
|
69
|
+
export declare function validateResourceType(resourceType: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Validates a candidate FHIR resource object.
|
|
72
|
+
* On success, silently returns void.
|
|
73
|
+
* On failure, throws an OperationOutcomeError with issues for each violation.
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* validateResource({ resourceType: 'Patient' }); // nothing
|
|
77
|
+
* validateResource({ resourceType: 'XYZ' }); // throws OperationOutcomeError
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* Note that this depends on globalSchema, which is populated by the StructureDefinition loader.
|
|
81
|
+
*
|
|
82
|
+
* In a server context, you can load all schema definitions:
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { indexStructureDefinitionBundle } from '@medplum/core';
|
|
86
|
+
* import { readJson } from '@medplum/definitions';
|
|
87
|
+
* import { Bundle } from '@medplum/fhirtypes';
|
|
88
|
+
*
|
|
89
|
+
* indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* In a client context, you can load the schema definitions using MedplumClient:
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { MedplumClient } from '@medplum/core';
|
|
96
|
+
*
|
|
97
|
+
* const medplum = new MedplumClient();
|
|
98
|
+
* await medplum.requestSchema('Patient');
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @param resourceType The candidate resource type string.
|
|
102
|
+
* @returns True if the resource type is a valid FHIR resource type.
|
|
103
|
+
*/
|
|
104
|
+
export declare function validateResource<T extends Resource>(resource: T): void;
|
|
105
|
+
export declare class FhirSchemaValidator<T extends Resource> {
|
|
106
|
+
#private;
|
|
107
|
+
constructor(root: T);
|
|
108
|
+
validate(): void;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Recursively checks for null values in an object.
|
|
112
|
+
*
|
|
113
|
+
* Note that "null" is a special value in JSON that is not allowed in FHIR.
|
|
114
|
+
*
|
|
115
|
+
* @param value Input value of any type.
|
|
116
|
+
* @param path Path string to the value for OperationOutcome.
|
|
117
|
+
* @param issues Output list of issues.
|
|
118
|
+
*/
|
|
119
|
+
export declare function checkForNull(value: unknown, path: string, issues: OperationOutcomeIssue[]): void;
|
|
120
|
+
export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bundle, ElementDefinition, SearchParameter, StructureDefinition } from '@medplum/fhirtypes';
|
|
1
|
+
import { Bundle, ElementDefinition, Reference, Resource, ResourceType, SearchParameter, StructureDefinition } from '@medplum/fhirtypes';
|
|
2
2
|
import { SearchParameterDetails } from './search/details';
|
|
3
3
|
export interface TypedValue {
|
|
4
4
|
readonly type: string;
|
|
@@ -157,17 +157,17 @@ export declare function indexSearchParameter(searchParam: SearchParameter): void
|
|
|
157
157
|
export declare function getElementDefinitionTypeName(elementDefinition: ElementDefinition): string;
|
|
158
158
|
export declare function buildTypeName(components: string[]): string;
|
|
159
159
|
/**
|
|
160
|
-
* Returns true if the type schema is a
|
|
160
|
+
* Returns true if the type schema is a non-abstract FHIR resource.
|
|
161
161
|
* @param typeSchema The type schema to check.
|
|
162
|
-
* @returns True if the type schema is a
|
|
162
|
+
* @returns True if the type schema is a non-abstract FHIR resource.
|
|
163
163
|
*/
|
|
164
|
-
export declare function
|
|
164
|
+
export declare function isResourceTypeSchema(typeSchema: TypeSchema): boolean;
|
|
165
165
|
/**
|
|
166
166
|
* Returns an array of all resource types.
|
|
167
167
|
* Note that this is based on globalSchema, and will only return resource types that are currently in memory.
|
|
168
168
|
* @returns An array of all resource types.
|
|
169
169
|
*/
|
|
170
|
-
export declare function getResourceTypes():
|
|
170
|
+
export declare function getResourceTypes(): ResourceType[];
|
|
171
171
|
/**
|
|
172
172
|
* Returns the type schema for the resource type.
|
|
173
173
|
* @param resourceType The resource type.
|
|
@@ -194,6 +194,20 @@ export declare function getPropertyDisplayName(path: string): string;
|
|
|
194
194
|
* @returns The element definition if found.
|
|
195
195
|
*/
|
|
196
196
|
export declare function getElementDefinition(typeName: string, propertyName: string): ElementDefinition | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* Typeguard to validate that an object is a FHIR resource
|
|
199
|
+
* @param value The object to check
|
|
200
|
+
* @returns True if the input is of type 'object' and contains property 'resourceType'
|
|
201
|
+
*/
|
|
202
|
+
export declare function isResource<T extends Resource = Resource>(value: T | Reference<T> | string | undefined | null): value is T;
|
|
203
|
+
/**
|
|
204
|
+
* Typeguard to validate that an object is a FHIR resource
|
|
205
|
+
* @param value The object to check
|
|
206
|
+
* @returns True if the input is of type 'object' and contains property 'reference'
|
|
207
|
+
*/
|
|
208
|
+
export declare function isReference<T extends Resource>(value: T | Reference<T> | string | undefined | null): value is Reference<T> & {
|
|
209
|
+
reference: string;
|
|
210
|
+
};
|
|
197
211
|
/**
|
|
198
212
|
* Global schema singleton.
|
|
199
213
|
*/
|
package/package.json
CHANGED