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; }
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 FormRepeatChargeEdit_Load(object sender, EventArgs e) { SetPatient(); if (IsNew) { FormProcCodes FormP = new FormProcCodes(); FormP.IsSelectionMode = true; FormP.ShowDialog(); if (FormP.DialogResult != DialogResult.OK) { DialogResult = DialogResult.Cancel; return; } ProcedureCode procCode = ProcedureCodes.GetProcCode(FormP.SelectedCodeNum); if (procCode.TreatArea != TreatmentArea.Mouth && procCode.TreatArea != TreatmentArea.None) { MsgBox.Show(this, "Procedure codes that require tooth numbers are not allowed."); DialogResult = DialogResult.Cancel; return; } RepeatCur.ProcCode = ProcedureCodes.GetStringProcCode(FormP.SelectedCodeNum); RepeatCur.IsEnabled = true; RepeatCur.CreatesClaim = false; } textCode.Text = RepeatCur.ProcCode; textDesc.Text = ProcedureCodes.GetProcCode(RepeatCur.ProcCode).Descript; textChargeAmt.Text = RepeatCur.ChargeAmt.ToString("F"); if (RepeatCur.DateStart.Year > 1880) { textDateStart.Text = RepeatCur.DateStart.ToShortDateString(); } if (RepeatCur.DateStop.Year > 1880) { textDateStop.Text = RepeatCur.DateStop.ToShortDateString(); } textNote.Text = RepeatCur.Note; _isErx = false; if (PrefC.GetBool(PrefName.DistributorKey) && Regex.IsMatch(RepeatCur.ProcCode, "^Z[0-9]{3,}$")) //Is eRx if HQ and a using an eRx Z code. { _isErx = true; labelPatNum.Visible = true; textPatNum.Visible = true; butMoveTo.Visible = true; labelNpi.Visible = true; textNpi.Visible = true; labelProviderName.Visible = true; textProvName.Visible = true; labelErxAccountId.Visible = true; textErxAccountId.Visible = true; if (!IsNew) //Existing eRx repeating charge. { textNpi.Text = RepeatCur.Npi; textErxAccountId.Text = RepeatCur.ErxAccountId; textProvName.Text = RepeatCur.ProviderName; textNpi.ReadOnly = true; textErxAccountId.ReadOnly = true; textProvName.ReadOnly = true; } } checkCopyNoteToProc.Checked = RepeatCur.CopyNoteToProc; checkCreatesClaim.Checked = RepeatCur.CreatesClaim; checkIsEnabled.Checked = RepeatCur.IsEnabled; if (PrefC.GetBool(PrefName.DistributorKey)) //OD HQ disable the IsEnabled and CreatesClaim checkboxes { checkCreatesClaim.Enabled = false; checkIsEnabled.Enabled = false; } if (PrefC.IsODHQ && EServiceCodeLink.IsProcCodeAnEService(RepeatCur.ProcCode)) { if (IsNew) { MsgBox.Show(this, "You cannot manually create any eService repeating charges.\r\n" + "Use the Signup Portal instead.\r\n\r\n" + "The Charge Amount can be manually edited after the Signup Portal has created the desired eService repeating charge."); DialogResult = DialogResult.Abort; return; } //The only things that users should be able to do for eServices are: //1. Change the repeating charge amount. //2. Manipulate the Start Date. //3. Manipulate the Note. //4. Manipulate Billing Day because not all customers will have a non-eService repeating charge in order to manipulate. //This is because legacy users (versions prior to 17.1) need the ability to manually set their monthly charge amount, etc. SetFormReadOnly(this, butOK, butCancel , textChargeAmt, labelChargeAmount , textDateStart, labelDateStart , textNote, labelNote , textBillingDay, labelBillingCycleDay); } Patient pat = Patients.GetPat(RepeatCur.PatNum); //pat should never be null. If it is, this will fail. //If this is a new repeat charge and no other active repeat charges exist, set the billing cycle day to today if (IsNew && !RepeatCharges.ActiveRepeatChargeExists(RepeatCur.PatNum)) { textBillingDay.Text = DateTimeOD.Today.Day.ToString(); } else { textBillingDay.Text = pat.BillingCycleDay.ToString(); } if (PrefC.GetBool(PrefName.BillingUseBillingCycleDay)) { labelBillingCycleDay.Visible = true; textBillingDay.Visible = true; } checkUsePrepay.Checked = RepeatCur.UsePrepay; }