Ejemplo n.º 1
0
        public void X12ToHcfaPdfTest()
        {
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OopFactory.X12.Hipaa.Tests.Unit.Claims.TestData.ProfessionalClaim1.txt");

            // new up a ClaimTransformationService object
            var service = new ClaimFormTransformationService(
                new ProfessionalClaimToHcfa1500FormTransformation(@"..\..\..\tests\OopFactory.X12.Hipaa.Tests.Unit\Claims\TestData\Images\HCFA1500_Red.gif"),
                new InstitutionalClaimToUB04ClaimFormTransformation(@"..\..\..\tests\OopFactory.X12.Hipaa.Tests.Unit\Claims\TestDate\Images\UB04_Red.gif"),
                new ProfessionalClaimToHcfa1500FormTransformation(@"..\..\..\tests\OopFactory.X12.Hipaa.Tests.Unit\Claims\TestDate\Images\HCFA1500_Red.gif")
                );

            ClaimDocument document = service.Transform837ToClaimDocument(stream);

            XmlDocument foDocument = new XmlDocument();
            string      foXml      = service.TransformClaimDocumentToFoXml(document);

            foDocument.LoadXml(foXml);

#if DEBUG
            var driver = Fonet.FonetDriver.Make();

            FileStream outputFile = new FileStream("c:\\Temp\\Pdfs\\ProfessionalClaim1.pdf", FileMode.Create, FileAccess.Write);
            driver.Render(foDocument, outputFile);
#endif
        }
Ejemplo n.º 2
0
        public void X12ToUbPdfTest()
        {
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OopFactory.X12.Hipaa.Tests.Unit.Claims.TestData.InstitutionalClaim5010.txt");

            var transformation = new InstitutionalClaimToUB04ClaimFormTransformation(@"..\..\..\tests\OopFactory.X12.Hipaa.Tests.Unit\Claims\Images\UB04_Red.gif");


            // new up a ClaimTransformationService object
            var service = new ClaimFormTransformationService(transformation, transformation, transformation);

            ClaimDocument document = service.Transform837ToClaimDocument(stream);

            var ub04 = transformation.TransformClaimToUB04(document.Claims.First());

            Trace.WriteLine(ub04.Serialize());

            XmlDocument foDocument = new XmlDocument();
            string      foXml      = service.TransformClaimDocumentToFoXml(document);

            foDocument.LoadXml(foXml);

#if DEBUG
            var driver = Fonet.FonetDriver.Make();

            FileStream outputFile = new FileStream("c:\\Temp\\Pdfs\\InstitutionalClaim5010.pdf", FileMode.Create, FileAccess.Write);
            driver.Render(foDocument, outputFile);
#endif
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var opts = new ExecutionOptions(args);

            var service = new ClaimFormTransformationService(
                new ProfessionalClaimToHcfa1500FormTransformation("HCFA1500_Red.gif"),
                new InstitutionalClaimToUB04ClaimFormTransformation("UB04_Red.gif"),
                new DentalClaimToJ400FormTransformation("ADAJ400_Red.gif"));

            foreach (var filename in Directory.GetFiles(opts.Path, opts.SearchPattern, SearchOption.TopDirectoryOnly))
            {
                try
                {
#if DEBUG
                    FileStream stream      = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    var        parser      = new X12.Parsing.X12Parser();
                    var        interchange = parser.Parse(stream);
                    File.WriteAllText(filename + ".dat", interchange.SerializeToX12(true));
                    stream.Close();
#endif
                    DateTime   start           = DateTime.Now;
                    FileStream inputFilestream = new FileStream(filename, FileMode.Open, FileAccess.Read);

                    var claimDoc = service.Transform837ToClaimDocument(inputFilestream);

                    FileInfo      fi = new FileInfo(filename);
                    DirectoryInfo di = new DirectoryInfo(opts.OutputPath);

                    if (opts.MakeXml)
                    {
                        string outputFilename = string.Format("{0}\\{1}.xml", di.FullName, fi.Name);

                        string xml = claimDoc.Serialize();
                        xml = xml.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");
                        File.WriteAllText(outputFilename, xml);
                    }

                    if (opts.MakePdf)
                    {
                        string outputFilename = string.Format("{0}\\{1}.pdf", di.FullName, fi.Name);
                        using (FileStream pdfOutput = new FileStream(outputFilename, FileMode.Create, FileAccess.Write))
                        {
                            XmlDocument foDoc = new XmlDocument();
                            string      foXml = service.TransformClaimDocumentToFoXml(claimDoc);
                            foDoc.LoadXml(foXml);

                            var driver = Fonet.FonetDriver.Make();
                            driver.Render(foDoc, pdfOutput);
                            pdfOutput.Close();
                        }
                    }

                    opts.WriteLine(string.Format("{0} parsed in {1}.", filename, DateTime.Now - start));
                }
                catch (Exception exc)
                {
                    opts.WriteLine(string.Format("Exception occurred: {0}.  {1}.  {2}", exc.GetType().FullName, exc.Message, exc.StackTrace));
                }
            }
        }
