示例#1
0
        /**
         * \brief <b>Brief Description</b> - Billing<b> <i>class method</i></b> - This will analyze the response file sent from the Ministry of Health.
         * \details <b>Details</b>
         *
         * The Ministry of Health will provide a response file to any submitted MonthlyBillingFile. The file will be analyzed to look for
         * codes sent back from the ministry. It will look for codes; <i>PAID</i>, <i>DECL(Declined)</i>, <i>FHCV(Failed Validation)</i>, <i>CMOH(Contact MoH)</i>.
         * It will update the monthly summary and will also flag the appointments for review if the code sent back is <b>FHCV</b> or <b>CMOH</b>.
         *
         * \return - <b>List<string></string></b> - this method will return the summarized monthly bill summary
         */
        public List <string> ReconcileMonthlyBilling(string monthFilePath = "govFile.txt")
        {
            string[] fn       = monthFilePath.Split('\\');
            string   tmpYear  = fn.Last().Substring(0, 4);
            string   tmpMonth = fn.Last().Substring(4, 2);

            double totalBilled  = 0;
            double totalRcvd    = 0;
            int    totalFlagged = 0;
            Dictionary <string, string[]> reconciledAppointment = FileIO.GetTableFromFile(monthFilePath, FileIO.FileInputFormat.GovernmentResponse);

            Dictionary <string, double> theSummary = new Dictionary <string, double>();
            List <string> theSummaryDisplayed      = new List <string>();

            theSummary.Add("TotalEncounters", reconciledAppointment.Count);

            foreach (KeyValuePair <string, string[]> data in reconciledAppointment)
            {
                try
                {
                    totalBilled = totalBilled + (Convert.ToDouble(data.Value[4]));
                    if (data.Value[5] == "PAID")
                    {
                        totalRcvd = totalRcvd + (Convert.ToDouble(data.Value[4]));
                    }
                    else if (data.Value[5] == "FHCV" || data.Value[5] == "CMOH")
                    {
                        totalFlagged++;
                        flaggedEncounters.Add(data.Value);
                    }
                }
                catch (FormatException f) { Logging.Log(f, "Billing", "ReconcileMonthlyBilling", "FAILED CONVERTING STRING TO DOUBLE - EXCEPTION"); }
                catch (OverflowException o) { Logging.Log(o, "Billing", "ReconcileMonthlyBilling", "FAILED CONVERTING STRING TO DOUBLE - EXCEPTION"); }
            }
            totalBilled = totalBilled / 10000;
            totalRcvd   = totalRcvd / 10000;

            theSummary.Add("TotalBilled", totalBilled);
            theSummaryDisplayed.Add("Total Billed : " + totalBilled.ToString("C2", CultureInfo.CurrentCulture));

            theSummary.Add("TotalReceived", totalRcvd);
            theSummaryDisplayed.Add("Total Received : " + totalRcvd.ToString("C2", CultureInfo.CurrentCulture));

            theSummary.Add("ReceivedPercentage", ((totalRcvd / totalBilled) * 100));
            theSummaryDisplayed.Add("Received Percentage : " + ((totalRcvd / totalBilled) * 100).ToString("C2", CultureInfo.CurrentCulture));

            theSummary.Add("AverageBilling", (totalRcvd / reconciledAppointment.Count));
            theSummaryDisplayed.Add("Average Billing : " + (totalRcvd / reconciledAppointment.Count).ToString("C2", CultureInfo.CurrentCulture));

            theSummary.Add("NumberOfFollowUps", totalFlagged);
            theSummaryDisplayed.Add("Number of Follow Ups : " + totalFlagged.ToString());

            Demographics demographics = new Demographics();

            foreach (string[] s in flaggedEncounters)
            {
                Patient p = demographics.GetPatientByHCN(s[1]);
                if (p != null)
                {
                    theSummaryDisplayed.Add(string.Format("{0} - {1},{2} - {3}", s[0], p.LastName, p.FirstName, s[3]));
                }
            }

            Logging.Log("Billing", "ReconcileMonthlyBilling", ("Summary displayed for Month: " + tmpMonth + " Year: " + tmpYear));
            return(theSummaryDisplayed);
        }