@metriport/fhir-sdk 1.6.2 → 1.7.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.
Files changed (81) hide show
  1. package/dist/__tests__/careplan.test.js +24 -22
  2. package/dist/__tests__/careplan.test.js.map +1 -1
  3. package/dist/__tests__/clinical-dates.test.js +25 -23
  4. package/dist/__tests__/clinical-dates.test.js.map +1 -1
  5. package/dist/__tests__/coding-utilities.test.js +9 -7
  6. package/dist/__tests__/coding-utilities.test.js.map +1 -1
  7. package/dist/__tests__/date-range-performance.test.js +4 -2
  8. package/dist/__tests__/date-range-performance.test.js.map +1 -1
  9. package/dist/__tests__/date-range-search.test.js +15 -13
  10. package/dist/__tests__/date-range-search.test.js.map +1 -1
  11. package/dist/__tests__/env-setup.js +32 -4
  12. package/dist/__tests__/env-setup.js.map +1 -1
  13. package/dist/__tests__/fhir-bundle-sdk-basic.test.js +6 -4
  14. package/dist/__tests__/fhir-bundle-sdk-basic.test.js.map +1 -1
  15. package/dist/__tests__/fhir-bundle-sdk.test.js +87 -85
  16. package/dist/__tests__/fhir-bundle-sdk.test.js.map +1 -1
  17. package/dist/__tests__/fixtures/fhir-bundles.d.ts +1 -1
  18. package/dist/__tests__/fixtures/fhir-bundles.d.ts.map +1 -1
  19. package/dist/__tests__/fixtures/fhir-bundles.js +17 -11
  20. package/dist/__tests__/fixtures/fhir-bundles.js.map +1 -1
  21. package/dist/__tests__/phase1-verification.test.js +12 -10
  22. package/dist/__tests__/phase1-verification.test.js.map +1 -1
  23. package/dist/__tests__/phase2-verification.test.js +16 -14
  24. package/dist/__tests__/phase2-verification.test.js.map +1 -1
  25. package/dist/__tests__/phase3-verification.test.js +17 -15
  26. package/dist/__tests__/phase3-verification.test.js.map +1 -1
  27. package/dist/__tests__/phase4-verification.test.js +29 -27
  28. package/dist/__tests__/phase4-verification.test.js.map +1 -1
  29. package/dist/__tests__/phase5-verification.test.js +40 -38
  30. package/dist/__tests__/phase5-verification.test.js.map +1 -1
  31. package/dist/__tests__/reverse-references.test.js +31 -29
  32. package/dist/__tests__/reverse-references.test.js.map +1 -1
  33. package/dist/__tests__/type-guards.test.js +18 -16
  34. package/dist/__tests__/type-guards.test.js.map +1 -1
  35. package/dist/clinical-dates.js +5 -1
  36. package/dist/clinical-dates.js.map +1 -1
  37. package/dist/fhir-bundle-sdk.js +38 -34
  38. package/dist/fhir-bundle-sdk.js.map +1 -1
  39. package/dist/index.js +22 -4
  40. package/dist/index.js.map +1 -1
  41. package/dist/internal/bundle-operations.js +9 -3
  42. package/dist/internal/bundle-operations.js.map +1 -1
  43. package/dist/internal/coding-systems.d.ts +12 -12
  44. package/dist/internal/coding-systems.js +18 -15
  45. package/dist/internal/coding-systems.js.map +1 -1
  46. package/dist/internal/coding-utilities.js +23 -15
  47. package/dist/internal/coding-utilities.js.map +1 -1
  48. package/dist/internal/date-extraction.js +7 -2
  49. package/dist/internal/date-extraction.js.map +1 -1
  50. package/dist/internal/graph-traversal.js +7 -3
  51. package/dist/internal/graph-traversal.js.map +1 -1
  52. package/dist/internal/indexing.js +15 -9
  53. package/dist/internal/indexing.js.map +1 -1
  54. package/dist/internal/llm-context.js +17 -8
  55. package/dist/internal/llm-context.js.map +1 -1
  56. package/dist/internal/reference-resolution.js +32 -25
  57. package/dist/internal/reference-resolution.js.map +1 -1
  58. package/dist/internal/reference-utils.js +11 -4
  59. package/dist/internal/reference-utils.js.map +1 -1
  60. package/dist/internal/transparent-proxy.js +14 -10
  61. package/dist/internal/transparent-proxy.js.map +1 -1
  62. package/dist/internal/validation.js +8 -4
  63. package/dist/internal/validation.js.map +1 -1
  64. package/dist/type-guards.d.ts +134 -105
  65. package/dist/type-guards.d.ts.map +1 -1
  66. package/dist/type-guards.js +322 -26
  67. package/dist/type-guards.js.map +1 -1
  68. package/dist/types/coding-fields.js +2 -1
  69. package/dist/types/sdk-types.js +5 -1
  70. package/dist/types/sdk-types.js.map +1 -1
  71. package/dist/types/smart-resources.js +10 -5
  72. package/dist/types/smart-resources.js.map +1 -1
  73. package/dist/utils/interval-tree/index.js +19 -10
  74. package/dist/utils/interval-tree/index.js.map +1 -1
  75. package/dist/utils/interval-tree/shallowequal/arrays.js +4 -1
  76. package/dist/utils/interval-tree/shallowequal/arrays.js.map +1 -1
  77. package/dist/utils/interval-tree/shallowequal/index.js +13 -5
  78. package/dist/utils/interval-tree/shallowequal/index.js.map +1 -1
  79. package/dist/utils/interval-tree/shallowequal/objects.js +4 -1
  80. package/dist/utils/interval-tree/shallowequal/objects.js.map +1 -1
  81. package/package.json +4 -3
