Parse and write X12 healthcare EDI claims
Project description
KW X12 EDI Parser
A Python library for parsing and writing X12 healthcare EDI files.
PyPI: pypi.org/project/kw-x12-parser · Source: github.com/rohanrkamath/KW-X12-Parser
Installation
pip install kw-x12-parser
# With DataFrame support and write-claims CLI:
pip install kw-x12-parser[dataframe]
From source (development):
pip install -e .
pip install -e ".[dataframe]"
Usage
1. casual_parse_x837p – key columns
DataFrame with essential columns (one row per claim): provider_name, claim_id, patient_name, total_charge, etc.
from kw_x12_parser import casual_parse_x837p
df = casual_parse_x837p("path/to/837p_file.txt")
# or: casual_parse_x837p(open("file.txt").read())
print(df[["claim_id", "patient_name", "total_charge"]])
2. full_parse_x837p – full schema
DataFrame with every loop and segment (420+ columns): ISA_, GS_, CLM_, NM1_, SV1_, OTHER_SUBSCRIBER_, etc.
from kw_x12_parser import full_parse_x837p
df = full_parse_x837p("path/to/837p_file.txt")
# Use for COB claims or when you need complete data
3. write_to_edi_x837p – DataFrame to EDI
Convert a DataFrame back to 837P EDI. Two modes: filter original EDI by claim IDs (preserves segments) or build from scratch.
from kw_x12_parser import casual_parse_x837p, write_to_edi_x837p
df = casual_parse_x837p("original.txt")
released = df[df["claim_id"].isin({"123", "456"})]
write_to_edi_x837p(released, "claims_out.txt", original_edi="original.txt")
CLI
write-claims claims.csv -o claims.txt
write-claims claims.csv original.txt -o claims.txt # filter by claim IDs
Requires pip install kw-x12-parser[dataframe].
Project structure
kw_x12_parser/
└── x837p/
├── api.py # casual_parse_x837p, full_parse_x837p, write_to_edi_x837p
├── write_claims.py # write-claims CLI
├── workflow/ # Workflow notebook
├── edi_examples/ # Sample 837P files
└── utils/ # Parser internals
Ultimate goal
Support parsing of all healthcare X12 EDI formats:
| Code | Name | Purpose | Dev status |
|---|---|---|---|
| 270 | Eligibility inquiry | Ask payer if patient is eligible for coverage | — |
| 271 | Eligibility response | Payer’s response to 270 | — |
| 276 | Claim status request | Request status of a claim | — |
| 277 | Claim status response | Payer’s claim status response | — |
| 278 | Prior authorization | Request/response for prior authorization (inbound/outbound) | — |
| 820 | Premium payment | Pay health plan premiums | — |
| 834 | Benefit enrollment | Enroll or update member benefits | — |
| 835 | Payment/remittance | Payer payment and remittance advice (ERA) | — |
| 837P | Professional claim | Medical/professional claims | ✅ |
| 837I | Institutional claim | Hospital/facility claims | — |
| 837D | Dental claim | Dental claims | — |
Current supported formats
- X12 837P (005010X222A1)
Contributing
Issues and pull requests: github.com/rohanrkamath/KW-X12-Parser/issues
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kw_x12_parser-0.1.6.tar.gz.
File metadata
- Download URL: kw_x12_parser-0.1.6.tar.gz
- Upload date:
- Size: 41.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d3ade934d604b10df207f4c82b7fd8d791034046504e9328c3786bc022ff464
|
|
| MD5 |
cb7a60dc081a3fcaedff6ea446a3345d
|
|
| BLAKE2b-256 |
d70d1c1b4ed67158ceb4349599c57722770eb66c0ebcdf32e4c07fc53148a817
|
File details
Details for the file kw_x12_parser-0.1.6-py3-none-any.whl.
File metadata
- Download URL: kw_x12_parser-0.1.6-py3-none-any.whl
- Upload date:
- Size: 41.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78a6578a524e65fbf9cb6c2a1f0083c457666f0618ffbdddce30316faeb5c37c
|
|
| MD5 |
ae5861f26fa2d45000ec1c73c1c4c340
|
|
| BLAKE2b-256 |
b11278c03a2d40fdf4818834d70e43da202699682bfa42b1aec180a4a6fece94
|