HIPAA X12 validator, parser and converter
Maintained. Last release 3 weeks ago, commits in 4 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install pyx12Pyx12
Pyx12 is a HIPAA X12 document parser, validator and converter. It reads an ANSI X12 data file and validates it against a representation of the X12 Implementation Guidelines. By default, it creates a 997 response for 4010 and a 999 response for 5010. It can create an HTML representation of the X12 document and can translate to and from an XML representation of the data file.
Usage
As a command line X12 validator
x12valid.exe <filename>
Fixes common X12 structural errors. Can add or remove line breaks. Can fix loop and segment counting.
x12norm.exe --fix --eol <filename>
Code Examples
Iterate over a loop. Alter children. Show changes
src = pyx12.x12context.X12ContextReader(param, errh, fd_in)
for datatree in src.iter_segments('2300'):
# do something with a 2300 claim loop
# we have access to the 2300 loop and all its children
for loop2400 in datatree.select('2400'):
print(loop2400.get_value('SV101'))
# update something
loop2400.set_value('SV102', 'xx')
# delete something
if loop2400.exists('PWK'):
loop2400.delete('PWK')
# iterate over all the child segments
for seg_node in datatree.iterate_segments():
print(seg_node.format())
Install
uv pip install pyx12
Contributing
The most useful contributions are new implementation-guide maps — either upgrading an existing 4010 map to its 5010 counterpart, or adding support for an X12 transaction pyx12 doesn't yet cover. Pyx12's design already handles the engine; the bottleneck is map coverage.
Where the maps live
XML maps live under pyx12/map/, one file per (transaction, version)
pair, named like <transaction>.<version>.<X-number>[.A<n>].xml —
e.g. 834.4010.X095.A1.xml, 837.5010.X222.A1.xml. The index that
pyx12 consults at runtime is pyx12/map/maps.xml; each entry binds a
(vriic, fic[, tspc]) triple to a map filename:
| Name | Abbreviation | X12 Element |
|---|---|---|