public void ParseModifyAndTransformBackToX12()
        {
            var stream = GetEdi("INS._270._4010.Example1_DHHS.txt");

            var parser = new X12Parser();
            Interchange interchange = parser.ParseMultiple(stream).First();
            string originalX12 = interchange.SerializeToX12(true);

            string xml = interchange.Serialize();

            XmlDocument doc = new XmlDocument();
            doc.PreserveWhitespace = true;
            doc.LoadXml(xml);

            XmlElement dmgElement = (XmlElement)(doc.GetElementsByTagName("DMG")[0]);
            dmgElement.ParentNode.RemoveChild(dmgElement);

            Console.WriteLine(doc.OuterXml);
            string x12 = parser.TransformToX12(doc.OuterXml);

            Console.WriteLine("ISA Segmemt:");
            Console.WriteLine(x12.Substring(0, 106));
            Console.WriteLine("Directly from XML:");
            Console.WriteLine(x12);

            var modifiedInterchange = parser.ParseMultiple(x12).First();

            string newX12 = modifiedInterchange.SerializeToX12(true);

            Console.WriteLine("After passing through interchange object:");
            Console.WriteLine(newX12);

            var seSegment = modifiedInterchange.FunctionGroups.First().Transactions.First().TrailerSegments.FirstOrDefault(ts => ts.SegmentId == "SE");

            Assert.IsNotNull(seSegment);
            Assert.AreEqual("0001", seSegment.GetElement(2));
            Assert.AreEqual("15", seSegment.GetElement(1));
        }
        public void ParseAndTransformToX12()
        {
            string resourcePath = Convert.ToString(TestContext.DataRow["ResourcePath"]);  // "INS._837P._4010.Spec_4.1.1_PatientIsSubscriber.txt";
            if (!resourcePath.Contains("_0x1D"))
            {
                Trace.WriteLine(resourcePath);
                Stream stream = GetEdi(resourcePath);

                var parser = new X12Parser();
                Interchange interchange = parser.ParseMultiple(stream).First();
                string originalX12 = interchange.SerializeToX12(true);

                string xml = interchange.Serialize();
                string x12 = parser.TransformToX12(xml);

                Interchange newInterchange = parser.ParseMultiple(x12).First();
                string newX12 = newInterchange.SerializeToX12(true);

                Assert.AreEqual(originalX12, newX12);
                Trace.Write(x12);
            }
        }
Esempio n. 3
0
 private static void UpdateEdiTest()
 {
     using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EdiTransform.ProfessionalClaim1.txt"))
     {
         var parser = new X12Parser();
         var interchanges = parser.ParseMultiple(stream);
         var service = new ProfessionalClaimToHcfa1500FormTransformation("");
         ClaimDocument doc = service.Transform837ToClaimDocument(interchanges.First());
         var claim = doc.Claims.First();
         claim.ServiceLines[0].Procedure.ProcedureCode = "87070";
         claim.ServiceLines[1].Procedure.ProcedureCode = "99213";
         claim.BillingProvider.TaxId = "12345";
         XmlDocument newdoc = TransformClaimDocumentTo837(interchanges.First(), claim);
         string x12 = parser.TransformToX12(newdoc.OuterXml);
         var modifiedInterchange = parser.ParseMultiple(x12).First();
         string newX12 = modifiedInterchange.SerializeToX12(true);
         Debug.WriteLine("After passing through interchange object:");
         Debug.WriteLine(newX12);
     }
 }