override protected void BuildLabTests() { if (patientID != 0) { string[] labTestsToGet = new string[] { "PSA", "CTC" }; LabTestDa da = new LabTestDa(); DataSet labTestsDs = da.GetLabTestsbyList(this.patientID, labTestsToGet); if (labTestsDs.Tables.Count > 0 && labTestsDs.Tables[0].Rows.Count > 0) { DataView dv = new DataView(labTestsDs.Tables[0]); dv.RowFilter = BOL.LabTest.LabDate + " IS NOT NULL and " + BOL.LabTest.LabDate + " >= #" + DateTime.Now.AddYears(-1).ToShortDateString() + "#"; dv.Sort = BOL.LabTest.LabTest_Field + " DESC, " + BOL.LabTest.LabDate + " DESC"; if (dv.Count > 0) { if (dv.Count > (NumLabsRowsAllowed * 2)) { NumLabsRowsAllowed = (int)(Math.Ceiling((decimal)(dv.Count / 2))) + 1; } labTests.DataSource = dv; labTests.DataBind(); } } } }
override protected void BuildLabTestsKidney(DateTime NephrectomyDate) { if (patientID != 0) { LabTestDa da = new LabTestDa(); string[] l = { "CREAT" }; DataSet ds = da.GetLabTestsbyList(this.patientID, l); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; // dt.Columns.Add("LastBeforeNeph", typeof(Boolean)); DataColumn LastBeforeNeph = new DataColumn(); LastBeforeNeph.ColumnName = "LastBeforeNeph"; LastBeforeNeph.DataType = System.Type.GetType("System.Boolean"); LastBeforeNeph.DefaultValue = false; dt.Columns.Add(LastBeforeNeph); // highlight pre-op creat if (NephrectomyDate != null && NephrectomyDate != DateTime.MinValue) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][BOL.LabTest.LabDate] != null && dt.Rows[i][BOL.LabTest.LabDate].ToString().Length > 0 && (DateTime)dt.Rows[i][BOL.LabTest.LabDate] <= NephrectomyDate) { if ((i == (dt.Rows.Count - 1)) || (DateTime)dt.Rows[i + 1][BOL.LabTest.LabDate] > NephrectomyDate || (DateTime)dt.Rows[i][BOL.LabTest.LabDate] == NephrectomyDate) { dt.Rows[i]["LastBeforeNeph"] = true; //DataRow moveRow = dt.Rows[i]; //DataRow newRow = dt.NewRow(); //newRow.ItemArray = moveRow.ItemArray; //dt.Rows.Remove(moveRow); //dt.Rows.InsertAt(newRow, 0); //break; } } } } DataView labDv = new DataView(dt); labDv.RowFilter = "(" + BOL.LabTest.LabDate + " > #" + DateTime.Today.AddYears(-1) + "# AND " + BOL.LabTest.LabDate + " >= #" + NephrectomyDate.ToShortDateString() + "#) OR LastBeforeNeph = true"; if (labDv.Count > 0) { DataView labRptDv = KidneyLabsWithGFR(this.patientID, labDv); labTests.DataSource = labRptDv; labTests.DataBind(); LabTestBlankRows.Visible = false; } } } }
private DataSet GetLabTestDataSet(int PatientID) { string[] labs = new string[] { "TSH", "FREET4", "THYRO", "CA", "CALCIT", "CEA", "RET Oncogene" }; LabTestDa da = new LabTestDa(); return(da.GetLabTestsbyList(PatientID, labs)); }
protected void BuildLabTestsKidney(DateTime NephrectomyDate) { LabTestDa da = new LabTestDa(); string[] l = { "CREAT" }; DataSet ds = da.GetLabTestsbyList(this._patientId, l); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; DataColumn LastBeforeNeph = new DataColumn(); LastBeforeNeph.ColumnName = "LastBeforeNeph"; LastBeforeNeph.DataType = System.Type.GetType("System.Boolean"); LastBeforeNeph.DefaultValue = false; dt.Columns.Add(LastBeforeNeph); // highlight pre-op creat if (NephrectomyDate != null && NephrectomyDate != DateTime.MinValue) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][BOL.LabTest.LabDate] != null && dt.Rows[i][BOL.LabTest.LabDate].ToString().Length > 0 && (DateTime)dt.Rows[i][BOL.LabTest.LabDate] <= NephrectomyDate) { if ((i == (dt.Rows.Count - 1)) || (DateTime)dt.Rows[i + 1][BOL.LabTest.LabDate] > NephrectomyDate || (DateTime)dt.Rows[i][BOL.LabTest.LabDate] == NephrectomyDate) { dt.Rows[i]["LastBeforeNeph"] = true; } } } } DataView labDv = new DataView(dt); labDv.RowFilter = "(" + BOL.LabTest.LabDate + " > #" + DateTime.Today.AddMonths(-3) + "# AND " + BOL.LabTest.LabDate + " >= #" + NephrectomyDate.ToShortDateString() + "#) OR LastBeforeNeph = true"; if (labDv.Count > 0) { DataView labRptDv = KidneyLabsWithGFR(this._patientId, labDv); labTests.DataSource = labRptDv; labTests.DataBind(); } } }
// complex table version override protected void BuildLabTests(int minNumLabTestRowsToShow, int minNumBlankLabTestRows) { if (patientID != 0) { string[] labTestsToGet = new string[] { "PSA", "CREAT" }; LabTestDa da = new LabTestDa(); DataSet labTestsDs = da.GetLabTestsbyList(this.patientID, labTestsToGet); if (labTestsDs.Tables.Count > 0 && labTestsDs.Tables[0].Rows.Count > 0) { int numBlankLabTestRows = minNumLabTestRowsToShow - labTestsDs.Tables[0].Rows.Count; if (numBlankLabTestRows < minNumBlankLabTestRows) { numBlankLabTestRows = minNumBlankLabTestRows; } for (int i = 0; i < numBlankLabTestRows; i++) { DataRow blankLabTestsRow; blankLabTestsRow = labTestsDs.Tables[0].NewRow(); blankLabTestsRow["LabDateText"] = "/ /"; labTestsDs.Tables[0].Rows.Add(blankLabTestsRow); } labTests.DataSource = LabsWithGFR(this.patientID, labTestsDs.Tables[0].DefaultView); } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } labTests.DataBind(); }
protected void BuildLabTests() { string[] labTestsToGet = new string[] { "PSA", "Prolaris Score", "Prolaris AUA", "Oncotype GPS", "Oncotype Path", "PCA3", "UPCA3", "UPCA3S", "PHI", "4K" }; //Lab Tests LabTestDa da = new LabTestDa(); DataSet labTestsDs = da.GetLabTestsbyList(this._patientId, labTestsToGet); DataTable allLabs = labTestsDs.Tables[0]; DataTable labsToDisplay = ASLabsTable(labTestsToGet, allLabs); DataView sortedLabView = new DataView(labsToDisplay); sortedLabView.Sort = LabTest.LabDate + " ASC"; DataTable sortedLabs = sortedLabView.ToTable(); labTests.DataSource = sortedLabs.DefaultView; labTests.DataBind(); }
private DataSet GetLabTestDataSet(int PatientID) { LabTestDa da = new LabTestDa(); return(da.GetLabTestsbyList(PatientID, labTests)); }
protected void BuildLabTestsKidney(DateTime NephrectomyDate) { LabTestDa da = new LabTestDa(); string[] l = { "CREAT" }; DataSet ds = da.GetLabTestsbyList(this.patientID, l); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; DataColumn LastBeforeNeph = new DataColumn(); LastBeforeNeph.ColumnName = "LastBeforeNeph"; LastBeforeNeph.DataType = System.Type.GetType("System.Boolean"); LastBeforeNeph.DefaultValue = false; dt.Columns.Add(LastBeforeNeph); // highlight pre-op creat if (NephrectomyDate != null && NephrectomyDate != DateTime.MinValue) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][BOL.LabTest.LabDate] != null && (DateTime)dt.Rows[i][BOL.LabTest.LabDate] <= NephrectomyDate) { if ((i == (dt.Rows.Count - 1)) || (DateTime)dt.Rows[i + 1][BOL.LabTest.LabDate] > NephrectomyDate || (DateTime)dt.Rows[i][BOL.LabTest.LabDate] == NephrectomyDate) { dt.Rows[i]["LastBeforeNeph"] = true; } } } } if (dt.Rows.Count > 0) { DataView labDv = new DataView(dt); DataView labRptDv = KidneyLabsWithGFR(this.patientID, labDv); labTests.DataSource = labRptDv; labTests.DataBind(); NoLabsMsg.Visible = false; GFRChart.Visible = true; var graphtable = labRptDv.ToTable(false, "GFR", "LabDateText", "LabDate", "LabResult"); graphtable.Columns.Add("MonthsSinceSurgery"); foreach (DataRow dr in graphtable.Rows) // iterate through each date { if (!string.IsNullOrEmpty(dr[BOL.LabTest.LabDate].ToString())) { dr["MonthsSinceSurgery"] = MonthsSinceLastSurgery((DateTime)dr[BOL.LabTest.LabDate]); } } var series = BuildSeries(GFRChart, "GFR"); if (LastSurgeryDate > DateTime.MinValue) { series.Points.DataBind(graphtable.DefaultView, "MonthsSinceSurgery", "GFR", ""); GFRChart.ChartAreas[0].AxisX.Title = "Months Since Surgery"; GFRChart.ChartAreas[0].AxisX.Minimum = 0; GFRChart.ChartAreas[0].AxisX.LabelStyle.Angle = 0; } else { series.XValueType = ChartValueType.DateTime; series.Points.DataBind(graphtable.DefaultView, "LabDateText", "GFR", ""); GFRChart.ChartAreas[0].AxisX.Title = "Date"; GFRChart.ChartAreas[0].AxisX.LabelStyle.Angle = 45; // GFRChart.ChartAreas[0].AxisX.Minimum = 0; //series.Points.DataBind(points, "SurveyDateText", "SurveyScore", ""); //chart.ChartAreas[0].AxisY.Minimum = YAxisMin[currentSurvey]; //chart.ChartAreas[0].AxisY.Maximum = YAxisMax[currentSurvey]; //chart.ChartAreas[0].AxisY.Interval = (chart.ChartAreas[0].AxisY.Maximum <= 10) ? 1 : ((chart.ChartAreas[0].AxisY.Maximum <= 30) ? 5 : 10); //if (YAxisCustomLabel[currentSurvey].Length > 0) chart.ChartAreas[0].AxisY.Title = YAxisCustomLabel[currentSurvey]; } GFRChart.ChartAreas[0].AxisX.LineWidth = 1; List <int> HLines = new List <int>(new int[] { 15, 45, 60, 90 }); foreach (int i in HLines) { StripLine s1 = new StripLine(); s1.StripWidth = 0; s1.BorderColor = Color.Gray; s1.BorderWidth = 1; s1.BorderDashStyle = ChartDashStyle.Dash; s1.Interval = 0; s1.IntervalOffset = i; s1.Text = i.ToString(); s1.TextAlignment = StringAlignment.Far; GFRChart.ChartAreas[0].AxisY.StripLines.Add(s1); } GFRChart.Titles[0].Visible = false; } } }
protected DataTable ASLabsTable(string[] labTestsToGet, int?PatientId) { // data table structure DataTable labsTable = new DataTable(); DataColumn DateTextCol = new DataColumn(); DateTextCol.ColumnName = "LabDateText"; labsTable.Columns.Add(DateTextCol); DataColumn DateCol = new DataColumn(); DateCol.ColumnName = "LabDate"; DateCol.DataType = System.Type.GetType("System.DateTime"); labsTable.Columns.Add(DateCol); DataColumn PSADT = new DataColumn(); PSADT.ColumnName = "PSADT"; labsTable.Columns.Add(PSADT); foreach (string lab in labTestsToGet) { DataColumn col = new DataColumn(); col.ColumnName = lab; labsTable.Columns.Add(col); DataColumn IDCol = new DataColumn(); IDCol.ColumnName = (lab + "Id"); IDCol.DataType = System.Type.GetType("System.Int32"); labsTable.Columns.Add(IDCol); } if (PatientId != null) { int pId = PatientId ?? default(int); LabTestDa da = new LabTestDa(); DataSet labTestsDs = da.GetLabTestsbyList(pId, labTestsToGet); DataTable allLabs = labTestsDs.Tables[0]; // table rows if (allLabs != null) { foreach (DataRow row in allLabs.Rows) { string LabDateText = row[BOL.LabTest.LabDateText].ToString(); DateTime LabDate = new DateTime(); if (row[BOL.LabTest.LabDate].ToString().Length > 0) { LabDate = (DateTime)row[BOL.LabTest.LabDate]; } string LabType = row[BOL.LabTest.LabTest_Field].ToString(); string LabResult = row[BOL.LabTest.LabResult].ToString(); string LabNotes = row[BOL.LabTest.LabNotes].ToString(); int LabTestId = (int)row[BOL.LabTest.LabTestId]; DataRow[] currentDateRow = labsTable.Select("LabDateText = '" + LabDateText + "'"); if (currentDateRow.Length > 0) { currentDateRow[0][LabType] = LabResult; currentDateRow[0][LabType + "Id"] = LabTestId; // special cases if (LabType.ToUpper().Equals("PROLARIS SCORE")) { currentDateRow[0]["Prolaris AUA"] = LabNotes; } if (LabType.ToUpper().Equals("ONCOTYPE GPS")) { currentDateRow[0]["Oncotype Path"] = LabNotes; } } else { DataRow dr = labsTable.NewRow(); dr["LabDateText"] = LabDateText; dr["LabDate"] = LabDate; dr[LabType] = LabResult; dr[LabType + "Id"] = LabTestId; // special cases if (LabType.ToUpper().Equals("PROLARIS SCORE")) { dr["Prolaris AUA"] = LabNotes; } if (LabType.ToUpper().Equals("ONCOTYPE GPS")) { dr["Oncotype Path"] = LabNotes; } labsTable.Rows.Add(dr); } } if (labsTable.Rows.Count > 0) { DataView sortedLabView = new DataView(labsTable); sortedLabView.Sort = LabTest.LabDate + " ASC"; labsTable = sortedLabView.ToTable(); // get prostate volumes to calculate PSADensity in lab tests DataTable ProstateVolumes = ProstateVolumesByDescendingDate(pId); if (ProstateVolumes.Rows.Count > 0) { foreach (DataRow labRow in labsTable.Rows) { double psa = 0; if (labRow["LabDate"].ToString().Length > 0 && labRow["PSA"].ToString().Length > 0 && double.TryParse(labRow["PSA"].ToString(), out psa)) { DataView v = new DataView(ProstateVolumes); v.RowFilter = Diagnostic.DxDate + " <= #" + ((DateTime)labRow["LabDate"]).ToShortDateString() + "#"; if (v.Count > 0) { double mostRecentVolumeMeasurement = 0; if (double.TryParse(v[0][ImageProstate.ImgProstateVolume].ToString(), out mostRecentVolumeMeasurement)) { double psadt = Math.Round((psa / mostRecentVolumeMeasurement), 4); labRow["PSADT"] = psadt; } } } } } } } } return(labsTable); }
private DataTable FilteredLabs(int PatientID) { DataTable labs = new DataTable(); string[] labTestsToGet = new string[] { "PSA", "FPSA", "PCA3", "UPCA3", "UPCA3S" }; LabTestDa da = new LabTestDa(); DataSet labTestsDs = da.GetLabTestsbyList(PatientID, labTestsToGet); if (labTestsDs.Tables.Count > 0 && labTestsDs.Tables[0].Rows.Count > 0) { DataTable allLabs = labTestsDs.Tables[0]; DataTable labsToDisplay = allLabs.Clone(); // get last 3 PSAs DataView PSAs = new DataView(allLabs); PSAs.RowFilter = LabTest.LabTest_Field + " = 'PSA'"; PSAs.Sort = LabTest.LabDate + " DESC"; int maxPSAs = 3; if (PSAs.Count > maxPSAs) { for (int i = 0; i < maxPSAs; i++) { labsToDisplay.ImportRow(PSAs[i].Row); } } else { labsToDisplay.Merge(PSAs.ToTable()); } // get last 3 FPSAs DataView FPSAs = new DataView(allLabs); FPSAs.RowFilter = LabTest.LabTest_Field + " = 'FPSA'"; FPSAs.Sort = LabTest.LabDate + " DESC"; int maxFPSAs = 3; if (FPSAs.Count > maxFPSAs) { for (int i = 0; i < maxFPSAs; i++) { labsToDisplay.ImportRow(FPSAs[i].Row); } } else { labsToDisplay.Merge(FPSAs.ToTable()); } // get all PCA3 DataView PCA3s = new DataView(allLabs); PCA3s.RowFilter = LabTest.LabTest_Field + " IN ('PCA3', 'UPCA3', 'UPCA3S')"; if (PCA3s.Count > 0) { labsToDisplay.Merge(PCA3s.ToTable()); } if (labsToDisplay.Rows.Count > 0) { DataView sortedLabView = new DataView(labsToDisplay); sortedLabView.Sort = LabTest.LabDate + " ASC"; labs = sortedLabView.ToTable(); } } return(labs); }
protected void ShowDxBiopsy(int DxBiopsyId) { populatedDiagnosisTable.Visible = true; NewDiagnosisTable.Visible = false; BusinessObject biz = BusinessObjectFactory.BuildBusinessObject("Procedures"); biz.Get(DxBiopsyId); DxDateLabel.Text = biz[BOL.Procedure.ProcDateText].ToString(); // PreTx PSA --------------------------- if (biz[BOL.Procedure.ProcDate].ToString().Length > 0) { LabTestDa da = new LabTestDa(); string[] l = { "PSA" }; DataSet ds = da.GetLabTestsbyList(this._patientId, l); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataView preTxPSAs = new DataView(ds.Tables[0]); preTxPSAs.RowFilter = BOL.LabTest.LabDate + " <= #" + (DateTime)biz[BOL.Procedure.ProcDate] + "#"; if (preTxPSAs.Count > 0) { preTxPSAs.Sort = BOL.LabTest.LabDate + " DESC"; PreBxTxPSA.Text = preTxPSAs[0][BOL.LabTest.LabResult].ToString() + preTxPSAs[0][BOL.LabTest.LabUnits].ToString() + " (" + (preTxPSAs[0][BOL.LabTest.LabDateText].ToString() + ")"); } } } // Path data for Biopsy --------------------------- DataView dv = BOL.BusinessObject.GetByFieldsAsDataView <BOL.Pathology>(new Dictionary <string, object> { { BOL.Pathology.ProcedureId, DxBiopsyId } }); dv.Sort = BOL.Pathology.PathDate + " DESC"; if (dv.Count > 0) { // DxDateLabel.Text = dv[0][BOL.Pathology.PathDateText].ToString(); int pathId = (int)dv[0][BOL.Pathology.PathologyId]; populatedDiagnosisTable.Attributes.Add("onclick", "LoadDataEntryForm('Pathology', '" + pathId.ToString() + "', '', '','ProstateBiopsyPath,PathologyStageGrade')"); // Prostate Biopsy Path DataView dv2 = BOL.BusinessObject.GetByParentAsDataView <BOL.BiopsyProstatePathology>(pathId); if (dv2.Count > 0) { PathGG1Label.Text = dv2[0][BOL.BiopsyProstatePathology.PathGG1].ToString(); PathGG2Label.Text = dv2[0][BOL.BiopsyProstatePathology.PathGG2].ToString(); PathGGSLabel.Text = dv2[0][BOL.BiopsyProstatePathology.PathGGS].ToString(); DiagnosisPositiveCoresLabel.Text = dv2[0][BOL.BiopsyProstatePathology.PathPosCores].ToString(); int posCores; int totCores; if (int.TryParse(dv2[0][BOL.BiopsyProstatePathology.PathPosCores].ToString(), out posCores) && int.TryParse(dv2[0][BOL.BiopsyProstatePathology.PathNumCores].ToString(), out totCores)) { int negCores = totCores - posCores; DiagnosisNegativeCoresLabel.Text = negCores.ToString(); } } // Prostate Biopsy Path DataView dv3 = BOL.BusinessObject.GetByParentAsDataView <BOL.PathologyStageGrade>(pathId); if (dv3.Count > 0) { DiagnosisUICC2002TStageLabel.Text = dv3[0][BOL.PathologyStageGrade.PathStageT].ToString(); DiagnosisUICC2002NStageLabel.Text = dv3[0][BOL.PathologyStageGrade.PathStageN].ToString(); DiagnosisUICC2002MStageLabel.Text = dv3[0][BOL.PathologyStageGrade.PathStageM].ToString(); } } }
//override protected void BuildLabTests() //{ // if (patientID != 0) // { // LabTestDa da = new LabTestDa(); // DataSet ds = da.FormGetRecords(this.patientID, this._formName, "Dynamic"); // if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) // { // labTestsBlankTable.Visible = false; // labTests.DataSource = ds.Tables[0].DefaultView; // labTests.DataBind(); // } // else // { // labTestsPopulatedTable.Visible = false; // } // } // else // { // labTestsPopulatedTable.Visible = false; // } //} // override base version, no longer use old stored proc override protected void BuildLabTests() { if (patientID != 0) { //Lab Tests LabTestDa da = new LabTestDa(); // old version DataSet labTestsDs = da.FormGetRecords(this.patientID, this._formName, "Dynamic"); string[] l = { "PSA", "FPSA", "AFP", "HCG", "HCGN", "LDH" }; DataSet labTestsDs = da.GetLabTestsbyList(this.patientID, l); if (labTestsDs.Tables.Count > 0) { DataTable LastXOfEach = labTestsDs.Tables[0].Clone(); int countPerLabTest = 3; // number of each type of lab test to show foreach (string labTest in l) { DataView dv = new DataView(labTestsDs.Tables[0]); string labFilter = BOL.LabTest.LabTest_Field + " = '" + labTest + "'"; dv.RowFilter = labFilter; dv.Sort = BOL.LabTest.LabDate + " DESC"; if (dv.Count > 0) { DataTable t = dv.ToTable(); int lastI = (t.Rows.Count >= countPerLabTest) ? countPerLabTest : t.Rows.Count; for (int i = 0; i < lastI; i++) { LastXOfEach.ImportRow(t.Rows[i]); } } } if (LastXOfEach.Rows.Count > 0) { DataView SortedLabsView = new DataView(LastXOfEach); SortedLabsView.Sort = BOL.LabTest.LabDate + " DESC"; DataTable SortedLabs = SortedLabsView.ToTable(); labTests.DataSource = SortedLabs.DefaultView; labTestsBlankTable.Visible = false; labTests.DataSource = SortedLabs.DefaultView; labTests.DataBind(); } else { labTestsPopulatedTable.Visible = false; } } else { labTestsPopulatedTable.Visible = false; } } else { labTestsPopulatedTable.Visible = false; } }
protected void BuildHypogonadism() { DataTable HypogonadismTable = this.HypogonadismTable(); // Lab Tests LabTestDa lDa = new LabTestDa(); List <List <string> > HypogonadismLabs = HypogonadismLabKey(); List <string> HypogonadismLabValues = new List <string>(); foreach (List <string> l in HypogonadismLabs) { HypogonadismLabValues.AddRange(l); } DataSet lDs = lDa.GetLabTestsbyList(this._patientId, HypogonadismLabValues.ToArray()); if (lDs != null && lDs.Tables.Count > 0 && lDs.Tables[0].Rows.Count > 0) { foreach (DataRow hRow in lDs.Tables[0].Rows) { foreach (List <string> l in HypogonadismLabs) { // if (hRow[BOL.LabTest.LabTest_Field].ToString().ToUpper() == l[0].ToUpper()) if (l.Contains(hRow[BOL.LabTest.LabTest_Field].ToString().ToUpper())) { HypogonadismTable = AddValueToHypogonadismTable(HypogonadismTable, hRow[BOL.LabTest.LabDateText].ToString(), l[0], hRow[BOL.LabTest.LabResult].ToString(), (int)hRow[BOL.LabTest.LabTestId]); break; } } } } // Medications MedicationDa mDa = new MedicationDa(); List <string> HypogonadismMedications = HypogonadismMedicationKey(); DataSet mDs = mDa.FormGetRecords(this._patientId, "", "Dynamic", ""); if (mDs != null && mDs.Tables.Count > 0 && mDs.Tables[0].Rows.Count > 0) { foreach (DataRow mRow in mDs.Tables[0].Rows) { foreach (string m in HypogonadismMedications) { if (mRow[BOL.Medication.Medication_Field].ToString().ToUpper() == m.ToUpper()) { string medValue = mRow[BOL.Medication.Medication_Field].ToString(); // if (mRow[BOL.Medication.MedDose].ToString().Length > 0) medValue += (" (" + mRow[BOL.Medication.MedDose].ToString() + mRow[BOL.Medication.MedUnits].ToString() + ")"); HypogonadismTable = AddValueToHypogonadismTable(HypogonadismTable, mRow[BOL.Medication.MedDateText].ToString(), "Medication", medValue, (int)mRow[BOL.Medication.MedicationId]); HypogonadismTable = AddValueToHypogonadismTable(HypogonadismTable, mRow[BOL.Medication.MedDateText].ToString(), "MedDose", mRow[BOL.Medication.MedDose].ToString()); HypogonadismTable = AddValueToHypogonadismTable(HypogonadismTable, mRow[BOL.Medication.MedDateText].ToString(), "MedUnits", mRow[BOL.Medication.MedUnits].ToString()); break; } } } } if (HypogonadismTable.Rows.Count > 0) { foreach (DataRow hRow in HypogonadismTable.Rows) { if (hRow["DateText"].ToString().Length > 0) { DateTime dt; if (DateTime.TryParse(hRow["DateText"].ToString(), out dt)) { hRow["Date"] = dt; } } } int maxRowsToShowOnForm = 8; if (HypogonadismTable.Rows.Count > maxRowsToShowOnForm) { int numRecordsToDelete = HypogonadismTable.Rows.Count - maxRowsToShowOnForm; DataView hgv = HypogonadismTable.DefaultView; hgv.Sort = "Date ASC"; DataTable hgt = hgv.ToTable(); for (int i = 0; i < numRecordsToDelete; i++) { hgt.Rows[0].Delete(); } DataView hgv2 = hgt.DefaultView; hgv2.Sort = "Date ASC"; FillHypogonadism(hgv2); } else { DataView hv = HypogonadismTable.DefaultView; hv.Sort = "Date ASC"; FillHypogonadism(hv); } } }
override protected void BuildLabTests(int minNumLabTestRowsToShow, int minNumBlankLabTestRows) { if (patientID != 0) { //Lab Tests string[] labTestsToGet = new string[] { "PSA", "FPSA", "PCA3", "UPCA3", "UPCA3S" }; LabTestDa da = new LabTestDa(); DataSet labTestsDs = da.GetLabTestsbyList(this.patientID, labTestsToGet); if (labTestsDs.Tables.Count > 0 && labTestsDs.Tables[0].Rows.Count > 0) { DataTable allLabs = labTestsDs.Tables[0]; DataTable labsToDisplay = allLabs.Clone(); // get last 3 PSAs DataView PSAs = new DataView(allLabs); PSAs.RowFilter = LabTest.LabTest_Field + " = 'PSA'"; PSAs.Sort = LabTest.LabDate + " DESC"; int maxPSAs = 3; if (PSAs.Count > maxPSAs) { for (int i = 0; i < maxPSAs; i++) { labsToDisplay.ImportRow(PSAs[i].Row); } } else { labsToDisplay.Merge(PSAs.ToTable()); } // get last 3 FPSAs DataView FPSAs = new DataView(allLabs); FPSAs.RowFilter = LabTest.LabTest_Field + " = 'FPSA'"; FPSAs.Sort = LabTest.LabDate + " DESC"; int maxFPSAs = 3; if (FPSAs.Count > maxFPSAs) { for (int i = 0; i < maxFPSAs; i++) { labsToDisplay.ImportRow(FPSAs[i].Row); } } else { labsToDisplay.Merge(FPSAs.ToTable()); } // get all PCA3 DataView PCA3s = new DataView(allLabs); PCA3s.RowFilter = LabTest.LabTest_Field + " IN ('PCA3', 'UPCA3', 'UPCA3S')"; if (PCA3s.Count > 0) { labsToDisplay.Merge(PCA3s.ToTable()); } if (labsToDisplay.Rows.Count > 0) { DataView sortedLabView = new DataView(labsToDisplay); sortedLabView.Sort = LabTest.LabDate + " ASC"; DataTable sortedLabs = sortedLabView.ToTable(); int numBlankLabTestRows = minNumLabTestRowsToShow - sortedLabs.Rows.Count; if (numBlankLabTestRows < minNumBlankLabTestRows) { numBlankLabTestRows = minNumBlankLabTestRows; } for (int i = 0; i < numBlankLabTestRows; i++) { DataRow blankLabTestsRow; blankLabTestsRow = sortedLabs.NewRow(); blankLabTestsRow["LabDateText"] = "/ /"; blankLabTestsRow["LabTest"] = " "; blankLabTestsRow["LabResult"] = " "; blankLabTestsRow["LabQuality"] = " "; sortedLabs.Rows.Add(blankLabTestsRow); } labTests.DataSource = sortedLabs.DefaultView; } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } labTests.DataBind(); }
// override base version, no longer use old stored proc override protected void BuildLabTests(int minNumLabTestRowsToShow, int minNumBlankLabTestRows) { if (patientID != 0) { //Lab Tests LabTestDa da = new LabTestDa(); // old version DataSet labTestsDs = da.FormGetRecords(this.patientID, this._formName, "Dynamic"); string[] l = { "PSA", "FPSA", "AFP", "HCG", "HCGN", "LDH" }; DataSet labTestsDs = da.GetLabTestsbyList(this.patientID, l); if (labTestsDs.Tables.Count > 0) { DataTable LastXOfEach = labTestsDs.Tables[0].Clone(); int countPerLabTest = 3; // number of each type of lab test to show foreach (string labTest in l) { DataView dv = new DataView(labTestsDs.Tables[0]); string labFilter = BOL.LabTest.LabTest_Field + " = '" + labTest + "'"; dv.RowFilter = labFilter; dv.Sort = BOL.LabTest.LabDate + " DESC"; if (dv.Count > 0) { DataTable t = dv.ToTable(); int lastI = (t.Rows.Count >= countPerLabTest) ? countPerLabTest : t.Rows.Count; for (int i = 0; i < lastI; i++) { LastXOfEach.ImportRow(t.Rows[i]); } } } if (LastXOfEach.Rows.Count > 0) { DataView SortedLabsView = new DataView(LastXOfEach); SortedLabsView.Sort = BOL.LabTest.LabDate + " DESC"; DataTable SortedLabs = SortedLabsView.ToTable(); int numBlankLabTestRows = minNumLabTestRowsToShow - SortedLabs.Rows.Count; if (numBlankLabTestRows < minNumBlankLabTestRows) { numBlankLabTestRows = minNumBlankLabTestRows; } for (int i = 0; i < numBlankLabTestRows; i++) { DataRow blankLabTestsRow; blankLabTestsRow = SortedLabs.NewRow(); blankLabTestsRow["LabDateText"] = "/ /"; blankLabTestsRow["LabTest"] = " "; blankLabTestsRow["LabResult"] = " "; blankLabTestsRow["LabQuality"] = " "; SortedLabs.Rows.Add(blankLabTestsRow); } labTests.DataSource = SortedLabs.DefaultView; } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } } else { labTests.DataSource = BlankLabTests(minNumLabTestRowsToShow).DefaultView; } labTests.DataBind(); }