@haste-health/hl7v2-parsing 0.127.0 → 0.127.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 +48 -1
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1 +1,48 @@
1
- # hl7v2-parsing
1
+ # @haste-health/hl7v2-parsing
2
+
3
+ Parses an HL7 v2 message (ADT, ORU, ORM, ...) into plain JavaScript data. The encoding characters are read from the MSH segment, so any field, component, repetition and subcomponent separators work. The result maps each segment name to its fields, nesting arrays only where the message has repetitions, components or subcomponents.
4
+
5
+ The Haste Health server does the same job in Rust with [haste-hl7v2](https://crates.io/crates/haste-hl7v2) behind its `$hl7v2-parse` operation and MLLP receiver. This package is for TypeScript code, in Node or the browser.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @haste-health/hl7v2-parsing
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import parseHl7V2Message from "@haste-health/hl7v2-parsing";
17
+
18
+ const message = parseHl7V2Message(
19
+ [
20
+ "MSH|^~\\&|SIMHOSP|SFAC|RAPP|RFAC|20200508130643||ADT^A01|5|T|2.3",
21
+ "PID|1|2590157853^^^SIMULATOR MRN^MRN|2590157853^^^SIMULATOR MRN^MRN~2478684691^^^NHSNBR^NHSNMBR||Esterkin^AKI Scenario 6^^^Miss",
22
+ ].join("\r"),
23
+ );
24
+
25
+ message.MSH[8]; // ["ADT", "A01"] MSH-9, message type
26
+ message.PID[4][0]; // "Esterkin" PID-5.1, family name
27
+ message.PID[2]; // [[...], [...]] PID-3 repeats: one array per identifier
28
+ message.PID[0]; // "1" PID-1, a plain string
29
+ ```
30
+
31
+ Indexes are the HL7 field numbers minus one: `PID[4]` is PID-5, and in MSH `MSH[0]` is the field separator (MSH-1) and `MSH[1]` the encoding characters (MSH-2). A field is a string when it has one value, an array of components when it has several, and an array of repetitions (each a string or component array) when the repetition separator appears. Subcomponents nest one level further.
32
+
33
+ Exported types: `Hl7V2Message`, `Hl7V2Segment`, `Hl7V2Field`, `Hl7V2Component`.
34
+
35
+ ## Limitations
36
+
37
+ - Segments are keyed by name, so a message with several segments of the same name (several `OBX` or `NK1`, say) keeps only the last one.
38
+ - Batch messages (`FHS`/`BHS`) are rejected, and a message that does not start with `MSH` throws an `OperationError` from [`@haste-health/operation-outcomes`](https://www.npmjs.com/package/@haste-health/operation-outcomes).
39
+ - Escape sequences (`\F\`, `\S\`, ...) are left as written.
40
+
41
+ ## Links
42
+
43
+ - [API reference](https://typescript.haste.health/modules/_haste-health_hl7v2-parsing.html)
44
+ - [Source](https://github.com/HasteHealth/HasteHealth/tree/main/frontend/packages/hl7v2-parsing)
45
+ - [HL7v2 ingestion guide](https://haste.health/docs/guides/hl7v2) and the [TypeScript SDK overview](https://haste.health/docs/api/sdks/typescript)
46
+ - Rust equivalent: [haste-hl7v2](https://crates.io/crates/haste-hl7v2)
47
+
48
+ Part of [Haste Health](https://haste.health), licensed under [Apache-2.0](https://github.com/HasteHealth/HasteHealth/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haste-health/hl7v2-parsing",
3
- "version": "0.127.0",
3
+ "version": "0.127.2",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "description": "Haste Health Hl7V2 Parsing library.",
@@ -15,7 +15,7 @@
15
15
  "lib/**"
16
16
  ],
17
17
  "dependencies": {
18
- "@haste-health/operation-outcomes": "^0.127.0"
18
+ "@haste-health/operation-outcomes": "^0.127.2"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "tsc",