@glion/annotate-profile-segments 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 +75 -0
- package/package.json +13 -9
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @glion/annotate-profile-segments
|
|
2
|
+
|
|
3
|
+
Unified plugin to annotate HL7v2 segment nodes with profile metadata.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
Segments in a parsed HL7v2 tree carry only their three-character name (`MSH`, `PID`, `OBX`, `OBR`). This plugin looks each segment up in the HL7v2 specification profile for the message's version and writes the official segment title — for example `Message Header` for MSH or `Patient Identification` for PID — onto `segment.data.title`. It reads the preloaded profile from `file.data.profile`, so it requires `@glion/annotate-profile-context` to run first.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @glion/annotate-profile-segments
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { hl7v2AnnotateProfileContext } from "@glion/annotate-profile-context";
|
|
19
|
+
import { hl7v2AnnotateProfileSegments } from "@glion/annotate-profile-segments";
|
|
20
|
+
import { hl7v2Parser } from "@glion/parser";
|
|
21
|
+
import { unified } from "unified";
|
|
22
|
+
|
|
23
|
+
const processor = unified()
|
|
24
|
+
.use(hl7v2Parser)
|
|
25
|
+
.use(hl7v2AnnotateProfileContext)
|
|
26
|
+
.use(hl7v2AnnotateProfileSegments);
|
|
27
|
+
|
|
28
|
+
const file = await processor.process(
|
|
29
|
+
"MSH|^~\\&|SENDER||RECEIVER||20241201||ADT^A01|MSG123|P|2.5\rPID|1||12345"
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// MSH segment.data.title === "Message Header"
|
|
33
|
+
// PID segment.data.title === "Patient Identification"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## API
|
|
37
|
+
|
|
38
|
+
This package exports the named constant `hl7v2AnnotateProfileSegments`. The default export is the plugin itself.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import type { Root } from "@glion/ast";
|
|
42
|
+
import type { Plugin } from "unified";
|
|
43
|
+
|
|
44
|
+
export const hl7v2AnnotateProfileSegments: Plugin<[], Root, Root>;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The plugin reads `file.data.profile.segments` (populated by `@glion/annotate-profile-context`) and writes to `SegmentData` on each matching segment.
|
|
48
|
+
|
|
49
|
+
## What it annotates
|
|
50
|
+
|
|
51
|
+
This plugin visits every `segment` node, looks up the segment profile by three-character name, and writes the human-readable title onto `segment.data.title`. Segments with no matching profile — Z-segments or segments from unsupported versions — are left untouched.
|
|
52
|
+
|
|
53
|
+
### `segment.data`
|
|
54
|
+
|
|
55
|
+
After this plugin runs, the augmented interface is:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
declare module "@glion/ast" {
|
|
59
|
+
interface SegmentData {
|
|
60
|
+
// Human-readable segment title from the HL7v2 specification.
|
|
61
|
+
// Examples: "Message Header" (MSH), "Patient Identification" (PID),
|
|
62
|
+
// "Observation/Result" (OBX), "Observation Request" (OBR).
|
|
63
|
+
title?: string;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Lookup uses `profile.segments.byId.get(node.name)` where `profile` is the `ProfileContext` attached by `@glion/annotate-profile-context`. If `file.data.profile` is missing entirely, the plugin returns without writing anything.
|
|
69
|
+
|
|
70
|
+
## Part of Glion
|
|
71
|
+
|
|
72
|
+
`@glion/annotate-profile-segments` is part of **[Glion]**, the application framework for HL7v2. See the [Glion README] for the full package catalog and architecture.
|
|
73
|
+
|
|
74
|
+
[Glion]: https://github.com/rethinkhealth/glion#readme
|
|
75
|
+
[Glion README]: https://github.com/rethinkhealth/glion#readme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/annotate-profile-segments",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "Unified plugin to annotate HL7v2 segment nodes with profile metadata",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotate",
|
|
@@ -40,20 +40,22 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"unified": "11.0.5",
|
|
42
42
|
"vfile": "^6.0.3",
|
|
43
|
-
"@glion/
|
|
44
|
-
"@glion/
|
|
43
|
+
"@glion/ast": "0.15.2",
|
|
44
|
+
"@glion/util-visit": "0.15.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^25.5.0",
|
|
48
48
|
"@vitest/coverage-v8": "4.1.0",
|
|
49
|
+
"publint": "0.3.18",
|
|
49
50
|
"tsdown": "0.21.7",
|
|
50
51
|
"typescript": "^5.9.3",
|
|
51
52
|
"vitest": "4.1.0",
|
|
52
|
-
"@glion/
|
|
53
|
-
"@glion/
|
|
54
|
-
"@glion/
|
|
55
|
-
"@glion/
|
|
56
|
-
"@glion/
|
|
53
|
+
"@glion/annotate-profile-context": "0.15.2",
|
|
54
|
+
"@glion/check-readme": "0.15.2",
|
|
55
|
+
"@glion/builder": "0.15.2",
|
|
56
|
+
"@glion/testing": "0.15.2",
|
|
57
|
+
"@glion/tsconfig": "0.15.2",
|
|
58
|
+
"@glion/profiles": "0.15.2"
|
|
57
59
|
},
|
|
58
60
|
"engines": {
|
|
59
61
|
"node": ">=18"
|
|
@@ -62,8 +64,10 @@
|
|
|
62
64
|
"scripts": {
|
|
63
65
|
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
64
66
|
"check-types": "tsc --noEmit",
|
|
67
|
+
"check:readme": "glion-check-readme",
|
|
65
68
|
"test": "vitest run",
|
|
66
69
|
"test:coverage": "vitest run --coverage",
|
|
67
|
-
"test:watch": "vitest"
|
|
70
|
+
"test:watch": "vitest",
|
|
71
|
+
"publint": "publint --strict"
|
|
68
72
|
}
|
|
69
73
|
}
|