@medplum/core 2.0.4 → 2.0.5

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 (71) hide show
  1. package/dist/cjs/index.cjs +35 -21
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.min.cjs +1 -1
  4. package/dist/esm/client.mjs +10 -17
  5. package/dist/esm/client.mjs.map +1 -1
  6. package/dist/esm/index.min.mjs +1 -1
  7. package/dist/esm/index.mjs +1 -1
  8. package/dist/esm/outcomes.mjs +17 -2
  9. package/dist/esm/outcomes.mjs.map +1 -1
  10. package/dist/esm/search/match.mjs +9 -4
  11. package/dist/esm/search/match.mjs.map +1 -1
  12. package/dist/{esm → types}/outcomes.d.ts +7 -1
  13. package/package.json +4 -4
  14. package/tsconfig.build.json +9 -0
  15. package/dist/cjs/outcomes.d.ts +0 -31
  16. package/dist/esm/cache.d.ts +0 -34
  17. package/dist/esm/client.d.ts +0 -1218
  18. package/dist/esm/crypto.d.ts +0 -9
  19. package/dist/esm/eventtarget.d.ts +0 -13
  20. package/dist/esm/fhirlexer/index.d.ts +0 -2
  21. package/dist/esm/fhirlexer/parse.d.ts +0 -47
  22. package/dist/esm/fhirlexer/tokenize.d.ts +0 -14
  23. package/dist/esm/fhirmapper/parse.d.ts +0 -7
  24. package/dist/esm/fhirmapper/tokenize.d.ts +0 -2
  25. package/dist/esm/fhirpath/atoms.d.ts +0 -120
  26. package/dist/esm/fhirpath/date.d.ts +0 -1
  27. package/dist/esm/fhirpath/functions.d.ts +0 -6
  28. package/dist/esm/fhirpath/index.d.ts +0 -4
  29. package/dist/esm/fhirpath/parse.d.ts +0 -64
  30. package/dist/esm/fhirpath/tokenize.d.ts +0 -4
  31. package/dist/esm/fhirpath/utils.d.ts +0 -95
  32. package/dist/esm/format.d.ts +0 -118
  33. package/dist/esm/hl7.d.ts +0 -136
  34. package/dist/esm/index.d.ts +0 -14
  35. package/dist/esm/jwt.d.ts +0 -5
  36. package/dist/esm/readablepromise.d.ts +0 -48
  37. package/dist/esm/search/details.d.ts +0 -33
  38. package/dist/esm/search/match.d.ts +0 -9
  39. package/dist/esm/search/parse.d.ts +0 -17
  40. package/dist/esm/search/search.d.ts +0 -66
  41. package/dist/esm/storage.d.ts +0 -47
  42. package/dist/esm/types.d.ts +0 -200
  43. package/dist/esm/utils.d.ts +0 -259
  44. /package/dist/{cjs → types}/cache.d.ts +0 -0
  45. /package/dist/{cjs → types}/client.d.ts +0 -0
  46. /package/dist/{cjs → types}/crypto.d.ts +0 -0
  47. /package/dist/{cjs → types}/eventtarget.d.ts +0 -0
  48. /package/dist/{cjs → types}/fhirlexer/index.d.ts +0 -0
  49. /package/dist/{cjs → types}/fhirlexer/parse.d.ts +0 -0
  50. /package/dist/{cjs → types}/fhirlexer/tokenize.d.ts +0 -0
  51. /package/dist/{cjs → types}/fhirmapper/parse.d.ts +0 -0
  52. /package/dist/{cjs → types}/fhirmapper/tokenize.d.ts +0 -0
  53. /package/dist/{cjs → types}/fhirpath/atoms.d.ts +0 -0
  54. /package/dist/{cjs → types}/fhirpath/date.d.ts +0 -0
  55. /package/dist/{cjs → types}/fhirpath/functions.d.ts +0 -0
  56. /package/dist/{cjs → types}/fhirpath/index.d.ts +0 -0
  57. /package/dist/{cjs → types}/fhirpath/parse.d.ts +0 -0
  58. /package/dist/{cjs → types}/fhirpath/tokenize.d.ts +0 -0
  59. /package/dist/{cjs → types}/fhirpath/utils.d.ts +0 -0
  60. /package/dist/{cjs → types}/format.d.ts +0 -0
  61. /package/dist/{cjs → types}/hl7.d.ts +0 -0
  62. /package/dist/{cjs → types}/index.d.ts +0 -0
  63. /package/dist/{cjs → types}/jwt.d.ts +0 -0
  64. /package/dist/{cjs → types}/readablepromise.d.ts +0 -0
  65. /package/dist/{cjs → types}/search/details.d.ts +0 -0
  66. /package/dist/{cjs → types}/search/match.d.ts +0 -0
  67. /package/dist/{cjs → types}/search/parse.d.ts +0 -0
  68. /package/dist/{cjs → types}/search/search.d.ts +0 -0
  69. /package/dist/{cjs → types}/storage.d.ts +0 -0
  70. /package/dist/{cjs → types}/types.d.ts +0 -0
  71. /package/dist/{cjs → types}/utils.d.ts +0 -0
