@healthcare-interoperability/fhir-tools 1.0.0 → 1.2.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 +239 -136
- package/dist/FHIRReferenceEngine.js +64 -0
- package/dist/USCoreFHIRReferenceEngine.js +14 -0
- package/dist/config/references/uscore.reference.config.js +197 -0
- package/dist/index.js +22 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
# @healthcare-interoperability/fhir-tools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight but powerful toolkit for **FHIR reference normalization**, **deterministic ID generation**, and **schema-aware traversal** of FHIR resources in JavaScript / Node.js.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Designed for **healthcare interoperability pipelines**, **HL7 → FHIR transforms**, and **US Core–aligned processing**.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
## ✨
|
|
9
|
+
## ✨ What This Package Solves
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
11
|
+
FHIR resources contain many `Reference` fields that:
|
|
12
|
+
|
|
13
|
+
* appear at different depths
|
|
14
|
+
* can be single or arrays
|
|
15
|
+
* vary by resource type
|
|
16
|
+
* need consistent internal identifiers
|
|
17
|
+
|
|
18
|
+
This package provides:
|
|
19
|
+
|
|
20
|
+
* 🔗 **Safe FHIR reference extraction**
|
|
21
|
+
* 🧭 **Config-driven reference traversal**
|
|
22
|
+
* 🆔 **Deterministic, integration-scoped ID generation**
|
|
23
|
+
* 🏗️ **Automatic object & array creation**
|
|
24
|
+
* 🇺🇸 **Built-in US Core reference rules**
|
|
18
25
|
|
|
19
26
|
---
|
|
20
27
|
|
|
@@ -26,229 +33,324 @@ npm install @healthcare-interoperability/fhir-tools
|
|
|
26
33
|
|
|
27
34
|
---
|
|
28
35
|
|
|
29
|
-
## 🔧
|
|
36
|
+
## 🔧 Peer Dependency
|
|
30
37
|
|
|
31
|
-
This package
|
|
38
|
+
This package relies on deterministic ID generation:
|
|
32
39
|
|
|
33
40
|
```ts
|
|
34
41
|
@quicore/resource-id
|
|
35
42
|
```
|
|
36
43
|
|
|
37
|
-
Make sure it is resolvable in your project.
|
|
38
|
-
|
|
39
44
|
---
|
|
40
45
|
|
|
41
|
-
##
|
|
46
|
+
## 🧠 Core Components
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
import { FHIRReferenceAssigner } from "@healthcare-interoperability/fhir-tools";
|
|
48
|
+
### 1️⃣ `FHIRReferenceAssigner`
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
Low-level utility that **assigns a normalized FHIR reference** to a declared object path.
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
* Creates missing objects and arrays
|
|
53
|
+
* Enforces correct types
|
|
54
|
+
* Preserves original FHIR reference
|
|
55
|
+
* Generates deterministic IDs
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
resource,
|
|
52
|
-
["subject"],
|
|
53
|
-
"Patient/123"
|
|
54
|
-
);
|
|
57
|
+
📌 Use this when you need **manual or custom reference placement**.
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
```
|
|
59
|
+
---
|
|
58
60
|
|
|
59
|
-
###
|
|
61
|
+
### 2️⃣ `FHIRReferenceEngine`
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
```
|
|
63
|
+
A **config-driven processor** that:
|
|
64
|
+
|
|
65
|
+
* Scans a FHIR resource
|
|
66
|
+
* Finds reference fields based on rules
|
|
67
|
+
* Normalizes all references into a single `_reference` tree
|
|
68
|
+
|
|
69
|
+
📌 Use this for **automated pipeline processing**.
|
|
70
70
|
|
|
71
71
|
---
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
### 3️⃣ `USCoreFHIRReferenceEngine`
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
A ready-to-use engine with **US Core–aligned reference rules** for common resources like:
|
|
76
76
|
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
77
|
+
* Encounter
|
|
78
|
+
* Observation
|
|
79
|
+
* Condition
|
|
80
|
+
* Procedure
|
|
81
|
+
* MedicationRequest
|
|
82
|
+
* Claim / Coverage
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
📌 Use this if you process **US Core FHIR R4 data**.
|
|
83
85
|
|
|
84
86
|
---
|
|
85
87
|
|
|
86
|
-
##
|
|
88
|
+
## 🚀 Quick Start (US Core)
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
```ts
|
|
91
|
+
import { USCoreFHIRReferenceEngine } from "@healthcare-interoperability/fhir-tools";
|
|
92
|
+
|
|
93
|
+
const engine = new USCoreFHIRReferenceEngine("my-integration-id");
|
|
89
94
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
| `string[]` | Explicitly declares an array at that key |
|
|
95
|
+
engine.process(fhirResource);
|
|
96
|
+
|
|
97
|
+
console.log(fhirResource._reference);
|
|
98
|
+
```
|
|
95
99
|
|
|
96
100
|
---
|
|
97
101
|
|
|
98
|
-
##
|
|
102
|
+
## 🧾 What Gets Generated
|
|
99
103
|
|
|
100
|
-
|
|
104
|
+
All normalized references are stored under:
|
|
101
105
|
|
|
102
106
|
```ts
|
|
103
|
-
|
|
104
|
-
resource,
|
|
105
|
-
["encounter", "serviceProvider"],
|
|
106
|
-
"Organization/456"
|
|
107
|
-
);
|
|
107
|
+
resource._reference
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
Each reference has the shape:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
111
113
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"type": "Organization",
|
|
116
|
-
"originalReference": "Organization/456"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
114
|
+
id: string; // Deterministic internal ID
|
|
115
|
+
type: string; // FHIR resource type
|
|
116
|
+
originalReference: string; // Original FHIR reference (ResourceType/ID)
|
|
119
117
|
}
|
|
120
118
|
```
|
|
121
119
|
|
|
120
|
+
This allows:
|
|
121
|
+
|
|
122
|
+
* consistent internal linking
|
|
123
|
+
* traceability back to source FHIR
|
|
124
|
+
* safe downstream joins and indexing
|
|
125
|
+
|
|
122
126
|
---
|
|
123
127
|
|
|
124
|
-
|
|
128
|
+
## 🧩 How the Engine Works
|
|
129
|
+
|
|
130
|
+
### Step 1: Match Rules
|
|
131
|
+
|
|
132
|
+
Each rule declares:
|
|
133
|
+
|
|
134
|
+
* `resourceType` (or `"*"`)
|
|
135
|
+
* one or more reference paths
|
|
136
|
+
|
|
137
|
+
Example:
|
|
125
138
|
|
|
126
139
|
```ts
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
[
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
{
|
|
141
|
+
resourceType: "Encounter",
|
|
142
|
+
references: [
|
|
143
|
+
{ path: ["serviceProvider"] },
|
|
144
|
+
{ path: ["participant"], array: true, nested: "individual" }
|
|
145
|
+
]
|
|
146
|
+
}
|
|
132
147
|
```
|
|
133
148
|
|
|
134
|
-
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### Step 2: Traverse Resource
|
|
152
|
+
|
|
153
|
+
For each rule:
|
|
154
|
+
|
|
155
|
+
* the engine checks if the path exists
|
|
156
|
+
* supports arrays automatically
|
|
157
|
+
* supports nested reference fields
|
|
135
158
|
|
|
136
159
|
---
|
|
137
160
|
|
|
138
|
-
### 3
|
|
161
|
+
### Step 3: Normalize References
|
|
139
162
|
|
|
140
|
-
|
|
163
|
+
References like:
|
|
141
164
|
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"Practitioner/321"
|
|
147
|
-
);
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"reference": "Patient/123"
|
|
168
|
+
}
|
|
148
169
|
```
|
|
149
170
|
|
|
150
|
-
|
|
171
|
+
Are transformed into:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
_reference: {
|
|
175
|
+
subject: {
|
|
176
|
+
id: "...",
|
|
177
|
+
type: "Patient",
|
|
178
|
+
originalReference: "Patient/123"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
151
182
|
|
|
152
183
|
---
|
|
153
184
|
|
|
154
|
-
##
|
|
185
|
+
## 📐 Rule Definition Reference
|
|
186
|
+
|
|
187
|
+
Each reference rule supports:
|
|
188
|
+
|
|
189
|
+
| Field | Type | Description |
|
|
190
|
+
| -------- | ---------- | ---------------------------- |
|
|
191
|
+
| `path` | `string[]` | Path to the reference field |
|
|
192
|
+
| `array` | `boolean` | Whether the path is an array |
|
|
193
|
+
| `nested` | `string` | Nested reference key |
|
|
155
194
|
|
|
156
|
-
|
|
195
|
+
### Example (Array + Nested)
|
|
157
196
|
|
|
158
197
|
```ts
|
|
159
198
|
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
199
|
+
path: ["participant"],
|
|
200
|
+
array: true,
|
|
201
|
+
nested: "individual"
|
|
163
202
|
}
|
|
164
203
|
```
|
|
165
204
|
|
|
166
|
-
|
|
205
|
+
Targets:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
participant[].individual.reference
|
|
209
|
+
```
|
|
167
210
|
|
|
168
211
|
---
|
|
169
212
|
|
|
170
|
-
##
|
|
213
|
+
## 🇺🇸 US Core Coverage
|
|
171
214
|
|
|
172
|
-
|
|
215
|
+
The built-in `US_CORE_REFERENCE_CONFIG` covers:
|
|
173
216
|
|
|
174
|
-
|
|
217
|
+
### Common (All Resources)
|
|
175
218
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
219
|
+
* subject
|
|
220
|
+
* patient
|
|
221
|
+
* beneficiary
|
|
222
|
+
* encounter
|
|
223
|
+
* author
|
|
224
|
+
* custodian
|
|
225
|
+
* recorder
|
|
226
|
+
* requester
|
|
227
|
+
* organization
|
|
228
|
+
* provider
|
|
179
229
|
|
|
180
|
-
|
|
230
|
+
### Encounter
|
|
181
231
|
|
|
182
|
-
|
|
232
|
+
* serviceProvider
|
|
233
|
+
* partOf
|
|
234
|
+
* location[].location
|
|
235
|
+
* participant[].individual
|
|
236
|
+
* diagnosis[].condition
|
|
237
|
+
* reasonReference[]
|
|
183
238
|
|
|
184
|
-
###
|
|
239
|
+
### Observation
|
|
185
240
|
|
|
186
|
-
|
|
241
|
+
* specimen
|
|
242
|
+
* device
|
|
243
|
+
* focus[]
|
|
244
|
+
* hasMember[]
|
|
245
|
+
* derivedFrom[]
|
|
246
|
+
* performer[]
|
|
187
247
|
|
|
188
|
-
|
|
189
|
-
* array vs object
|
|
248
|
+
### Condition
|
|
190
249
|
|
|
191
|
-
|
|
250
|
+
* asserter
|
|
251
|
+
* recorder
|
|
252
|
+
* evidence[].detail
|
|
192
253
|
|
|
193
|
-
|
|
194
|
-
Path segment 'participant' at 'participant[0]' must be an array
|
|
195
|
-
```
|
|
254
|
+
### Procedure
|
|
196
255
|
|
|
197
|
-
|
|
256
|
+
* location
|
|
257
|
+
* usedReference[]
|
|
258
|
+
* reasonReference[]
|
|
259
|
+
* report[]
|
|
260
|
+
* performer[].actor
|
|
198
261
|
|
|
199
|
-
###
|
|
262
|
+
### MedicationRequest
|
|
200
263
|
|
|
201
|
-
|
|
264
|
+
* medicationReference
|
|
265
|
+
* recorder
|
|
266
|
+
* performer
|
|
267
|
+
* reasonReference[]
|
|
268
|
+
* basedOn[]
|
|
202
269
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
270
|
+
### DiagnosticReport
|
|
271
|
+
|
|
272
|
+
* specimen[]
|
|
273
|
+
* result[]
|
|
274
|
+
* imagingStudy[]
|
|
275
|
+
|
|
276
|
+
### Claim / Coverage
|
|
206
277
|
|
|
207
|
-
|
|
278
|
+
* insurer
|
|
279
|
+
* insurance[].coverage
|
|
280
|
+
* careTeam[].provider
|
|
281
|
+
* diagnosis[].diagnosisReference
|
|
282
|
+
* procedure[].procedureReference
|
|
283
|
+
* beneficiary
|
|
284
|
+
* payor[]
|
|
208
285
|
|
|
209
286
|
---
|
|
210
287
|
|
|
211
|
-
##
|
|
288
|
+
## 🔐 Error Handling Philosophy
|
|
212
289
|
|
|
213
|
-
|
|
290
|
+
* Invalid references are **ignored safely**
|
|
291
|
+
* Structural conflicts are prevented
|
|
292
|
+
* Failures are **logged, not fatal**
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
console.warn(
|
|
296
|
+
`Reference assign failed Encounter/123 at ["participant",0,"individual"]`
|
|
297
|
+
);
|
|
298
|
+
```
|
|
214
299
|
|
|
215
|
-
|
|
216
|
-
* `RangeError` → invalid array access
|
|
217
|
-
* `Error` → invalid references or ID generation failures
|
|
300
|
+
This makes the engine safe for:
|
|
218
301
|
|
|
219
|
-
|
|
302
|
+
* batch processing
|
|
303
|
+
* partial data
|
|
304
|
+
* real-world EHR payloads
|
|
220
305
|
|
|
221
306
|
---
|
|
222
307
|
|
|
223
308
|
## 🏥 Typical Use Cases
|
|
224
309
|
|
|
225
|
-
* HL7v2 → FHIR
|
|
226
|
-
*
|
|
227
|
-
* Appointment
|
|
228
|
-
*
|
|
229
|
-
*
|
|
310
|
+
* HL7v2 → FHIR pipelines
|
|
311
|
+
* US Core ingestion
|
|
312
|
+
* Appointment & encounter consolidation
|
|
313
|
+
* Claim normalization
|
|
314
|
+
* AI-ready FHIR preprocessing
|
|
315
|
+
* Cross-resource reference indexing
|
|
230
316
|
|
|
231
317
|
---
|
|
232
318
|
|
|
233
|
-
## 📄 API
|
|
319
|
+
## 📄 API Summary
|
|
234
320
|
|
|
235
|
-
### `
|
|
321
|
+
### `FHIRReferenceAssigner`
|
|
236
322
|
|
|
237
|
-
|
|
323
|
+
```ts
|
|
324
|
+
new FHIRReferenceAssigner(integrationId)
|
|
325
|
+
assign(baseObject, pathSegments, sourceReference)
|
|
326
|
+
```
|
|
238
327
|
|
|
239
328
|
---
|
|
240
329
|
|
|
241
|
-
### `
|
|
330
|
+
### `FHIRReferenceEngine`
|
|
242
331
|
|
|
243
|
-
|
|
332
|
+
```ts
|
|
333
|
+
new FHIRReferenceEngine(integrationId, config)
|
|
334
|
+
process(resource)
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
### `USCoreFHIRReferenceEngine`
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
new USCoreFHIRReferenceEngine(integrationId)
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
---
|
|
244
346
|
|
|
245
|
-
|
|
347
|
+
## 🧪 Design Goals
|
|
246
348
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
349
|
+
* Deterministic
|
|
350
|
+
* Schema-aware
|
|
351
|
+
* Safe-by-default
|
|
352
|
+
* Interop-friendly
|
|
353
|
+
* AI-readable output
|
|
252
354
|
|
|
253
355
|
---
|
|
254
356
|
|
|
@@ -260,8 +362,9 @@ MIT
|
|
|
260
362
|
|
|
261
363
|
## 🤝 Contributing
|
|
262
364
|
|
|
263
|
-
Contributions
|
|
365
|
+
Contributions are welcome—especially for:
|
|
264
366
|
|
|
265
|
-
* FHIR
|
|
266
|
-
*
|
|
267
|
-
*
|
|
367
|
+
* Additional FHIR profiles
|
|
368
|
+
* R5 support
|
|
369
|
+
* Custom profile generators
|
|
370
|
+
* Reference validation helpers
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FHIRReferenceEngine = void 0;
|
|
7
|
+
var _FHIRReferenceAssigner = require("./FHIRReferenceAssigner");
|
|
8
|
+
class FHIRReferenceEngine {
|
|
9
|
+
constructor(integrationId, config) {
|
|
10
|
+
if (!integrationId) {
|
|
11
|
+
throw new Error('integrationId is required');
|
|
12
|
+
}
|
|
13
|
+
if (!Array.isArray(config)) {
|
|
14
|
+
throw new Error('Reference config must be an array');
|
|
15
|
+
}
|
|
16
|
+
this.integrationId = integrationId;
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.assigner = new _FHIRReferenceAssigner.FHIRReferenceAssigner(integrationId);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Process a single FHIR resource
|
|
23
|
+
*/
|
|
24
|
+
process(resource) {
|
|
25
|
+
if (!resource?.resourceType) return;
|
|
26
|
+
if (!resource._reference) {
|
|
27
|
+
resource._reference = {};
|
|
28
|
+
}
|
|
29
|
+
const applicableRules = this.config.filter(rule => rule.resourceType === '*' || rule.resourceType === resource.resourceType);
|
|
30
|
+
applicableRules.forEach(rule => {
|
|
31
|
+
rule.references.forEach(refRule => {
|
|
32
|
+
this.applyRule(resource, refRule);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
applyRule(resource, rule) {
|
|
37
|
+
const {
|
|
38
|
+
path,
|
|
39
|
+
array,
|
|
40
|
+
nested
|
|
41
|
+
} = rule;
|
|
42
|
+
const target = resource?.[path[0]];
|
|
43
|
+
if (!target) return;
|
|
44
|
+
if (array && Array.isArray(target)) {
|
|
45
|
+
target.forEach((item, index) => {
|
|
46
|
+
const reference = nested ? item?.[nested]?.reference : item?.reference;
|
|
47
|
+
if (!reference) return;
|
|
48
|
+
this.safeAssign(resource, [[path[0]], index, ...(nested ? [nested] : [])], reference);
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
const reference = nested ? target?.[nested]?.reference : target?.reference;
|
|
52
|
+
if (!reference) return;
|
|
53
|
+
this.safeAssign(resource, path, reference);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
safeAssign(resource, path, reference) {
|
|
57
|
+
try {
|
|
58
|
+
this.assigner.assign(resource._reference, path, reference, this.integrationId);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.warn(`Reference assign failed ${resource.resourceType}/${resource.id || 'unknown'} at ${JSON.stringify(path)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.FHIRReferenceEngine = FHIRReferenceEngine;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.USCoreFHIRReferenceEngine = void 0;
|
|
7
|
+
var _uscoreReference = require("./config/references/uscore.reference.config");
|
|
8
|
+
var _FHIRReferenceEngine = require("./FHIRReferenceEngine");
|
|
9
|
+
class USCoreFHIRReferenceEngine extends _FHIRReferenceEngine.FHIRReferenceEngine {
|
|
10
|
+
constructor(integrationId) {
|
|
11
|
+
super(integrationId, _uscoreReference.US_CORE_REFERENCE_CONFIG);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.USCoreFHIRReferenceEngine = USCoreFHIRReferenceEngine;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.US_CORE_REFERENCE_CONFIG = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* US Core FHIR Reference Configuration
|
|
9
|
+
*
|
|
10
|
+
* Each rule declares:
|
|
11
|
+
* - resourceType (or "*")
|
|
12
|
+
* - path to reference(s)
|
|
13
|
+
* - whether the path is an array
|
|
14
|
+
* - optional nested reference field
|
|
15
|
+
*/
|
|
16
|
+
const US_CORE_REFERENCE_CONFIG = exports.US_CORE_REFERENCE_CONFIG = [
|
|
17
|
+
// ======================================================
|
|
18
|
+
// COMMON (applies to most resources)
|
|
19
|
+
// ======================================================
|
|
20
|
+
{
|
|
21
|
+
resourceType: '*',
|
|
22
|
+
references: [{
|
|
23
|
+
path: ['subject']
|
|
24
|
+
}, {
|
|
25
|
+
path: ['patient']
|
|
26
|
+
}, {
|
|
27
|
+
path: ['beneficiary']
|
|
28
|
+
}, {
|
|
29
|
+
path: ['encounter']
|
|
30
|
+
}, {
|
|
31
|
+
path: ['author']
|
|
32
|
+
}, {
|
|
33
|
+
path: ['custodian']
|
|
34
|
+
}, {
|
|
35
|
+
path: ['recorder']
|
|
36
|
+
}, {
|
|
37
|
+
path: ['requester']
|
|
38
|
+
}, {
|
|
39
|
+
path: ['organization']
|
|
40
|
+
}, {
|
|
41
|
+
path: ['provider']
|
|
42
|
+
}]
|
|
43
|
+
},
|
|
44
|
+
// ======================================================
|
|
45
|
+
// ENCOUNTER
|
|
46
|
+
// ======================================================
|
|
47
|
+
{
|
|
48
|
+
resourceType: 'Encounter',
|
|
49
|
+
references: [{
|
|
50
|
+
path: ['serviceProvider']
|
|
51
|
+
}, {
|
|
52
|
+
path: ['partOf']
|
|
53
|
+
}, {
|
|
54
|
+
path: ['location'],
|
|
55
|
+
array: true,
|
|
56
|
+
nested: 'location'
|
|
57
|
+
}, {
|
|
58
|
+
path: ['participant'],
|
|
59
|
+
array: true,
|
|
60
|
+
nested: 'individual'
|
|
61
|
+
}, {
|
|
62
|
+
path: ['diagnosis'],
|
|
63
|
+
array: true,
|
|
64
|
+
nested: 'condition'
|
|
65
|
+
}, {
|
|
66
|
+
path: ['reasonReference'],
|
|
67
|
+
array: true
|
|
68
|
+
}]
|
|
69
|
+
},
|
|
70
|
+
// ======================================================
|
|
71
|
+
// OBSERVATION
|
|
72
|
+
// ======================================================
|
|
73
|
+
{
|
|
74
|
+
resourceType: 'Observation',
|
|
75
|
+
references: [{
|
|
76
|
+
path: ['specimen']
|
|
77
|
+
}, {
|
|
78
|
+
path: ['device']
|
|
79
|
+
}, {
|
|
80
|
+
path: ['focus'],
|
|
81
|
+
array: true
|
|
82
|
+
}, {
|
|
83
|
+
path: ['hasMember'],
|
|
84
|
+
array: true
|
|
85
|
+
}, {
|
|
86
|
+
path: ['derivedFrom'],
|
|
87
|
+
array: true
|
|
88
|
+
}, {
|
|
89
|
+
path: ['performer'],
|
|
90
|
+
array: true
|
|
91
|
+
}]
|
|
92
|
+
},
|
|
93
|
+
// ======================================================
|
|
94
|
+
// CONDITION
|
|
95
|
+
// ======================================================
|
|
96
|
+
{
|
|
97
|
+
resourceType: 'Condition',
|
|
98
|
+
references: [{
|
|
99
|
+
path: ['asserter']
|
|
100
|
+
}, {
|
|
101
|
+
path: ['recorder']
|
|
102
|
+
}, {
|
|
103
|
+
path: ['evidence'],
|
|
104
|
+
array: true,
|
|
105
|
+
nested: 'detail'
|
|
106
|
+
}]
|
|
107
|
+
},
|
|
108
|
+
// ======================================================
|
|
109
|
+
// PROCEDURE
|
|
110
|
+
// ======================================================
|
|
111
|
+
{
|
|
112
|
+
resourceType: 'Procedure',
|
|
113
|
+
references: [{
|
|
114
|
+
path: ['location']
|
|
115
|
+
}, {
|
|
116
|
+
path: ['usedReference'],
|
|
117
|
+
array: true
|
|
118
|
+
}, {
|
|
119
|
+
path: ['reasonReference'],
|
|
120
|
+
array: true
|
|
121
|
+
}, {
|
|
122
|
+
path: ['report'],
|
|
123
|
+
array: true
|
|
124
|
+
}, {
|
|
125
|
+
path: ['performer'],
|
|
126
|
+
array: true,
|
|
127
|
+
nested: 'actor'
|
|
128
|
+
}]
|
|
129
|
+
},
|
|
130
|
+
// ======================================================
|
|
131
|
+
// MEDICATION
|
|
132
|
+
// ======================================================
|
|
133
|
+
{
|
|
134
|
+
resourceType: 'MedicationRequest',
|
|
135
|
+
references: [{
|
|
136
|
+
path: ['medicationReference']
|
|
137
|
+
}, {
|
|
138
|
+
path: ['recorder']
|
|
139
|
+
}, {
|
|
140
|
+
path: ['performer']
|
|
141
|
+
}, {
|
|
142
|
+
path: ['reasonReference'],
|
|
143
|
+
array: true
|
|
144
|
+
}, {
|
|
145
|
+
path: ['basedOn'],
|
|
146
|
+
array: true
|
|
147
|
+
}]
|
|
148
|
+
},
|
|
149
|
+
// ======================================================
|
|
150
|
+
// DIAGNOSTIC REPORT
|
|
151
|
+
// ======================================================
|
|
152
|
+
{
|
|
153
|
+
resourceType: 'DiagnosticReport',
|
|
154
|
+
references: [{
|
|
155
|
+
path: ['specimen'],
|
|
156
|
+
array: true
|
|
157
|
+
}, {
|
|
158
|
+
path: ['result'],
|
|
159
|
+
array: true
|
|
160
|
+
}, {
|
|
161
|
+
path: ['imagingStudy'],
|
|
162
|
+
array: true
|
|
163
|
+
}]
|
|
164
|
+
},
|
|
165
|
+
// ======================================================
|
|
166
|
+
// CLAIM / COVERAGE
|
|
167
|
+
// ======================================================
|
|
168
|
+
{
|
|
169
|
+
resourceType: 'Claim',
|
|
170
|
+
references: [{
|
|
171
|
+
path: ['insurer']
|
|
172
|
+
}, {
|
|
173
|
+
path: ['insurance'],
|
|
174
|
+
array: true,
|
|
175
|
+
nested: 'coverage'
|
|
176
|
+
}, {
|
|
177
|
+
path: ['careTeam'],
|
|
178
|
+
array: true,
|
|
179
|
+
nested: 'provider'
|
|
180
|
+
}, {
|
|
181
|
+
path: ['diagnosis'],
|
|
182
|
+
array: true,
|
|
183
|
+
nested: 'diagnosisReference'
|
|
184
|
+
}, {
|
|
185
|
+
path: ['procedure'],
|
|
186
|
+
array: true,
|
|
187
|
+
nested: 'procedureReference'
|
|
188
|
+
}]
|
|
189
|
+
}, {
|
|
190
|
+
resourceType: 'Coverage',
|
|
191
|
+
references: [{
|
|
192
|
+
path: ['beneficiary']
|
|
193
|
+
}, {
|
|
194
|
+
path: ['payor'],
|
|
195
|
+
array: true
|
|
196
|
+
}]
|
|
197
|
+
}];
|
package/dist/index.js
CHANGED
|
@@ -9,4 +9,25 @@ Object.defineProperty(exports, "FHIRReferenceAssigner", {
|
|
|
9
9
|
return _FHIRReferenceAssigner.FHIRReferenceAssigner;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
Object.defineProperty(exports, "FHIRReferenceEngine", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _FHIRReferenceEngine.FHIRReferenceEngine;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "USCoreFHIRReferenceEngine", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _USCoreFHIRReferenceEngine.USCoreFHIRReferenceEngine;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "US_CORE_REFERENCE_CONFIG", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _uscoreReference.US_CORE_REFERENCE_CONFIG;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _FHIRReferenceAssigner = require("./FHIRReferenceAssigner");
|
|
31
|
+
var _FHIRReferenceEngine = require("./FHIRReferenceEngine");
|
|
32
|
+
var _USCoreFHIRReferenceEngine = require("./USCoreFHIRReferenceEngine");
|
|
33
|
+
var _uscoreReference = require("./config/references/uscore.reference.config");
|