@glion/lint-profile-table-values 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.
Files changed (2) hide show
  1. package/README.md +89 -0
  2. package/package.json +13 -9
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @glion/lint-profile-table-values
2
+
3
+ Lint rule to validate coded field values against HL7v2 tables.
4
+
5
+ ## What it does
6
+
7
+ Flags coded field values that are not present in the HL7-defined table referenced by the field's profile. The rule reads profile context attached by `@glion/annotate-profile-context`, resolves the table by id (stripping the `HL7` prefix, so `HL70001` looks up table `0001`), and checks the first component value of each repetition against the table's code set. Only `hl7`-type tables are validated; user-defined tables, empty fields, and Z-segments are skipped.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @glion/lint-profile-table-values
13
+ ```
14
+
15
+ ## Use
16
+
17
+ ```ts
18
+ import { hl7v2AnnotateProfileContext } from "@glion/annotate-profile-context";
19
+ import { hl7v2Parser } from "@glion/parser";
20
+ import hl7v2LintTableValues from "@glion/lint-profile-table-values";
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(hl7v2LintTableValues)
33
+ .process(message);
34
+
35
+ console.error(reporter([file]));
36
+ ```
37
+
38
+ ## API
39
+
40
+ ### `unified().use(hl7v2LintTableValues)`
41
+
42
+ A `unified` lint rule plugin. Takes no options.
43
+
44
+ Reads `file.data.profile`. For each non-empty field with a declared `table` reference in its profile, loads the table definition from `ctx.tables`. If the table is HL7-defined it checks each repetition's first subcomponent value against the table's code set.
45
+
46
+ ```ts
47
+ import type { Plugin } from "unified";
48
+ import type { Root } from "@glion/ast";
49
+
50
+ declare const hl7v2LintTableValues: Plugin<[], Root>;
51
+ export default hl7v2LintTableValues;
52
+ ```
53
+
54
+ ## What it checks
55
+
56
+ This rule flags coded values that are not members of the HL7 table referenced by the field's profile. For example, `PID-8` (Administrative Sex) references table `HL70001`, whose v2.5 codes include `F`, `M`, `O`, `U`, `A`, `N`.
57
+
58
+ ### Valid
59
+
60
+ `PID-8` is `F`, which is a valid code in table `0001`:
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
+ `PID-8` is `Z`, which is not in table `0001`:
70
+
71
+ ```hl7
72
+ MSH|^~\&|SENDER|FAC|RECV|RFAC|20250601120000||ADT^A01^ADT_A01|MSG00001|P|2.5
73
+ PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|Z
74
+ ```
75
+
76
+ Reported message:
77
+
78
+ ```
79
+ Field PID-8 (Administrative Sex) value 'Z' is not in table 0001 (Administrative Sex)
80
+ ```
81
+
82
+ When the field has a profile name it appears in parentheses. The table id is reported without the `HL7` prefix, matching the way the tables store keys its entries. One message is reported per offending repetition.
83
+
84
+ ## Part of Glion
85
+
86
+ `@glion/lint-profile-table-values` 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-table-values",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "Lint rule to validate coded field values against HL7v2 tables",
5
5
  "keywords": [
6
6
  "health",
@@ -34,22 +34,24 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "unified-lint-rule": "3.0.1",
37
- "@glion/ast": "0.15.1",
38
- "@glion/util-visit": "0.15.1",
39
- "@glion/utils": "0.15.1"
37
+ "@glion/ast": "0.15.2",
38
+ "@glion/utils": "0.15.2",
39
+ "@glion/util-visit": "0.15.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^25.5.0",
43
43
  "@vitest/coverage-v8": "4.1.2",
44
+ "publint": "0.3.18",
44
45
  "tsdown": "0.21.7",
45
46
  "typescript": "^5.9.3",
46
47
  "unified": "^11.0.5",
47
48
  "vfile": "^6.0.3",
48
49
  "vitest": "4.1.2",
49
- "@glion/tsconfig": "0.15.1",
50
- "@glion/builder": "0.15.1",
51
- "@glion/annotate-profile-context": "0.15.1",
52
- "@glion/testing": "0.15.1"
50
+ "@glion/builder": "0.15.2",
51
+ "@glion/annotate-profile-context": "0.15.2",
52
+ "@glion/check-readme": "0.15.2",
53
+ "@glion/testing": "0.15.2",
54
+ "@glion/tsconfig": "0.15.2"
53
55
  },
54
56
  "engines": {
55
57
  "node": ">=18"
@@ -58,9 +60,11 @@
58
60
  "scripts": {
59
61
  "build": "tsdown && tsc --emitDeclarationOnly",
60
62
  "check-types": "tsc --noEmit",
63
+ "check:readme": "glion-check-readme",
61
64
  "bench": "vitest bench --run",
62
65
  "test": "vitest run",
63
66
  "test:coverage": "vitest run --coverage",
64
- "test:watch": "vitest"
67
+ "test:watch": "vitest",
68
+ "publint": "publint --strict"
65
69
  }
66
70
  }