@rethinkhealth/hl7v2-ast 0.4.2 → 0.5.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/README.md +9 -9
- package/index.d.ts +12 -36
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -14,8 +14,8 @@ The specification follows the [Unist](https://github.com/syntax-tree/unist) mode
|
|
|
14
14
|
|
|
15
15
|
### Where this specification fits
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
- **hl7v2-ast** extends [unist](https://github.com/syntax-tree/unist) with HL7-specific node types.
|
|
18
|
+
- Integrates with editor tooling, validators, and transformers.
|
|
19
19
|
|
|
20
20
|
## Types
|
|
21
21
|
|
|
@@ -40,9 +40,9 @@ root
|
|
|
40
40
|
└── subcomponent (&)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
- Every **field** always contains one or more `field-repetition` nodes, even if there is no `~`.
|
|
44
|
+
- Every **component** always contains one or more `subcomponent` nodes, even if there is no `&`.
|
|
45
|
+
- Only `subcomponent` nodes carry `value`.
|
|
46
46
|
|
|
47
47
|
## Nodes (abstract)
|
|
48
48
|
|
|
@@ -183,9 +183,9 @@ type HL7v2Content =
|
|
|
183
183
|
|
|
184
184
|
The AST is designed for:
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
- **Validation plugins** (segment rules, field presence)
|
|
187
|
+
- **Annotation plugins** (map to FHIR, metadata)
|
|
188
|
+
- **Transformers** (to JSON, FHIR, XML)
|
|
189
189
|
|
|
190
190
|
## Contributing
|
|
191
191
|
|
|
@@ -209,4 +209,4 @@ This program is licensed to you under the terms of the [MIT License](https://ope
|
|
|
209
209
|
|
|
210
210
|
[github-code-of-conduct]: https://github.com/rethinkhealth/hl7v2/blob/main/CODE_OF_CONDUCT.md
|
|
211
211
|
[github-license]: https://github.com/rethinkhealth/hl7v2/blob/main/LICENSE
|
|
212
|
-
[github-contributing]: https://github.com/rethinkhealth/hl7v2/blob/main/CONTRIBUTING.md
|
|
212
|
+
[github-contributing]: https://github.com/rethinkhealth/hl7v2/blob/main/CONTRIBUTING.md
|
package/index.d.ts
CHANGED
|
@@ -8,14 +8,14 @@ import type {
|
|
|
8
8
|
/**
|
|
9
9
|
* HL7v2 Delimiters type
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export interface Delimiters {
|
|
12
12
|
field: string;
|
|
13
13
|
component: string;
|
|
14
14
|
subcomponent: string;
|
|
15
15
|
repetition: string;
|
|
16
16
|
escape: string;
|
|
17
17
|
segment: string;
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
// ## Abstract nodes
|
|
21
21
|
|
|
@@ -125,28 +125,16 @@ export type RootContent = RootContentMap[keyof RootContentMap];
|
|
|
125
125
|
* > **Note**: {@link Root} does not need to be an entire document.
|
|
126
126
|
* > it can also be a fragment.
|
|
127
127
|
*
|
|
128
|
-
* This interface can be augmented to register custom node types:
|
|
129
|
-
*
|
|
130
|
-
* ```ts
|
|
131
|
-
* declare module 'mdast' {
|
|
132
|
-
* interface RootContentMap {
|
|
133
|
-
* // Allow using toml nodes defined by `remark-frontmatter`.
|
|
134
|
-
* toml: TOML;
|
|
135
|
-
* }
|
|
136
|
-
* }
|
|
137
|
-
* ```
|
|
138
|
-
*
|
|
139
128
|
* For a union of all {@link Root} children, see {@link RootContent}.
|
|
140
129
|
*/
|
|
141
|
-
export
|
|
142
|
-
segmentHeader: SegmentHeader;
|
|
130
|
+
export interface RootContentMap {
|
|
143
131
|
segment: Segment;
|
|
144
132
|
group: Group;
|
|
145
133
|
field: Field;
|
|
146
134
|
fieldRepetition: FieldRepetition;
|
|
147
135
|
component: Component;
|
|
148
136
|
subcomponent: Subcomponent;
|
|
149
|
-
}
|
|
137
|
+
}
|
|
150
138
|
|
|
151
139
|
// ## Concrete nodes
|
|
152
140
|
|
|
@@ -182,11 +170,13 @@ export interface Segment extends Parent {
|
|
|
182
170
|
*/
|
|
183
171
|
type: "segment";
|
|
184
172
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* `children[0]` is always a {@link SegmentHeader}.
|
|
173
|
+
* Name identifier for the segment (e.g., "MSH", "PID").
|
|
188
174
|
*/
|
|
189
|
-
|
|
175
|
+
name: string;
|
|
176
|
+
/**
|
|
177
|
+
* Children of segment — only {@link Field} nodes.
|
|
178
|
+
*/
|
|
179
|
+
children: Field[];
|
|
190
180
|
/**
|
|
191
181
|
* Data associated with the segment.
|
|
192
182
|
*/
|
|
@@ -198,20 +188,6 @@ export interface Segment extends Parent {
|
|
|
198
188
|
*/
|
|
199
189
|
export interface SegmentData extends Data {}
|
|
200
190
|
|
|
201
|
-
/**
|
|
202
|
-
* HL7v2 segment header literal.
|
|
203
|
-
*
|
|
204
|
-
* This node always appears as the first child of a {@link Segment}. Consumers
|
|
205
|
-
* should treat `segment.children[0]` as the canonical location of the
|
|
206
|
-
* three-character HL7 identifier (for example, "MSH" or "PID").
|
|
207
|
-
*/
|
|
208
|
-
export interface SegmentHeader extends Literal {
|
|
209
|
-
/**
|
|
210
|
-
* Node type of HL7v2 segment header.
|
|
211
|
-
*/
|
|
212
|
-
type: "segment-header";
|
|
213
|
-
}
|
|
214
|
-
|
|
215
191
|
/**
|
|
216
192
|
* HL7v2 group.
|
|
217
193
|
*
|
|
@@ -230,11 +206,11 @@ export interface Group extends Parent {
|
|
|
230
206
|
* Name identifier for the group (e.g., "ORDER", "OBSERVATION").
|
|
231
207
|
* Used for querying specific groups in nested structures.
|
|
232
208
|
*/
|
|
233
|
-
name
|
|
209
|
+
name: string;
|
|
234
210
|
/**
|
|
235
211
|
* Children of group.
|
|
236
212
|
*/
|
|
237
|
-
children:
|
|
213
|
+
children: (Segment | Group)[];
|
|
238
214
|
/**
|
|
239
215
|
* Data associated with the mdast block quote.
|
|
240
216
|
*/
|
package/package.json
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rethinkhealth/hl7v2-ast",
|
|
3
|
+
"version": "0.5.0",
|
|
3
4
|
"description": "HL7v2 is a specification for representing HL7v2 messages as an abstract syntax tree. It implements the unist spec.",
|
|
4
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bin",
|
|
7
|
+
"cli",
|
|
8
|
+
"hl7v2",
|
|
9
|
+
"hl7v2ast",
|
|
10
|
+
"unified"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://www.rethinkhealth.io/hl7v2/docs",
|
|
5
13
|
"license": "MIT",
|
|
6
14
|
"author": {
|
|
7
15
|
"name": "Melek Somai",
|
|
8
16
|
"email": "melek@rethinkhealth.io"
|
|
9
17
|
},
|
|
10
|
-
"
|
|
18
|
+
"repository": "rethinkhealth/hl7v2.git",
|
|
11
19
|
"files": [
|
|
12
20
|
"index.d.ts"
|
|
13
21
|
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
14
26
|
"devDependencies": {
|
|
15
27
|
"@types/node": "24.10.1",
|
|
16
28
|
"@types/unist": "^3.0.3",
|
|
17
|
-
"@vitest/coverage-v8": "4.0.
|
|
29
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
18
30
|
"tsup": "8.5.1",
|
|
19
31
|
"typescript": "^5.9.3",
|
|
20
32
|
"unified": "^11.0.5",
|
|
@@ -25,19 +37,7 @@
|
|
|
25
37
|
"engines": {
|
|
26
38
|
"node": ">=18"
|
|
27
39
|
},
|
|
28
|
-
"repository": "rethinkhealth/hl7v2.git",
|
|
29
|
-
"homepage": "https://www.rethinkhealth.io/hl7v2/docs",
|
|
30
|
-
"keywords": [
|
|
31
|
-
"bin",
|
|
32
|
-
"cli",
|
|
33
|
-
"hl7v2",
|
|
34
|
-
"hl7v2ast",
|
|
35
|
-
"unified"
|
|
36
|
-
],
|
|
37
40
|
"packageManager": "pnpm@10.14.0",
|
|
38
|
-
"publishConfig": {
|
|
39
|
-
"access": "public"
|
|
40
|
-
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"check-types": "tsc ./index.d.ts --noEmit"
|
|
43
43
|
}
|