private void butYes_Click(object sender, System.EventArgs e) { //Customers have been complaining about procedurelog entries changing their CodeNum column to 0. //Based on a security log provided by a customer, we were able to determine that this is one of two potential violators. //The following code is here simply to try and get the user to call us so that we can have proof and hopefully find the core of the issue. try { if (_verifyCode < 1) { throw new ApplicationException("Invalid Verify Code"); } } catch (ApplicationException ae) { string error = "Please notify support with the following information.\r\n" + "Error: " + ae.Message + "\r\n" + "_verifyCode: " + _verifyCode.ToString() + "\r\n" + "_procCur.CodeNum: " + (_procCur == null ? "NULL" : _procCur.CodeNum.ToString()) + "\r\n" + "_procCodeCur.CodeNum: " + (_procCodeCur == null ? "NULL" : _procCodeCur.CodeNum.ToString()) + "\r\n" + "\r\n" + "StackTrace:\r\n" + ae.StackTrace; MsgBoxCopyPaste MsgBCP = new MsgBoxCopyPaste(error); MsgBCP.Text = "Fatal Error!!!"; MsgBCP.Show(); //Use .Show() to make it easy for the user to keep this window open while they call in. return; } //Moved from FormProcEdit.SaveAndClose() in version 16.3+ Procedure procOld = _procCur.Copy(); _procCur.CodeNum = _verifyCode; if (new[] { ProcStat.TP, ProcStat.C, ProcStat.TPi }.Contains(_procCur.ProcStatus)) //Only change the fee if Complete or TP { InsSub prisub = null; InsPlan priplan = null; if (_listPatPlans.Count > 0) { prisub = InsSubs.GetSub(_listPatPlans[0].InsSubNum, _listInsSubs); priplan = InsPlans.GetPlan(prisub.PlanNum, _listInsPlans); } _procCur.ProcFee = Fees.GetAmount0(_procCur.CodeNum, FeeScheds.GetFeeSched(_patCur, _listInsPlans, _listPatPlans, _listInsSubs, _procCur.ProvNum), _procCur.ClinicNum, _procCur.ProvNum); if (priplan != null && priplan.PlanType == "p") //PPO { double standardfee = Fees.GetAmount0(_procCur.CodeNum, Providers.GetProv(Patients.GetProvNum(_patCur)).FeeSched, _procCur.ClinicNum, _procCur.ProvNum); _procCur.ProcFee = Math.Max(_procCur.ProcFee, standardfee); } } Procedures.Update(_procCur, procOld); //Compute estimates required, otherwise if adding through quick add, it could have incorrect WO or InsEst if code changed. Procedures.ComputeEstimates(_procCur, _patCur.PatNum, _listClaimProcs, false, _listInsPlans, _listPatPlans, _listBenefits, _patCur.Age, _listInsSubs); Recalls.Synch(_procCur.PatNum); if (_procCur.ProcStatus.In(ProcStat.C, ProcStat.EO, ProcStat.EC)) { string logText = _procCodeCur.ProcCode + " (" + _procCur.ProcStatus + "), "; if (_teethText != null && _teethText.Trim() != "") { logText += Lan.g(this, "Teeth") + ": " + _teethText + ", "; } logText += Lan.g(this, "Fee") + ": " + _procCur.ProcFee.ToString("F") + ", " + _procCodeCur.Descript; Permissions perm = Permissions.ProcComplEdit; if (_procCur.ProcStatus.In(ProcStat.EO, ProcStat.EC)) { perm = Permissions.ProcExistingEdit; } SecurityLogs.MakeLogEntry(perm, _patCur.PatNum, logText); } DialogResult = DialogResult.OK; }
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>Updates all claimproc estimates and also updates claim totals to db. Must supply all claimprocs for this patient. Must supply procList which includes all procedures that this claim is linked to. Will also need to refresh afterwards to see the results</summary> public static void CalculateAndUpdate(ClaimProc[] ClaimProcList, Procedure[] procList, InsPlan[] PlanList, Claim ClaimCur, PatPlan[] patPlans, Benefit[] benefitList) { //Remember that this can be called externally also //ClaimProcList=claimProcList; ClaimProc[] ClaimProcsForClaim = ClaimProcs.GetForClaim(ClaimProcList, ClaimCur.ClaimNum); double claimFee = 0; double dedApplied = 0; double insPayEst = 0; double insPayAmt = 0; InsPlan PlanCur = InsPlans.GetPlan(ClaimCur.PlanNum, PlanList); if (PlanCur == null) { return; } //InsPlans.Cur=(InsPlan)InsPlans.HList[ClaimCur.PlanNum]; int provNum; double dedRem; int patPlanNum = PatPlans.GetPatPlanNum(patPlans, ClaimCur.PlanNum); //this next line has to be done outside the loop. Takes annual max into consideration double insRem; //no changes get made to insRem in the loop. if (patPlanNum == 0) //patient does not have current coverage { insRem = 0; } else { insRem = InsPlans.GetInsRem(ClaimProcList, ClaimProcsForClaim[0].ProcDate, ClaimCur.PlanNum, patPlanNum, ClaimCur.ClaimNum, PlanList, benefitList); } //first loop handles totals for received items. for (int i = 0; i < ClaimProcsForClaim.Length; i++) { if (ClaimProcsForClaim[i].Status != ClaimProcStatus.Received) { continue; //disregard any status except Receieved. } claimFee += ClaimProcsForClaim[i].FeeBilled; dedApplied += ClaimProcsForClaim[i].DedApplied; insPayEst += ClaimProcsForClaim[i].InsPayEst; insPayAmt += ClaimProcsForClaim[i].InsPayAmt; } //loop again only for procs not received. //And for preauth. Procedure ProcCur; for (int i = 0; i < ClaimProcsForClaim.Length; i++) { if (ClaimProcsForClaim[i].Status != ClaimProcStatus.NotReceived && ClaimProcsForClaim[i].Status != ClaimProcStatus.Preauth) { continue; } ProcCur = Procedures.GetProc(procList, ClaimProcsForClaim[i].ProcNum); if (ProcCur.ProcNum == 0) { continue; //ignores payments, etc } //fee: if (PlanCur.ClaimsUseUCR) //use UCR for the provider of the procedure { provNum = ProcCur.ProvNum; if (provNum == 0) //if no prov set, then use practice default. { provNum = PrefB.GetInt("PracticeDefaultProv"); } ClaimProcsForClaim[i].FeeBilled = Fees.GetAmount0( //get the fee based on ada and prov fee sched ProcCur.ADACode , Providers.ListLong[Providers.GetIndexLong(provNum)].FeeSched); } else //don't use ucr. Use the procedure fee instead. { ClaimProcsForClaim[i].FeeBilled = ProcCur.ProcFee; } claimFee += ClaimProcsForClaim[i].FeeBilled; if (ClaimCur.ClaimType == "PreAuth" || ClaimCur.ClaimType == "Other") { //only the fee gets calculated, the rest does not ClaimProcs.Update(ClaimProcsForClaim[i]); continue; } //deduct: if (patPlanNum == 0) //patient does not have current coverage { dedRem = 0; } else { dedRem = InsPlans.GetDedRem(ClaimProcList, ClaimProcsForClaim[i].ProcDate, ClaimCur.PlanNum, patPlanNum, ClaimCur.ClaimNum, PlanList, benefitList, ProcCur.ADACode) - dedApplied; //subtracts deductible amounts already applied on this claim if (dedRem < 0) { dedRem = 0; } } if (dedRem > ClaimProcsForClaim[i].FeeBilled) //if deductible is more than cost of procedure { ClaimProcsForClaim[i].DedApplied = ClaimProcsForClaim[i].FeeBilled; } else { ClaimProcsForClaim[i].DedApplied = dedRem; } //??obsolete: if dedApplied is too big, it might be adjusted in the next few lines.?? //insest: //Unlike deductible, we do not need to take into account any of the received claimprocs when calculating insest. So insRem takes care of annual max rather than received+est. //if(patPlanNum==0){//patient does not have current coverage // insRem=0; //} //else{ //insRem-=insPayEst;//subtracts insest amounts already applied on this claim //insRem=InsPlans.GetInsRem(ClaimProcList,ClaimProcsForClaim[i].ProcDate,ClaimCur.PlanNum, // patPlanNum,ClaimCur.ClaimNum,PlanList,benefitList) // -insPayEst;//subtracts insest amounts already applied on this claim // if(insRem<0) { // insRem=0; // } //} if (ClaimCur.ClaimType == "P") //primary { ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i], ProcCur, PriSecTot.Pri, PlanList, patPlans, benefitList); //handles dedBeforePerc ClaimProcsForClaim[i].InsPayEst = Procedures.GetEst(ProcCur, ClaimProcList, PriSecTot.Pri, patPlans, true); //ClaimProcsForClaim[i].BaseEst; if (!ClaimProcsForClaim[i].DedBeforePerc) { ClaimProcsForClaim[i].InsPayEst -= ClaimProcsForClaim[i].DedApplied; } } else if (ClaimCur.ClaimType == "S") //secondary { ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i], ProcCur, PriSecTot.Sec, PlanList, patPlans, benefitList); ClaimProcsForClaim[i].InsPayEst = Procedures.GetEst(ProcCur, ClaimProcList, PriSecTot.Sec, patPlans, true); //ClaimProcsForClaim[i].BaseEst; if (!ClaimProcsForClaim[i].DedBeforePerc) { ClaimProcsForClaim[i].InsPayEst -= ClaimProcsForClaim[i].DedApplied; } } //other claimtypes only changed manually if (ClaimProcsForClaim[i].InsPayEst < 0) { //example: if inspayest = 19 - 50(ded) for total of -31. ClaimProcsForClaim[i].DedApplied += ClaimProcsForClaim[i].InsPayEst; //eg. 50+(-31)=19 ClaimProcsForClaim[i].InsPayEst = 0; //so only 19 of deductible gets applied, and inspayest is 0 } if (insRem - insPayEst < 0) //total remaining ins-Estimated so far on this claim { ClaimProcsForClaim[i].InsPayEst = 0; } else if (ClaimProcsForClaim[i].InsPayEst > insRem - insPayEst) { ClaimProcsForClaim[i].InsPayEst = insRem - insPayEst; } dedApplied += ClaimProcsForClaim[i].DedApplied; insPayEst += ClaimProcsForClaim[i].InsPayEst; ClaimProcs.Update(ClaimProcsForClaim[i]); //but notice that the ClaimProcs lists are not refreshed until the loop is finished. } //for claimprocs.forclaim ClaimCur.ClaimFee = claimFee; ClaimCur.DedApplied = dedApplied; ClaimCur.InsPayEst = insPayEst; ClaimCur.InsPayAmt = insPayAmt; //Cur=ClaimCur; Update(ClaimCur); }
private void SaveAllowedFees() { //if no allowed fees entered, then nothing to do bool allowedFeesEntered = false; for (int i = 0; i < gridMain.Rows.Count; i++) { if (gridMain.Rows[i].Cells[7].Text != "") { allowedFeesEntered = true; break; } } if (!allowedFeesEntered) { return; } //if no allowed fee schedule, then nothing to do InsPlan plan = InsPlans.GetPlan(ClaimProcsToEdit[0].PlanNum, PlanList); if (plan.AllowedFeeSched == 0) //no allowed fee sched //plan.PlanType!="p" && //not ppo, and { return; } //ask user if they want to save the fees if (!MsgBox.Show(this, true, "Save the allowed amounts to the allowed fee schedule?")) { return; } //select the feeSchedule long feeSched = -1; //if(plan.PlanType=="p"){//ppo // feeSched=plan.FeeSched; //} //else if(plan.AllowedFeeSched!=0){//an allowed fee schedule exists feeSched = plan.AllowedFeeSched; //} if (FeeScheds.GetIsHidden(feeSched)) { MsgBox.Show(this, "Allowed fee schedule is hidden, so no changes can be made."); return; } Fee FeeCur = null; long codeNum; List <Procedure> ProcList = Procedures.Refresh(PatCur.PatNum); Procedure proc; for (int i = 0; i < ClaimProcsToEdit.Length; i++) { //this gives error message if proc not found: proc = Procedures.GetProcFromList(ProcList, ClaimProcsToEdit[i].ProcNum); codeNum = proc.CodeNum; if (codeNum == 0) { continue; } FeeCur = Fees.GetFee(codeNum, feeSched); if (FeeCur == null) { FeeCur = new Fee(); FeeCur.FeeSched = feeSched; FeeCur.CodeNum = codeNum; FeeCur.Amount = PIn.Double(gridMain.Rows[i].Cells[7].Text); Fees.Insert(FeeCur); } else { FeeCur.Amount = PIn.Double(gridMain.Rows[i].Cells[7].Text); Fees.Update(FeeCur); } SecurityLogs.MakeLogEntry(Permissions.ProcFeeEdit, 0, Lan.g(this, "Procedure") + ": " + ProcedureCodes.GetStringProcCode(FeeCur.CodeNum) + ", " + Lan.g(this, "Fee: ") + "" + FeeCur.Amount.ToString("c") + ", " + Lan.g(this, "Fee Schedule") + " " + FeeScheds.GetDescription(FeeCur.FeeSched) + ". " + Lan.g(this, "Automatic change to allowed fee in Enter Payment window. Confirmed by user."), FeeCur.CodeNum); } //Fees.Refresh();//redundant? DataValid.SetInvalid(InvalidType.Fees); }
private void butOK_Click(object sender, System.EventArgs e) { long feeSched = FeeSchedC.ListShort[listFeeSched.SelectedIndex].FeeSchedNum; string catName = ""; //string to hold current category name Fees fee = new Fees(); ReportSimpleGrid report = new ReportSimpleGrid(); report.Query = "SELECT procedurecode.ProcCode,fee.Amount,' ',procedurecode.Descript," + "procedurecode.AbbrDesc FROM procedurecode,fee " + "WHERE procedurecode.CodeNum=fee.CodeNum AND fee.FeeSched='" + feeSched.ToString() + "' ORDER BY procedurecode.ProcCode"; FormQuery2 = new FormQuery(report); FormQuery2.IsReport = true; if (radioCode.Checked == true) { FormQuery2.SubmitReportQuery(); report.Title = "Procedure Codes"; report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle)); report.SubTitle.Add(FeeScheds.GetDescription(feeSched)); report.SetColumn(this, 0, "Code", 70); report.SetColumn(this, 1, "Fee Amount", 70, HorizontalAlignment.Right); report.SetColumn(this, 2, " ", 80); //otherwise, the amount gets bunched up next to the description. report.SetColumn(this, 3, "Description", 200); report.SetColumn(this, 4, "Abbr Description", 200); FormQuery2.ShowDialog(); DialogResult = DialogResult.OK; } else //categories //report.SubmitTemp();//create TableTemp which is not actually used { ProcedureCode[] ProcList = ProcedureCodes.GetProcList(); report.TableQ = new DataTable(null); for (int i = 0; i < 5; i++) //add columns { report.TableQ.Columns.Add(new System.Data.DataColumn()); //blank columns } report.InitializeColumns(); DataRow row = report.TableQ.NewRow();//add first row by hand to get value for temp row[0] = DefC.GetName(DefCat.ProcCodeCats, ProcList[0].ProcCat); catName = row[0].ToString(); row[1] = ProcList[0].ProcCode; row[2] = ProcList[0].Descript; row[3] = ProcList[0].AbbrDesc; row[4] = ((double)Fees.GetAmount0(ProcList[0].CodeNum, feeSched)).ToString("F"); report.ColTotal[4] += PIn.Decimal(row[4].ToString()); report.TableQ.Rows.Add(row); for (int i = 1; i < ProcList.Length; i++) //loop through data rows { row = report.TableQ.NewRow(); //create new row called 'row' based on structure of TableQ row[0] = DefC.GetName(DefCat.ProcCodeCats, ProcList[i].ProcCat); if (catName == row[0].ToString()) { row[0] = ""; } else { catName = row[0].ToString(); } row[1] = ProcList[i].ProcCode.ToString(); row[2] = ProcList[i].Descript; row[3] = ProcList[i].AbbrDesc.ToString(); row[4] = ((double)Fees.GetAmount0(ProcList[i].CodeNum, feeSched)).ToString("F"); //report.ColTotal[4]+=PIn.PDouble(row[4].ToString()); report.TableQ.Rows.Add(row); } FormQuery2.ResetGrid(); //this is a method in FormQuery2; report.Title = "Procedure Codes"; report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle)); report.SubTitle.Add(FeeScheds.GetDescription(feeSched)); report.ColPos[0] = 20; report.ColPos[1] = 120; report.ColPos[2] = 270; report.ColPos[3] = 470; report.ColPos[4] = 620; report.ColPos[5] = 770; report.ColCaption[0] = "Category"; report.ColCaption[1] = "Code"; report.ColCaption[2] = "Description"; report.ColCaption[3] = "Abbr Description"; report.ColCaption[4] = "Fee Amount"; report.ColAlign[4] = HorizontalAlignment.Right; FormQuery2.ShowDialog(); DialogResult = DialogResult.OK; } }
private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e) { if (IsSelectionMode) { SelectedCodeNum = PIn.PInt(ProcTable.Rows[e.Row]["CodeNum"].ToString()); DialogResult = DialogResult.OK; return; } //else not selecting a code if (!Security.IsAuthorized(Permissions.Setup, DateTime.MinValue, true)) { return; } int codeNum = PIn.PInt(ProcTable.Rows[e.Row]["CodeNum"].ToString()); //string =ProcTable.Rows[e.Row]["ProcCode"].ToString(); if (e.Col > 3) //if double clicked on a fee { Fee FeeCur = null; int feesched = 0; if (e.Col == 4) { FeeCur = Fees.GetFeeByOrder(codeNum, listFeeSched.SelectedIndex); feesched = DefB.Short[(int)DefCat.FeeSchedNames][listFeeSched.SelectedIndex].DefNum; } if (e.Col == 5) { if (comboCompare1.SelectedIndex == 0) { return; } FeeCur = Fees.GetFeeByOrder(codeNum, comboCompare1.SelectedIndex - 1); feesched = DefB.Short[(int)DefCat.FeeSchedNames][comboCompare1.SelectedIndex - 1].DefNum; } if (e.Col == 6) { if (comboCompare2.SelectedIndex == 0) { return; } FeeCur = Fees.GetFeeByOrder(codeNum, comboCompare2.SelectedIndex - 1); feesched = DefB.Short[(int)DefCat.FeeSchedNames][comboCompare2.SelectedIndex - 1].DefNum; } FormFeeEdit FormFE = new FormFeeEdit(); if (FeeCur == null) { FeeCur = new Fee(); FeeCur.FeeSched = feesched; FeeCur.CodeNum = codeNum; Fees.Insert(FeeCur); FormFE.IsNew = true; } FormFE.FeeCur = FeeCur; FormFE.ShowDialog(); if (FormFE.DialogResult == DialogResult.OK) { Fees.Refresh(); changed = true; FillGrid(); } } else //not on a fee: Edit code instead { FormProcCodeEdit FormPCE = new FormProcCodeEdit(ProcedureCodes.GetProcCode(codeNum)); FormPCE.IsNew = false; FormPCE.ShowDialog(); if (FormPCE.DialogResult == DialogResult.OK) { //ProcedureCodes.Refresh(); changed = true; //Fees.Refresh();//fees were already refreshed within procCodeEdit FillGrid(); } } }
private void butAdd_Click(object sender, EventArgs e) { FormProcCodes FormP = new FormProcCodes(); FormP.IsSelectionMode = true; FormP.ShowDialog(); if (FormP.DialogResult != DialogResult.OK) { return; } Procedure ProcCur; ProcCur = new Procedure(); //going to be an insert, so no need to set Procedures.CurOld ProcCur.CodeNum = FormP.SelectedCodeNum; //procnum ProcCur.PatNum = AptCur.PatNum; //aptnum //proccode //ProcCur.CodeNum=ProcedureCodes.GetProcCode(ProcCur.OldCode).CodeNum;//already set ProcCur.ProcDate = DateTime.Today; ProcCur.DateTP = ProcCur.ProcDate; //int totUnits = ProcCur.BaseUnits + ProcCur.UnitQty; InsPlan priplan = null; InsSub prisub = null; Family fam = Patients.GetFamily(AptCur.PatNum); Patient pat = fam.GetPatient(AptCur.PatNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum); if (patPlanList.Count > 0) { prisub = InsSubs.GetSub(patPlanList[0].InsSubNum, subList); priplan = InsPlans.GetPlan(prisub.PlanNum, planList); } //Check if it's a medical procedure. double insfee; bool isMed = false; ProcCur.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode; if (ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") { isMed = true; } //Get fee schedule for medical or dental. long feeSch; if (isMed) { feeSch = Fees.GetMedFeeSched(pat, planList, patPlanList, subList); } else { feeSch = Fees.GetFeeSched(pat, planList, patPlanList, subList); } //Get the fee amount for medical or dental. if (PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) { insfee = Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum, feeSch); } else { insfee = Fees.GetAmount0(ProcCur.CodeNum, feeSch); } if (priplan != null && priplan.PlanType == "p") //PPO { double standardfee = Fees.GetAmount0(ProcCur.CodeNum, Providers.GetProv(Patients.GetProvNum(pat)).FeeSched); if (standardfee > insfee) { ProcCur.ProcFee = standardfee; } else { ProcCur.ProcFee = insfee; } } else { ProcCur.ProcFee = insfee; } //surf //ToothNum //Procedures.Cur.ToothRange //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.ProcCode).NoBillIns; ProcCur.Priority = 0; ProcCur.ProcStatus = ProcStat.TP; if (ProcedureCodes.GetProcCode(ProcCur.CodeNum).IsHygiene && pat.SecProv != 0) { ProcCur.ProvNum = pat.SecProv; } else { ProcCur.ProvNum = pat.PriProv; } ProcCur.Note = ""; ProcCur.ClinicNum = pat.ClinicNum; //dx //nextaptnum ProcCur.DateEntryC = DateTime.Now; ProcCur.BaseUnits = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits; ProcCur.SiteNum = pat.SiteNum; ProcCur.RevCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).RevenueCodeDefault; Procedures.Insert(ProcCur); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); Procedures.ComputeEstimates(ProcCur, pat.PatNum, new List <ClaimProc>(), true, planList, patPlanList, benefitList, pat.Age, subList); FormProcEdit FormPE = new FormProcEdit(ProcCur, pat.Copy(), fam); FormPE.IsNew = true; FormPE.ShowDialog(); if (FormPE.DialogResult == DialogResult.Cancel) { //any created claimprocs are automatically deleted from within procEdit window. try{ Procedures.Delete(ProcCur.ProcNum); //also deletes the claimprocs } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (Programs.UsingOrion) { //No need to synch with Orion mode. } else { //Default is set to TP, so Synch is usually not needed. if (ProcCur.ProcStatus == ProcStat.C || ProcCur.ProcStatus == ProcStat.EC || ProcCur.ProcStatus == ProcStat.EO) { Recalls.Synch(pat.PatNum); } } FillGrid(); }
/* * ///<summary>Only used in GetSearchResults. All times between start and stop get set to true in provBarSched.</summary> * private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){ * int startI=GetProvBarIndex(timeStart); * int stopI=GetProvBarIndex(timeStop); * for(int i=startI;i<=stopI;i++){ * provBarSched[i]=true; * } * } * * private static int GetProvBarIndex(TimeSpan time) { * return (int)(((double)time.Hours*(double)60/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)//aptTimeIncr=minutesPerIncr +(double)time.Minutes/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)) *(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr) * /ApptDrawing.LineH;//rounds down * }*/ ///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule. This method creates the appointment and attaches all appropriate procedures. It's up to the calling class to then place the appointment on the pinboard. If the appointment doesn't get scheduled, it's important to delete it. If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary> public static Appointment CreateRecallApt(Patient patCur, List <Procedure> procList, List <InsPlan> planList, long recallNum, List <InsSub> subList) { List <Recall> recallList = Recalls.GetList(patCur.PatNum); Recall recallCur = null; if (recallNum > 0) { recallCur = Recalls.GetRecall(recallNum); } else { for (int i = 0; i < recallList.Count; i++) { if (recallList[i].RecallTypeNum == RecallTypes.PerioType || recallList[i].RecallTypeNum == RecallTypes.ProphyType) { if (!recallList[i].IsDisabled) { recallCur = recallList[i]; } break; } } } if (recallCur == null) // || recallCur.DateDue.Year<1880){ { throw new ApplicationException(Lan.g("AppointmentL", "No recall is due.")); //should never happen because everyone has a recall. } if (recallCur.DateScheduled.Date >= DateTime.Now.Date) { throw new ApplicationException(Lan.g("AppointmentL", "Recall has already been scheduled for ") + recallCur.DateScheduled.ToShortDateString()); } Appointment AptCur = new Appointment(); AptCur.PatNum = patCur.PatNum; AptCur.AptStatus = ApptStatus.UnschedList; //In all places where this is used, the unsched status with no aptDateTime will cause the appt to be deleted when the pinboard is cleared. if (patCur.PriProv == 0) { AptCur.ProvNum = PrefC.GetLong(PrefName.PracticeDefaultProv); } else { AptCur.ProvNum = patCur.PriProv; } AptCur.ProvHyg = patCur.SecProv; if (AptCur.ProvHyg != 0) { AptCur.IsHygiene = true; } AptCur.ClinicNum = patCur.ClinicNum; //whether perio or prophy: List <string> procs = RecallTypes.GetProcs(recallCur.RecallTypeNum); string recallPattern = RecallTypes.GetTimePattern(recallCur.RecallTypeNum); if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum) && patCur.Birthdate.AddYears(12) > ((recallCur.DateDue > DateTime.Today)?recallCur.DateDue:DateTime.Today)) //if pt's 12th birthday falls after recall date. ie younger than 12. { for (int i = 0; i < RecallTypeC.Listt.Count; i++) { if (RecallTypeC.Listt[i].RecallTypeNum == RecallTypes.ChildProphyType) { List <string> childprocs = RecallTypes.GetProcs(RecallTypeC.Listt[i].RecallTypeNum); if (childprocs.Count > 0) { procs = childprocs; //overrides adult procs. } string childpattern = RecallTypes.GetTimePattern(RecallTypeC.Listt[i].RecallTypeNum); if (childpattern != "") { recallPattern = childpattern; //overrides adult pattern. } } } } //convert time pattern to 5 minute increment StringBuilder savePattern = new StringBuilder(); for (int i = 0; i < recallPattern.Length; i++) { savePattern.Append(recallPattern.Substring(i, 1)); if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 10) { savePattern.Append(recallPattern.Substring(i, 1)); } if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15) { savePattern.Append(recallPattern.Substring(i, 1)); savePattern.Append(recallPattern.Substring(i, 1)); } } if (savePattern.ToString() == "") { if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15) { savePattern.Append("///XXX///"); } else { savePattern.Append("//XX//"); } } AptCur.Pattern = savePattern.ToString(); //Add films------------------------------------------------------------------------------------------------------ if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum)) //if this is a prophy or perio { for (int i = 0; i < recallList.Count; i++) { if (recallCur.RecallNum == recallList[i].RecallNum) { continue; //already handled. } if (recallList[i].IsDisabled) { continue; } if (recallList[i].DateDue.Year < 1880) { continue; } if (recallList[i].DateDue > recallCur.DateDue && //if film due date is after prophy due date recallList[i].DateDue > DateTime.Today) //and not overdue { continue; } //incomplete: exclude manual recall types procs.AddRange(RecallTypes.GetProcs(recallList[i].RecallTypeNum)); } } AptCur.ProcDescript = ""; for (int i = 0; i < procs.Count; i++) { if (i > 0) { AptCur.ProcDescript += ", "; } AptCur.ProcDescript += ProcedureCodes.GetProcCode(procs[i]).AbbrDesc; } Appointments.Insert(AptCur); Procedure ProcCur; List <PatPlan> patPlanList = PatPlans.Refresh(patCur.PatNum); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); InsPlan priplan = null; InsSub prisub = null; if (patPlanList.Count > 0) { prisub = InsSubs.GetSub(patPlanList[0].InsSubNum, subList); priplan = InsPlans.GetPlan(prisub.PlanNum, planList); } double insfee; double standardfee; for (int i = 0; i < procs.Count; i++) { ProcCur = new Procedure(); //this will be an insert //procnum ProcCur.PatNum = patCur.PatNum; ProcCur.AptNum = AptCur.AptNum; ProcCur.CodeNum = ProcedureCodes.GetCodeNum(procs[i]); ProcCur.ProcDate = DateTime.Now; ProcCur.DateTP = DateTime.Now; //Check if it's a medical procedure. bool isMed = false; ProcCur.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode; if (ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") { isMed = true; } //Get fee schedule for medical or dental. long feeSch; if (isMed) { feeSch = Fees.GetMedFeeSched(patCur, planList, patPlanList, subList); } else { feeSch = Fees.GetFeeSched(patCur, planList, patPlanList, subList); } //Get the fee amount for medical or dental. if (PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) { insfee = Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum, feeSch); } else { insfee = Fees.GetAmount0(ProcCur.CodeNum, feeSch); } if (priplan != null && priplan.PlanType == "p") //PPO { standardfee = Fees.GetAmount0(ProcCur.CodeNum, Providers.GetProv(Patients.GetProvNum(patCur)).FeeSched); if (standardfee > insfee) { ProcCur.ProcFee = standardfee; } else { ProcCur.ProcFee = insfee; } } else { ProcCur.ProcFee = insfee; } //surf //toothnum //Procedures.Cur.ToothRange=""; //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.CodeNum).NoBillIns; //priority ProcCur.ProcStatus = ProcStat.TP; ProcCur.Note = ""; //Procedures.Cur.PriEstim= //Procedures.Cur.SecEstim= //claimnum ProcCur.ProvNum = patCur.PriProv; //Procedures.Cur.Dx= ProcCur.ClinicNum = patCur.ClinicNum; //nextaptnum ProcCur.BaseUnits = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits; Procedures.Insert(ProcCur); //no recall synch required Procedures.ComputeEstimates(ProcCur, patCur.PatNum, new List <ClaimProc>(), false, planList, patPlanList, benefitList, patCur.Age, subList); if (Programs.UsingOrion) { FormProcEdit FormP = new FormProcEdit(ProcCur, patCur.Copy(), Patients.GetFamily(patCur.PatNum)); FormP.IsNew = true; FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { //any created claimprocs are automatically deleted from within procEdit window. try{ Procedures.Delete(ProcCur.ProcNum); //also deletes the claimprocs } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { //Do not synch. Recalls based on ScheduleByDate reports in Orion mode. //Recalls.Synch(PatCur.PatNum); } } } return(AptCur); }
///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule. This method creates the appointment and attaches all appropriate procedures. It's up to the calling class to then place the appointment on the pinboard. If the appointment doesn't get scheduled, it's important to delete it.</summary> public static Appointment CreateRecallApt(Patient patCur, Procedure[] procList, Recall recallCur, InsPlan[] planList) { Appointment AptCur = new Appointment(); AptCur.PatNum = patCur.PatNum; AptCur.AptStatus = ApptStatus.Scheduled; //convert time pattern to 5 minute increment StringBuilder savePattern = new StringBuilder(); for (int i = 0; i < PrefB.GetString("RecallPattern").Length; i++) { savePattern.Append(PrefB.GetString("RecallPattern").Substring(i, 1)); savePattern.Append(PrefB.GetString("RecallPattern").Substring(i, 1)); if (PrefB.GetInt("AppointmentTimeIncrement") == 15) { savePattern.Append(PrefB.GetString("RecallPattern").Substring(i, 1)); } } AptCur.Pattern = savePattern.ToString(); if (patCur.PriProv == 0) { AptCur.ProvNum = PrefB.GetInt("PracticeDefaultProv"); } else { AptCur.ProvNum = patCur.PriProv; } AptCur.ProvHyg = patCur.SecProv; if (AptCur.ProvHyg != 0) { AptCur.IsHygiene = true; } AptCur.ClinicNum = patCur.ClinicNum; string[] procs = PrefB.GetString("RecallProcedures").Split(','); if (PrefB.GetString("RecallBW") != "") //BWs { bool dueBW = true; //DateTime dueDate=PIn.PDate(listFamily.Items[ for (int i = 0; i < procList.Length; i++) //loop through all procedures for this pt. //if any BW found within last year, then dueBW=false. { if (PrefB.GetString("RecallBW") == procList[i].ADACode && recallCur.DateDue.Year > 1880 && procList[i].ProcDate > recallCur.DateDue.AddYears(-1)) { dueBW = false; } } if (dueBW) { string[] procs2 = new string[procs.Length + 1]; procs.CopyTo(procs2, 0); procs2[procs2.Length - 1] = PrefB.GetString("RecallBW"); procs = new string[procs2.Length]; procs2.CopyTo(procs, 0); } } AptCur.ProcDescript = ""; for (int i = 0; i < procs.Length; i++) { if (i > 0) { AptCur.ProcDescript += ", "; } AptCur.ProcDescript += ProcedureCodes.GetProcCode(procs[i]).AbbrDesc; } Appointments.InsertOrUpdate(AptCur, null, true); Procedure ProcCur; PatPlan[] patPlanList = PatPlans.Refresh(patCur.PatNum); Benefit[] benefitList = Benefits.Refresh(patPlanList); //ClaimProc[] claimProcs=ClaimProcs.Refresh(Patients.Cur.PatNum); for (int i = 0; i < procs.Length; i++) { ProcCur = new Procedure(); //this will be an insert //procnum ProcCur.PatNum = patCur.PatNum; ProcCur.AptNum = AptCur.AptNum; ProcCur.ADACode = procs[i]; ProcCur.ProcDate = DateTime.Now; ProcCur.ProcFee = Fees.GetAmount0(ProcCur.ADACode, Fees.GetFeeSched(patCur, planList, patPlanList)); //ProcCur.OverridePri=-1; //ProcCur.OverrideSec=-1; //surf //toothnum //Procedures.Cur.ToothRange=""; //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.ADACode).NoBillIns; //priority ProcCur.ProcStatus = ProcStat.TP; ProcCur.Note = ""; //Procedures.Cur.PriEstim= //Procedures.Cur.SecEstim= //claimnum ProcCur.ProvNum = patCur.PriProv; //Procedures.Cur.Dx= ProcCur.ClinicNum = patCur.ClinicNum; //nextaptnum ProcCur.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.ADACode).MedicalCode; Procedures.Insert(ProcCur); //no recall synch required Procedures.ComputeEstimates(ProcCur, patCur.PatNum, new ClaimProc[0], false, planList, patPlanList, benefitList); } return(AptCur); }
///<summary></summary> private void FillAndSortListFees() { List <long> listClinicNums = Clinics.GetForUserod(Security.CurUser, true).Select(x => x.ClinicNum).ToList(); _listFees = Fees.GetFeesForCode(_procCode.CodeNum, listClinicNums); //already sorted }
private void butOK_Click(object sender, System.EventArgs e) { int feeSched = DefB.Short[(int)DefCat.FeeSchedNames][listFeeSched.SelectedIndex].DefNum; string catName = ""; //string to hold current category name Fees fee = new Fees(); Queries.CurReport = new ReportOld(); Queries.CurReport.Query = "SELECT procedurecode.adacode,fee.amount,' ',procedurecode.descript," + "procedurecode.abbrdesc FROM procedurecode,fee " + "WHERE procedurecode.adacode=fee.adacode AND fee.feesched='" + feeSched.ToString() + "' ORDER BY procedurecode.adacode"; FormQuery2 = new FormQuery(); FormQuery2.IsReport = true; if (radioADA.Checked == true) { FormQuery2.SubmitReportQuery(); Queries.CurReport.Title = "Procedure Codes"; Queries.CurReport.SubTitle = new string[2]; Queries.CurReport.SubTitle[0] = ((Pref)PrefB.HList["PracticeTitle"]).ValueString; Queries.CurReport.SubTitle[1] = DefB.GetName(DefCat.FeeSchedNames, feeSched); Queries.CurReport.ColPos = new int[6]; Queries.CurReport.ColCaption = new string[5]; Queries.CurReport.ColAlign = new HorizontalAlignment[5]; Queries.CurReport.ColPos[0] = 60; Queries.CurReport.ColPos[1] = 130; Queries.CurReport.ColPos[2] = 200; Queries.CurReport.ColPos[3] = 220; Queries.CurReport.ColPos[4] = 420; Queries.CurReport.ColPos[5] = 620; Queries.CurReport.ColCaption[0] = "ADA Code"; Queries.CurReport.ColCaption[1] = "Fee Amount"; Queries.CurReport.ColCaption[2] = " "; //otherwise, the amount gets bunched up next to the description. Queries.CurReport.ColCaption[3] = "Description"; Queries.CurReport.ColCaption[4] = "Abbr Description"; //Queries.CurReport.ColCaption[3]="Fee Amount"; Queries.CurReport.ColAlign[1] = HorizontalAlignment.Right; Queries.CurReport.Summary = new string[0]; FormQuery2.ShowDialog(); DialogResult = DialogResult.OK; } else { Queries.SubmitTemp(); //create TableTemp which is not actually used ProcedureCode[] ProcList = ProcedureCodes.GetProcList(); Queries.TableQ = new DataTable(null); for (int i = 0; i < 5; i++) //add columns { Queries.TableQ.Columns.Add(new System.Data.DataColumn()); //blank columns } Queries.CurReport.ColTotal = new double[Queries.TableQ.Columns.Count]; DataRow row = Queries.TableQ.NewRow();//add first row by hand to get value for temp row[0] = DefB.GetName(DefCat.ProcCodeCats, ProcList[0].ProcCat); catName = row[0].ToString(); row[1] = ProcList[0].ADACode; row[2] = ProcList[0].Descript; row[3] = ProcList[0].AbbrDesc; row[4] = ((double)Fees.GetAmount0(ProcList[0].ADACode, feeSched)).ToString("F"); Queries.CurReport.ColTotal[4] += PIn.PDouble(row[4].ToString()); Queries.TableQ.Rows.Add(row); for (int i = 1; i < ProcList.Length; i++) //loop through data rows { row = Queries.TableQ.NewRow(); //create new row called 'row' based on structure of TableQ row[0] = DefB.GetName(DefCat.ProcCodeCats, ProcList[i].ProcCat); if (catName == row[0].ToString()) { row[0] = ""; } else { catName = row[0].ToString(); } row[1] = ProcList[i].ADACode.ToString(); row[2] = ProcList[i].Descript; row[3] = ProcList[i].AbbrDesc.ToString(); row[4] = ((double)Fees.GetAmount0(ProcList[i].ADACode, feeSched)).ToString("F"); //Queries.CurReport.ColTotal[4]+=PIn.PDouble(row[4].ToString()); Queries.TableQ.Rows.Add(row); } Queries.CurReport.ColWidth = new int[Queries.TableQ.Columns.Count]; Queries.CurReport.ColPos = new int[Queries.TableQ.Columns.Count + 1]; Queries.CurReport.ColPos[0] = 0; Queries.CurReport.ColCaption = new string[Queries.TableQ.Columns.Count]; Queries.CurReport.ColAlign = new HorizontalAlignment[Queries.TableQ.Columns.Count]; FormQuery2.ResetGrid(); //this is a method in FormQuery2; Queries.CurReport.Title = "Procedure Codes"; Queries.CurReport.SubTitle = new string[5]; Queries.CurReport.SubTitle[0] = ((Pref)PrefB.HList["PracticeTitle"]).ValueString; Queries.CurReport.SubTitle[1] = DefB.GetName(DefCat.FeeSchedNames, feeSched); Queries.CurReport.ColPos[0] = 20; Queries.CurReport.ColPos[1] = 120; Queries.CurReport.ColPos[2] = 270; Queries.CurReport.ColPos[3] = 470; Queries.CurReport.ColPos[4] = 620; Queries.CurReport.ColPos[5] = 770; Queries.CurReport.ColCaption[0] = "Category"; Queries.CurReport.ColCaption[1] = "ADA Code"; Queries.CurReport.ColCaption[2] = "Description"; Queries.CurReport.ColCaption[3] = "Abbr Description"; Queries.CurReport.ColCaption[4] = "Fee Amount"; Queries.CurReport.ColAlign[4] = HorizontalAlignment.Right; Queries.CurReport.Summary = new string[5]; FormQuery2.ShowDialog(); DialogResult = DialogResult.OK; } }