@medplum/core 2.0.24 → 2.0.25

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 (81) hide show
  1. package/dist/cjs/index.cjs +28 -14114
  2. package/dist/cjs/index.cjs.map +7 -1
  3. package/dist/esm/index.mjs +31 -29
  4. package/dist/esm/index.mjs.map +7 -1
  5. package/dist/types/utils.d.ts +14 -0
  6. package/package.json +2 -2
  7. package/dist/cjs/index.min.cjs +0 -1
  8. package/dist/esm/access.mjs +0 -142
  9. package/dist/esm/access.mjs.map +0 -1
  10. package/dist/esm/base-schema.json.mjs +0 -4408
  11. package/dist/esm/base-schema.json.mjs.map +0 -1
  12. package/dist/esm/base64.mjs +0 -33
  13. package/dist/esm/base64.mjs.map +0 -1
  14. package/dist/esm/bundle.mjs +0 -36
  15. package/dist/esm/bundle.mjs.map +0 -1
  16. package/dist/esm/cache.mjs +0 -64
  17. package/dist/esm/cache.mjs.map +0 -1
  18. package/dist/esm/client.mjs +0 -2168
  19. package/dist/esm/client.mjs.map +0 -1
  20. package/dist/esm/crypto.mjs +0 -22
  21. package/dist/esm/crypto.mjs.map +0 -1
  22. package/dist/esm/eventtarget.mjs +0 -36
  23. package/dist/esm/eventtarget.mjs.map +0 -1
  24. package/dist/esm/fhirlexer/parse.mjs +0 -122
  25. package/dist/esm/fhirlexer/parse.mjs.map +0 -1
  26. package/dist/esm/fhirlexer/tokenize.mjs +0 -231
  27. package/dist/esm/fhirlexer/tokenize.mjs.map +0 -1
  28. package/dist/esm/fhirmapper/parse.mjs +0 -329
  29. package/dist/esm/fhirmapper/parse.mjs.map +0 -1
  30. package/dist/esm/fhirmapper/tokenize.mjs +0 -13
  31. package/dist/esm/fhirmapper/tokenize.mjs.map +0 -1
  32. package/dist/esm/fhirpath/atoms.mjs +0 -347
  33. package/dist/esm/fhirpath/atoms.mjs.map +0 -1
  34. package/dist/esm/fhirpath/date.mjs +0 -24
  35. package/dist/esm/fhirpath/date.mjs.map +0 -1
  36. package/dist/esm/fhirpath/functions.mjs +0 -1626
  37. package/dist/esm/fhirpath/functions.mjs.map +0 -1
  38. package/dist/esm/fhirpath/parse.mjs +0 -145
  39. package/dist/esm/fhirpath/parse.mjs.map +0 -1
  40. package/dist/esm/fhirpath/tokenize.mjs +0 -10
  41. package/dist/esm/fhirpath/tokenize.mjs.map +0 -1
  42. package/dist/esm/fhirpath/utils.mjs +0 -377
  43. package/dist/esm/fhirpath/utils.mjs.map +0 -1
  44. package/dist/esm/filter/parse.mjs +0 -101
  45. package/dist/esm/filter/parse.mjs.map +0 -1
  46. package/dist/esm/filter/tokenize.mjs +0 -16
  47. package/dist/esm/filter/tokenize.mjs.map +0 -1
  48. package/dist/esm/filter/types.mjs +0 -34
  49. package/dist/esm/filter/types.mjs.map +0 -1
  50. package/dist/esm/format.mjs +0 -390
  51. package/dist/esm/format.mjs.map +0 -1
  52. package/dist/esm/hl7.mjs +0 -242
  53. package/dist/esm/hl7.mjs.map +0 -1
  54. package/dist/esm/index.min.mjs +0 -1
  55. package/dist/esm/jwt.mjs +0 -30
  56. package/dist/esm/jwt.mjs.map +0 -1
  57. package/dist/esm/node_modules/tslib/package.json +0 -1
  58. package/dist/esm/outcomes.mjs +0 -295
  59. package/dist/esm/outcomes.mjs.map +0 -1
  60. package/dist/esm/readablepromise.mjs +0 -82
  61. package/dist/esm/readablepromise.mjs.map +0 -1
  62. package/dist/esm/schema.mjs +0 -417
  63. package/dist/esm/schema.mjs.map +0 -1
  64. package/dist/esm/search/details.mjs +0 -162
  65. package/dist/esm/search/details.mjs.map +0 -1
  66. package/dist/esm/search/match.mjs +0 -166
  67. package/dist/esm/search/match.mjs.map +0 -1
  68. package/dist/esm/search/search.mjs +0 -378
  69. package/dist/esm/search/search.mjs.map +0 -1
  70. package/dist/esm/sftp.mjs +0 -24
  71. package/dist/esm/sftp.mjs.map +0 -1
  72. package/dist/esm/storage.mjs +0 -95
  73. package/dist/esm/storage.mjs.map +0 -1
  74. package/dist/esm/types.mjs +0 -370
  75. package/dist/esm/types.mjs.map +0 -1
  76. package/dist/esm/typeschema/types.mjs +0 -278
  77. package/dist/esm/typeschema/types.mjs.map +0 -1
  78. package/dist/esm/typeschema/validation.mjs +0 -262
  79. package/dist/esm/typeschema/validation.mjs.map +0 -1
  80. package/dist/esm/utils.mjs +0 -632
  81. package/dist/esm/utils.mjs.map +0 -1
