@medplum/core 2.1.8 → 2.1.10

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 (50) hide show
  1. package/api-extractor.json +3 -0
  2. package/dist/cjs/index.cjs +3 -3
  3. package/dist/cjs/index.cjs.map +4 -4
  4. package/dist/esm/index.mjs +3 -3
  5. package/dist/esm/index.mjs.map +4 -4
  6. package/dist/types.d.ts +4181 -0
  7. package/package.json +4 -4
  8. package/dist/types/access.d.ts +0 -77
  9. package/dist/types/base-schema.d.ts +0 -7
  10. package/dist/types/base64.d.ts +0 -14
  11. package/dist/types/bundle.d.ts +0 -32
  12. package/dist/types/cache.d.ts +0 -36
  13. package/dist/types/client.d.ts +0 -1728
  14. package/dist/types/config.d.ts +0 -57
  15. package/dist/types/constants.d.ts +0 -6
  16. package/dist/types/contenttype.d.ts +0 -18
  17. package/dist/types/crypto.d.ts +0 -19
  18. package/dist/types/eventtarget.d.ts +0 -18
  19. package/dist/types/fhircast/index.d.ts +0 -115
  20. package/dist/types/fhircast/test-utils.d.ts +0 -2
  21. package/dist/types/fhirlexer/parse.d.ts +0 -55
  22. package/dist/types/fhirlexer/tokenize.d.ts +0 -45
  23. package/dist/types/fhirmapper/parse.d.ts +0 -7
  24. package/dist/types/fhirmapper/tokenize.d.ts +0 -2
  25. package/dist/types/fhirpath/atoms.d.ts +0 -139
  26. package/dist/types/fhirpath/date.d.ts +0 -1
  27. package/dist/types/fhirpath/functions.d.ts +0 -4
  28. package/dist/types/fhirpath/parse.d.ts +0 -65
  29. package/dist/types/fhirpath/tokenize.d.ts +0 -4
  30. package/dist/types/fhirpath/utils.d.ts +0 -96
  31. package/dist/types/filter/parse.d.ts +0 -7
  32. package/dist/types/filter/tokenize.d.ts +0 -2
  33. package/dist/types/filter/types.d.ts +0 -32
  34. package/dist/types/format.d.ts +0 -120
  35. package/dist/types/hl7.d.ts +0 -242
  36. package/dist/types/index.d.ts +0 -34
  37. package/dist/types/jwt.d.ts +0 -18
  38. package/dist/types/outcomes.d.ts +0 -58
  39. package/dist/types/readablepromise.d.ts +0 -51
  40. package/dist/types/schema.d.ts +0 -43
  41. package/dist/types/search/details.d.ts +0 -37
  42. package/dist/types/search/match.d.ts +0 -9
  43. package/dist/types/search/search.d.ts +0 -102
  44. package/dist/types/sftp.d.ts +0 -9
  45. package/dist/types/storage.d.ts +0 -55
  46. package/dist/types/types.d.ts +0 -202
  47. package/dist/types/typeschema/crawler.d.ts +0 -12
  48. package/dist/types/typeschema/types.d.ts +0 -92
  49. package/dist/types/typeschema/validation.d.ts +0 -25
  50. package/dist/types/utils.d.ts +0 -326
