Command-line tools¶
Installing the package places the following scripts on PATH. Each script
is also available as python -m pyx12.scripts.<name>; the --help
output captured below is identical to running the entry-point directly.
x12valid¶
Parse an ANSI X12N data file and validate it against the appropriate HIPAA
implementation guide. Emits errors to stderr; with -H also writes an
HTML rendering next to the input file.
$ x12valid --help
usage: x12valid [-h] [--config-file CONFIGFILE] [--log-file LOGFILE]
[--map-path MAP_PATH] [--verbose] [--debug] [--quiet] [--html]
[--json-output] [--suppress CODE,CODE,...]
[--exclude-external-codes EXCLUDE_EXTERNAL] [--charset {b,e}]
[--version]
[input_files ...]
X12 Validation
positional arguments:
input_files
options:
-h, --help show this help message and exit
--config-file, -c CONFIGFILE
--log-file, -l LOGFILE
--map-path, -m MAP_PATH
--verbose, -v
--debug, -d
--quiet, -q
--html, -H
--json-output, -J Write JSON error output alongside the input as
<input>.json
--suppress, -S CODE,CODE,...
Suppress pyx12 error codes from the err_handler tree,
997/999 ack output, and JSON output. Comma-separated;
may be given multiple times. Example: --suppress
ELE_6_invalid_composite,SEG_3_too_many_elements
--exclude-external-codes, -x EXCLUDE_EXTERNAL
External Code Names to ignore
--charset, -s {b,e} Specify X12 character set: b=basic, e=extended
--version show program's version number and exit
External code names accepted by --exclude-external-codes / -x
(pass the flag once per name to suppress validation against that codeset):
states US State or Province Codes
country Country Codes
currency Currency Code
entity_id Entity Identifier Code
remark_code Remark Code
service_type Service Type Code
claim_status_cat Health Care Claim Status Category Code (Code Source 507)
claim_status Health Care Claim Status Code (Code Source 508)
pos Place of Service - code source 237
x12norm¶
Re-format an X12 document. Adds segment-terminator newlines with -e and
patches common loop / segment counting errors with -f. Reads stdin and
writes stdout when no files are given.
$ x12norm --help
usage: x12norm [-h] [--verbose] [--quiet] [--debug] [--eol] [--inplace]
[--fixcounting] [--output OUTPUTFILE] [--version]
[input_files ...]
Format an X12 document
positional arguments:
input_files
options:
-h, --help show this help message and exit
--verbose, -v
--quiet, -q
--debug, -d
--eol, -e Add eol to each segment line
--inplace, -i Make changes to files in place
--fixcounting, -f Try to fix counting errors
--output, -o OUTPUTFILE
Output filename. Defaults to stdout
--version show program's version number and exit
x12html¶
Render an X12 document as an HTML view that highlights structure and errors.
$ x12html --help
usage: x12html [-h] [--config-file CONFIGFILE] [--log-file LOGFILE]
[--map-path MAP_PATH] [--verbose] [--debug] [--quiet] [--html]
[--exclude-external-codes EXCLUDE_EXTERNAL] [--charset {b,e}]
[--version]
[input_files ...]
Format an X12 file as HTML
positional arguments:
input_files
options:
-h, --help show this help message and exit
--config-file, -c CONFIGFILE
--log-file, -l LOGFILE
--map-path, -m MAP_PATH
--verbose, -v
--debug, -d
--quiet, -q
--html, -H Write HTML to a file instead of stdout
--exclude-external-codes, -x EXCLUDE_EXTERNAL
External Code Names to ignore
--charset, -s {b,e} Specify X12 character set: b=basic, e=extended
--version show program's version number and exit
External code names accepted by --exclude-external-codes / -x
(pass the flag once per name to suppress validation against that codeset):
states US State or Province Codes
country Country Codes
currency Currency Code
entity_id Entity Identifier Code
remark_code Remark Code
service_type Service Type Code
claim_status_cat Health Care Claim Status Category Code (Code Source 507)
claim_status Health Care Claim Status Code (Code Source 508)
pos Place of Service - code source 237
x12info¶
Print summary metadata (interchange / functional group / transaction set counts and identifiers) for an X12 document.
$ x12info --help
usage: x12info [-h] [--verbose] [--quiet] [--debug] [--eol] [--inplace]
[--fixcounting] [--output-dir OUTPUTDIRECTORY]
[--map-path MAP_PATH] [--version]
[input_files ...]
X12 File Metadata
positional arguments:
input_files
options:
-h, --help show this help message and exit
--verbose, -v
--quiet, -q
--debug, -d
--eol, -e Add eol to each segment line
--inplace, -i Make changes to files in place
--fixcounting, -f Try to fix counting errors
--output-dir, -t OUTPUTDIRECTORY
Output directory
--map-path, -m MAP_PATH
--version show program's version number and exit
x12xml¶
Convert an X12 document to its XML representation.
$ x12xml --help
usage: x12xml [-h] [--config-file CONFIGFILE] [--log-file LOGFILE]
[--map-path MAP_PATH] [--verbose] [--debug] [--quiet] [--html]
[--outputfile OUTPUTFILE]
[--exclude-external-codes EXCLUDE_EXTERNAL] [--charset {b,e}]
[--version]
input_file
X12 to XML conversion
positional arguments:
input_file
options:
-h, --help show this help message and exit
--config-file, -c CONFIGFILE
--log-file, -l LOGFILE
--map-path, -m MAP_PATH
--verbose, -v
--debug, -d
--quiet, -q
--html, -H
--outputfile, -o OUTPUTFILE
XML target filename
--exclude-external-codes, -x EXCLUDE_EXTERNAL
External Code Names to ignore
--charset, -s {b,e} Specify X12 character set: b=basic, e=extended
--version show program's version number and exit
External code names accepted by --exclude-external-codes / -x
(pass the flag once per name to suppress validation against that codeset):
states US State or Province Codes
country Country Codes
currency Currency Code
entity_id Entity Identifier Code
remark_code Remark Code
service_type Service Type Code
claim_status_cat Health Care Claim Status Category Code (Code Source 507)
claim_status Health Care Claim Status Code (Code Source 508)
pos Place of Service - code source 237
xmlx12¶
Convert an XML representation produced by x12xml back into an X12
document.
$ xmlx12 --help
usage: xmlx12 [-h] [--log-file LOGFILE] [--verbose] [--debug] [--quiet]
[--outputfile OUTPUTFILE] [--version]
input_file
XML to X12 conversion
positional arguments:
input_file
options:
-h, --help show this help message and exit
--log-file, -l LOGFILE
--verbose, -v
--debug, -d
--quiet, -q
--outputfile, -o OUTPUTFILE
X12 target filename
--version show program's version number and exit