Ejemplo n.º 1
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.º 2
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\Images\HCFA1500_Red.gif"),
                new InstitutionalClaimToUB04ClaimFormTransformation(@"..\..\..\tests\OopFactory.X12.Hipaa.Tests.Unit\Claims\Images\UB04_Red.gif"),
                new ProfessionalClaimToHcfa1500FormTransformation(@"..\..\..\tests\OopFactory.X12.Hipaa.Tests.Unit\Claims\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
        }