Node.js library
node-x12
A general ASC X12 parser, generator, query engine and mapper for Node.js, MIT-licensed, with stream support. Its latest npm release dates from April 2022.
X12
@cosyte/x12 decodes the HIPAA 005010 transaction sets into typed models, keeps every amount in exact decimal arithmetic, and reports each vendor deviation it tolerated with a stable code instead of failing or guessing.
npm install @cosyte/x12Need it integrated? Talk to us.
The standard
@cosyte/x12
Reading an X12 transaction correctly normally means buying its TR3 implementation guide and hand-mapping element positions no compiler checks. This library does that mapping once, with tests, for the engineer who has one 835 to post or one 271 to answer.
import { parseX12, get835 } from "@cosyte/x12";
const raw = `ISA*00* *00* *ZZ*MEDICARE *ZZ*SUBMITTER *260601*1200*^*00501*000000001*0*P*:~
GS*HP*MEDICARE*SUBMITTER*20260601*1200*1*X*005010X221A1~
ST*835*0001~
BPR*I*450.00*C*ACH*CCP*01*123456789*DA*987654321*1512345678**01*111111111*DA*222222222*20260601~
TRN*1*0012345*1512345678~
DTM*405*20260601~
N1*PR*MEDICARE PART A~
N3*123 PAYER WAY~
N4*BALTIMORE*MD*21244~
PER*BL*JANE COORDINATOR*TE*5551234567~
N1*PE*SAMPLE CLINIC INC~
N3*456 PROVIDER LN~
N4*CLEVELAND*OH*44113~
REF*TJ*123456789~
LX*1~
CLP*PT-ACCT-001*1*500.00*450.00*50.00*MC*PAYER-CLAIM-001*11*1~
NM1*QC*1*PATIENT*TEST*A***MI*MEMBER001~
NM1*82*2*RENDERING PROVIDER INC*****XX*1234567890~
DTM*232*20260501~
DTM*233*20260501~
SVC*HC:99213*500.00*450.00**1~
DTM*472*20260501~
CAS*PR*1*50.00~
REF*6R*LINE-CTRL-001~
SE*23*0001~
GE*1*1~
IEA*1*000000001~`;
const ix = parseX12(raw);
const tx = ix.groups[0]?.transactions.find((t) => t.st.elements[1] === "835");
if (tx === undefined) throw new Error("no 835 in this interchange");
const remit = get835(ix.delimiters, tx);
if (remit === undefined) throw new Error("not an 835");
// The payment, the claim's split, and who owes the difference and why.
const claim = remit.claims[0];
const adjustment = claim?.serviceLines[0]?.adjustments[0];
console.log("paid", remit.payment.totalActualPayment?.toString(), "by", remit.payment.method);
console.log("claim", claim?.patientControlNumber, "charged", claim?.totalChargeAmount?.toString());
console.log("patient owes", claim?.patientResponsibilityAmount?.toString());
console.log("reason", adjustment?.groupCode, adjustment?.reasonCode, adjustment?.reasonDescription);
console.log("warnings", ix.warnings.length);
// The values printed above, which the test suite asserts on every run:
remit.payment.totalActualPayment?.toString(); // => "450.00"
claim?.totalChargeAmount?.toString(); // => "500.00"
claim?.patientResponsibilityAmount?.toString(); // => "50.00"
adjustment?.groupCode; // => "PR"
adjustment?.reasonCode; // => "1"
adjustment?.reasonDescription; // => "Deductible Amount"
ix.warnings; // => []From the @cosyte/x12 README on GitHub, verbatim. Every value in it is synthetic.
Limits
Its README states what is not covered, deliberately:
Alternatives
Each description comes from the project’s own documentation or listing, linked below.
Node.js library
A general ASC X12 parser, generator, query engine and mapper for Node.js, MIT-licensed, with stream support. Its latest npm release dates from April 2022.
Node.js library
An MIT-licensed X12 parser built on Node.js streams, for very large files, with no production dependencies.
Python library
A BSD-licensed HIPAA X12 parser, validator and converter for Python. It validates a file against a representation of the X12 implementation guidelines and can create a 999 acknowledgement for 5010.
EDI toolkit
A toolkit for translating EDI inside your own applications, covering ten EDI standards, from X12 and HIPAA to EDIFACT, HL7 and NCPDP.
Clearinghouse
A clearinghouse you integrate with through APIs. A clearinghouse reaches payers; a library such as @cosyte/x12 works with the transactions inside your own code but connects you to no one.
Works with
It is free and MIT-licensed. If it saves you a day, a star on GitHub helps other engineers find it.
Need it integrated? Talk to us, or see what our integration services cover.