Пример #1
0
        /// <summary>
        /// Reinterperits the billable procedure table as a dictionary between
        /// a billable procedure (one per day:patient:code) and a list of the pks
        /// for each procedure which share the attributes.
        /// </summary>
        /// <param name="target_month">The current month</param>
        /// <returns>The dictionary.</returns>
        private Dictionary <BillableProcedure, List <int> > BillingDBAsDict(int target_month)
        {
            //Creates a new dictionary
            Dictionary <BillableProcedure, List <int> > dict = new Dictionary <BillableProcedure, List <int> >();

            //Loop through the keys
            foreach (object pk in procedures.Keys)
            {
                //Create a new billable procedure
                BillableProcedure bp = new BillableProcedure();

                //Save the aptid
                int aptid = (int)procedures[pk, "AppointmentID"];

                //Save the month
                int month = (int)appointments[aptid, "Month"];

                //If the month isnt the current month
                if (month != target_month)
                {
                    continue;
                }

                //Obtain all of the information needed
                bp.year  = CalendarManager.ConvertMonthToYear(ref month);
                bp.month = month;

                bp.day = (int)appointments[aptid, "Day"];

                bp.HCN = (string)people[appointments[aptid, "PatientID"], "HCN"];

                bp.code = (string)procedures[pk, "BillingCode"];

                bp.sex = people[appointments[aptid, "PatientID"], "sex"].ToString()[0];

                bp.fee = (string)billingMaster[bp.code, "DollarAmount"];

                //Create a list that will hold this information
                List <int> pks = dict.ContainsKey(bp) ? dict[bp] : new List <int>();

                //Add the information to the list
                pks.Add((int)pk);

                //Save the information into a dictionary
                dict[bp] = pks;
            }

            return(dict);
        }
Пример #2
0
        /// <summary>
        /// Matches the procedures
        /// </summary>
        /// <param name="month"> The month being searched </param>
        /// <param name="response"> The response being created </param>
        /// <param name="logger"> Used to log any errors or success messages </param>
        ///

        private void MatchProcedures(int month, Dictionary <BillableProcedure, List <string> > response, Logging logger = null)
        {
            //Create a dictionary of pks
            Dictionary <BillableProcedure, List <int> > pks = BillingDBAsDict(month);

            //Set information to variable
            int year = CalendarManager.ConvertMonthToYear(ref month);

            //Loop through each billable procedure
            foreach (BillableProcedure bp in response.Keys)
            {
                //If the month or the year doesn't match
                if (bp.month != month || bp.year != year)
                {
                    logger?.Log(LoggingInfo.ErrorLevel.ERROR, "Invalid date for response");
                    continue;
                }

                //If the response doesn't match
                if (!response.ContainsKey(bp))
                {
                    logger?.Log(LoggingInfo.ErrorLevel.WARN, "Could not match " + bp + " to known procedures");
                    continue;
                }

                //If the count of pks doesn't match the count of responses
                if (pks[bp].Count != response[bp].Count)
                {
                    logger?.Log(LoggingInfo.ErrorLevel.ERROR, "Billable procedure response and database data mismatched for procedure " + bp);
                    continue;
                }

                //Save information into a variable
                var zipped = response[bp].Zip(pks[bp], (s, i) => new Tuple <int, string>(i, s));

                //Loop through each procedure
                foreach (Tuple <int, string> procedure in zipped)
                {
                    procedures[procedure.Item1, "CodeResponse"] = (BillingCodeResponse)Enum.Parse(typeof(BillingCodeResponse), procedure.Item2);
                }

                //Log the success
                logger?.Log(LoggingInfo.ErrorLevel.INFO, "Successfully merged billable procedures for " + pks[bp] + " and " + response[bp]);
            }

            //Log that done
            logger?.Log(LoggingInfo.ErrorLevel.INFO, "Finished merging billable procedure responses");
        }
Пример #3
0
        /// <summary>
        /// Generates a billable procedure line.
        /// </summary>
        /// <remarks>
        ///
        /// Format:
        ///
        /// 20171120 1234567890KV F   A665 00000913500
        /// YYYYMMDD HCN          Sex Code Price
        ///
        /// Note: there are no spaces in the actual line
        ///
        /// </remarks>
        /// <param name="appointment"> The appointment ID</param>
        /// <param name="procedure"> The proceduer ID</param>
        /// <returns>Full billing code</returns>
        public string GenerateBillableProcedureLine(int appointment, int procedure)
        {
            //Get the date information
            int      month = (int)appointments[appointment, "Month"];
            DateTime date  = new DateTime(CalendarManager.ConvertMonthToYear(ref month), month, (int)appointments[appointment, "Day"]);

            //Get the patient pk and store in object
            object patient_pk = appointments[appointment, "PatientID"];

            //Gets the HCN at corresponding pk
            string HCN = (string)people[patient_pk, "HCN"];

            //Gets the sex at corresponding pk
            SexTypes sex = (SexTypes)people[patient_pk, "sex"];

            //Gets the fee code at corresponding pk
            string code = (string)procedures[procedure, "BillingCode"];

            //Gets the fee price at corresponding pk
            string price = (string)billingMaster[code, "DollarAmount"];

            return(date.ToString("yyyyMMdd") + HCN + sex.ToString() + code + price);
        }