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