Python library for parsing X12 healthcare EDI files (835, 837P, 837I)
Project description
█▀█ █▀█ █▀▀ █▄ █ ▀▄▀ ▄█ ▀█
█▄█ █▀▀ ██▄ █ ▀█ █ █ █ █▄
Parse X12 healthcare EDI files with Python
835 (ERA) • 837P (Professional) • 837I (Institutional)
Features
- Zero dependencies - Uses only Python standard library
- Clean API -
x835.parse(content).summary() - Multiple outputs -
.json(),.table(),.summary() - Direct access -
.claims,.payer,.total_billed - CLI included - Parse files from command line
Installation
pip install openx12
Quick Start
from openx12 import x835, x837p, x837i
# Parse an 835 ERA file
era = x835.parse(edi_content)
print(era.summary())
print(f"Payment: ${era.payment_amount}")
print(f"Payer: {era.payer['name']}")
# Parse an 837P professional claim
claim = x837p.parse(edi_content)
print(claim.summary())
print(f"Total Billed: ${claim.total_billed}")
print(f"Claims: {len(claim.claims)}")
# Parse an 837I institutional claim
claim = x837i.parse(edi_content)
print(claim.summary())
print(f"Facility: {claim.billing_facility['last_name']}")
Output Methods
Each parser returns an object with three output methods:
claim = x837p.parse(content)
# Quick overview
claim.summary()
# Full structured data
claim.json()
# Display-friendly tables
claim.table()
Direct Property Access
Access parsed data directly without calling methods:
# 835 ERA
era = x835.parse(content)
era.payer # {'name': 'ACME INSURANCE', 'id': '12345'}
era.payee # {'name': 'MEDICAL CLINIC', 'id': '67890'}
era.claims # List of all claims
era.payment_amount # 1500.00
era.check_number # '123456789'
# 837P Professional
claim = x837p.parse(content)
claim.claims # List of all claims
claim.patients # List of all patients
claim.providers # List of all providers
claim.total_billed # 72663.87
claim.billing_provider # First provider dict
# 837I Institutional
claim = x837i.parse(content)
claim.claims # List of all claims
claim.patients # List of all patients
claim.providers # List of all providers
claim.total_billed # 250000.00
claim.billing_facility # First facility dict
CLI Usage
# Parse with auto-detect
openx12 parse remittance.835
# Get summary
openx12 parse claim.edi -f summary
# Specify type
openx12 parse claim.edi -t 837p
# Output as table format
openx12 parse era.txt -f table
# Save to file
openx12 parse input.835 -o output.json
# Read from stdin
cat file.835 | openx12 parse -
Output Structures
.summary()
# 835 ERA
{
"file_type": "835 (ERA/Remittance)",
"payer": "ACME INSURANCE",
"payee": "MEDICAL CLINIC",
"check_number": "123456789",
"payment_amount": 1500.00,
"total_claims": 5,
"total_charged": 2000.00,
"total_paid": 1500.00,
"total_patient_responsibility": 300.00
}
# 837P Professional
{
"file_type": "837P (Professional Claim)",
"billing_provider": "SEQUOIA FAMILY MEDICAL CENTER",
"billing_npi": "1790221703",
"total_claims": 592,
"total_patients": 631,
"total_billed": 72663.87,
"service_date_range": "2024-12-13 to 2025-12-03",
"total_services": 1346
}
# 837I Institutional
{
"file_type": "837I (Institutional Claim)",
"billing_facility": "GENERAL HOSPITAL",
"billing_npi": "1234567890",
"total_claims": 10,
"total_billed": 250000.00,
"admission_type_breakdown": {"1": 3, "3": 7}
}
.json()
Returns full parsed data including:
- All segments parsed
- Interchange/group headers
- Claims with services, diagnoses, dates
- Providers with addresses
- Patients with demographics
.table()
Returns display-friendly format:
{
"file_info": {"type": "837P", "total_claims": 592},
"tables": {
"claims": [...],
"services": [...],
"patients": [...],
"providers": [...]
}
}
Supported Transactions
| Code | Name | Description |
|---|---|---|
| 835 | ERA | Electronic Remittance Advice (payment/denial info) |
| 837P | Professional | Physician/outpatient claims (CMS-1500 equivalent) |
| 837I | Institutional | Hospital/facility claims (UB-04 equivalent) |
Development
git clone https://github.com/josephbiagio/openx12.git
cd openx12
pip install -e ".[dev]"
pytest tests/ -v
License
MIT © Joseph Biagio
Project details
Release history Release notifications | RSS feed
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 openx12-0.2.0.tar.gz.
File metadata
- Download URL: openx12-0.2.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
245ac261f777291e0425df855e1389f1cc56edbc9ff7c61bdde15ac16474a11c
|
|
| MD5 |
2d44952f664bb3acd5819697015f5d41
|
|
| BLAKE2b-256 |
333d6f7c2480d7e61bb72c31dfebcebc539fca27063407a420351c3041df3c98
|
File details
Details for the file openx12-0.2.0-py3-none-any.whl.
File metadata
- Download URL: openx12-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb4d4d29967207028813b44bb65be683f521ea998887a19956d1d51565dd249c
|
|
| MD5 |
205d326fb3bd24aa70c68bfe0b03dd4b
|
|
| BLAKE2b-256 |
89ed9217100209b1f43d9ea09544976027c90eecbafb0938367c344cc2a9b611
|