/// <summary> /// Gets a report of surveys OR letters sent by date range /// </summary> /// <param name="physicianName"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> private DataView GetReportsDataView() { DateTime startDate = !string.IsNullOrEmpty(StartDateField.Value) ? DateTime.Parse(StartDateField.Value) : DateTime.Today; DateTime endDate = !string.IsNullOrEmpty(EndDateField.Value) ? DateTime.Parse(EndDateField.Value) : DateTime.Today; string procType = this.ProcedureType.SelectedValue; string actionItem; if (this.GetFormType() == "Survey") { actionItem = "%" + this.GetFormType() + "% Month Sent"; } else { actionItem = "%Month " + this.GetFormType() + " Sent"; } FollowUpDA da = new FollowUpDA(); DataTable followUpReportTable = da.GetFollowUpReportList(procType, startDate.ToShortDateString(), endDate.ToShortDateString(), actionItem); // now we need to create a new datatable so we can loop and add the column for Completed Date DataTable myTable = new DataTable(); string[] colNames = new string[] { "PatientId", "Patient", "Survey", "Month", "Treating Physician", "Sent Date", "Received Date" }; foreach (string colName in colNames) { myTable.Columns.Add(new DataColumn(colName)); } foreach (DataRow dr in followUpReportTable.Rows) { DataRow newRow = myTable.NewRow(); string ptName = dr[Patient.PtFirstName].ToString() + " " + dr[Patient.PtMiddleName].ToString() + " " + dr[Patient.PtLastName].ToString(); newRow["PatientId"] = dr[Patient.PatientId].ToString(); newRow["Patient"] = ptName; newRow["Treating Physician"] = da.GetMostRecentTreatingPhysician(int.Parse(dr[Patient.PatientId].ToString())); string actionItemStr = dr[Caisis.BOL.Action.ActionItem].ToString(); string actionId = dr[Caisis.BOL.Action.ActionId].ToString(); string fuMonth = FollowUpUtil.GetSurveyMonthNoFromActionItem(actionItemStr); newRow["Month"] = fuMonth; string formName = FollowUpUtil.GetSurveyNameFromActionItem(actionItemStr); if (this.GetFormType() == "Letter") { formName += " " + "Follow Up Letter"; } newRow["Survey"] = formName; newRow["Sent Date"] = DateTime.Parse(dr[Caisis.BOL.Action.ActionDate].ToString()).ToShortDateString(); // Add Survey completed date, if it exists (we check the Surveys table) string completedDate = string.Empty; //DataTable dtRec = da.GetSurveyReceived(Int32.Parse(dr[Patient.PatientId].ToString()), actionItemExpr); DataTable dtRec = da.GetSurveyByActionItem(Int32.Parse(dr[Patient.PatientId].ToString()), actionItemStr); if (dtRec.Rows.Count > 0 && !string.IsNullOrEmpty(dtRec.Rows[0][Survey.SurveyDate].ToString())) { completedDate = DateTime.Parse(dtRec.Rows[0][Survey.SurveyDate].ToString()).ToShortDateString(); } else { completedDate = "--"; } newRow["Received Date"] = completedDate; // Finally add new row to datasource myTable.Rows.Add(newRow); } return(myTable.DefaultView); }