X12 271 · 005010X279A1
X12 271 eligibility responses, explained, and a TypeScript parser to read them.
import { readFile } from 'node:fs/promises';
import { readX12 } from '@ediocracy/parser';
import { read271s } from '@ediocracy/parser/271';
const text = await readFile('response.x12', 'utf8');
for (const { response } of read271s(readX12(text))) {
for (const subscriber of response.subscribers) {
const lastName = subscriber.name?.element(3);
const firstName = subscriber.name?.element(4);
console.log(`${firstName} ${lastName}: ${subscriber.benefits.length} benefits`);
}
} One line from a 271. Every segment starts with an ID, then elements separated by *, then ends with ~.
Node.js 26 or later · ESM only · not yet published to npm