public void ClaimCreationTest() { Interchange interchange = CreateSample1WithFunctionGroup(); Transaction transaction = interchange.FunctionGroups.First().AddTransaction("837", "0034"); Segment bhtSegment = transaction.AddSegment("BHT*0019*00*3920394930203*20070816*1615*CH"); Segment refSegment = transaction.AddSegment("REF*87*004010X096A1"); Loop senderLoop = transaction.AddLoop("NM1*41*2*HOWDEE HOSPITAL*****XX*0123456789"); senderLoop.AddSegment("PER*IC*BETTY RUBBLE*TE*9195551111"); Loop receiverLoop = transaction.AddLoop("NM1*40*2*BLUE CROSS BLUE SHIELD OF NC*****46*987654321"); HierarchicalLoop providerLoop = transaction.AddHLoop("1", "20", true); providerLoop.AddSegment("PRV*BI*ZZ*203BA0200N"); var billingProvider = providerLoop.AddLoop("NM1*85*2*HOWDEE HOSPITAL*****XX*0123456789"); billingProvider.AddSegment("N3*123 HOWDEE BOULEVARD"); billingProvider.AddSegment("N4*DURHAM*NC*27701"); billingProvider.AddSegment("REF*1J*654"); billingProvider.AddSegment("PER*IC*BETTY RUBBLE*TE*9195551111*FX*6145551212"); HierarchicalLoop subscriberLoop = providerLoop.AddHLoop("2", "22", false); subscriberLoop.AddSegment("SBR*P*18*XYZ1234567******BL"); subscriberLoop.AddSegment("PAT*********Y"); var subscriberNameLoop = subscriberLoop.AddLoop("NM1*IL*1*DOUGH*MARY****MI*12312312312"); subscriberNameLoop.AddSegment("N3*BOX 12312"); subscriberNameLoop.AddSegment("N4*DURHAM*NC*27715"); subscriberNameLoop.AddSegment("DMG*D8*19670807*F"); subscriberLoop.AddLoop("NM1*PR*2*BLUE CROSS BLUE SHIELD OF NC*****PI*987654321"); var claimLoop = subscriberLoop.AddLoop("CLM*2235057*200***13:A:1*Y**Y*A*********N"); claimLoop.AddSegment("DTP*434*RD8*20070730-20070730"); claimLoop.AddSegment("CL1*1*9*01"); claimLoop.AddSegment("AMT*C5*160"); claimLoop.AddSegment("REF*F8*ASD0000123"); claimLoop.AddSegment("HI*BK:25000"); claimLoop.AddSegment("HI*BF:78901"); claimLoop.AddSegment("HI*BR:4491:D8:20070730"); claimLoop.AddSegment("HI*BH:41:D8:20070501*BH:27:D8:20070715*BH:33:D8:20070415*BH:C2:D8:20070410"); claimLoop.AddSegment("HI*BE:30:::20"); claimLoop.AddSegment("HI*BG:01"); var physicianLoop = claimLoop.AddLoop("NM1*71*1*SMITH*ELIZABETH*AL***34*243898989"); physicianLoop.AddSegment("REF*1G*P97777"); var claimLineLoop = claimLoop.AddLoop("LX*1"); claimLineLoop.AddSegment("SV2*0300*HC:81000*120*UN*1"); claimLineLoop.AddSegment("DTP*472*D8*20070730"); claimLineLoop = claimLoop.AddLoop("LX*2"); claimLineLoop.AddSegment("SV2*0320*HC:76092*50*UN*1"); claimLineLoop.AddSegment("DTP*472*D8*20070730"); claimLineLoop = claimLoop.AddLoop("LX*3"); claimLineLoop.AddSegment("SV2*0270*HC:J1120*30*UN*1"); claimLineLoop.AddSegment("DTP*472*D8*20070730"); Assert.AreEqual(new StreamReader(Extensions.GetEdi("INS._837I._4010.Example1.txt")).ReadToEnd(), interchange.SerializeToX12(true)); }
public void CreatePurchaseOrder850(PurchaseOrder purchaseOrder, string fileName) { DateTime purcaseOrderDate = DateTime.Now; Interchange interchange = new Interchange(purcaseOrderDate, Convert.ToInt32(purchaseOrder.Number), true) { InterchangeSenderIdQualifier = "ZZ", InterchangeSenderId = InterchangeSenderId, InterchangeReceiverIdQualifier = "ZZ", InterchangeReceiverId = InterchangeReceiverId, InterchangeDate = purcaseOrderDate, }; interchange.SetElement(14, "0"); //No Aknowlegement is 0 FunctionGroup group = interchange.AddFunctionGroup("PO", purcaseOrderDate, Convert.ToInt32(purchaseOrder.Number), "004010"); group.ApplicationSendersCode = InterchangeSenderId; group.ApplicationReceiversCode = InterchangeReceiverId; // group.Date = purcaseOrderDate; // group.ControlNumber = Convert.ToInt32(purchaseOrder.Number); Transaction transaction = group.AddTransaction("850", "0001"); Segment bhtSegment = transaction.AddSegment("BEG"); bhtSegment.SetElement(1, "00"); bhtSegment.SetElement(2, "SA"); bhtSegment.SetElement(3, purchaseOrder.Number); bhtSegment.SetElement(5, purcaseOrderDate.ToString("yyyyMMdd")); //bhtSegment = transaction.AddSegment("CUR"); //bhtSegment.SetElement(1, "BY"); //bhtSegment.SetElement(2, "USD"); //bhtSegment = transaction.AddSegment("PER"); //bhtSegment.SetElement(1, "IC"); //bhtSegment.SetElement(2, "Doe,Jane"); //bhtSegment.SetElement(8, "Doe,Jane"); //bill to section Loop loop = transaction.AddLoop("N1"); loop.SetElement(1, "BT"); loop.SetElement(2, purchaseOrder.Customer.BillingName); loop.SetElement(3, 92); loop.SetElement(4, purchaseOrder.Customer.BillingAddress.Id); Segment segment = loop.AddSegment("N3"); segment.SetElement(1, purchaseOrder.Customer.BillingAddress.Street); segment.SetElement(2, purchaseOrder.Customer.BillingAddress.City + " " + purchaseOrder.Customer.BillingAddress.State + " " + purchaseOrder.Customer.BillingAddress.PostalCode + " " + purchaseOrder.Customer.BillingAddress.Country); segment = loop.AddSegment("N4"); segment.SetElement(1, purchaseOrder.Customer.BillingAddress.City); segment.SetElement(2, purchaseOrder.Customer.BillingAddress.ShortState); // short state segment.SetElement(3, purchaseOrder.Customer.BillingAddress.PostalCode); segment.SetElement(4, purchaseOrder.Customer.BillingAddress.ShortCountry); //short country //ship to to section loop = transaction.AddLoop("N1"); loop.SetElement(1, "ST"); loop.SetElement(2, purchaseOrder.Customer.ShippingName); loop.SetElement(3, 92); loop.SetElement(4, purchaseOrder.Customer.ShippingAddress.Id); segment = loop.AddSegment("N3"); segment.SetElement(1, purchaseOrder.Customer.ShippingAddress.Street); segment.SetElement(2, purchaseOrder.Customer.ShippingAddress.City + " " + purchaseOrder.Customer.ShippingAddress.State + " " + purchaseOrder.Customer.ShippingAddress.PostalCode + " " + purchaseOrder.Customer.ShippingAddress.Country); segment = loop.AddSegment("N4"); segment.SetElement(1, purchaseOrder.Customer.ShippingAddress.City); segment.SetElement(2, purchaseOrder.Customer.BillingAddress.ShortState); // short state segment.SetElement(3, purchaseOrder.Customer.BillingAddress.PostalCode); segment.SetElement(4, purchaseOrder.Customer.BillingAddress.ShortCountry); //short country int count = 1; foreach (LineItem lineItem in purchaseOrder.Items) { loop = transaction.AddLoop("PO1"); loop.SetElement(1, count++); loop.SetElement(2, lineItem.Quantity); loop.SetElement(3, "EA"); loop.SetElement(4, lineItem.Price); loop.SetElement(6, "CGT"); loop.SetElement(7, lineItem.SupplierItemNumber); } loop = transaction.AddLoop("CTT"); loop.SetElement(1, --count); var x12 = interchange.SerializeToX12(true); Console.WriteLine(x12); // Write the string to a file. fileName += purchaseOrder.Number + ".850"; System.IO.StreamWriter file = new System.IO.StreamWriter(fileName); file.WriteLine(x12); file.Close(); }
public void CreatePurchaseOrder850() { DateTime purcaseOrderDate = DateTime.Now; Interchange interchange = new Interchange(purcaseOrderDate, 245, true) { InterchangeSenderIdQualifier = "01", InterchangeSenderId = "828513080", InterchangeReceiverIdQualifier = "01", InterchangeReceiverId = "001903202U", InterchangeDate = purcaseOrderDate, }; interchange.SetElement(14, "0"); //No Aknowlegement is 0 FunctionGroup group = interchange.AddFunctionGroup("PO", purcaseOrderDate, 1, "005010X222"); group.ApplicationSendersCode = "828513080"; group.ApplicationReceiversCode = "001903202U"; group.Date = purcaseOrderDate; group.ControlNumber = 245; Transaction transaction = group.AddTransaction("850", "0001"); Segment bhtSegment = transaction.AddSegment("BEG"); bhtSegment.SetElement(1, "00"); bhtSegment.SetElement(2, "SA"); bhtSegment.SetElement(3, "S41000439"); bhtSegment.SetElement(5, "20100810"); bhtSegment = transaction.AddSegment("CUR"); bhtSegment.SetElement(1, "BY"); bhtSegment.SetElement(2, "USD"); bhtSegment = transaction.AddSegment("PER"); bhtSegment.SetElement(1, "IC"); bhtSegment.SetElement(2, "Doe,Jane"); bhtSegment.SetElement(8, "Doe,Jane"); // Bill to address Loop loop = transaction.AddLoop("N1"); loop.SetElement(1, "BT"); loop.SetElement(2, "Doe Jane"); loop.SetElement(3, 92); loop.SetElement(4, 10001); Segment segment = loop.AddSegment("N3"); segment.SetElement(1, "Street"); segment.SetElement(2, "City State Pin Country"); segment = loop.AddSegment("N4"); segment.SetElement(1, "City"); segment.SetElement(2, "SS"); segment.SetElement(3, "PIN"); segment.SetElement(4, "SC"); // ship to address loop = transaction.AddLoop("N1"); loop.SetElement(1, "ST"); loop.SetElement(2, "Doe Jane"); loop.SetElement(3, 92); loop.SetElement(4, 10001); segment = loop.AddSegment("N3"); segment.SetElement(1, "Street"); segment.SetElement(2, "City State Pin Country"); segment = loop.AddSegment("N4"); segment.SetElement(1, "City"); segment.SetElement(2, "SS"); segment.SetElement(3, "PIN"); segment.SetElement(4, "SC"); // add products ordered loop = transaction.AddLoop("PO1"); loop.SetElement(1, "1"); loop.SetElement(2, 10); loop.SetElement(3, "EA"); loop.SetElement(4, "10.2"); loop.SetElement(6, "IB"); loop.SetElement(7, "100001"); var x12 = interchange.SerializeToX12(true); Console.WriteLine(x12); }