@cosyte/x12 0.0.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/CHANGELOG.md +1067 -0
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/index.cjs +9777 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12482 -0
- package/dist/index.d.ts +12482 -0
- package/dist/index.mjs +9595 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +103 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cosyte
|
|
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/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @cosyte/x12
|
|
2
|
+
|
|
3
|
+
> Parse real-world, vendor-quirky ASC X12 healthcare EDI — 835 remits, 837 claims, 270/271 eligibility, 276/277 status, 278, 820, 834, 999/TA1 — and pull the fields you need without reading a TR3.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@cosyte/x12)
|
|
6
|
+
[](https://github.com/cosyte/x12/actions/workflows/ci.yml)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
|
|
10
|
+
A developer-focused ASC X12 EDI parser and utility library for Node.js and TypeScript — the payer-side sibling of [`@cosyte/hl7`](https://github.com/cosyte/hl7). Zero runtime dependencies, dual ESM/CJS, strict types. Lenient on the way in (vendor deviations become warnings, not exceptions), spec-clean on the way out.
|
|
11
|
+
|
|
12
|
+
> **Status:** pre-alpha (`0.0.x`, not yet published to npm). The full v1 **read** scope (270/271, 276/277/277CA, 278, 820, 834, 835, 837P/I/D, 999, TA1) and **emit** scope (per-transaction domain builders + a general serializer) are complete and hardened; the first npm publish is gated on the coordinated public launch.
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# pnpm (recommended) — also works with: npm install @cosyte/x12 | yarn add @cosyte/x12
|
|
18
|
+
pnpm add @cosyte/x12
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Parse an 835 remittance advice and read the money — three lines of useful output, no TR3 lookup:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { parseX12, get835 } from "@cosyte/x12";
|
|
25
|
+
|
|
26
|
+
const ix = parseX12(rawEdi); // never throws except on 4 structural fatals
|
|
27
|
+
const tx = ix.groups[0]?.transactions.find((t) => t.st.elements[1] === "835");
|
|
28
|
+
const remit = tx ? get835(ix.delimiters, tx) : undefined;
|
|
29
|
+
|
|
30
|
+
remit?.payment.totalActualPayment.toString(); // "450.00" — BigInt-exact, never a float
|
|
31
|
+
remit?.claims[0]?.patientControlNumber; // "PT-ACCT-001" — your account number, echoed back
|
|
32
|
+
remit?.claims[0]?.serviceLines[0]?.adjustments[0]?.reasonCode; // "1" — CARC (why it was adjusted)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
That's the pitch: no schema upload, no spec knowledge. The parser accepts vendor-quirky input by default and flags what it tolerated with stable warning codes; you reach for strict mode, dot-paths, profiles, or the emit builders when you want them.
|
|
36
|
+
|
|
37
|
+
## What's inside
|
|
38
|
+
|
|
39
|
+
- **Every v1 HIPAA transaction, read + emit** — 270/271, 276/277/277CA, 278, 820, 834, 835, 837P/I/D, plus 999/TA1 acknowledgments. Per-transaction helpers (`get835`, `get837Claims`, `get271Eligibility`, …) and domain builders (`build835`, `build837P/I/D`, `build271`, …).
|
|
40
|
+
- **Postel's Law** — a lenient parser (deviations → warnings with a stable code + positional context) and a strict, spec-clean serializer with recomputed envelope counts. Only **4 structural failures** are ever fatal.
|
|
41
|
+
- **Money is exact** — every monetary/percent/quantity field decodes as `X12Decimal` (string-backed, BigInt arithmetic). The library **never `parseFloat`s** an EDI amount.
|
|
42
|
+
- **Safety-critical fidelity** — TRN reassociation traces, 835 balance invariants, 837 HL hierarchy integrity, 834 maintenance types, and 278 certification actions are preserved **verbatim** and never inferred; ambiguity yields a warning or a typed refusal, never a confident wrong answer.
|
|
43
|
+
- **PHI-disciplined** — synthetic-only fixtures, a PHI commit-gate, and warnings/errors that carry codes and positions but never patient data.
|
|
44
|
+
|
|
45
|
+
See the [**Cookbook**](./docs-content/cookbook.md) for task-oriented recipes (post an 835, route 277CA rejections, round-trip a 271, walk an 837, read a 999) and [**KNOWN-LIMITATIONS.md**](./KNOWN-LIMITATIONS.md) for the honest do-not-over-trust list.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT — see [LICENSE](./LICENSE).
|
|
50
|
+
|
|
51
|
+
Built by [Cosyte](https://cosyte.com).
|