///<summary>Downloads Canadian procedure codes from our website and updates _codeList accordingly.</summary> private void CanadaDownloadProcedureCodes() { Cursor = Cursors.WaitCursor; _codeList = new List <ProcedureCode>(); string url = @"http://www.opendental.com/feescanada/procedurecodes.txt"; string tempFile = PrefC.GetRandomTempFile(".tmp"); WebClient myWebClient = new WebClient(); try { myWebClient.DownloadFile(url, tempFile); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Failed to download procedure codes") + ":\r\n" + ex.Message); Cursor = Cursors.Default; return; } string codeData = File.ReadAllText(tempFile); File.Delete(tempFile); string[] codeLines = codeData.Split('\n'); for (int i = 0; i < codeLines.Length; i++) { string[] fields = codeLines[i].Split('\t'); if (fields.Length < 1) //Skip blank lines if they exist. { continue; } ProcedureCode procCode = new ProcedureCode(); procCode.ProcCode = PIn.String(fields[0]); //0 ProcCode procCode.Descript = PIn.String(fields[1]); //1 Description procCode.TreatArea = (TreatmentArea)PIn.Int(fields[2]); //2 TreatArea procCode.NoBillIns = PIn.Bool(fields[3]); //3 NoBillIns procCode.IsProsth = PIn.Bool(fields[4]); //4 IsProsth procCode.IsHygiene = PIn.Bool(fields[5]); //5 IsHygiene procCode.PaintType = (ToothPaintingType)PIn.Int(fields[6]); //6 PaintType procCode.ProcCatDescript = PIn.String(fields[7]); //7 ProcCatDescript procCode.ProcTime = PIn.String(fields[8]); //8 ProcTime procCode.AbbrDesc = PIn.String(fields[9]); //9 AbbrDesc procCode.CanadaTimeUnits = PIn.Double(fields[10]); //10 CanadaTimeUnits _codeList.Add(procCode); } Cursor = Cursors.Default; }
private void butExport_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; SaveFileDialog Dlg = new SaveFileDialog(); if (Directory.Exists(PrefC.GetString(PrefName.ExportPath))) { Dlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath); } else if (Directory.Exists("C:\\")) { Dlg.InitialDirectory = "C:\\"; } Dlg.FileName = "Fees" + FeeScheds.GetDescription(SchedNum) + ".txt"; if (Dlg.ShowDialog() != DialogResult.OK) { Cursor = Cursors.Default; return; } //MessageBox.Show(Dlg.FileName);//includes full path //OverwritePrompt is already set to true DataTable table = ProcedureCodes.GetProcTable("", "", "", new List <long>(), SchedNum, 0, 0); double fee; using (StreamWriter sr = File.CreateText(Dlg.FileName)){ for (int i = 0; i < table.Rows.Count; i++) { sr.Write(PIn.String(table.Rows[i]["ProcCode"].ToString()) + "\t"); fee = PIn.Double(table.Rows[i]["FeeAmt1"].ToString()); if (fee != -1) { sr.Write(fee.ToString("n")); } sr.Write("\t"); sr.Write(PIn.String(table.Rows[i]["AbbrDesc"].ToString()) + "\t"); sr.WriteLine(PIn.String(table.Rows[i]["Descript"].ToString())); } } Cursor = Cursors.Default; DialogResult = DialogResult.OK; }
private void FillFields() { long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } textUsername.Text = ProgramProperties.GetPropValFromList(_listProgProps, "Username", clinicNum); textPassword.Text = ProgramProperties.GetPropValFromList(_listProgProps, "Password", clinicNum); textPassword.UseSystemPasswordChar = textPassword.Text.Trim().Length > 0; string payTypeDefNum = ProgramProperties.GetPropValFromList(_listProgProps, "PaymentType", clinicNum); string processingMethod = ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.DefaultProcessingMethod, clinicNum); checkTerminal.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, "TerminalProcessingEnabled", clinicNum)); checkForceRecurring.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PayConnectForceRecurringCharge, clinicNum)); checkPreventSavingNewCC.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, clinicNum)); checkPatientPortalPayEnabled.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PatientPortalPaymentsEnabled, clinicNum)); textToken.Text = PIn.String(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PatientPortalPaymentsToken, clinicNum)); comboPaymentType.Items.Clear(); _listPaymentTypeDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true); for (int i = 0; i < _listPaymentTypeDefs.Count; i++) { comboPaymentType.Items.Add(_listPaymentTypeDefs[i].ItemName); if (_listPaymentTypeDefs[i].DefNum.ToString() == payTypeDefNum) { comboPaymentType.SelectedIndex = i; } } comboDefaultProcessing.Items.Clear(); comboDefaultProcessing.Items.Add(Lan.g(this, PayConnectProcessingMethod.WebService.GetDescription())); comboDefaultProcessing.Items.Add(Lan.g(this, PayConnectProcessingMethod.Terminal.GetDescription())); if (processingMethod == "0" || processingMethod == "1") { comboDefaultProcessing.SelectedIndex = PIn.Int(processingMethod); } }
private void FormApptReminderRuleEdit_Load(object sender, EventArgs e) { textSMSAggShared.Text = PIn.String(ApptReminderRuleCur.TemplateSMSAggShared); textSMSAggPerAppt.Text = PIn.String(ApptReminderRuleCur.TemplateSMSAggPerAppt); textEmailSubjAggShared.Text = PIn.String(ApptReminderRuleCur.TemplateEmailSubjAggShared); _emailPlainTextShared = PIn.String(ApptReminderRuleCur.TemplateEmailAggShared); RefreshEmail(); textEmailAggPerAppt.Text = PIn.String(ApptReminderRuleCur.TemplateEmailAggPerAppt); labelTags.Text = GetTagsAvailable(); textSingleAutoReply.Text = PIn.String(ApptReminderRuleCur.TemplateAutoReply); textAggregateAutoReply.Text = PIn.String(ApptReminderRuleCur.TemplateAutoReplyAgg); if (ApptReminderRuleCur.TypeCur == ApptReminderType.PatientPortalInvite) { textSMSAggShared.Enabled = false; textSMSAggPerAppt.Enabled = false; labelEmailAggPerAppt.Text += " " + Lans.g(this, "Replaces the [Credentials] tag."); } if (ApptReminderRuleCur.TypeCur != ApptReminderType.ConfirmationFutureDay) { tabTemplates.TabPages.Remove(tabAutoReplyTemplate); } }
private void butOK_Click(object sender, System.EventArgs e) { carrier = PIn.String(textBoxCarrier.Text); ReportSimpleGrid report = new ReportSimpleGrid(); /* * SELECT insplan.subscriber,insplan.carrier,patient.hmphone, * insplan.groupname FROM insplan,patient WHERE insplan.subscriber=patient.patnum * && insplan.carrier like +carrier+'%' * Order By patient.lname,patient.fname * */ report.Query = "SELECT carrier.CarrierName" + ",CONCAT(CONCAT(CONCAT(CONCAT(patient.LName,', '),patient.FName),' '),patient.MiddleI),carrier.Phone," + "insplan.Groupname " + "FROM insplan,inssub,patient,carrier " //,patplan "//we only include patplan to make sure insurance is active for a patient. We don't want any info from patplan. + "WHERE inssub.Subscriber=patient.PatNum " + "AND inssub.PlanNum=insplan.PlanNum " + "AND EXISTS (SELECT * FROM patplan WHERE patplan.InsSubNum=inssub.InsSubNum) " //+"AND insplan.PlanNum=patplan.PlanNum " //+"AND patplan.PatNum=patient.PatNum " //+"AND patplan.Ordinal=1 " + "AND carrier.CarrierNum=insplan.CarrierNum " + "AND carrier.CarrierName LIKE '" + carrier + "%' " + "ORDER BY carrier.CarrierName,patient.LName"; //Debug.WriteLine(report.Query); FormQuery2 = new FormQuery(report); FormQuery2.IsReport = true; FormQuery2.SubmitReportQuery(); report.Title = "Insurance Plan List"; report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle)); report.SetColumn(this, 0, "Carrier Name", 230); report.SetColumn(this, 1, "Subscriber Name", 175); report.SetColumn(this, 2, "Carrier Phone#", 175); report.SetColumn(this, 3, "Group Name", 165); report.Summary.Add(Lan.g(this, "Total: ") + report.TableQ.Rows.Count.ToString()); FormQuery2.ShowDialog(); DialogResult = DialogResult.OK; }
protected override void OnOk() { if (!ArePosAndSizeValid()) { return; } SheetFieldDefCur.TabOrder = PIn.Int(textTabOrder.Text); SheetFieldDefCur.ReportableName = PIn.String(textReportable.Text); SheetFieldDefCur.UiLabelMobile = textUiLabelMobile.Text; //ComboBox FieldValue will be: selectedItem;all|possible|options|here|with|selectedItem|also //This is so we don't have to change the database schema for combo boxes. SheetFieldDefCur.FieldValue = _selectedOption + ";"; //NOTE: ; can change to whatever. Maybe {? Maybe something else not used often like @? for (int i = 0; i < listboxComboOptions.Items.Count; i++) { if (i > 0) { SheetFieldDefCur.FieldValue += "|"; } SheetFieldDefCur.FieldValue += listboxComboOptions.Items[i].ToString(); } SheetFieldDefCur.IsNew = false; DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textName.Text.Trim())) { MsgBox.Show(this, "Reason required."); return; } if (_apptTypeCur == null) { MsgBox.Show(this, "Appointment Type required."); return; } _defCur.ItemName = PIn.String(textName.Text); if (_defCur.IsNew) { Defs.Insert(_defCur); } else { Defs.Update(_defCur); } DefLinks.SetFKeyForDef(_defCur.DefNum, _apptTypeCur.AppointmentTypeNum, DefLinkType.AppointmentType); DialogResult = DialogResult.OK; }
private void butAdd_Click(object sender, EventArgs e) { if (!PrefC.GetBool(PrefName.StoreCCnumbers)) { if (Programs.IsEnabled(ProgramName.Xcharge)) { Program prog = Programs.GetCur(ProgramName.Xcharge); if (!File.Exists(prog.Path)) { MsgBox.Show(this, "Path is not valid."); if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); if (FormX.DialogResult != DialogResult.OK) { return; } } } string user = ProgramProperties.GetPropVal(prog.ProgramNum, "Username"); string password = ProgramProperties.GetPropVal(prog.ProgramNum, "Password"); ProcessStartInfo info = new ProcessStartInfo(prog.Path); string resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt"); File.Delete(resultfile); //delete the old result file. info.Arguments = ""; info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + user + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT "; info.Arguments += "/STAYONTOP "; info.Arguments += "/SMARTAUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/HIDEMAINWINDOW "; info.Arguments += "/SMALLWINDOW "; info.Arguments += "/NORESULTDIALOG "; info.Arguments += "/TOOLBAREXITBUTTON "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; string xChargeToken = ""; string accountMasked = ""; string exp = "";; bool insertCard = false; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { break; } insertCard = true; } if (line.StartsWith("XCACCOUNTID=")) { xChargeToken = PIn.String(line.Substring(12)); } if (line.StartsWith("ACCOUNT=")) { accountMasked = PIn.String(line.Substring(8)); } if (line.StartsWith("EXPIRATION=")) { exp = PIn.String(line.Substring(11)); } line = reader.ReadLine(); } if (insertCard && xChargeToken != "") //Might not be necessary but we've had successful charges with no tokens returned before. { CreditCard creditCardCur = new CreditCard(); List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); creditCardCur.PatNum = PatCur.PatNum; creditCardCur.ItemOrder = itemOrderCount.Count; creditCardCur.CCNumberMasked = accountMasked; creditCardCur.XChargeToken = xChargeToken; creditCardCur.CCExpiration = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1); CreditCards.Insert(creditCardCur); } } RefreshCardList(); return; } else { MsgBox.Show(this, "Not allowed to store credit cards."); return; } } bool remember = false; int placement = listCreditCards.SelectedIndex; if (placement != -1) { remember = true; } FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur); FormCCE.CreditCardCur = new CreditCard(); FormCCE.CreditCardCur.IsNew = true; FormCCE.ShowDialog(); RefreshCardList(); if (remember) //in case they canceled and had one selected { listCreditCards.SelectedIndex = placement; } if (FormCCE.DialogResult == DialogResult.OK && creditCards.Count > 0) { listCreditCards.SelectedIndex = 0; } }
private void butAdd_Click(object sender, EventArgs e) { if (!PrefC.GetBool(PrefName.StoreCCnumbers)) { bool hasXCharge = false; bool hasPayConnect = false; bool hasPaySimple = false; Dictionary <string, int> dictEnabledProcessors = new Dictionary <string, int>(); int idx = 0; bool hasXChargePreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.Xcharge).ProgramNum, ProgramProperties.PropertyDescs.XCharge.XChargePreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd) { dictEnabledProcessors["X-Charge"] = idx++; } bool hasPayConnectPreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PayConnect).ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd) { dictEnabledProcessors["PayConnect"] = idx++; } bool hasPaySimplePreventCCAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PaySimple).ProgramNum, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd) { dictEnabledProcessors["PaySimple"] = idx++; } if (dictEnabledProcessors.Count > 1) { List <string> listCCProcessors = dictEnabledProcessors.Select(x => x.Key).ToList(); InputBox chooseProcessor = new InputBox(Lan.g(this, "For which credit card processing company would you like to add this card?"), listCCProcessors, true); if (chooseProcessor.ShowDialog() == DialogResult.Cancel) { return; } hasXCharge = dictEnabledProcessors.ContainsKey("X-Charge") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["X-Charge"]); hasPayConnect = dictEnabledProcessors.ContainsKey("PayConnect") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PayConnect"]); hasPaySimple = dictEnabledProcessors.ContainsKey("PaySimple") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PaySimple"]); } else if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd) { hasXCharge = true; } else if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd) { hasPayConnect = true; } else if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd) { hasPaySimple = true; } else //not storing CC numbers and both PayConnect and X-Charge are disabled { MsgBox.Show(this, "Not allowed to store credit cards."); return; } CreditCard creditCardCur = null; if (hasXCharge) { if (ODBuild.IsWeb()) { MsgBox.Show(this, "XCharge is not available while viewing through the web."); return; } Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); string xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim(); string xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim(); //Force user to retry entering information until it's correct or they press cancel while (!File.Exists(path) || string.IsNullOrEmpty(xPassword) || string.IsNullOrEmpty(xUsername)) { MsgBox.Show(this, "The Path, Username, and/or Password for X-Charge have not been set or are invalid."); if (!Security.IsAuthorized(Permissions.Setup)) { return; } FormXchargeSetup FormX = new FormXchargeSetup(); //refreshes program and program property caches on OK click FormX.ShowDialog(); if (FormX.DialogResult != DialogResult.OK) //if user presses cancel, return { return; } prog = Programs.GetCur(ProgramName.Xcharge); //refresh local variable prog to reflect any changes made in setup window path = Programs.GetProgramPath(prog); xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim(); xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim(); } xPassword = CodeBase.MiscUtils.Decrypt(xPassword); ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = PrefC.GetRandomTempFile("txt"); try { File.Delete(resultfile); //delete the old result file. } catch { MsgBox.Show(this, "Could not delete XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have sufficient permissions."); return; } info.Arguments = ""; info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + xUsername + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT "; info.Arguments += "/STAYONTOP "; info.Arguments += "/SMARTAUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/HIDEMAINWINDOW "; info.Arguments += "/SMALLWINDOW "; info.Arguments += "/NORESULTDIALOG "; info.Arguments += "/TOOLBAREXITBUTTON "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; string xChargeToken = ""; string accountMasked = ""; string exp = "";; bool insertCard = false; try { using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { throw new Exception(); } insertCard = true; } if (line.StartsWith("XCACCOUNTID=")) { xChargeToken = PIn.String(line.Substring(12)); } if (line.StartsWith("ACCOUNT=")) { accountMasked = PIn.String(line.Substring(8)); } if (line.StartsWith("EXPIRATION=")) { exp = PIn.String(line.Substring(11)); } line = reader.ReadLine(); } if (insertCard && xChargeToken != "") //Might not be necessary but we've had successful charges with no tokens returned before. { creditCardCur = new CreditCard(); List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); creditCardCur.PatNum = PatCur.PatNum; creditCardCur.ItemOrder = itemOrderCount.Count; creditCardCur.CCNumberMasked = accountMasked; creditCardCur.XChargeToken = xChargeToken; creditCardCur.CCExpiration = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1); creditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs); creditCardCur.CCSource = CreditCardSource.XServer; creditCardCur.ClinicNum = Clinics.ClinicNum; CreditCards.Insert(creditCardCur); } } } catch (Exception) { MsgBox.Show(this, "There was a problem adding the credit card. Please try again."); } } if (hasPayConnect) { FormPayConnect FormPC = new FormPayConnect(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true); FormPC.ShowDialog(); } if (hasPaySimple) { FormPaySimple formPS = new FormPaySimple(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true); formPS.ShowDialog(); } FillGrid(); if (gridMain.ListGridRows.Count > 0 && creditCardCur != null) { gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true); } return; } //storing CC numbers allowed from here down FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur); FormCCE.CreditCardCur = new CreditCard(); FormCCE.CreditCardCur.IsNew = true; FormCCE.CreditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs); FormCCE.ShowDialog(); if (FormCCE.DialogResult == DialogResult.OK) { FillGrid(); if (gridMain.ListGridRows.Count > 0) { gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true); } } }
private void butRun_Click(object sender, EventArgs e) { //The encounter file is a list of all of the appointments provided for Arizona Primary Care patients within the specified //date range. Since each encounter/appointment is reimbursed by the local government at a flat rate, we only need to report //a single procedure for each appointment in the encounter file and if there is a question by the government as to the other //procedures that were performed during a particular appointment, then the dental office can simply look that information up //in Open Dental (but no such calls will likely happen). Thus we always use the same Diagnosis code corresponding to the single //ADA code that we emit in this flat file, just to keep things simple and workable. this.textLog.Text = ""; string outFile = ODFileUtils.CombinePaths(this.textEncounterFolder.Text, this.textEncounterFile.Text); if (File.Exists(outFile)) { if (MessageBox.Show("The file at " + outFile + " already exists. Overwrite?", "Overwrite File?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } string command = ""; //Locate the payment definition number for payments of patients using the Arizona Primary Care program. command = "SELECT DefNum FROM definition WHERE Category=" + POut.Long((int)DefCat.PaymentTypes) + " AND IsHidden=0 AND LOWER(TRIM(ItemName))='noah'"; DataTable payDefNumTab = Reports.GetTable(command); if (payDefNumTab.Rows.Count != 1) { MessageBox.Show("You must define exactly one payment type with the name 'NOAH' before running this report. " + "This payment type must be used on payments made by Arizona Primary Care patients."); return; } long payDefNum = PIn.Long(payDefNumTab.Rows[0][0].ToString()); string outputText = ""; string patientsIdNumberStr = "SPID#"; //Only certain procedures can be billed to the Arizona Primary Care program. //Since the code list doesn't change often, it is simply hard coded here. string billableProcedures = "'D0120','D0140','D0150','D0160','D1110','D1120','D1201','D1203','D1204','D1205','D1208'," + "'D1351','D1510','D1515','D1520','D1525','D1550','D4341','D4355','D4910','D2140','D2150','D2160','D2161'," + "'D2330','D2331','D2332','D2335','D2390','D2391','D2392','D2393','D2394','D2910','D2920','D2930','D2931'," + "'D2932','D2940','D2950','D2970','D3110','D3120','D3220','D3221','D3230','D3240','D7140','D7210','D7220'," + "'D7270','D7285','D7286','D7510','D9110','D9310','D9610'"; //Get the list of all Arizona Primary Care patients, based on the patients which have an insurance carrier named 'noah' command = "SELECT DISTINCT p.PatNum FROM patplan pp,inssub,insplan i,patient p,carrier c " + "WHERE p.PatNum=pp.PatNum AND inssub.InsSubNum=pp.InsSubNum AND inssub.PlanNum=i.PlanNum AND i.CarrierNum=c.CarrierNum " + "AND LOWER(TRIM(c.CarrierName))='noah'"; DataTable primaryCarePatients = Reports.GetTable(command); for (int i = 0; i < primaryCarePatients.Rows.Count; i++) { string patNum = POut.Long(PIn.Long(primaryCarePatients.Rows[i][0].ToString())); //Now that we have an Arizona Primary Care patient's patNum, we need to see if there are any appointments //that the patient has attented (completed) in the date range specified where there is at least one ADA coded procedure //associated with that appointment. If there are, then those appointments will be placed into the flat file. command = "SELECT a.AptNum FROM appointment a WHERE a.PatNum=" + patNum + " AND a.AptStatus=" + ((int)ApptStatus.Complete) + " AND " + "a.AptDateTime BETWEEN " + POut.Date(dateTimeFrom.Value) + " AND " + POut.Date(dateTimeTo.Value) + " AND " + "(SELECT COUNT(*) FROM procedurelog pl,procedurecode pc WHERE pl.AptNum=a.AptNum AND pc.CodeNum=pl.CodeNum AND " + "pc.ProcCode IN (" + billableProcedures + ") " + DbHelper.LimitAnd(1) + ")>0"; DataTable appointmentList = Reports.GetTable(command); for (int j = 0; j < appointmentList.Rows.Count; j++) { string aptNum = POut.Long(PIn.Long(appointmentList.Rows[j][0].ToString())); string datesql = "CURDATE()"; if (DataConnection.DBtype == DatabaseType.Oracle) { datesql = "(SELECT CURRENT_DATE FROM dual)"; } command = "SELECT " + "TRIM((SELECT f.FieldValue FROM patfield f WHERE f.PatNum=p.PatNum AND " + "LOWER(f.FieldName)=LOWER('" + patientsIdNumberStr + "') " + DbHelper.LimitAnd(1) + ")) PCIN, " + //Patient's Care ID Number "p.BirthDate," + //birthdate "(CASE p.Gender WHEN 0 THEN 'M' WHEN 1 THEN 'F' ELSE '' END) Gender," + //Gender "CONCAT(CONCAT(p.Address,' '),p.Address2) Address," + //address "p.City," + //city "p.State," + //state "p.Zip," + //zipcode "(SELECT CASE pp.Relationship WHEN 0 THEN 1 ELSE 0 END FROM patplan pp,inssub,insplan i,carrier c WHERE " + //Relationship to subscriber "pp.PatNum=" + patNum + " AND inssub.InsSubNum=pp.InsSubNum AND inssub.PlanNum=i.PlanNum AND i.CarrierNum=c.CarrierNum AND LOWER(TRIM(c.CarrierName))='noah' " + DbHelper.LimitAnd(1) + ") InsRelat," + "(CASE p.Position WHEN 0 THEN 1 WHEN 1 THEN 2 ELSE 3 END) MaritalStatus," + //Marital status "(CASE WHEN p.EmployerNum=0 THEN (CASE WHEN (" + DbHelper.DateAddYear("p.BirthDate", "18") + ">" + datesql + ") THEN 3 ELSE 2 END) ELSE 1 END) EmploymentStatus," + "(CASE p.StudentStatus WHEN 'f' THEN 1 WHEN 'p' THEN 2 ELSE 3 END) StudentStatus," + //student status "'ADHS PCP' InsurancePlanName," + //insurance plan name "'' ReferringPhysicianName," + //Name of referring physician "'' ReferringPhysicianID," + //ID # of referring physician "'V722' DiagnosisCode1," + //Diagnosis Code 1. Always set to V72.2 for simplicity and workability "'' DiagnosisCode2," + //Diagnosis code 2 "'' DiagnosisCode3," + //Diagnosis code 3 "'' DiagnosisCode4," + //Diagnosis code 4 "(SELECT a.AptDateTime FROM appointment a WHERE a.AptNum=" + aptNum + " " + DbHelper.LimitAnd(1) + ") DateOfEncounter," + //Date of encounter "(" + DbHelper.LimitOrderBy("SELECT pc.ProcCode FROM procedurecode pc,procedurelog pl " + "WHERE pl.AptNum=" + aptNum + " AND pl.CodeNum=pc.CodeNum AND pc.ProcCode IN (" + billableProcedures + ") ORDER BY pl.ProcNum", 1) + ") Procedure1," + "'' Procedure1Modifier1," + //Procedure modifier 1 "'' Procedure1Modifier2," + //Procedure modifier 2 "'' Procedure1DiagnosisCode," + //Diagnosis code "(" + DbHelper.LimitOrderBy("SELECT pl.ProcFee FROM procedurecode pc,procedurelog pl " + "WHERE pl.AptNum=" + aptNum + " AND pl.CodeNum=pc.CodeNum AND pc.ProcCode IN (" + billableProcedures + ") ORDER BY pl.ProcNum", 1) + ") Procedure1Charges," + "'' Procedure2," + //2nd procedure cpt/hcpcs "'' Procedure2Modifier1," + //2nd procedure modifier 1 "'' Procedure2Modifier2," + //2nd procedure modifier 2 "'' Procedure2DiagnosisCode," + //Diagnosis code "0 Procedure2Charges," + //charges "'' Procedure3," + //3rd procedure cpt/hcpcs "'' Procedure3Modifier1," + //3rd procedure modifier 1 "'' Procedure3Modifier2," + //3rd procedure modifier 2 "'' Procedure3DiagnosisCode," + //Diagnosis code "0 Procedure3Charges," + //Charges "'' Procedure4," + //4th procedure cpt/hcpcs "'' Procedure4Modifier1," + //4th procedure modifier 1 "'' Procedure4Modifier2," + //4th procedure modifier 2 "'' Procedure4DiagnosisCode," + //Diagnosis code "0 Procedure4Charges," + //Charges "'' Procedure5," + //5th procedure cpt/hcpcs "'' Procedure5Modifier1," + //5th procedure modifier 1 "'' Procedure5Modifier2," + //5th procedure modifier 2 "'' Procedure5DiagnosisCode," + //diagnosis code "0 Procedure5Charges," + //Charges "'' Procedure6," + //6th procedure cpt/hcpcs "'' Procedure6Modifier1," + //6th procedure modifier 1 "'' Procedure6Modifier2," + //6th procedure modifier 2 "'' Procedure6DiagnosisCode," + //Diagnosis code "0 Procedure6Charges," + //Charges "(SELECT SUM(pl.ProcFee) FROM procedurelog pl WHERE pl.AptNum=" + aptNum + ") TotalCharges," + //Total charges "(SELECT SUM(a.AdjAmt) FROM adjustment a WHERE a.PatNum=" + patNum + " AND a.AdjType=" + payDefNum + ") AmountPaid," + //Amount paid "0 BalanceDue," + //Balance due "TRIM((SELECT cl.Description FROM appointment ap,clinic cl WHERE ap.AptNum=" + aptNum + " AND " + "ap.ClinicNum=cl.ClinicNum " + DbHelper.LimitAnd(1) + ")) ClinicDescription," + "(SELECT pr.StateLicense FROM provider pr,appointment ap WHERE ap.AptNum=" + aptNum + " AND pr.ProvNum=ap.ProvNum " + DbHelper.LimitAnd(1) + ") PhysicianID," + "(SELECT CONCAT(CONCAT(pr.FName,' '),pr.MI) FROM provider pr,appointment ap " + "WHERE ap.AptNum=" + aptNum + " AND pr.ProvNum=ap.ProvNum " + DbHelper.LimitAnd(1) + ") PhysicianFAndMNames," + //Physician's first name and middle initial "(SELECT pr.LName FROM provider pr,appointment ap " + "WHERE ap.AptNum=" + aptNum + " AND pr.ProvNum=ap.ProvNum " + DbHelper.LimitAnd(1) + ") PhysicianLName " + //Physician's last name "FROM patient p WHERE " + "p.PatNum=" + patNum; DataTable primaryCareReportRow = Reports.GetTable(command); string outputRow = ""; string rowErrors = ""; string rowWarnings = ""; //Patient's ID Number string pcin = primaryCareReportRow.Rows[0]["PCIN"].ToString(); if (pcin.Length < 9) { rowErrors += "ERROR: Incorrectly formatted patient data for patient with patnum " + patNum + ". Patient ID Number '" + pcin + "' is not at least 9 characters long." + Environment.NewLine; } outputRow += pcin.PadLeft(15, '0'); //Patient's date of birth outputRow += PIn.Date(primaryCareReportRow.Rows[0]["Birthdate"].ToString()).ToString("MMddyyyy"); //Patient's gender outputRow += PIn.String(primaryCareReportRow.Rows[0]["Gender"].ToString()); //Patient's address string householdAddress = POut.String(PIn.String(primaryCareReportRow.Rows[0]["Address"].ToString())); if (householdAddress.Length > 29) { string newHouseholdAddress = householdAddress.Substring(0, 29); rowWarnings += "WARNING: Address for patient with patnum of " + patNum + " was longer than 29 characters and " + "was truncated in the report ouput. Address was changed from '" + householdAddress + "' to '" + newHouseholdAddress + "'" + Environment.NewLine; householdAddress = newHouseholdAddress; } outputRow += householdAddress.PadRight(29, ' '); //Patient's city string householdCity = POut.String(PIn.String(primaryCareReportRow.Rows[0]["City"].ToString())); if (householdCity.Length > 15) { string newHouseholdCity = householdCity.Substring(0, 15); rowWarnings += "WARNING: City name for patient with patnum of " + patNum + " was longer than 15 characters and " + "was truncated in the report ouput. City name was changed from '" + householdCity + "' to '" + newHouseholdCity + "'" + Environment.NewLine; householdCity = newHouseholdCity; } outputRow += householdCity.PadRight(15, ' '); //Patient's State string householdState = POut.String(PIn.String(primaryCareReportRow.Rows[0]["State"].ToString())); if (householdState.ToUpper() != "AZ") { rowErrors += "ERROR: State abbreviation for patient with patnum of " + patNum + " must be set to AZ." + Environment.NewLine; householdState = "AZ"; } outputRow += householdState; //Patient's zip code string householdZip = POut.String(PIn.String(primaryCareReportRow.Rows[0]["Zip"].ToString())); if (householdZip.Length > 5) { string newHouseholdZip = householdZip.Substring(0, 5); rowWarnings += "WARNING: The zipcode for patient with patnum of " + patNum + " was longer than 5 characters in length and " + "was truncated in the report ouput. The zipcode was changed from '" + householdZip + "' to '" + newHouseholdZip + "'" + Environment.NewLine; householdZip = newHouseholdZip; } if (householdZip.Length < 5) { rowWarnings += "WARNING: The zipcode for patient with patnum of " + patNum + " was shorter than 5 characters in length " + "(current zipcode is '" + householdZip + "')" + Environment.NewLine; householdZip = householdZip.PadLeft(5, '0'); } outputRow += householdZip.PadRight(5, ' '); //Patient's relationship to insured. string insuranceRelationship = POut.String(PIn.String(primaryCareReportRow.Rows[0]["InsRelat"].ToString())); if (insuranceRelationship != "1") //Not self? { rowWarnings += "WARNING: The patient insurance relationship is not 'self' for the patient with a patnum of " + patNum + Environment.NewLine; } outputRow += insuranceRelationship; //Patient's marital status outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["MaritalStatus"].ToString())); //Patient's employment status outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["EmploymentStatus"].ToString())); //Patient's student status outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["StudentStatus"].ToString())); //Insurance plan name outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["InsurancePlanName"].ToString())).PadRight(25, ' '); //Name of referring physician. outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["ReferringPhysicianName"].ToString())).PadRight(26, ' '); //ID# of referring physician outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["ReferringPhysicianID"].ToString())).PadLeft(6, ' '); //Diagnosis code 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["DiagnosisCode1"].ToString())).PadRight(6, '0'); //Diagnosis code 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["DiagnosisCode2"].ToString())).PadRight(6, '0'); //Diagnosis code 3 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["DiagnosisCode3"].ToString())).PadRight(6, '0'); //Diagnosis code 4 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["DiagnosisCode4"].ToString())).PadRight(6, '0'); //Date of encounter outputRow += PIn.Date(primaryCareReportRow.Rows[0]["DateOfEncounter"].ToString()).ToString("MMddyyyy"); //Procedure 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure1"].ToString())).PadRight(5, '0'); //Procedure 1 modifier 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure1Modifier1"].ToString())).PadRight(2, '0'); //Procedure 1 modifier 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure1Modifier2"].ToString())).PadRight(2, '0'); //Procedure 1 diagnosis code outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure1DiagnosisCode"].ToString())).PadRight(4, '0'); //Procedure 1 charges outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["Procedure1Charges"].ToString())).ToString().PadLeft(6, '0'); //Procedure 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure2"].ToString())).PadRight(5, '0'); //Procedure 2 modifier 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure2Modifier1"].ToString())).PadRight(2, '0'); //Procedure 2 modifier 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure2Modifier2"].ToString())).PadRight(2, '0'); //Procedure 2 diagnosis code outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure2DiagnosisCode"].ToString())).PadRight(4, '0'); //Procedure 2 charges outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["Procedure2Charges"].ToString())).ToString().PadLeft(6, '0'); //Procedure 3 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure3"].ToString())).PadRight(5, '0'); //Procedure 3 modifier 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure3Modifier1"].ToString())).PadRight(2, '0'); //Procedure 3 modifier 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure3Modifier2"].ToString())).PadRight(2, '0'); //Procedure 3 diagnosis code outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure3DiagnosisCode"].ToString())).PadRight(4, '0'); //Procedure 3 charges outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["Procedure3Charges"].ToString())).ToString().PadLeft(6, '0'); //Procedure 4 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure4"].ToString())).PadRight(5, '0'); //Procedure 4 modifier 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure4Modifier1"].ToString())).PadRight(2, '0'); //Procedure 4 modifier 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure4Modifier2"].ToString())).PadRight(2, '0'); //Procedure 4 diagnosis code outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure4DiagnosisCode"].ToString())).PadRight(4, '0'); //Procedure 4 charges outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["Procedure4Charges"].ToString())).ToString().PadLeft(6, '0'); //Procedure 5 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure5"].ToString())).PadRight(5, '0'); //Procedure 5 modifier 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure5Modifier1"].ToString())).PadRight(2, '0'); //Procedure 5 modifier 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure5Modifier2"].ToString())).PadRight(2, '0'); //Procedure 5 diagnosis code outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure5DiagnosisCode"].ToString())).PadRight(4, '0'); //Procedure 5 charges outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["Procedure5Charges"].ToString())).ToString().PadLeft(6, '0'); //Procedure 6 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure6"].ToString())).PadRight(5, '0'); //Procedure 6 modifier 1 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure6Modifier1"].ToString())).PadRight(2, '0'); //Procedure 6 modifier 2 outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure6Modifier2"].ToString())).PadRight(2, '0'); //Procedure 6 diagnosis code outputRow += POut.String(PIn.String(primaryCareReportRow.Rows[0]["Procedure6DiagnosisCode"].ToString())).PadRight(4, '0'); //Procedure 6 charges outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["Procedure6Charges"].ToString())).ToString().PadLeft(6, '0'); //Total charges outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["TotalCharges"].ToString())).ToString().PadLeft(7, '0'); //Amount paid outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["AmountPaid"].ToString())).ToString().PadLeft(7, '0'); //Balance due outputRow += Math.Round(PIn.Double(primaryCareReportRow.Rows[0]["BalanceDue"].ToString())).ToString().PadLeft(7, '0'); //Facility site number string siteId = PIn.String(primaryCareReportRow.Rows[0]["ClinicDescription"].ToString()); if (siteId == "null") { siteId = ""; } if (!Regex.IsMatch(siteId, "^.*_[0-9]{5}$")) { rowErrors += "ERROR: The clinic description for the clinic associated with the last completed appointment " + "for the patient with a patnum of " + patNum + " must be the clinic name, follwed by a '_', followed by the 5-digit Site ID Number " + "for the clinic. i.e. ClinicName_12345. The current clinic description is '" + siteId + "'." + Environment.NewLine; } else { siteId = siteId.Substring(siteId.Length - 5); } outputRow += siteId; //Physician ID string physicianId = PIn.String(primaryCareReportRow.Rows[0]["PhysicianID"].ToString()); if (physicianId.Length > 12) { string newPhysicianId = physicianId.Substring(0, 12); rowWarnings += "WARNING: The physician ID '" + physicianId + "' of the provider associated to the patient with a patnum of '" + patNum + "' is longer than 12 digits. The physician id has been truncated from '" + physicianId + "' to '" + newPhysicianId + "'." + Environment.NewLine; physicianId = newPhysicianId; } outputRow += physicianId.PadLeft(12, '0'); //Pysician's First Name and Middle Initial string physicianFirstAndMiddle = PIn.String(primaryCareReportRow.Rows[0]["PhysicianFAndMNames"].ToString()); if (physicianFirstAndMiddle.Length > 12) { string newPhysicianFirstAndMiddle = physicianFirstAndMiddle.Substring(0, 12); rowWarnings += "WARNING: The physician first name and middle initial of the provider associated to the patient with " + "a patnum of '" + patNum + "' was truncated from '" + physicianFirstAndMiddle + "' to '" + newPhysicianFirstAndMiddle + "'." + Environment.NewLine; physicianFirstAndMiddle = newPhysicianFirstAndMiddle; } outputRow += physicianFirstAndMiddle.PadRight(12, ' '); //Physician's last name. string physicianLastName = PIn.String(primaryCareReportRow.Rows[0]["PhysicianLName"].ToString()); if (physicianLastName.Length > 20) { string newPhysicianLastName = physicianLastName.Substring(0, 20); rowWarnings += "WARNING: The physician last name of the provider associated to the patient with a patnum of '" + patNum + "' " + "was truncated from '" + physicianLastName + "' to '" + newPhysicianLastName + "'." + Environment.NewLine; physicianLastName = newPhysicianLastName; } outputRow += physicianLastName.PadRight(20, ' '); //Finish adding the row to the output file and log warnings and errors. textLog.Text += rowErrors + rowWarnings; if (rowErrors.Length > 0) { continue; } outputText += outputRow + Environment.NewLine; //Only add the row to the output file if it is properly formatted. } } File.WriteAllText(outFile, outputText); MessageBox.Show("Done."); }
private void butRun_Click(object sender, EventArgs e) { this.textLog.Text = ""; string outFile = ODFileUtils.CombinePaths(textEligibilityFolder.Text, textEligibilityFile.Text); if (File.Exists(outFile)) { if (MessageBox.Show("The file at " + outFile + " already exists. Overwrite?", "Overwrite File?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } string outputText = ""; string patientsIdNumberStr = "SPID#"; string householdGrossIncomeStr = "Household Gross Income"; string householdPercentOfPovertyStr = "Household % of Poverty"; string statusStr = "Eligibility Status"; string command = ""; //Locate the payment definition number for copayments of patients using the Arizona Primary Care program. command = "SELECT DefNum FROM definition WHERE Category=" + POut.Long((int)DefCat.PaymentTypes) + " AND IsHidden=0 AND LOWER(TRIM(ItemName))='noah'"; DataTable copayDefNumTab = Reports.GetTable(command); if (copayDefNumTab.Rows.Count != 1) { MessageBox.Show("You must define exactly one payment type with the name 'NOAH' before running this report. " + "This payment type must be used on payments made by Arizona Primary Care patients."); return; } long copayDefNum = PIn.Long(copayDefNumTab.Rows[0][0].ToString()); //Get the list of all Arizona Primary Care patients, based on the patients which have an insurance carrier named 'noah' command = "SELECT DISTINCT p.PatNum FROM patplan pp,inssub,insplan i,patient p,carrier c " + "WHERE p.PatNum=pp.PatNum AND inssub.InsSubNum=pp.InsSubNum AND inssub.PlanNum=i.PlanNum AND i.CarrierNum=c.CarrierNum " + "AND LOWER(TRIM(c.CarrierName))='noah' AND " + "(SELECT MAX(a.AptDateTime) FROM appointment a WHERE a.PatNum=p.PatNum AND a.AptStatus=" + ((int)ApptStatus.Complete) + ") BETWEEN " + POut.Date(dateTimeFrom.Value) + " AND " + POut.Date(dateTimeTo.Value); DataTable primaryCarePatients = Reports.GetTable(command); for (int i = 0; i < primaryCarePatients.Rows.Count; i++) { string patNum = POut.Long(PIn.Long(primaryCarePatients.Rows[i][0].ToString())); command = "SELECT " + "TRIM((SELECT f.FieldValue FROM patfield f WHERE f.PatNum=p.PatNum AND " + "LOWER(f.FieldName)=LOWER('" + patientsIdNumberStr + "') " + DbHelper.LimitAnd(1) + ")) PCIN, " + //Patient's Care ID Number "TRIM((" + DbHelper.LimitOrderBy("SELECT cl.Description FROM appointment ap,clinic cl WHERE ap.PatNum=" + patNum + " AND " + "ap.AptStatus=" + ((int)ApptStatus.Complete) + " AND ap.ClinicNum=cl.ClinicNum ORDER BY ap.AptDateTime DESC", 1) + ")) SiteIDNumber," + "p.BirthDate," + "CASE p.Position WHEN " + ((int)PatientPosition.Single) + " THEN 1 " + "WHEN " + ((int)PatientPosition.Married) + " THEN 2 ELSE 3 END MaritalStatus," + //Marital status //"CASE p.Race WHEN "+((int)PatientRaceOld.Asian)+" THEN 'A' WHEN "+((int)PatientRaceOld.HispanicLatino)+" THEN 'H' "+ // "WHEN "+((int)PatientRaceOld.HawaiiOrPacIsland)+" THEN 'P' WHEN "+((int)PatientRaceOld.AfricanAmerican)+" THEN 'B' "+ // "WHEN "+((int)PatientRaceOld.AmericanIndian)+" THEN 'I' WHEN "+((int)PatientRaceOld.White)+" THEN 'W' ELSE 'O' END PatRace,"+ "CONCAT(CONCAT(TRIM(p.Address),' '),TRIM(p.Address2)) HouseholdAddress," + //Patient address "p.City HouseholdCity," + //Household residence city "p.State HouseholdState," + //Household residence state "p.Zip HouseholdZip," + //Household residence zip code "TRIM((SELECT f.FieldValue FROM patfield f WHERE f.PatNum=p.PatNum AND " + "LOWER(f.FieldName)=LOWER('" + householdGrossIncomeStr + "') " + DbHelper.LimitAnd(1) + ")) HGI, " + //Household gross income "TRIM((SELECT f.FieldValue FROM patfield f WHERE f.PatNum=p.PatNum AND " + "LOWER(f.FieldName)=LOWER('" + householdPercentOfPovertyStr + "') " + DbHelper.LimitAnd(1) + ")) HPP, " + //Household % of poverty "(" + DbHelper.LimitOrderBy("SELECT a.AdjAmt FROM adjustment a WHERE a.PatNum=" + patNum + " AND a.AdjType=" + copayDefNum + " ORDER BY AdjDate DESC", 1) + ") HSFS," + //Household sliding fee scale "(SELECT i.DateEffective FROM insplan i,inssub,patplan pp WHERE pp.PatNum=" + patNum + " AND inssub.InsSubNum=pp.InsSubNum AND inssub.PlanNum=i.PlanNum " + DbHelper.LimitAnd(1) + ") DES," + //Date of eligibility status "TRIM((SELECT f.FieldValue FROM patfield f WHERE f.PatNum=p.PatNum AND " + "LOWER(f.FieldName)=LOWER('" + statusStr + "') " + DbHelper.LimitAnd(1) + ")) CareStatus " + //Status "FROM patient p WHERE " + "p.PatNum=" + patNum; DataTable primaryCareReportRow = Reports.GetTable(command); if (primaryCareReportRow.Rows.Count != 1) { //Either the results are ambiguous or for some reason, the patient number listed in the patfield table //does not actually exist. In either of these cases, it makes the most sense to just skip this patient //and continue with the rest of the reporting. continue; } string outputRow = ""; string rowErrors = ""; string rowWarnings = ""; string pcin = PIn.String(primaryCareReportRow.Rows[0]["PCIN"].ToString()); if (pcin.Length < 9) { rowErrors += "ERROR: Incorrectly formatted patient data for patient with patnum " + patNum + ". Patient ID Number '" + pcin + "' is not at least 9 characters long." + Environment.NewLine; } outputRow += pcin.PadLeft(15, '0'); //Patient's ID Number string siteId = primaryCareReportRow.Rows[0]["SiteIDNumber"].ToString(); if (siteId == "null") { siteId = ""; } if (!Regex.IsMatch(siteId, "^.*_[0-9]{5}$")) { rowErrors += "ERROR: The clinic description for the clinic associated with the last completed appointment " + "for the patient with a patnum of " + patNum + " must be the clinic name, follwed by a '_', followed by the 5-digit Site ID Number " + "for the clinic. i.e. ClinicName_12345. The current clinic description is '" + siteId + "'." + Environment.NewLine; } else { siteId = siteId.Substring(siteId.Length - 5); } outputRow += siteId; outputRow += PIn.Date(primaryCareReportRow.Rows[0]["Birthdate"].ToString()).ToString("MMddyyyy"); //Patient's Date of Birth outputRow += POut.Long(PIn.Long(primaryCareReportRow.Rows[0]["MaritalStatus"].ToString())); //outputRow+=primaryCareReportRow.Rows[0]["PatRace"].ToString(); //Gets the old patient race enum based on the PatientRace entries in the db and displays the corresponding letters. switch (PatientRaces.GetPatientRaceOldFromPatientRaces(PIn.Long(patNum))) { case PatientRaceOld.Asian: outputRow += 'A'; break; case PatientRaceOld.HispanicLatino: outputRow += 'H'; break; case PatientRaceOld.HawaiiOrPacIsland: outputRow += 'P'; break; case PatientRaceOld.AfricanAmerican: outputRow += 'B'; break; case PatientRaceOld.AmericanIndian: outputRow += 'I'; break; case PatientRaceOld.White: outputRow += 'W'; break; default: outputRow += 'O'; break; } //Household residence address string householdAddress = POut.String(PIn.String(primaryCareReportRow.Rows[0]["HouseholdAddress"].ToString())); if (householdAddress.Length > 29) { string newHouseholdAddress = householdAddress.Substring(0, 29); rowWarnings += "WARNING: Address for patient with patnum of " + patNum + " was longer than 29 characters and " + "was truncated in the report ouput. Address was changed from '" + householdAddress + "' to '" + newHouseholdAddress + "'" + Environment.NewLine; householdAddress = newHouseholdAddress; } outputRow += householdAddress.PadRight(29, ' '); //Household residence city string householdCity = POut.String(PIn.String(primaryCareReportRow.Rows[0]["HouseholdCity"].ToString())); if (householdCity.Length > 15) { string newHouseholdCity = householdCity.Substring(0, 15); rowWarnings += "WARNING: City name for patient with patnum of " + patNum + " was longer than 15 characters and " + "was truncated in the report ouput. City name was changed from '" + householdCity + "' to '" + newHouseholdCity + "'" + Environment.NewLine; householdCity = newHouseholdCity; } outputRow += householdCity.PadRight(15, ' '); //Household residence state string householdState = POut.String(PIn.String(primaryCareReportRow.Rows[0]["HouseholdState"].ToString())); if (householdState.Length > 2) { string newHouseholdState = householdState.Substring(0, 2); rowWarnings += "WARNING: State abbreviation for patient with patnum of " + patNum + " was longer than 2 characters and " + "was truncated in the report ouput. State abbreviation was changed from '" + householdState + "' to '" + newHouseholdState + "'" + Environment.NewLine; householdState = newHouseholdState; } outputRow += householdState.PadRight(2, ' '); //Household residence zip code string householdZip = POut.String(PIn.String(primaryCareReportRow.Rows[0]["HouseholdZip"].ToString())); if (householdZip.Length > 5) { string newHouseholdZip = householdZip.Substring(0, 5); rowWarnings += "WARNING: The zipcode for patient with patnum of " + patNum + " was longer than 5 characters and " + "was truncated in the report ouput. The zipcode was changed from '" + householdZip + "' to '" + newHouseholdZip + "'" + Environment.NewLine; householdZip = newHouseholdZip; } outputRow += householdZip.PadRight(5, ' '); //Household gross income string householdGrossIncome = POut.String(PIn.String(primaryCareReportRow.Rows[0]["HGI"].ToString())); if (householdGrossIncome == "" || householdGrossIncome == "null") { householdGrossIncome = "0"; } //Remove any character that is not a digit or a decimal. string newHouseholdGrossIncome = Math.Round(Convert.ToDouble(Regex.Replace(householdGrossIncome, "[^0-9\\.]", "")), 0).ToString(); if (householdGrossIncome != newHouseholdGrossIncome) { rowWarnings += "WARNING: The household gross income for patient with patnum " + patNum + " contained invalid characters " + "and was changed in the output report from '" + householdGrossIncome + "' to '" + newHouseholdGrossIncome + "'." + Environment.NewLine; } householdGrossIncome = newHouseholdGrossIncome.PadLeft(7, '0'); if (householdGrossIncome.Length > 7) { rowErrors += "ERROR: Abnormally large household gross income of '" + householdGrossIncome + "' for patient with patnum of " + patNum + "." + Environment.NewLine; } outputRow += householdGrossIncome; //Household percent of poverty string householdPercentPoverty = POut.String(PIn.String(primaryCareReportRow.Rows[0]["HPP"].ToString())); if (householdPercentPoverty == "" || householdPercentPoverty == "null") { householdPercentPoverty = "0"; } string newHouseholdPercentPoverty = Regex.Replace(householdPercentPoverty, "[^0-9]", ""); //Remove anything that is not a digit. if (newHouseholdPercentPoverty != householdPercentPoverty) { rowWarnings += "WARNING: Household percent poverty for the patient with a patnum of " + patNum + " had to be modified in the output report from '" + householdPercentPoverty + "' to '" + newHouseholdPercentPoverty + "' based on output requirements." + Environment.NewLine; } householdPercentPoverty = newHouseholdPercentPoverty.PadLeft(3, '0'); if (householdPercentPoverty.Length > 3 || Convert.ToInt16(householdPercentPoverty) > 200) { rowErrors += "ERROR: Household percent poverty must be between 0 and 200 percent, but is set to '" + householdPercentPoverty + "' for the patient with the patnum of " + patNum + Environment.NewLine; } outputRow += householdPercentPoverty; string householdSlidingFeeScale = POut.String(PIn.String(primaryCareReportRow.Rows[0]["HSFS"].ToString())); if (householdSlidingFeeScale.Length == 0) { householdSlidingFeeScale = "0"; } string newHouseholdSlidingFeeScale = Regex.Replace(householdSlidingFeeScale, "[^0-9]", ""); if (newHouseholdSlidingFeeScale != householdSlidingFeeScale) { rowWarnings += "WARNING: The household sliding fee scale (latest NOAH copay amount) for the patient with a patnum of " + patNum + " contains invalid characters and was changed from '" + householdSlidingFeeScale + "' to '" + newHouseholdSlidingFeeScale + "'." + Environment.NewLine; householdSlidingFeeScale = newHouseholdSlidingFeeScale; } if (householdSlidingFeeScale.Length > 3 || Convert.ToInt16(householdSlidingFeeScale) > 100) { rowWarnings += "WARNING: The household sliding fee scale (latest NOAH copay amount) for the patient with a patnum of " + patNum + " is '" + householdSlidingFeeScale + "', but will be reported as 100." + Environment.NewLine; householdSlidingFeeScale = "100"; } outputRow += householdSlidingFeeScale.PadLeft(3, '0'); string dateOfEligibilityStatusStr = primaryCareReportRow.Rows[0]["DES"].ToString(); DateTime dateOfEligibilityStatus = DateTime.MinValue; if (dateOfEligibilityStatusStr != "" && dateOfEligibilityStatusStr != "null") { dateOfEligibilityStatus = PIn.Date(dateOfEligibilityStatusStr); } outputRow += dateOfEligibilityStatus.ToString("MMddyyyy"); //Primary care status string primaryCareStatus = POut.String(PIn.String(primaryCareReportRow.Rows[0]["CareStatus"].ToString())).ToUpper(); if (primaryCareStatus != "A" && primaryCareStatus != "B" && primaryCareStatus != "C" && primaryCareStatus != "D") { rowErrors += "ERROR: The primary care status of the patient with a patnum of " + patNum + " is set to '" + primaryCareStatus + "', but must be set to A, B, C or D. " + Environment.NewLine; } outputRow += primaryCareStatus; textLog.Text += rowErrors + rowWarnings; if (rowErrors.Length > 0) { continue; } outputText += outputRow + Environment.NewLine; //Only add the row to the output file if it is properly formatted. } File.WriteAllText(outFile, outputText); MessageBox.Show("Done."); }
private void butSend_Click(object sender, EventArgs e) { //Assuming the use of XCharge. If adding another vendor (PayConnect for example) //make sure to move XCharge validation in FillGrid() to here. if (prog == null) //Gets filled in FillGrid() { return; } if (gridMain.SelectedIndices.Length < 1) { MsgBox.Show(this, "Must select at least one recurring charge."); return; } if (!PaymentsWithinLockDate()) { return; } string recurringResultFile = "Recurring charge results for " + DateTime.Now.ToShortDateString() + " ran at " + DateTime.Now.ToShortTimeString() + "\r\n\r\n"; int failed = 0; int success = 0; string user = ProgramProperties.GetPropVal(prog.ProgramNum, "Username"); string password = ProgramProperties.GetPropVal(prog.ProgramNum, "Password"); #region Card Charge Loop for (int i = 0; i < gridMain.SelectedIndices.Length; i++) { #region X-Charge if (table.Rows[gridMain.SelectedIndices[i]]["XChargeToken"].ToString() != "" && CreditCards.IsDuplicateXChargeToken(table.Rows[gridMain.SelectedIndices[i]]["XChargeToken"].ToString())) { MessageBox.Show(Lan.g(this, "A duplicate token was found, the card cannot be charged for customer: ") + table.Rows[i]["PatName"].ToString()); continue; } insertPayment = false; ProcessStartInfo info = new ProcessStartInfo(xPath); long patNum = PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PatNum"].ToString()); string resultfile = Path.Combine(Path.GetDirectoryName(xPath), "XResult.txt"); File.Delete(resultfile); //delete the old result file. info.Arguments = ""; double amt = PIn.Double(table.Rows[gridMain.SelectedIndices[i]]["ChargeAmt"].ToString()); DateTime exp = PIn.Date(table.Rows[gridMain.SelectedIndices[i]]["CCExpiration"].ToString()); string address = PIn.String(table.Rows[gridMain.SelectedIndices[i]]["Address"].ToString()); string addressPat = PIn.String(table.Rows[gridMain.SelectedIndices[i]]["AddressPat"].ToString()); string zip = PIn.String(table.Rows[gridMain.SelectedIndices[i]]["Zip"].ToString()); string zipPat = PIn.String(table.Rows[gridMain.SelectedIndices[i]]["ZipPat"].ToString()); info.Arguments += "/AMOUNT:" + amt.ToString("F2") + " /LOCKAMOUNT "; info.Arguments += "/TRANSACTIONTYPE:PURCHASE /LOCKTRANTYPE "; if (table.Rows[gridMain.SelectedIndices[i]]["XChargeToken"].ToString() != "") { info.Arguments += "/XCACCOUNTID:" + table.Rows[gridMain.SelectedIndices[i]]["XChargeToken"].ToString() + " "; info.Arguments += "/RECURRING "; } else { info.Arguments += "/ACCOUNT:" + table.Rows[gridMain.SelectedIndices[i]]["CCNumberMasked"].ToString() + " "; } if (exp.Year > 1880) { info.Arguments += "/EXP:" + exp.ToString("MMyy") + " "; } if (address != "") { info.Arguments += "\"/ADDRESS:" + address + "\" "; } else if (addressPat != "") { info.Arguments += "\"/ADDRESS:" + addressPat + "\" "; } if (zip != "") { info.Arguments += "\"/ZIP:" + zip + "\" "; } else if (zipPat != "") { info.Arguments += "\"/ZIP:" + zipPat + "\" "; } info.Arguments += "/RECEIPT:Pat" + patNum + " "; //aka invoice# info.Arguments += "\"/CLERK:" + Security.CurUser.UserName + " R\" /LOCKCLERK "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + user + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/HIDEMAINWINDOW "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/SMALLWINDOW "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/NORESULTDIALOG "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string line = ""; string resultText = ""; recurringResultFile += "PatNum: " + patNum + " Name: " + table.Rows[i]["PatName"].ToString() + "\r\n"; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resultText != "") { resultText += "\r\n"; } resultText += line; if (line.StartsWith("RESULT=")) { if (line == "RESULT=SUCCESS") { success++; labelCharged.Text = Lan.g(this, "Charged=") + success; insertPayment = true; } else { failed++; labelFailed.Text = Lan.g(this, "Failed=") + failed; } } line = reader.ReadLine(); } recurringResultFile += resultText + "\r\n\r\n"; } #endregion if (insertPayment) { Patient patCur = Patients.GetPat(patNum); Payment paymentCur = new Payment(); paymentCur.DateEntry = nowDateTime.Date; paymentCur.PayDate = GetPayDate(PIn.Date(table.Rows[gridMain.SelectedIndices[i]]["LatestPayment"].ToString()), PIn.Date(table.Rows[gridMain.SelectedIndices[i]]["DateStart"].ToString())); paymentCur.PatNum = patCur.PatNum; paymentCur.ClinicNum = PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["ClinicNum"].ToString()); paymentCur.PayType = PIn.Int(ProgramProperties.GetPropVal(prog.ProgramNum, "PaymentType")); paymentCur.PayAmt = amt; paymentCur.PayNote = resultText; paymentCur.IsRecurringCC = true; Payments.Insert(paymentCur); long provNum = PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["ProvNum"].ToString()); //for payment plans only if (provNum == 0) //Regular payments need to apply to the provider that the family owes the most money to. { DataTable dt = Patients.GetPaymentStartingBalances(patCur.Guarantor, paymentCur.PayNum); double highestAmt = 0; for (int j = 0; j < dt.Rows.Count; j++) { double afterIns = PIn.Double(dt.Rows[j]["AfterIns"].ToString()); if (highestAmt >= afterIns) { continue; } highestAmt = afterIns; provNum = PIn.Long(dt.Rows[j]["ProvNum"].ToString()); } } PaySplit split = new PaySplit(); split.PatNum = paymentCur.PatNum; split.ClinicNum = paymentCur.ClinicNum; split.PayNum = paymentCur.PayNum; split.ProcDate = paymentCur.PayDate; split.DatePay = paymentCur.PayDate; split.ProvNum = provNum; split.SplitAmt = paymentCur.PayAmt; split.PayPlanNum = PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PayPlanNum"].ToString()); PaySplits.Insert(split); if (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily)) { Ledgers.ComputeAging(patCur.Guarantor, PrefC.GetDate(PrefName.DateLastAging), false); } else { Ledgers.ComputeAging(patCur.Guarantor, DateTimeOD.Today, false); if (PrefC.GetDate(PrefName.DateLastAging) != DateTime.Today) { Prefs.UpdateString(PrefName.DateLastAging, POut.Date(DateTime.Today, false)); //Since this is always called from UI, the above line works fine to keep the prefs cache current. } } } } #endregion try { File.WriteAllText(Path.Combine(Path.GetDirectoryName(xPath), "RecurringChargeResult.txt"), recurringResultFile); } catch { } //Do nothing cause this is just for internal use. FillGrid(); labelCharged.Text = Lan.g(this, "Charged=") + success; labelFailed.Text = Lan.g(this, "Failed=") + failed; MsgBox.Show(this, "Done charging cards.\r\nIf there are any patients remaining in list, print the list and handle each one manually."); }
private void FillGrid() { table = _tableRequests; table.Rows.Sort(FeatureRequestSort); //Sort user submited/voted features to the top. //FillGrid used to start here------------------------------------------------ long selectedRequestId = 0; int selectedIndex = gridMain.GetSelectedIndex(); if (selectedIndex != -1) { if (table.Rows.Count > selectedIndex) { selectedRequestId = PIn.Long(table.Rows[gridMain.GetSelectedIndex()]["RequestId"]); } } gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col = new GridColumn(Lan.g("TableRequest", "Req#"), 40, GridSortingStrategy.AmountParse); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Mine"), 40, GridSortingStrategy.StringCompare); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "My Votes"), 60, GridSortingStrategy.StringCompare); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Total Votes"), 70, GridSortingStrategy.StringCompare); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Comments"), 70, GridSortingStrategy.AmountParse); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Version\r\nCompleted"), 75, GridSortingStrategy.VersionNumber); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Diff"), 40, GridSortingStrategy.AmountParse); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Weight"), 45, HorizontalAlignment.Right, GridSortingStrategy.AmountParse); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Approval"), 90, GridSortingStrategy.StringCompare); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableRequest", "Description"), 500, GridSortingStrategy.StringCompare); gridMain.ListGridColumns.Add(col); gridMain.ListGridRows.Clear(); GridRow row; for (int i = 0; i < table.Rows.Count; i++) { if ((checkMine.Checked && PIn.String(table.Rows[i]["isMine"]) != "X") || (checkMyVotes.Checked && PIn.String(table.Rows[i]["myVotes"]) == "")) { continue; } row = new GridRow(); row.Cells.Add(table.Rows[i]["RequestId"]); row.Cells.Add(table.Rows[i]["isMine"]); row.Cells.Add(table.Rows[i]["myVotes"]); row.Cells.Add(table.Rows[i]["totalVotes"]); row.Cells.Add(table.Rows[i]["TotalComments"]); row.Cells.Add(table.Rows[i]["versionCompleted"]); row.Cells.Add(table.Rows[i]["Difficulty"]); row.Cells.Add(PIn.Double(table.Rows[i]["Weight"]).ToString("F")); row.Cells.Add(table.Rows[i]["approval"]); row.Cells.Add(table.Rows[i]["Description"]); //If they voted or pledged on this feature, mark it so they can see. Can be re-added when/if they need to be more visible. if (table.Rows[i]["isMine"].ToString() != "" && table.Rows[i]["personalVotes"].ToString() == "0" && table.Rows[i]["personalCrit"].ToString() == "0" && table.Rows[i]["personalPledged"].ToString() == "0" && table.Rows[i]["approval"].ToString() != "Complete") { row.ColorBackG = Color.FromArgb(255, 255, 230); //light yellow. } gridMain.ListGridRows.Add(row); row.Tag = table.Rows[i]; } gridMain.EndUpdate(); for (int i = 0; i < table.Rows.Count; i++) { if (selectedRequestId.ToString() == table.Rows[i]["RequestId"]) { gridMain.SetSelected(i, true); } } }
private void butAddOrUpdate_Click(object sender, EventArgs e) { List <PayPlanEntry> listSelectedEntries = new List <PayPlanEntry>(); for (int i = 0; i < gridMain.SelectedIndices.Count(); i++) //add all of the currently selected entries to this list. { listSelectedEntries.Add((PayPlanEntry)(gridMain.Rows[gridMain.SelectedIndices[i]].Tag)); } if (listSelectedEntries.Count <= 1) //validation (doesn't matter if multiple are selected) { if (String.IsNullOrEmpty(textAmt.Text) || textAmt.errorProvider1.GetError(textAmt) != "" || PIn.Double(textAmt.Text) == 0) { MsgBox.Show(this, "Please enter a valid amount."); return; } if (textDate.Text != "" && textDate.errorProvider1.GetError(textDate) != "") { MsgBox.Show(this, "Please enter a valid date."); return; } } if (textDate.Text == "") { textDate.Text = DateTime.Today.ToShortDateString(); } if (Security.IsGlobalDateLock(Permissions.PayPlanEdit, PIn.Date(textDate.Text))) { return; } if (listSelectedEntries.Count == 0) //if they have none selected //add an unattached charge. { PayPlanCharge addCharge = new PayPlanCharge() { ChargeDate = PIn.Date(textDate.Text), ChargeType = PayPlanChargeType.Credit, Guarantor = _patCur.PatNum, //credits should always appear on the patient of the payment plan. Note = PIn.String(textNote.Text), PatNum = _patCur.PatNum, PayPlanNum = _payPlanCur.PayPlanNum, Principal = PIn.Double(textAmt.Text), ProcNum = 0, //provider/clinic will be set when the amortization schedule is saved. FormPayPlan.SaveData() //ClinicNum=0, //ProvNum=0, }; ListPayPlanCreditsCur.Add(addCharge); } else if (listSelectedEntries.Count == 1) //if they have one selected { PayPlanEntry selectedEntry = listSelectedEntries[0]; if (selectedEntry.IsChargeOrd) //if it's a charge //update the charge selected. get info from text boxes. //DO NOT use PayPlanChargeNum. They are not pre-inserted so they will all be 0 if new. { PayPlanCharge selectedCharge = ((PayPlanEntry)(gridMain.Rows[gridMain.SelectedIndices[0]].Tag)).Charge; selectedCharge.Principal = PIn.Double(textAmt.Text); selectedCharge.Note = PIn.String(textNote.Text); if (selectedEntry.ProcStatOrd == ProcStat.TP && selectedEntry.ProcNumOrd != 0) //if it's treatment planned, save the date as maxvalue so it will not show up in the ledger. //if it doesn't have a procnum, then we are editing an unattached row. { selectedCharge.ChargeDate = DateTime.MaxValue; } else { selectedCharge.ChargeDate = PIn.Date(textDate.Text); } } else //if it's a procedure //add a charge for the selected procedure. get info from text boxes. { PayPlanCharge addCharge = new PayPlanCharge(); if (selectedEntry.ProcStatOrd == ProcStat.TP && selectedEntry.ProcNumOrd != 0) //If tp, maxvalue. //if procnum == 0, it's unattached. { addCharge.ChargeDate = DateTime.MaxValue; } else { addCharge.ChargeDate = PIn.Date(textDate.Text); } addCharge.ChargeType = PayPlanChargeType.Credit; addCharge.Guarantor = _patCur.PatNum; //credits should always appear on the patient of the payment plan. addCharge.Note = PIn.String(textNote.Text); addCharge.PatNum = _patCur.PatNum; addCharge.PayPlanNum = _payPlanCur.PayPlanNum; addCharge.Principal = PIn.Double(textAmt.Text); addCharge.ProcNum = selectedEntry.ProcNumOrd; //provider/clinic will be set when the amortization schedule is saved. FormPayPlan.SaveData() //ClinicNum=0, //ProvNum=0, ListPayPlanCreditsCur.Add(addCharge); } } else if (listSelectedEntries.Count > 1) //if they have more than one entry selected //remove everythig that doesn't have a procnum from the list { List <PayPlanEntry> listSelectedProcs = listSelectedEntries.Where(x => !x.IsChargeOrd).Where(x => x.Proc != null).ToList(); if (listSelectedEntries.Count == 0) //if the list is then empty, there's nothing to do. { MsgBox.Show(this, "You must have at least one procedure selected."); return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Add a payment plan credit for each of the selected procedure's remaining amount? Selected credits will be ignored.")) { return; } //add a charge for every selected procedure for the amount remaining. //don't allow adding $0.00 credits. foreach (PayPlanEntry entryProcCur in listSelectedProcs) { List <PayPlanEntry> listEntriesForProc = _listPayPlanEntries .Where(x => x.ProcNumOrd == entryProcCur.ProcNumOrd) .Where(x => x.IsChargeOrd == true).ToList(); PayPlanCharge addCharge = new PayPlanCharge(); if (entryProcCur.ProcStatOrd == ProcStat.TP) //If tp, maxvalue. { addCharge.ChargeDate = DateTime.MaxValue; } else { addCharge.ChargeDate = DateTimeOD.Today; } addCharge.ChargeType = PayPlanChargeType.Credit; addCharge.Guarantor = _patCur.PatNum; //credits should always appear on the patient of the payment plan. addCharge.Note = ProcedureCodes.GetStringProcCode(entryProcCur.Proc.CodeNum) + ": " + Procedures.GetDescription(entryProcCur.Proc); addCharge.PatNum = _patCur.PatNum; addCharge.PayPlanNum = _payPlanCur.PayPlanNum; addCharge.Principal = PIn.Double(entryProcCur.RemBefStr); if (listEntriesForProc.Count != 0) { addCharge.Principal = listEntriesForProc.Min(x => PIn.Double(x.RemAftStr)); } addCharge.ProcNum = entryProcCur.ProcNumOrd; //provider/clinic will be set when the amortization schedule is saved. FormPayPlan.SaveData() //ClinicNum=0, //ProvNum=0, if (addCharge.Principal > 0) { ListPayPlanCreditsCur.Add(addCharge); } } } textAmt.Text = ""; textDate.Text = ""; textNote.Text = ""; FillGrid(); SetTextBoxes(); }
private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e) { SelectedDomainName = PIn.String(gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag.ToString()); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (_gridCurCell.Y > 0 && _gridCurCell.Y < _listTableHeaders.Count) //no pick list option for the PK col { _listTableHeaders[_gridCurCell.Y].PickList = string.Join("\r\n", _listStringPick); } #region Validation List <string> listColNames = new List <string>(); for (int i = 1; i < gridMain.ListGridRows.Count; i++) //start with index 1, first col is PK { string colName = gridMain.ListGridRows[i].Cells[0].Text; string colWidth = gridMain.ListGridRows[i].Cells[1].Text; #region Validate Column Widths if (Regex.IsMatch(colWidth, @"\D")) // "\D" matches any non-decimal character { MsgBox.Show(this, "Column widths must only contain positive integers."); return; } //inlcude the comma for international support. For instance Pi = 3.1415 or 3,1415 depending on your region if (new[] { '-', '.', ',' }.Any(x => colWidth.Contains(x))) { MsgBox.Show(this, "Column widths must only contain positive integers."); return; } #endregion Validate Column Widths #region Validate Column Names if (listColNames.Contains(colName)) { MessageBox.Show(Lan.g(this, $"Duplicate column name detected") + ": " + colName); return; } listColNames.Add(colName); if (i == 0) //don't check PK column name, since it can't be changed { continue; } if (Regex.IsMatch(colName, @"^\d")) { MsgBox.Show(this, "Column cannot start with numbers."); return; } if (Regex.IsMatch(colName, @"\s")) { MsgBox.Show(this, "Column names cannot contain spaces."); return; } if (Regex.IsMatch(colName, @"\W")) //W=non-word chars { MsgBox.Show(this, "Column names cannot contain special characters."); return; } //Check for reserved words-------------------------------------------------------------------------------- if (DbHelper.isMySQLReservedWord(colName)) { MessageBox.Show(Lan.g(this, "Column name is a reserved word in MySQL") + ": " + colName); return; } #endregion Validate Column Names } #endregion Validation #region Update _listTableHeaders for (int i = 0; i < _listTableHeaders.Count; i++) { if (i > 0) //don't allow renaming the first column, it's the PK { _listTableHeaders[i].ColName = PIn.String(gridMain.ListGridRows[i].Cells[0].Text); } _listTableHeaders[i].ColWidth = PIn.Int(gridMain.ListGridRows[i].Cells[1].Text); } #endregion Update _listTableHeaders #region Try Update DB try { WikiListHeaderWidths.UpdateNamesAndWidths(_wikiListCurName, _listTableHeaders); } catch (Exception ex) { MessageBox.Show(ex.Message); //will throw exception if table schema has changed since the window was opened. DialogResult = DialogResult.Cancel; } #endregion Try Update DB DataValid.SetInvalid(InvalidType.Wiki); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { ReportSimpleGrid report = new ReportSimpleGrid(); report.Query = "SELECT claim.dateservice,claim.claimnum,claim.claimtype,claim.claimstatus," + "CONCAT(CONCAT(CONCAT(CONCAT(patient.LName,', '),patient.FName),' '),patient.MiddleI),carrier.CarrierName,claim.claimfee " + "FROM patient,claim,insplan,carrier " + "WHERE patient.patnum=claim.patnum AND insplan.plannum=claim.plannum " + "AND insplan.CarrierNum=carrier.CarrierNum " + "AND (claim.claimstatus = 'U' OR claim.claimstatus = 'H' OR claim.claimstatus = 'W')"; if (radioRange.Checked == true) { report.Query += " AND claim.dateservice >= '" + date1.SelectionStart.ToString("yyyy-MM-dd") + "' " + "AND claim.dateservice <= '" + date2.SelectionStart.ToString("yyyy-MM-dd") + "'"; } else { report.Query += " AND claim.dateservice = '" + date1.SelectionStart.ToString("yyyy-MM-dd") + "'"; } FormQuery2 = new FormQuery(report); FormQuery2.IsReport = true; DataTable tempT = report.GetTempTable(); report.TableQ = new DataTable(null); //new table no name for (int i = 0; i < 6; i++) //add columns { report.TableQ.Columns.Add(new System.Data.DataColumn()); //blank columns } report.InitializeColumns(); for (int i = 0; i < tempT.Rows.Count; i++) //loop through data rows { DataRow row = report.TableQ.NewRow(); //create new row called 'row' based on structure of TableQ row[0] = (PIn.Date(tempT.Rows[i][0].ToString())).ToShortDateString(); //claim dateservice if (PIn.String(tempT.Rows[i][2].ToString()) == "P") { row[1] = "Primary"; } if (PIn.String(tempT.Rows[i][2].ToString()) == "S") { row[1] = "Secondary"; } if (PIn.String(tempT.Rows[i][2].ToString()) == "PreAuth") { row[1] = "PreAuth"; } if (PIn.String(tempT.Rows[i][2].ToString()) == "Other") { row[1] = "Other"; } if (tempT.Rows[i][3].ToString().Equals("H")) { row[2] = "Holding"; //Claim Status } else if (tempT.Rows[i][3].ToString().Equals("W")) { row[2] = "WaitQ"; //Claim Status, added SPK 7/15/04 } else { row[2] = "Unsent"; //Claim Status } row[3] = tempT.Rows[i][4]; //Patient name row[4] = tempT.Rows[i][5]; //Ins Carrier row[5] = PIn.Double(tempT.Rows[i][6].ToString()).ToString("F"); //claim fee report.ColTotal[5] += PIn.Double(tempT.Rows[i][6].ToString()); report.TableQ.Rows.Add(row); } FormQuery2.ResetGrid(); //this is a method in FormQuery2; report.Title = "Claims Not Sent"; report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle)); if (radioRange.Checked == true) { report.SubTitle.Add(date1.SelectionStart.ToString("d") + " - " + date2.SelectionStart.ToString("d")); } else { report.SubTitle.Add(date1.SelectionStart.ToString("d")); } report.ColPos[0] = 20; report.ColPos[1] = 145; report.ColPos[2] = 270; report.ColPos[3] = 395; report.ColPos[4] = 520; report.ColPos[5] = 645; report.ColPos[6] = 770; report.ColCaption[0] = "Date"; report.ColCaption[1] = "Type"; report.ColCaption[2] = "Claim Status"; report.ColCaption[3] = "Patient Name"; report.ColCaption[4] = "Insurance Carrier"; report.ColCaption[5] = "Amount"; report.ColAlign[5] = HorizontalAlignment.Right; FormQuery2.ShowDialog(); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { RxAlertCur.NotificationMsg = PIn.String(textMessage.Text); RxAlerts.Update(RxAlertCur); 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 butAdd_Click(object sender, EventArgs e) { List <MultiAdjEntry> listSelectedEntries = new List <MultiAdjEntry>(); for (int i = 0; i < gridMain.SelectedIndices.Count(); i++) { listSelectedEntries.Add((MultiAdjEntry)(gridMain.Rows[gridMain.SelectedIndices[i]].Tag)); } #region User Input Validation if (listSelectedEntries.Count() == 0 && _rigorousAdjustments == 0) { MsgBox.Show(this, "You must select a procedure to add the adjustment to."); return; } if (listTypePos.SelectedIndex == -1 && listTypeNeg.SelectedIndex == -1) { MsgBox.Show(this, "Please pick an adjustment type."); return; } if (comboProv.SelectedIndex == -1) { MsgBox.Show(this, "Please pick a provider."); return; } if (PrefC.HasClinicsEnabled && comboClinic.SelectedIndex == -1) { MsgBox.Show(this, "Please pick a clinic."); return; } if (string.IsNullOrWhiteSpace(dateAdjustment.Text) || dateAdjustment.errorProvider1.GetError(dateAdjustment) != "") { MsgBox.Show(this, "Please enter a valid date."); return; } if (PIn.Date(dateAdjustment.Text) > DateTime.Today && !PrefC.GetBool(PrefName.FutureTransDatesAllowed)) { MsgBox.Show(this, "Adjustments cannot be made for future dates"); return; } if (string.IsNullOrWhiteSpace(textAmt.Text) || textAmt.errorProvider1.GetError(textAmt) != "") { MsgBox.Show(this, "Please enter a valid amount."); return; } #endregion //loop through and update all adjustment rows foreach (MultiAdjEntry adjRow in listSelectedEntries.FindAll(x => x.Adj != null)) { UpdateAdjValues(adjRow); } Def selectedAdjType; if (listTypePos.SelectedIndex != -1) { selectedAdjType = _listAdjPosCats[listTypePos.SelectedIndex]; } else { selectedAdjType = _listAdjNegCats[listTypeNeg.SelectedIndex]; } //Create new adjustment Adjustment adjCur = new Adjustment(); adjCur.AdjType = selectedAdjType.DefNum; adjCur.AdjDate = PIn.Date(dateAdjustment.Text); adjCur.AdjNote = PIn.String(textNote.Text); adjCur.PatNum = _patCur.PatNum; if (listSelectedEntries.Count == 0) //User did not select anything and hit "add", so they must want to add an unattached adjustment. { InsertUnattachedRow(); adjCur.ProvNum = _patCur.PriProv; adjCur.ClinicNum = _patCur.ClinicNum; adjCur.ProcDate = adjCur.AdjDate; adjCur.ProcNum = 0; MultiAdjEntry adjRow = new MultiAdjEntry(adjCur, adjCur.AdjAmt); adjRow.AdjAmtType = AdjAmtType.FixedAmt; adjRow.AdjAmtOrPerc = PIn.Double(textAmt.Text); adjRow.RecalculateAdjAmt(0); _listGridEntries.Add(adjRow); } else //One or more procedure rows selected, create adjustments { foreach (MultiAdjEntry procRow in listSelectedEntries.FindAll(x => x.IsProcedureRow())) //Loop through all selected procedures { Adjustment adj = adjCur.Clone(); adj.ProcDate = procRow.Proc.ProcDate; adj.ProcNum = procRow.Proc.ProcNum; MultiAdjEntry adjRow = new MultiAdjEntry(procRow.Proc, adj, procRow.RemAfter); adjRow = UpdateAdjValues(adjRow); //This will set all of the important values from UI selections adjRow.AdjAmtType = SetAdjAmtType(); adjRow.AdjAmtOrPerc = PIn.Double(textAmt.Text); _listGridEntries.Add(adjRow); } } gridMain.Title = "Available Procedures with Adjustments"; FillGrid(); }
private void butOK_Click(object sender, EventArgs e) { if (_gridCurIndex > 0) { _listTableHeaders[_gridCurIndex].PickList = string.Join("\r\n", _listComboOptions); } //Set primary key to correct name----------------------------------------------------------------------- gridMain.Rows[0].Cells[0].Text = _wikiListCurName + "Num"; //prevents exceptions from occuring when user tries to rename PK. //Validate column names--------------------------------------------------------------------------------- for (int i = 0; i < gridMain.Rows.Count; i++) //ODGridCell colNameCell in gridMain.Rows[0].Cells){ { if (Regex.IsMatch(gridMain.Rows[i].Cells[0].Text, @"^\d")) { MsgBox.Show(this, "Column cannot start with numbers."); return; } if (Regex.IsMatch(gridMain.Rows[i].Cells[0].Text, @"\s")) { MsgBox.Show(this, "Column names cannot contain spaces."); return; } if (Regex.IsMatch(gridMain.Rows[i].Cells[0].Text, @"\W")) //W=non-word chars { MsgBox.Show(this, "Column names cannot contain special characters."); return; } } //Check for reserved words-------------------------------------------------------------------------------- for (int i = 0; i < gridMain.Rows.Count; i++) //ODGridCell colNameCell in gridMain.Rows[0].Cells){ { if (DbHelper.isMySQLReservedWord(gridMain.Rows[i].Cells[0].Text)) { MessageBox.Show(Lan.g(this, "Column name is a reserved word in MySQL") + ":" + gridMain.Rows[i].Cells[0].Text); return; } //primary key is caught by duplicate column name logic. } //Check for duplicates----------------------------------------------------------------------------------- List <string> listColNamesCheck = new List <string>(); for (int i = 0; i < gridMain.Rows.Count; i++) //ODGridCell colNameCell in gridMain.Rows[0].Cells){ { if (listColNamesCheck.Contains(gridMain.Rows[i].Cells[0].Text)) { MessageBox.Show(Lan.g(this, "Duplicate column name detected") + ":" + gridMain.Rows[0].Cells[i].Text); return; } listColNamesCheck.Add(gridMain.Rows[i].Cells[0].Text); } //Validate column widths--------------------------------------------------------------------------------- for (int i = 0; i < gridMain.Rows.Count; i++) //ODGridCell colNameCell in gridMain.Rows[0].Cells){ { if (Regex.IsMatch(gridMain.Rows[i].Cells[1].Text, @"\D")) // "\D" matches any non-decimal character { MsgBox.Show(this, "Column widths must only contain positive integers."); return; } if (gridMain.Rows[i].Cells[1].Text.Contains("-") || gridMain.Rows[i].Cells[1].Text.Contains(".") || gridMain.Rows[i].Cells[1].Text.Contains(",")) //inlcude the comma for international support. For instance Pi = 3.1415 or 3,1415 depending on your region { MsgBox.Show(this, "Column widths must only contain positive integers."); return; } } //save values to List<WikiListHeaderWidth> TableHeaders for (int i = 0; i < _listTableHeaders.Count; i++) { _listTableHeaders[i].ColName = PIn.String(gridMain.Rows[i].Cells[0].Text); _listTableHeaders[i].ColWidth = PIn.Int(gridMain.Rows[i].Cells[1].Text); } //Save data to database----------------------------------------------------------------------------------- try { WikiListHeaderWidths.UpdateNamesAndWidths(_wikiListCurName, _listTableHeaders); } catch (Exception ex) { MessageBox.Show(ex.Message); //will throw exception if table schema has changed since the window was opened. DialogResult = DialogResult.Cancel; } DataValid.SetInvalid(InvalidType.Wiki); DialogResult = DialogResult.OK; }
private void FillGrid() { long clinicNum = 0; //if clinics are not enabled, comboClinic.SelectedIndex will be -1, so clinicNum will be 0 and list will not be filtered by clinic if (Security.CurUser.ClinicIsRestricted && comboClinics.SelectedIndex > -1) { clinicNum = _listClinics[comboClinics.SelectedIndex].ClinicNum; } else if (comboClinics.SelectedIndex > 0) //if user is not restricted, clinicNum will be 0 and the query will get all clinic data { clinicNum = _listClinics[comboClinics.SelectedIndex - 1].ClinicNum; //if user is not restricted, comboClinic will contain "All" so minus 1 } int clinicWidth = 80; int patientWidth = 180; int carrierWidth = 220; if (PrefC.HasClinicsEnabled) { patientWidth = 140; carrierWidth = 200; } gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "Patient"), patientWidth); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "Carrier"), carrierWidth); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "TxMonths"), 70); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "Banding"), 80, HorizontalAlignment.Center); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "MonthsRem"), 100); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "#Sent"), 60); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "LastSent"), 80, HorizontalAlignment.Center); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "NextClaim"), 80, HorizontalAlignment.Center); gridMain.Columns.Add(col); if (PrefC.HasClinicsEnabled) //clinics is turned on { col = new ODGridColumn(Lan.g("TableAutoOrthoClaims", "Clinic"), clinicWidth, HorizontalAlignment.Center); gridMain.Columns.Add(col); } gridMain.Rows.Clear(); ODGridRow row; foreach (DataRow rowCur in _tableOutstandingAutoClaims.Rows) { //need a check for if clinics is on here if (PrefC.HasClinicsEnabled && //Clinics are enabled (Security.CurUser.ClinicIsRestricted || comboClinics.SelectedIndex != 0) && //"All" is not selected clinicNum != PIn.Long(rowCur["ClinicNum"].ToString())) //currently selected clinic doesn't match the row's clinic { continue; } row = new ODGridRow(); DateTime dateLastSeen = PIn.Date(rowCur["LastSent"].ToString()); DateTime dateBanding = PIn.Date(rowCur["DateBanding"].ToString()); DateTime dateNextClaim = PIn.Date(rowCur["OrthoAutoNextClaimDate"].ToString()); DateTimeOD dateTMonthsRem = new DateTimeOD(PIn.Date(rowCur["DateBanding"].ToString()).AddMonths(PIn.Int(rowCur["MonthsTreat"].ToString())), DateTimeOD.Today); row.Cells.Add(PIn.String(rowCur["Patient"].ToString())); row.Cells.Add(PIn.String(rowCur["CarrierName"].ToString())); row.Cells.Add(PIn.String(rowCur["MonthsTreat"].ToString())); row.Cells.Add(dateBanding.Year < 1880 ? "" : dateBanding.ToShortDateString()); //add blank if there is no banding if (dateBanding.Year < 1880) //add blank if there is no banding { row.Cells.Add(""); } else { row.Cells.Add(((dateTMonthsRem.YearsDiff * 12) + dateTMonthsRem.MonthsDiff) + " " + Lan.g(this, "months") + ", " + dateTMonthsRem.DaysDiff + " " + Lan.g(this, "days")); } row.Cells.Add(PIn.String(rowCur["NumSent"].ToString())); row.Cells.Add(dateLastSeen.Year < 1880 ? "" : dateLastSeen.ToShortDateString()); row.Cells.Add(dateNextClaim.Year < 1880 ? "" : dateNextClaim.ToShortDateString()); if (PrefC.HasClinicsEnabled) //clinics is turned on //Use the long list of clinics so that hidden clinics can be shown for unrestricted users. { row.Cells.Add(Clinics.GetAbbr(PIn.Long(rowCur["ClinicNum"].ToString()))); } row.Tag = rowCur; gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void butText_Click(object sender,EventArgs e) { long patNum; string wirelessPhone; YN txtMsgOk; if(grid.Rows.Count==0) { MsgBox.Show(this,"There are no Patients in the table. Must have at least one."); return; } if(PrefC.GetLong(PrefName.ConfirmStatusTextMessaged)==0) { MsgBox.Show(this,"You need to set a status first for confirmation text messages in the Recall Setup window."); return; } if(grid.SelectedIndices.Length==0) {//None selected. Select all of type text that are not yet confirmed by text message. ContactMethod cmeth; for(int i=0;i<Table.Rows.Count;i++) { cmeth=(ContactMethod)PIn.Int(Table.Rows[i]["PreferConfirmMethod"].ToString()); if(cmeth!=ContactMethod.TextMessage) { continue; } if(Table.Rows[i]["confirmed"].ToString()==DefC.GetName(DefCat.ApptConfirmed,PrefC.GetLong(PrefName.ConfirmStatusTextMessaged))) {//Already confirmed by text continue; } if(!Table.Rows[i]["contactMethod"].ToString().StartsWith("Text:")) {//Check contact method continue; } grid.SetSelected(i,true); } if(grid.SelectedIndices.Length==0) { MsgBox.Show(this,"All patients of text message type have been sent confirmations."); return; } } //deselect the ones that do not have text messages specified or are not OK to send texts to or have already been texted int skipped=0; for(int i=grid.SelectedIndices.Length-1;i>=0;i--) { wirelessPhone=Table.Rows[grid.SelectedIndices[i]]["WirelessPhone"].ToString(); if(wirelessPhone=="") {//Check for wireless number skipped++; grid.SetSelected(grid.SelectedIndices[i],false); continue; } txtMsgOk=(YN)PIn.Int(Table.Rows[grid.SelectedIndices[i]]["TxtMsgOk"].ToString()); if(txtMsgOk==YN.Unknown && PrefC.GetBool(PrefName.TextMsgOkStatusTreatAsNo)) {//Check if OK to text skipped++; grid.SetSelected(grid.SelectedIndices[i],false); continue; } if(txtMsgOk==YN.No){//Check if OK to text skipped++; grid.SetSelected(grid.SelectedIndices[i],false); continue; } } if(grid.SelectedIndices.Length==0) { MsgBox.Show(this,"None of the selected patients have wireless phone numbers and are OK to text."); return; } if(skipped>0) { MessageBox.Show(Lan.g(this,"Selected patients skipped: ")+skipped.ToString()); } if(!MsgBox.Show(this,MsgBoxButtons.YesNo,"Send text message to all of the selected patients?")) { return; } Cursor=Cursors.WaitCursor; FormTxtMsgEdit FormTME=new FormTxtMsgEdit(); string message=""; //Appointment apt; for(int i=0;i<grid.SelectedIndices.Length;i++){ patNum=PIn.Long(Table.Rows[grid.SelectedIndices[i]]["PatNum"].ToString()); wirelessPhone=PIn.String(Table.Rows[grid.SelectedIndices[i]]["WirelessPhone"].ToString()); txtMsgOk=((YN)PIn.Int(Table.Rows[grid.SelectedIndices[i]]["TxtMsgOk"].ToString())); message=PrefC.GetString(PrefName.ConfirmTextMessage); message=message.Replace("[NameF]",Table.Rows[grid.SelectedIndices[i]]["nameF"].ToString()); message=message.Replace("[NameFL]",Table.Rows[grid.SelectedIndices[i]]["nameFL"].ToString()); message=message.Replace("[date]",((DateTime)Table.Rows[grid.SelectedIndices[i]]["AptDateTime"]).ToShortDateString()); message=message.Replace("[time]",((DateTime)Table.Rows[grid.SelectedIndices[i]]["AptDateTime"]).ToShortTimeString()); FormTME.SendText(patNum,wirelessPhone,message,txtMsgOk); Appointments.SetConfirmed(PIn.Long(Table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString()),PrefC.GetLong(PrefName.ConfirmStatusTextMessaged)); } FillMain(); Cursor=Cursors.Default; }
private void butOK_Click(object sender, System.EventArgs e) { try { PIn.Int(textPort.Text); } catch { MsgBox.Show(this, "Invalid outgoing port number."); return; } try { PIn.Int(textPortIncoming.Text); } catch { MsgBox.Show(this, "Invalid incoming port number."); return; } if (string.IsNullOrWhiteSpace(textUsername.Text)) { MsgBox.Show(this, "Please enter a valid email address."); return; } //Only checks against non-user email addresses. if (EmailAddresses.AddressExists(textUsername.Text, _emailAddressCur.EmailAddressNum)) { MsgBox.Show(this, "This email address already exists."); return; } if (!textPassword.Text.IsNullOrEmpty() && !textAccessToken.Text.IsNullOrEmpty()) { MsgBox.Show(this, "There is an email password and access token entered. Please clear one and try again."); return; } _emailAddressCur.AccessToken = textAccessToken.Text; _emailAddressCur.RefreshToken = textRefreshToken.Text; if (!_isNew && (!string.IsNullOrWhiteSpace(_emailAddressCur.AccessToken) || !string.IsNullOrWhiteSpace(_emailAddressCur.RefreshToken)) && //If has a token (_emailAddressCur.SMTPserver != PIn.String(textSMTPserver.Text) || _emailAddressCur.Pop3ServerIncoming != PIn.String(textSMTPserverIncoming.Text))) //And changed a server { if (!MsgBox.Show(MsgBoxButtons.OKCancel, "There is an access token associated to this email address. " + "Changing servers will wipe out the access token and may require reauthentication. Continue?")) { return; } _emailAddressCur.AccessToken = ""; _emailAddressCur.RefreshToken = ""; //TODO: If this is a google token, we may want to tell Google we no longer require access to their account. //This will limit our total number of active users } _emailAddressCur.SMTPserver = PIn.String(textSMTPserver.Text); _emailAddressCur.EmailUsername = PIn.String(textUsername.Text); _emailAddressCur.EmailPassword = PIn.String(MiscUtils.Encrypt(textPassword.Text)); _emailAddressCur.ServerPort = PIn.Int(textPort.Text); _emailAddressCur.UseSSL = checkSSL.Checked; _emailAddressCur.SenderAddress = PIn.String(textSender.Text); _emailAddressCur.Pop3ServerIncoming = PIn.String(textSMTPserverIncoming.Text); _emailAddressCur.ServerPortIncoming = PIn.Int(textPortIncoming.Text); _emailAddressCur.UserNum = ((Userod)(textUserod.Tag))?.UserNum ?? 0; if (_isNew) { EmailAddresses.Insert(_emailAddressCur); } else { EmailAddresses.Update(_emailAddressCur); } DialogResult = DialogResult.OK; }
///<summary>Set all fields of this control. This is an alternative to constructing an entirely new instance. ///All uses of this control currently construct as Visible=false so that is the default here.</summary> public void ResetData(DataRow rowApt, DataTable tableApptFields, DataTable tablePatFields, Point location, bool visible = false) { DataRoww = rowApt; TableApptFields = tableApptFields; TablePatFields = tablePatFields; Pattern = PIn.String(DataRoww["Pattern"].ToString()); PatternShowing = ApptSingleDrawing.GetPatternShowing(Pattern); Location = location; Size = ApptSingleDrawing.SetSize(Pattern); //These controls are always drawn as their Shadow bitmap. //They never actually render as a control. //Always set Visible to false here so that parent panel/form doesn't account for them when drawings it's controls. //In the case where it is a draggable control or on the pinboard, then it will be set to Visible=true. Visible = visible; //These are used heavily so deserialize here once to save time when accessing. AptNum = PIn.Long(DataRoww["AptNum"].ToString()); PatNum = PIn.Long(DataRoww["PatNum"].ToString()); AptDateTime = PIn.DateT(DataRoww["AptDateTime"].ToString()); OpNum = PIn.Long(DataRoww["Op"].ToString()); ClinicNum = PIn.Long(DataRoww["ClinicNum"].ToString()); ProvNum = PIn.Long(DataRoww["ProvNum"].ToString()); ProvHyg = PIn.Long(DataRoww["ProvHyg"].ToString()); Confirmed = PIn.Long(DataRoww["Confirmed"].ToString()); IsHygiene = PIn.Bool(DataRoww["IsHygiene"].ToString()); GrossProduction = PIn.Decimal(DataRoww["productionVal"].ToString()); WriteoffPPO = PIn.Decimal(DataRoww["writeoffPPO"].ToString()); AdjustmentTotal = PIn.Decimal(DataRoww["adjustmentTotal"].ToString()); ImageFolder = PIn.String(DataRoww["ImageFolder"].ToString()); PatientName = PIn.String(DataRoww["patientName"].ToString()); AptDate = PIn.String(DataRoww["aptDate"].ToString()); AptDay = PIn.String(DataRoww["aptDay"].ToString()); AptLength = PIn.String(DataRoww["aptLength"].ToString()); AptTime = PIn.String(DataRoww["aptTime"].ToString()); Email = PIn.String(DataRoww["Email"].ToString()); Language = PIn.String(DataRoww["language"].ToString()); ReferralTo = PIn.String(DataRoww["referralTo"].ToString()); ReferralFrom = PIn.String(DataRoww["referralFrom"].ToString()); ApptModNote = PIn.String(DataRoww["apptModNote"].ToString()); FamFinUrgNote = PIn.String(DataRoww["famFinUrgNote"].ToString()); AddrNote = PIn.String(DataRoww["addrNote"].ToString()); Insurance = PIn.String(DataRoww["insurance"].ToString()); ContactMethods = PIn.String(DataRoww["contactMethods"].ToString()); WirelessPhone = PIn.String(DataRoww["wirelessPhone"].ToString()); WkPhone = PIn.String(DataRoww["wkPhone"].ToString()); HmPhone = PIn.String(DataRoww["hmPhone"].ToString()); Age = PIn.String(DataRoww["age"].ToString()); BillingType = PIn.String(DataRoww["billingType"].ToString()); ChartNumber = PIn.String(DataRoww["chartNumber"].ToString()); Note = PIn.String(DataRoww["Note"].ToString()); Procs = PIn.String(DataRoww["procs"].ToString()); Lab = PIn.String(DataRoww["lab"].ToString()); MedUrgNote = PIn.String(DataRoww["MedUrgNote"].ToString()); PreMedFlag = PIn.String(DataRoww["preMedFlag"].ToString()); ConfirmedFromDef = PIn.String(DataRoww["confirmed"].ToString()); Production = PIn.String(DataRoww["production"].ToString()); Provider = PIn.String(DataRoww["provider"].ToString()); ApptStatus aptStatus; if (Enum.TryParse(PIn.String(DataRoww["AptStatus"].ToString()), out aptStatus)) { AptStatus = aptStatus; } else { AptStatus = ApptStatus.None; } ApptPriority priority; if (Enum.TryParse(PIn.String(DataRoww["Priority"].ToString()), out priority)) { Priority = priority; } else { Priority = ApptPriority.Normal; } }
///<summary>Saves the selected rows to database. MUST close window after this.</summary> private bool SaveToDB() { if (textDate.errorProvider1.GetError(textDate) != "") { MsgBox.Show(this, "Please fix data entry errors first."); return(false); } //Prevent backdating---------------------------------------------------------------------------------------- DateTime date = PIn.Date(textDate.Text); if (IsNew) { if (!Security.IsAuthorized(Permissions.DepositSlips, date)) { return(false); } } else { //We enforce security here based on date displayed, not date entered if (!Security.IsAuthorized(Permissions.DepositSlips, date)) { return(false); } } DepositCur.DateDeposit = PIn.Date(textDate.Text); //amount already handled. DepositCur.BankAccountInfo = PIn.String(textBankAccountInfo.Text); if (IsNew) { if (gridPat.SelectedIndices.Length + gridIns.SelectedIndices.Length > 18) { if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "No more than 18 items will fit on a QuickBooks deposit slip. Continue anyway?")) { return(false); } } Deposits.Insert(DepositCur); if (Accounts.DepositsLinked() && DepositCur.Amount > 0) { if (PrefC.GetInt(PrefName.AccountingSoftware) == (int)AccountingSoftware.QuickBooks) { //Create a deposit within QuickBooks. try { Cursor.Current = Cursors.WaitCursor; QuickBooks.CreateDeposit(DepositAccountsQB[comboDepositAccount.SelectedIndex] , PrefC.GetString(PrefName.QuickBooksIncomeAccount), DepositCur.Amount); Cursor.Current = Cursors.Default; } catch (Exception ex) { Cursor.Current = Cursors.Default; if (MessageBox.Show(ex.Message + "\r\n\r\nA deposit has not been created in QuickBooks, continue anyway?", "QuickBooks Deposit Create Failed", MessageBoxButtons.YesNo) != DialogResult.Yes) { return(false); } } } else { //create a transaction here Transaction trans = new Transaction(); trans.DepositNum = DepositCur.DepositNum; trans.UserNum = Security.CurUser.UserNum; Transactions.Insert(trans); //first the deposit entry JournalEntry je = new JournalEntry(); je.AccountNum = DepositAccounts[comboDepositAccount.SelectedIndex]; je.CheckNumber = Lan.g(this, "DEP"); je.DateDisplayed = DepositCur.DateDeposit; //it would be nice to add security here. je.DebitAmt = DepositCur.Amount; je.Memo = Lan.g(this, "Deposit"); je.Splits = Accounts.GetDescript(PrefC.GetLong(PrefName.AccountingIncomeAccount)); je.TransactionNum = trans.TransactionNum; JournalEntries.Insert(je); //then, the income entry je = new JournalEntry(); je.AccountNum = PrefC.GetLong(PrefName.AccountingIncomeAccount); //je.CheckNumber=; je.DateDisplayed = DepositCur.DateDeposit; //it would be nice to add security here. je.CreditAmt = DepositCur.Amount; je.Memo = Lan.g(this, "Deposit"); je.Splits = Accounts.GetDescript(DepositAccounts[comboDepositAccount.SelectedIndex]); je.TransactionNum = trans.TransactionNum; JournalEntries.Insert(je); } } } else { Deposits.Update(DepositCur); } if (IsNew) //never allowed to change or attach more checks after initial creation of deposit slip { for (int i = 0; i < gridPat.SelectedIndices.Length; i++) { PatPayList[gridPat.SelectedIndices[i]].DepositNum = DepositCur.DepositNum; Payments.Update(PatPayList[gridPat.SelectedIndices[i]], false); } for (int i = 0; i < gridIns.SelectedIndices.Length; i++) { ClaimPayList[gridIns.SelectedIndices[i]].DepositNum = DepositCur.DepositNum; ClaimPayments.Update(ClaimPayList[gridIns.SelectedIndices[i]]); } } if (IsNew) { SecurityLogs.MakeLogEntry(Permissions.DepositSlips, 0, DepositCur.DateDeposit.ToShortDateString() + " New " + DepositCur.Amount.ToString("c")); } else { SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, 0, DepositCur.DateDeposit.ToShortDateString() + " " + DepositCur.Amount.ToString("c")); } return(true); }
private void butOK_Click(object sender, System.EventArgs e) { if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" || textDateTo.errorProvider1.GetError(textDateTo) != "" ) { MessageBox.Show(Lan.g(this, "Please fix data entry errors first.")); return; } DateTime FromDate; DateTime ToDate; if (textDateFrom.Text == "") { MessageBox.Show(Lan.g(this, "From Date cannot be left blank.")); return; } FromDate = PIn.Date(textDateFrom.Text); if (textDateTo.Text == "") { ToDate = DateTime.MaxValue.AddDays(-1); } else { ToDate = PIn.Date(textDateTo.Text); } //Create the file and first row-------------------------------------------------------- List <ProgramProperty> ForProgram = ProgramProperties.GetForProgram(ProgramCur.ProgramNum); ProgramProperty PPCur = ProgramProperties.GetCur(ForProgram, "Export Path"); string fileName = PPCur.PropertyValue + "Appt.txt"; if (!Directory.Exists(PPCur.PropertyValue)) { Directory.CreateDirectory(PPCur.PropertyValue); } StreamWriter sr = File.CreateText(fileName); sr.WriteLine("\"LastName\",\"FirstName\",\"PatientNumber\",\"HomePhone\",\"WorkNumber\"," + "\"EmailAddress\",\"SendEmail\",\"Address\",\"Address2\",\"City\",\"State\",\"Zip\"," + "\"ApptDate\",\"ApptTime\",\"ApptReason\",\"DoctorNumber\",\"DoctorName\",\"IsNewPatient\",\"WirelessPhone\""); DataTable table = HouseCallsQueries.GetHouseCalls(FromDate, ToDate); bool usePatNum = false; PPCur = ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");; if (PPCur.PropertyValue == "0") { usePatNum = true; } DateTime aptDT; for (int i = 0; i < table.Rows.Count; i++) { sr.Write("\"" + Dequote(PIn.String(table.Rows[i][0].ToString())) + "\","); //0-LastName if (table.Rows[i][2].ToString() != "") //if Preferred Name exists { sr.Write("\"" + Dequote(PIn.String(table.Rows[i][2].ToString())) + "\","); //2-PrefName } else { sr.Write("\"" + Dequote(PIn.String(table.Rows[i][1].ToString())) + "\","); //1-FirstName } if (usePatNum) { sr.Write("\"" + table.Rows[i][3].ToString() + "\","); //3-PatNum } else { sr.Write("\"" + Dequote(PIn.String(table.Rows[i][4].ToString())) + "\","); //4-ChartNumber } sr.Write("\"" + Dequote(PIn.String(table.Rows[i][5].ToString())) + "\","); //5-HomePhone sr.Write("\"" + Dequote(PIn.String(table.Rows[i][6].ToString())) + "\","); //6-WorkNumber sr.Write("\"" + Dequote(PIn.String(table.Rows[i][7].ToString())) + "\","); //7-EmailAddress if (table.Rows[i][7].ToString() != "") //if an email exists { sr.Write("\"T\","); //SendEmail } else { sr.Write("\"F\","); } sr.Write("\"" + Dequote(PIn.String(table.Rows[i][8].ToString())) + "\","); //8-Address sr.Write("\"" + Dequote(PIn.String(table.Rows[i][9].ToString())) + "\","); //9-Address2 sr.Write("\"" + Dequote(PIn.String(table.Rows[i][10].ToString())) + "\","); //10-City sr.Write("\"" + Dequote(PIn.String(table.Rows[i][11].ToString())) + "\","); //11-State sr.Write("\"" + Dequote(PIn.String(table.Rows[i][12].ToString())) + "\","); //12-Zip aptDT = PIn.DateT(table.Rows[i][13].ToString()); sr.Write("\"" + aptDT.ToString("MM/dd/yyyy") + "\","); //13-ApptDate sr.Write("\"" + aptDT.ToString("hh:mm tt") + "\","); //13-ApptTime eg 01:30 PM sr.Write("\"" + Dequote(PIn.String(table.Rows[i][14].ToString())) + "\","); //14-ApptReason sr.Write("\"" + table.Rows[i][15].ToString() + "\","); //15-DoctorNumber. might possibly be 0 //15-DoctorName. Can handle 0 without any problem. sr.Write("\"" + Dequote(Providers.GetLName(PIn.Long(table.Rows[i][15].ToString()))) + "\","); if (table.Rows[i][16].ToString() == "1") //16-IsNewPatient { sr.Write("\"T\","); //SendEmail } else { sr.Write("\"F\","); } sr.Write("\"" + Dequote(PIn.String(table.Rows[i][17].ToString())) + "\""); //17-WirelessPhone sr.WriteLine(); //Must be last. } sr.Close(); MessageBox.Show("Done"); DialogResult = DialogResult.OK; }
public void FillGrid() { RefreshReport(); gridMain.BeginUpdate(); GridColumn col = null; if (gridMain.ListGridColumns.Count == 0) { col = new GridColumn(Lan.g(this, "Patient Name"), _colWidthPatName); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Stat"), _colWidthStat, HorizontalAlignment.Center); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Procedure Date"), _colWidthProcDate, HorizontalAlignment.Center); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Procedure Descipion"), 0); //Dynaimc width gridMain.ListGridColumns.Add(col); if (PrefC.HasClinicsEnabled) { col = new GridColumn(Lan.g(this, "Clinic"), _colWidthClinic); gridMain.ListGridColumns.Add(col); } col = new GridColumn(Lan.g(this, "Amount"), _colWidthAmount, HorizontalAlignment.Right); gridMain.ListGridColumns.Add(col); } gridMain.ListGridRows.Clear(); GridRow row; for (int i = 0; i < _myReport.ReportObjects.Count; i++) { if (_myReport.ReportObjects[i].ObjectType != ReportObjectType.QueryObject) { continue; } QueryObject queryObj = (QueryObject)_myReport.ReportObjects[i]; for (int j = 0; j < queryObj.ReportTable.Rows.Count; j++) { row = new GridRow(); row.Cells.Add(queryObj.ReportTable.Rows[j][0].ToString()); //Procedure Name row.Cells.Add(Lan.g("enumProcStat", PIn.String(queryObj.ReportTable.Rows[j][1].ToString()))); //Stat row.Cells.Add(PIn.Date(queryObj.ReportTable.Rows[j][2].ToString()).ToShortDateString()); //Procedure Date row.Cells.Add(queryObj.ReportTable.Rows[j][3].ToString()); //Procedure Description if (PrefC.HasClinicsEnabled) { long clinicNum = PIn.Long(queryObj.ReportTable.Rows[j][6].ToString()); if (clinicNum == 0) { row.Cells.Add("Unassigned"); } else { row.Cells.Add(Clinics.GetAbbr(clinicNum)); } } row.Cells.Add(PIn.Double(queryObj.ReportTable.Rows[j][4].ToString()).ToString("c")); //Amount _procTotalAmt += PIn.Decimal(queryObj.ReportTable.Rows[j][4].ToString()); row.Tag = ((QueryObject)_myReport.ReportObjects[i]).ReportTable.Rows[j]; gridMain.ListGridRows.Add(row); } } gridMain.EndUpdate(); }