Pyx12 is a HIPAA X12 document validator and converter. It parses an ANSI X12N (Healthcare) data file and validates it against a representation of the Implementation Guidelines for a HIPAA transaction. By default, it creates a 997 response. It can create an annotated HTML representation of the X12 document or can translate to and from several XML representations of the data file.

The validation specifications for each X12 transaction are contained in XML files (map files). For a particular transaction, the map file describes the loops, segments, and elements; their relationships, their requirement conditions; and their data types. As XML files, their contents can be altered using XSL transformations. The parsing and validation of an X12 document can be altered by giving one or more XSLT files as command line arguments. The XSLT files are applied to the correct map for the X12 document in turn. Using this feature, the validation of the document can be made more or less restrictive.

XSL transforms can also be used to apply a regular expression to a map element node. This allows further element value validation. See example XSLT files in %PYTHONDIR%\test\files and the XML Schema file 'map.xsd' for more details. For syntax, see python regular expression syntax.

The XSL transform should be written so that it only affects the intended map file. Applying the XSLT to any other map should result in no change. Also, the resulting XML map must validate against the XML Schema file 'map.xsd'.

Pyx12 is currently a command line only application. It it composed of several scripts:

Validates X12 documents. Creates a Functional Acknowledgement (997) file. Can create an annotated HTML representation of the source document.
Converts the X12 document into one of several flavors of XML documents.
Converts an XML file in a form created by x12xml into an X12 document
Cleanup (normalize) an X12 document. Can add/remove segment line breaks and can fix loop counting errors.