private void butOK_Click(object sender, System.EventArgs e) { if (textChargeAmt.errorProvider1.GetError(textChargeAmt) != "" || textDateStart.errorProvider1.GetError(textDateStart) != "" || textDateStop.errorProvider1.GetError(textDateStop) != "" ) { MsgBox.Show(this, "Please fix data entry errors first."); return; } if (textDateStart.Text == "") { MsgBox.Show(this, "Start date cannot be left blank."); return; } if (PIn.PDate(textDateStart.Text) < DateTime.Today.AddMonths(-1)) { MsgBox.Show(this, "Start date cannot be more than a month in the past. But you can still enter previous charges manually in the account."); return; } RepeatCur.ADACode = textADACode.Text; RepeatCur.ChargeAmt = PIn.PDouble(textChargeAmt.Text); RepeatCur.DateStart = PIn.PDate(textDateStart.Text); RepeatCur.DateStop = PIn.PDate(textDateStop.Text); RepeatCur.Note = textNote.Text; if (IsNew) { RepeatCharges.Insert(RepeatCur); } else { RepeatCharges.Update(RepeatCur); } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if (textChargeAmt.errorProvider1.GetError(textChargeAmt) != "" || textDateStart.errorProvider1.GetError(textDateStart) != "" || textDateStop.errorProvider1.GetError(textDateStop) != "" ) { MsgBox.Show(this, "Please fix data entry errors first."); return; } if (textDateStart.Text == "") { MsgBox.Show(this, "Start date cannot be left blank."); return; } if (PIn.Date(textDateStart.Text) != RepeatCur.DateStart) //if the user changed the date { if (PIn.Date(textDateStart.Text) < DateTime.Today.AddDays(-3)) //and if the date the user entered is more than three days in the past { MsgBox.Show(this, "Start date cannot be more than three days in the past. You should enter previous charges manually in the account."); return; } } RepeatCur.ProcCode = textCode.Text; RepeatCur.ChargeAmt = PIn.Double(textChargeAmt.Text); RepeatCur.DateStart = PIn.Date(textDateStart.Text); RepeatCur.DateStop = PIn.Date(textDateStop.Text); RepeatCur.Note = textNote.Text; RepeatCur.CopyNoteToProc = checkCopyNoteToProc.Checked; RepeatCur.IsEnabled = checkIsEnabled.Checked; RepeatCur.CreatesClaim = checkCreatesClaim.Checked; if (IsNew) { RepeatCharges.Insert(RepeatCur); } else { RepeatCharges.Update(RepeatCur); } DialogResult = DialogResult.OK; }
private void butProcess_Click(object sender, EventArgs e) { if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will add a new repeating charge for each provider in the list above" + " who is new (does not already have a repeating charge), based on PatNum and NPI. Continue?")) { return; } Cursor = Cursors.WaitCursor; int numChargesAdded = 0; int numSkipped = 0; for (int i = 0; i < gridBillingList.Rows.Count; i++) { long patNum = PIn.Long(gridBillingList.Rows[i].Cells[0].Text); string npi = PIn.String(gridBillingList.Rows[i].Cells[1].Text); string billingType = gridBillingList.Rows[i].Cells[3].Text; List <RepeatCharge> repeatChargesNewCrop = RepeatCharges.GetForNewCrop(patNum); RepeatCharge repeatCur = GetRepeatChargeForNPI(repeatChargesNewCrop, npi); if (repeatCur == null) //No such repeating charge exists yet for the given npi. //We consider the provider a new provider and create a new repeating charge. { string yearMonth = gridBillingList.Rows[i].Cells[2].Text; int yearBilling = PIn.Int(yearMonth.Substring(0, 4)); //The year chosen by the OD employee when running the NewCrop Billing report. int monthBilling = PIn.Int(yearMonth.Substring(4)); //The month chosen by the OD employee when running the NewCrop Billing report. int dayOtherCharges = GetChargeDayOfMonth(patNum); //The day of the month that the customer already has other repeating charges. Keeps their billing simple (one bill per month for all charges). DateTime dateNewCropCharge = new DateTime(yearBilling, monthBilling, dayOtherCharges); if (dateNewCropCharge < DateTime.Today.AddMonths(-3)) //Just in case the user runs an older report. { numSkipped++; continue; } repeatCur = new RepeatCharge(); repeatCur.IsNew = true; repeatCur.PatNum = patNum; repeatCur.ProcCode = GetProcCodeForNewCharge(repeatChargesNewCrop); repeatCur.ChargeAmt = 15; //15$/month repeatCur.DateStart = dateNewCropCharge; repeatCur.Note = "NPI=" + npi; repeatCur.IsEnabled = true; RepeatCharges.Insert(repeatCur); numChargesAdded++; } else //The repeating charge for NewCrop billing already exists for the given npi. { DateTime dateEndLastMonth = (new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)).AddDays(-1); if (billingType == "B" || billingType == "N") //The provider sent eRx last month. { if (repeatCur.DateStop.Year > 2010) //NewCrop support for this provider was disabled at one point, but has been used since. { if (repeatCur.DateStop < dateEndLastMonth) //If the stop date is in the future or already at the end of the month, then we cannot presume that there will be a charge next month. { repeatCur.DateStop = dateEndLastMonth; //Make sure the recent use is reflected in the end date. RepeatCharges.Update(repeatCur); } } } else if (billingType == "U") //The provider did not send eRx last month, but did send eRx two months ago. //Customers must call in to disable repeating charges, they are not disabled automatically. { } else { throw new Exception("Unknown NewCrop Billing type " + billingType); } } } FillGrid(); Cursor = Cursors.Default; string msg = "Done. Number of provider charges added: " + numChargesAdded; if (numSkipped > 0) { msg += Environment.NewLine + "Number skipped due to old DateBilling (over 3 months ago): " + numSkipped; } MessageBox.Show(msg); }
private void butProcess_Click(object sender, EventArgs e) { if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will add a new repeating charge for each provider in the list above" + " who is new (does not already have a repeating charge), based on PatNum and NPI. Continue?")) { return; } Cursor = Cursors.WaitCursor; List <NewCropCharge> listAddedCharges = new List <NewCropCharge>(); int numSkipped = 0; StringBuilder strBldArchivedPats = new StringBuilder(); foreach (NewCropCharge charge in _listNewCropCharges) { if (charge.repeatCharge == null) //No such repeating charge exists yet for the given npi. //We consider the provider a new provider and create a new repeating charge. { int dayOtherCharges = GetChargeDayOfMonth(charge.PatNumForRegKey); //The day of the month that the customer already has other repeating charges. Keeps their billing simple (one bill per month for all charges). int daysInMonth = DateTime.DaysInMonth(_dateBillingMonthYear.Year, _dateBillingMonthYear.Month); if (dayOtherCharges > daysInMonth) { //The day that the user used eRx (signed up) was in a month that does not have the day of the other monthly charges in it. //E.g. dayOtherCharges = 31 and the user started a new eRx account in a month without 31 days. //Therefore, we have to use the last day of the month that they started. //This can introduce multiple statements being sent out which can potentially delay us (HQ) from getting paid in a timely fashion. //A workaround for this would be to train our techs to never run billing after the 28th of every month that way incomplete statements are not sent. dayOtherCharges = daysInMonth; } DateTime dateErxCharge = new DateTime(_dateBillingMonthYear.Year, _dateBillingMonthYear.Month, dayOtherCharges); if (dateErxCharge < DateTime.Today.AddMonths(-3)) //Just in case the user runs an older report. { numSkipped++; continue; } charge.repeatCharge = new RepeatCharge(); charge.repeatCharge.IsNew = true; charge.repeatCharge.PatNum = charge.PatNumForRegKey; charge.repeatCharge.ProcCode = GetProcCodeForNewCharge(charge.PatNumForRegKey); charge.repeatCharge.ChargeAmt = 15; //15$/month charge.repeatCharge.DateStart = dateErxCharge; charge.repeatCharge.Npi = charge.NPI; charge.repeatCharge.ErxAccountId = charge.AccountId; charge.repeatCharge.ProviderName = charge.FirstName + " " + charge.LastName; charge.repeatCharge.IsEnabled = true; charge.repeatCharge.CopyNoteToProc = true; //Copy the billing note to the procedure note by default so that the customer can see the NPI the charge corresponds to. Can be unchecked by user if a private note is added later (rare). if (!RepeatCharges.ActiveRepeatChargeExists(charge.repeatCharge.PatNum)) { //Set the patient's billing day to the start day on the repeat charge Patient patOld = Patients.GetPat(charge.repeatCharge.PatNum); Patient patNew = patOld.Copy(); //Check the patients status and move them to Archived if they are currently deleted. if (patOld.PatStatus == PatientStatus.Deleted) { patNew.PatStatus = PatientStatus.Archived; } //Notify the user about any deleted or archived patients that were just given a new repeating charge. if (patOld.PatStatus == PatientStatus.Archived || patOld.PatStatus == PatientStatus.Deleted) { strBldArchivedPats.AppendLine("#" + patOld.PatNum + " - " + patOld.GetNameLF()); } patNew.BillingCycleDay = charge.repeatCharge.DateStart.Day; Patients.Update(patNew, patOld); } RepeatCharges.Insert(charge.repeatCharge); _listErxRepeatCharges.Add(charge.repeatCharge); listAddedCharges.Add(charge); } else //The repeating charge for eRx billing already exists for the given npi. { DateTime dateEndLastMonth = (new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)).AddDays(-1); if (charge.repeatCharge.DateStop.Year > 2010) //eRx support for this provider was disabled at one point, but has been used since. { if (charge.repeatCharge.DateStop < dateEndLastMonth) //If the stop date is in the future or already at the end of the month, then we cannot presume that there will be a charge next month. { charge.repeatCharge.DateStop = dateEndLastMonth; //Make sure the recent use is reflected in the end date. RepeatCharges.Update(charge.repeatCharge); } } } } FillGrid(); Cursor = Cursors.Default; StringBuilder sbMsg = new StringBuilder(); sbMsg.AppendLine("Done."); if (numSkipped > 0) { sbMsg.AppendLine("Number skipped due to old DateBilling (over 3 months ago): " + numSkipped); } if (listAddedCharges.Count > 0) { const int colNameWidth = 62; const int colErxAccountIdWidth = 18; const int colNpiWidth = 10; sbMsg.AppendLine("Added the following new repeating charges (" + listAddedCharges.Count + " total):"); sbMsg.Append(" "); sbMsg.Append("NAME".PadRight(colNameWidth, ' ')); sbMsg.Append("ERXACCOUNTID".PadRight(colErxAccountIdWidth, ' ')); sbMsg.AppendLine("NPI".PadRight(colNpiWidth, ' ')); foreach (NewCropCharge charge in listAddedCharges) { string firstLastName = charge.FirstName + " " + charge.LastName; if (firstLastName.Length > colNameWidth) { firstLastName = firstLastName.Substring(0, colNameWidth); } sbMsg.Append(" "); sbMsg.Append(firstLastName.PadRight(colNameWidth, ' ')); sbMsg.Append(charge.AccountId.PadRight(colErxAccountIdWidth, ' ')); sbMsg.AppendLine(charge.NPI.PadRight(colNpiWidth, ' ')); } } if (strBldArchivedPats.Length > 0) { sbMsg.AppendLine("Archived patients that had a repeating charge created:"); sbMsg.AppendLine(strBldArchivedPats.ToString()); } MsgBoxCopyPaste msgBoxCP = new MsgBoxCopyPaste(sbMsg.ToString()); msgBoxCP.ShowDialog(); //Must be modal, because non-modal does not display here for some reason. }
private void butOK_Click(object sender, EventArgs e) { if (textChargeAmt.errorProvider1.GetError(textChargeAmt) != "" || textDateStart.errorProvider1.GetError(textDateStart) != "" || textDateStop.errorProvider1.GetError(textDateStop) != "" || textBillingDay.errorProvider1.GetError(textBillingDay) != "" ) { MsgBox.Show(this, "Please fix data entry errors first."); return; } if (textDateStart.Text == "") { MsgBox.Show(this, "Start date cannot be left blank."); return; } if (PIn.Date(textDateStart.Text) != RepeatCur.DateStart) //if the user changed the date { if (PIn.Date(textDateStart.Text) < DateTime.Today.AddDays(-3)) //and if the date the user entered is more than three days in the past { MsgBox.Show(this, "Start date cannot be more than three days in the past. You should enter previous charges manually in the account."); return; } } if (textDateStop.Text.Trim() != "" && PIn.Date(textDateStart.Text) > PIn.Date(textDateStop.Text)) { if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "The start date is after the stop date. Continue?")) { return; } } if (_isErx && !Regex.IsMatch(textNpi.Text, "^[0-9]{10}$")) { MsgBox.Show(this, "Invalid NPI. Must be 10 digits."); return; } if (_isErx && textErxAccountId.Text != "" && !Regex.IsMatch(textErxAccountId.Text, "^[0-9]+\\-[a-zA-Z0-9]{5}$")) { MsgBox.Show(this, "Invalid ErxAccountId."); return; } if (PrefC.GetBool(PrefName.BillingUseBillingCycleDay) && textBillingDay.Text != "") { Patient patOld = Patients.GetPat(RepeatCur.PatNum); Patient patNew = patOld.Copy(); patNew.BillingCycleDay = PIn.Int(textBillingDay.Text); Patients.Update(patNew, patOld); } RepeatCur.ProcCode = textCode.Text; RepeatCur.ChargeAmt = PIn.Double(textChargeAmt.Text); RepeatCur.DateStart = PIn.Date(textDateStart.Text); RepeatCur.DateStop = PIn.Date(textDateStop.Text); RepeatCur.Npi = textNpi.Text; RepeatCur.ErxAccountId = textErxAccountId.Text; RepeatCur.Note = textNote.Text; RepeatCur.ProviderName = textProvName.Text; RepeatCur.CopyNoteToProc = checkCopyNoteToProc.Checked; RepeatCur.IsEnabled = checkIsEnabled.Checked; RepeatCur.CreatesClaim = checkCreatesClaim.Checked; RepeatCur.UsePrepay = checkUsePrepay.Checked; if (IsNew) { if (!RepeatCharges.ActiveRepeatChargeExists(RepeatCur.PatNum) && (textBillingDay.Text == "" || textBillingDay.Text == "0")) { Patient patOld = Patients.GetPat(RepeatCur.PatNum); Patient patNew = patOld.Copy(); patNew.BillingCycleDay = PIn.Date(textDateStart.Text).Day; Patients.Update(patNew, patOld); } RepeatCharges.Insert(RepeatCur); if (PrefC.IsODHQ) { AddProcedureToCC(); } } else //not a new repeat charge { RepeatCharges.Update(RepeatCur); } DialogResult = DialogResult.OK; }
///<summary>Go through the transaction dictionary created in CreateProcedureLogs() to edit repeat charges as needed. ///Returns the note for the newly generated repeat charge.</summary> private void ZeroOutRepeatingCharge(ProcedureCode procCur, List <AvaTax.TransQtyAmt> listCurTrans) { Commlog prepaymentCommlog = new Commlog(); prepaymentCommlog.PatNum = _patCur.PatNum; prepaymentCommlog.SentOrReceived = CommSentOrReceived.Received; prepaymentCommlog.CommDateTime = DateTime.Now; prepaymentCommlog.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.FIN); prepaymentCommlog.Mode_ = CommItemMode.None; prepaymentCommlog.Note = "";//Appended to below. prepaymentCommlog.UserNum = Security.CurUser.UserNum; string note = "From PrepaymentTool: \r\n"; bool hasBeenBilledThisMonth = (DateTimeOD.Today.Day >= _patCur.BillingCycleDay); //Get all applicable repeat charges. List <RepeatCharge> listRcForProc = _listRcForPat.FindAll(x => x.ProcCode == procCur.ProcCode && x.IsEnabled); //Get number of months new repeat charge will be for. int numMonths = listCurTrans.Sum(x => x.qty); //Create repeat charge, taken from ContrAccount.cs RepeatCharge rcNew = new RepeatCharge(); rcNew.PatNum = _patCur.PatNum; rcNew.ProcCode = procCur.ProcCode; rcNew.ChargeAmt = 0; rcNew.IsEnabled = true; rcNew.CopyNoteToProc = true; //Build dates using billing day so the patient doesn't have gaps in their repeat charges. DateTime dateBillThisMonth = DateTimeOD.GetMostRecentValidDate(DateTime.Today.Year, DateTime.Today.Month, _patCur.BillingCycleDay); if (hasBeenBilledThisMonth) { //Current month has been billed, push new repeat charge out a month. rcNew.DateStart = dateBillThisMonth.AddMonths(1); rcNew.DateStop = dateBillThisMonth.AddMonths(numMonths); } else { //Current month has not been billed yet, include on this repeat charge. rcNew.DateStart = dateBillThisMonth; rcNew.DateStop = dateBillThisMonth.AddMonths(numMonths - 1); } //Use the stop date to update the Note as requested by Accounting. DatePrepaidThrough = rcNew.DateStop.AddMonths(1).AddDays(-1); rcNew.Note = _prepaidThroughNote; //Edit exisiting repeat charge start/stop dates. foreach (RepeatCharge rcExisting in listRcForProc) { if (rcExisting.DateStop.Year > 1880 && rcExisting.DateStop < DateTimeOD.Today) { continue; //The charge has a stop date in the past (has been disabled). } if (rcExisting.DateStop.Year > 1880 && rcExisting.DateStop <= DateTimeOD.Today.AddMonths(numMonths)) { rcExisting.DateStop = DateTimeOD.Today; rcExisting.IsEnabled = false; //This repeat charge will never be used again due to the prepayment we are creating right now. Disable and add note to commlog for history. note += "Disabled repeat charge with Rate: " + POut.Double(rcExisting.ChargeAmt) + " for Code: " + POut.String(rcExisting.ProcCode) + " Start Date: " + POut.Date(rcExisting.DateStart) + " Stop Date: " + POut.Date(rcExisting.DateStop) + "\r\n"; RepeatCharges.Update(rcExisting); continue; } //Need to push start date of existing repeat charge forward one month past the new repeat charge (if charge months overlap). DateTime dateNext = rcNew.DateStop.AddMonths(1); if (dateNext > rcExisting.DateStart) //Only change if needed. { note += "Edited Start Date for repeat charge from: " + POut.Date(rcExisting.DateStart) + " to: " + POut.Date(dateNext) + " Code: " + POut.String(rcExisting.ProcCode) + " Rate: " + POut.Double(rcExisting.ChargeAmt) + "\r\n"; //Change to billing day to make sure it matches other repeat charges. rcExisting.DateStart = dateNext; RepeatCharges.Update(rcExisting); } } //Insert the new repeat charge. prepaymentCommlog.Note = note; Commlogs.Insert(prepaymentCommlog); RepeatCharges.Insert(rcNew); }