@@ -1,46 +1,48 @@
1
- import { FhirBundleSdk } from "../index";
2
- import { validCompleteBundle, bundleWithBrokenReferences, bundleWithFullUrlReferences, emptyBundle, patientsOnlyBundle, invalidBundleWrongType, mixedResourceTypesBundle, CONSTANT_TIME_EXPECTED_THRESHOLD_MS, } from "./fixtures/fhir-bundles";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("../index");
4
+ const fhir_bundles_1 = require("./fixtures/fhir-bundles");
3
5
  describe("FhirBundleSdk", () => {
4
6
  describe("Bundle Loading and Initialization", () => {
5
7
  describe("FR-1.1: SDK constructor accepts a FHIR Bundle object", () => {
6
8
  it("should accept a valid FHIR bundle", async () => {
7
- await expect(FhirBundleSdk.create(validCompleteBundle)).resolves.not.toThrow();
9
+ await expect(index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle)).resolves.not.toThrow();
8
10
  });
9
11
  });
10
12
  describe("FR-1.2: SDK constructor throws error if bundle.resourceType !== 'Bundle'", () => {
11
13
  it("should throw error for invalid resourceType", async () => {
12
- await expect(FhirBundleSdk.create(invalidBundleWrongType)).rejects.toThrow();
14
+ await expect(index_1.FhirBundleSdk.create(fhir_bundles_1.invalidBundleWrongType)).rejects.toThrow();
13
15
  });
14
16
  });
15
17
  describe("FR-1.4: SDK constructor creates internal indexes for O(1) resource lookup", () => {
16
18
  it("should create internal indexes during construction", async () => {
17
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
19
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
18
20
  const start = performance.now();
19
21
  const patient = sdk.getResourceById("patient-123");
20
22
  const end = performance.now();
21
23
  expect(patient).toBeDefined();
22
24
  expect(patient?.resourceType).toBe("Patient");
23
- expect(end - start).toBeLessThan(CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
25
+ expect(end - start).toBeLessThan(fhir_bundles_1.CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
24
26
  });
25
27
  });
26
28
  });
27
29
  describe("Reference Validation", () => {
28
30
  describe("FR-2.1: lookForBrokenReferences() method returns validation result", () => {
29
31
  it("should return validation result for valid bundle", async () => {
30
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
32
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
31
33
  const result = sdk.lookForBrokenReferences();
32
34
  expect(result).toBeDefined();
33
35
  expect(typeof result.hasBrokenReferences).toBe("boolean");
34
36
  expect(Array.isArray(result.brokenReferences)).toBe(true);
35
37
  });
36
38
  it("should return true for valid references", async () => {
37
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
39
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
38
40
  const result = sdk.lookForBrokenReferences();
39
41
  expect(result.hasBrokenReferences).toBe(false);
40
42
  expect(result.brokenReferences).toHaveLength(0);
41
43
  });
42
44
  it("should return false for invalid references", async () => {
43
- const sdk = await FhirBundleSdk.create(bundleWithBrokenReferences);
45
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithBrokenReferences);
44
46
  const result = sdk.lookForBrokenReferences();
45
47
  expect(result.hasBrokenReferences).toBe(true);
46
48
  expect(result.brokenReferences.length).toBeGreaterThan(0);
@@ -48,32 +50,32 @@ describe("FhirBundleSdk", () => {
48
50
  });
49
51
  describe("FR-2.2: Validation identifies references by Resource/id pattern and fullUrl references", () => {
50
52
  it("should identify Resource/id pattern references", async () => {
51
- const sdk = await FhirBundleSdk.create(bundleWithBrokenReferences);
53
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithBrokenReferences);
52
54
  const result = sdk.lookForBrokenReferences();
53
55
  const brokenSubjectRef = result.brokenReferences.find(ref => ref.reference === "Patient/nonexistent-patient");
54
56
  expect(brokenSubjectRef).toBeDefined();
55
57
  });
56
58
  it("should validate fullUrl references", async () => {
57
- const sdk = await FhirBundleSdk.create(bundleWithFullUrlReferences);
59
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithFullUrlReferences);
58
60
  const result = sdk.lookForBrokenReferences();
59
61
  expect(result.hasBrokenReferences).toBe(false);
60
62
  });
61
63
  });
62
64
  describe("FR-2.3: Validation handles both relative and absolute references", () => {
63
65
  it("should handle relative references (Patient/123)", async () => {
64
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
66
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
65
67
  const result = sdk.lookForBrokenReferences();
66
68
  expect(result.hasBrokenReferences).toBe(false);
67
69
  });
68
70
  it("should handle absolute references (urn:uuid:123)", async () => {
69
- const sdk = await FhirBundleSdk.create(bundleWithFullUrlReferences);
71
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithFullUrlReferences);
70
72
  const result = sdk.lookForBrokenReferences();
71
73
  expect(result.hasBrokenReferences).toBe(false);
72
74
  });
73
75
  });
74
76
  describe("FR-2.4: Validation result includes list of broken references with details", () => {
75
77
  it("should provide detailed broken reference information", async () => {
76
- const sdk = await FhirBundleSdk.create(bundleWithBrokenReferences);
78
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithBrokenReferences);
77
79
  const result = sdk.lookForBrokenReferences();
78
80
  expect(result.brokenReferences.length).toBeGreaterThan(0);
79
81
  const brokenRef = result.brokenReferences[0];
@@ -90,7 +92,7 @@ describe("FhirBundleSdk", () => {
90
92
  describe("Resource Retrieval by ID", () => {
91
93
  describe("FR-3.1: getResourceById<T>(id: string): T | undefined returns resource matching the ID", () => {
92
94
  it("should return resource by ID", async () => {
93
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
95
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
94
96
  const patient = sdk.getResourceById("patient-123");
95
97
  expect(patient).toBeDefined();
96
98
  expect(patient?.id).toBe("patient-123");
@@ -99,19 +101,19 @@ describe("FhirBundleSdk", () => {
99
101
  });
100
102
  describe("FR-3.2: Method searches both resource.id and entry.fullUrl for matches", () => {
101
103
  it("should find resource by resource.id", async () => {
102
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
104
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
103
105
  const patient = sdk.getResourceById("patient-123");
104
106
  expect(patient?.id).toBe("patient-123");
105
107
  });
106
108
  it("should find resource by fullUrl", async () => {
107
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
109
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
108
110
  const patient = sdk.getResourceById("urn:uuid:patient-123");
109
111
  expect(patient?.id).toBe("patient-123");
110
112
  });
111
113
  });
112
114
  describe("FR-3.3: Method supports type parameter for proper TypeScript return typing", () => {
113
115
  it("should return properly typed resource", async () => {
114
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
116
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
115
117
  const patient = sdk.getResourceById("patient-123");
116
118
  // TypeScript should infer this as Patient | undefined
117
119
  expect(patient?.name).toBeDefined();
@@ -120,26 +122,26 @@ describe("FhirBundleSdk", () => {
120
122
  });
121
123
  describe("FR-3.4: Method returns undefined if resource not found", () => {
122
124
  it("should return undefined for nonexistent resource", async () => {
123
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
125
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
124
126
  const result = sdk.getResourceById("nonexistent-id");
125
127
  expect(result).toBeUndefined();
126
128
  });
127
129
  });
128
130
  describe("FR-3.5: Lookup operates in O(1) time complexity", () => {
129
131
  it("should perform lookup in O(1) time", async () => {
130
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
132
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
131
133
  const start = performance.now();
132
134
  sdk.getResourceById("patient-123");
133
135
  const end = performance.now();
134
136
  // O(1) lookup should be very fast
135
- expect(end - start).toBeLessThan(CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
137
+ expect(end - start).toBeLessThan(fhir_bundles_1.CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
136
138
  });
137
139
  });
138
140
  });
139
141
  describe("Type-Specific Resource Getters", () => {
140
142
  describe("FR-4.1: getPatients(): Patient[] returns all Patient resources", () => {
141
143
  it("should return all patients", async () => {
142
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
144
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
143
145
  const patients = sdk.getPatients();
144
146
  expect(Array.isArray(patients)).toBe(true);
145
147
  expect(patients).toHaveLength(1);
@@ -148,7 +150,7 @@ describe("FhirBundleSdk", () => {
148
150
  });
149
151
  describe("FR-4.2: getObservations(): Observation[] returns all Observation resources", () => {
150
152
  it("should return all observations", async () => {
151
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
153
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
152
154
  const observations = sdk.getObservations();
153
155
  expect(Array.isArray(observations)).toBe(true);
154
156
  expect(observations).toHaveLength(1);
@@ -157,7 +159,7 @@ describe("FhirBundleSdk", () => {
157
159
  });
158
160
  describe("FR-4.3: getEncounters(): Encounter[] returns all Encounter resources", () => {
159
161
  it("should return all encounters", async () => {
160
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
162
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
161
163
  const encounters = sdk.getEncounters();
162
164
  expect(Array.isArray(encounters)).toBe(true);
163
165
  expect(encounters).toHaveLength(1);
@@ -166,7 +168,7 @@ describe("FhirBundleSdk", () => {
166
168
  });
167
169
  describe("FR-4.4: getPractitioners(): Practitioner[] returns all Practitioner resources", () => {
168
170
  it("should return all practitioners", async () => {
169
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
171
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
170
172
  const practitioners = sdk.getPractitioners();
171
173
  expect(Array.isArray(practitioners)).toBe(true);
172
174
  expect(practitioners).toHaveLength(1);
@@ -175,7 +177,7 @@ describe("FhirBundleSdk", () => {
175
177
  });
176
178
  describe("FR-4.5: getDiagnosticReports(): DiagnosticReport[] returns all DiagnosticReport resources", () => {
177
179
  it("should return all diagnostic reports", async () => {
178
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
180
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
179
181
  const reports = sdk.getDiagnosticReports();
180
182
  expect(Array.isArray(reports)).toBe(true);
181
183
  expect(reports).toHaveLength(1);
@@ -184,7 +186,7 @@ describe("FhirBundleSdk", () => {
184
186
  });
185
187
  describe("FR-4.6: All type-specific getters return empty array if no resources of that type exist", () => {
186
188
  it("should return empty array when no resources exist", async () => {
187
- const sdk = await FhirBundleSdk.create(emptyBundle);
189
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.emptyBundle);
188
190
  expect(sdk.getPatients()).toEqual([]);
189
191
  expect(sdk.getObservations()).toEqual([]);
190
192
  expect(sdk.getEncounters()).toEqual([]);
@@ -192,7 +194,7 @@ describe("FhirBundleSdk", () => {
192
194
  expect(sdk.getDiagnosticReports()).toEqual([]);
193
195
  });
194
196
  it("should return empty array for missing resource types", async () => {
195
- const sdk = await FhirBundleSdk.create(patientsOnlyBundle);
197
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.patientsOnlyBundle);
196
198
  expect(sdk.getPatients()).toHaveLength(3);
197
199
  expect(sdk.getObservations()).toEqual([]);
198
200
  expect(sdk.getEncounters()).toEqual([]);
@@ -202,7 +204,7 @@ describe("FhirBundleSdk", () => {
202
204
  });
203
205
  describe("FR-4.7: All methods use @medplum/fhirtypes for return type definitions", () => {
204
206
  it("should return properly typed resources", async () => {
205
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
207
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
206
208
  const patients = sdk.getPatients();
207
209
  const observations = sdk.getObservations();
208
210
  const encounters = sdk.getEncounters();
@@ -220,7 +222,7 @@ describe("FhirBundleSdk", () => {
220
222
  describe("Smart Reference Resolution", () => {
221
223
  describe("FR-5.1: Resources returned by SDK have additional getter methods for each Reference field", () => {
222
224
  it("should add getter methods for reference fields", async () => {
223
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
225
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
224
226
  const observations = sdk.getObservations();
225
227
  const observation = observations[0];
226
228
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -233,7 +235,7 @@ describe("FhirBundleSdk", () => {
233
235
  });
234
236
  describe("FR-5.2: For Observation.subject reference, SDK adds getSubject() method", () => {
235
237
  it("should resolve subject reference to Patient", async () => {
236
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
238
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
237
239
  const observations = sdk.getObservations();
238
240
  const observation = observations[0];
239
241
  const subject = observation?.getSubject();
@@ -244,7 +246,7 @@ describe("FhirBundleSdk", () => {
244
246
  });
245
247
  describe("FR-5.3: For Observation.encounter reference, SDK adds getEncounter() method", () => {
246
248
  it("should resolve encounter reference to Encounter", async () => {
247
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
249
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
248
250
  const observations = sdk.getObservations();
249
251
  const observation = observations[0];
250
252
  const encounter = observation?.getEncounter();
@@ -255,7 +257,7 @@ describe("FhirBundleSdk", () => {
255
257
  });
256
258
  describe("FR-5.4: For Observation.performer reference array, SDK adds getPerformer() method", () => {
257
259
  it("should resolve performer references to array of resources", async () => {
258
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
260
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
259
261
  const observations = sdk.getObservations();
260
262
  const observation = observations[0];
261
263
  const performers = observation?.getPerformers();
@@ -267,13 +269,13 @@ describe("FhirBundleSdk", () => {
267
269
  });
268
270
  describe("FR-5.5: Reference resolution methods handle both resource.id and fullUrl matching", () => {
269
271
  it("should resolve references by resource.id", async () => {
270
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
272
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
271
273
  const observations = sdk.getObservations();
272
274
  const subject = observations[0]?.getSubject();
273
275
  expect(subject?.id).toBe("patient-123");
274
276
  });
275
277
  it("should resolve references by fullUrl", async () => {
276
- const sdk = await FhirBundleSdk.create(bundleWithFullUrlReferences);
278
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithFullUrlReferences);
277
279
  const observations = sdk.getObservations();
278
280
  const subject = observations[0]?.getSubject();
279
281
  expect(subject?.id).toBe("patient-fullurl");
@@ -281,7 +283,7 @@ describe("FhirBundleSdk", () => {
281
283
  });
282
284
  describe("FR-5.6: Reference resolution methods return undefined for unresolvable references", () => {
283
285
  it("should return undefined for broken references", async () => {
284
- const sdk = await FhirBundleSdk.create(bundleWithBrokenReferences);
286
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithBrokenReferences);
285
287
  const observations = sdk.getObservations();
286
288
  const observation = observations[0];
287
289
  expect(observation?.getSubject()).toBeUndefined();
@@ -291,19 +293,19 @@ describe("FhirBundleSdk", () => {
291
293
  });
292
294
  describe("FR-5.7: Reference resolution operates in O(1) time complexity per reference", () => {
293
295
  it("should resolve references in O(1) time", async () => {
294
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
296
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
295
297
  const observations = sdk.getObservations();
296
298
  const observation = observations[0];
297
299
  const start = performance.now();
298
300
  observation?.getSubject();
299
301
  const end = performance.now();
300
302
  // O(1) resolution should be very fast
301
- expect(end - start).toBeLessThan(CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
303
+ expect(end - start).toBeLessThan(fhir_bundles_1.CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
302
304
  });
303
305
  });
304
306
  describe("FR-5.8: Original reference fields remain unchanged", () => {
305
307
  it("should preserve original reference fields", async () => {
306
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
308
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
307
309
  const observations = sdk.getObservations();
308
310
  const observation = observations[0];
309
311
  expect(observation?.subject?.reference).toBe("Patient/patient-123");
@@ -315,7 +317,7 @@ describe("FhirBundleSdk", () => {
315
317
  describe("Bundle Export Functionality", () => {
316
318
  describe("FR-6.1: exportSubset(resourceIds: string[]): Bundle creates new bundle with specified resources", () => {
317
319
  it("should export subset of resources by ID", async () => {
318
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
320
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
319
321
  const subset = sdk.exportSubset(["patient-123", "observation-001"]);
320
322
  expect(subset.resourceType).toBe("Bundle");
321
323
  expect(subset.type).toBe("collection");
@@ -325,7 +327,7 @@ describe("FhirBundleSdk", () => {
325
327
  });
326
328
  describe("FR-6.2: exportByType(resourceType: string): Bundle creates new bundle with all resources of specified type", () => {
327
329
  it("should export all resources of specified type", async () => {
328
- const sdk = await FhirBundleSdk.create(mixedResourceTypesBundle);
330
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.mixedResourceTypesBundle);
329
331
  const patientBundle = sdk.exportByType("Patient");
330
332
  expect(patientBundle.resourceType).toBe("Bundle");
331
333
  expect(patientBundle.type).toBe("collection");
@@ -338,7 +340,7 @@ describe("FhirBundleSdk", () => {
338
340
  });
339
341
  describe("FR-6.3: exportByTypes(resourceTypes: string[]): Bundle creates new bundle with all resources of specified types", () => {
340
342
  it("should export all resources of specified types", async () => {
341
- const sdk = await FhirBundleSdk.create(mixedResourceTypesBundle);
343
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.mixedResourceTypesBundle);
342
344
  const bundle = sdk.exportByTypes(["Patient", "Observation"]);
343
345
  expect(bundle.resourceType).toBe("Bundle");
344
346
  expect(bundle.type).toBe("collection");
@@ -348,7 +350,7 @@ describe("FhirBundleSdk", () => {
348
350
  });
349
351
  describe("FR-6.4: Exported bundles maintain original bundle metadata but update total count", () => {
350
352
  it("should maintain metadata and update total", async () => {
351
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
353
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
352
354
  const subset = sdk.exportSubset(["patient-123"]);
353
355
  expect(subset.resourceType).toBe("Bundle");
354
356
  expect(subset.type).toBe("collection");
@@ -358,7 +360,7 @@ describe("FhirBundleSdk", () => {
358
360
  });
359
361
  describe("FR-6.5: Exported bundles include only resources that exist in the original bundle", () => {
360
362
  it("should ignore nonexistent resource IDs", async () => {
361
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
363
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
362
364
  const subset = sdk.exportSubset(["patient-123", "nonexistent-id"]);
363
365
  expect(subset.entry).toHaveLength(1);
364
366
  expect(subset.total).toBe(1);
@@ -366,7 +368,7 @@ describe("FhirBundleSdk", () => {
366
368
  });
367
369
  describe("FR-6.6: Exported bundles preserve original entry.fullUrl values", () => {
368
370
  it("should preserve fullUrl values", async () => {
369
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
371
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
370
372
  const subset = sdk.exportSubset(["patient-123"]);
371
373
  expect(subset.entry?.[0]?.fullUrl).toBe("urn:uuid:patient-123");
372
374
  });
@@ -375,7 +377,7 @@ describe("FhirBundleSdk", () => {
375
377
  describe("Error Handling", () => {
376
378
  describe("FR-7.1: All methods handle malformed resource references gracefully", () => {
377
379
  it("should handle malformed references without throwing", async () => {
378
- const sdk = await FhirBundleSdk.create(bundleWithBrokenReferences);
380
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithBrokenReferences);
379
381
  expect(() => {
380
382
  const observations = sdk.getObservations();
381
383
  observations[0]?.getSubject();
@@ -384,12 +386,12 @@ describe("FhirBundleSdk", () => {
384
386
  });
385
387
  describe("FR-7.2: SDK throws descriptive errors for invalid bundle structure during initialization", () => {
386
388
  it("should throw descriptive error for invalid bundle", async () => {
387
- await expect(FhirBundleSdk.create(invalidBundleWrongType)).rejects.toThrow("Invalid bundle: resourceType must be 'Bundle'");
389
+ await expect(index_1.FhirBundleSdk.create(fhir_bundles_1.invalidBundleWrongType)).rejects.toThrow("Invalid bundle: resourceType must be 'Bundle'");
388
390
  });
389
391
  });
390
392
  describe("FR-7.3: Reference resolution methods never throw errors, only return undefined for invalid references", () => {
391
393
  it("should return undefined instead of throwing for invalid references", async () => {
392
- const sdk = await FhirBundleSdk.create(bundleWithBrokenReferences);
394
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithBrokenReferences);
393
395
  const observations = sdk.getObservations();
394
396
  expect(() => observations[0]?.getSubject()).not.toThrow();
395
397
  expect(observations[0]?.getSubject()).toBeUndefined();
@@ -399,38 +401,38 @@ describe("FhirBundleSdk", () => {
399
401
  describe("Performance Requirements", () => {
400
402
  describe("FR-9.1: Resource lookup by ID completes in O(1) time", () => {
401
403
  it("should perform ID lookup in O(1) time", async () => {
402
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
404
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
403
405
  const start = performance.now();
404
406
  sdk.getResourceById("patient-123");
405
407
  const end = performance.now();
406
- expect(end - start).toBeLessThan(CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
408
+ expect(end - start).toBeLessThan(fhir_bundles_1.CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
407
409
  });
408
410
  });
409
411
  describe("FR-9.2: Type-specific getters complete in O(n) time where n is number of resources of that type", () => {
410
412
  it("should perform type-specific queries efficiently", async () => {
411
- const sdk = await FhirBundleSdk.create(mixedResourceTypesBundle);
413
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.mixedResourceTypesBundle);
412
414
  const start = performance.now();
413
415
  const patients = sdk.getPatients();
414
416
  const end = performance.now();
415
417
  expect(patients).toHaveLength(2);
416
- expect(end - start).toBeLessThan(CONSTANT_TIME_EXPECTED_THRESHOLD_MS * 2); // Should be fast for small bundles
418
+ expect(end - start).toBeLessThan(fhir_bundles_1.CONSTANT_TIME_EXPECTED_THRESHOLD_MS * 2); // Should be fast for small bundles
417
419
  });
418
420
  });
419
421
  describe("FR-9.4: Reference resolution per reference completes in O(1) time", () => {
420
422
  it("should resolve references in O(1) time", async () => {
421
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
423
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
422
424
  const observations = sdk.getObservations();
423
425
  const start = performance.now();
424
426
  observations[0]?.getSubject();
425
427
  const end = performance.now();
426
- expect(end - start).toBeLessThan(CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
428
+ expect(end - start).toBeLessThan(fhir_bundles_1.CONSTANT_TIME_EXPECTED_THRESHOLD_MS);
427
429
  });
428
430
  });
429
431
  });
430
432
  describe("Reference Walking (BFS)", () => {
431
433
  describe("Basic single-level traversal", () => {
432
434
  it("should walk references from an Observation to related resources", async () => {
433
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
435
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
434
436
  const observation = sdk.getObservationById("observation-001");
435
437
  if (observation === undefined) {
436
438
  throw new Error("Observation not found");
@@ -451,7 +453,7 @@ describe("FhirBundleSdk", () => {
451
453
  expect(resourceIds).toContain("practitioner-456"); // performer
452
454
  });
453
455
  it("should organize resources by depth level", async () => {
454
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
456
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
455
457
  const observation = sdk.getObservationById("observation-001");
456
458
  if (observation === undefined) {
457
459
  throw new Error("Observation not found");
@@ -474,7 +476,7 @@ describe("FhirBundleSdk", () => {
474
476
  expect(depth1.length).toBeGreaterThan(0);
475
477
  });
476
478
  it("should report the depth reached", async () => {
477
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
479
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
478
480
  const observation = sdk.getObservationById("observation-001");
479
481
  if (observation === undefined) {
480
482
  throw new Error("Observation not found");
@@ -486,7 +488,7 @@ describe("FhirBundleSdk", () => {
486
488
  });
487
489
  describe("Multi-level traversal", () => {
488
490
  it("should traverse multiple levels from DiagnosticReport", async () => {
489
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
491
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
490
492
  const diagnosticReport = sdk.getDiagnosticReportById("diagnostic-report-002");
491
493
  if (diagnosticReport === undefined) {
492
494
  throw new Error("DiagnosticReport not found");
@@ -502,7 +504,7 @@ describe("FhirBundleSdk", () => {
502
504
  });
503
505
  describe("Include start resource option", () => {
504
506
  it("should include start resource by default", async () => {
505
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
507
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
506
508
  const observation = sdk.getObservationById("observation-001");
507
509
  if (observation === undefined) {
508
510
  throw new Error("Observation not found");
@@ -511,7 +513,7 @@ describe("FhirBundleSdk", () => {
511
513
  expect(result.allResources.map(r => r.id)).toContain("observation-001");
512
514
  });
513
515
  it("should exclude start resource when includeStartResource is false", async () => {
514
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
516
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
515
517
  const observation = sdk.getObservationById("observation-001");
516
518
  if (observation === undefined) {
517
519
  throw new Error("Observation not found");
@@ -524,7 +526,7 @@ describe("FhirBundleSdk", () => {
524
526
  });
525
527
  describe("Max depth limiting", () => {
526
528
  it("should respect maxDepth of 0 (only start resource)", async () => {
527
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
529
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
528
530
  const observation = sdk.getObservationById("observation-001");
529
531
  if (observation === undefined) {
530
532
  throw new Error("Observation not found");
@@ -538,7 +540,7 @@ describe("FhirBundleSdk", () => {
538
540
  expect(result.resourcesByDepth.size).toBe(1);
539
541
  });
540
542
  it("should respect maxDepth of 1 (start + direct references)", async () => {
541
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
543
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
542
544
  const observation = sdk.getObservationById("observation-001");
543
545
  if (observation === undefined) {
544
546
  throw new Error("Observation not found");
@@ -555,7 +557,7 @@ describe("FhirBundleSdk", () => {
555
557
  expect(result.resourcesByDepth.has(2)).toBe(false);
556
558
  });
557
559
  it("should respect maxDepth of 2 from DiagnosticReport", async () => {
558
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
560
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
559
561
  const diagnosticReport = sdk.getDiagnosticReportById("diagnostic-report-002");
560
562
  if (diagnosticReport === undefined) {
561
563
  throw new Error("DiagnosticReport not found");
@@ -575,7 +577,7 @@ describe("FhirBundleSdk", () => {
575
577
  expect(allResourceIds).toContain("patient-123");
576
578
  });
577
579
  it("should handle Infinity maxDepth (default)", async () => {
578
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
580
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
579
581
  const observation = sdk.getObservationById("observation-001");
580
582
  if (observation === undefined) {
581
583
  throw new Error("Observation not found");
@@ -610,7 +612,7 @@ describe("FhirBundleSdk", () => {
610
612
  },
611
613
  ],
612
614
  };
613
- const sdk = await FhirBundleSdk.create(circularBundle);
615
+ const sdk = await index_1.FhirBundleSdk.create(circularBundle);
614
616
  const org1 = sdk.getOrganizationById("org-1");
615
617
  // Should complete without hanging
616
618
  if (org1 === undefined) {
@@ -626,7 +628,7 @@ describe("FhirBundleSdk", () => {
626
628
  });
627
629
  describe("Array reference handling", () => {
628
630
  it("should handle array references correctly", async () => {
629
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
631
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
630
632
  const observation = sdk.getObservationById("observation-001");
631
633
  if (observation === undefined) {
632
634
  throw new Error("Observation not found");
@@ -637,7 +639,7 @@ describe("FhirBundleSdk", () => {
637
639
  expect(result.allResources.map(r => r.id)).toContain(practitionerId);
638
640
  });
639
641
  it("should handle DiagnosticReport result array", async () => {
640
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
642
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
641
643
  const diagnosticReport = sdk.getDiagnosticReportById("diagnostic-report-002");
642
644
  if (diagnosticReport === undefined) {
643
645
  throw new Error("DiagnosticReport not found");
@@ -662,7 +664,7 @@ describe("FhirBundleSdk", () => {
662
664
  },
663
665
  ],
664
666
  };
665
- const sdk = await FhirBundleSdk.create(bundleWithIsolatedPatient);
667
+ const sdk = await index_1.FhirBundleSdk.create(bundleWithIsolatedPatient);
666
668
  const patient = sdk.getPatientById("patient-isolated");
667
669
  if (patient === undefined) {
668
670
  throw new Error("Patient not found");
@@ -673,7 +675,7 @@ describe("FhirBundleSdk", () => {
673
675
  expect(result.allResources[0]?.id).toBe("patient-isolated");
674
676
  });
675
677
  it("should handle resources with broken references", async () => {
676
- const sdk = await FhirBundleSdk.create(bundleWithBrokenReferences);
678
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.bundleWithBrokenReferences);
677
679
  const observation = sdk.getObservationById("observation-broken");
678
680
  // Should not throw, just return what's reachable
679
681
  if (observation === undefined) {
@@ -684,7 +686,7 @@ describe("FhirBundleSdk", () => {
684
686
  expect(result.startResource.id).toBe("observation-broken");
685
687
  });
686
688
  it("should handle empty options", async () => {
687
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
689
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
688
690
  const observation = sdk.getObservationById("observation-001");
689
691
  if (observation === undefined) {
690
692
  throw new Error("Observation not found");
@@ -708,7 +710,7 @@ describe("FhirBundleSdk", () => {
708
710
  },
709
711
  name: [{ family: "Smith", given: ["John"] }],
710
712
  };
711
- const cleaned = FhirBundleSdk.stripNonClinicalData(patient);
713
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(patient);
712
714
  expect(cleaned.meta).toBeUndefined();
713
715
  expect(cleaned.name).toEqual([{ family: "Smith", given: ["John"] }]);
714
716
  expect(cleaned.id).toBeUndefined();
@@ -725,7 +727,7 @@ describe("FhirBundleSdk", () => {
725
727
  ],
726
728
  name: [{ family: "Smith", given: ["John"] }],
727
729
  };
728
- const cleaned = FhirBundleSdk.stripNonClinicalData(patient);
730
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(patient);
729
731
  expect(cleaned.extension).toBeUndefined();
730
732
  expect(cleaned.name).toEqual([{ family: "Smith", given: ["John"] }]);
731
733
  });
@@ -742,7 +744,7 @@ describe("FhirBundleSdk", () => {
742
744
  div: "<div>Some narrative</div>",
743
745
  },
744
746
  };
745
- const cleaned = FhirBundleSdk.stripNonClinicalData(observation);
747
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(observation);
746
748
  expect(cleaned.text).toBeUndefined();
747
749
  expect(cleaned.code).toBeDefined();
748
750
  expect(cleaned.status).toBe("final");
@@ -756,7 +758,7 @@ describe("FhirBundleSdk", () => {
756
758
  },
757
759
  name: [{ family: "Smith", given: ["John"] }],
758
760
  };
759
- const cleaned = FhirBundleSdk.stripNonClinicalData(patient);
761
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(patient);
760
762
  // Original should be unchanged
761
763
  expect(patient.meta).toBeDefined();
762
764
  expect(patient.id).toBe("patient-123");
@@ -781,7 +783,7 @@ describe("FhirBundleSdk", () => {
781
783
  },
782
784
  ],
783
785
  };
784
- const cleaned = FhirBundleSdk.stripNonClinicalData(patient);
786
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(patient);
785
787
  expect(cleaned.name?.[0]?.extension).toBeUndefined();
786
788
  expect(cleaned.name?.[0]?.family).toBe("Smith");
787
789
  });
@@ -791,7 +793,7 @@ describe("FhirBundleSdk", () => {
791
793
  id: "patient-123",
792
794
  name: [{ family: "Smith", given: ["John"] }],
793
795
  };
794
- const cleaned = FhirBundleSdk.stripNonClinicalData(patient);
796
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(patient);
795
797
  expect(cleaned.id).toBeUndefined();
796
798
  expect(cleaned.name).toEqual([{ family: "Smith", given: ["John"] }]);
797
799
  });
@@ -807,7 +809,7 @@ describe("FhirBundleSdk", () => {
807
809
  ],
808
810
  name: [{ family: "Smith", given: ["John"] }],
809
811
  };
810
- const cleaned = FhirBundleSdk.stripNonClinicalData(patient);
812
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(patient);
811
813
  expect(cleaned.identifier).toBeUndefined();
812
814
  expect(cleaned.name).toEqual([{ family: "Smith", given: ["John"] }]);
813
815
  });
@@ -824,7 +826,7 @@ describe("FhirBundleSdk", () => {
824
826
  performer: [{ reference: "Practitioner/practitioner-789" }],
825
827
  basedOn: [{ reference: "ServiceRequest/sr-001" }],
826
828
  };
827
- const cleaned = FhirBundleSdk.stripNonClinicalData(observation);
829
+ const cleaned = index_1.FhirBundleSdk.stripNonClinicalData(observation);
828
830
  // All reference fields should be removed
829
831
  expect(cleaned.subject).toBeUndefined();
830
832
  expect(cleaned.encounter).toBeUndefined();
@@ -837,7 +839,7 @@ describe("FhirBundleSdk", () => {
837
839
  });
838
840
  describe("generateLLMContext", () => {
839
841
  it("should generate structured text format by default", async () => {
840
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
842
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
841
843
  const observation = sdk.getObservationById("observation-001");
842
844
  if (observation === undefined) {
843
845
  throw new Error("Observation not found");
@@ -848,7 +850,7 @@ describe("FhirBundleSdk", () => {
848
850
  expect(context).toContain("DIRECTLY REFERENCED");
849
851
  });
850
852
  it("should respect maxDepth option", async () => {
851
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
853
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
852
854
  const observation = sdk.getObservationById("observation-001");
853
855
  if (observation === undefined) {
854
856
  throw new Error("Observation not found");
@@ -858,7 +860,7 @@ describe("FhirBundleSdk", () => {
858
860
  expect(context).not.toContain("DIRECTLY REFERENCED");
859
861
  });
860
862
  it("should generate JSON format when specified", async () => {
861
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
863
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
862
864
  const observation = sdk.getObservationById("observation-001");
863
865
  if (observation === undefined) {
864
866
  throw new Error("Observation not found");
@@ -895,7 +897,7 @@ describe("FhirBundleSdk", () => {
895
897
  },
896
898
  ],
897
899
  };
898
- const sdk = await FhirBundleSdk.create(bundleWithMeta);
900
+ const sdk = await index_1.FhirBundleSdk.create(bundleWithMeta);
899
901
  const observation = sdk.getObservationById("obs-with-meta");
900
902
  if (observation === undefined) {
901
903
  throw new Error("Observation not found");
@@ -907,7 +909,7 @@ describe("FhirBundleSdk", () => {
907
909
  expect(parsed.primaryResource.code).toBeDefined();
908
910
  });
909
911
  it("should group resources by type at each depth", async () => {
910
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
912
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
911
913
  const diagnosticReport = sdk.getDiagnosticReportById("diagnostic-report-002");
912
914
  if (diagnosticReport === undefined) {
913
915
  throw new Error("DiagnosticReport not found");
@@ -918,7 +920,7 @@ describe("FhirBundleSdk", () => {
918
920
  expect(context).toMatch(/--- \w+ \(\d+\) ---/);
919
921
  });
920
922
  it("should handle includeStartResource option", async () => {
921
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
923
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
922
924
  const observation = sdk.getObservationById("observation-001");
923
925
  if (observation === undefined) {
924
926
  throw new Error("Observation not found");
@@ -935,7 +937,7 @@ describe("FhirBundleSdk", () => {
935
937
  });
936
938
  it("should log resource counts to console", async () => {
937
939
  const consoleSpy = jest.spyOn(console, "log").mockImplementation();
938
- const sdk = await FhirBundleSdk.create(validCompleteBundle);
940
+ const sdk = await index_1.FhirBundleSdk.create(fhir_bundles_1.validCompleteBundle);
939
941
  const observation = sdk.getObservationById("observation-001");
940
942
  if (observation === undefined) {
941
943
  throw new Error("Observation not found");