@glion/annotate-profile-segments 0.14.1
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 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Rethink Health
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Root } from "@glion/ast";
|
|
2
|
+
import type { Plugin } from "unified";
|
|
3
|
+
declare module "@glion/ast" {
|
|
4
|
+
interface SegmentData {
|
|
5
|
+
/**
|
|
6
|
+
* Human-readable segment title from the HL7v2 specification (e.g., "Message
|
|
7
|
+
* Header").
|
|
8
|
+
*/
|
|
9
|
+
title?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Unified plugin that annotates Segment nodes with their title from the
|
|
14
|
+
* HL7v2 specification profile.
|
|
15
|
+
*
|
|
16
|
+
* Reads segment definitions from `file.data.profile.segments` (populated by
|
|
17
|
+
* `@glion/annotate-profile-context`) and sets
|
|
18
|
+
* `segment.data.title` on each segment node.
|
|
19
|
+
*
|
|
20
|
+
* Unknown segments (Z-segments) and unsupported versions are silently skipped.
|
|
21
|
+
*/
|
|
22
|
+
export declare const hl7v2AnnotateProfileSegments: Plugin<[], Root, Root>;
|
|
23
|
+
export default hl7v2AnnotateProfileSegments;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,WAAW;QACnB;;;WAGG;QACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B;CACF;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAuB7D,CAAC;AAEJ,eAAe,4BAA4B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { visit } from "@glion/util-visit";
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* Unified plugin that annotates Segment nodes with their title from the
|
|
5
|
+
* HL7v2 specification profile.
|
|
6
|
+
*
|
|
7
|
+
* Reads segment definitions from `file.data.profile.segments` (populated by
|
|
8
|
+
* `@glion/annotate-profile-context`) and sets
|
|
9
|
+
* `segment.data.title` on each segment node.
|
|
10
|
+
*
|
|
11
|
+
* Unknown segments (Z-segments) and unsupported versions are silently skipped.
|
|
12
|
+
*/
|
|
13
|
+
const hl7v2AnnotateProfileSegments = () => (tree, file) => {
|
|
14
|
+
const ctx = file.data.profile;
|
|
15
|
+
if (!ctx) return tree;
|
|
16
|
+
const { segments } = ctx;
|
|
17
|
+
visit(tree, "segment", (node) => {
|
|
18
|
+
const profile = segments.byId.get(node.name);
|
|
19
|
+
if (!profile) return;
|
|
20
|
+
if (!node.data) node.data = {};
|
|
21
|
+
node.data.title = profile.title;
|
|
22
|
+
});
|
|
23
|
+
return tree;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { hl7v2AnnotateProfileSegments as default, hl7v2AnnotateProfileSegments };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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\";\nimport type { Root } from \"@glion/ast\";\nimport { visit } from \"@glion/util-visit\";\nimport type { Plugin } from \"unified\";\nimport type { VFile } from \"vfile\";\n\ndeclare module \"@glion/ast\" {\n interface SegmentData {\n /**\n * Human-readable segment title from the HL7v2 specification (e.g., \"Message\n * Header\").\n */\n title?: string | undefined;\n }\n}\n\n/**\n * Unified plugin that annotates Segment nodes with their title from the\n * HL7v2 specification profile.\n *\n * Reads segment definitions from `file.data.profile.segments` (populated by\n * `@glion/annotate-profile-context`) and sets\n * `segment.data.title` on each segment node.\n *\n * Unknown segments (Z-segments) and unsupported versions are silently skipped.\n */\nexport const hl7v2AnnotateProfileSegments: Plugin<[], Root, Root> =\n () => (tree: Root, file: VFile) => {\n const ctx = file.data.profile;\n if (!ctx) {\n return tree;\n }\n\n const { segments } = ctx;\n\n visit(tree, \"segment\", (node) => {\n const profile = segments.byId.get(node.name);\n if (!profile) {\n return;\n }\n\n if (!node.data) {\n node.data = {};\n }\n\n node.data.title = profile.title;\n });\n\n return tree;\n };\n\nexport default hl7v2AnnotateProfileSegments;\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAa,sCACJ,MAAY,SAAgB;CACjC,MAAM,MAAM,KAAK,KAAK;AACtB,KAAI,CAAC,IACH,QAAO;CAGT,MAAM,EAAE,aAAa;AAErB,OAAM,MAAM,YAAY,SAAS;EAC/B,MAAM,UAAU,SAAS,KAAK,IAAI,KAAK,KAAK;AAC5C,MAAI,CAAC,QACH;AAGF,MAAI,CAAC,KAAK,KACR,MAAK,OAAO,EAAE;AAGhB,OAAK,KAAK,QAAQ,QAAQ;GAC1B;AAEF,QAAO"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glion/annotate-profile-segments",
|
|
3
|
+
"version": "0.14.1",
|
|
4
|
+
"description": "Unified plugin to annotate HL7v2 segment nodes with profile metadata",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"annotate",
|
|
7
|
+
"health",
|
|
8
|
+
"healthcare",
|
|
9
|
+
"hl7",
|
|
10
|
+
"hl7v2",
|
|
11
|
+
"nodejs",
|
|
12
|
+
"plugin",
|
|
13
|
+
"profile",
|
|
14
|
+
"segment",
|
|
15
|
+
"typescript",
|
|
16
|
+
"unified"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://glion.dev",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Melek Somai",
|
|
22
|
+
"email": "melek@rethinkhealth.io"
|
|
23
|
+
},
|
|
24
|
+
"repository": "rethinkhealth/glion.git",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"unified": "11.0.5",
|
|
38
|
+
"vfile": "^6.0.3",
|
|
39
|
+
"@glion/ast": "0.14.1",
|
|
40
|
+
"@glion/util-visit": "0.14.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^25.5.0",
|
|
44
|
+
"@vitest/coverage-v8": "4.1.0",
|
|
45
|
+
"tsdown": "0.21.7",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vitest": "4.1.0",
|
|
48
|
+
"@glion/annotate-profile-context": "0.14.1",
|
|
49
|
+
"@glion/builder": "0.14.1",
|
|
50
|
+
"@glion/profiles": "0.14.1",
|
|
51
|
+
"@glion/testing": "0.0.2",
|
|
52
|
+
"@glion/tsconfig": "0.0.1"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
59
|
+
"check-types": "tsc --noEmit",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"test:coverage": "vitest run --coverage",
|
|
62
|
+
"test:watch": "vitest"
|
|
63
|
+
}
|
|
64
|
+
}
|