///<summary></summary> public static string RunningSum(string groupBy,string addValue){ decimal num=PIn.Decimal(addValue); if(groupByVal==null || groupBy!=groupByVal){//if new or changed group runningSum=0; } groupByVal=groupBy; runningSum+=num; return runningSum.ToString("F"); }
private void FillScreen() { List <ContrDashProvList_Row> ListProv = new List <ContrDashProvList_Row>(); ContrDashProvList_Row row; for (int i = 0; i < table.Rows.Count; i++) { row = new ContrDashProvList_Row(); row.ProvName = Providers.GetAbbr(PIn.Long(table.Rows[i]["ProvNum"].ToString())); System.Drawing.Color c1 = Providers.GetColor(PIn.Long(table.Rows[i]["ProvNum"].ToString())); row.ProvColor = Color.FromArgb(c1.A, c1.R, c1.G, c1.B); decimal production = PIn.Decimal(table.Rows[i]["production"].ToString()); if (production == 0) { row.Production = ""; } else { row.Production = production.ToString("c0"); } decimal income = PIn.Decimal(table.Rows[i]["income"].ToString()); if (income == 0) { row.Income = ""; } else { row.Income = income.ToString("c0"); } ListProv.Add(row); } //Style style=new Style(typeof(TextBlock)); //style.Setters.Add(new Setter(TextBlock.HorizontalAlignmentProperty,HorizontalAlignment.Right)); //((DataGridTextColumn)gridMain.Columns[2]).ElementStyle=style; //((DataGridTextColumn)gridMain.Columns[2]).Binding=new Binding("Production"); //((DataGridTextColumn)gridMain.Columns[2]).Binding.StringFormat="c0"; gridMain.ItemsSource = ListProv; }
///<summary>Adds the xml for one statement.</summary> public static void GenerateOneStatement(XmlWriter writer, Statement stmt, Patient pat, Family fam, DataSet dataSet) { writer.WriteStartElement("Statement"); writer.WriteStartElement("RecipientAddress"); Patient guar = fam.ListPats[0]; writer.WriteElementString("Name", guar.GetNameFLFormal()); if (PrefC.GetBool(PrefName.StatementAccountsUseChartNumber)) { writer.WriteElementString("Account", guar.ChartNumber); } else { writer.WriteElementString("Account", POut.Long(guar.PatNum)); } writer.WriteElementString("Address1", guar.Address); writer.WriteElementString("Address2", guar.Address2); writer.WriteElementString("City", guar.City); writer.WriteElementString("State", guar.State); writer.WriteElementString("Zip", guar.Zip); string email = ""; Def billingDef = Defs.GetDef(DefCat.BillingTypes, guar.BillingType); if (billingDef.ItemValue == "E") { email = guar.Email; } writer.WriteElementString("EMail", email); writer.WriteEndElement(); //RecipientAddress //Account summary----------------------------------------------------------------------- if (stmt.DateRangeFrom.Year < 1880) //make up a statement date. { writer.WriteElementString("PriorStatementDate", DateTime.Today.AddMonths(-1).ToString("MM/dd/yyyy")); } else { writer.WriteElementString("PriorStatementDate", stmt.DateRangeFrom.AddDays(-1).ToString("MM/dd/yyyy")); } DateTime dueDate; if (PrefC.GetLong(PrefName.StatementsCalcDueDate) == -1) { dueDate = DateTime.Today.AddDays(10); } else { dueDate = DateTime.Today.AddDays(PrefC.GetLong(PrefName.StatementsCalcDueDate)); } writer.WriteElementString("DueDate", dueDate.ToString("MM/dd/yyyy")); writer.WriteElementString("StatementDate", stmt.DateSent.ToString("MM/dd/yyyy")); double balanceForward = 0; for (int r = 0; r < dataSet.Tables["misc"].Rows.Count; r++) { if (dataSet.Tables["misc"].Rows[r]["descript"].ToString() == "balanceForward") { balanceForward = PIn.Double(dataSet.Tables["misc"].Rows[r]["value"].ToString()); } } writer.WriteElementString("PriorBalance", balanceForward.ToString("F2")); DataTable tableAccount = null; for (int i = 0; i < dataSet.Tables.Count; i++) { if (dataSet.Tables[i].TableName.StartsWith("account")) { tableAccount = dataSet.Tables[i]; } } double credits = 0; for (int i = 0; i < tableAccount.Rows.Count; i++) { credits += PIn.Double(tableAccount.Rows[i]["creditsDouble"].ToString()); } writer.WriteElementString("Credits", credits.ToString("F2")); decimal payPlanDue = 0; double amountDue = guar.BalTotal; for (int m = 0; m < dataSet.Tables["misc"].Rows.Count; m++) { if (dataSet.Tables["misc"].Rows[m]["descript"].ToString() == "payPlanDue") { payPlanDue += PIn.Decimal(dataSet.Tables["misc"].Rows[m]["value"].ToString()); //This will be an option once more users are using it. } } writer.WriteElementString("PayPlanDue", payPlanDue.ToString("F2")); if (PrefC.GetBool(PrefName.BalancesDontSubtractIns)) { writer.WriteElementString("EstInsPayments", ""); //optional. } else //this is typical { writer.WriteElementString("EstInsPayments", guar.InsEst.ToString("F2")); //optional. amountDue -= guar.InsEst; } InstallmentPlan installPlan = InstallmentPlans.GetOneForFam(guar.PatNum); if (installPlan != null) { //show lesser of normal total balance or the monthly payment amount. if (installPlan.MonthlyPayment < amountDue) { amountDue = installPlan.MonthlyPayment; } } writer.WriteElementString("AmountDue", amountDue.ToString("F2")); writer.WriteElementString("PastDue30", guar.Bal_31_60.ToString("F2")); //optional writer.WriteElementString("PastDue60", guar.Bal_61_90.ToString("F2")); //optional writer.WriteElementString("PastDue90", guar.BalOver90.ToString("F2")); //optional //Notes----------------------------------------------------------------------------------- writer.WriteStartElement("Notes"); if (stmt.NoteBold != "") { writer.WriteStartElement("Note"); writer.WriteAttributeString("FgColor", "Red"); writer.WriteCData(stmt.NoteBold); writer.WriteEndElement(); //Note } if (stmt.Note != "") { writer.WriteStartElement("Note"); writer.WriteCData(stmt.Note); writer.WriteEndElement(); //Note } writer.WriteEndElement(); //Notes //Detail items------------------------------------------------------------------------------ writer.WriteStartElement("DetailItems"); //string note; string descript; string fulldesc; string procCode; string tth; //string linedesc; string[] lineArray; List <string> lines; DateTime date; int seq = 0; for (int i = 0; i < tableAccount.Rows.Count; i++) { procCode = tableAccount.Rows[i]["ProcCode"].ToString(); tth = tableAccount.Rows[i]["tth"].ToString(); descript = tableAccount.Rows[i]["description"].ToString(); fulldesc = procCode + " " + tth + " " + descript; lineArray = fulldesc.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); lines = new List <string>(lineArray); //The specs say that the line limit is 30 char. But in testing, it will take 50 char. //We will use 40 char to be safe. if (lines[0].Length > 40) { string newline = lines[0].Substring(40); lines[0] = lines[0].Substring(0, 40); //first half lines.Insert(1, newline); //second half } for (int li = 0; li < lines.Count; li++) { writer.WriteStartElement("DetailItem"); //has a child item. We won't add optional child note writer.WriteAttributeString("sequence", seq.ToString()); writer.WriteStartElement("Item"); if (li == 0) { date = (DateTime)tableAccount.Rows[i]["DateTime"]; writer.WriteElementString("Date", date.ToString("MM/dd/yyyy")); writer.WriteElementString("PatientName", tableAccount.Rows[i]["patient"].ToString()); } else { writer.WriteElementString("Date", ""); writer.WriteElementString("PatientName", ""); } writer.WriteElementString("Description", lines[li]); if (li == 0) { writer.WriteElementString("Charges", tableAccount.Rows[i]["charges"].ToString()); writer.WriteElementString("Credits", tableAccount.Rows[i]["credits"].ToString()); writer.WriteElementString("Balance", tableAccount.Rows[i]["balance"].ToString()); } else { writer.WriteElementString("Charges", ""); writer.WriteElementString("Credits", ""); writer.WriteElementString("Balance", ""); } writer.WriteEndElement(); //Item writer.WriteEndElement(); //DetailItem seq++; } } writer.WriteEndElement(); //DetailItems writer.WriteEndElement(); //Statement }
private void RunProvider() { ReportComplex report = new ReportComplex(true, true); _dateFrom = PIn.Date(textDateFrom.Text); _dateTo = PIn.Date(textDateTo.Text); List <DataSet> listProdData = new List <DataSet>(); List <Provider> listProvs = new List <Provider>(); List <string> listServerNames = new List <string>(); string strFailedConn = ""; for (int i = 0; i < ConnList.Count; i++) { ODThread odThread = new ODThread(ConnectAndRunProviderReport, new object[] { ConnList[i] }); odThread.GroupName = "ConnectAndReportProvider"; odThread.Start(false); } ODThread.JoinThreadsByGroupName(Timeout.Infinite, "ConnectAndReportProvider"); List <ODThread> listThreads = ODThread.GetThreadsByGroupName("ConnectAndReportProvider"); for (int i = 0; i < listThreads.Count; i++) { object[] obj = (object[])listThreads[i].Tag; DataSet data = (DataSet)obj[0]; string connString = CentralConnections.GetConnectionString((CentralConnection)obj[1]); List <Provider> listConnProvs = (List <Provider>)obj[2]; if (data == null) { strFailedConn += connString + "\r\n"; } else { listServerNames.Add(connString); listProdData.Add(data); listProvs.AddRange(listConnProvs); } listThreads[i].QuitSync(Timeout.Infinite); } report.ReportName = "Provider P&I"; report.AddTitle("Title", Lan.g(this, "Provider Production and Income")); report.AddSubTitle("PracName", PrefC.GetString(PrefName.PracticeTitle)); report.AddSubTitle("Date", _dateFrom.ToShortDateString() + " - " + _dateTo.ToShortDateString()); report.AddSubTitle("Providers", Lan.g(this, "All Providers")); report.AddSubTitle("Clinics", Lan.g(this, "All Clinics")); //setup query QueryObject query; DataSet dsTotal = new DataSet(); for (int i = 0; i < listProdData.Count; i++) { DataTable dt = listProdData[i].Tables["Clinic"]; DataTable dtTot = listProdData[i].Tables["Total"].Copy(); dtTot.TableName = dtTot.TableName + "_" + i; dsTotal.Tables.Add(dtTot); query = report.AddQuery(dt, listServerNames[i], "Clinic", SplitByKind.Value, 1, true); // add columns to report query.AddColumn("Provider", 75, FieldValueType.String); query.AddColumn("Production", 120, FieldValueType.Number); query.AddColumn("Adjustments", 120, FieldValueType.Number); query.AddColumn("Writeoff", 120, FieldValueType.Number); query.AddColumn("Tot Prod", 120, FieldValueType.Number); query.AddColumn("Pt Income", 120, FieldValueType.Number); query.AddColumn("Ins Income", 120, FieldValueType.Number); query.AddColumn("Total Income", 120, FieldValueType.Number); } if (dsTotal.Tables.Count == 0) { MsgBox.Show(this, "This report returned no values"); return; } DataTable dtTotal; decimal production; decimal adjust; decimal inswriteoff; decimal totalproduction; decimal ptincome; decimal insincome; decimal totalincome; dtTotal = dsTotal.Tables[0].Clone(); for (int i = 0; i < listProvs.Count; i++) { Provider provCur = listProvs[i]; DataRow row = dtTotal.NewRow(); row[0] = provCur.Abbr; production = 0; adjust = 0; inswriteoff = 0; totalproduction = 0; ptincome = 0; insincome = 0; totalincome = 0; bool hasAnyAmount = false; for (int j = 0; j < dsTotal.Tables.Count; j++) { for (int k = 0; k < dsTotal.Tables[j].Rows.Count; k++) { if (dsTotal.Tables[j].Rows[k][0].ToString() == provCur.Abbr && (PIn.Decimal(dsTotal.Tables[j].Rows[k]["Production"].ToString()) != 0 || PIn.Decimal(dsTotal.Tables[j].Rows[k]["Adjustments"].ToString()) != 0 || PIn.Decimal(dsTotal.Tables[j].Rows[k]["WriteOff"].ToString()) != 0 || PIn.Decimal(dsTotal.Tables[j].Rows[k]["Pt Income"].ToString()) != 0 || PIn.Decimal(dsTotal.Tables[j].Rows[k]["Ins Income"].ToString()) != 0)) { production += PIn.Decimal(dsTotal.Tables[j].Rows[k]["Production"].ToString()); adjust += PIn.Decimal(dsTotal.Tables[j].Rows[k]["Adjustments"].ToString()); inswriteoff += PIn.Decimal(dsTotal.Tables[j].Rows[k]["WriteOff"].ToString()); //Writeoffs stored as negative number ptincome += PIn.Decimal(dsTotal.Tables[j].Rows[k]["Pt Income"].ToString()); insincome += PIn.Decimal(dsTotal.Tables[j].Rows[k]["Ins Income"].ToString()); hasAnyAmount = true; } } } totalproduction = production + adjust + inswriteoff; totalincome = ptincome + insincome; row[1] = production.ToString("n"); row[2] = adjust.ToString("n"); row[3] = inswriteoff.ToString("n"); row[4] = totalproduction.ToString("n"); row[5] = ptincome.ToString("n"); row[6] = insincome.ToString("n"); row[7] = totalincome.ToString("n"); if (hasAnyAmount) { dtTotal.Rows.Add(row); } } query = report.AddQuery(dtTotal, "Totals", "", SplitByKind.None, 2, true); query.AddColumn("Provider", 75, FieldValueType.String); query.AddColumn("Production", 120, FieldValueType.Number); query.AddColumn("Adjustments", 120, FieldValueType.Number); query.AddColumn("Writeoff", 120, FieldValueType.Number); query.AddColumn("Tot Prod", 120, FieldValueType.Number); query.AddColumn("Pt Income", 120, FieldValueType.Number); query.AddColumn("Ins Income", 120, FieldValueType.Number); query.AddColumn("Total Income", 120, FieldValueType.Number); report.AddPageNum(); // execute query if (!report.SubmitQueries()) //Does not actually submit queries because we use datatables in the central management tool. { return; } if (strFailedConn != "") { MsgBoxCopyPaste msgBoxCP = new MsgBoxCopyPaste(strFailedConn); msgBoxCP.ShowDialog(); } // display the report FormReportComplex FormR = new FormReportComplex(report); FormR.ShowDialog(); DialogResult = DialogResult.OK; }