@glion/lint-profile-extra-components 0.25.0 → 0.27.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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/package.json +12 -9
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -76,13 +76,13 @@ PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|F^EXTRA
|
|
|
76
76
|
Reported message:
|
|
77
77
|
|
|
78
78
|
```
|
|
79
|
-
|
|
79
|
+
The field repetition has 2 components; its datatype allows at most 1 component.
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
The limit comes from the field's datatype in the message's version. `PID-3` is a `CX` field, which defines 10 components in v2.5, so a repetition with 11 is reported as:
|
|
83
83
|
|
|
84
84
|
```
|
|
85
|
-
|
|
85
|
+
The field repetition has 11 components; its datatype allows at most 10 components.
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
## Part of Glion
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Root } from "@glion/ast";
|
|
|
5
5
|
*
|
|
6
6
|
* A primitive datatype defines one component. Empty fields are not checked.
|
|
7
7
|
*
|
|
8
|
-
* Reads `
|
|
8
|
+
* Reads `datatype` from `field.data`, so
|
|
9
9
|
* `@glion/annotate-profile-fields` MUST run before it.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWvC;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,wBAAwB,mDAsC7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,14 +3,14 @@ import { isEmptyNode } from "@glion/utils";
|
|
|
3
3
|
import pluralize from "pluralize";
|
|
4
4
|
import { lintRule } from "unified-lint-rule";
|
|
5
5
|
//#region src/index.ts
|
|
6
|
-
const messages = { tooManyComponents: (
|
|
6
|
+
const messages = { tooManyComponents: (count, max) => `The field repetition has ${pluralize("component", count, true)}; its datatype allows at most ${pluralize("component", max, true)}.` };
|
|
7
7
|
/**
|
|
8
8
|
* Lint rule that reports a field repetition with more components than its
|
|
9
9
|
* datatype defines.
|
|
10
10
|
*
|
|
11
11
|
* A primitive datatype defines one component. Empty fields are not checked.
|
|
12
12
|
*
|
|
13
|
-
* Reads `
|
|
13
|
+
* Reads `datatype` from `field.data`, so
|
|
14
14
|
* `@glion/annotate-profile-fields` MUST run before it.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
@@ -28,15 +28,15 @@ const hl7v2LintExtraComponents = lintRule({
|
|
|
28
28
|
const ctx = file.data.profile;
|
|
29
29
|
if (!ctx) return;
|
|
30
30
|
visit(tree, "field", (field, ancestors) => {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const datatype =
|
|
34
|
-
if (
|
|
31
|
+
const { data } = field;
|
|
32
|
+
if (isEmptyNode(field)) return SKIP;
|
|
33
|
+
const datatype = data?.datatype && ctx.datatypes.get(data.datatype);
|
|
34
|
+
if (!datatype) return SKIP;
|
|
35
35
|
const max = Math.max(1, ...datatype.componentsBySequence.keys());
|
|
36
36
|
for (const repetition of field.children) {
|
|
37
37
|
const count = repetition.children.length;
|
|
38
38
|
if (count > max) {
|
|
39
|
-
const message = file.message(messages.tooManyComponents(
|
|
39
|
+
const message = file.message(messages.tooManyComponents(count, max), {
|
|
40
40
|
ancestors: [
|
|
41
41
|
...ancestors,
|
|
42
42
|
field,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers VFile DataMap augmentation\nimport type { ProfileContext } from \"@glion/annotate-profile-context\";\n// oxlint-disable-next-line no-unused-vars -- triggers FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\nimport type { Root } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport { isEmptyNode } from \"@glion/utils\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\n\nconst messages = {\n tooManyComponents: (
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers VFile DataMap augmentation\nimport type { ProfileContext } from \"@glion/annotate-profile-context\";\n// oxlint-disable-next-line no-unused-vars -- triggers FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\nimport type { Root } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport { isEmptyNode } from \"@glion/utils\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\n\nconst messages = {\n tooManyComponents: (count: number, max: number) =>\n `The field repetition has ${pluralize(\"component\", count, true)}; its datatype allows at most ${pluralize(\"component\", max, true)}.`,\n} as const;\n\n/**\n * Lint rule that reports a field repetition with more components than its\n * datatype defines.\n *\n * A primitive datatype defines one component. Empty fields are not checked.\n *\n * Reads `datatype` from `field.data`, so\n * `@glion/annotate-profile-fields` MUST run before it.\n *\n * @example\n * ```typescript\n * unified()\n * .use(hl7v2AnnotateProfileContext)\n * .use(hl7v2AnnotateProfileFields)\n * .use(hl7v2LintExtraComponents);\n * ```;\n */\nconst hl7v2LintExtraComponents = lintRule<Root>(\n {\n origin: \"hl7v2-lint:extra-components\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-extra-components#readme\",\n },\n (tree, file) => {\n const ctx = file.data.profile;\n if (!ctx) {\n return;\n }\n\n visit(tree, \"field\", (field, ancestors) => {\n const { data } = field;\n if (isEmptyNode(field)) {\n return SKIP;\n }\n const datatype = data?.datatype && ctx.datatypes.get(data.datatype);\n if (!datatype) {\n return SKIP;\n }\n\n // A primitive datatype has no component definitions; its value is\n // component 1.\n const max = Math.max(1, ...datatype.componentsBySequence.keys());\n\n for (const repetition of field.children) {\n const count = repetition.children.length;\n if (count > max) {\n const message = file.message(messages.tooManyComponents(count, max), {\n ancestors: [...ancestors, field, repetition],\n place: repetition.position ?? field.position,\n });\n message.actual = String(count);\n }\n }\n return SKIP;\n });\n }\n);\n\nexport default hl7v2LintExtraComponents;\n"],"mappings":";;;;;AAUA,MAAM,WAAW,EACf,oBAAoB,OAAe,QACjC,4BAA4B,UAAU,aAAa,OAAO,KAAK,CAAC,gCAAgC,UAAU,aAAa,KAAK,KAAK,CAAC,IACrI;;;;;;;;;;;;;;;;;;AAmBD,MAAM,2BAA2B,SAC/B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;CACd,MAAM,MAAM,KAAK,KAAK;AACtB,KAAI,CAAC,IACH;AAGF,OAAM,MAAM,UAAU,OAAO,cAAc;EACzC,MAAM,EAAE,SAAS;AACjB,MAAI,YAAY,MAAM,CACpB,QAAO;EAET,MAAM,WAAW,MAAM,YAAY,IAAI,UAAU,IAAI,KAAK,SAAS;AACnE,MAAI,CAAC,SACH,QAAO;EAKT,MAAM,MAAM,KAAK,IAAI,GAAG,GAAG,SAAS,qBAAqB,MAAM,CAAC;AAEhE,OAAK,MAAM,cAAc,MAAM,UAAU;GACvC,MAAM,QAAQ,WAAW,SAAS;AAClC,OAAI,QAAQ,KAAK;IACf,MAAM,UAAU,KAAK,QAAQ,SAAS,kBAAkB,OAAO,IAAI,EAAE;KACnE,WAAW;MAAC,GAAG;MAAW;MAAO;MAAW;KAC5C,OAAO,WAAW,YAAY,MAAM;KACrC,CAAC;AACF,YAAQ,SAAS,OAAO,MAAM;;;AAGlC,SAAO;GACP;EAEL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/lint-profile-extra-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Lint rule to warn when a composite field contains more components than its datatype profile defines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"health",
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"pluralize": "8.0.0",
|
|
37
37
|
"unified-lint-rule": "3.0.1",
|
|
38
|
-
"@glion/annotate-profile-fields": "0.
|
|
39
|
-
"@glion/
|
|
40
|
-
"@glion/
|
|
41
|
-
"@glion/utils": "0.
|
|
38
|
+
"@glion/annotate-profile-fields": "0.27.0",
|
|
39
|
+
"@glion/ast": "0.27.0",
|
|
40
|
+
"@glion/util-visit": "0.27.0",
|
|
41
|
+
"@glion/utils": "0.27.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@stryker-mutator/core": "10.0.0",
|
|
45
|
+
"@stryker-mutator/vitest-runner": "10.0.0",
|
|
44
46
|
"@types/node": "25.6.0",
|
|
45
47
|
"@types/pluralize": "^0.0.33",
|
|
46
48
|
"@vitest/coverage-v8": "4.1.11",
|
|
@@ -50,8 +52,8 @@
|
|
|
50
52
|
"unified": "^11.0.5",
|
|
51
53
|
"vfile": "^6.0.3",
|
|
52
54
|
"vitest": "4.1.11",
|
|
53
|
-
"@glion/annotate-profile-context": "0.
|
|
54
|
-
"@glion/builder": "0.
|
|
55
|
+
"@glion/annotate-profile-context": "0.27.0",
|
|
56
|
+
"@glion/builder": "0.27.0",
|
|
55
57
|
"@glion/check-readme": "0.18.0",
|
|
56
58
|
"@glion/testing": "0.18.0",
|
|
57
59
|
"@glion/tsconfig": "0.18.0"
|
|
@@ -63,9 +65,10 @@
|
|
|
63
65
|
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
64
66
|
"check-types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
|
|
65
67
|
"check:readme": "glion-check-readme",
|
|
68
|
+
"mutate": "stryker run",
|
|
69
|
+
"publint": "publint --strict",
|
|
66
70
|
"test": "vitest run",
|
|
67
71
|
"test:coverage": "vitest run --coverage",
|
|
68
|
-
"test:watch": "vitest"
|
|
69
|
-
"publint": "publint --strict"
|
|
72
|
+
"test:watch": "vitest"
|
|
70
73
|
}
|
|
71
74
|
}
|