@gefyra/diffyr6-cli 1.0.0 β 1.0.2
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/LICENSE +21 -21
- package/README.md +449 -447
- package/config/README.md +27 -27
- package/config/default-rules.json +135 -135
- package/config/resources-r4-not-in-r6.json +42 -42
- package/package.json +54 -54
- package/src/cli.js +94 -92
- package/src/compare-profiles.js +386 -386
- package/src/config.js +153 -147
- package/src/generate-fsh.js +457 -457
- package/src/index.js +462 -394
- package/src/rules-engine.js +642 -642
- package/src/upgrade-sushi.js +553 -553
- package/src/utils/fs.js +38 -38
- package/src/utils/html.js +28 -28
- package/src/utils/process.js +101 -101
- package/src/utils/removed-resources.js +135 -135
- package/src/utils/sushi-log.js +46 -46
- package/src/utils/validator.js +103 -103
- package/src/utils/zip.js +112 -0
package/README.md
CHANGED
|
@@ -1,447 +1,449 @@
|
|
|
1
|
-
# DiffyR6 - FHIR Profile Comparison & Analysis CLI
|
|
2
|
-
|
|
3
|
-
An automated toolkit for comparing FHIR profiles across different versions, analyzing structural differences, and generating comprehensive impact reports with rule-based evaluation.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- π¦ **Automated Package Download** - Downloads FHIR packages from the official registry
|
|
8
|
-
- π **FSH Generation** - Converts FHIR resources to FSH using GoFSH
|
|
9
|
-
- β¬οΈ **Profile Upgrade Pipeline** - Automatically upgrades profiles between FHIR versions using SUSHI
|
|
10
|
-
- π **Profile Comparison** - Compares profile versions using the HL7 FHIR Validator
|
|
11
|
-
- π **Rule-Based Difference Analysis** - Applies customizable rules to classify and score structural changes
|
|
12
|
-
- π― **Impact Scoring** - Calculates complexity scores based on breaking changes and migration risks
|
|
13
|
-
- π¨ **Removed Resource Detection** - Identifies profiles based on resource types removed in newer FHIR versions
|
|
14
|
-
- π **Markdown Reports** - Generates detailed comparison reports with timestamps and findings categorization
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
### From GitHub Registry
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install @gefyra/diffyr6-cli
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### From Source
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
git clone https://github.com/Gefyra/DiffyR6-Cli.git
|
|
28
|
-
cd DiffyR6-Cli
|
|
29
|
-
npm install
|
|
30
|
-
npm link
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Prerequisites
|
|
34
|
-
|
|
35
|
-
- **Node.js** 18.0.0 or higher
|
|
36
|
-
- **npm** for package management
|
|
37
|
-
- **Java** (for HL7 FHIR Validator)
|
|
38
|
-
- **tar** available on PATH (for extracting FHIR packages)
|
|
39
|
-
|
|
40
|
-
### Required Peer Dependencies
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npm install gofsh fsh-sushi
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Quick Start
|
|
47
|
-
|
|
48
|
-
### 1. Create a Configuration File
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
fhir-r6-migrate --init
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
This creates a `migration-config.json` file with default settings.
|
|
55
|
-
|
|
56
|
-
### 2. Edit the Configuration
|
|
57
|
-
|
|
58
|
-
```json
|
|
59
|
-
{
|
|
60
|
-
"configVersion": "1.0.0",
|
|
61
|
-
"packageId": "de.basisprofil.r4",
|
|
62
|
-
"packageVersion": "1.5.0",
|
|
63
|
-
"enableGoFSH": true,
|
|
64
|
-
"resourcesDir": "Resources",
|
|
65
|
-
"resourcesR6Dir": "ResourcesR6",
|
|
66
|
-
"compareDir": "compare",
|
|
67
|
-
"outputDir": "output",
|
|
68
|
-
"rulesConfigPath": null,
|
|
69
|
-
"validatorJarPath": null,
|
|
70
|
-
"workdir": null,
|
|
71
|
-
"compareMode": "incremental"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
import {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
console.log('
|
|
135
|
-
console.log('
|
|
136
|
-
console.log('
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
"
|
|
247
|
-
"
|
|
248
|
-
"
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
"
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
- **
|
|
268
|
-
- **
|
|
269
|
-
- **
|
|
270
|
-
- **
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
- **
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
**
|
|
303
|
-
**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
β βββ
|
|
395
|
-
β βββ
|
|
396
|
-
β βββ
|
|
397
|
-
β βββ
|
|
398
|
-
β βββ
|
|
399
|
-
β
|
|
400
|
-
β
|
|
401
|
-
β
|
|
402
|
-
β βββ
|
|
403
|
-
β βββ
|
|
404
|
-
β βββ
|
|
405
|
-
β
|
|
406
|
-
βββ
|
|
407
|
-
β
|
|
408
|
-
|
|
409
|
-
βββ
|
|
410
|
-
βββ
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
- [
|
|
446
|
-
- [
|
|
447
|
-
- [
|
|
1
|
+
# DiffyR6 - FHIR Profile Comparison & Analysis CLI
|
|
2
|
+
|
|
3
|
+
An automated toolkit for comparing FHIR profiles across different versions, analyzing structural differences, and generating comprehensive impact reports with rule-based evaluation.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- π¦ **Automated Package Download** - Downloads FHIR packages from the official registry
|
|
8
|
+
- π **FSH Generation** - Converts FHIR resources to FSH using GoFSH
|
|
9
|
+
- β¬οΈ **Profile Upgrade Pipeline** - Automatically upgrades profiles between FHIR versions using SUSHI
|
|
10
|
+
- π **Profile Comparison** - Compares profile versions using the HL7 FHIR Validator
|
|
11
|
+
- π **Rule-Based Difference Analysis** - Applies customizable rules to classify and score structural changes
|
|
12
|
+
- π― **Impact Scoring** - Calculates complexity scores based on breaking changes and migration risks
|
|
13
|
+
- π¨ **Removed Resource Detection** - Identifies profiles based on resource types removed in newer FHIR versions
|
|
14
|
+
- π **Markdown Reports** - Generates detailed comparison reports with timestamps and findings categorization
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### From GitHub Registry
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @gefyra/diffyr6-cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### From Source
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/Gefyra/DiffyR6-Cli.git
|
|
28
|
+
cd DiffyR6-Cli
|
|
29
|
+
npm install
|
|
30
|
+
npm link
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Prerequisites
|
|
34
|
+
|
|
35
|
+
- **Node.js** 18.0.0 or higher
|
|
36
|
+
- **npm** for package management
|
|
37
|
+
- **Java** (for HL7 FHIR Validator)
|
|
38
|
+
- **tar** available on PATH (for extracting FHIR packages)
|
|
39
|
+
|
|
40
|
+
### Required Peer Dependencies
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install gofsh fsh-sushi
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### 1. Create a Configuration File
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
fhir-r6-migrate --init
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This creates a `migration-config.json` file with default settings.
|
|
55
|
+
|
|
56
|
+
### 2. Edit the Configuration
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"configVersion": "1.0.0",
|
|
61
|
+
"packageId": "de.basisprofil.r4",
|
|
62
|
+
"packageVersion": "1.5.0",
|
|
63
|
+
"enableGoFSH": true,
|
|
64
|
+
"resourcesDir": "Resources",
|
|
65
|
+
"resourcesR6Dir": "ResourcesR6",
|
|
66
|
+
"compareDir": "compare",
|
|
67
|
+
"outputDir": "output",
|
|
68
|
+
"rulesConfigPath": null,
|
|
69
|
+
"validatorJarPath": null,
|
|
70
|
+
"workdir": null,
|
|
71
|
+
"compareMode": "incremental",
|
|
72
|
+
"exportZip": true
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Run the Migration
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
fhir-r6-migrate
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or with a custom config:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
fhir-r6-migrate --config my-config.json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
### CLI Usage
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Run with default config
|
|
94
|
+
fhir-r6-migrate
|
|
95
|
+
|
|
96
|
+
# Run with custom config
|
|
97
|
+
fhir-r6-migrate --config path/to/config.json
|
|
98
|
+
|
|
99
|
+
# Create example config
|
|
100
|
+
fhir-r6-migrate --init
|
|
101
|
+
|
|
102
|
+
# Show version
|
|
103
|
+
fhir-r6-migrate --version
|
|
104
|
+
|
|
105
|
+
# Show help
|
|
106
|
+
fhir-r6-migrate --help
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Programmatic Usage
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
import { runMigration } from '@gefyra/fhir-r6-migration-runner';
|
|
113
|
+
import { loadConfig } from '@gefyra/fhir-r6-migration-runner/config';
|
|
114
|
+
|
|
115
|
+
// Load config from file
|
|
116
|
+
const config = await loadConfig('./migration-config.json');
|
|
117
|
+
|
|
118
|
+
// Or create config programmatically
|
|
119
|
+
const config = {
|
|
120
|
+
configVersion: '1.0.0',
|
|
121
|
+
packageId: 'de.basisprofil.r4',
|
|
122
|
+
packageVersion: '1.5.0',
|
|
123
|
+
enableGoFSH: true,
|
|
124
|
+
resourcesDir: 'Resources',
|
|
125
|
+
resourcesR6Dir: 'ResourcesR6',
|
|
126
|
+
compareDir: 'compare',
|
|
127
|
+
outputDir: 'output',
|
|
128
|
+
compareMode: 'incremental',
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Run migration
|
|
132
|
+
const result = await runMigration(config);
|
|
133
|
+
|
|
134
|
+
console.log('Migration complete!');
|
|
135
|
+
console.log('Report:', result.report);
|
|
136
|
+
console.log('Score:', result.score);
|
|
137
|
+
console.log('Findings:', result.findingsCount);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Configuration Reference
|
|
141
|
+
|
|
142
|
+
### Required Fields
|
|
143
|
+
|
|
144
|
+
| Field | Type | Description |
|
|
145
|
+
|-------|------|-------------|
|
|
146
|
+
| `configVersion` | string | Config schema version (must be "1.0.0") |
|
|
147
|
+
| `packageId` | string | FHIR package ID (required if `enableGoFSH` is true) |
|
|
148
|
+
| `resourcesDir` | string | Directory for baseline/source version resources |
|
|
149
|
+
| `resourcesR6Dir` | string | Directory for target/comparison version resources |
|
|
150
|
+
| `compareDir` | string | Directory for comparison HTML files |
|
|
151
|
+
| `outputDir` | string | Directory for generated reports |
|
|
152
|
+
|
|
153
|
+
### Optional Fields
|
|
154
|
+
|
|
155
|
+
| Field | Type | Default | Description |
|
|
156
|
+
|-------|------|---------|-------------|
|
|
157
|
+
| `packageVersion` | string | `"current"` | FHIR package version |
|
|
158
|
+
| `enableGoFSH` | boolean | `true` | Enable GoFSH package download & FSH generation |
|
|
159
|
+
| `rulesConfigPath` | string | `null` | Path to custom rules config (uses default if null) |
|
|
160
|
+
| `validatorJarPath` | string | `null` | Path to validator_cli.jar (auto-downloads latest from GitHub if null) |
|
|
161
|
+
| `workdir` | string | `null` | Working directory (uses current dir if null) |
|
|
162
|
+
| `compareMode` | string | `"incremental"` | Comparison mode: `"incremental"` or `"full"` |
|
|
163
|
+
| `exportZip` | boolean | `true` | Create a ZIP export containing compare HTML, markdown report, and run config |
|
|
164
|
+
|
|
165
|
+
**Auto-download feature:** When `validatorJarPath` is `null`, the HL7 FHIR Validator will be automatically downloaded from a [stable GitHub release](https://github.com/hapifhir/org.hl7.fhir.core/releases/download/6.7.10/validator_cli.jar) to `<workdir>/validator_cli.jar`. This download only happens once - subsequent runs will reuse the existing JAR file.
|
|
166
|
+
|
|
167
|
+
## Pipeline Steps
|
|
168
|
+
|
|
169
|
+
The comparison pipeline consists of 4 steps:
|
|
170
|
+
|
|
171
|
+
### 1. GoFSH (Optional)
|
|
172
|
+
|
|
173
|
+
Downloads the specified FHIR package and converts it to FSH using GoFSH for the baseline version.
|
|
174
|
+
|
|
175
|
+
**Skipped if:** `resourcesDir/sushi-config.yaml` already exists
|
|
176
|
+
|
|
177
|
+
### 2. Profile Upgrade
|
|
178
|
+
|
|
179
|
+
Runs SUSHI to upgrade profiles to the target FHIR version, applying automatic fixes for common issues.
|
|
180
|
+
|
|
181
|
+
**Skipped if:** `resourcesR6Dir/sushi-config.yaml` already exists
|
|
182
|
+
|
|
183
|
+
### 3. Profile Comparison
|
|
184
|
+
|
|
185
|
+
Uses the HL7 FHIR Validator to compare baseline and target profile versions, generating HTML comparison files showing structural differences.
|
|
186
|
+
|
|
187
|
+
**Incremental mode:** Only compares profiles with missing HTML files
|
|
188
|
+
**Full mode:** Compares all profiles, overwriting existing files
|
|
189
|
+
|
|
190
|
+
### 4. Report Generation
|
|
191
|
+
|
|
192
|
+
Applies rules to the comparison HTML files and generates a markdown report with:
|
|
193
|
+
- Removed resource detection (profiles based on deprecated resource types)
|
|
194
|
+
- Detailed findings grouped by profile and category
|
|
195
|
+
- Impact score based on breaking changes
|
|
196
|
+
- Timestamped filename (e.g., `comparison-report-20260123-143052.md`)
|
|
197
|
+
|
|
198
|
+
## Compare Modes
|
|
199
|
+
|
|
200
|
+
### Incremental Mode (Default)
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"compareMode": "incremental"
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
- Only compares profiles that don't have existing HTML files
|
|
209
|
+
- Faster for incremental updates
|
|
210
|
+
- Preserves existing comparisons
|
|
211
|
+
|
|
212
|
+
### Full Mode
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"compareMode": "full"
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
- Compares all profiles, overwriting existing files
|
|
221
|
+
- Useful for clean rebuilds
|
|
222
|
+
- Ensures all comparisons are up-to-date
|
|
223
|
+
|
|
224
|
+
## Custom Rules
|
|
225
|
+
|
|
226
|
+
The package includes a default set of rules for common migration issues. You can customize or extend these rules:
|
|
227
|
+
|
|
228
|
+
### Using Custom Rules
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"rulesConfigPath": "./my-rules.json"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Rules Configuration Format
|
|
237
|
+
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"title": "Custom Analysis Rules",
|
|
241
|
+
"tables": [
|
|
242
|
+
{
|
|
243
|
+
"sectionHeading": "Structure",
|
|
244
|
+
"rules": [
|
|
245
|
+
{
|
|
246
|
+
"name": "Element removed in target version",
|
|
247
|
+
"description": "An element from the baseline version no longer exists in the target",
|
|
248
|
+
"rank": 50,
|
|
249
|
+
"value": 2,
|
|
250
|
+
"conditions": [
|
|
251
|
+
{
|
|
252
|
+
"column": "Comments",
|
|
253
|
+
"operator": "equals",
|
|
254
|
+
"value": "Removed this element"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
"template": "The element {{Name}} exists in baseline but was removed in target."
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Rule Properties
|
|
266
|
+
|
|
267
|
+
- **name**: Rule category name (groups findings in the report)
|
|
268
|
+
- **description**: Detailed explanation of the difference
|
|
269
|
+
- **rank**: Sorting order in the report (lower = higher priority)
|
|
270
|
+
- **value**: Score contribution (higher = more significant change)
|
|
271
|
+
- **conditions**: Array of conditions that must ALL match
|
|
272
|
+
- **template**: Output text with variable substitution (`{{variableName}}`)
|
|
273
|
+
|
|
274
|
+
### Condition Operators
|
|
275
|
+
|
|
276
|
+
- `equals`: Exact match (case-insensitive by default)
|
|
277
|
+
- `contains`: Substring match (case-insensitive by default)
|
|
278
|
+
- `!equals` / `notequals`: Not equal
|
|
279
|
+
|
|
280
|
+
### Available Variables
|
|
281
|
+
|
|
282
|
+
- Column aliases (e.g., `{{Name}}`, `{{Comments}}`)
|
|
283
|
+
- Index-based columns (e.g., `{{col1}}`, `{{col2}}`)
|
|
284
|
+
- Context variables: `{{file}}`, `{{section}}`, `{{profile}}`
|
|
285
|
+
|
|
286
|
+
## Impact Score
|
|
287
|
+
|
|
288
|
+
The impact score is calculated by summing the `value` field from all rule matches across all differences found.
|
|
289
|
+
|
|
290
|
+
**Interpretation:**
|
|
291
|
+
- **0-50**: Low impact - minor differences, straightforward adaptation
|
|
292
|
+
- **51-150**: Medium impact - moderate structural changes requiring attention
|
|
293
|
+
- **151+**: High impact - significant breaking changes and redesign needed
|
|
294
|
+
|
|
295
|
+
## Output
|
|
296
|
+
|
|
297
|
+
### Report Format
|
|
298
|
+
|
|
299
|
+
```markdown
|
|
300
|
+
# FHIR Profile Comparison Report
|
|
301
|
+
|
|
302
|
+
**Generated:** 2026-01-23T14:30:52.000Z
|
|
303
|
+
**Total Findings:** 42
|
|
304
|
+
**Impact Score:** 135
|
|
305
|
+
**Resources Removed:** 0
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## β οΈ Resources Removed in Target Version
|
|
310
|
+
|
|
311
|
+
β
**No profiles found that are based on resource types removed in target version.**
|
|
312
|
+
|
|
313
|
+
Your baseline profiles do not use any deprecated resource types.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## PatientProfile
|
|
318
|
+
|
|
319
|
+
**Score:** 25 | **Findings:** 8
|
|
320
|
+
|
|
321
|
+
### Element removed in target version
|
|
322
|
+
|
|
323
|
+
*An element from baseline version no longer exists in target...*
|
|
324
|
+
|
|
325
|
+
- Element identifier exists in baseline but removed in target. *(Score: 15)*
|
|
326
|
+
- Element photo exists in baseline but removed in target. *(Score: 15)*
|
|
327
|
+
|
|
328
|
+
### Change in cardinality
|
|
329
|
+
|
|
330
|
+
*The cardinality of an element has changed...*
|
|
331
|
+
|
|
332
|
+
- For element name, the cardinality changed: cardinalities differ (0..* vs 1..*) *(Score: 5)*
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
**Final Impact Score:** 135
|
|
337
|
+
|
|
338
|
+
*Lower scores indicate fewer structural changes.*
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Configuration Versioning
|
|
342
|
+
|
|
343
|
+
The package uses semantic versioning for configuration schemas.
|
|
344
|
+
|
|
345
|
+
**Current version:** `1.0.0`
|
|
346
|
+
|
|
347
|
+
### Version Compatibility
|
|
348
|
+
|
|
349
|
+
- **Major version** must match exactly
|
|
350
|
+
- **Minor/patch versions** are backwards compatible
|
|
351
|
+
|
|
352
|
+
If you receive a config version error:
|
|
353
|
+
1. Update the package: `npm update @gefyra/fhir-r6-migration-runner`
|
|
354
|
+
2. Or update your config's `configVersion` field
|
|
355
|
+
|
|
356
|
+
## Troubleshooting
|
|
357
|
+
|
|
358
|
+
### Error: "Missing configVersion field"
|
|
359
|
+
|
|
360
|
+
Add `"configVersion": "1.0.0"` to your config file.
|
|
361
|
+
|
|
362
|
+
### Error: "Incompatible config version"
|
|
363
|
+
|
|
364
|
+
Update the package or adjust your config to match the expected major version.
|
|
365
|
+
|
|
366
|
+
### GoFSH not found
|
|
367
|
+
|
|
368
|
+
Ensure `gofsh` is installed:
|
|
369
|
+
```bash
|
|
370
|
+
npm install gofsh
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Or specify a custom path in your environment:
|
|
374
|
+
```bash
|
|
375
|
+
export GOFSH_BIN=/path/to/gofsh
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Validator JAR download fails
|
|
379
|
+
|
|
380
|
+
Download manually and specify the path:
|
|
381
|
+
```json
|
|
382
|
+
{
|
|
383
|
+
"validatorJarPath": "/path/to/validator_cli.jar"
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Development
|
|
388
|
+
|
|
389
|
+
### Project Structure
|
|
390
|
+
|
|
391
|
+
```
|
|
392
|
+
DiffyR6-Cli/
|
|
393
|
+
βββ src/
|
|
394
|
+
β βββ index.js # Main pipeline logic
|
|
395
|
+
β βββ cli.js # CLI entry point
|
|
396
|
+
β βββ config.js # Configuration loading & validation
|
|
397
|
+
β βββ rules-engine.js # Rule evaluation engine
|
|
398
|
+
β βββ generate-fsh.js # GoFSH package download & FSH generation
|
|
399
|
+
β βββ upgrade-sushi.js # SUSHI profile upgrade with auto-fixes
|
|
400
|
+
β βββ compare-profiles.js # HL7 Validator profile comparison
|
|
401
|
+
β βββ utils/
|
|
402
|
+
β βββ fs.js # Filesystem utilities
|
|
403
|
+
β βββ process.js # Process spawning utilities
|
|
404
|
+
β βββ sushi-log.js # SUSHI log parsing
|
|
405
|
+
β βββ html.js # HTML parsing utilities
|
|
406
|
+
β βββ validator.js # Validator JAR auto-download
|
|
407
|
+
β βββ removed-resources.js # Removed resource detection
|
|
408
|
+
βββ config/
|
|
409
|
+
β βββ default-rules.json # Default analysis rules
|
|
410
|
+
β βββ resources-r4-not-in-r6.json # List of removed resource types
|
|
411
|
+
βββ package.json
|
|
412
|
+
βββ README.md
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Building
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
npm run build
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### Testing
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
npm test
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
*Note: Tests are not yet implemented*
|
|
428
|
+
|
|
429
|
+
## Contributing
|
|
430
|
+
|
|
431
|
+
Contributions are welcome! Please open an issue or pull request on GitHub.
|
|
432
|
+
|
|
433
|
+
## License
|
|
434
|
+
|
|
435
|
+
MIT
|
|
436
|
+
|
|
437
|
+
## Author
|
|
438
|
+
|
|
439
|
+
Jonas SchΓΆn (Gefyra GmbH)
|
|
440
|
+
- Email: js@gefyra.de
|
|
441
|
+
- GitHub: [@Gefyra](https://github.com/Gefyra)
|
|
442
|
+
|
|
443
|
+
## Links
|
|
444
|
+
|
|
445
|
+
- [GitHub Repository](https://github.com/Gefyra/fhir-r6-migration-runner)
|
|
446
|
+
- [npm Package](https://www.npmjs.com/package/@gefyra/fhir-r6-migration-runner)
|
|
447
|
+
- [FHIR R6 Specification](https://hl7.org/fhir/R6/)
|
|
448
|
+
- [GoFSH](https://github.com/FHIR/GoFSH)
|
|
449
|
+
- [SUSHI](https://github.com/FHIR/sushi)
|