///<summary>Exports a fee schedule. Called only in FormFeeSchedTools. Fires FeeSchedEvents for a progress bar.</summary> public static void ExportFeeSchedule(long feeSchedNum, long clinicNum, long provNum, string fileName) { //No need to check RemotingRole; no call to db. //CreateText will overwrite any content if the file already exists. using (StreamWriter sr = File.CreateText(fileName)) { //Get every single procedure code from the cache which will already be ordered by ProcCat and then ProcCode. //Even if the code does not have a fee, include it in the export because that will trigger a 'deletion' when importing over other schedules. int rowNum = 0; List <ProcedureCode> listProcCodes = ProcedureCodes.GetListDeep(); List <Fee> listFees = Fees.GetListForScheds(feeSchedNum, clinicNum, provNum);//gets best matches foreach (ProcedureCode procCode in listProcCodes) { //Get the best matching fee (not exact match) for the current selections. Fee fee = Fees.GetFee(procCode.CodeNum, feeSchedNum, clinicNum, provNum, listFees); sr.Write(procCode.ProcCode + "\t"); if (fee != null && fee.Amount != -1) { sr.Write(fee.Amount.ToString("n")); } sr.Write("\t"); sr.Write(procCode.AbbrDesc + "\t"); sr.WriteLine(procCode.Descript); double percent = ((rowNum * 1.0) / listProcCodes.Count * 100); FeeSchedEvent.Fire(ODEventType.FeeSched, new ProgressBarHelper( "Exporting fees, please wait...", percent.ToString(), blockValue: (int)percent, progressStyle: ProgBarStyle.Continuous)); rowNum++; } } }
///<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); }