package/dist/esm/jwt.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Parses the JWT payload.
3
- * @param token JWT token
4
- */
5
- export declare function parseJWTPayload(token: string): Record<string, number | string>;
@@ -1,48 +0,0 @@
1
- /**
2
- * The ReadablePromise class wraps a request promise suitable for React Suspense.
3
- * See: https://blog.logrocket.com/react-suspense-data-fetching/#wrappromise-js
4
- * See: https://github.com/ovieokeh/suspense-data-fetching/blob/master/lib/api/wrapPromise.js
5
- */
6
- export declare class ReadablePromise<T> implements Promise<T> {
7
- #private;
8
- readonly [Symbol.toStringTag]: string;
9
- constructor(requestPromise: Promise<T>);
10
- /**
11
- * Returns true if the promise is pending.
12
- * @returns True if the Promise is pending.
13
- */
14
- isPending(): boolean;
15
- /**
16
- * Returns true if the promise resolved successfully.
17
- * @returns True if the Promise resolved successfully.
18
- */
19
- isOk(): boolean;
20
- /**
21
- * Attempts to read the value of the promise.
22
- * If the promise is pending, this method will throw a promise.
23
- * If the promise rejected, this method will throw the rejection reason.
24
- * If the promise resolved, this method will return the resolved value.
25
- * @returns The resolved value of the Promise.
26
- */
27
- read(): T;
28
- /**
29
- * Attaches callbacks for the resolution and/or rejection of the Promise.
30
- * @param onfulfilled The callback to execute when the Promise is resolved.
31
- * @param onrejected The callback to execute when the Promise is rejected.
32
- * @returns A Promise for the completion of which ever callback is executed.
33
- */
34
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
35
- /**
36
- * Attaches a callback for only the rejection of the Promise.
37
- * @param onrejected The callback to execute when the Promise is rejected.
38
- * @returns A Promise for the completion of the callback.
39
- */
40
- catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
41
- /**
42
- * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
43
- * resolved value cannot be modified from the callback.
44
- * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
45
- * @returns A Promise for the completion of the callback.
46
- */
47
- finally(onfinally?: (() => void) | undefined | null): Promise<T>;
48
- }
@@ -1,33 +0,0 @@
1
- import { ElementDefinition, SearchParameter } from '@medplum/fhirtypes';
2
- export declare enum SearchParameterType {
3
- BOOLEAN = "BOOLEAN",
4
- NUMBER = "NUMBER",
5
- QUANTITY = "QUANTITY",
6
- TEXT = "TEXT",
7
- REFERENCE = "REFERENCE",
8
- DATE = "DATE",
9
- DATETIME = "DATETIME",
10
- PERIOD = "PERIOD"
11
- }
12
- export interface SearchParameterDetails {
13
- readonly columnName: string;
14
- readonly type: SearchParameterType;
15
- readonly elementDefinition?: ElementDefinition;
16
- readonly array?: boolean;
17
- }
18
- /**
19
- * Returns the type details of a SearchParameter.
20
- *
21
- * The SearchParameter resource has a "type" parameter, but that is missing some critical information.
22
- *
23
- * For example:
24
- * 1) The "date" type includes "date", "datetime", and "period".
25
- * 2) The "token" type includes enums and booleans.
26
- * 3) Arrays/multiple values are not reflected at all.
27
- *
28
- * @param resourceType The root resource type.
29
- * @param searchParam The search parameter.
30
- * @returns The search parameter type details.
31
- */
32
- export declare function getSearchParameterDetails(resourceType: string, searchParam: SearchParameter): SearchParameterDetails;
33
- export declare function getExpressionForResourceType(resourceType: string, expression: string): string | undefined;
@@ -1,9 +0,0 @@
1
- import { Resource } from '@medplum/fhirtypes';
2
- import { SearchRequest } from './search';
3
- /**
4
- * Determines if the resource matches the search request.
5
- * @param resource The resource that was created or updated.
6
- * @param searchRequest The subscription criteria as a search request.
7
- * @returns True if the resource satisfies the search request.
8
- */
9
- export declare function matchesSearchRequest(resource: Resource, searchRequest: SearchRequest): boolean;
@@ -1,17 +0,0 @@
1
- /// <reference types="node" />
2
- import { ResourceType } from '@medplum/fhirtypes';
3
- import { URL } from 'url';
4
- import { SearchRequest } from './search';
5
- /**
6
- * Parses a search URL into a search request.
7
- * @param resourceType The FHIR resource type.
8
- * @param query The collection of query string parameters.
9
- * @returns A parsed SearchRequest.
10
- */
11
- export declare function parseSearchRequest(resourceType: ResourceType, query: Record<string, string[] | string | undefined>): SearchRequest;
12
- /**
13
- * Parses a search URL into a search request.
14
- * @param url The search URL.
15
- * @returns A parsed SearchRequest.
16
- */
17
- export declare function parseSearchUrl(url: URL): SearchRequest;
@@ -1,66 +0,0 @@
1
- import { ResourceType } from '@medplum/fhirtypes';
2
- export declare const DEFAULT_SEARCH_COUNT = 20;
3
- export interface SearchRequest {
4
- readonly resourceType: ResourceType;
5
- filters?: Filter[];
6
- sortRules?: SortRule[];
7
- offset?: number;
8
- count?: number;
9
- fields?: string[];
10
- name?: string;
11
- total?: 'none' | 'estimate' | 'accurate';
12
- revInclude?: string;
13
- }
14
- export interface Filter {
15
- code: string;
16
- operator: Operator;
17
- value: string;
18
- unitSystem?: string;
19
- unitCode?: string;
20
- }
21
- export interface SortRule {
22
- code: string;
23
- descending?: boolean;
24
- }
25
- /**
26
- * Search operators.
27
- * These operators represent "modifiers" and "prefixes" in FHIR search.
28
- * See: https://www.hl7.org/fhir/search.html
29
- */
30
- export declare enum Operator {
31
- EQUALS = "eq",
32
- NOT_EQUALS = "ne",
33
- GREATER_THAN = "gt",
34
- LESS_THAN = "lt",
35
- GREATER_THAN_OR_EQUALS = "ge",
36
- LESS_THAN_OR_EQUALS = "le",
37
- STARTS_AFTER = "sa",
38
- ENDS_BEFORE = "eb",
39
- APPROXIMATELY = "ap",
40
- CONTAINS = "contains",
41
- EXACT = "exact",
42
- TEXT = "text",
43
- NOT = "not",
44
- ABOVE = "above",
45
- BELOW = "below",
46
- IN = "in",
47
- NOT_IN = "not-in",
48
- OF_TYPE = "of-type",
49
- MISSING = "missing"
50
- }
51
- /**
52
- * Parses a URL into a SearchRequest.
53
- *
54
- * See the FHIR search spec: http://hl7.org/fhir/r4/search.html
55
- *
56
- * @param url The URL to parse.
57
- * @returns Parsed search definition.
58
- */
59
- export declare function parseSearchDefinition(url: string): SearchRequest;
60
- /**
61
- * Formats a search definition object into a query string.
62
- * Note: The return value does not include the resource type.
63
- * @param {!SearchRequest} definition The search definition.
64
- * @returns Formatted URL.
65
- */
66
- export declare function formatSearchQuery(definition: SearchRequest): string;
@@ -1,47 +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.
7
- */
8
- export declare class ClientStorage {
9
- #private;
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;
22
- constructor();
23
- /**
24
- * Returns the number of key/value pairs.
25
- */
26
- get length(): number;
27
- /**
28
- * Removes all key/value pairs, if there are any.
29
- */
30
- clear(): void;
31
- /**
32
- * Returns the current value associated with the given key, or null if the given key does not exist.
33
- */
34
- getItem(key: string): string | null;
35
- /**
36
- * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
37
- */
38
- setItem(key: string, value: string | null): void;
39
- /**
40
- * Removes the key/value pair with the given key, if a key/value pair with the given key exists.
41
- */
42
- removeItem(key: string): void;
43
- /**
44
- * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
45
- */
46
- key(index: number): string | null;
47
- }
@@ -1,200 +0,0 @@
1
- import { Bundle, ElementDefinition, SearchParameter, StructureDefinition } from '@medplum/fhirtypes';
2
- import { SearchParameterDetails } from './search/details';
3
- export interface TypedValue {
4
- readonly type: string;
5
- readonly value: any;
6
- }
7
- /**
8
- * List of property types.
9
- * http://www.hl7.org/fhir/valueset-defined-types.html
10
- * The list here includes additions found from StructureDefinition resources.
11
- */
12
- export declare enum PropertyType {
13
- Address = "Address",
14
- Age = "Age",
15
- Annotation = "Annotation",
16
- Attachment = "Attachment",
17
- BackboneElement = "BackboneElement",
18
- CodeableConcept = "CodeableConcept",
19
- Coding = "Coding",
20
- ContactDetail = "ContactDetail",
21
- ContactPoint = "ContactPoint",
22
- Contributor = "Contributor",
23
- Count = "Count",
24
- DataRequirement = "DataRequirement",
25
- Distance = "Distance",
26
- Dosage = "Dosage",
27
- Duration = "Duration",
28
- Expression = "Expression",
29
- Extension = "Extension",
30
- HumanName = "HumanName",
31
- Identifier = "Identifier",
32
- MarketingStatus = "MarketingStatus",
33
- Meta = "Meta",
34
- Money = "Money",
35
- Narrative = "Narrative",
36
- ParameterDefinition = "ParameterDefinition",
37
- Period = "Period",
38
- Population = "Population",
39
- ProdCharacteristic = "ProdCharacteristic",
40
- ProductShelfLife = "ProductShelfLife",
41
- Quantity = "Quantity",
42
- Range = "Range",
43
- Ratio = "Ratio",
44
- Reference = "Reference",
45
- RelatedArtifact = "RelatedArtifact",
46
- SampledData = "SampledData",
47
- Signature = "Signature",
48
- SubstanceAmount = "SubstanceAmount",
49
- SystemString = "http://hl7.org/fhirpath/System.String",
50
- Timing = "Timing",
51
- TriggerDefinition = "TriggerDefinition",
52
- UsageContext = "UsageContext",
53
- base64Binary = "base64Binary",
54
- boolean = "boolean",
55
- canonical = "canonical",
56
- code = "code",
57
- date = "date",
58
- dateTime = "dateTime",
59
- decimal = "decimal",
60
- id = "id",
61
- instant = "instant",
62
- integer = "integer",
63
- markdown = "markdown",
64
- oid = "oid",
65
- positiveInt = "positiveInt",
66
- string = "string",
67
- time = "time",
68
- unsignedInt = "unsignedInt",
69
- uri = "uri",
70
- url = "url",
71
- uuid = "uuid"
72
- }
73
- /**
74
- * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.
75
- *
76
- * StructureDefinition resources contain schema information for other resource types.
77
- * These schemas can be used to automatically generate user interface elements for
78
- * resources.
79
- *
80
- * However, a StructureDefinition resource is not optimized for realtime lookups. All
81
- * resource types, sub types, and property definitions are stored in a flat array of
82
- * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., "Patient.name")
83
- * requires a linear scan of all ElementDefinition objects
84
- *
85
- * A StructureDefinition resource contains information about one or more types.
86
- * For example, the "Patient" StructureDefinition includes "Patient", "Patient_Contact",
87
- * "Patient_Communication", and "Patient_Link". This is inefficient.
88
- *
89
- * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.
90
- * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.
91
- *
92
- * The hierarchy is:
93
- * IndexedStructureDefinition - top level for one resource type
94
- * TypeSchema - one per resource type and all contained BackboneElements
95
- * PropertySchema - one per property/field
96
- */
97
- export interface IndexedStructureDefinition {
98
- types: {
99
- [resourceType: string]: TypeSchema;
100
- };
101
- }
102
- /**
103
- * An indexed TypeSchema.
104
- *
105
- * Example: The IndexedStructureDefinition for "Patient" would include the following TypeSchemas:
106
- * 1) Patient
107
- * 2) Patient_Contact
108
- * 3) Patient_Communication
109
- * 4) Patient_Link
110
- */
111
- export interface TypeSchema {
112
- structureDefinition: StructureDefinition;
113
- elementDefinition: ElementDefinition;
114
- display: string;
115
- properties: {
116
- [name: string]: ElementDefinition;
117
- };
118
- searchParams?: {
119
- [code: string]: SearchParameter;
120
- };
121
- searchParamsDetails?: {
122
- [code: string]: SearchParameterDetails;
123
- };
124
- description?: string;
125
- parentType?: string;
126
- }
127
- /**
128
- * Indexes a bundle of StructureDefinitions for faster lookup.
129
- * @param bundle A FHIR bundle StructureDefinition resources.
130
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
131
- */
132
- export declare function indexStructureDefinitionBundle(bundle: Bundle): void;
133
- /**
134
- * Indexes a StructureDefinition for fast lookup.
135
- * @param structureDefinition The original StructureDefinition.
136
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
137
- */
138
- export declare function indexStructureDefinition(structureDefinition: StructureDefinition): void;
139
- /**
140
- * Indexes a bundle of SearchParameter resources for faster lookup.
141
- * @param bundle A FHIR bundle SearchParameter resources.
142
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
143
- */
144
- export declare function indexSearchParameterBundle(bundle: Bundle<SearchParameter>): void;
145
- /**
146
- * Indexes a SearchParameter resource for fast lookup.
147
- * Indexes by SearchParameter.code, which is the query string parameter name.
148
- * @param searchParam The SearchParameter resource.
149
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
150
- */
151
- export declare function indexSearchParameter(searchParam: SearchParameter): void;
152
- /**
153
- * Returns the type name for an ElementDefinition.
154
- * @param elementDefinition The element definition.
155
- * @returns The Medplum type name.
156
- */
157
- export declare function getElementDefinitionTypeName(elementDefinition: ElementDefinition): string;
158
- export declare function buildTypeName(components: string[]): string;
159
- /**
160
- * Returns true if the type schema is a DomainResource.
161
- * @param typeSchema The type schema to check.
162
- * @returns True if the type schema is a DomainResource.
163
- */
164
- export declare function isResourceType(typeSchema: TypeSchema): boolean;
165
- /**
166
- * Returns an array of all resource types.
167
- * Note that this is based on globalSchema, and will only return resource types that are currently in memory.
168
- * @returns An array of all resource types.
169
- */
170
- export declare function getResourceTypes(): string[];
171
- /**
172
- * Returns the type schema for the resource type.
173
- * @param resourceType The resource type.
174
- * @returns The type schema for the resource type.
175
- */
176
- export declare function getResourceTypeSchema(resourceType: string): TypeSchema;
177
- /**
178
- * Returns the search parameters for the resource type indexed by search code.
179
- * @param resourceType The resource type.
180
- * @returns The search parameters for the resource type indexed by search code.
181
- */
182
- export declare function getSearchParameters(resourceType: string): Record<string, SearchParameter> | undefined;
183
- /**
184
- * Returns a human friendly display name for a FHIR element definition path.
185
- * @param path The FHIR element definition path.
186
- * @returns The best guess of the display name.
187
- */
188
- export declare function getPropertyDisplayName(path: string): string;
189
- /**
190
- * Returns an element definition by type and property name.
191
- * Handles content references.
192
- * @param typeName The type name.
193
- * @param propertyName The property name.
194
- * @returns The element definition if found.
195
- */
196
- export declare function getElementDefinition(typeName: string, propertyName: string): ElementDefinition | undefined;
197
- /**
198
- * Global schema singleton.
199
- */
200
- export declare const globalSchema: IndexedStructureDefinition;