@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
package/dist/index.d.ts
CHANGED
|
@@ -1,245 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { Smart } from "./types/smart-resources";
|
|
1
|
+
export { FhirBundleSdk } from "./fhir-bundle-sdk";
|
|
3
2
|
export { Smart } from "./types/smart-resources";
|
|
3
|
+
export { ValidationResult, BrokenReference, BundleDiffResult, WalkOptions, LLMContextOptions, WalkResult, ReverseReferenceOptions, DateRangeSearchOptions, } from "./types/sdk-types";
|
|
4
4
|
export { AllergyIntolerance, Bundle, Composition, Condition, Coverage, DiagnosticReport, DocumentReference, Encounter, FamilyMemberHistory, Immunization, Location, Medication, MedicationAdministration, MedicationDispense, MedicationRequest, MedicationStatement, Observation, Organization, Patient, Practitioner, Procedure, RelatedPerson, Resource, RiskAssessment, ServiceRequest, } from "@medplum/fhirtypes";
|
|
5
|
-
/**
|
|
6
|
-
* Validation result interface
|
|
7
|
-
*/
|
|
8
|
-
export interface ValidationResult {
|
|
9
|
-
hasBrokenReferences: boolean;
|
|
10
|
-
brokenReferences: BrokenReference[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Broken reference details interface
|
|
14
|
-
*/
|
|
15
|
-
export interface BrokenReference {
|
|
16
|
-
sourceResourceId: string;
|
|
17
|
-
sourceResourceType: string;
|
|
18
|
-
referenceField: string;
|
|
19
|
-
reference: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Bundle diff result interface
|
|
23
|
-
*/
|
|
24
|
-
export interface BundleDiffResult {
|
|
25
|
-
/** Resources that exist in both bundles */
|
|
26
|
-
common: FhirBundleSdk;
|
|
27
|
-
/** Resources that exist only in the base bundle (this bundle) */
|
|
28
|
-
baseOnly: FhirBundleSdk;
|
|
29
|
-
/** Resources that exist only in the parameter bundle */
|
|
30
|
-
parameterOnly: FhirBundleSdk;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* FHIR Bundle SDK for parsing, querying, and manipulating FHIR bundles with reference resolution
|
|
34
|
-
*/
|
|
35
|
-
export declare class FhirBundleSdk {
|
|
36
|
-
private bundle;
|
|
37
|
-
private resourcesById;
|
|
38
|
-
private resourcesByFullUrl;
|
|
39
|
-
private resourcesByType;
|
|
40
|
-
private smartResourceCache;
|
|
41
|
-
private smartResourceArrayCache;
|
|
42
|
-
private resolutionStack;
|
|
43
|
-
/**
|
|
44
|
-
* Configuration for dynamically generated resource getter methods.
|
|
45
|
-
*
|
|
46
|
-
* Each entry in this array automatically generates both single and collection getter methods.
|
|
47
|
-
*
|
|
48
|
-
* **Example:**
|
|
49
|
-
* ```typescript
|
|
50
|
-
* {
|
|
51
|
-
* resourceType: 'Patient',
|
|
52
|
-
* singleGetterMethodName: 'getPatientById',
|
|
53
|
-
* collectionGetterMethodName: 'getPatients'
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* **Generates the equivalent of:**
|
|
58
|
-
* ```typescript
|
|
59
|
-
* // Single resource getter
|
|
60
|
-
* getPatientById(id: string): Smart<Patient> | undefined {
|
|
61
|
-
* return this.getResourceByIdAndType<Patient>(id, 'Patient');
|
|
62
|
-
* }
|
|
63
|
-
*
|
|
64
|
-
* // Collection getter
|
|
65
|
-
* getPatients(): Smart<Patient>[] {
|
|
66
|
-
* return this.getResourcesByType<Patient>('Patient');
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* **Usage:**
|
|
71
|
-
* ```typescript
|
|
72
|
-
* const sdk = await FhirBundleSdk.create(bundle);
|
|
73
|
-
* const patient = sdk.getPatientById('patient-123'); // Smart<Patient> | undefined
|
|
74
|
-
* const allPatients = sdk.getPatients(); // Smart<Patient>[]
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* To add a new resource type, simply add a new entry to this array and declare
|
|
78
|
-
* the corresponding method signatures in the class body.
|
|
79
|
-
*/
|
|
80
|
-
private static readonly RESOURCE_METHODS;
|
|
81
|
-
private constructor();
|
|
82
|
-
get total(): number;
|
|
83
|
-
get entry(): BundleEntry[];
|
|
84
|
-
toObject(): Bundle;
|
|
85
|
-
/**
|
|
86
|
-
* Create a new FhirBundleSdk instance (async for backwards compatibility)
|
|
87
|
-
* FR-1.2: Validate bundle resourceType
|
|
88
|
-
*/
|
|
89
|
-
static create(bundle: Bundle): Promise<FhirBundleSdk>;
|
|
90
|
-
/**
|
|
91
|
-
* Create a new FhirBundleSdk instance synchronously
|
|
92
|
-
* FR-1.2: Validate bundle resourceType
|
|
93
|
-
*/
|
|
94
|
-
static createSync(bundle: Bundle): FhirBundleSdk;
|
|
95
|
-
/**
|
|
96
|
-
* Build O(1) indexes for resource lookup
|
|
97
|
-
*/
|
|
98
|
-
private buildResourceIndexes;
|
|
99
|
-
/**
|
|
100
|
-
* Create a smart resource with reference resolution methods
|
|
101
|
-
* FR-5.1: Resources returned by SDK have additional getter methods for each Reference field
|
|
102
|
-
* FR-5.7: Reference resolution operates in O(1) time complexity per reference
|
|
103
|
-
* FR-5.8: Original reference fields remain unchanged
|
|
104
|
-
*/
|
|
105
|
-
private createSmartResource;
|
|
106
|
-
/**
|
|
107
|
-
* Resolve a reference method call to actual resources
|
|
108
|
-
* FR-5.2-5.6: Handle different reference types and patterns
|
|
109
|
-
*/
|
|
110
|
-
private resolveReference;
|
|
111
|
-
/**
|
|
112
|
-
* Resolve a single reference object to a resource
|
|
113
|
-
* FR-5.5: Reference resolution methods handle both resource.id and fullUrl matching
|
|
114
|
-
*/
|
|
115
|
-
private resolveReferenceObject;
|
|
116
|
-
/**
|
|
117
|
-
* Check if a reference field expects an array of references
|
|
118
|
-
*/
|
|
119
|
-
private isArrayReferenceField;
|
|
120
|
-
/**
|
|
121
|
-
* Find all Reference fields in a resource recursively
|
|
122
|
-
*/
|
|
123
|
-
private findAllReferences;
|
|
124
|
-
/**
|
|
125
|
-
* Check if a reference can be resolved within the bundle
|
|
126
|
-
*/
|
|
127
|
-
private canResolveReference;
|
|
128
|
-
/**
|
|
129
|
-
* FR-2.1: Validate all references in the bundle
|
|
130
|
-
* FR-2.2: Identifies references by Resource/id pattern and fullUrl references
|
|
131
|
-
* FR-2.3: Handles both relative and absolute references
|
|
132
|
-
* FR-2.4: Returns validation result with broken reference details
|
|
133
|
-
*/
|
|
134
|
-
lookForBrokenReferences(): ValidationResult;
|
|
135
|
-
/**
|
|
136
|
-
* FR-3.1: Get resource by ID with type parameter support
|
|
137
|
-
* FR-3.2: Method searches both resource.id and entry.fullUrl for matches
|
|
138
|
-
* FR-3.4: Method returns undefined if resource not found
|
|
139
|
-
* FR-3.5: Lookup operates in O(1) time complexity
|
|
140
|
-
* FR-5.1: Returns smart resource with reference resolution methods
|
|
141
|
-
*/
|
|
142
|
-
getResourceById<T extends Resource>(id: string): Smart<T> | undefined;
|
|
143
|
-
/**
|
|
144
|
-
* Generic helper method to get a resource by ID with type validation
|
|
145
|
-
*/
|
|
146
|
-
private getResourceByIdAndType;
|
|
147
|
-
getPatientById: (id: string) => Smart<Patient> | undefined;
|
|
148
|
-
getObservationById: (id: string) => Smart<Observation> | undefined;
|
|
149
|
-
getEncounterById: (id: string) => Smart<Encounter> | undefined;
|
|
150
|
-
getAllergyIntoleranceById: (id: string) => Smart<AllergyIntolerance> | undefined;
|
|
151
|
-
getConditionById: (id: string) => Smart<Condition> | undefined;
|
|
152
|
-
getOrganizationById: (id: string) => Smart<Organization> | undefined;
|
|
153
|
-
getLocationById: (id: string) => Smart<Location> | undefined;
|
|
154
|
-
getPractitionerById: (id: string) => Smart<Practitioner> | undefined;
|
|
155
|
-
getDiagnosticReportById: (id: string) => Smart<DiagnosticReport> | undefined;
|
|
156
|
-
getCompositionById: (id: string) => Smart<Composition> | undefined;
|
|
157
|
-
getCoverageById: (id: string) => Smart<Coverage> | undefined;
|
|
158
|
-
getDocumentReferenceById: (id: string) => Smart<DocumentReference> | undefined;
|
|
159
|
-
getImmunizationById: (id: string) => Smart<Immunization> | undefined;
|
|
160
|
-
getMedicationById: (id: string) => Smart<Medication> | undefined;
|
|
161
|
-
getMedicationRequestById: (id: string) => Smart<MedicationRequest> | undefined;
|
|
162
|
-
getProcedureById: (id: string) => Smart<Procedure> | undefined;
|
|
163
|
-
getFamilyMemberHistoryById: (id: string) => Smart<FamilyMemberHistory> | undefined;
|
|
164
|
-
getMedicationAdministrationById: (id: string) => Smart<MedicationAdministration> | undefined;
|
|
165
|
-
getMedicationDispenseById: (id: string) => Smart<MedicationDispense> | undefined;
|
|
166
|
-
getMedicationStatementById: (id: string) => Smart<MedicationStatement> | undefined;
|
|
167
|
-
getRelatedPersonById: (id: string) => Smart<RelatedPerson> | undefined;
|
|
168
|
-
getRiskAssessmentById: (id: string) => Smart<RiskAssessment> | undefined;
|
|
169
|
-
getServiceRequestById: (id: string) => Smart<ServiceRequest> | undefined;
|
|
170
|
-
/**
|
|
171
|
-
* Generic helper method to get all resources of a specific type
|
|
172
|
-
* FR-10.1: Returns references to cached objects, not copies
|
|
173
|
-
*/
|
|
174
|
-
private getResourcesByType;
|
|
175
|
-
getPatients: () => Smart<Patient>[];
|
|
176
|
-
getObservations: () => Smart<Observation>[];
|
|
177
|
-
getEncounters: () => Smart<Encounter>[];
|
|
178
|
-
getPractitioners: () => Smart<Practitioner>[];
|
|
179
|
-
getDiagnosticReports: () => Smart<DiagnosticReport>[];
|
|
180
|
-
getAllergyIntolerances: () => Smart<AllergyIntolerance>[];
|
|
181
|
-
getConditions: () => Smart<Condition>[];
|
|
182
|
-
getOrganizations: () => Smart<Organization>[];
|
|
183
|
-
getLocations: () => Smart<Location>[];
|
|
184
|
-
getCompositions: () => Smart<Composition>[];
|
|
185
|
-
getCoverages: () => Smart<Coverage>[];
|
|
186
|
-
getDocumentReferences: () => Smart<DocumentReference>[];
|
|
187
|
-
getImmunizations: () => Smart<Immunization>[];
|
|
188
|
-
getMedications: () => Smart<Medication>[];
|
|
189
|
-
getMedicationRequests: () => Smart<MedicationRequest>[];
|
|
190
|
-
getProcedures: () => Smart<Procedure>[];
|
|
191
|
-
getFamilyMemberHistories: () => Smart<FamilyMemberHistory>[];
|
|
192
|
-
getMedicationAdministrations: () => Smart<MedicationAdministration>[];
|
|
193
|
-
getMedicationDispenses: () => Smart<MedicationDispense>[];
|
|
194
|
-
getMedicationStatements: () => Smart<MedicationStatement>[];
|
|
195
|
-
getRelatedPersons: () => Smart<RelatedPerson>[];
|
|
196
|
-
getRiskAssessments: () => Smart<RiskAssessment>[];
|
|
197
|
-
getServiceRequests: () => Smart<ServiceRequest>[];
|
|
198
|
-
/**
|
|
199
|
-
* Create a new bundle entry from an existing entry, preserving fullUrl
|
|
200
|
-
*/
|
|
201
|
-
private createBundleEntry;
|
|
202
|
-
/**
|
|
203
|
-
* Create a new bundle with specified entries, maintaining original metadata
|
|
204
|
-
*/
|
|
205
|
-
private createExportBundle;
|
|
206
|
-
/**
|
|
207
|
-
* Find original bundle entry for a given resource
|
|
208
|
-
*/
|
|
209
|
-
private findOriginalEntry;
|
|
210
|
-
/**
|
|
211
|
-
* FR-6.1: Export subset of resources by their IDs
|
|
212
|
-
* FR-6.4: Exported bundles maintain original bundle metadata but update total count
|
|
213
|
-
* FR-6.5: Exported bundles include only resources that exist in the original bundle
|
|
214
|
-
* FR-6.6: Exported bundles preserve original entry.fullUrl values
|
|
215
|
-
*/
|
|
216
|
-
exportSubset(resourceIds: string[]): Bundle;
|
|
217
|
-
/**
|
|
218
|
-
* FR-6.2: Export all resources of a specific type
|
|
219
|
-
* FR-6.4: Exported bundles maintain original bundle metadata but update total count
|
|
220
|
-
* FR-6.6: Exported bundles preserve original entry.fullUrl values
|
|
221
|
-
*/
|
|
222
|
-
exportByType(resourceType: string): Bundle;
|
|
223
|
-
/**
|
|
224
|
-
* FR-6.3: Export all resources of specified types
|
|
225
|
-
* FR-6.4: Exported bundles maintain original bundle metadata but update total count
|
|
226
|
-
* FR-6.6: Exported bundles preserve original entry.fullUrl values
|
|
227
|
-
*/
|
|
228
|
-
exportByTypes(resourceTypes: string[]): Bundle;
|
|
229
|
-
/**
|
|
230
|
-
* Concatenate entries from another FhirBundleSdk with this bundle
|
|
231
|
-
* Returns a new bundle with combined entries while preserving original metadata
|
|
232
|
-
*/
|
|
233
|
-
concatEntries(otherSdk: FhirBundleSdk): Promise<FhirBundleSdk>;
|
|
234
|
-
/**
|
|
235
|
-
* Diff this bundle with another FHIR Bundle by comparing resource ids.
|
|
236
|
-
* Returns three FhirBundleSdk instances: common, baseOnly, parameterOnly.
|
|
237
|
-
*/
|
|
238
|
-
diff(other: Bundle): Promise<BundleDiffResult>;
|
|
239
|
-
/**
|
|
240
|
-
* Diff this bundle with another FhirBundleSdk by comparing resource ids.
|
|
241
|
-
* Returns three FhirBundleSdk instances: common, baseOnly, parameterOnly.
|
|
242
|
-
*/
|
|
243
|
-
diff(other: FhirBundleSdk): Promise<BundleDiffResult>;
|
|
244
|
-
}
|
|
245
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,SAAS,EACT,aAAa,EACb,QAAQ,EACR,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAC"}
|