Unbundling How To?

Jun 29, 2011 at 9:26 PM

It's great to see progress in X12Parser.  

I've got a project with a requirement to "unbundle" both 835 and 837 files into valid individual x12 provider files.  I ran across this page: http://x12parser.codeplex.com/wikipage?title=Unbundling%20an%20X12%20file%20by%20Loop%20ID which provides instructions to do so... however I'm not proficient enough in VS to understand exactly what I need to do to build this functionality.  

Ideally I'd like to implement a command line switch in the x12parser.exe that would turn on unbundling and pass the interchange loopid (in my case 2300).  Because it could possibly generate multiple output files a simple increment on the end of the specified output file would suffice.  I'm willing to role up my sleeves and learn, but I just need a nudge in the right direction.

BTW, I recently ran across an x12 "deidentifier" (http://etasoft.com/ot.htm) which would make it easy to provide you with sample data files.  If you need any, let me know!



Jun 30, 2011 at 2:59 AM

OK. After kicking around VS for awhile, here's what I've come up with that appears to work. I just used the main X12Parser project and modified it accordingly.  It takes only 1 argument from the command line - the input file.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using OopFactory.X12.Parsing;

namespace OopFactory.X12.X12Parser
    class Program
        static void Main(string[] args)
            string x12Filename = args[0];
            string outputFilename = args.Length > 1 ? args[1] : x12Filename;
            //string outputFilename = args.Length > 1 ? args[1] : x12Filename + ".xml";

            FileStream fs = new FileStream(x12Filename, FileMode.Open);
            //OopFactory.X12.Parsing.X12Parser parser = new Parsing.X12Parser();
            //string xml = parser.Parse(fs).Serialize();
            //X12Parser parser = new X12Parser();
            OopFactory.X12.Parsing.X12Parser parser = new Parsing.X12Parser();
            //Interchange interchange = parser.Parse(fs);
            Parsing.Model.Interchange interchange = parser.Parse(fs);
            var list = parser.UnbundleByLoop(interchange, "2300");
            int i = 1;
            foreach (var item in list)
                string ubundle = item.SerializeToX12(true);
                FileStream outputFs = new FileStream(outputFilename + Convert.ToString(i) + ".edi", FileMode.Create);
                StreamWriter writer = new StreamWriter(outputFs);

It generates the correct number of "2300" loop EDI files.  I have yet to test the output, but assume they are valid.  I'll post any additional progress I've made.  If there's any glaring issues with how I've constructed it, I'd appreciate feedback.



Jun 30, 2011 at 3:12 AM

You've beat me to it, and I thought you said you were unfamiliar with VS 2010!

I have also checked in a separate console app "UnbundleX12" that will perform what you have described.

You can see the program.cs file here: http://x12parser.codeplex.com/SourceControl/changeset/view/8959#148453

It is basically using the same algorithm that you have done.  I have added some error handling and help to the command line if the correct arguments are not recieved.

I also allow you to supply the loopid as an argument and override the default format string so that you can add leading zeros to to appended suffix.

I will include it as part of release 2.1.7 and update the document page on unbundling to include this.

I noticed that you had done some work identifying some of the errors in the 837 specification.  I have done some clean up on it after reviewing the 837D, 837P and 837I specifications (pretty mind numbing).  Let me know if you experience any adverse affects to the changes I have made (not yet released).  I was hoping to release it this weekend.  Next month I was going to try and update all three on the 5010 version (I can only numb my mind so much in one month).  

Thanks for being an active participant, I always love feedback from real users of the tool and will incorporate suggestions as quickly as I am able to.

Jun 30, 2011 at 3:52 AM

I'm getting a bit more familiar with VS 2010... but I feel like I'm 5 steps into a marathon in terms of understanding how the app is constructed. (My brain works better as an analyst vs. a programmer) :)

I see the unbundle version you just checked in.  Thanks for that.  I'll check it out tomorrow. Your intention then it to add the unbundle capability to the main parser exe? (Rather than maintain a separate version?)

Yes, I tested the parser a while back but ended up running into issues with several of test 835/837 files. (Some type of issue with a segment missing as I recall)  BUT in testing with build 8953 today it ran wonderfully.  I decided to really put it through it's paces and pushed 400 or so 835 & 837 files without a hitch so whatever the issue was, it has been fixed.

I really appreciate your responsiveness!  If there's anything I can help with, just ask!

Jun 30, 2011 at 7:31 PM

I have created a seperate exe for unbundling.  I don't wany anyone else who already uses the parser to have to change their command line configuration, and unbundling is a more distinct action that I think needs a separate command line verb.

I am glad I was able to clear up your parsing issues.  I had meant to do a through review of the spec for a while, but just now got around to it because no one was screaming to me that it was broken.  Unfortunately, people may have already moved onto other solutions instead of asking me to fix the spec.

I do like that de-identifier tool that you linked me to.  If you have specific test samples, I would be happy to include it in the unit test so that you can be assured that any additional changes will always be able to parse your specific data requirements.  Either way, any problems you have with parsing I would greatly appreciate if you report right away and I will get the fix incorporated quickly.  People are hesitant to report errors, but that is the only way that I can stabilize the product and it can gain more widespread adoption.  It's already the first result when you search google for x12 parser.  But I have a little higher standards than that.  I wouldn't mind if certain expensive tools lost market share because developer's don't have to ask their IT department to buy them anymore, because the open source solution offers a better value proposition.

Thanks for coming back to the site even though you had problems with the solution before!

Jul 1, 2011 at 2:11 PM

Creating the separate exe for unbundling makes sense.

I'll plan on providing at least one de-identified 837p file from each of the different payers so that you can test with them.  I'll probably just create an issue and attach them to it.

Yes, I'll definitely plan on reporting back any issues I have with the parser.  With the unbundling function, it's exactly what I needed for a current project so I'll be putting it to good use.

The next step I want to learn how to do with it is transform from XML to X12 formats...

Jul 10, 2011 at 8:57 PM

I have fixed the bug you identified where the unbunding was creating duplicates.  It has been released in version 2.1.7.