Example #1
0
        ///<summary>Replaces ImportCanadaFeeSchedule.  Imports a canadian fee schedule. Called only in FormFeeSchedTools, located here to allow unit testing.
        ///Fires FeeSchedEvents for a progress bar.</summary>
        public static List <Fee> ImportCanadaFeeSchedule2(FeeSched feeSched, string feeData, long clinicNum, long provNum, out int numImported, out int numSkipped)
        {
            //No need to check RemotingRole; no call to db.
            string[] feeLines = feeData.Split('\n');
            numImported = 0;
            numSkipped  = 0;
            List <Fee> listFees         = Fees.GetListExact(feeSched.FeeSchedNum, clinicNum, provNum);
            List <Fee> listFeesImported = new List <Fee>(listFees);

            for (int i = 0; i < feeLines.Length; i++)
            {
                string[] fields = feeLines[i].Split('\t');
                if (fields.Length > 1)               // && fields[1]!=""){//we no longer skip blank fees
                {
                    string procCode = fields[0];
                    if (ProcedureCodes.IsValidCode(procCode))
                    {
                        long codeNum = ProcedureCodes.GetCodeNum(procCode);
                        Fee  fee     = Fees.GetFee(codeNum, feeSched.FeeSchedNum, clinicNum, provNum, listFees); //gets best match
                        if (fields[1] == "")                                                                     //an empty entry will delete an existing fee, but not insert a blank override
                        {
                            if (fee == null)                                                                     //nothing to do

                            {
                            }
                            else
                            {
                                //doesn't matter if the existing fee is an override or not.
                                Fees.Delete(fee);
                                listFeesImported.Remove(fee);
                            }
                        }
                        else                          //value found in text file
                        {
                            if (fee == null)          //no current fee
                            {
                                fee           = new Fee();
                                fee.Amount    = PIn.Double(fields[1], doUseEnUSFormat: true);                          //The fees are always in the format "1.00" so we need to parse accordingly.
                                fee.FeeSched  = feeSched.FeeSchedNum;
                                fee.CodeNum   = codeNum;
                                fee.ClinicNum = clinicNum;
                                fee.ProvNum   = provNum;
                                Fees.Insert(fee);
                                listFeesImported.Add(fee);
                            }
                            else
                            {
                                fee.Amount = PIn.Double(fields[1], doUseEnUSFormat: true);
                                Fees.Update(fee);
                            }
                        }
                        numImported++;
                    }
                    else
                    {
                        numSkipped++;
                    }
                    FeeSchedEvent.Fire(ODEventType.FeeSched,
                                       new ProgressBarHelper(Lans.g("FeeScheds", "Processing fees, please wait") + "...", "", (numImported + numSkipped), feeLines.Length,
                                                             ProgBarStyle.Continuous));
                }
            }
            return(listFeesImported);
        }