{"slug": "show-hn-x12sdk-read-check-and-generate-hipaa-x12-claim-files-in-python", "title": "Show HN: X12sdk – read, check and generate HIPAA X12 claim files in Python", "summary": "A developer released x12sdk, an open-source Python library that parses, validates and generates HIPAA X12 healthcare transactions — claims (837P, 837I, 837D), remittances (835), eligibility (270/271), claim status (276/277) and enrollment (834) — into Pydantic v2 models checked against implementation-guide rules and written back byte for byte. The library ships with an MCP server for AI assistants, a browser playground that runs locally so files are never uploaded, and a synthetic generator that reproduces identical bytes from a seed, alongside a published dataset of 30,000 claims with their remittances, since no shareable corpus of real X12 exists because every claim carries protected health information.", "body_md": "Read, check and generate HIPAA X12 health care transactions in Python: claims (837P, 837I, 837D), remittances (835), eligibility (270/271), claim status (276/277) and enrollment (834).\n\n**[Try it in your browser](https://huggingface.co/spaces/owgreen-dev/x12sdk-playground)**:\ncheck a file and see where it breaks, turn an 835 into a CSV, or generate\nsample files, with nothing to install. The page runs x12sdk in your browser\ntab, so your file is never uploaded. Guides and the API reference are at\n**[owgreen-dev.github.io/x12sdk](https://owgreen-dev.github.io/x12sdk/)**.\n\n- **835 or 837 to a spreadsheet:**`x12sdk-table remit.835 -o remit.csv` , one\nrow per service line.\n- **Sample files with no PHI:** realistic synthetic claims and remittances\nfrom a seed, or a[ready-made dataset](https://huggingface.co/datasets/owgreen-dev/x12sdk) of 30,000 claims with their remittances.\n- **Every transaction typed and checked:** each file parses into[Pydantic v2](https://docs.pydantic.dev/) models validated against the\nimplementation guide rules, and writes back out byte for byte.\n- **For AI assistants:** an[MCP server](#ai-assistants-mcp) that reads,\nchecks and generates X12 through the library.\n\nEverything runs locally; no file is uploaded anywhere. Building a service on\nit? Read [Handling untrusted input](https://owgreen-dev.github.io/x12sdk/security.html)\n(pass `allow_paths=False` for files you receive).\n\n```\npip install x12sdk\nx12sdk-table remit.835 -o remit.csv\npython\nfrom x12sdk.tables import read_lines, to_dataframe\n\nrows = read_lines(\"remit.835\")       # list of dicts, one per service line\nframe = to_dataframe(\"remit.835\")    # pandas: pip install \"x12sdk[pandas]\"\n```\n\nAn 835 becomes one row per paid service line: the payment, the claim, the\npatient, the procedure, what was charged and paid, and the adjustments totalled\nby group (`co_amount`, `pr_amount`, `oa_amount`, `pi_amount`, `cr_amount`)\nalongside every `GROUP-REASON` code. An 837 (professional, institutional or\ndental) becomes one row per billed line, with diagnoses, revenue codes and\nteeth where they apply. Claim rows and remittance rows join on\n`patient_control_number` (CLM01 = CLP01). The columns are fixed\n(`x12sdk.tables.REMITTANCE_COLUMNS`, `CLAIM_COLUMNS`), so a pipeline built on\nthem does not move. For one row per adjustment instead, see\n[Denial analytics](#denial-analytics).\n\nThere is no shareable corpus of real X12: every claim and remittance carries protected health information. x12sdk generates valid files from a seed instead:\n\n```\nx12sdk-generate 835 --seed 7 --claims 2 --payer-name \"EXAMPLE HEALTH PLAN\" --payee-name \"EXAMPLE MEDICAL GROUP\"\n```\n\nor, from Python:\n\n``` python\nfrom x12sdk.generate import generate_835\n\nprint(generate_835(seed=7, claims=2, payer_name=\"EXAMPLE HEALTH PLAN\",\n                   payee_name=\"EXAMPLE MEDICAL GROUP\"))\n```\n\nEither way:\n\n```\nISA*00*          *00*          *30*SYNTHETICPAYER *30*SYNTHETICPROV  *260101*1200*^*00501*000000001*0*T*:~\nGS*HP*SYNTHETICPAYER*SYNTHETICPROV*20260101*1200*1*X*005010X221A1~\nST*835*0001~\nBPR*I*1734.53*C*CHK~\nTRN*1*0922121677*1661318600~\nN1*PR*EXAMPLE HEALTH PLAN~\nN3*9265 MAIN AVE~\nN4*FRANKLIN*IL*85642~\nN1*PE*EXAMPLE MEDICAL GROUP*XX*1260181593~\nLX*1~\nCLP*PCN000001*1*1797.81*1258.47**CH*148194179472~\nNM1*QC*1*ANDERSON*LINDA****MI*X410965605~\nSVC*HC:71046*1797.81*1258.47**1~\nCAS*CO*45*539.34~\n...\nPLB*1260181593*20251231*L6*-8.63~\nSE*20*0001~\nGE*1*1~\nIEA*1*000000001~\n```\n\nThe same seed reproduces the same bytes. Every file parses through the\nlibrary's own validators, round-trips byte for byte, and carries both the\nsubscriber and the dependent branch of the hierarchy, the place real code\nloses claims. All nine supported transaction sets generate, a claim can be\ngenerated together with the remittance that answers it, and scenarios can be\ndescribed exactly, from a denial pattern to a multi-employer enrollment. See\n[Generating synthetic files](#generating-synthetic-files), or download the\n[dataset](https://huggingface.co/datasets/owgreen-dev/x12sdk).\n\n```\nx12sdk-validate claims.837 remit.835\nclaims.837: valid — 1 transaction (837, 005010X222A2), 12 claims\nremit.835: INVALID\n  loop 2000A #1 › loop 2000B #1 › loop 2300 #1: Claim Amount 9161.47 != Service Line Total 161.47\n```\n\nIt exits 1 if any file is invalid, so it can gate a build; `--json` prints\none record per file. A claim whose total does not match its lines, a missing\nrequired segment, an unknown code value, a wrong segment count, a hierarchy\nwhose parent ids do not line up: each is reported with where it is, without\nechoing the file's content. From Python, `x12sdk.validation.check(path)`\nreturns the same result.\n\n``` python\nfrom x12sdk.matching import match_claims, match_rows\n\nfor match in match_claims(\"claims.837\", [\"remit-1.835\", \"remit-2.835\"]):\n    print(match.patient_control_number, match.outcome, match.billed, match.paid)\n```\n\nClaims and payments join on the patient control number (CLM01 = CLP01).\nEvery payment for a number is kept (a payment, a reversal, a corrected\npayment), and nothing is dropped: a claim no remittance answers is\n`no remittance`, a payment for a claim you did not give is `no claim`.\n`match_rows` gives the same as flat rows for a CSV or a DataFrame.\n\nFiles are read one transaction at a time; a transaction is validated as a\nwhole, so it is held in memory as a whole. From `python scripts/benchmark.py`\non an Apple-silicon Mac, Python 3.12, one transaction per file:\n\n| File | Claims | Size | Read and validate | Peak memory | \n|---|---|---|---|---|\n| 835 | 10,000 | 1.6 MB | 1.2 s (about 8,200 claims/s) | 203 MB | \n| 837P | 10,000 | 4.4 MB | 4.7 s (about 2,100 claims/s) | 536 MB | \n\nMemory grows with the size of the largest transaction, not of the file; a file of many moderate transactions streams in roughly constant memory. Run the script on your own machine for your own numbers.\n\nx12sdk is the maintained continuation of\n[LinuxForHealth x12](https://github.com/LinuxForHealth/x12), which stopped at\n0.57.0 in June 2022. It runs on **Pydantic v2 and Python 3.10–3.14**.\n\nSupported transaction sets:\n\n| Set | Implementation | What it is | Parse | Generate | Accessors | \n|---|---|---|---|---|---|\n| 837P | 005010X222A2 | Professional claim | yes | `generate_837p` | `claims()` ,`subscribers()` | \n| 837I | 005010X223A3 | Institutional claim | yes | `generate_837i` | `claims()` ,`subscribers()` | \n| 837D | 005010X224A2 | Dental claim | yes | `generate_837d` | `claims()` ,`subscribers()` | \n| 835 | 005010X221A1 | Claim payment / remittance advice | yes | `generate_835` | `claims()` | \n| 834 | 005010X220A1 | Benefit enrollment and maintenance | yes | `generate_834` |  | \n| 270 / 271 | 005010X279A1 | Eligibility inquiry / response | yes | `generate_270` /`generate_271` | `members()` | \n| 276 / 277 | 005010X212 | Claim status inquiry / response | yes | `generate_276` /`generate_277` | `claims()` | \n\nEvery transaction is parsed into a validated Pydantic model and can be serialized back to X12; the test suite asserts that round trip reproduces each sample file byte for byte.\n\n```\npip install x12sdk\n```\n\nFrom source:\n\n```\ngit clone https://github.com/owgreen-dev/x12sdk\ncd x12sdk\npython3 -m venv .venv && source .venv/bin/activate\npip install --upgrade pip\npip install -e .\n```\n\nThe `x12sdk.io` module streams either raw segments or validated transaction\nmodels from a file.\n\nStream segments (each segment becomes its name plus a list of fields):\n\n``` python\nfrom x12sdk.io import X12SegmentReader\n\nwith X12SegmentReader(\"/home/edi/270.x12\") as r:\n    for segment_name, segment_fields in r.segments():\n        print(segment_name, segment_fields)\n```\n\nStream models (the payload is validated; one model per transaction set):\n\n``` python\nfrom x12sdk.io import X12ModelReader\n\nwith X12ModelReader(\"/home/edi/270.x12\") as r:\n    for model in r.models():\n        print(model.header)   # common attributes: header, footer\n        print(model.footer)\n        model.x12()           # serialize back to X12\n```\n\nThe models mirror the X12 loop hierarchy, so a claim is several levels down.\nOn an 837 it is down one of *two* paths, because a claim sits under the\nsubscriber when the patient is the subscriber and under a dependent when they\nare not:\n\n```\nloop_2000a[i].loop_2000b[j].loop_2300[k]                  patient = subscriber\nloop_2000a[i].loop_2000b[j].loop_2000c[l].loop_2300[k]    patient = dependent\n```\n\nBoth are ordinary. Code written against one runs happily on a file that uses\nthe other and reports no claims at all, so `claims()` walks both and yields a\nflat record. It is a generator, so a large file is never materialized.\n\n```\nfor claim in model.claims():\n    print(claim.patient_control_number, claim.charge, claim.patient_name)\n```\n\nEach record carries the claim plus the context you would otherwise re-derive:\n`billing_provider`, `subscriber`, `payer`, `patient`, `is_dependent` and\n`relationship`. `patient` already points at whoever was treated, so you never\nneed to know which branch the claim came from. `subscribers()` yields the\nsubscribers and their dependents.\n\n`claims()` on an 835 yields the claim payments, each with `charge`, `paid`,\n`status`, `adjustments`, `service_lines` and the LX `header_number`.\n\nThe eligibility and claim status pairs branch the same way, so they have\naccessors too. `members()` on a 270 or 271 yields whoever the transaction is\nabout, with their benefits; `claims()` on a 276 or 277 yields the tracked\nclaims. Both hide the subscriber and dependent branch the same way `claims()`\ndoes on an 837:\n\n```\nfor member in eligibility.members():\n    print(member.name, member.is_dependent, member.service_type_codes)\n\nfor claim in status.claims():\n    print(claim.trace_number, claim.charge, claim.paid)\n```\n\nA tracked claim reads its charge from AMT on an inquiry and from STC on a response, so the caller does not have to know which it is holding.\n\n```\nx12sdk --help\nusage: x12sdk [-h] [-s | -m] [-x] [-p] [-d] file\n\nThe x12sdk CLI parses and validates X12 messages.\nMessages are returned in JSON format in either a segment or transactional format.\n\npositional arguments:\n  file              The path to a ASC X12 file\n\noptions:\n  -h, --help        show this help message and exit\n  -s, --segment     Returns X12 segments\n  -m, --model       Returns X12 models\n  -x, --exclude     Exclude fields set to None in model output\n  -p, --pretty      Pretty print output\n  -d, --delimiters  Include X12 delimiters in output (model mode only)\nx12sdk -s -p demo-file/demo.270   # segments\nx12sdk -m -p demo-file/demo.270   # models\n```\n\n`x12sdk-generate` is the shell form of [`x12sdk.generate`](#generating-synthetic-files):\none subcommand per transaction set, every option a keyword argument of the\nmatching `generate_*` function, so the command and the library call produce the\nsame bytes.\n\n```\nx12sdk-generate --help\nusage: x12sdk-generate [-h] [--version] SET ...\n\npositional arguments:\n  SET         which transaction set to generate\n    835       claim payment / remittance advice\n    837p      professional claim\n    837i      institutional claim\n    837d      dental claim\n    834       benefit enrollment and maintenance\n    270       eligibility inquiry\n    271       eligibility response\n    276       claim status inquiry\n    277       claim status response\nx12sdk-generate 835 --seed 7 --claims 2                     # to stdout\nx12sdk-generate 837p --seed 7 --claims 25 --dependent-rate 0.5 --out claims.837\nx12sdk-generate 837d --claims 10 --payer-name \"EXAMPLE DENTAL PLAN\"\nx12sdk-generate 834 --enrollees 10 --sponsor-name \"EXAMPLE EMPLOYER\"\nx12sdk-generate 270 --members 3 -o inquiry.270 && x12sdk-generate 271 --members 3 -o response.271\nx12sdk-generate 835 --claims 10 --provider-adjustments 2   # two PLB adjustments; 0 for none\n```\n\nThe count option is named for what the set carries (`--claims`, `--enrollees`,\n`--members`, `--patients`); `-n` works for all of them.\n\nThe transaction models cover ST through SE. `write_transactions` adds the\ninterchange and functional group envelopes and keeps the control numbers\nconsistent, so you get a file a trading partner would accept.\n\n``` python\nfrom x12sdk.io import X12ModelReader, write_transactions\n\nwith X12ModelReader(\"in.835\") as reader:\n    transactions = list(reader.models())\n\nout = write_transactions(transactions, sender_id=\"SENDERID\", receiver_id=\"RECEIVERID\")\n```\n\n`X12ModelWriter` is the same thing as a context manager, the mirror image of\nthe reader: write models into it and the interchange is assembled when the\nblock exits. If the block raises, nothing is written.\n\n``` python\nfrom x12sdk.io import X12ModelReader, X12ModelWriter\n\nwith X12ModelReader(\"in.835\") as reader, X12ModelWriter(\n    \"out.835\", sender_id=\"SENDERID\", receiver_id=\"RECEIVERID\"\n) as writer:\n    for model in reader.models():\n        if model.header.st_segment.transaction_set_control_number != \"0003\":\n            writer.write(model)   # drop one transaction, keep the rest\n```\n\nThe destination can be a path, an open text stream, or nothing at all, in\nwhich case the result is on `writer.interchange` after the block.\n\nReal claims and remittances contain PHI, and there is no public X12 corpus to\ntest against. `x12sdk.generate` builds valid transactions from the same models\nthe parser produces, so your test data is guaranteed synthetic.\n\n``` python\nfrom x12sdk.generate import generate_835\n\nremittance = generate_835(seed=7, claims=25)   # a complete file, envelope included\n```\n\nThe same seed always produces the same bytes, and generation never touches the\nglobal random state, so it is safe inside someone else's test suite. The same\ncalls are available from the shell as [`x12sdk-generate`](#cli).\n\nTo build a specific scenario, describe it:\n\n``` python\nfrom x12sdk.generate import ClaimSpec, ServiceLineSpec, denial, generate_835\n\nspec = [\n    ClaimSpec(\n        charge=\"900.00\",\n        lines=[ServiceLineSpec(charge=\"900.00\", procedure=\"99214\",\n                               adjustments=[denial(\"CO\", \"97\", \"300.00\")])],\n    )\n]\nremittance = generate_835(seed=1, claims=spec, payer_name=\"EXAMPLE HEALTH PLAN\")\n```\n\nA claim's payment is derived as charge minus adjustments, so a specification that would break the 835 balance rule cannot be written down.\n\nClaim submissions work the same way:\n\n``` python\nfrom x12sdk.generate import generate_837p\n\nsubmission = generate_837p(seed=7, claims=25)\n```\n\nIn an 837 a claim sits under the subscriber when the patient is the\nsubscriber, and under a dependent when they are not. Code that walks the\nhierarchy often handles only the first, so generated files contain both by\ndefault. Set `dependent_rate` to choose the mix, or pass a `SubmissionSpec`\nto place each claim yourself:\n\n```\nfrom x12sdk.generate import (\n    ClaimSpec, PatientSpec, ServiceLineSpec, SubmissionSpec, generate_837p\n)\n\nspec = SubmissionSpec(\n    patients=[\n        PatientSpec(\n            claims=[ClaimSpec(charge=\"450.00\",\n                              lines=[ServiceLineSpec(charge=\"450.00\",\n                                                     procedure=\"99214\")])],\n            dependent=True,\n            relationship=\"19\",   # child\n        )\n    ]\n)\nsubmission = generate_837p(seed=1, claims=spec)\n```\n\nA remittance can also move money outside any claim, in the PLB segment: an overpayment recovered, interest owed. Invented remittances carry one such adjustment by default; a described scenario carries only what it describes, and the check amount in BPR02 is derived from both:\n\n``` python\nfrom x12sdk.generate import ClaimSpec, generate_835, provider_adjustment\n\nremittance = generate_835(\n    seed=1,\n    claims=[ClaimSpec(charge=\"500.00\")],\n    provider_adjustments=[provider_adjustment(\"WO\", \"25.00\", \"PCN000099\")],\n)\n# PLB*<payee NPI>*20251231*WO:PCN000099*25.00~   and   BPR*I*475.00*...\n```\n\nAn enrollment roster has its own repeating loops that readers get wrong: a member can have up to three employers (2100D) and several disability periods (2200), and a parser that keeps only the last of each looks correct on most files. Invented rosters exercise both by default; to pin them down:\n\n``` python\nfrom x12sdk.generate import DisabilitySpec, EmployerSpec, EnrolleeSpec, EnrollmentSpec, generate_834\n\nroster = EnrollmentSpec(\n    enrollees=[\n        EnrolleeSpec(\n            employers=[EmployerSpec(\"FIRST EMPLOYER\"), EmployerSpec(\"SECOND EMPLOYER\")],\n            disabilities=[\n                DisabilitySpec(type=\"2\", begins=\"20250101\", ends=\"20250601\"),\n                DisabilitySpec(type=\"3\", begins=\"20250701\"),\n            ],\n        )\n    ]\n)\nenrollment = generate_834(seed=1, enrollees=roster)\n```\n\nAn 835 tells you what a payer did to a claim, but in a shape built for\ntransmission: adjustments nested at claim and service line level, up to six\nreason/amount pairs per CAS segment, remark codes in a different segment\nagain. `x12sdk.denials` flattens that to one record per reason code and\naggregates it the way a revenue-cycle or payer analytics team asks the\nquestion.\n\n``` python\nfrom x12sdk.io import X12ModelReader\nfrom x12sdk.denials import denial_summary, iter_adjustments\n\nwith X12ModelReader(\"remit.835\") as reader:\n    for transaction in reader.models():\n        rows = list(iter_adjustments(transaction))\n        for row in denial_summary(rows):\n            print(row.payer_name, row.group_code, row.reason_code,\n                  row.category, row.claim_count, row.total_amount)\n```\n\n`denial_summary` counts payer-side groups (`CO`, `OA`, `PI`) by default and\nleaves out patient cost share (`PR`), because a deductible is not a denial;\npass `include_patient_responsibility=True` to keep it. Amounts stay `Decimal`,\nso totals are exact. `claim_count` counts distinct claims, so a reason hitting\nthree lines of one claim counts once.\n\nFor DataFrame work, install the extra and use `to_dataframe`:\n\n```\npip install 'x12sdk[pandas]'\n```\n\nCARC and RARC **descriptions** are published by X12 and the Washington\nPublishing Company and are licensed separately, so **x12sdk ships none of that\ntext**. What it ships is `categorize()`, x12sdk's own grouping of reason codes\ninto analysis categories such as `eligibility`, `authorization`, `duplicate`\nand `timely_filing`, with anything unmapped resolving to `other`.\n\nIf you need the official wording, obtain the list from\n[x12.org/codes](https://x12.org/codes) under whatever licence applies to you\nand load it yourself:\n\n``` python\nfrom x12sdk.denials import describe, load_code_descriptions\n\ndescriptions = load_code_descriptions(\"carc.csv\")   # your file, not ours\nfor row in describe(denial_summary(rows), descriptions):\n    print(row[\"reason_code\"], row[\"description\"], row[\"total_amount\"])\n```\n\nEligibility works the same way, and a 270 and the 271 answering it can be generated as a matched pair from one specification. One inquiry may ask about several service types, since EQ repeats:\n\n``` python\nfrom x12sdk.generate import BenefitSpec, EligibilitySpec, MemberSpec\nfrom x12sdk.generate import generate_270, generate_271\n\nspec = EligibilitySpec(\n    members=[MemberSpec(benefits=(BenefitSpec(service_type=\"35\"),), dependent=True)]\n)\ninquiry = generate_270(seed=1, members=spec)\nresponse = generate_271(seed=1, members=spec)\n```\n\nThe eligibility transactions carry the same subscriber and dependent branch as the 837, so generated files contain both by default here too.\n\nClaim status works the same way. The 276 states what was billed, the 277 answers with an STC status, and on one seed the pair describes the same people and the same claims:\n\n``` python\nfrom x12sdk.generate import generate_276, generate_277\n\ninquiry = generate_276(seed=9, patients=8)\nresponse = generate_277(seed=9, patients=8)\n```\n\nEnrollment has no hierarchy to branch on. A dependent on an 834 is a separate member record told apart by INS01 and INS02, not a loop nested under the subscriber, and both kinds appear by default:\n\n``` python\nfrom x12sdk.generate import generate_834\n\nroster = generate_834(seed=3, enrollees=20)\n```\n\nAll nine supported transaction sets can be generated. The institutional and dental claims take the same specification as the professional one:\n\n``` python\nfrom x12sdk.generate import generate_837i\n\nsubmission = generate_837i(seed=7, claims=25)\n```\n\nOn a dental claim a line's procedure is a CDT code, and a line done to a tooth names it, with the surfaces treated for a filling. Invented files mix lines with a tooth and lines without one (an exam, a cleaning):\n\n```\nfrom x12sdk.generate import (\n    ClaimSpec, PatientSpec, ServiceLineSpec, SubmissionSpec, generate_837d\n)\n\nspec = SubmissionSpec(\n    patients=[\n        PatientSpec(\n            claims=[ClaimSpec(charge=\"395.00\", lines=[\n                ServiceLineSpec(charge=\"55.00\", procedure=\"D0120\"),\n                ServiceLineSpec(charge=\"340.00\", procedure=\"D2392\",\n                                tooth=\"19\", surfaces=(\"M\", \"O\")),\n            ])]\n        )\n    ]\n)\nsubmission = generate_837d(seed=1, claims=spec)   # ... SV3*AD:D2392*340.00****1~ TOO*JP*19*M:O~\n```\n\nA tooth on an 837P or 837I is refused rather than dropped.\n\nA claim and the remittance that answers it can be generated together. Every\nclaim on the 837 is answered by exactly one claim payment on the 835, linked\nas real files are, by CLM01 = CLP01, with the same charge, the same procedure\non each line, and the same patient, payer and payee. Outcomes are mixed by\ndefault: some claims paid in full, most reduced by a contractual write-off,\nsome leaving a share to the patient, and a share denied outright\n(`denial_rate`, 0.15 by default). Real pairs are PHI, so this is the only way\nto have claims and their outcomes side by side in the open.\n\n``` python\nfrom x12sdk.generate import generate_claim_pair\n\nclaim, remittance = generate_claim_pair(seed=7, claims=25, claim_type=\"837d\")\n```\n\n`claim_type` is `\"837p\"`, `\"837i\"` or `\"837d\"`. To describe the outcome\nyourself, give `ClaimSpec` s: the lines and charges are what was submitted, the\nadjustments and `status` what the payer decided. The decision reaches the 835\nand is kept off the 837:\n\n``` python\nfrom x12sdk.generate import ClaimSpec, ServiceLineSpec, denial, generate_claim_pair\n\nspec = [\n    ClaimSpec(charge=\"120.00\", status=\"4\",   # denied\n              lines=[ServiceLineSpec(charge=\"120.00\", procedure=\"93000\",\n                                     adjustments=[denial(\"CO\", \"29\", \"120.00\")])]),\n]\nclaim, remittance = generate_claim_pair(seed=1, claims=spec)\n```\n\nRead both back with `claims()` and join on `patient_control_number`.\n\nA prebuilt set of pairs, with the claims and service lines as tables, is\npublished as the [x12sdk synthetic claims and remittances](https://huggingface.co/datasets/owgreen-dev/x12sdk)\ndataset; `scripts/build_dataset.py` rebuilds it byte for byte.\n\n`x12sdk-mcp` is an [MCP](https://modelcontextprotocol.io) server, so an AI\nassistant can read, check and generate X12 with the library instead of\nguessing at the format. Install the optional extra:\n\n```\npip install \"x12sdk[mcp]\"\nclaude mcp add x12sdk -- x12sdk-mcp      # Claude Code; other clients: run x12sdk-mcp over stdio\n```\n\n| Tool | What it does | \n|---|---|\n| `validate_x12` | Parses X12 text against the implementation guide; for an invalid file, where and why it failed | \n| `parse_x12` | Each transaction as JSON, loop by loop | \n| `list_claims` | One flat row per claim from an 837 (P, I or D), 835, 276 or 277 | \n| `generate_x12` | A synthetic file of any supported set, reproducible from a seed | \n| `generate_claim_pair` | A synthetic 837 and the 835 that answers it | \n\nEvery tool is read-only and works on the text it is given: the server never opens files or the network, and refuses a file path rather than reading it. What a tool returns does reach the assistant, though, so give it real claims only if your organization is permitted to share PHI with that assistant. The generators exist so that you need not.\n\n| before | after | \n|---|---|\n| `pip install linuxforhealth-x12` | `pip install x12sdk` | \n| `from linuxforhealth.x12.io import X12ModelReader` | `from x12sdk.io import X12ModelReader` | \n| `lfhx12 -m -p file.x12` | `x12sdk -m -p file.x12` | \n| `lfhx12-api` (FastAPI endpoint) | removed; wrap the SDK in your own service | \n\nSee [CHANGELOG.md](https://github.com/owgreen-dev/x12sdk/blob/main/CHANGELOG.md) for everything that changed.\n\n```\npip install -e \".[dev]\"\nruff check src\npytest --cov\n```\n\n`src/tests/audit/` is a suite of generic detectors, one per bug class that has\nshipped here, run over every transaction set on every commit; it is described,\nlimits included, in [repo-docs/AUDIT.md](https://github.com/owgreen-dev/x12sdk/blob/main/repo-docs/AUDIT.md).\n\nWhere the project is going, release by release, is in [ROADMAP.md](https://github.com/owgreen-dev/x12sdk/blob/main/ROADMAP.md).\n\nContributions are welcome; see [CONTRIBUTING.md](https://github.com/owgreen-dev/x12sdk/blob/main/CONTRIBUTING.md) (Apache-2.0,\nDCO sign-off, no copyrighted standards text, no real PHI). To add a\ntransaction set, see [repo-docs/NEW_TRANSACTION.md](https://github.com/owgreen-dev/x12sdk/blob/main/repo-docs/NEW_TRANSACTION.md);\nthe design is described in [repo-docs/DESIGN.md](https://github.com/owgreen-dev/x12sdk/blob/main/repo-docs/DESIGN.md).\n\nx12sdk is a fork of **[LinuxForHealth x12](https://github.com/LinuxForHealth/x12)**\nby Dixon Whitmire and the LinuxForHealth contributors (IBM), released under\nthe Apache License 2.0. The models, parser, readers, and test corpus\noriginate there; x12sdk exists to keep that work usable on current Python\nand Pydantic. The original LICENSE is retained, and attribution and\ntrademark notes are in [NOTICE](https://github.com/owgreen-dev/x12sdk/blob/main/NOTICE) and [TRADEMARK.md](https://github.com/owgreen-dev/x12sdk/blob/main/TRADEMARK.md).\nx12sdk is not affiliated with or endorsed by IBM, LinuxForHealth, or the\nLinux Foundation.\n\n- **[MdClarity/x12](https://github.com/MdClarity/x12)** — an independent\nfork by MD Clarity (Cary Lee) that completed a Pydantic v2 migration and\nadded type checking and fuzzing in 2026. x12sdk's port is written\nseparately from the 2022 upstream; their work is acknowledged here and\ntheir fixes are welcome upstream in x12sdk.\n- **[pyx12](https://github.com/azoner/pyx12)** — the long-standing Python X12\nvalidator/converter (XML/dict output, map-driven). Choose pyx12 for\nvalidation against X12 maps; choose x12sdk for typed Python models.\n- **[edi-835-parser](https://github.com/keiron-stoddart/edi-835-parser)** —\na popular 835-only parser with pandas output.", "url": "https://wpnews.pro/news/show-hn-x12sdk-read-check-and-generate-hipaa-x12-claim-files-in-python", "canonical_source": "https://github.com/owgreen-dev/x12sdk", "published_at": "2026-11-29 14:15:48+00:00", "updated_at": "2026-11-29 14:44:20.672522+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents", "agent-protocols", "ai-tools"], "entities": ["x12sdk", "Pydantic", "Hugging Face", "owgreen-dev"], "also_reported_by": [], "takeaway": "x12sdk parses 837/835/270/271/276/277/834 files into validated Pydantic v2 models that round-trip byte for byte, and its seed-based generator reproduces identical synthetic files, so pipelines can be tested without PHI.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-x12sdk-read-check-and-generate-hipaa-x12-claim-files-in-python", "markdown": "https://wpnews.pro/news/show-hn-x12sdk-read-check-and-generate-hipaa-x12-claim-files-in-python.md", "text": "https://wpnews.pro/news/show-hn-x12sdk-read-check-and-generate-hipaa-x12-claim-files-in-python.txt", "jsonld": "https://wpnews.pro/news/show-hn-x12sdk-read-check-and-generate-hipaa-x12-claim-files-in-python.jsonld"}}