@glion/lint-profile-extra-fields 0.15.1 → 0.15.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 +89 -0
- package/package.json +12 -8
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @glion/lint-profile-extra-fields
|
|
2
|
+
|
|
3
|
+
Lint rule that warns when a segment contains fields beyond the maximum sequence defined in its profile.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
Flags fields whose sequence number exceeds the highest field position defined in the HL7v2 profile for that segment at the message's version. The rule reads profile context attached by `@glion/annotate-profile-context`, computes the maximum defined sequence per segment, and reports each field past that boundary. Segments without a known profile (for example Z-segments) are silently skipped.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @glion/lint-profile-extra-fields
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { hl7v2AnnotateProfileContext } from "@glion/annotate-profile-context";
|
|
19
|
+
import { hl7v2Parser } from "@glion/parser";
|
|
20
|
+
import hl7v2LintExtraFields from "@glion/lint-profile-extra-fields";
|
|
21
|
+
import { unified } from "unified";
|
|
22
|
+
import { reporter } from "vfile-reporter";
|
|
23
|
+
|
|
24
|
+
const message = [
|
|
25
|
+
"MSH|^~\\&|SENDER|FAC|RECV|RFAC|20250601120000||ADT^A01^ADT_A01|MSG00001|P|2.5",
|
|
26
|
+
"PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|F",
|
|
27
|
+
].join("\r");
|
|
28
|
+
|
|
29
|
+
const file = await unified()
|
|
30
|
+
.use(hl7v2Parser)
|
|
31
|
+
.use(hl7v2AnnotateProfileContext)
|
|
32
|
+
.use(hl7v2LintExtraFields)
|
|
33
|
+
.process(message);
|
|
34
|
+
|
|
35
|
+
console.error(reporter([file]));
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### `unified().use(hl7v2LintExtraFields)`
|
|
41
|
+
|
|
42
|
+
A `unified` lint rule plugin. Takes no options.
|
|
43
|
+
|
|
44
|
+
Reads `file.data.profile`. For each segment it looks up the field definition set and takes the largest key (a 1-based HL7 sequence number) as the maximum. It then walks the segment's fields and reports each field whose sequence is greater than that maximum.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import type { Plugin } from "unified";
|
|
48
|
+
import type { Root } from "@glion/ast";
|
|
49
|
+
|
|
50
|
+
declare const hl7v2LintExtraFields: Plugin<[], Root>;
|
|
51
|
+
export default hl7v2LintExtraFields;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## What it checks
|
|
55
|
+
|
|
56
|
+
This rule flags fields past the defined range for a segment. `MSH` in v2.5 ends at `MSH-21`, so any field at sequence 22 or higher is unexpected for that segment and version.
|
|
57
|
+
|
|
58
|
+
### Valid
|
|
59
|
+
|
|
60
|
+
`MSH` stops at `MSH-12` (Version ID) and all fields are within the v2.5 definition:
|
|
61
|
+
|
|
62
|
+
```hl7
|
|
63
|
+
MSH|^~\&|SENDER|FAC|RECV|RFAC|20250601120000||ADT^A01^ADT_A01|MSG00001|P|2.5
|
|
64
|
+
PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|F
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Invalid
|
|
68
|
+
|
|
69
|
+
`MSH` carries a field at sequence 22, which is past the v2.5 maximum of `MSH-21`:
|
|
70
|
+
|
|
71
|
+
```hl7
|
|
72
|
+
MSH|^~\&|SENDER|FAC|RECV|RFAC|20250601120000||ADT^A01^ADT_A01|MSG00001|P|2.5||||||||||EXTRA
|
|
73
|
+
PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|F
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Reported message:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Field MSH-22 is beyond the defined fields for MSH (max: 21 in v2.5)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The reported max comes from the profile's highest sequence number and the version is taken from the annotated profile context. One message is reported per extra field.
|
|
83
|
+
|
|
84
|
+
## Part of Glion
|
|
85
|
+
|
|
86
|
+
`@glion/lint-profile-extra-fields` is part of **[Glion]**, the application framework for HL7v2. See the [Glion README] for the full package catalog and architecture.
|
|
87
|
+
|
|
88
|
+
[Glion]: https://github.com/rethinkhealth/glion#readme
|
|
89
|
+
[Glion README]: https://github.com/rethinkhealth/glion#readme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/lint-profile-extra-fields",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "Lint rule that warns when a segment contains fields beyond the maximum sequence defined in its profile",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"health",
|
|
@@ -34,21 +34,23 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"unified-lint-rule": "3.0.1",
|
|
37
|
-
"@glion/
|
|
38
|
-
"@glion/
|
|
37
|
+
"@glion/ast": "0.15.2",
|
|
38
|
+
"@glion/util-visit": "0.15.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^25.5.0",
|
|
42
42
|
"@vitest/coverage-v8": "4.1.2",
|
|
43
|
+
"publint": "0.3.18",
|
|
43
44
|
"tsdown": "0.21.7",
|
|
44
45
|
"typescript": "^5.9.3",
|
|
45
46
|
"unified": "^11.0.5",
|
|
46
47
|
"vfile": "^6.0.3",
|
|
47
48
|
"vitest": "4.1.2",
|
|
48
|
-
"@glion/
|
|
49
|
-
"@glion/builder": "0.15.
|
|
50
|
-
"@glion/
|
|
51
|
-
"@glion/
|
|
49
|
+
"@glion/check-readme": "0.15.2",
|
|
50
|
+
"@glion/builder": "0.15.2",
|
|
51
|
+
"@glion/annotate-profile-context": "0.15.2",
|
|
52
|
+
"@glion/testing": "0.15.2",
|
|
53
|
+
"@glion/tsconfig": "0.15.2"
|
|
52
54
|
},
|
|
53
55
|
"engines": {
|
|
54
56
|
"node": ">=18"
|
|
@@ -57,9 +59,11 @@
|
|
|
57
59
|
"scripts": {
|
|
58
60
|
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
59
61
|
"check-types": "tsc --noEmit",
|
|
62
|
+
"check:readme": "glion-check-readme",
|
|
60
63
|
"bench": "vitest bench --run",
|
|
61
64
|
"test": "vitest run",
|
|
62
65
|
"test:coverage": "vitest run --coverage",
|
|
63
|
-
"test:watch": "vitest"
|
|
66
|
+
"test:watch": "vitest",
|
|
67
|
+
"publint": "publint --strict"
|
|
64
68
|
}
|
|
65
69
|
}
|