@@ -1,102 +0,0 @@
1
- import { Resource } from '@medplum/fhirtypes';
2
- import { TypedValue } from '../types';
3
- export declare const DEFAULT_SEARCH_COUNT = 20;
4
- export interface SearchRequest<T extends Resource = Resource> {
5
- readonly resourceType: T['resourceType'];
6
- filters?: Filter[];
7
- sortRules?: SortRule[];
8
- offset?: number;
9
- count?: number;
10
- fields?: string[];
11
- name?: string;
12
- total?: 'none' | 'estimate' | 'accurate';
13
- include?: IncludeTarget[];
14
- revInclude?: IncludeTarget[];
15
- summary?: 'true' | 'text' | 'data';
16
- }
17
- export interface Filter {
18
- code: string;
19
- operator: Operator;
20
- value: string;
21
- }
22
- export interface SortRule {
23
- code: string;
24
- descending?: boolean;
25
- }
26
- export interface IncludeTarget {
27
- resourceType: string;
28
- searchParam: string;
29
- targetType?: string;
30
- modifier?: string;
31
- }
32
- /**
33
- * Search operators.
34
- * These operators represent "modifiers" and "prefixes" in FHIR search.
35
- * See: https://www.hl7.org/fhir/search.html
36
- */
37
- export declare enum Operator {
38
- EQUALS = "eq",
39
- NOT_EQUALS = "ne",
40
- GREATER_THAN = "gt",
41
- LESS_THAN = "lt",
42
- GREATER_THAN_OR_EQUALS = "ge",
43
- LESS_THAN_OR_EQUALS = "le",
44
- STARTS_AFTER = "sa",
45
- ENDS_BEFORE = "eb",
46
- APPROXIMATELY = "ap",
47
- CONTAINS = "contains",
48
- EXACT = "exact",
49
- TEXT = "text",
50
- NOT = "not",
51
- ABOVE = "above",
52
- BELOW = "below",
53
- IN = "in",
54
- NOT_IN = "not-in",
55
- OF_TYPE = "of-type",
56
- MISSING = "missing",
57
- IDENTIFIER = "identifier",
58
- ITERATE = "iterate"
59
- }
60
- /**
61
- * Parses a search URL into a search request.
62
- * @param resourceType The FHIR resource type.
63
- * @param query The collection of query string parameters.
64
- * @returns A parsed SearchRequest.
65
- */
66
- export declare function parseSearchRequest<T extends Resource = Resource>(resourceType: T['resourceType'], query: Record<string, string[] | string | undefined>): SearchRequest<T>;
67
- /**
68
- * Parses a search URL into a search request.
69
- * @param url The search URL.
70
- * @returns A parsed SearchRequest.
71
- */
72
- export declare function parseSearchUrl<T extends Resource = Resource>(url: URL): SearchRequest<T>;
73
- /**
74
- * Parses a URL string into a SearchRequest.
75
- * @param url The URL to parse.
76
- * @returns Parsed search definition.
77
- */
78
- export declare function parseSearchDefinition<T extends Resource = Resource>(url: string): SearchRequest<T>;
79
- /**
80
- * Parses a FHIR criteria string into a SearchRequest.
81
- * FHIR criteria strings are found on resources such as Subscription.
82
- * @param criteria The FHIR criteria string.
83
- * @returns Parsed search definition.
84
- */
85
- export declare function parseCriteriaAsSearchRequest(criteria: string): SearchRequest;
86
- /**
87
- * Parses an extended FHIR search criteria string (i.e. application/x-fhir-query), evaluating
88
- * any embedded FHIRPath subexpressions (e.g. `{{ %patient.id }}`) with the provided variables.
89
- *
90
- * @see https://hl7.org/fhir/fhir-xquery.html
91
- * @param query The X-Fhir-Query string to parse
92
- * @param variables Values to pass into embedded FHIRPath expressions
93
- * @returns The parsed search request
94
- */
95
- export declare function parseXFhirQuery(query: string, variables: Record<string, TypedValue>): SearchRequest;
96
- /**
97
- * Formats a search definition object into a query string.
98
- * Note: The return value does not include the resource type.
99
- * @param definition The search definition.
100
- * @returns Formatted URL.
101
- */
102
- export declare function formatSearchQuery(definition: SearchRequest): string;
@@ -1,9 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { Readable } from 'stream';
4
- /**
5
- * Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data.
6
- * @param stream - The Readable stream to read from.
7
- * @returns A Promise that resolves with a Buffer containing all the data from the Readable stream.
8
- */
9
- export declare function streamToBuffer(stream: Readable): Promise<Buffer>;
@@ -1,55 +0,0 @@
1
- /**
2
- * The ClientStorage class is a utility class for storing strings and objects.
3
- *
4
- * When using MedplumClient in the browser, it will be backed by browser localStorage.
5
- *
6
- * When Using MedplumClient in the server, it will be backed by the MemoryStorage class. For example, the Medplum CLI uses `FileSystemStorage`.
7
- */
8
- export declare class ClientStorage {
9
- private readonly storage;
10
- constructor();
11
- clear(): void;
12
- getString(key: string): string | undefined;
13
- setString(key: string, value: string | undefined): void;
14
- getObject<T>(key: string): T | undefined;
15
- setObject<T>(key: string, value: T): void;
16
- }
17
- /**
18
- * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.
19
- */
20
- export declare class MemoryStorage implements Storage {
21
- private data;
22
- constructor();
23
- /**
24
- * Returns the number of key/value pairs.
25
- * @returns The number of key/value pairs.
26
- */
27
- get length(): number;
28
- /**
29
- * Removes all key/value pairs, if there are any.
30
- */
31
- clear(): void;
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.
36
- */
37
- getItem(key: string): string | null;
38
- /**
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.
42
- */
43
- setItem(key: string, value: string | null): void;
44
- /**
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.
47
- */
48
- removeItem(key: string): void;
49
- /**
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.
53
- */
54
- key(index: number): string | null;
55
- }
@@ -1,202 +0,0 @@
1
- import { Bundle, ElementDefinition, Reference, Resource, ResourceType, SearchParameter } from '@medplum/fhirtypes';
2
- import { SearchParameterDetails } from './search/details';
3
- import { InternalSchemaElement, InternalTypeSchema } from './typeschema/types';
4
- export interface TypedValue {
5
- readonly type: string;
6
- readonly value: any;
7
- }
8
- /**
9
- * List of property types.
10
- * http://www.hl7.org/fhir/valueset-defined-types.html
11
- * The list here includes additions found from StructureDefinition resources.
12
- */
13
- export declare const PropertyType: {
14
- Address: string;
15
- Age: string;
16
- Annotation: string;
17
- Attachment: string;
18
- BackboneElement: string;
19
- CodeableConcept: string;
20
- Coding: string;
21
- ContactDetail: string;
22
- ContactPoint: string;
23
- Contributor: string;
24
- Count: string;
25
- DataRequirement: string;
26
- Distance: string;
27
- Dosage: string;
28
- Duration: string;
29
- Expression: string;
30
- Extension: string;
31
- HumanName: string;
32
- Identifier: string;
33
- MarketingStatus: string;
34
- Meta: string;
35
- Money: string;
36
- Narrative: string;
37
- ParameterDefinition: string;
38
- Period: string;
39
- Population: string;
40
- ProdCharacteristic: string;
41
- ProductShelfLife: string;
42
- Quantity: string;
43
- Range: string;
44
- Ratio: string;
45
- Reference: string;
46
- RelatedArtifact: string;
47
- SampledData: string;
48
- Signature: string;
49
- SubstanceAmount: string;
50
- SystemString: string;
51
- Timing: string;
52
- TriggerDefinition: string;
53
- UsageContext: string;
54
- base64Binary: string;
55
- boolean: string;
56
- canonical: string;
57
- code: string;
58
- date: string;
59
- dateTime: string;
60
- decimal: string;
61
- id: string;
62
- instant: string;
63
- integer: string;
64
- markdown: string;
65
- oid: string;
66
- positiveInt: string;
67
- string: string;
68
- time: string;
69
- unsignedInt: string;
70
- uri: string;
71
- url: string;
72
- uuid: string;
73
- };
74
- /**
75
- * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.
76
- *
77
- * StructureDefinition resources contain schema information for other resource types.
78
- * These schemas can be used to automatically generate user interface elements for
79
- * resources.
80
- *
81
- * However, a StructureDefinition resource is not optimized for realtime lookups. All
82
- * resource types, sub types, and property definitions are stored in a flat array of
83
- * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., "Patient.name")
84
- * requires a linear scan of all ElementDefinition objects
85
- *
86
- * A StructureDefinition resource contains information about one or more types.
87
- * For example, the "Patient" StructureDefinition includes "Patient", "Patient_Contact",
88
- * "Patient_Communication", and "Patient_Link". This is inefficient.
89
- *
90
- * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.
91
- * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.
92
- *
93
- * The hierarchy is:
94
- * IndexedStructureDefinition - top level for one resource type
95
- * TypeSchema - one per resource type and all contained BackboneElements
96
- * PropertySchema - one per property/field
97
- */
98
- export interface IndexedStructureDefinition {
99
- types: {
100
- [resourceType: string]: TypeInfo;
101
- };
102
- }
103
- /**
104
- * An indexed TypeSchema.
105
- *
106
- * Example: The IndexedStructureDefinition for "Patient" would include the following TypeSchemas:
107
- * 1) Patient
108
- * 2) Patient_Contact
109
- * 3) Patient_Communication
110
- * 4) Patient_Link
111
- */
112
- export interface TypeInfo {
113
- searchParams?: {
114
- [code: string]: SearchParameter;
115
- };
116
- searchParamsDetails?: {
117
- [code: string]: SearchParameterDetails;
118
- };
119
- }
120
- /**
121
- * Indexes a bundle of SearchParameter resources for faster lookup.
122
- * @param bundle A FHIR bundle SearchParameter resources.
123
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
124
- */
125
- export declare function indexSearchParameterBundle(bundle: Bundle<SearchParameter>): void;
126
- /**
127
- * Indexes a SearchParameter resource for fast lookup.
128
- * Indexes by SearchParameter.code, which is the query string parameter name.
129
- * @param searchParam The SearchParameter resource.
130
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
131
- */
132
- export declare function indexSearchParameter(searchParam: SearchParameter): void;
133
- /**
134
- * Returns the type name for an ElementDefinition.
135
- * @param elementDefinition The element definition.
136
- * @returns The Medplum type name.
137
- */
138
- export declare function getElementDefinitionTypeName(elementDefinition: ElementDefinition): string;
139
- export declare function buildTypeName(components: string[]): string;
140
- /**
141
- * Returns true if the type schema is a non-abstract FHIR resource.
142
- * @param typeSchema The type schema to check.
143
- * @returns True if the type schema is a non-abstract FHIR resource.
144
- */
145
- export declare function isResourceTypeSchema(typeSchema: InternalTypeSchema): boolean;
146
- /**
147
- * Returns an array of all resource types.
148
- * Note that this is based on globalSchema, and will only return resource types that are currently in memory.
149
- * @returns An array of all resource types.
150
- */
151
- export declare function getResourceTypes(): ResourceType[];
152
- /**
153
- * Returns the search parameters for the resource type indexed by search code.
154
- * @param resourceType The resource type.
155
- * @returns The search parameters for the resource type indexed by search code.
156
- */
157
- export declare function getSearchParameters(resourceType: string): Record<string, SearchParameter> | undefined;
158
- /**
159
- * Returns a search parameter for a resource type by search code.
160
- * @param resourceType The FHIR resource type.
161
- * @param code The search parameter code.
162
- * @returns The search parameter if found, otherwise undefined.
163
- */
164
- export declare function getSearchParameter(resourceType: string, code: string): SearchParameter | undefined;
165
- /**
166
- * Returns a human friendly display name for a FHIR element definition path.
167
- * @param path The FHIR element definition path.
168
- * @returns The best guess of the display name.
169
- */
170
- export declare function getPropertyDisplayName(path: string): string;
171
- /**
172
- * Returns an element definition by type and property name.
173
- * Handles content references.
174
- * @param typeName The type name.
175
- * @param propertyName The property name.
176
- * @returns The element definition if found.
177
- */
178
- export declare function getElementDefinition(typeName: string, propertyName: string): InternalSchemaElement | undefined;
179
- /**
180
- * Typeguard to validate that an object is a FHIR resource
181
- * @param value The object to check
182
- * @returns True if the input is of type 'object' and contains property 'resourceType'
183
- */
184
- export declare function isResource(value: unknown): value is Resource;
185
- /**
186
- * Typeguard to validate that an object is a FHIR resource
187
- * @param value The object to check
188
- * @returns True if the input is of type 'object' and contains property 'reference'
189
- */
190
- export declare function isReference(value: unknown): value is Reference & {
191
- reference: string;
192
- };
193
- /**
194
- * Global schema singleton.
195
- */
196
- export declare const globalSchema: IndexedStructureDefinition;
197
- /**
198
- * Output the string representation of a value, suitable for use as part of a search query.
199
- * @param v The value to format as a string
200
- * @returns The stringified value
201
- */
202
- export declare function stringifyTypedValue(v: TypedValue): string;
@@ -1,12 +0,0 @@
1
- import { Resource } from '@medplum/fhirtypes';
2
- import { TypedValue } from '../types';
3
- import { InternalTypeSchema } from './types';
4
- export interface ResourceVisitor {
5
- onEnterObject?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
6
- onExitObject?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
7
- onEnterResource?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
8
- onExitResource?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
9
- visitProperty?: (parent: TypedValue, key: string, path: string, propertyValues: (TypedValue | TypedValue[] | undefined)[], schema: InternalTypeSchema) => void;
10
- }
11
- export declare function crawlResource(resource: Resource, visitor: ResourceVisitor, schema?: InternalTypeSchema, initialPath?: string): void;
12
- export declare function getNestedProperty(value: TypedValue, key: string): (TypedValue | TypedValue[] | undefined)[];
@@ -1,92 +0,0 @@
1
- import { Bundle, ElementDefinitionBinding, Resource, 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: string;
8
- url?: string;
9
- kind?: string;
10
- description?: string;
11
- elements: Record<string, InternalSchemaElement>;
12
- constraints?: Constraint[];
13
- parentType?: InternalTypeSchema;
14
- innerTypes: InternalTypeSchema[];
15
- summaryProperties?: Set<string>;
16
- mandatoryProperties?: Set<string>;
17
- }
18
- export interface InternalSchemaElement {
19
- description: string;
20
- path: string;
21
- min: number;
22
- max: number;
23
- isArray?: boolean;
24
- constraints?: Constraint[];
25
- type: ElementType[];
26
- slicing?: SlicingRules;
27
- fixed?: TypedValue;
28
- pattern?: TypedValue;
29
- binding?: ElementDefinitionBinding;
30
- }
31
- export interface ElementType {
32
- code: string;
33
- targetProfile?: string[];
34
- }
35
- export interface Constraint {
36
- key: string;
37
- severity: 'error' | 'warning';
38
- expression: string;
39
- description: string;
40
- }
41
- export interface SlicingRules {
42
- discriminator: SliceDiscriminator[];
43
- ordered: boolean;
44
- rule?: 'open' | 'closed' | 'openAtEnd';
45
- slices: SliceDefinition[];
46
- }
47
- export interface SliceDefinition {
48
- name: string;
49
- type?: ElementType[];
50
- elements: Record<string, InternalSchemaElement>;
51
- min: number;
52
- max: number;
53
- }
54
- export interface SliceDiscriminator {
55
- path: string;
56
- type: string;
57
- }
58
- /**
59
- * Parses a StructureDefinition resource into an internal schema better suited for
60
- * programmatic validation and usage in internal systems
61
- * @param sd The StructureDefinition resource to parse
62
- * @returns The parsed schema for the given resource type
63
- * @experimental
64
- */
65
- export declare function parseStructureDefinition(sd: StructureDefinition): InternalTypeSchema;
66
- export declare function indexStructureDefinitionBundle(bundle: StructureDefinition[] | Bundle): void;
67
- export declare function loadDataType(sd: StructureDefinition): void;
68
- export declare function getAllDataTypes(): Record<string, InternalTypeSchema>;
69
- export declare function isDataTypeLoaded(type: string): boolean;
70
- export declare function tryGetDataType(type: string): InternalTypeSchema | undefined;
71
- export declare function getDataType(type: string): InternalTypeSchema;
72
- /**
73
- * Returns true if the given string is a valid FHIR resource type.
74
- *
75
- * ```ts
76
- * isResourceType('Patient'); // true
77
- * isResourceType('XYZ'); // false
78
- * ```
79
- *
80
- * @param resourceType The candidate resource type string.
81
- * @returns True if the resource type is a valid FHIR resource type.
82
- */
83
- export declare function isResourceType(resourceType: string): boolean;
84
- /**
85
- * Construct the subset of a resource containing a minimum set of fields. The returned resource is not guaranteed
86
- * to contain only the provided properties, and may contain others (e.g. `resourceType` and `id`)
87
- *
88
- * @param resource The resource to subset
89
- * @param properties The minimum properties to include in the subset
90
- * @returns The modified resource, containing the listed properties and possibly other mandatory ones
91
- */
92
- export declare function subsetResource<T extends Resource>(resource: T | undefined, properties: string[]): T | undefined;
@@ -1,25 +0,0 @@
1
- import { Resource, StructureDefinition } from '@medplum/fhirtypes';
2
- export declare const fhirTypeToJsType: {
3
- readonly base64Binary: "string";
4
- readonly boolean: "boolean";
5
- readonly canonical: "string";
6
- readonly code: "string";
7
- readonly date: "string";
8
- readonly dateTime: "string";
9
- readonly decimal: "number";
10
- readonly id: "string";
11
- readonly instant: "string";
12
- readonly integer: "number";
13
- readonly markdown: "string";
14
- readonly oid: "string";
15
- readonly positiveInt: "number";
16
- readonly string: "string";
17
- readonly time: "string";
18
- readonly unsignedInt: "number";
19
- readonly uri: "string";
20
- readonly url: "string";
21
- readonly uuid: "string";
22
- readonly xhtml: "string";
23
- readonly 'http://hl7.org/fhirpath/System.String': "string";
24
- };
25
- export declare function validateResource(resource: Resource, profile?: StructureDefinition): void;