@metriport/fhir-sdk 1.2.7 → 1.3.0
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/README.md +207 -0
- package/dist/__tests__/date-range-performance.test.d.ts +2 -0
- package/dist/__tests__/date-range-performance.test.d.ts.map +1 -0
- package/dist/__tests__/date-range-performance.test.js +218 -0
- package/dist/__tests__/date-range-performance.test.js.map +1 -0
- package/dist/__tests__/date-range-search.test.d.ts +2 -0
- package/dist/__tests__/date-range-search.test.d.ts.map +1 -0
- package/dist/__tests__/date-range-search.test.js +215 -0
- package/dist/__tests__/date-range-search.test.js.map +1 -0
- package/dist/__tests__/fhir-bundle-sdk.test.js +467 -0
- package/dist/__tests__/fhir-bundle-sdk.test.js.map +1 -1
- package/dist/__tests__/reverse-references.test.d.ts +2 -0
- package/dist/__tests__/reverse-references.test.d.ts.map +1 -0
- package/dist/__tests__/reverse-references.test.js +241 -0
- package/dist/__tests__/reverse-references.test.js.map +1 -0
- package/dist/demo-reverse-references.d.ts +7 -0
- package/dist/demo-reverse-references.d.ts.map +1 -0
- package/dist/demo-reverse-references.js +207 -0
- package/dist/demo-reverse-references.js.map +1 -0
- package/dist/fhir-bundle-sdk.d.ts +222 -0
- package/dist/fhir-bundle-sdk.d.ts.map +1 -0
- package/dist/fhir-bundle-sdk.js +527 -0
- package/dist/fhir-bundle-sdk.js.map +1 -0
- package/dist/index.d.ts +2 -242
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -677
- package/dist/index.js.map +1 -1
- package/dist/internal/bundle-operations.d.ts +14 -0
- package/dist/internal/bundle-operations.d.ts.map +1 -0
- package/dist/internal/bundle-operations.js +55 -0
- package/dist/internal/bundle-operations.js.map +1 -0
- package/dist/internal/date-extraction.d.ts +12 -0
- package/dist/internal/date-extraction.d.ts.map +1 -0
- package/dist/internal/date-extraction.js +206 -0
- package/dist/internal/date-extraction.js.map +1 -0
- package/dist/internal/graph-traversal.d.ts +13 -0
- package/dist/internal/graph-traversal.d.ts.map +1 -0
- package/dist/internal/graph-traversal.js +89 -0
- package/dist/internal/graph-traversal.js.map +1 -0
- package/dist/internal/indexing.d.ts +17 -0
- package/dist/internal/indexing.d.ts.map +1 -0
- package/dist/internal/indexing.js +118 -0
- package/dist/internal/indexing.js.map +1 -0
- package/dist/internal/llm-context.d.ts +39 -0
- package/dist/internal/llm-context.d.ts.map +1 -0
- package/dist/internal/llm-context.js +188 -0
- package/dist/internal/llm-context.js.map +1 -0
- package/dist/internal/reference-resolution.d.ts +25 -0
- package/dist/internal/reference-resolution.d.ts.map +1 -0
- package/dist/internal/reference-resolution.js +133 -0
- package/dist/internal/reference-resolution.js.map +1 -0
- package/dist/internal/reference-utils.d.ts +26 -0
- package/dist/internal/reference-utils.d.ts.map +1 -0
- package/dist/internal/reference-utils.js +89 -0
- package/dist/internal/reference-utils.js.map +1 -0
- package/dist/internal/validation.d.ts +16 -0
- package/dist/internal/validation.d.ts.map +1 -0
- package/dist/internal/validation.js +45 -0
- package/dist/internal/validation.js.map +1 -0
- package/dist/types/sdk-types.d.ts +107 -0
- package/dist/types/sdk-types.d.ts.map +1 -0
- package/dist/types/sdk-types.js +17 -0
- package/dist/types/sdk-types.js.map +1 -0
- package/dist/types/smart-resources.d.ts +97 -4
- package/dist/types/smart-resources.d.ts.map +1 -1
- package/dist/types/smart-resources.js +82 -5
- package/dist/types/smart-resources.js.map +1 -1
- package/dist/utils/interval-tree/index.d.ts +87 -0
- package/dist/utils/interval-tree/index.d.ts.map +1 -0
- package/dist/utils/interval-tree/index.js +774 -0
- package/dist/utils/interval-tree/index.js.map +1 -0
- package/dist/utils/interval-tree/shallowequal/arrays.d.ts +3 -0
- package/dist/utils/interval-tree/shallowequal/arrays.d.ts.map +1 -0
- package/dist/utils/interval-tree/shallowequal/arrays.js +25 -0
- package/dist/utils/interval-tree/shallowequal/arrays.js.map +1 -0
- package/dist/utils/interval-tree/shallowequal/index.d.ts +6 -0
- package/dist/utils/interval-tree/shallowequal/index.d.ts.map +1 -0
- package/dist/utils/interval-tree/shallowequal/index.js +28 -0
- package/dist/utils/interval-tree/shallowequal/index.js.map +1 -0
- package/dist/utils/interval-tree/shallowequal/objects.d.ts +3 -0
- package/dist/utils/interval-tree/shallowequal/objects.d.ts.map +1 -0
- package/dist/utils/interval-tree/shallowequal/objects.js +28 -0
- package/dist/utils/interval-tree/shallowequal/objects.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FhirBundleSdk = void 0;
|
|
4
|
+
const sdk_types_1 = require("./types/sdk-types");
|
|
5
|
+
const interval_tree_1 = require("./utils/interval-tree");
|
|
6
|
+
const validation_1 = require("./internal/validation");
|
|
7
|
+
const date_extraction_1 = require("./internal/date-extraction");
|
|
8
|
+
const indexing_1 = require("./internal/indexing");
|
|
9
|
+
const reference_resolution_1 = require("./internal/reference-resolution");
|
|
10
|
+
const bundle_operations_1 = require("./internal/bundle-operations");
|
|
11
|
+
const graph_traversal_1 = require("./internal/graph-traversal");
|
|
12
|
+
const llm_context_1 = require("./internal/llm-context");
|
|
13
|
+
/**
|
|
14
|
+
* FHIR Bundle SDK for parsing, querying, and manipulating FHIR bundles with reference resolution
|
|
15
|
+
*/
|
|
16
|
+
class FhirBundleSdk {
|
|
17
|
+
constructor(bundle) {
|
|
18
|
+
this.resourcesById = new Map();
|
|
19
|
+
this.resourcesByFullUrl = new Map();
|
|
20
|
+
this.resourcesByType = new Map();
|
|
21
|
+
// Reverse reference index: maps resource ID to resources that reference it
|
|
22
|
+
this.reverseReferencesById = new Map();
|
|
23
|
+
// Date range index: interval tree for O(log n + k) date range searches
|
|
24
|
+
this.dateRangeIndex = new interval_tree_1.IntervalTree();
|
|
25
|
+
// Smart resource caching to maintain object identity
|
|
26
|
+
this.smartResourceCache = new WeakMap();
|
|
27
|
+
// Array caching for type-specific getters to maintain reference identity
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
this.smartResourceArrayCache = new Map();
|
|
30
|
+
// Circular reference protection
|
|
31
|
+
this.resolutionStack = new Set();
|
|
32
|
+
// FR-1.1, FR-1.4: Initialize bundle and create indexes
|
|
33
|
+
this.bundle = bundle;
|
|
34
|
+
this.bundle.total = bundle.entry?.length ?? 0;
|
|
35
|
+
(0, indexing_1.buildResourceIndexes)(this.bundle, this.resourcesById, this.resourcesByFullUrl, this.resourcesByType, this.reverseReferencesById, this.dateRangeIndex, this.resolutionStack);
|
|
36
|
+
}
|
|
37
|
+
get total() {
|
|
38
|
+
if (!this.bundle.entry) {
|
|
39
|
+
throw new Error("No valid total - bundle property `entry` is undefined");
|
|
40
|
+
}
|
|
41
|
+
return this.bundle.entry.length;
|
|
42
|
+
}
|
|
43
|
+
get entry() {
|
|
44
|
+
if (!this.bundle.entry) {
|
|
45
|
+
console.error("Bundle property `entry` is undefined");
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return this.bundle.entry;
|
|
49
|
+
}
|
|
50
|
+
toObject() {
|
|
51
|
+
return this.bundle;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Strip non-clinical metadata from a FHIR resource to reduce noise for LLM consumption.
|
|
55
|
+
* Removes: meta, extension, modifierExtension, text
|
|
56
|
+
* Returns an immutable copy without mutating the original.
|
|
57
|
+
*/
|
|
58
|
+
static stripNonClinicalData(resource) {
|
|
59
|
+
return (0, llm_context_1.stripNonClinicalData)(resource);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a new FhirBundleSdk instance (async for backwards compatibility)
|
|
63
|
+
* FR-1.2: Validate bundle resourceType
|
|
64
|
+
*/
|
|
65
|
+
static async create(bundle) {
|
|
66
|
+
return FhirBundleSdk.createSync(bundle);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a new FhirBundleSdk instance synchronously
|
|
70
|
+
* FR-1.2: Validate bundle resourceType
|
|
71
|
+
*/
|
|
72
|
+
static createSync(bundle) {
|
|
73
|
+
// FR-1.2: Validate bundle resourceType
|
|
74
|
+
if (bundle.resourceType !== "Bundle") {
|
|
75
|
+
throw new Error("Invalid bundle: resourceType must be 'Bundle'");
|
|
76
|
+
}
|
|
77
|
+
return new FhirBundleSdk(bundle);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create a smart resource with reference resolution methods
|
|
81
|
+
* FR-5.1: Resources returned by SDK have additional getter methods for each Reference field
|
|
82
|
+
* FR-5.7: Reference resolution operates in O(1) time complexity per reference
|
|
83
|
+
* FR-5.8: Original reference fields remain unchanged
|
|
84
|
+
*/
|
|
85
|
+
createSmartResource(resource) {
|
|
86
|
+
return (0, reference_resolution_1.createSmartResource)(resource, this.smartResourceCache, this.resourcesById, this.resourcesByFullUrl, this.resolutionStack, (targetId, options) => this.getResourcesReferencingId(targetId, options));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* FR-2.1: Validate all references in the bundle
|
|
90
|
+
* FR-2.2: Identifies references by Resource/id pattern and fullUrl references
|
|
91
|
+
* FR-2.3: Handles both relative and absolute references
|
|
92
|
+
* FR-2.4: Returns validation result with broken reference details
|
|
93
|
+
*/
|
|
94
|
+
lookForBrokenReferences() {
|
|
95
|
+
return (0, validation_1.lookForBrokenReferences)(this.bundle, this.resourcesById, this.resourcesByFullUrl);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* FR-3.1: Get resource by ID with type parameter support
|
|
99
|
+
* FR-3.2: Method searches both resource.id and entry.fullUrl for matches
|
|
100
|
+
* FR-3.4: Method returns undefined if resource not found
|
|
101
|
+
* FR-3.5: Lookup operates in O(1) time complexity
|
|
102
|
+
* FR-5.1: Returns smart resource with reference resolution methods
|
|
103
|
+
*/
|
|
104
|
+
getResourceById(id) {
|
|
105
|
+
// First try to find by resource.id
|
|
106
|
+
const resourceById = this.resourcesById.get(id);
|
|
107
|
+
if (resourceById) {
|
|
108
|
+
return this.createSmartResource(resourceById);
|
|
109
|
+
}
|
|
110
|
+
// Then try to find by fullUrl
|
|
111
|
+
const resourceByFullUrl = this.resourcesByFullUrl.get(id);
|
|
112
|
+
if (resourceByFullUrl) {
|
|
113
|
+
return this.createSmartResource(resourceByFullUrl);
|
|
114
|
+
}
|
|
115
|
+
// Return undefined if not found (FR-3.4)
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Generic helper method to get a resource by ID with type validation
|
|
120
|
+
*/
|
|
121
|
+
getResourceByIdAndType(id, resourceType) {
|
|
122
|
+
const resource = this.getResourceById(id);
|
|
123
|
+
if (resource && resource.resourceType === resourceType) {
|
|
124
|
+
return resource;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Generic helper method to get all resources of a specific type
|
|
130
|
+
* FR-10.1: Returns references to cached objects, not copies
|
|
131
|
+
*/
|
|
132
|
+
getResourcesByType(resourceType) {
|
|
133
|
+
// Check cache first to maintain array reference identity
|
|
134
|
+
const cached = this.smartResourceArrayCache.get(resourceType);
|
|
135
|
+
if (cached) {
|
|
136
|
+
return cached;
|
|
137
|
+
}
|
|
138
|
+
const resources = (this.resourcesByType.get(resourceType) || []);
|
|
139
|
+
const smartResources = resources.map(resource => this.createSmartResource(resource));
|
|
140
|
+
// Cache the array to maintain reference identity
|
|
141
|
+
this.smartResourceArrayCache.set(resourceType, smartResources);
|
|
142
|
+
return smartResources;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* FR-6.1: Export subset of resources by their IDs
|
|
146
|
+
* FR-6.4: Exported bundles maintain original bundle metadata but update total count
|
|
147
|
+
* FR-6.5: Exported bundles include only resources that exist in the original bundle
|
|
148
|
+
* FR-6.6: Exported bundles preserve original entry.fullUrl values
|
|
149
|
+
*/
|
|
150
|
+
exportSubset(resourceIds) {
|
|
151
|
+
const exportEntries = [];
|
|
152
|
+
for (const resourceId of resourceIds) {
|
|
153
|
+
const resource = this.getResourceById(resourceId);
|
|
154
|
+
if (resource) {
|
|
155
|
+
const originalEntry = (0, bundle_operations_1.findOriginalEntry)(this.bundle, resource);
|
|
156
|
+
if (originalEntry) {
|
|
157
|
+
exportEntries.push((0, bundle_operations_1.createBundleEntry)(originalEntry, resource));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// FR-6.5: Silently skip resources that don't exist
|
|
161
|
+
}
|
|
162
|
+
return (0, bundle_operations_1.createExportBundle)(this.bundle, exportEntries);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* FR-6.2: Export all resources of a specific type
|
|
166
|
+
* FR-6.4: Exported bundles maintain original bundle metadata but update total count
|
|
167
|
+
* FR-6.6: Exported bundles preserve original entry.fullUrl values
|
|
168
|
+
*/
|
|
169
|
+
exportByType(resourceType) {
|
|
170
|
+
const resources = this.resourcesByType.get(resourceType) || [];
|
|
171
|
+
const exportEntries = [];
|
|
172
|
+
for (const resource of resources) {
|
|
173
|
+
const originalEntry = (0, bundle_operations_1.findOriginalEntry)(this.bundle, resource);
|
|
174
|
+
if (originalEntry) {
|
|
175
|
+
exportEntries.push((0, bundle_operations_1.createBundleEntry)(originalEntry, resource));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return (0, bundle_operations_1.createExportBundle)(this.bundle, exportEntries);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* FR-6.3: Export all resources of specified types
|
|
182
|
+
* FR-6.4: Exported bundles maintain original bundle metadata but update total count
|
|
183
|
+
* FR-6.6: Exported bundles preserve original entry.fullUrl values
|
|
184
|
+
*/
|
|
185
|
+
exportByTypes(resourceTypes) {
|
|
186
|
+
const exportEntries = [];
|
|
187
|
+
for (const resourceType of resourceTypes) {
|
|
188
|
+
const resources = this.resourcesByType.get(resourceType) || [];
|
|
189
|
+
for (const resource of resources) {
|
|
190
|
+
const originalEntry = (0, bundle_operations_1.findOriginalEntry)(this.bundle, resource);
|
|
191
|
+
if (originalEntry) {
|
|
192
|
+
exportEntries.push((0, bundle_operations_1.createBundleEntry)(originalEntry, resource));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return (0, bundle_operations_1.createExportBundle)(this.bundle, exportEntries);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Concatenate entries from another FhirBundleSdk with this bundle
|
|
200
|
+
* Returns a new bundle with combined entries while preserving original metadata
|
|
201
|
+
*/
|
|
202
|
+
async concatEntries(otherSdk) {
|
|
203
|
+
const currentEntries = this.bundle.entry || [];
|
|
204
|
+
const otherEntries = otherSdk.bundle.entry || [];
|
|
205
|
+
const combinedEntries = [...currentEntries, ...otherEntries];
|
|
206
|
+
const resultBundle = (0, bundle_operations_1.createExportBundle)(this.bundle, combinedEntries);
|
|
207
|
+
return await FhirBundleSdk.create(resultBundle);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Diff this bundle with another bundle or FhirBundleSdk by comparing resource ids.
|
|
211
|
+
* Returns three FhirBundleSdk instances: common, baseOnly, parameterOnly.
|
|
212
|
+
*/
|
|
213
|
+
async diff(other) {
|
|
214
|
+
const baseBundle = this.bundle;
|
|
215
|
+
const parameterBundle = other instanceof FhirBundleSdk ? other.bundle : other;
|
|
216
|
+
const commonEntries = [];
|
|
217
|
+
const baseOnlyEntries = [];
|
|
218
|
+
const parameterOnlyEntries = [];
|
|
219
|
+
// Create maps with resource identifiers (prefer resource.id, fallback to fullUrl)
|
|
220
|
+
const baseResourceIdentifiers = new Map();
|
|
221
|
+
const parameterResourceIdentifiers = new Map();
|
|
222
|
+
// Populate base bundle identifiers
|
|
223
|
+
for (const entry of baseBundle?.entry ?? []) {
|
|
224
|
+
const identifier = (0, sdk_types_1.getResourceIdentifier)(entry);
|
|
225
|
+
if (identifier) {
|
|
226
|
+
baseResourceIdentifiers.set(identifier, entry);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Populate parameter bundle identifiers
|
|
230
|
+
for (const entry of parameterBundle?.entry ?? []) {
|
|
231
|
+
const identifier = (0, sdk_types_1.getResourceIdentifier)(entry);
|
|
232
|
+
if (identifier) {
|
|
233
|
+
parameterResourceIdentifiers.set(identifier, entry);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// Find common and base-only resources
|
|
237
|
+
for (const [identifier, entry] of baseResourceIdentifiers.entries()) {
|
|
238
|
+
if (parameterResourceIdentifiers.has(identifier)) {
|
|
239
|
+
commonEntries.push(entry);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
baseOnlyEntries.push(entry);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// Find parameter-only resources
|
|
246
|
+
for (const [identifier, entry] of parameterResourceIdentifiers.entries()) {
|
|
247
|
+
if (!baseResourceIdentifiers.has(identifier)) {
|
|
248
|
+
parameterOnlyEntries.push(entry);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
common: await FhirBundleSdk.create((0, bundle_operations_1.createExportBundle)(this.bundle, commonEntries)),
|
|
253
|
+
baseOnly: await FhirBundleSdk.create((0, bundle_operations_1.createExportBundle)(this.bundle, baseOnlyEntries)),
|
|
254
|
+
parameterOnly: await FhirBundleSdk.create((0, bundle_operations_1.createExportBundle)(this.bundle, parameterOnlyEntries)),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Walk references from a starting resource using BFS traversal.
|
|
259
|
+
* Discovers all reachable resources up to maxDepth levels.
|
|
260
|
+
*
|
|
261
|
+
* @param startResource - The smart resource to start traversal from
|
|
262
|
+
* @param options - Walk options including maxDepth and includeStartResource
|
|
263
|
+
* @returns WalkResult containing all discovered resources organized by depth
|
|
264
|
+
*/
|
|
265
|
+
walkReferences(startResource, options) {
|
|
266
|
+
return (0, graph_traversal_1.walkReferences)(startResource, options);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Generate LLM-friendly context from a starting resource and its related resources.
|
|
270
|
+
* Uses BFS to discover related resources, strips non-clinical data, and formats output.
|
|
271
|
+
*
|
|
272
|
+
* @param startResource - The smart resource to start traversal from
|
|
273
|
+
* @param options - Options for depth, inclusion, and format
|
|
274
|
+
* @returns Formatted string suitable for LLM context
|
|
275
|
+
*/
|
|
276
|
+
generateLLMContext(startResource, options) {
|
|
277
|
+
return (0, llm_context_1.generateLLMContext)(startResource, options, (sr, opts) => this.walkReferences(sr, opts));
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get all resources that reference a given resource ID (reverse reference lookup).
|
|
281
|
+
* Operates in O(1) time complexity.
|
|
282
|
+
*
|
|
283
|
+
* @param targetId - The ID of the resource to find references to
|
|
284
|
+
* @param options - Optional filters for resourceType and referenceField
|
|
285
|
+
* @returns Array of smart resources that reference the target resource
|
|
286
|
+
*/
|
|
287
|
+
getResourcesReferencingId(targetId, options) {
|
|
288
|
+
const reverseRefs = this.reverseReferencesById.get(targetId) ?? [];
|
|
289
|
+
let filteredRefs = reverseRefs;
|
|
290
|
+
// Apply resource type filter
|
|
291
|
+
if (options?.resourceType) {
|
|
292
|
+
filteredRefs = filteredRefs.filter(ref => ref.sourceResourceType === options.resourceType);
|
|
293
|
+
}
|
|
294
|
+
// Apply reference field filter
|
|
295
|
+
if (options?.referenceField) {
|
|
296
|
+
filteredRefs = filteredRefs.filter(ref => ref.referenceField === options.referenceField);
|
|
297
|
+
}
|
|
298
|
+
// Convert to smart resources
|
|
299
|
+
const smartResources = [];
|
|
300
|
+
for (const ref of filteredRefs) {
|
|
301
|
+
const resource = this.getResourceById(ref.sourceResourceId);
|
|
302
|
+
if (resource) {
|
|
303
|
+
smartResources.push(resource);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return smartResources;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Search for resources by date range using interval tree.
|
|
310
|
+
* Operates in O(log n + k) time complexity, where k is the number of matching intervals.
|
|
311
|
+
*
|
|
312
|
+
* @param options - Search options including date range and optional filters
|
|
313
|
+
* @returns Array of smart resources that match the date range criteria
|
|
314
|
+
*/
|
|
315
|
+
searchByDateRange(options) {
|
|
316
|
+
const { dateFrom, dateTo, resourceTypes, dateFields } = options;
|
|
317
|
+
const fromMs = (0, date_extraction_1.parseDate)(typeof dateFrom === "string" ? dateFrom : dateFrom.toISOString());
|
|
318
|
+
const toMs = (0, date_extraction_1.parseDate)(dateTo
|
|
319
|
+
? typeof dateTo === "string"
|
|
320
|
+
? dateTo
|
|
321
|
+
: dateTo.toISOString()
|
|
322
|
+
: new Date().toISOString());
|
|
323
|
+
if (fromMs === undefined) {
|
|
324
|
+
throw new Error("Invalid dateFrom parameter");
|
|
325
|
+
}
|
|
326
|
+
if (toMs === undefined) {
|
|
327
|
+
throw new Error("Invalid dateTo parameter");
|
|
328
|
+
}
|
|
329
|
+
const matchingRecords = this.dateRangeIndex.search(fromMs, toMs);
|
|
330
|
+
let filteredRecords = matchingRecords;
|
|
331
|
+
if (resourceTypes && resourceTypes.length > 0) {
|
|
332
|
+
const resourceTypeSet = new Set(resourceTypes);
|
|
333
|
+
filteredRecords = filteredRecords.filter(record => resourceTypeSet.has(record.resourceType));
|
|
334
|
+
}
|
|
335
|
+
if (dateFields && dateFields.length > 0) {
|
|
336
|
+
const dateFieldSet = new Set(dateFields);
|
|
337
|
+
filteredRecords = filteredRecords.filter(record => dateFieldSet.has(record.dateField));
|
|
338
|
+
}
|
|
339
|
+
const resourceIdSet = new Set(filteredRecords.map(record => record.resourceId));
|
|
340
|
+
const smartResources = [];
|
|
341
|
+
for (const resourceId of resourceIdSet) {
|
|
342
|
+
const resource = this.getResourceById(resourceId);
|
|
343
|
+
if (resource) {
|
|
344
|
+
smartResources.push(resource);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return smartResources;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
exports.FhirBundleSdk = FhirBundleSdk;
|
|
351
|
+
/**
|
|
352
|
+
* Configuration for dynamically generated resource getter methods.
|
|
353
|
+
*
|
|
354
|
+
* Each entry in this array automatically generates both single and collection getter methods.
|
|
355
|
+
*
|
|
356
|
+
* **Example:**
|
|
357
|
+
* ```typescript
|
|
358
|
+
* {
|
|
359
|
+
* resourceType: 'Patient',
|
|
360
|
+
* singleGetterMethodName: 'getPatientById',
|
|
361
|
+
* collectionGetterMethodName: 'getPatients'
|
|
362
|
+
* }
|
|
363
|
+
* ```
|
|
364
|
+
*
|
|
365
|
+
* **Generates the equivalent of:**
|
|
366
|
+
* ```typescript
|
|
367
|
+
* // Single resource getter
|
|
368
|
+
* getPatientById(id: string): Smart<Patient> | undefined {
|
|
369
|
+
* return this.getResourceByIdAndType<Patient>(id, 'Patient');
|
|
370
|
+
* }
|
|
371
|
+
*
|
|
372
|
+
* // Collection getter
|
|
373
|
+
* getPatients(): Smart<Patient>[] {
|
|
374
|
+
* return this.getResourcesByType<Patient>('Patient');
|
|
375
|
+
* }
|
|
376
|
+
* ```
|
|
377
|
+
*
|
|
378
|
+
* **Usage:**
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const sdk = await FhirBundleSdk.create(bundle);
|
|
381
|
+
* const patient = sdk.getPatientById('patient-123'); // Smart<Patient> | undefined
|
|
382
|
+
* const allPatients = sdk.getPatients(); // Smart<Patient>[]
|
|
383
|
+
* ```
|
|
384
|
+
*
|
|
385
|
+
* To add a new resource type, simply add a new entry to this array and declare
|
|
386
|
+
* the corresponding method signatures in the class body.
|
|
387
|
+
*/
|
|
388
|
+
FhirBundleSdk.RESOURCE_METHODS = [
|
|
389
|
+
{
|
|
390
|
+
resourceType: "Patient",
|
|
391
|
+
singleGetterMethodName: "getPatientById",
|
|
392
|
+
collectionGetterMethodName: "getPatients",
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
resourceType: "Observation",
|
|
396
|
+
singleGetterMethodName: "getObservationById",
|
|
397
|
+
collectionGetterMethodName: "getObservations",
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
resourceType: "Encounter",
|
|
401
|
+
singleGetterMethodName: "getEncounterById",
|
|
402
|
+
collectionGetterMethodName: "getEncounters",
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
resourceType: "AllergyIntolerance",
|
|
406
|
+
singleGetterMethodName: "getAllergyIntoleranceById",
|
|
407
|
+
collectionGetterMethodName: "getAllergyIntolerances",
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
resourceType: "Condition",
|
|
411
|
+
singleGetterMethodName: "getConditionById",
|
|
412
|
+
collectionGetterMethodName: "getConditions",
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
resourceType: "Organization",
|
|
416
|
+
singleGetterMethodName: "getOrganizationById",
|
|
417
|
+
collectionGetterMethodName: "getOrganizations",
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
resourceType: "Location",
|
|
421
|
+
singleGetterMethodName: "getLocationById",
|
|
422
|
+
collectionGetterMethodName: "getLocations",
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
resourceType: "Practitioner",
|
|
426
|
+
singleGetterMethodName: "getPractitionerById",
|
|
427
|
+
collectionGetterMethodName: "getPractitioners",
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
resourceType: "DiagnosticReport",
|
|
431
|
+
singleGetterMethodName: "getDiagnosticReportById",
|
|
432
|
+
collectionGetterMethodName: "getDiagnosticReports",
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
resourceType: "Composition",
|
|
436
|
+
singleGetterMethodName: "getCompositionById",
|
|
437
|
+
collectionGetterMethodName: "getCompositions",
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
resourceType: "Coverage",
|
|
441
|
+
singleGetterMethodName: "getCoverageById",
|
|
442
|
+
collectionGetterMethodName: "getCoverages",
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
resourceType: "DocumentReference",
|
|
446
|
+
singleGetterMethodName: "getDocumentReferenceById",
|
|
447
|
+
collectionGetterMethodName: "getDocumentReferences",
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
resourceType: "Immunization",
|
|
451
|
+
singleGetterMethodName: "getImmunizationById",
|
|
452
|
+
collectionGetterMethodName: "getImmunizations",
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
resourceType: "Medication",
|
|
456
|
+
singleGetterMethodName: "getMedicationById",
|
|
457
|
+
collectionGetterMethodName: "getMedications",
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
resourceType: "MedicationRequest",
|
|
461
|
+
singleGetterMethodName: "getMedicationRequestById",
|
|
462
|
+
collectionGetterMethodName: "getMedicationRequests",
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
resourceType: "Procedure",
|
|
466
|
+
singleGetterMethodName: "getProcedureById",
|
|
467
|
+
collectionGetterMethodName: "getProcedures",
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
resourceType: "FamilyMemberHistory",
|
|
471
|
+
singleGetterMethodName: "getFamilyMemberHistoryById",
|
|
472
|
+
collectionGetterMethodName: "getFamilyMemberHistories",
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
resourceType: "MedicationAdministration",
|
|
476
|
+
singleGetterMethodName: "getMedicationAdministrationById",
|
|
477
|
+
collectionGetterMethodName: "getMedicationAdministrations",
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
resourceType: "MedicationDispense",
|
|
481
|
+
singleGetterMethodName: "getMedicationDispenseById",
|
|
482
|
+
collectionGetterMethodName: "getMedicationDispenses",
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
resourceType: "MedicationStatement",
|
|
486
|
+
singleGetterMethodName: "getMedicationStatementById",
|
|
487
|
+
collectionGetterMethodName: "getMedicationStatements",
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
resourceType: "RelatedPerson",
|
|
491
|
+
singleGetterMethodName: "getRelatedPersonById",
|
|
492
|
+
collectionGetterMethodName: "getRelatedPersons",
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
resourceType: "RiskAssessment",
|
|
496
|
+
singleGetterMethodName: "getRiskAssessmentById",
|
|
497
|
+
collectionGetterMethodName: "getRiskAssessments",
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
resourceType: "ServiceRequest",
|
|
501
|
+
singleGetterMethodName: "getServiceRequestById",
|
|
502
|
+
collectionGetterMethodName: "getServiceRequests",
|
|
503
|
+
},
|
|
504
|
+
];
|
|
505
|
+
// Static initialization block to generate methods
|
|
506
|
+
(() => {
|
|
507
|
+
// Generate both single and collection getter methods from unified configuration
|
|
508
|
+
for (const { resourceType, singleGetterMethodName, collectionGetterMethodName, } of FhirBundleSdk.RESOURCE_METHODS) {
|
|
509
|
+
// Generate single resource getter (e.g., getPatientById)
|
|
510
|
+
Object.defineProperty(FhirBundleSdk.prototype, singleGetterMethodName, {
|
|
511
|
+
value: function (id) {
|
|
512
|
+
return this.getResourceByIdAndType(id, resourceType);
|
|
513
|
+
},
|
|
514
|
+
writable: false,
|
|
515
|
+
configurable: false,
|
|
516
|
+
});
|
|
517
|
+
// Generate collection getter (e.g., getPatients)
|
|
518
|
+
Object.defineProperty(FhirBundleSdk.prototype, collectionGetterMethodName, {
|
|
519
|
+
value: function () {
|
|
520
|
+
return this.getResourcesByType(resourceType);
|
|
521
|
+
},
|
|
522
|
+
writable: false,
|
|
523
|
+
configurable: false,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
})();
|
|
527
|
+
//# sourceMappingURL=fhir-bundle-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fhir-bundle-sdk.js","sourceRoot":"","sources":["../src/fhir-bundle-sdk.ts"],"names":[],"mappings":";;;AA+BA,iDAW2B;AAC3B,yDAAqD;AACrD,sDAA+F;AAC/F,gEAAuD;AACvD,kDAA2D;AAC3D,0EAAiG;AACjG,oEAIs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