.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "X12::Parser 3pm" .TH X12::Parser 3pm 2024-03-09 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME X12::Parser \- Perl module for parsing X12 Transaction files .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use X12::Parser; \& \& # Create a parser object \& my $p = new X12::Parser; \& \& # Parse a file with the transaction specific configuration file \& $p\->parsefile ( \& file => \*(Aq837.txt\*(Aq, \& conf => \*(AqX12\-837P.cf\*(Aq \& ); \& \& # Step through the file \& while ( my $loop = $p\->get_next_loop ) { \& my @loop = $p\->get_loop_segments; \& } \& \& # or use this method instead \& while ( my ($pos, $loop) = $p\->get_next_pos_loop ) { \& my @loop = $p\->get_loop_segments; \& } \& \& # or use \& while ( my ($pos, $level, $loop) = $p\->get_next_pos_level_loop ) { \& my @loop = $p\->get_loop_segments; \& } .Ve .SH ABSTRACT .IX Header "ABSTRACT" X12::Parser package provides a efficient way to parse X12 transaction files. Although this package is built keeping HIPAA related X12 transactions in mind, it is flexible and can be adapted to parse any X12 or similar transactions. .SH DESCRIPTION .IX Header "DESCRIPTION" The X12::Parser is a token based parser for parsing X12 transaction files. The parsing of transaction files requires the presence of configuration files for the different transaction types. .PP The following methods are available: .IP new 2 .IX Item "new" .Vb 1 \& $p = new X12::Parser; .Ve .Sp This is the object constructor method. It does not take any arguments. It only initializes the members variables required for parsing the transaction file. .IP parsefile 2 .IX Item "parsefile" .Vb 1 \& $p\->parsefile(file => \*(Aq837.txt\*(Aq, conf => \*(AqX12\-837P.cf\*(Aq); .Ve .Sp This method takes two arguments. The first argument is the transaction file that needs to be parsed. The second argument specifies the configuration file to be used for parsing the transaction file. .Sp To create your own configuration file read the X12::Parser::Readme man page. .IP parse 2 .IX Item "parse" .Vb 2 \& open($file, \*(Aq837.txt\*(Aq); \& $p\->parse(handle => $file, conf => \*(AqX12\-837P.cf\*(Aq); .Ve .Sp This method is similar to parsefile, except it takes an open file handle as input. .IP closefile 2 .IX Item "closefile" .Vb 1 \& $p\->closefile(); .Ve .Sp Close a X12 file. If you parse an X12 file till the very end the Parser will close the file. But if you only parse a few segments you can explicitly close the file by calling \fBclosefile()\fR; .IP get_next_loop 2 .IX Item "get_next_loop" .Vb 1 \& $p\->get_next_loop; .Ve .Sp This function returns the name of the next loop that is present in the file being parsed. The loop name is as specified in the cf file. .IP get_loop_segments 2 .IX Item "get_loop_segments" .Vb 1 \& $p\->get_loop_segments; .Ve .Sp This function returns the segments in the loop that was returned by \fBget_next_loop()\fR. This function is to be used in tandem with the get_next_loop. If not it may return/produce undesired results. .IP get_next_pos_loop 2 .IX Item "get_next_pos_loop" .Vb 1 \& $p\->get_next_pos_loop; .Ve .Sp This function returns the next loop name and the segment position. Note position 1 corresponds to the first segment. .IP get_next_pos_level_loop 2 .IX Item "get_next_pos_level_loop" .Vb 1 \& $p\->get_next_pos_level_loop; .Ve .Sp Same as \fBget_next_pos_loop()\fR except that in addition this function returns the level of the loop. The level corresponds to the level of the loop in the loop hierarchy. The top level loop has level 1. .IP print_tree 2 .IX Item "print_tree" .Vb 1 \& $p\->print_tree; .Ve .Sp Prints the transaction file in a tree format. .IP get_segment_separator 2 .IX Item "get_segment_separator" .Vb 1 \& $p\->get_segment_separator; .Ve .Sp Get the segment separator. .IP get_element_separator 2 .IX Item "get_element_separator" .Vb 1 \& $p\->get_element_separator; .Ve .Sp Get the element separator. .IP get_subelement_separator 2 .IX Item "get_subelement_separator" .Vb 1 \& $p\->get_subelement_separator; .Ve .Sp Get the sub-element separator. .PP The configuration files provided with this package and the corresponding transaction type are mentioned below. These are the X12 HIPAA transactions. .PP .Vb 10 \& type configuration file \& \-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& 1) 270 270_004010X092.cf \& 2) 271 271_004010X092.cf \& 3) 276 276_004010X093.cf \& 4) 277 277_004010X092.cf \& 5) 278 278_004010X094_Req.cf \& 6) 278 278_004010X094_Res.cf \& 7) 820 820_004010X061.cf \& 8) 834 834_004010X095.cf \& 9) 835 835_004010X091.cf \& 10) 837I 837_004010X096.cf \& 11) 837D 837_004010X097.cf \& 12) 837P 837_004010X098.cf .Ve .PP These cf files are installed in under the X12/Parser/cf folder. .PP The sample cf files provided with this package are good to the best of the authors knowledge. However the user should ensure the validity of these files. The user may use them as is at their own risk. .SS EXPORT .IX Subsection "EXPORT" None by default. .SH "SEE ALSO" .IX Header "SEE ALSO" For details on Transaction sets refer to: National Electronic Data Interchange Transaction Set Implementation Guide. Implementation guides are available for all the Transaction sets. .PP X12::Parser::Readme for more information on the Parser and configuration files. .PP X12::Parser::Tree .PP X12::Parser::Cf .PP If you have a mailing list set up for your module, mention it here. .PP If you have a web site set up for your module, mention it here. .SH AUTHOR .IX Header "AUTHOR" Prasad Balan, \fIprasad@cpan.org\fR .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2009 by Prasad Balan .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.