Ejemplo n.º 4
0
        public void X12ToUbPdfLayoutTest()
        {
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("X12.Hipaa.Tests.Unit.Claims.TestData.InstitutionalClaim5010.txt");

            var transformation = new InstitutionalClaimToUb04ClaimFormTransformation($"{TestImageDirectory}\\UB04_Red.gif");

            // new up a ClaimTransformationService object
            var service = new ClaimFormTransformationService(transformation, transformation, transformation);

            ClaimDocument document = service.Transform837ToClaimDocument(stream);

            var    fonetDocument = new XmlDocument();
            string fonetXml      = service.TransformClaimDocumentToFoXml(document);

            fonetDocument.LoadXml(fonetXml);
        }
Ejemplo n.º 5
0
        public List <string> Parse(List <Exception> exceptions)
        {
            var result = new List <string>();

            X12Parser parser = new X12Parser();
            ClaimFormTransformationService service = new ClaimFormTransformationService(
                new ProfessionalClaimToHcfa1500FormTransformation(""),
                new InstitutionalClaimToUB04ClaimFormTransformation(""),
                new DentalClaimToJ400FormTransformation(""),
                parser
                );

            try
            {
                Stream        fileStream = _fileData.GetReadStream();
                ClaimDocument claimDoc   = service.Transform837ToClaimDocument(fileStream);

                XmlSerializer xs = new XmlSerializer(typeof(Claim));
                foreach (Claim claim in claimDoc.Claims)
                {
                    MemoryStream ms = new MemoryStream();
                    xs.Serialize(ms, claim);
                    ms.Seek(0, SeekOrigin.Begin);
                    StreamReader sr       = new StreamReader(ms);
                    string       claimXml = sr.ReadToEnd();
                    result.Add(claimXml);
                    //sr.Dispose();
                    //ms.Dispose();
                }
            }
            catch (Exception ex)
            {
                exceptions.Add(ex);
                throw new Exception("Aborting import of EDI file");
            }

            return(result);
        }
