Giter Site home page Giter Site logo

x12-parser-library's Introduction

X12 Parser / Serializer

Releases

1.0.0
  • Initial release
  • Basic parsing and serializing of X12
  • EDI is stored in hierarchical data structure

Including this library

You'll need to include this library in your project in order to use it. First, add the following to the repositories section of your composer.json file:

{
  ...
  "require": {
    ...
    "uhin/x12-parser": "1.0.0"
    ...
  }
}

You can now include the library into your project by running:

composer require uhin/x12-parser:1.0.0

Once you're included the library in your project, you can now begin writing code to parse and serialize X12 EDI.

Examples

Parsing a file
use Uhin\X12Parser\Parser\X12Parser;

// Load the file into memory
$rawX12 = file_get_contents('path-to-your-file');

// Create a parser object
$parser = new X12Parser($rawX12);

// Parse the file into an object data structure
$x12 = $parser->parse();
// $x12 is now an X12 object containing all of the information from the X12 file
Accessing/Modifying data in the X12

Note: If any segment/property can have multiples then it will always be parsed into an array, even if there is only one present. This is to avoid confusion on whether or not you are dealing with an array or an object.

// Using the $x12 object from the examlpe above...

// Retrieving the GS06
$gs06 = $x12->ISA[0]->GS[0]->GS06;

// Setting the GS06 value
$x12->ISA[0]->GS[0]->GS06 = 'Changed Value';
Converting a parsed file back to X12
use Uhin\X12Parser\Serializer\X12Serializer;

// Using the $x12 object from the examlpe above...
$serializer = new X12Serializer($x12);

// Options for serializing:
$serializer->addNewLineAfterSegment(true);
$serializer->addNewLineAfterIEA(true);

// Generate the raw X12 string
$rawX12 = $serializer->serialize();

Unit Tests

First, make sure that you've placed your test files in the tests/test-files directory.

NOTE: Don't commit these files to git if they have any HIPPA data.

The current tests will look for the following files in the tests/test-files directory:

  • 277.txt
  • 835.txt
  • 837.txt
  • 999.txt
  • TA1.txt

Once you have your files in place, you can run this command from the root of the library:

./vendor/bin/phpunit --bootstrap ./vendor/autoload.php --testdox tests

x12-parser-library's People

Contributors

cameronhejazifar avatar zlobato avatar behrhartuhin avatar rmclellanduhin avatar markguyver avatar chejaziuhin avatar kclayton925 avatar skiram avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.