This project has moved and is read-only. For the latest updates, please go here.

Generate 5010 834 file from scratch.

Jan 2, 2014 at 2:57 PM
I want to start out by saying X12 Parser ROCKS. I love the way this library is coded. GREAT JOB TEAM!

Please provide a working example of how to create a 5010 834 file from scratch. I'm able to generate 837's with no problems. I received an error when trying to add multiple REF's to the file but was able to get passed that by modifying the source code. I need some help and direction on where to go from here.

The following is what I have so far:
public void Generate834(DataTable MemberEligDT)
        {
            int LoopID = 0;
            List<string> Errors = new List<string>();
            if (MemberEligDT == null)
                return;
            DateTime startDT = DateTime.Now;

            // Create a new interchange...
            var message = new Interchange(startDT, 000905, false)
            {
                InterchangeSenderIdQualifier = "01",
                InterchangeSenderId = "Blah Inc",
                InterchangeReceiverIdQualifier = "01",
                InterchangeReceiverId = "Blah 2 Inc.",
                SecurityInfo = "",
                SecurityInfoQualifier = "00",
            };
            message.SetElement(12, "00501");
            message.SetElement(10, "1253");
            message.SetElement(11, "^");

            var group = message.AddFunctionGroup("BE", DateTime.Now, 1, "005010X220A1");
            group.ApplicationSendersCode = "9998503898";
            group.ApplicationReceiversCode = "0123456789";
            group.Date = DateTime.Now;
            group.ControlNumber = 1;
            group.SetElement(5, "0802");

            int transactionnum = LoopID;
            transactionnum++;
            string TransNumString = string.Empty;

            if (transactionnum < 10)
                TransNumString = "0000" + transactionnum.ToString();
            else
                TransNumString = "000" + transactionnum.ToString();

            var transaction = group.AddTransaction("834", TransNumString);

            transaction.SetElement(2, TransNumString);
            transaction.SetElement(3, "005010X220A1");

            var bgnSegment = transaction.AddSegment("BGN");
            bgnSegment.SetElement(1, "00");
            bgnSegment.SetElement(2, "1");
            DateTime NOWdt = DateTime.Now;
            bgnSegment.SetElement(3, NOWdt.ToString("yyyyMMdd", CultureInfo.InvariantCulture));
            bgnSegment.SetElement(4, DateTime.Now.ToString("hhmm", CultureInfo.InvariantCulture));
            bgnSegment.SetElement(6, "1");
            bgnSegment.SetElement(8, "4");

            var sponsorLoop = transaction.AddLoop(new TypedLoopN1());
            sponsorLoop.N101_EntityIdentifierCode = "P5";
            sponsorLoop.N102_Name = "ACME Ins Co";
            sponsorLoop.N103_IdentificationCodeQualifier = "FI";
            sponsorLoop.N104_IdentificationCode = "PMED";

            var partyIDLoop = transaction.AddLoop(new TypedLoopN1());
            partyIDLoop.N101_EntityIdentifierCode = "IN";
            partyIDLoop.N103_IdentificationCodeQualifier = "FI";
            partyIDLoop.N104_IdentificationCode = "999505788";

            
            
            // Loop through the members...
            for (int x = 0;x < MemberEligDT.Rows.Count;x++)
            {
                var InsSegment = transaction.AddSegment("INS", true);
                InsSegment.SetElement(1, "Y");
                InsSegment.SetElement(2, "18");
                InsSegment.SetElement(3, "030");
                InsSegment.SetElement(4, "XN");
                InsSegment.SetElement(5, "A");
                InsSegment.SetElement(6, "A:0");
                InsSegment.SetElement(8, "AC");

                var InsRefLoop1 = transaction.AddSegment(new TypedSegmentREF());
                InsRefLoop1.REF01_ReferenceIdQualifier = "REF";
                InsRefLoop1.REF02_ReferenceId = "0F";
                InsRefLoop1.REF03_Description = "00025907AVA";

                var InsRefLoop2 = transaction.AddSegment(new TypedSegmentREF());
                InsRefLoop2.REF01_ReferenceIdQualifier = "REF";
                InsRefLoop2.REF02_ReferenceId = "17";
                InsRefLoop2.REF03_Description = "00025907AVA";

                var MemberNM1 = transaction.AddLoop(new TypedLoopNM1("NM1"));
                MemberNM1.NM101_EntityIdCode = "NM1";
                MemberNM1.NM101_EntityIdentifierCodeEnum = EntityIdentifierCode.InsuredOrSubscriber;
                MemberNM1.NM102_EntityTypeQualifier = EntityTypeQualifier.Person;
                MemberNM1.NM103_NameLastOrOrganizationName = (string)MemberEligDT.Rows[x]["FirstName"];
                MemberNM1.NM104_NameFirst = "FIRST";
                MemberNM1.NM105_NameMiddle = "M";
                
            }
            
            string Output = message.SerializeToX12(true);
        }
Jan 23, 2014 at 2:54 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 5, 2014 at 2:01 PM
Please post your 837 generation code