@rethinkhealth/hl7v2-parser 0.2.2 → 0.2.4

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 (42) hide show
  1. package/README.md +14 -8
  2. package/dist/index.d.ts +4 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +325 -534
  5. package/dist/index.js.map +1 -1
  6. package/dist/parser.d.ts +6 -13
  7. package/dist/parser.d.ts.map +1 -1
  8. package/dist/preprocessor.d.ts +26 -0
  9. package/dist/preprocessor.d.ts.map +1 -0
  10. package/dist/processor.d.ts +3 -5
  11. package/dist/processor.d.ts.map +1 -1
  12. package/dist/tokenizer.d.ts +18 -0
  13. package/dist/tokenizer.d.ts.map +1 -0
  14. package/dist/types.d.ts +29 -13
  15. package/dist/types.d.ts.map +1 -1
  16. package/dist/utils.d.ts +3 -0
  17. package/dist/utils.d.ts.map +1 -0
  18. package/package.json +6 -5
  19. package/dist/constants.d.ts +0 -11
  20. package/dist/constants.d.ts.map +0 -1
  21. package/dist/pipeline/core/message.d.ts +0 -16
  22. package/dist/pipeline/core/message.d.ts.map +0 -1
  23. package/dist/pipeline/core/parsers/component.d.ts +0 -13
  24. package/dist/pipeline/core/parsers/component.d.ts.map +0 -1
  25. package/dist/pipeline/core/parsers/field.d.ts +0 -13
  26. package/dist/pipeline/core/parsers/field.d.ts.map +0 -1
  27. package/dist/pipeline/core/parsers/segment-msh.d.ts +0 -14
  28. package/dist/pipeline/core/parsers/segment-msh.d.ts.map +0 -1
  29. package/dist/pipeline/core/parsers/segment.d.ts +0 -13
  30. package/dist/pipeline/core/parsers/segment.d.ts.map +0 -1
  31. package/dist/pipeline/core/parsers/subcomponent.d.ts +0 -10
  32. package/dist/pipeline/core/parsers/subcomponent.d.ts.map +0 -1
  33. package/dist/pipeline/core/registry.d.ts +0 -30
  34. package/dist/pipeline/core/registry.d.ts.map +0 -1
  35. package/dist/pipeline/index.d.ts +0 -10
  36. package/dist/pipeline/index.d.ts.map +0 -1
  37. package/dist/pipeline/interfaces.d.ts +0 -109
  38. package/dist/pipeline/interfaces.d.ts.map +0 -1
  39. package/dist/pipeline/utils/index.d.ts +0 -18
  40. package/dist/pipeline/utils/index.d.ts.map +0 -1
  41. package/dist/pipeline/validation/basic-validation.d.ts +0 -17
  42. package/dist/pipeline/validation/basic-validation.d.ts.map +0 -1
package/README.md CHANGED
@@ -8,6 +8,14 @@ This utility is a low level project. It’s used in [@rethinkhealth/hl7v2](../hl
8
8
 
9
9
  If you want to handle syntax trees manually, use this. For an easier time processing content, use the [@rethinkhealth/hl7v2](../hl7v2/) ecosystem instead.
10
10
 
11
+ ## Features
12
+
13
+ - **Speed-first**: pull-based tokenizer, single pass, minimal object allocations.
14
+ - **Spec-aware**: auto-detects delimiters from MSH-1 and MSH-2.
15
+ - **AST design**: outputs a unist-compatible tree for use in the HL7v2 unified ecosystem.
16
+ - **Composable**: works directly as a unified parser plugin or as a standalone function.
17
+ - **Streaming-friendly**: pull-based design is ready for streaming use cases.
18
+
11
19
  ## Install
12
20
 
13
21
  This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). In Node.js (version 16+), install with npm:
@@ -21,18 +29,16 @@ npm install @rethinkhealth/hl7v2-parser
21
29
  ### Basic Usage
22
30
 
23
31
  ```typescript
32
+ import { unified } from 'unified';
24
33
  import { hl7v2Parser } from '@rethinkhealth/hl7v2-parser';
25
34
 
26
- // Sample HL7v2 message
27
- const message = `MSH|^~\\&|SENDING_APP|SENDING_FAC|RECEIVING_APP|RECEIVING_FAC|20110613061611||ADT^A04|12345|P|2.3
28
- PID|1||123456||SMITH^JOHN^J||19800101|M|||123 MAIN ST^^ANYTOWN^ST^12345
29
- PV1|1|I|ICU^101^1|||DOCTOR123^SMITH^JOHN^MD`;
35
+ const message = `MSH|^~\\&|SENDING_APP|SENDING_FAC|...`;
30
36
 
31
- // Parse using the unified processor
32
- const processor = hl7v2Parser();
33
- const result = processor.parse(message);
37
+ const tree = unified()
38
+ .use(hl7v2Parser)
39
+ .parse(message);
34
40
 
35
- console.log(`Parsed ${result.children?.length} segments`);
41
+ console.log(tree);
36
42
  ```
37
43
 
38
44
  ## Contributing
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- export { default as hl7v2Parser } from './processor';
1
+ export { default as hl7v2Parser } from './parser';
2
+ export * from './preprocessor';
3
+ export { parseHL7v2FromIterator } from './processor';
4
+ export * from './tokenizer';
2
5
  export * from './types';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}