@@ -1,95 +0,0 @@
1
- import { stringify } from './utils.mjs';
2
-
3
- /**
4
- * The ClientStorage class is a utility class for storing strings and objects.
5
- *
6
- * When using MedplumClient in the browser, it will be backed by browser localStorage.
7
- *
8
- * When Using MedplumClient in the server, it will be backed by the MemoryStorage class. For example, the Medplum CLI uses `FileSystemStorage`.
9
- */
10
- class ClientStorage {
11
- constructor() {
12
- this.storage = typeof localStorage !== 'undefined' ? localStorage : new MemoryStorage();
13
- }
14
- clear() {
15
- this.storage.clear();
16
- }
17
- getString(key) {
18
- return this.storage.getItem(key) || undefined;
19
- }
20
- setString(key, value) {
21
- if (value) {
22
- this.storage.setItem(key, value);
23
- }
24
- else {
25
- this.storage.removeItem(key);
26
- }
27
- }
28
- getObject(key) {
29
- const str = this.getString(key);
30
- return str ? JSON.parse(str) : undefined;
31
- }
32
- setObject(key, value) {
33
- this.setString(key, value ? stringify(value) : undefined);
34
- }
35
- }
36
- /**
37
- * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.
38
- */
39
- class MemoryStorage {
40
- constructor() {
41
- this.data = new Map();
42
- }
43
- /**
44
- * Returns the number of key/value pairs.
45
- * @returns The number of key/value pairs.
46
- */
47
- get length() {
48
- return this.data.size;
49
- }
50
- /**
51
- * Removes all key/value pairs, if there are any.
52
- */
53
- clear() {
54
- this.data.clear();
55
- }
56
- /**
57
- * Returns the current value associated with the given key, or null if the given key does not exist.
58
- * @param key The specified storage key.
59
- * @returns The current value associated with the given key, or null if the given key does not exist.
60
- */
61
- getItem(key) {
62
- return this.data.get(key) ?? null;
63
- }
64
- /**
65
- * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
66
- * @param key The storage key.
67
- * @param value The new value.
68
- */
69
- setItem(key, value) {
70
- if (value) {
71
- this.data.set(key, value);
72
- }
73
- else {
74
- this.data.delete(key);
75
- }
76
- }
77
- /**
78
- * Removes the key/value pair with the given key, if a key/value pair with the given key exists.
79
- * @param key The storage key.
80
- */
81
- removeItem(key) {
82
- this.data.delete(key);
83
- }
84
- /**
85
- * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
86
- * @param index The numeric index.
87
- * @returns The nth key.
88
- */
89
- key(index) {
90
- return Array.from(this.data.keys())[index];
91
- }
92
- }
93
-
94
- export { ClientStorage, MemoryStorage };
95
- //# sourceMappingURL=storage.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.mjs","sources":["../../src/storage.ts"],"sourcesContent":["import { stringify } from './utils';\n\n/**\n * The ClientStorage class is a utility class for storing strings and objects.\n *\n * When using MedplumClient in the browser, it will be backed by browser localStorage.\n *\n * When Using MedplumClient in the server, it will be backed by the MemoryStorage class. For example, the Medplum CLI uses `FileSystemStorage`.\n */\nexport class ClientStorage {\n private readonly storage: Storage;\n\n constructor() {\n this.storage = typeof localStorage !== 'undefined' ? localStorage : new MemoryStorage();\n }\n\n clear(): void {\n this.storage.clear();\n }\n\n getString(key: string): string | undefined {\n return this.storage.getItem(key) || undefined;\n }\n\n setString(key: string, value: string | undefined): void {\n if (value) {\n this.storage.setItem(key, value);\n } else {\n this.storage.removeItem(key);\n }\n }\n\n getObject<T>(key: string): T | undefined {\n const str = this.getString(key);\n return str ? (JSON.parse(str) as T) : undefined;\n }\n\n setObject<T>(key: string, value: T): void {\n this.setString(key, value ? stringify(value) : undefined);\n }\n}\n\n/**\n * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.\n */\nexport class MemoryStorage implements Storage {\n private data: Map<string, string>;\n\n constructor() {\n this.data = new Map<string, string>();\n }\n\n /**\n * Returns the number of key/value pairs.\n * @returns The number of key/value pairs.\n */\n get length(): number {\n return this.data.size;\n }\n\n /**\n * Removes all key/value pairs, if there are any.\n */\n clear(): void {\n this.data.clear();\n }\n\n /**\n * Returns the current value associated with the given key, or null if the given key does not exist.\n * @param key The specified storage key.\n * @returns The current value associated with the given key, or null if the given key does not exist.\n */\n getItem(key: string): string | null {\n return this.data.get(key) ?? null;\n }\n\n /**\n * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.\n * @param key The storage key.\n * @param value The new value.\n */\n setItem(key: string, value: string | null): void {\n if (value) {\n this.data.set(key, value);\n } else {\n this.data.delete(key);\n }\n }\n\n /**\n * Removes the key/value pair with the given key, if a key/value pair with the given key exists.\n * @param key The storage key.\n */\n removeItem(key: string): void {\n this.data.delete(key);\n }\n\n /**\n * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.\n * @param index The numeric index.\n * @returns The nth key.\n */\n key(index: number): string | null {\n return Array.from(this.data.keys())[index];\n }\n}\n"],"names":[],"mappings":";;AAEA;;;;;;AAMG;MACU,aAAa,CAAA;AAGxB,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,YAAY,KAAK,WAAW,GAAG,YAAY,GAAG,IAAI,aAAa,EAAE,CAAC;KACzF;IAED,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;KACtB;AAED,IAAA,SAAS,CAAC,GAAW,EAAA;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;KAC/C;IAED,SAAS,CAAC,GAAW,EAAE,KAAyB,EAAA;AAC9C,QAAA,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAClC,SAAA;AAAM,aAAA;AACL,YAAA,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC9B,SAAA;KACF;AAED,I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ACf,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;KAC5C;AACF;;;;"}
@@ -1,370 +0,0 @@
1
- import baseSchema from './base-schema.json.mjs';
2
- import { capitalize } from './utils.mjs';
3
-
4
- /**
5
- * List of property types.
6
- * http://www.hl7.org/fhir/valueset-defined-types.html
7
- * The list here includes additions found from StructureDefinition resources.
8
- */
9
- var PropertyType;
10
- (function (PropertyType) {
11
- PropertyType["Address"] = "Address";
12
- PropertyType["Age"] = "Age";
13
- PropertyType["Annotation"] = "Annotation";
14
- PropertyType["Attachment"] = "Attachment";
15
- PropertyType["BackboneElement"] = "BackboneElement";
16
- PropertyType["CodeableConcept"] = "CodeableConcept";
17
- PropertyType["Coding"] = "Coding";
18
- PropertyType["ContactDetail"] = "ContactDetail";
19
- PropertyType["ContactPoint"] = "ContactPoint";
20
- PropertyType["Contributor"] = "Contributor";
21
- PropertyType["Count"] = "Count";
22
- PropertyType["DataRequirement"] = "DataRequirement";
23
- PropertyType["Distance"] = "Distance";
24
- PropertyType["Dosage"] = "Dosage";
25
- PropertyType["Duration"] = "Duration";
26
- PropertyType["Expression"] = "Expression";
27
- PropertyType["Extension"] = "Extension";
28
- PropertyType["HumanName"] = "HumanName";
29
- PropertyType["Identifier"] = "Identifier";
30
- PropertyType["MarketingStatus"] = "MarketingStatus";
31
- PropertyType["Meta"] = "Meta";
32
- PropertyType["Money"] = "Money";
33
- PropertyType["Narrative"] = "Narrative";
34
- PropertyType["ParameterDefinition"] = "ParameterDefinition";
35
- PropertyType["Period"] = "Period";
36
- PropertyType["Population"] = "Population";
37
- PropertyType["ProdCharacteristic"] = "ProdCharacteristic";
38
- PropertyType["ProductShelfLife"] = "ProductShelfLife";
39
- PropertyType["Quantity"] = "Quantity";
40
- PropertyType["Range"] = "Range";
41
- PropertyType["Ratio"] = "Ratio";
42
- PropertyType["Reference"] = "Reference";
43
- PropertyType["RelatedArtifact"] = "RelatedArtifact";
44
- PropertyType["SampledData"] = "SampledData";
45
- PropertyType["Signature"] = "Signature";
46
- PropertyType["SubstanceAmount"] = "SubstanceAmount";
47
- PropertyType["SystemString"] = "http://hl7.org/fhirpath/System.String";
48
- PropertyType["Timing"] = "Timing";
49
- PropertyType["TriggerDefinition"] = "TriggerDefinition";
50
- PropertyType["UsageContext"] = "UsageContext";
51
- PropertyType["base64Binary"] = "base64Binary";
52
- PropertyType["boolean"] = "boolean";
53
- PropertyType["canonical"] = "canonical";
54
- PropertyType["code"] = "code";
55
- PropertyType["date"] = "date";
56
- PropertyType["dateTime"] = "dateTime";
57
- PropertyType["decimal"] = "decimal";
58
- PropertyType["id"] = "id";
59
- PropertyType["instant"] = "instant";
60
- PropertyType["integer"] = "integer";
61
- PropertyType["markdown"] = "markdown";
62
- PropertyType["oid"] = "oid";
63
- PropertyType["positiveInt"] = "positiveInt";
64
- PropertyType["string"] = "string";
65
- PropertyType["time"] = "time";
66
- PropertyType["unsignedInt"] = "unsignedInt";
67
- PropertyType["uri"] = "uri";
68
- PropertyType["url"] = "url";
69
- PropertyType["uuid"] = "uuid";
70
- })(PropertyType || (PropertyType = {}));
71
- /**
72
- * Indexes a bundle of StructureDefinitions for faster lookup.
73
- * @param bundle A FHIR bundle StructureDefinition resources.
74
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
75
- */
76
- function indexStructureDefinitionBundle(bundle) {
77
- for (const entry of bundle.entry) {
78
- const resource = entry.resource;
79
- if (resource.resourceType === 'StructureDefinition') {
80
- indexStructureDefinition(resource);
81
- }
82
- }
83
- }
84
- /**
85
- * Indexes a StructureDefinition for fast lookup.
86
- * @param structureDefinition The original StructureDefinition.
87
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
88
- */
89
- function indexStructureDefinition(structureDefinition) {
90
- const typeName = structureDefinition.name;
91
- if (!typeName) {
92
- return;
93
- }
94
- const elements = structureDefinition.snapshot?.element;
95
- if (elements) {
96
- // First pass, build types
97
- elements.forEach((element) => indexType(structureDefinition, element));
98
- // Second pass, build properties
99
- elements.forEach((element) => indexProperty(structureDefinition, element));
100
- }
101
- }
102
- /**
103
- * Indexes TypeSchema from an ElementDefinition.
104
- * In the common case, there will be many ElementDefinition instances per TypeSchema.
105
- * Only the first occurrence is saved.
106
- * @param structureDefinition The parent type structure definition.
107
- * @param elementDefinition The element definition.
108
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
109
- */
110
- function indexType(structureDefinition, elementDefinition) {
111
- const path = elementDefinition.path;
112
- const typeCode = elementDefinition.type?.[0]?.code;
113
- if (typeCode !== undefined && typeCode !== 'Element' && typeCode !== 'BackboneElement') {
114
- return;
115
- }
116
- const parts = path.split('.');
117
- // Force the first part to be the type name
118
- // This is necessary for "SimpleQuantity" and "MoneyQuantity"
119
- parts[0] = structureDefinition.name;
120
- const typeName = buildTypeName(parts);
121
- let typeSchema = globalSchema.types[typeName];
122
- if (!typeSchema) {
123
- globalSchema.types[typeName] = typeSchema = {};
124
- }
125
- typeSchema.parentType = typeSchema.parentType || buildTypeName(parts.slice(0, parts.length - 1));
126
- typeSchema.display = typeSchema.display || typeName;
127
- typeSchema.structureDefinition = typeSchema.structureDefinition || structureDefinition;
128
- typeSchema.elementDefinition = typeSchema.elementDefinition || elementDefinition;
129
- typeSchema.description = typeSchema.description || elementDefinition.definition;
130
- typeSchema.properties = typeSchema.properties || {};
131
- }
132
- /**
133
- * Indexes PropertySchema from an ElementDefinition.
134
- * @param structureDefinition The input StructureDefinition.
135
- * @param element The input ElementDefinition.
136
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
137
- */
138
- function indexProperty(structureDefinition, element) {
139
- const path = element.path;
140
- const parts = path.split('.');
141
- if (parts.length === 1) {
142
- return;
143
- }
144
- // Force the first part to be the type name
145
- // This is necessary for "SimpleQuantity" and "MoneyQuantity"
146
- parts[0] = structureDefinition.name;
147
- const typeName = buildTypeName(parts.slice(0, parts.length - 1));
148
- const typeSchema = globalSchema.types[typeName];
149
- if (!typeSchema) {
150
- return;
151
- }
152
- const key = parts[parts.length - 1];
153
- typeSchema.properties[key] = element;
154
- }
155
- /**
156
- * Indexes a bundle of SearchParameter resources for faster lookup.
157
- * @param bundle A FHIR bundle SearchParameter resources.
158
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
159
- */
160
- function indexSearchParameterBundle(bundle) {
161
- for (const entry of bundle.entry) {
162
- const resource = entry.resource;
163
- if (resource.resourceType === 'SearchParameter') {
164
- indexSearchParameter(resource);
165
- }
166
- }
167
- }
168
- /**
169
- * Indexes a SearchParameter resource for fast lookup.
170
- * Indexes by SearchParameter.code, which is the query string parameter name.
171
- * @param searchParam The SearchParameter resource.
172
- * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.
173
- */
174
- function indexSearchParameter(searchParam) {
175
- if (!searchParam.base) {
176
- return;
177
- }
178
- for (const resourceType of searchParam.base) {
179
- const typeSchema = globalSchema.types[resourceType];
180
- if (!typeSchema) {
181
- continue;
182
- }
183
- if (!typeSchema.searchParams) {
184
- typeSchema.searchParams = {
185
- _id: {
186
- base: [resourceType],
187
- code: '_id',
188
- type: 'token',
189
- expression: resourceType + '.id',
190
- },
191
- _lastUpdated: {
192
- base: [resourceType],
193
- code: '_lastUpdated',
194
- type: 'date',
195
- expression: resourceType + '.meta.lastUpdated',
196
- },
197
- _compartment: {
198
- base: [resourceType],
199
- code: '_compartment',
200
- type: 'reference',
201
- expression: resourceType + '.meta.compartment',
202
- },
203
- _profile: {
204
- base: [resourceType],
205
- code: '_profile',
206
- type: 'uri',
207
- expression: resourceType + '.meta.profile',
208
- },
209
- _security: {
210
- base: [resourceType],
211
- code: '_security',
212
- type: 'token',
213
- expression: resourceType + '.meta.security',
214
- },
215
- _source: {
216
- base: [resourceType],
217
- code: '_source',
218
- type: 'uri',
219
- expression: resourceType + '.meta.source',
220
- },
221
- _tag: {
222
- base: [resourceType],
223
- code: '_tag',
224
- type: 'token',
225
- expression: resourceType + '.meta.tag',
226
- },
227
- };
228
- }
229
- typeSchema.searchParams[searchParam.code] = searchParam;
230
- }
231
- }
232
- /**
233
- * Returns the type name for an ElementDefinition.
234
- * @param elementDefinition The element definition.
235
- * @returns The Medplum type name.
236
- */
237
- function getElementDefinitionTypeName(elementDefinition) {
238
- const code = elementDefinition.type?.[0]?.code;
239
- return code === 'BackboneElement' || code === 'Element'
240
- ? buildTypeName(elementDefinition.path?.split('.'))
241
- : code;
242
- }
243
- function buildTypeName(components) {
244
- if (components.length === 1) {
245
- return components[0];
246
- }
247
- return components.map(capitalize).join('');
248
- }
249
- /**
250
- * Returns true if the type schema is a non-abstract FHIR resource.
251
- * @param typeSchema The type schema to check.
252
- * @returns True if the type schema is a non-abstract FHIR resource.
253
- */
254
- function isResourceTypeSchema(typeSchema) {
255
- const structureDefinition = typeSchema.structureDefinition;
256
- return (structureDefinition &&
257
- structureDefinition.name === typeSchema.elementDefinition.path &&
258
- structureDefinition.kind === 'resource' &&
259
- !structureDefinition.abstract);
260
- }
261
- /**
262
- * Returns an array of all resource types.
263
- * Note that this is based on globalSchema, and will only return resource types that are currently in memory.
264
- * @returns An array of all resource types.
265
- */
266
- function getResourceTypes() {
267
- const result = [];
268
- for (const [resourceType, typeSchema] of Object.entries(globalSchema.types)) {
269
- if (isResourceTypeSchema(typeSchema)) {
270
- result.push(resourceType);
271
- }
272
- }
273
- return result;
274
- }
275
- /**
276
- * Returns the type schema for the resource type.
277
- * @param resourceType The resource type.
278
- * @returns The type schema for the resource type.
279
- */
280
- function getResourceTypeSchema(resourceType) {
281
- return globalSchema.types[resourceType];
282
- }
283
- /**
284
- * Returns the search parameters for the resource type indexed by search code.
285
- * @param resourceType The resource type.
286
- * @returns The search parameters for the resource type indexed by search code.
287
- */
288
- function getSearchParameters(resourceType) {
289
- return globalSchema.types[resourceType].searchParams;
290
- }
291
- /**
292
- * Returns a human friendly display name for a FHIR element definition path.
293
- * @param path The FHIR element definition path.
294
- * @returns The best guess of the display name.
295
- */
296
- function getPropertyDisplayName(path) {
297
- // Get the property name, which is the remainder after the last period
298
- // For example, for path "Patient.birthDate"
299
- // the property name is "birthDate"
300
- const propertyName = path.replaceAll('[x]', '').split('.').pop();
301
- // Split by capital letters
302
- // Capitalize the first letter of each word
303
- // Join together with spaces in between
304
- // Then normalize whitespace to single space character
305
- // For example, for property name "birthDate",
306
- // the display name is "Birth Date".
307
- return propertyName
308
- .split(/(?=[A-Z])/)
309
- .map(capitalizeDisplayWord)
310
- .join(' ')
311
- .replace('_', ' ')
312
- .replace(/\s+/g, ' ');
313
- }
314
- const capitalizedWords = new Set(['ID', 'IP', 'PKCE', 'JWKS', 'URI', 'URL']);
315
- function capitalizeDisplayWord(word) {
316
- const upper = word.toUpperCase();
317
- if (capitalizedWords.has(upper)) {
318
- return upper;
319
- }
320
- return upper.charAt(0) + word.slice(1);
321
- }
322
- /**
323
- * Returns an element definition by type and property name.
324
- * Handles content references.
325
- * @param typeName The type name.
326
- * @param propertyName The property name.
327
- * @returns The element definition if found.
328
- */
329
- function getElementDefinition(typeName, propertyName) {
330
- const typeSchema = globalSchema.types[typeName];
331
- if (!typeSchema) {
332
- return undefined;
333
- }
334
- const property = typeSchema.properties[propertyName] ?? typeSchema.properties[propertyName + '[x]'];
335
- if (!property) {
336
- return undefined;
337
- }
338
- if (property.contentReference) {
339
- // Content references start with a "#"
340
- // Remove the "#" character
341
- const contentReference = property.contentReference.substring(1).split('.');
342
- const referencePropertyName = contentReference.pop();
343
- const referenceTypeName = buildTypeName(contentReference);
344
- return getElementDefinition(referenceTypeName, referencePropertyName);
345
- }
346
- return property;
347
- }
348
- /**
349
- * Typeguard to validate that an object is a FHIR resource
350
- * @param value The object to check
351
- * @returns True if the input is of type 'object' and contains property 'resourceType'
352
- */
353
- function isResource(value) {
354
- return !!(value && typeof value === 'object' && 'resourceType' in value);
355
- }
356
- /**
357
- * Typeguard to validate that an object is a FHIR resource
358
- * @param value The object to check
359
- * @returns True if the input is of type 'object' and contains property 'reference'
360
- */
361
- function isReference(value) {
362
- return !!(value && typeof value === 'object' && 'reference' in value);
363
- }
364
- /**
365
- * Global schema singleton.
366
- */
367
- const globalSchema = baseSchema;
368
-
369
- export { PropertyType, buildTypeName, getElementDefinition, getElementDefinitionTypeName, getPropertyDisplayName, getResourceTypeSchema, getResourceTypes, getSearchParameters, globalSchema, indexSearchParameter, indexSearchParameterBundle, indexStructureDefinition, indexStructureDefinitionBundle, isReference, isResource, isResourceTypeSchema };
370
- //# sourceMappingURL=types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.mjs","sources":["../../src/types.ts"],"sourcesContent":["import {\n Bundle,\n BundleEntry,\n ElementDefinition,\n Reference,\n Resource,\n ResourceType,\n SearchParameter,\n StructureDefinition,\n} from '@medplum/fhirtypes';\nimport baseSchema from './base-schema.json';\nimport { SearchParameterDetails } from './search/details';\nimport { capitalize } from './utils';\n\nexport interface TypedValue {\n readonly type: string;\n readonly value: any;\n}\n\n/**\n * List of property types.\n * http://www.hl7.org/fhir/valueset-defined-types.html\n * The list here includes additions found from StructureDefinition resources.\n */\nexport enum PropertyType {\n Address = 'Address',\n Age = 'Age',\n Annotation = 'Annotation',\n Attachment = 'Attachment',\n BackboneElement = 'BackboneElement',\n CodeableConcept = 'CodeableConcept',\n Coding = 'Coding',\n ContactDetail = 'ContactDetail',\n ContactPoint = 'ContactPoint',\n Contributor = 'Contributor',\n Count = 'Count',\n DataRequirement = 'DataRequirement',\n Distance = 'Distance',\n Dosage = 'Dosage',\n Duration = 'Duration',\n Expression = 'Expression',\n Extension = 'Extension',\n HumanName = 'HumanName',\n Identifier = 'Identifier',\n MarketingStatus = 'MarketingStatus',\n Meta = 'Meta',\n Money = 'Money',\n Narrative = 'Narrative',\n ParameterDefinition = 'ParameterDefinition',\n Period = 'Period',\n Population = 'Population',\n ProdCharacteristic = 'ProdCharacteristic',\n ProductShelfLife = 'ProductShelfLife',\n Quantity = 'Quantity',\n Range = 'Range',\n Ratio = 'Ratio',\n Reference = 'Reference',\n RelatedArtifact = 'RelatedArtifact',\n SampledData = 'SampledData',\n Signature = 'Signature',\n SubstanceAmount = 'SubstanceAmount',\n SystemString = 'http://hl7.org/fhirpath/System.String',\n Timing = 'Timing',\n TriggerDefinition = 'TriggerDefinition',\n UsageContext = 'UsageContext',\n base64Binary = 'base64Binary',\n boolean = 'boolean',\n canonical = 'canonical',\n code = 'code',\n date = 'date',\n dateTime = 'dateTime',\n decimal = 'decimal',\n id = 'id',\n instant = 'instant',\n integer = 'integer',\n markdown = 'markdown',\n oid = 'oid',\n positiveInt = 'positiveInt',\n string = 'string',\n time = 'time',\n unsignedInt = 'unsignedInt',\n uri = 'uri',\n url = 'url',\n uuid = 'uuid',\n}\n\n/**\n * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.\n *\n * StructureDefinition resources contain schema information for other resource types.\n * These schemas can be used to automatically generate user interface elements for\n * resources.\n *\n * However, a StructureDefinition resource is not optimized for realtime lookups. All\n * resource types, sub types, and property definitions are stored in a flat array of\n * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., \"Patient.name\")\n * requires a linear scan of all ElementDefinition objects\n *\n * A StructureDefinition resource contains information about one or more types.\n * For example, the \"Patient\" StructureDefinition includes \"Patient\", \"Patient_Contact\",\n * \"Patient_Communication\", and \"Patient_Link\". This is inefficient.\n *\n * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.\n * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.\n *\n * The hierarchy is:\n * IndexedStructureDefinition - top level for one resource type\n * TypeSchema - one per resource type and all contained BackboneElements\n * PropertySchema - one per property/field\n */\nexport interface IndexedStructureDefinition {\n types: { [resourceType: string]: TypeSchema };\n}\n\n/**\n * An indexed TypeSchema.\n *\n * Example: The IndexedStructureDefinition for \"Patient\" would include the following TypeSchemas:\n * 1) Patient\n * 2) Patient_Contact\n * 3) Patient_Communication\n * 4) Patient_Link\n */\nexport interface TypeSchema {\n structureDefinition: StructureDefinition;\n elementDefinition: ElementDefinition;\n display: string;\n properties: { [name: string]: ElementDefinition };\n searchParams?: { [code: string]: SearchParameter };\n searchParamsDetails?: { [code: string]: SearchParameterDetails };\n description?: string;\n parentType?: string;\n}\n\n/**\n * Indexes a bundle of StructureDefinitions for faster lookup.\n * @param bundle A FHIR bundle StructureDefinition resources.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexStructureDefinitionBundle(bundle: Bundle): void {\n for (const entry of bundle.entry as BundleEntry[]) {\n const resource = entry.resource as Resource;\n if (resource.resourceType === 'StructureDefinition') {\n indexStructureDefinition(resource);\n }\n }\n}\n\n/**\n * Indexes a StructureDefinition for fast lookup.\n * @param structureDefinition The original StructureDefinition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexStructureDefinition(structureDefinition: StructureDefinition): void {\n const typeName = structureDefinition.name;\n if (!typeName) {\n return;\n }\n\n const elements = structureDefinition.snapshot?.element;\n if (elements) {\n // First pass, build types\n elements.forEach((element) => indexType(structureDefinition, element));\n\n // Second pass, build properties\n elements.forEach((element) => indexProperty(structureDefinition, element));\n }\n}\n\n/**\n * Indexes TypeSchema from an ElementDefinition.\n * In the common case, there will be many ElementDefinition instances per TypeSchema.\n * Only the first occurrence is saved.\n * @param structureDefinition The parent type structure definition.\n * @param elementDefinition The element definition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nfunction indexType(structureDefinition: StructureDefinition, elementDefinition: ElementDefinition): void {\n const path = elementDefinition.path as string;\n const typeCode = elementDefinition.type?.[0]?.code;\n if (typeCode !== undefined && typeCode !== 'Element' && typeCode !== 'BackboneElement') {\n return;\n }\n\n const parts = path.split('.');\n\n // Force the first part to be the type name\n // This is necessary for \"SimpleQuantity\" and \"MoneyQuantity\"\n parts[0] = structureDefinition.name as string;\n\n const typeName = buildTypeName(parts);\n let typeSchema = globalSchema.types[typeName];\n\n if (!typeSchema) {\n globalSchema.types[typeName] = typeSchema = {} as TypeSchema;\n }\n\n typeSchema.parentType = typeSchema.parentType || buildTypeName(parts.slice(0, parts.length - 1));\n typeSchema.display = typeSchema.display || typeName;\n typeSchema.structureDefinition = typeSchema.structureDefinition || structureDefinition;\n typeSchema.elementDefinition = typeSchema.elementDefinition || elementDefinition;\n typeSchema.description = typeSchema.description || elementDefinition.definition;\n typeSchema.properties = typeSchema.properties || {};\n}\n\n/**\n * Indexes PropertySchema from an ElementDefinition.\n * @param structureDefinition The input StructureDefinition.\n * @param element The input ElementDefinition.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nfunction indexProperty(structureDefinition: StructureDefinition, element: ElementDefinition): void {\n const path = element.path as string;\n const parts = path.split('.');\n if (parts.length === 1) {\n return;\n }\n\n // Force the first part to be the type name\n // This is necessary for \"SimpleQuantity\" and \"MoneyQuantity\"\n parts[0] = structureDefinition.name as string;\n\n const typeName = buildTypeName(parts.slice(0, parts.length - 1));\n const typeSchema = globalSchema.types[typeName];\n if (!typeSchema) {\n return;\n }\n const key = parts[parts.length - 1];\n typeSchema.properties[key] = element;\n}\n\n/**\n * Indexes a bundle of SearchParameter resources for faster lookup.\n * @param bundle A FHIR bundle SearchParameter resources.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexSearchParameterBundle(bundle: Bundle<SearchParameter>): void {\n for (const entry of bundle.entry as BundleEntry[]) {\n const resource = entry.resource as SearchParameter;\n if (resource.resourceType === 'SearchParameter') {\n indexSearchParameter(resource);\n }\n }\n}\n\n/**\n * Indexes a SearchParameter resource for fast lookup.\n * Indexes by SearchParameter.code, which is the query string parameter name.\n * @param searchParam The SearchParameter resource.\n * @see {@link IndexedStructureDefinition} for more details on indexed StructureDefinitions.\n */\nexport function indexSearchParameter(searchParam: SearchParameter): void {\n if (!searchParam.base) {\n return;\n }\n\n for (const resourceType of searchParam.base) {\n const typeSchema = globalSchema.types[resourceType];\n if (!typeSchema) {\n continue;\n }\n\n if (!typeSchema.searchParams) {\n typeSchema.searchParams = {\n _id: {\n base: [resourceType],\n code: '_id',\n type: 'token',\n expression: resourceType + '.id',\n } as SearchParameter,\n _lastUpdated: {\n base: [resourceType],\n code: '_lastUpdated',\n type: 'date',\n expression: resourceType + '.meta.lastUpdated',\n } as SearchParameter,\n _compartment: {\n base: [resourceType],\n code: '_compartment',\n type: 'reference',\n expression: resourceType + '.meta.compartment',\n } as SearchParameter,\n _profile: {\n base: [resourceType],\n code: '_profile',\n type: 'uri',\n expression: resourceType + '.meta.profile',\n } as SearchParameter,\n _security: {\n base: [resourceType],\n code: '_security',\n type: 'token',\n expression: resourceType + '.meta.security',\n } as SearchParameter,\n _source: {\n base: [resourceType],\n code: '_source',\n type: 'uri',\n expression: resourceType + '.meta.source',\n } as SearchParameter,\n _tag: {\n base: [resourceType],\n code: '_tag',\n type: 'token',\n expression: resourceType + '.meta.tag',\n } as SearchParameter,\n };\n }\n\n typeSchema.searchParams[searchParam.code as string] = searchParam;\n }\n}\n\n/**\n * Returns the type name for an ElementDefinition.\n * @param elementDefinition The element definition.\n * @returns The Medplum type name.\n */\nexport function getElementDefinitionTypeName(elementDefinition: ElementDefinition): string {\n const code = elementDefinition.type?.[0]?.code as string;\n return code === 'BackboneElement' || code === 'Element'\n ? buildTypeName(elementDefinition.path?.split('.') as string[])\n : code;\n}\n\nexport function buildTypeName(components: string[]): string {\n if (components.length === 1) {\n return components[0];\n }\n return components.map(capitalize).join('');\n}\n\n/**\n * Returns true if the type schema is a non-abstract FHIR resource.\n * @param typeSchema The type schema to check.\n * @returns True if the type schema is a non-abstract FHIR resource.\n */\nexport function isResourceTypeSchema(typeSchema: TypeSchema): boolean {\n const structureDefinition = typeSchema.structureDefinition;\n return (\n structureDefinition &&\n structureDefinition.name === typeSchema.elementDefinition.path &&\n structureDefinition.kind === 'resource' &&\n !structureDefinition.abstract\n );\n}\n\n/**\n * Returns an array of all resource types.\n * Note that this is based on globalSchema, and will only return resource types that are currently in memory.\n * @returns An array of all resource types.\n */\nexport function getResourceTypes(): ResourceType[] {\n const result: ResourceType[] = [];\n for (const [resourceType, typeSchema] of Object.entries(globalSchema.types)) {\n if (isResourceTypeSchema(typeSchema)) {\n result.push(resourceType as ResourceType);\n }\n }\n return result;\n}\n\n/**\n * Returns the type schema for the resource type.\n * @param resourceType The resource type.\n * @returns The type schema for the resource type.\n */\nexport function getResourceTypeSchema(resourceType: string): TypeSchema {\n return globalSchema.types[resourceType];\n}\n\n/**\n * Returns the search parameters for the resource type indexed by search code.\n * @param resourceType The resource type.\n * @returns The search parameters for the resource type indexed by search code.\n */\nexport function getSearchParameters(resourceType: string): Record<string, SearchParameter> | undefined {\n return globalSchema.types[resourceType].searchParams;\n}\n\n/**\n * Returns a human friendly display name for a FHIR element definition path.\n * @param path The FHIR element definition path.\n * @returns The best guess of the display name.\n */\nexport function getPropertyDisplayName(path: string): string {\n // Get the property name, which is the remainder after the last period\n // For example, for path \"Patient.birthDate\"\n // the property name is \"birthDate\"\n const propertyName = path.replaceAll('[x]', '').split('.').pop() as string;\n\n // Split by capital letters\n // Capitalize the first letter of each word\n // Join together with spaces in between\n // Then normalize whitespace to single space character\n // For example, for property name \"birthDate\",\n // the display name is \"Birth Date\".\n return propertyName\n .split(/(?=[A-Z])/)\n .map(capitalizeDisplayWord)\n .join(' ')\n .replace('_', ' ')\n .replace(/\\s+/g, ' ');\n}\n\nconst capitalizedWords = new Set(['ID', 'IP', 'PKCE', 'JWKS', 'URI', 'URL']);\n\nfunction capitalizeDisplayWord(word: string): string {\n const upper = word.toUpperCase();\n if (capitalizedWords.has(upper)) {\n return upper;\n }\n return upper.charAt(0) + word.slice(1);\n}\n\n/**\n * Returns an element definition by type and property name.\n * Handles content references.\n * @param typeName The type name.\n * @param propertyName The property name.\n * @returns The element definition if found.\n */\nexport function getElementDefinition(typeName: string, propertyName: string): ElementDefinition | undefined {\n const typeSchema = globalSchema.types[typeName];\n if (!typeSchema) {\n return undefined;\n }\n\n const property = typeSchema.properties[propertyName] ?? typeSchema.properties[propertyName + '[x]'];\n if (!property) {\n return undefined;\n }\n\n if (property.contentReference) {\n // Content references start with a \"#\"\n // Remove the \"#\" character\n const contentReference = property.contentReference.substring(1).split('.');\n const referencePropertyName = contentReference.pop() as string;\n const referenceTypeName = buildTypeName(contentReference);\n return getElementDefinition(referenceTypeName, referencePropertyName);\n }\n\n return property;\n}\n\n/**\n * Typeguard to validate that an object is a FHIR resource\n * @param value The object to check\n * @returns True if the input is of type 'object' and contains property 'resourceType'\n */\nexport function isResource<T extends Resource = Resource>(\n value: T | Reference<T> | string | undefined | null\n): value is T {\n return !!(value && typeof value === 'object' && 'resourceType' in value);\n}\n\n/**\n * Typeguard to validate that an object is a FHIR resource\n * @param value The object to check\n * @returns True if the input is of type 'object' and contains property 'reference'\n */\nexport function isReference<T extends Resource>(\n value: T | Reference<T> | string | undefined | null\n): value is Reference<T> & { reference: string } {\n return !!(value && typeof value === 'object' && 'reference' in value);\n}\n\n/**\n * Global schema singleton.\n */\nexport const globalSchema = baseSchema as unknown as IndexedStructureDefinition;\n"],"names":[],"mappings":";;;AAmBA;;;;AAIG;IACS,aA4DX;AA5DD,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,YAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AACzB,IAAA,YAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AACzB,IAAA,YAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,YAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,YAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,YAAA,CAAA,eAAA,CAAA,GAAA,eAA+B,CAAA;AAC/B,IAAA,YAAA,CAAA,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