protected void GetSurveyItems(Object Sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { SurveyDa sDa = new SurveyDa(); DataTable sDt = sDa.GetSurveyItems((int)((DataRowView)e.Item.DataItem)["SurveyId"]); if (sDt != null && sDt.Rows.Count > 0) { Literal Agent = (Literal)e.Item.FindControl("Agent"); Literal Dose = (Literal)e.Item.FindControl("Dose"); Literal PercErection = (Literal)e.Item.FindControl("PercErection"); Literal PrimaryDeformity = (Literal)e.Item.FindControl("PrimaryDeformity"); Literal SecondaryDeformity = (Literal)e.Item.FindControl("SecondaryDeformity"); Literal AssociatedDeformities = (Literal)e.Item.FindControl("AssociatedDeformities"); foreach (DataRow sDr in sDt.Rows) { if (sDr[BOL.SurveyItem.SurveyItem_Field].ToString() == "Agent" && Agent.Text.Length < 1) { Agent.Text = sDr[BOL.SurveyItem.SurveyItemResult].ToString(); } if (sDr[BOL.SurveyItem.SurveyItem_Field].ToString() == "Dose" && Dose.Text.Length < 1) { Dose.Text = sDr[BOL.SurveyItem.SurveyItemResult].ToString(); } if (sDr[BOL.SurveyItem.SurveyItem_Field].ToString() == "% Erection" && PercErection.Text.Length < 1) { PercErection.Text = sDr[BOL.SurveyItem.SurveyItemResult].ToString(); } if (sDr[BOL.SurveyItem.SurveyItem_Field].ToString() == "Primary Deformity" && PrimaryDeformity.Text.Length < 1) { PrimaryDeformity.Text = sDr[BOL.SurveyItem.SurveyItemResult].ToString(); } if (sDr[BOL.SurveyItem.SurveyItem_Field].ToString() == "Secondary Deformity" && SecondaryDeformity.Text.Length < 1) { SecondaryDeformity.Text = sDr[BOL.SurveyItem.SurveyItemResult].ToString(); } if (sDr[BOL.SurveyItem.SurveyItem_Field].ToString() == "Associated Deformities" && AssociatedDeformities.Text.Length < 1) { AssociatedDeformities.Text = sDr[BOL.SurveyItem.SurveyItemResult].ToString(); } } } } }
DataTable GraphSurveys_QOL(int patientId, DateTime baseDate) { MSKProstateQOLSurvey helper = new MSKProstateQOLSurvey(); // we could make GetSurveyTable a property that returns a DataView DataTable _surveyTable = helper.GetSurveys(patientId); //DataView surveyScores = helper.GetScores(_surveyTable); DataView surveyScores = helper.GetScores_Adjusted_ActiveSurvelliance(_surveyTable); DataTable efChartTable = InitChartTable(); DataTable ufChartTable = InitChartTable(); int count = surveyScores.Count; SurveyDa.BaselineScores baseline = SurveyDa.GetPhysicianBaselineScores(patientId, baseDate); for (int i = 0; i < count; i++) { DataRowView row = surveyScores[i]; DateTime surveyDate = (DateTime)row["SurveyDate"]; double yearsSinceBaseDate = (surveyDate - baseDate).Days / DAYS_PER_YEAR; Func <string, int?> getScore = s => row[s] == DBNull.Value ? null : (int?)row[s]; int?efScore = getScore("EF_Score"); int?ufScore = getScore("UF_Score"); if (efScore.HasValue) { AddDataPoint(efChartTable, yearsSinceBaseDate, efScore.Value); } if (ufScore.HasValue) { AddDataPoint(ufChartTable, yearsSinceBaseDate, ufScore.Value); } EFChart.Series["QOL_Scores"].Points.DataBind(efChartTable.DefaultView, "Years", "Score", "Tooltip=Score, Label=Score"); UFChart.Series["QOL_Scores"].Points.DataBind(ufChartTable.DefaultView, "Years", "Score", "Tooltip=Score, Label=Score"); } return(_surveyTable); }
protected virtual void BuildProstateSitesOfDisease() { if (patientID != 0) { SurveyDa sDa = new SurveyDa(); DataSet sDs = sDa.FormGetRecentSurveyByType(this.patientID, this._formName, "Dynamic", "Prostate Sites of Disease"); if (sDs.Tables.Count > 1 && sDs.Tables[1].Rows.Count > 0) { // Bone CheckSiteOfDisease(sDs.Tables[1], "Bone", Bone_Present, Bone_Absent); CheckSiteOfDisease(sDs.Tables[1], "Soft Tissue", SoftTissue_Present, SoftTissue_Absent); CheckSiteOfDisease(sDs.Tables[1], "Lymph Nodes", LymphNodes_Present, LymphNodes_Absent); CheckSiteOfDisease(sDs.Tables[1], "Lung", Lung_Present, Lung_Absent); CheckSiteOfDisease(sDs.Tables[1], "Liver", Liver_Present, Liver_Absent); CheckSiteOfDisease(sDs.Tables[1], "Local Disease", LocalDisease_Present, LocalDisease_Absent); CheckSiteOfDisease(sDs.Tables[1], "Prostatic Mass", LocalDisease_Present, LocalDisease_Absent); } } }
// Kevin todo: Jason please review this section and remove any fields that are no longer used // protected void BuildUrinaryStatusValues() // { // if (patientID != 0) // { // SurveyDa urinaryDa = new SurveyDa(); // Hashtable ht = urinaryDa.FormGetUrinaryStatusValues(this.patientID, this._formName, "Dynamic"); // // // // // if (ht["LastCont"] != null && ht["LastCont"].ToString() != "") // { // LastCont.Text = " " + ht["LastCont"].ToString(); // } // if (ht["ContLv2"] != null && ht["ContLv2"].ToString() != "") // { // ContLv2Textbox.Value = ht["ContLv2"].ToString(); // } // if (ht["ContLv1"] != null && ht["ContLv1"].ToString() != "") // { // ContLv1Textbox.Value = ht["ContLv1"].ToString(); // } // if (ht["LastIncontTx"] != null && ht["LastIncontTx"].ToString() != "") // { // LastIncontTx.Text = ht["LastIncontTx"].ToString(); // } // else // { // LastIncontTxTableRow.Visible = false; // } // if (ht["UrinaryQOL"] != null && ht["UrinaryQOL"].ToString() != "") // { // UrinaryQOL.Text = "<br> " + ht["UrinaryQOL"].ToString(); // } // // // // } // // } protected override void BuildPotencyStatusValues() { if (patientID != 0) { SurveyDa potencyDa = new SurveyDa(); Hashtable ht = potencyDa.FormGetPotencyStatusValues(this.patientID, this._formName, "Dynamic"); if (ht["PreTxPot"] != null && ht["PreTxPot"].ToString() != "") { PreTxPot.Text = ht["PreTxPot"].ToString() + "<br>"; } if (ht["LastPot"] != null && ht["LastPot"].ToString() != "") { LastPot.Text = ht["LastPot"].ToString() + "<br>"; } if (ht["SexualQOL"] != null && ht["SexualQOL"].ToString() != "") { SexualQOL.Text = "<br> " + ht["SexualQOL"].ToString(); } /* * if (ht["PotLv3"] != null && ht["PotLv3"].ToString() != "") * { * potLv3Textbox.Value = ht["PotLv3"].ToString(); * } * if (ht["PotLv2"] != null && ht["PotLv2"].ToString() != "") * { * potLv2Textbox.Value = ht["PotLv2"].ToString(); * } * if (ht["PotLv1"] != null && ht["PotLv1"].ToString() != "") * { * potLv1Textbox.Value = ht["PotLv1"].ToString(); * } */ } }
public CaisisBreastQServices(string datasetSQL) { this.da = new SurveyDa(); this.scoreUtil = new CaisisBreastQEngine(); this.datasetSQL = datasetSQL; }
// build a dynamic datasource for the survey response repeater void GetRecentSurveyReponses(DataTable surveys) { IDictionary <KeyValuePair <string, string>, string> map = SurveyDa.GetSurveyItemResponseMap(MSKProstateQOLSurvey.ShortName); Func <string, string, string, string> getResponse = (text, num, result) => { KeyValuePair <string, string> kvp = new KeyValuePair <string, string>(text, result); KeyValuePair <string, string> numKVP = new KeyValuePair <string, string>(num, result); if (map.ContainsKey(kvp)) { return(map[kvp]); } else if (map.ContainsKey(numKVP)) { return(map[numKVP]); } else { return(result); } }; DataView sv = surveys.DefaultView; sv.Sort = "SurveyDate DESC, SurveyId DESC"; int latestSurveyId = (int)sv[0]["SurveyId"]; var ds = from row in surveys.AsEnumerable() let surveyId = (int)row["SurveyId"] let itemNum = row["SurveyItemNum"].ToString() let text = row["SurveyItem"].ToString() where surveyId == latestSurveyId && !text.StartsWith("Total", StringComparison.CurrentCultureIgnoreCase) && !text.StartsWith("Patient reported", StringComparison.CurrentCultureIgnoreCase) select new { QuestionNum = itemNum, QuestionText = text, QuestionResult = getResponse(text, itemNum, row["SurveyItemResult"].ToString()) }; SurveyResponsesRepeater.DataSource = ds; // handle injection questions var injections = from row in surveys.AsEnumerable() let surveyId = (int)row["SurveyId"] let itemNum = row["SurveyItemNum"].ToString() let text = row["SurveyItem"].ToString() where surveyId == latestSurveyId && (text.Contains("use injections") || text.Contains("used injection")) select new { Num = itemNum, Question = text, Response = row["SurveyItemResult"].ToString() }; bool hadInjection = false; string injectionStatus = null; foreach (var i in injections) { if (i.Question.Contains("Do you use injections") && i.Response == "Yes") { hadInjection = true; } else if (i.Question.Contains("used injection therapy")) { int injectionResponse; if (int.TryParse(i.Response, out injectionResponse)) { injectionStatus = GetInjectionMessage(injectionResponse); } else { injectionStatus = MapInjectionMessage(i.Response); } } } if (hadInjection) { CurrentInjectionStatus.Text = injectionStatus; } }
// analyze post-rp survey data, return raw survey data DataTable AnalyzeSurveys(int patientId, DateTime rpDate) { MSKProstateQOLSurvey helper = new MSKProstateQOLSurvey(); // we could make GetSurveyTable a property that returns a DataView DataTable _surveyTable = helper.GetSurveys(patientId); DataView surveyScores = helper.GetScores(_surveyTable); DataTable efChartTable = InitChartTable(); DataTable ufChartTable = InitChartTable(); int count = surveyScores.Count; SurveyDa.BaselineScores baseline = SurveyDa.GetPhysicianBaselineScores(patientId, rpDate); BaselinePhysicianEFScore.Text = baseline.ErectileFunction.HasValue ? baseline.ErectileFunction.ToString() : "N/A"; BaselinePhysicianUFScore.Text = baseline.UrinaryFunction.HasValue ? baseline.UrinaryFunction.ToString() : "N/A"; bool foundPatientBaseline_EF = false; bool addedPatientBaseline_EF = false; bool foundPatientBaseline_UF = false; bool addedPatientBaseline_UF = false; int patientBaseline_efScore = 0; int patientBaseline_ufScore = 0; int?prevMinUrinaryScore = null; int?prevUrinaryScore = null; for (int i = 0; i < count; i++) { DataRowView row = surveyScores[i]; DateTime surveyDate = (DateTime)row["SurveyDate"]; double monthsSinceRP = (surveyDate - rpDate).Days / DAYS_PER_MONTH; //int roundedMonths = (int) Math.Round(monthsSinceRP, 0); double roundedMonths = monthsSinceRP; bool physicianReported = (bool)row["PhysicianReported"]; // display scores as a fraction Func <int, string, string> frac = (x, f) => x + " / " + row[f]; Func <string, int?> getScore = s => row[s] == DBNull.Value ? null : (int?)row[s]; int?efScore = getScore("EF_Score"); int?ufScore = getScore("UF_Score"); int?qolScore = getScore("GH_Score"); int?bowelScore = getScore("BF_Score"); // add only the most recent pre-rp survey to the chart datasources if (surveyDate <= rpDate) { if (efScore.HasValue) { patientBaseline_efScore = efScore.Value; foundPatientBaseline_EF = true; if (count == 1) { BaselinePatientEFScore.Text = frac(patientBaseline_efScore, "EF_Possible") + " " + GetErectileStatus(patientBaseline_efScore); AddDataPoint(efChartTable, 0, patientBaseline_efScore); } } if (ufScore.HasValue) { patientBaseline_ufScore = ufScore.Value; foundPatientBaseline_UF = true; if (count == 1) { BaselinePatientUFScore.Text = frac(patientBaseline_ufScore, "UF_Possible") + " " + GetUrinaryStatus(patientBaseline_ufScore); AddDataPoint(ufChartTable, 0, patientBaseline_ufScore); } } continue; } else { if (foundPatientBaseline_EF && !addedPatientBaseline_EF) { BaselinePatientEFScore.Text = frac(patientBaseline_efScore, "EF_Possible") + " " + GetErectileStatus(patientBaseline_efScore); AddDataPoint(efChartTable, 0, patientBaseline_efScore); addedPatientBaseline_EF = true; } if (foundPatientBaseline_UF && !addedPatientBaseline_UF) { BaselinePatientUFScore.Text = frac(patientBaseline_ufScore, "UF_Possible") + " " + GetUrinaryStatus(patientBaseline_ufScore); AddDataPoint(ufChartTable, 0, patientBaseline_ufScore); addedPatientBaseline_UF = true; } } if (efScore.HasValue) { AddDataPoint(efChartTable, roundedMonths, efScore.Value); } if (ufScore.HasValue) { AddDataPoint(ufChartTable, roundedMonths, ufScore.Value); } // conditionally build status messages Action <Label, string, Func <int, string>, HtmlContainerControl> status = (l, s, f, bullet) => { object obj = row[s]; if (obj != DBNull.Value) { l.Text = "Current: " + f((int)obj); } else if (bullet != null) { bullet.Visible = false; } }; if (i == count - 1) { // handle current if (efScore.HasValue) { CurrentEFScore.Text = frac(efScore.Value, "EF_Possible") + " " + GetErectileStatus(efScore.Value); } if (ufScore.HasValue) { CurrentUFScore.Text = frac(ufScore.Value, "UF_Possible") + " " + GetUrinaryStatus(ufScore.Value); } if (bowelScore.HasValue) { CurrentBFScore.Text = GetBowelSymptoms(bowelScore.Value); } if (qolScore.HasValue) { CurrentGeneralScore.Text = frac(qolScore.Value, "GH_Possible"); } status(CurrentPenetrationStatus, "PenetrationResponse", GetPenetrationMessage, CurrentPenetrationBullet); status(CurrentPadStatus, "PadResponse", GetPadMessage, PadStatusBullet); } // clear alerts if conditions improve // erectile alerts if (efScore.HasValue) { if (efScore < 22) { erectileAlerts.Add(surveyDate); } else { erectileAlerts.Clear(); } } // urinary alerts // handle max urinary score if (ufScore.HasValue) { if (i > 0 && prevMinUrinaryScore.HasValue) { if ((monthsSinceRP > 12 && ufScore <= prevMinUrinaryScore.Value - 3) || (monthsSinceRP <= 12 && ufScore < prevMinUrinaryScore.Value)) { urinaryDeclineAlerts.Add(surveyDate); } else if (prevUrinaryScore.HasValue && ufScore > prevUrinaryScore) { urinaryDeclineAlerts.Clear(); } } if (!prevMinUrinaryScore.HasValue || ufScore < prevMinUrinaryScore.Value) { prevMinUrinaryScore = ufScore; } prevUrinaryScore = ufScore; } // qol alerts if (qolScore.HasValue) { if (qolScore < 6) { qolAlerts.Add(surveyDate); } else { qolAlerts.Clear(); } } // pad alerts object padObj = row["PadResponse"]; if (padObj != DBNull.Value && surveyDate > rpDate.AddYears(1)) { if (3 <= (int)padObj) { padAlerts.Add(surveyDate); } else { padAlerts.Clear(); } } // bowel alerts object bowelHabitObj = row["HabitResponse"]; object bowelEnjoymentObj = row["EnjoymentResponse"]; if ((bowelHabitObj != DBNull.Value && 3 <= (int)bowelHabitObj) || (bowelEnjoymentObj != DBNull.Value && 3 <= (int)bowelEnjoymentObj)) { bowelAlerts.Add(surveyDate); } else if (bowelHabitObj != DBNull.Value && bowelEnjoymentObj != DBNull.Value && 2 >= (int)bowelHabitObj && 2 >= (int)bowelEnjoymentObj) { bowelAlerts.Clear(); } } UFChart.DataSource = ufChartTable; EFChart.DataSource = efChartTable; /* * List<int> months = new List<int>() { 0, 3, 6, 9, 12, 15, 18, 21, 24, 36, 48 }; * var ranges = GenerateRanges(months); * * DataTable ufTableFiltered = FilterChartDataPoints(ufChartTable, ranges); * DataTable efTableFiltered = FilterChartDataPoints(efChartTable, ranges); * * UFChart.DataSource = ufTableFiltered; * EFChart.DataSource = efTableFiltered; * * showUrinaryChart = ufTableFiltered.Rows.Count > 1; * showErectileChart = efTableFiltered.Rows.Count > 1; */ showUrinaryChart = ufChartTable.Rows.Count > 1; showErectileChart = efChartTable.Rows.Count > 1; return(_surveyTable); }
private DataView GetBreastQReport(string surveyGroup, string subType) { // validate type map if (!typesToSurveys.ContainsKey(surveyGroup)) { return(new DataTable().DefaultView); } IEnumerable <string> surveyTypes = typesToSurveys[surveyGroup]; Caisis.Controller.PatientController pc = new Controller.PatientController(); string datasetSQL = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]); CaisisBreastQEngine engine = new CaisisBreastQEngine(); SurveyDa surveyDA = new SurveyDa(); List <Dictionary <string, string> > allScores = new List <Dictionary <string, string> >(); var aliasMap = GetAliasToSurveys(); foreach (string surveyType in surveyTypes) { var survey = engine.GetSurveyDefinition(surveyType); var scales = survey.Definitions; string[] questions = scales.SelectMany(s => s.Questions).Distinct().ToArray(); string[] _surveyTypes = new string[] { surveyType }; // special case if (aliasMap.ContainsKey(surveyType)) { _surveyTypes = aliasMap[surveyType].ToArray(); } foreach (string _surveyType in _surveyTypes) { // optional filter by exact survey if (string.IsNullOrEmpty(subType) || subType.Equals(_surveyType, StringComparison.OrdinalIgnoreCase)) { string engineSurveyType = surveyType; // TODO: refactor into generic class to read and fill scores data table // read pivotted row (patient+survey+questions), and score surveyDA.ConsumeBreastQSurveyData(datasetSQL, _surveyType, questions, (record) => { // get responses, 1a=>2, 1b=>2, ... Dictionary <string, string> responses = questions.ToDictionary(q => q, q => record[q].ToString()); // get scores by scale, Satisfaction With Breasts => 56, ... Dictionary <string, BreastQ.BreastQScaleScore> scores = engine.GetSurveyScoreByScale(engineSurveyType, responses); // create column values Dictionary <string, string> values = new Dictionary <string, string>(); // add required columns values.Add("MRN", pc.GetPatientMRN(record["PtMRN"].ToString())); values.Add("Survey", _surveyType); values.Add("Date", string.Format("{0:d}", record["SurveyDate"])); // fill in scale scores foreach (var score in scores) { string scaleName = score.Key; string scaleValue = ""; // valida score if (score.Value.Error == QScoreLibrary.Estimation.eErrors.eNoError) { scaleValue = score.Value.Score.ToString(); } // error in scoring else { scaleValue = "FAIL: " + engine.GetQScoreErrorString(score.Value.Error); } //values.Add(score.Key, score.Value.Score.ToString()); values.Add(scaleName, scaleValue); } // add row allScores.Add(values); // continue return(true); }); } } } // get a list of columns across patients (i.e., PtMRN, Date, Scale 1, Scale 3, Scale 7) string[] columns = allScores.SelectMany(s => s.Keys).Distinct().ToArray(); string[] patientColumns = new string[] { "MRN", "Survey", "Date" }; string[] scaleColumns = columns.Except(patientColumns).ToArray(); // normalize datasource DataTable dataSource = new DataTable(); dataSource.Columns.AddRange(columns.Select(c => new DataColumn(c, typeof(String))).ToArray()); // for each row, normalize values foreach (var row in allScores) { object[] values = new object[columns.Length]; for (int i = 0; i < columns.Length; i++) { string column = columns[i]; // add patient columns if (patientColumns.Contains(column)) { values[i] = row[column]; } else if (scaleColumns.Contains(column)) { // applicable scale if (row.ContainsKey(column)) { values[i] = row[column]; } // non-applicable scale else { values[i] = "N/A"; } } } dataSource.Rows.Add(values); } return(dataSource.DefaultView); }
protected void BuildErectileFunction(int minNumRowsToShow, int minNumBlankRows) { if (patientID != 0) { SurveyDa sDa = new SurveyDa(); DataSet sDs = sDa.FormGetSurveyErectileFunction(this.patientID); if (sDs != null && sDs.Tables.Count > 0 && sDs.Tables[0].Rows.Count > 0) { // fill in blank rows for medications when they are not populated only because the prescription hasn't changed for (int j = 1; j < sDs.Tables[0].Rows.Count; j++) { try { // oral meds if (sDs.Tables[0].Rows[j]["Oral Agent"] != null && sDs.Tables[0].Rows[j]["Oral Agent"].ToString().Length < 1 && sDs.Tables[0].Rows[j]["Oral Dose"].ToString().Length < 1 && sDs.Tables[0].Rows[j]["Date"].ToString().Length > 1 && sDs.Tables[0].Rows[j - 1]["Date"].ToString().Length > 1 && sDs.Tables[0].Rows[j - 1]["Oral Agent"].ToString().Length > 0 && (sDs.Tables[0].Rows[j - 1]["Oral Agent Stop Date"].ToString().Length <1 || Convert.ToDateTime(sDs.Tables[0].Rows[j - 1]["Oral Agent Stop Date"].ToString())> DateTime.Now || Convert.ToDateTime(sDs.Tables[0].Rows[j - 1]["Oral Agent Stop Date"].ToString()) > Convert.ToDateTime(sDs.Tables[0].Rows[j]["Date"].ToString())) ) { sDs.Tables[0].Rows[j]["Oral Agent"] = sDs.Tables[0].Rows[j - 1]["Oral Agent"]; sDs.Tables[0].Rows[j]["Oral Dose"] = sDs.Tables[0].Rows[j - 1]["Oral Dose"]; sDs.Tables[0].Rows[j]["Oral Agent Stop Date"] = sDs.Tables[0].Rows[j - 1]["Oral Agent Stop Date"]; } } catch { } try { // ICI meds if (sDs.Tables[0].Rows[j]["ICI Agent"] != null && sDs.Tables[0].Rows[j]["ICI Agent"].ToString().Length < 1 && sDs.Tables[0].Rows[j]["ICI Dose"].ToString().Length < 1 && sDs.Tables[0].Rows[j]["Date"].ToString().Length > 1 && sDs.Tables[0].Rows[j - 1]["Date"].ToString().Length > 1 && sDs.Tables[0].Rows[j - 1]["ICI Agent"].ToString().Length > 0 && (sDs.Tables[0].Rows[j - 1]["ICI Stop Date"].ToString().Length <1 || Convert.ToDateTime(sDs.Tables[0].Rows[j - 1]["ICI Stop Date"].ToString())> DateTime.Now || Convert.ToDateTime(sDs.Tables[0].Rows[j - 1]["ICI Stop Date"].ToString()) > Convert.ToDateTime(sDs.Tables[0].Rows[j]["Date"].ToString())) ) { sDs.Tables[0].Rows[j]["ICI Agent"] = sDs.Tables[0].Rows[j - 1]["ICI Agent"]; sDs.Tables[0].Rows[j]["ICI Dose"] = sDs.Tables[0].Rows[j - 1]["ICI Dose"]; sDs.Tables[0].Rows[j]["ICI Stop Date"] = sDs.Tables[0].Rows[j - 1]["ICI Stop Date"]; } } catch { } } // original way int numBlankRows = minNumRowsToShow - sDs.Tables[0].Rows.Count; if (numBlankRows < minNumBlankRows) { numBlankRows = minNumBlankRows; } for (int i = 0; i < numBlankRows; i++) { DataRow blankRow = sDs.Tables[0].NewRow(); sDs.Tables[0].Rows.Add(blankRow); } erectileFunction.DataSource = sDs.Tables[0].DefaultView; /* with filter * DataView sDv = sDs.Tables[0].DefaultView; * string filterExpression = "(Len([Duration Post TX]) > 0) OR (Len([Spontaneous Erectile Function %]) > 0)"; * sDv.RowFilter = filterExpression; * * DataTable newDt = sDv.ToTable(); * * * * int numBlankRows = minNumRowsToShow - newDt.Rows.Count; * * if (numBlankRows < minNumBlankRows) * { * numBlankRows = minNumBlankRows; * } * * for (int i = 0; i < numBlankRows; i++) * { * DataRow blankRow = newDt.NewRow(); * newDt.Rows.Add(blankRow); * } * erectileFunction.DataSource = newDt.DefaultView; */ } else { erectileFunction.DataSource = BlankErectileFunction(minNumRowsToShow).DefaultView; } } else { erectileFunction.DataSource = BlankErectileFunction(minNumRowsToShow).DefaultView; } try { erectileFunction.DataBind(); } catch { erectileFunction.DataSource = BlankErectileFunction(minNumRowsToShow).DefaultView; erectileFunction.DataBind(); } }