Ejemplo n.º 6
0
        public void X12ToUbPdfLayoutTest()
        {
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OopFactory.X12.Hipaa.Tests.Unit.Claims.TestData.InstitutionalClaim5010.txt");


            var transformation = new InstitutionalClaimToUB04ClaimFormTransformation($"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}/Claims/TestData/Images/UB04_Red.gif");

            // new up a ClaimTransformationService object
            var service = new ClaimFormTransformationService(transformation, transformation, transformation);

            ClaimDocument document = service.Transform837ToClaimDocument(stream);

            XmlDocument foDocument = new XmlDocument();
            string      foXml      = service.TransformClaimDocumentToFoXml(document);

            foDocument.LoadXml(foXml);

#if DEBUG
            var driver = Fonet.FonetDriver.Make();

            FileStream outputFile = new FileStream("c:\\Temp\\Pdfs\\InstitutionalClaimPlaceholders.pdf", FileMode.Create, FileAccess.Write);
            driver.Render(foDocument, outputFile);
#endif
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            bool throwException = Convert.ToBoolean(ConfigurationManager.AppSettings["ThrowExceptionOnSyntaxErrors"]);

            //var opts = new ExecutionOptions(args);
            var institutionalClaimToUb04ClaimFormTransformation = new InstitutionalClaimToUb04ClaimFormTransformation("UB04_Red.gif");
            var service = new ClaimFormTransformationService(
                new ProfessionalClaimToHcfa1500FormTransformation("HCFA1500_Red.gif"),
                institutionalClaimToUb04ClaimFormTransformation,
                new DentalClaimToJ400FormTransformation("ADAJ400_Red.gif"),
                new X12Parser(throwException));



            string filename   = @"E:\Projects\_temp\EdiFiles\EDI_INS_202009131900.edi";
            string OutputPath = @"E:\Projects\_temp\Output";
            bool   MakePdf    = true;

            try
            {
#if DEBUG
                var stream      = new FileStream(filename, FileMode.Open, FileAccess.Read);
                var parser      = new X12Parser();
                var interchange = parser.ParseMultiple(stream).First();
                File.WriteAllText(filename + ".dat", interchange.SerializeToX12(true));
                stream.Close();
#endif
                DateTime start           = DateTime.Now;
                var      inputFilestream = new FileStream(filename, FileMode.Open, FileAccess.Read);

                var revenueDictionary = new Dictionary <string, string>
                {
                    ["0572"] = "Test Code"
                };
                service.FillRevenueCodeDescriptionMapping(revenueDictionary);
                var claimDoc = service.Transform837ToClaimDocument(inputFilestream);
                institutionalClaimToUb04ClaimFormTransformation.PerPageTotalChargesView = true;
                var fi = new FileInfo(filename);
                var di = new DirectoryInfo(OutputPath);

                //if (opts.MakeXml)
                //{
                //    string outputFilename = $"{di.FullName}\\{fi.Name}.xml";
                //    string xml = claimDoc.Serialize();
                //    xml = xml.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");
                //    File.WriteAllText(outputFilename, xml);
                //}

                if (MakePdf)
                {
                    string outputFilename = $"{di.FullName}\\{fi.Name}.pdf";
                    using (FileStream pdfOutput = new FileStream(outputFilename, FileMode.Create, FileAccess.Write))
                    {
                        var    foDoc = new XmlDocument();
                        string foXml = service.TransformClaimDocumentToFoXml(claimDoc);
                        foDoc.LoadXml(foXml);

                        FonetDriver driver = FonetDriver.Make();
                        driver.Render(foDoc, pdfOutput);
                        pdfOutput.Close();
                    }
                }

                Console.WriteLine($"{filename} parsed in {DateTime.Now - start}.");
            }
            catch (Exception exc)
            {
                Console.WriteLine($"Exception occurred: {exc.GetType().FullName}.  {exc.Message}.  {exc.StackTrace}");
            }
            //    var stream = new FileStream(filename, FileMode.Open, FileAccess.Read);
            //    var parser = new X12Parser();
            //    var interchange = parser.ParseMultiple(stream).First();
            //    File.WriteAllText(filename + ".dat", interchange.SerializeToX12(true));
            //    stream.Close();

            //}
            //private ClaimDocument Transform837ToClaimDocument(Stream stream)
            //{
            //    var parser = new X12Parser();
            //    var interchanges = parser.ParseMultiple(stream);
            //    var doc = new ClaimDocument();
            //    foreach (var interchange in interchanges)
            //    {
            //        var thisDoc = Transform837ToClaimDocument(interchange);
            //        this.AddRevenueCodeDescription(thisDoc);
            //        doc.Claims.AddRange(thisDoc.Claims);
            //    }

            //    return doc;
            //}
            Console.ReadLine();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            bool throwException = Convert.ToBoolean(ConfigurationManager.AppSettings["ThrowExceptionOnSyntaxErrors"]);

            var opts = new ExecutionOptions(args);
            InstitutionalClaimToUB04ClaimFormTransformation institutionalClaimToUB04ClaimFormTransformation = new InstitutionalClaimToUB04ClaimFormTransformation("UB04_Red.gif");
            var service = new ClaimFormTransformationService(
                new ProfessionalClaimToHcfa1500FormTransformation("HCFA1500_Red.gif"),
                institutionalClaimToUB04ClaimFormTransformation,
                new DentalClaimToJ400FormTransformation("ADAJ400_Red.gif"),
                new X12Parser(throwException));

            foreach (var filename in Directory.GetFiles(opts.Path, opts.SearchPattern, SearchOption.TopDirectoryOnly))
            {
                try
                {
#if DEBUG
                    FileStream stream      = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    var        parser      = new X12.Parsing.X12Parser();
                    var        interchange = parser.ParseMultiple(stream).First();
                    File.WriteAllText(filename + ".dat", interchange.SerializeToX12(true));
                    stream.Close();
#endif
                    DateTime   start           = DateTime.Now;
                    FileStream inputFilestream = new FileStream(filename, FileMode.Open, FileAccess.Read);

                    Dictionary <string, string> revenueDictionary = new Dictionary <string, string>();
                    revenueDictionary["0572"] = "Test Code";
                    service.FillRevenueCodeDescriptionMapping(revenueDictionary);
                    var claimDoc = service.Transform837ToClaimDocument(inputFilestream);
                    institutionalClaimToUB04ClaimFormTransformation.PerPageTotalChargesView = true;
                    FileInfo      fi = new FileInfo(filename);
                    DirectoryInfo di = new DirectoryInfo(opts.OutputPath);

                    if (opts.MakeXml)
                    {
                        string outputFilename = string.Format("{0}\\{1}.xml", di.FullName, fi.Name);

                        string xml = claimDoc.Serialize();
                        xml = xml.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");
                        File.WriteAllText(outputFilename, xml);
                    }

                    if (opts.MakePdf)
                    {
                        string outputFilename = string.Format("{0}\\{1}.pdf", di.FullName, fi.Name);
                        using (FileStream pdfOutput = new FileStream(outputFilename, FileMode.Create, FileAccess.Write))
                        {
                            XmlDocument foDoc = new XmlDocument();
                            string      foXml = service.TransformClaimDocumentToFoXml(claimDoc);
                            foDoc.LoadXml(foXml);

                            var driver = Fonet.FonetDriver.Make();
                            driver.Render(foDoc, pdfOutput);
                            pdfOutput.Close();
                        }
                    }

                    opts.WriteLine(string.Format("{0} parsed in {1}.", filename, DateTime.Now - start));
                }
                catch (Exception exc)
                {
                    opts.WriteLine(string.Format("Exception occurred: {0}.  {1}.  {2}", exc.GetType().FullName, exc.Message, exc.StackTrace));
                }
            }
        }