///<summary></summary> public static void Update(FeeSched feeSched) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(),feeSched); return; } Crud.FeeSchedCrud.Update(feeSched); }
///<summary>Returns whether the FeeSched has IsGlobal set to true. Defaults to false if not found.</summary> public static bool IsGlobal(long feeSchedNum) { //No need to check RemotingRole; no call to db. FeeSched feeSched = GetFirstOrDefault(x => x.FeeSchedNum == feeSchedNum); return(feeSched == null ? false : feeSched.IsGlobal); }
///<summary>Returns whether the FeeSched is hidden. Defaults to true if not found.</summary> public static bool GetIsHidden(long feeSchedNum) { //No need to check RemotingRole; no call to db. FeeSched feeSched = GetFirstOrDefault(x => x.FeeSchedNum == feeSchedNum); return(feeSched == null ? true : feeSched.IsHidden); }
///<summary>If the named fee schedule does not exist, then it will be created. It always returns the defnum for the feesched used, regardless of whether it already existed. procCode must have already been tested for valid code, and feeSchedName must not be blank.</summary> public static long ImportTrojan(string procCode,double amt,string feeSchedName) { FeeSched feeSched=FeeScheds.GetByExactName(feeSchedName); //if isManaged, then this should be done differently from here on out. if(feeSched==null){ //add the new fee schedule feeSched=new FeeSched(); feeSched.ItemOrder=FeeSchedC.ListLong.Count; feeSched.Description=feeSchedName; feeSched.FeeSchedType=FeeScheduleType.Normal; //feeSched.IsNew=true; FeeScheds.Insert(feeSched); //Cache.Refresh(InvalidType.FeeScheds); //Fees.Refresh(); DataValid.SetInvalid(InvalidType.FeeScheds, InvalidType.Fees); } if(feeSched.IsHidden){ feeSched.IsHidden=false;//unhide it FeeScheds.Update(feeSched); DataValid.SetInvalid(InvalidType.FeeScheds); } Fee fee=Fees.GetFee(ProcedureCodes.GetCodeNum(procCode),feeSched.FeeSchedNum); if(fee==null) { fee=new Fee(); fee.Amount=amt; fee.FeeSched=feeSched.FeeSchedNum; fee.CodeNum=ProcedureCodes.GetCodeNum(procCode); Fees.Insert(fee); } else{ fee.Amount=amt; Fees.Update(fee); } return feeSched.FeeSchedNum; }
///<summary></summary> public static long Insert(FeeSched feeSched) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { feeSched.FeeSchedNum=Meth.GetLong(MethodBase.GetCurrentMethod(),feeSched); return feeSched.FeeSchedNum; } return Crud.FeeSchedCrud.Insert(feeSched); }
///<summary>Returns feeSchedNum</summary> public static long CreateFeeSched(FeeScheduleType feeSchedType,string suffix){ FeeSched feeSched=new FeeSched(); feeSched.FeeSchedType=feeSchedType; feeSched.Description="FeeSched"+suffix; FeeScheds.Insert(feeSched); FeeScheds.RefreshCache(); return feeSched.FeeSchedNum; }
///<summary></summary> public static void Update(FeeSched feeSched) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), feeSched); return; } Crud.FeeSchedCrud.Update(feeSched); }
///<summary></summary> public static long Insert(FeeSched feeSched) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { feeSched.FeeSchedNum = Meth.GetLong(MethodBase.GetCurrentMethod(), feeSched); return(feeSched.FeeSchedNum); } return(Crud.FeeSchedCrud.Insert(feeSched)); }
///<summary></summary> public static long Insert(FeeSched feeSched) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { feeSched.FeeSchedNum = Meth.GetLong(MethodBase.GetCurrentMethod(), feeSched); return(feeSched.FeeSchedNum); } //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS. feeSched.SecUserNumEntry = Security.CurUser.UserNum; return(Crud.FeeSchedCrud.Insert(feeSched)); }
///<summary>Returns the description of the fee schedule. Appends (hidden) if the fee schedule has been hidden.</summary> public static string GetDescription(long feeSchedNum) { //No need to check RemotingRole; no call to db. string feeSchedDesc = ""; FeeSched feeSched = GetFirstOrDefault(x => x.FeeSchedNum == feeSchedNum); if (feeSched != null) { feeSchedDesc = feeSched.Description + (feeSched.IsHidden ? " (" + Lans.g("FeeScheds", "hidden") + ")" : ""); } return(feeSchedDesc); }
///<summary></summary> public static long Insert(FeeSched feeSched) { if (RemotingClient.RemotingRole != RemotingRole.ServerWeb) { feeSched.SecUserNumEntry = Security.CurUser.UserNum; //must be before normal remoting role check to get user at workstation } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { feeSched.FeeSchedNum = Meth.GetLong(MethodBase.GetCurrentMethod(), feeSched); return(feeSched.FeeSchedNum); } return(Crud.FeeSchedCrud.Insert(feeSched)); }
///<summary>Increases the fee schedule by percent. Round should be the number of decimal places, either 0,1,or 2. ///Returns listFees back after increasing the fees from the passed in fee schedule information.</summary> public static List <Fee> Increase(long feeSchedNum, int percent, int round, List <Fee> listFees, long clinicNum, long provNum) { //No need to check RemotingRole; no call to db. FeeSched feeSched = FeeScheds.GetFirst(x => x.FeeSchedNum == feeSchedNum); List <long> listCodeNums = new List <long>(); //Contains only the fee codeNums that have been increased. Used for keeping track. foreach (Fee feeCur in listFees) { if (listCodeNums.Contains(feeCur.CodeNum)) { continue; //Skip the fee if it's associated to a procedure code that has already been increased / added. } //The best match isn't 0, and we haven't already done this CodeNum if (feeCur != null && feeCur.Amount != 0) { double newVal = (double)feeCur.Amount * (1 + (double)percent / 100); if (round > 0) { newVal = Math.Round(newVal, round); } else { newVal = Math.Round(newVal, MidpointRounding.AwayFromZero); } //The fee showing in the fee schedule is not a perfect match. Make a new one that is. //E.g. We are increasing all fees for clinicNum of 1 and provNum of 5 and the best match found was for clinicNum of 3 and provNum of 7. //We would then need to make a copy of that fee, increase it, and then associate it to the clinicNum and provNum passed in (1 and 5). if (!feeSched.IsGlobal && (feeCur.ClinicNum != clinicNum || feeCur.ProvNum != provNum)) { Fee fee = new Fee(); fee.Amount = newVal; fee.CodeNum = feeCur.CodeNum; fee.ClinicNum = clinicNum; fee.ProvNum = provNum; fee.FeeSched = feeSchedNum; listFees.Add(fee); } else //Just update the match found. { feeCur.Amount = newVal; } } listCodeNums.Add(feeCur.CodeNum); } return(listFees); }
///<summary>This sorts feescheds by type and alphabetically.</summary> private static int CompareFeeScheds(FeeSched feeSched1,FeeSched feeSched2) { if(feeSched1==null){ if(feeSched2==null){ return 0;//both null, so equal } else{ return -1; } } if(feeSched2==null){ return 1; } if(feeSched1.FeeSchedType!=feeSched2.FeeSchedType){ return feeSched1.FeeSchedType.CompareTo(feeSched2.FeeSchedType); } return feeSched1.Description.CompareTo(feeSched2.Description); }
///<summary>Used from butGetElectronic_Click and from butOK_Click. Returns false if unable to complete. Also fills SubCur if not null.</summary> private bool FillPlanCurFromForm(){ if(textDateEffect.errorProvider1.GetError(textDateEffect)!="" ||textDateTerm.errorProvider1.GetError(textDateTerm)!="" ||textDentaide.errorProvider1.GetError(textDentaide)!="" ) { MsgBox.Show(this,"Please fix data entry errors first."); return false; } if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA if(textPlanFlag.Text!="" && textPlanFlag.Text!="A" && textPlanFlag.Text!="V" && textPlanFlag.Text!="N") { MsgBox.Show(this,"Plan flag must be A, V, N, or blank."); return false; } if(textPlanFlag.Text=="") { if(checkIsPMP.Checked) { MsgBox.Show(this,"The provincial medical plan checkbox must be unchecked when the plan flag is blank."); return false; } } else { if(!checkIsPMP.Checked) { MsgBox.Show(this,"The provincial medical plan checkbox must be checked when the plan flag is not blank."); return false; } if(textPlanFlag.Text=="A") { if(textCanadianDiagCode.Text=="" || textCanadianDiagCode.Text!=Eclaims.Canadian.TidyAN(textCanadianDiagCode.Text,textCanadianDiagCode.Text.Length,true)) { MsgBox.Show(this,"When plan flag is set to A, diagnostic code must be set and must be 6 characters or less in length."); return false; } if(textCanadianInstCode.Text=="" || textCanadianInstCode.Text!=Eclaims.Canadian.TidyAN(textCanadianInstCode.Text,textCanadianInstCode.Text.Length,true)) { MsgBox.Show(this,"When plan flag is set to A, institution code must be set and must be 6 characters or less in length."); return false; } } } } if(textSubscriberID.Text=="" && SubCur!=null) { MsgBox.Show(this,"Subscriber ID not allowed to be blank."); return false; } if(textCarrier.Text=="") { MsgBox.Show(this,"Carrier not allowed to be blank."); return false; } if(PatPlanCur!=null && textOrdinal.errorProvider1.GetError(textOrdinal)!=""){ MsgBox.Show(this,"Please fix data entry errors first."); return false; } if(SubCur!=null) { //Subscriber: Only changed when user clicks change button. SubCur.SubscriberID=textSubscriberID.Text; SubCur.DateEffective=PIn.Date(textDateEffect.Text); SubCur.DateTerm=PIn.Date(textDateTerm.Text); SubCur.ReleaseInfo=checkRelease.Checked; SubCur.AssignBen=checkAssign.Checked; SubCur.SubscNote=textSubscNote.Text; //MonthRenew already handled inside benefit window. } GetEmployerNum(); PlanCur.GroupName=textGroupName.Text; PlanCur.GroupNum=textGroupNum.Text; PlanCur.RxBIN=textBIN.Text; PlanCur.DivisionNo=textDivisionNo.Text;//only visible in Canada //carrier----------------------------------------------------------------------------------------------------- CarrierCur=new Carrier(); CarrierCur.CarrierName=textCarrier.Text; CarrierCur.Phone=textPhone.Text; CarrierCur.Address=textAddress.Text; CarrierCur.Address2=textAddress2.Text; CarrierCur.City=textCity.Text; CarrierCur.State=textState.Text; CarrierCur.Zip=textZip.Text; CarrierCur.ElectID=textElectID.Text; CarrierCur.NoSendElect=checkNoSendElect.Checked; if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA bool carrierFound=true; try { CarrierCur=Carriers.GetIndentical(CarrierCur); } catch {//match not found carrierFound=false; } if(!carrierFound) { if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"Carrier not found. Create new carrier?")) { return false; } FormCarrierEdit formCE=new FormCarrierEdit(); formCE.IsNew=true; formCE.CarrierCur=CarrierCur; formCE.ShowDialog(); if(formCE.DialogResult!=DialogResult.OK) { return false; } } } else { CarrierCur=Carriers.GetIndentical(CarrierCur); } PlanCur.CarrierNum=CarrierCur.CarrierNum; //plantype already handled. if(comboClaimForm.SelectedIndex!=-1){ PlanCur.ClaimFormNum=ClaimForms.ListShort[comboClaimForm.SelectedIndex].ClaimFormNum; } PlanCur.UseAltCode=checkAlternateCode.Checked; PlanCur.CodeSubstNone=checkCodeSubst.Checked; PlanCur.IsMedical=checkIsMedical.Checked; PlanCur.ClaimsUseUCR=checkClaimsUseUCR.Checked; PlanCur.IsHidden=checkIsHidden.Checked; PlanCur.ShowBaseUnits=checkShowBaseUnits.Checked; if(comboFeeSched.SelectedIndex==0){ PlanCur.FeeSched=0; } else{ PlanCur.FeeSched=FeeSchedsStandard[comboFeeSched.SelectedIndex-1].FeeSchedNum; } if(comboCopay.SelectedIndex==0){ PlanCur.CopayFeeSched=0; } else{ PlanCur.CopayFeeSched=FeeSchedsCopay[comboCopay.SelectedIndex-1].FeeSchedNum; } if(comboAllowedFeeSched.SelectedIndex==0){ if(IsNewPlan && PlanCur.PlanType==""//percentage && PrefC.GetBool(PrefName.AllowedFeeSchedsAutomate)){ //add a fee schedule if needed FeeSched sched=FeeScheds.GetByExactName(CarrierCur.CarrierName,FeeScheduleType.Allowed); if(sched==null){ sched=new FeeSched(); sched.Description=CarrierCur.CarrierName; sched.FeeSchedType=FeeScheduleType.Allowed; //sched.IsNew=true; sched.ItemOrder=FeeSchedC.ListLong.Count; FeeScheds.Insert(sched); DataValid.SetInvalid(InvalidType.FeeScheds); } PlanCur.AllowedFeeSched=sched.FeeSchedNum; } else{ PlanCur.AllowedFeeSched=0; } } else{ PlanCur.AllowedFeeSched=FeeSchedsAllowed[comboAllowedFeeSched.SelectedIndex-1].FeeSchedNum; } PlanCur.CobRule=(EnumCobRule)comboCobRule.SelectedIndex; if(comboFilingCode.SelectedIndex==-1) { PlanCur.FilingCode=0; } else { PlanCur.FilingCode=InsFilingCodeC.Listt[comboFilingCode.SelectedIndex].InsFilingCodeNum; } PlanCur.FilingCodeSubtype=0; List<InsFilingCodeSubtype> subtypeList=InsFilingCodeSubtypes.GetForInsFilingCode(PlanCur.FilingCode); if(comboFilingCodeSubtype.SelectedIndex != -1 && comboFilingCodeSubtype.SelectedIndex < subtypeList.Count) { PlanCur.FilingCodeSubtype=subtypeList[comboFilingCodeSubtype.SelectedIndex].InsFilingCodeSubtypeNum; } //Canadian------------------------------------------------------------------------------------------ PlanCur.DentaideCardSequence=PIn.Byte(textDentaide.Text); PlanCur.CanadianPlanFlag=textPlanFlag.Text;//validated PlanCur.CanadianDiagnosticCode=textCanadianDiagCode.Text;//validated PlanCur.CanadianInstitutionCode=textCanadianInstCode.Text;//validated //Canadian end--------------------------------------------------------------------------------------- PlanCur.TrojanID=textTrojanID.Text; PlanCur.PlanNote=textPlanNote.Text; return true; }
///<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); }
///<summary>Copies one fee schedule to one or more fee schedules. fromClinicNum, fromProvNum, and toProvNum can be zero. Set listClinicNumsTo to copy to multiple clinic overrides. If this list is null or empty, clinicNum 0 will be used.</summary> public static void CopyFeeSchedule(FeeSched fromFeeSched, long fromClinicNum, long fromProvNum, FeeSched toFeeSched, List <long> listClinicNumsTo, long toProvNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), fromFeeSched, fromClinicNum, fromProvNum, toFeeSched, listClinicNumsTo, toProvNum); return; } if (listClinicNumsTo == null) { listClinicNumsTo = new List <long>(); } if (listClinicNumsTo.Count == 0) { listClinicNumsTo.Add(0); } //Store a local copy of the fees from the old FeeSched List <Fee> listFeeLocalCopy = Fees.GetListExact(toFeeSched.FeeSchedNum, listClinicNumsTo, toProvNum); //Delete all fees that exactly match setting in "To" combo selections. foreach (long clinicNum in listClinicNumsTo) { Fees.DeleteFees(toFeeSched.FeeSchedNum, clinicNum, toProvNum); } //Copy: List <Fee> listNewFees = Fees.GetListExact(fromFeeSched.FeeSchedNum, fromClinicNum, fromProvNum); int blockValue = 0; int blockMax = (listNewFees.Count * listClinicNumsTo.Count); object locker = new object(); List <Action> listActions = new List <Action>(); foreach (long clinicNumTo in listClinicNumsTo) { listActions.Add(() => { foreach (Fee fee in listNewFees) { bool isReplacementFee = false; Fee newFee = fee.Copy(); newFee.FeeNum = 0; newFee.ProvNum = toProvNum; newFee.ClinicNum = clinicNumTo; newFee.FeeSched = toFeeSched.FeeSchedNum; Fees.Insert(newFee); //Check to see if this replaced an old fee with the same fee details Fee oldFee = listFeeLocalCopy.Where(x => x.ProvNum == newFee.ProvNum) .Where(x => x.ClinicNum == newFee.ClinicNum) .Where(x => x.CodeNum == newFee.CodeNum) .Where(x => x.FeeSched == newFee.FeeSched) .FirstOrDefault(); if (oldFee != null) { isReplacementFee = true; } ProcedureCode procCode = ProcedureCodes.GetProcCode(fee.CodeNum); string securityLogText = "Fee Schedule \"" + fromFeeSched.Description + "\" copied to Fee Schedule \"" + toFeeSched.Description + "\", "; if (clinicNumTo != 0) { securityLogText += "To Clinic \"" + Clinics.GetDesc(clinicNumTo) + "\", "; } securityLogText += "Proc Code \"" + procCode.ProcCode + "\", Fee \"" + fee.Amount + "\", "; if (isReplacementFee) { securityLogText += "Replacing Previous Fee \"" + oldFee.Amount + "\""; } SecurityLogs.MakeLogEntry(Permissions.FeeSchedEdit, 0, securityLogText); FeeSchedEvent.Fire(ODEventType.FeeSched, new ProgressBarHelper(Lans.g("FormFeeSchedTools", "Copying fees, please wait") + "...", blockValue: blockValue, blockMax: blockMax, progressStyle: ProgBarStyle.Continuous)); lock (locker) { blockValue++; } } }); } //Research and testing will determine whether we can run this on multiple threads. ODThread.RunParallel(listActions, TimeSpan.FromMinutes(30), numThreads: 1); }
///<summary>Gets a list of procedure codes directly from the database. If categories.length==0, then we will get for all categories. Categories are defnums. FeeScheds are, for now, defnums.</summary> public static DataTable GetProcTable(string abbr, string desc, string code, List <long> categories, long feeSchedNum, long feeSched2Num, long feeSched3Num) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetTable(MethodBase.GetCurrentMethod(), abbr, desc, code, categories, feeSchedNum, feeSched2Num, feeSched3Num)); } string whereCat; if (categories.Count == 0) { whereCat = "1"; } else { whereCat = "("; for (int i = 0; i < categories.Count; i++) { if (i > 0) { whereCat += " OR "; } whereCat += "ProcCat=" + POut.Long(categories[i]); } whereCat += ")"; } FeeSched feeSched = FeeScheds.GetFirstOrDefault(x => x.FeeSchedNum == feeSchedNum); FeeSched feeSched2 = FeeScheds.GetFirstOrDefault(x => x.FeeSchedNum == feeSched2Num); FeeSched feeSched3 = FeeScheds.GetFirstOrDefault(x => x.FeeSchedNum == feeSched3Num); //Query changed to be compatible with both MySQL and Oracle (not tested). string command = "SELECT ProcCat,Descript,AbbrDesc,procedurecode.ProcCode,"; if (feeSched == null) { command += "-1 FeeAmt1,"; } else { command += "CASE "; if (!feeSched.IsGlobal && Clinics.ClinicNum != 0) //Use local clinic fee if there's one present { command += "WHEN (feeclinic1.Amount IS NOT NULL) THEN feeclinic1.Amount "; } command += "WHEN (feehq1.Amount IS NOT NULL) THEN feehq1.Amount ELSE -1 END FeeAmt1,"; } if (feeSched2 == null) { command += "-1 FeeAmt2,"; } else { command += "CASE "; if (!feeSched2.IsGlobal && Clinics.ClinicNum != 0) //Use local clinic fee if there's one present { command += "WHEN (feeclinic2.Amount IS NOT NULL) THEN feeclinic2.Amount "; } command += "WHEN (feehq2.Amount IS NOT NULL) THEN feehq2.Amount ELSE -1 END FeeAmt2,"; } if (feeSched3 == null) { command += "-1 FeeAmt3,"; } else { command += "CASE "; if (!feeSched3.IsGlobal && Clinics.ClinicNum != 0) //Use local clinic fee if there's one present { command += "WHEN (feeclinic3.Amount IS NOT NULL) THEN feeclinic3.Amount "; } command += "WHEN (feehq3.Amount IS NOT NULL) THEN feehq3.Amount ELSE -1 END FeeAmt3,"; } command += "procedurecode.CodeNum "; if (feeSched != null && !feeSched.IsGlobal && Clinics.ClinicNum != 0) { command += ",CASE WHEN (feeclinic1.Amount IS NOT NULL) THEN 1 ELSE 0 END IsClinic1 "; } if (feeSched2 != null && !feeSched2.IsGlobal && Clinics.ClinicNum != 0) { command += ",CASE WHEN (feeclinic2.Amount IS NOT NULL) THEN 1 ELSE 0 END IsClinic2 "; } if (feeSched3 != null && !feeSched3.IsGlobal && Clinics.ClinicNum != 0) { command += ",CASE WHEN (feeclinic3.Amount IS NOT NULL) THEN 1 ELSE 0 END IsClinic3 "; } command += "FROM procedurecode "; if (feeSched != null) { if (!feeSched.IsGlobal && Clinics.ClinicNum != 0) //Get local clinic fee if there's one present { command += "LEFT JOIN fee feeclinic1 ON feeclinic1.CodeNum=procedurecode.CodeNum AND feeclinic1.FeeSched=" + POut.Long(feeSched.FeeSchedNum) + " AND feeclinic1.ClinicNum=" + POut.Long(Clinics.ClinicNum) + " "; } //Get the hq clinic fee if there's one present command += "LEFT JOIN fee feehq1 ON feehq1.CodeNum=procedurecode.CodeNum AND feehq1.FeeSched=" + POut.Long(feeSched.FeeSchedNum) + " AND feehq1.ClinicNum=0 "; } if (feeSched2 != null) { if (!feeSched2.IsGlobal && Clinics.ClinicNum != 0) //Get local clinic fee if there's one present { command += "LEFT JOIN fee feeclinic2 ON feeclinic2.CodeNum=procedurecode.CodeNum AND feeclinic2.FeeSched=" + POut.Long(feeSched2.FeeSchedNum) + " AND feeclinic2.ClinicNum=" + POut.Long(Clinics.ClinicNum) + " "; } //Get the hq clinic fee if there's one present command += "LEFT JOIN fee feehq2 ON feehq2.CodeNum=procedurecode.CodeNum AND feehq2.FeeSched=" + POut.Long(feeSched2.FeeSchedNum) + " AND feehq2.ClinicNum=0 "; } if (feeSched3 != null) { if (!feeSched3.IsGlobal && Clinics.ClinicNum != 0) //Get local clinic fee if there's one present { command += "LEFT JOIN fee feeclinic3 ON feeclinic3.CodeNum=procedurecode.CodeNum AND feeclinic3.FeeSched=" + POut.Long(feeSched3.FeeSchedNum) + " AND feeClinic3.ClinicNum=" + POut.Long(Clinics.ClinicNum) + " "; } //Get the hq clinic fee if there's one present command += "LEFT JOIN fee feehq3 ON feehq3.CodeNum=procedurecode.CodeNum AND feehq3.FeeSched=" + POut.Long(feeSched3.FeeSchedNum) + " AND feehq3.ClinicNum=0 "; } command += "LEFT JOIN definition ON definition.DefNum=procedurecode.ProcCat " + "WHERE " + whereCat + " " + "AND Descript LIKE '%" + POut.String(desc) + "%' " + "AND AbbrDesc LIKE '%" + POut.String(abbr) + "%' " + "AND procedurecode.ProcCode LIKE '%" + POut.String(code) + "%' " + "ORDER BY definition.ItemOrder,procedurecode.ProcCode"; return(Db.GetTable(command)); }
private void butImportEcw_Click(object sender,EventArgs e) { Cursor=Cursors.WaitCursor; OpenFileDialog Dlg=new OpenFileDialog(); #if DEBUG Dlg.InitialDirectory=@"E:\My Documents\Bridge Info\eClinicalWorks\FeeSchedules"; #endif if(Dlg.ShowDialog()!=DialogResult.OK) { Cursor=Cursors.Default; return; } if(!File.Exists(Dlg.FileName)) { Cursor=Cursors.Default; MsgBox.Show(this,"File not found"); return; } string extension=Path.GetExtension(Dlg.FileName); if(extension!=".csv") { Cursor=Cursors.Default; MsgBox.Show(this,"Only .csv files may be imported."); return; } string[] lines=File.ReadAllLines(Dlg.FileName); if(lines.Length==0 || lines[0]!="Code,Description,Unit Fee,Allowed Fee,POS,TOS,Modifier,RequiresCliaID,GlobalBillingDays,ChargeCode") { Cursor=Cursors.Default; MessageBox.Show("Unexpected file format. First line in file should be:\r\nCode,Description,Unit Fee,Allowed Fee,POS,TOS,Modifier,RequiresCliaID,GlobalBillingDays,ChargeCode"); return; } string feeSchedName=Path.GetFileNameWithoutExtension(Dlg.FileName); FeeSched feesched=FeeScheds.GetByExactName(feeSchedName,FeeScheduleType.Normal); if(feesched==null) { feesched=new FeeSched(); feesched.Description=feeSchedName; feesched.FeeSchedType=FeeScheduleType.Normal; feesched.ItemOrder=FeeSchedC.ListLong[FeeSchedC.ListLong.Count-1].ItemOrder+1; feesched.IsHidden=false; //feesched.IsNew=true; FeeScheds.Insert(feesched); DataValid.SetInvalid(InvalidType.FeeScheds); } else{ if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"Fee schedule already exists and all the fees will be overwritten. Continue?")) { Cursor=Cursors.Default; return; } Fees.ClearFeeSched(feesched.FeeSchedNum); } bool importAllowed=false; if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Import Allowed Fee column instead of Unit Fee column?")) { importAllowed=true; } int imported=0; int skippedCode=0; int skippedMalformed=0; string[] fieldArray; List<string> fields; double feeAmt=0; string codeText=""; bool formatQuotes=false; if(lines.Length>1) { if(lines[1].Substring(0,1)=="\"") { formatQuotes=true; } } if(formatQuotes) {//Original format - fields are surrounded by quotes (except first row, above)-------------------------------------------------------------------------------------- for(int i=1;i<lines.Length;i++) { //fieldArray=lines[i].Split(new string[1] { "\"" },StringSplitOptions.RemoveEmptyEntries);//Removing emtpy entries will misalign the columns fieldArray=lines[i].Split(new string[1] { "\"" },StringSplitOptions.None);//half the 'fields' will be commas fields=new List<string>(); for(int f=1;f<fieldArray.Length-1;f++) {//this loop skips the first and last elements because they are artifacts of the string splitting. if(fieldArray[f]==",") { continue; } fields.Add(fieldArray[f]); } if(fields.Count<4) { skippedMalformed++; continue; } if(importAllowed) { feeAmt=PIn.Double(fields[3]); } else { feeAmt=PIn.Double(fields[2]); } codeText=fields[0]; if(!ProcedureCodes.IsValidCode(codeText)) { skippedCode++; continue; } Fees.Import(fields[0],feeAmt,feesched.FeeSchedNum); imported++; } } else {//New format - fields are delimited by commas only (no quotes)----------------------------------------------------------------------------------------------------------------- for(int i=1;i<lines.Length;i++) { fieldArray=lines[i].Split(new string[1] { "," },StringSplitOptions.None); fields=new List<string>(); for(int f=0;f<fieldArray.Length;f++) { fields.Add(fieldArray[f]); } if(fields.Count<4) { skippedMalformed++; continue; } if(fields.Count>10) { MsgBox.Show(this,"Import aborted. Commas are not allowed in text fields. Check your descriptions for commas and try again."); Cursor=Cursors.Default; return; } if(importAllowed) { feeAmt=PIn.Double(fields[3]); } else { feeAmt=PIn.Double(fields[2]); } codeText=fields[0]; if(!ProcedureCodes.IsValidCode(codeText)) { skippedCode++; continue; } Fees.Import(fields[0],feeAmt,feesched.FeeSchedNum); imported++; } } DataValid.SetInvalid(InvalidType.Fees); Cursor=Cursors.Default; string displayMsg="Import complete.\r\nCodes imported: "+imported.ToString(); if(skippedCode>0) { displayMsg+="\r\nCodes skipped because not valid codes in Open Dental: "+skippedCode.ToString(); } if(skippedMalformed>0) { displayMsg+="\r\nCodes skipped because malformed line in text file: "+skippedMalformed.ToString(); } MessageBox.Show(displayMsg); DialogResult=DialogResult.OK; }
///<summary>Returns the number of fee schedules added. It doesn't inform the user of how many plans were affected, but there will obviously be a certain number of plans for every new fee schedule.</summary> public static long GenerateAllowedFeeSchedules() { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { return Meth.GetLong(MethodBase.GetCurrentMethod()); } //get carrier names for all plans without an allowed fee schedule that are also not hidden. string command="SELECT carrier.CarrierName " +"FROM insplan,carrier " +"WHERE carrier.CarrierNum=insplan.CarrierNum " +"AND insplan.AllowedFeeSched=0 " +"AND insplan.PlanType='' " +"AND insplan.IsHidden='0' " +"GROUP BY carrier.CarrierName"; DataTable table=Db.GetTable(command); //loop through all the carrier names string carrierName; FeeSched sched; List<FeeSched> listFeeScheds=FeeSchedC.GetListLong(); int itemOrder=listFeeScheds.Count; DataTable tableCarrierNums; long retVal=0; for(int i=0;i<table.Rows.Count;i++){ carrierName=PIn.String(table.Rows[i]["CarrierName"].ToString()); if(carrierName=="" || carrierName==" "){ continue; } //add a fee schedule if needed sched=FeeScheds.GetByExactName(carrierName,FeeScheduleType.OutNetwork); if(sched==null){ sched=new FeeSched(); sched.Description=carrierName; sched.FeeSchedType=FeeScheduleType.OutNetwork; //sched.IsNew=true; sched.ItemOrder=itemOrder; FeeScheds.Insert(sched); itemOrder++; } //assign the fee sched to many plans //for compatibility with Oracle, get a list of all carrierNums that use the carriername command="SELECT CarrierNum FROM carrier WHERE CarrierName='"+POut.String(carrierName)+"'"; tableCarrierNums=Db.GetTable(command); if(tableCarrierNums.Rows.Count==0){ continue;//I don't see how this could happen } command="UPDATE insplan " +"SET AllowedFeeSched="+POut.Long(sched.FeeSchedNum)+" " +"WHERE AllowedFeeSched=0 " +"AND PlanType='' " +"AND IsHidden='0' " +"AND ("; for(int c=0;c<tableCarrierNums.Rows.Count;c++){ if(c>0){ command+=" OR "; } command+="CarrierNum="+tableCarrierNums.Rows[c]["CarrierNum"].ToString(); } command+=")"; retVal+=Db.NonQ(command); } return retVal; }