/// <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); }
/// <summary> /// /// </summary> /// <returns></returns> private DataView GetReport() { 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 surveyType = ddlSurveyType.SelectedValue + "%"; FollowUpDA da = new FollowUpDA(); DataTable dt = da.GetCompletedSurveysByType(startDate.ToShortDateString(), endDate.ToShortDateString(), surveyType); DataTable myTable = new DataTable(); string[] colNames = new string[] { "MRN", "Patient Name", "SurveyId", "Survey", "Month", "Sent Date", "Received Date" }; foreach (string colName in colNames) { myTable.Columns.Add(new DataColumn(colName)); } // get the names of the scoring sections for the column names from the first survey returned if (dt.Rows.Count > 0) { int surveyId = (int)dt.Rows[0][Survey.SurveyId]; DataTable scoreDt1 = SurveyScoringUtil.FillScores(surveyId); foreach (DataRow dr1 in scoreDt1.Rows) { myTable.Columns.Add(new DataColumn(dr1["Section"].ToString())); } } foreach (DataRow dr in dt.Rows) { DataRow newRow = myTable.NewRow(); string ptName = dr[Patient.PtFirstName].ToString() + " " + dr[Patient.PtMiddleName].ToString() + " " + dr[Patient.PtLastName].ToString(); int surveyId = int.Parse(dr[Survey.SurveyId].ToString()); // get table with scores DataTable scoreDt2 = new DataTable(); scoreDt2 = SurveyScoringUtil.FillScores(surveyId); newRow["MRN"] = dr[Patient.PtMRN].ToString(); newRow["Patient Name"] = ptName; newRow["SurveyId"] = dr[Survey.SurveyId].ToString(); newRow["Survey"] = dr[Survey.SurveyType].ToString(); string actionItemStr = dr[Caisis.BOL.Action.ActionItem].ToString(); string surveyMonth = FollowUpUtil.GetSurveyMonthNoFromActionItem(actionItemStr); newRow["Month"] = surveyMonth; newRow["Sent Date"] = DateTime.Parse(dr[Caisis.BOL.Action.ActionDate].ToString()).ToShortDateString(); newRow["Received Date"] = DateTime.Parse(dr[Survey.SurveyDate].ToString()).ToShortDateString(); // translate the scores that are in rows to columns in this patients record for (int i = 0; i < scoreDt2.Rows.Count; i++) { int columnIndex = i + 7; newRow[columnIndex] = scoreDt2.Rows[i]["AverageStandardized"].ToString(); } myTable.Rows.Add(newRow); } return(myTable.DefaultView); }
private DataTable SetFollowUpLetterList() { // need to validate string is actual date DateTime processDate = Convert.ToDateTime(ProcessDate.Text); // procedure can be entered from UI too string procedureType = ProcedureType.Text; _redirectPath += "&proc=" + procedureType + "&processDate=" + processDate.ToShortDateString(); FollowUpDA da = new FollowUpDA(); DataTable lastSurveyPatientsDt = new DataTable(); lastSurveyPatientsDt = da.GetPatientsLastSurveySentList(procedureType, FollowUpUtil.GetSurveyShortName(ddlSurveyType.SelectedValue)); DataTable fuLetterPatientsDt = new DataTable(); DataColumn dc0 = new DataColumn("PatientId"); DataColumn dc1 = new DataColumn("PtName"); DataColumn dc2 = new DataColumn("PtMRN"); DataColumn dc3 = new DataColumn("Surgeon"); DataColumn dc4 = new DataColumn("FUMonth"); DataColumn dc5 = new DataColumn("SurveyName"); DataColumn dc6 = new DataColumn("SentDate"); DataColumn dc7 = new DataColumn("Address1"); DataColumn dc8 = new DataColumn("Address2"); DataColumn dc9 = new DataColumn("City"); DataColumn dc10 = new DataColumn("State"); DataColumn dc11 = new DataColumn("Zip"); DataColumn dc12 = new DataColumn("LastName"); DataColumn dc13 = new DataColumn("FirstName"); fuLetterPatientsDt.Columns.Add(dc12); fuLetterPatientsDt.Columns.Add(dc13); fuLetterPatientsDt.Columns.Add(dc0); fuLetterPatientsDt.Columns.Add(dc1); fuLetterPatientsDt.Columns.Add(dc2); fuLetterPatientsDt.Columns.Add(dc3); fuLetterPatientsDt.Columns.Add(dc4); fuLetterPatientsDt.Columns.Add(dc5); fuLetterPatientsDt.Columns.Add(dc6); fuLetterPatientsDt.Columns.Add(dc7); fuLetterPatientsDt.Columns.Add(dc8); fuLetterPatientsDt.Columns.Add(dc9); fuLetterPatientsDt.Columns.Add(dc10); fuLetterPatientsDt.Columns.Add(dc11); // HERE: remove patients who have completed the survey within 20 days after it was sent to them foreach (DataRow dr in lastSurveyPatientsDt.Rows) { int pId = Int32.Parse(dr[Patient.PatientId].ToString()); DateTime surveySentDate = Convert.ToDateTime(dr[Caisis.BOL.Action.ActionDate].ToString()); // we have the surveySent actionItem is "NAME x Month Sent" string surveySentActionItem = dr[Caisis.BOL.Action.ActionItem].ToString(); string surveyType = FollowUpUtil.GetSurveyNameFromActionItem(surveySentActionItem); string month = FollowUpUtil.GetSurveyMonthNoFromActionItem(surveySentActionItem); // and want to get the equivalent letterSent ActionItem: for now it is "NAME x Month Letter Sent" string letterSentActionItem = FollowUpUtil.GetActionItemToLog(pId, month, surveyType, false); if (processDate > surveySentDate.AddDays(20)) //expected to receive survey within 20 days of processdate { // if expected survey was not received, send letter to patient only if not already sent before if (da.GetSurveyByActionItem(pId, surveySentActionItem).Rows.Count == 0 && da.LetterAlreadySent(pId, letterSentActionItem) == false) { // get the (full) survey name to display in the list of results string selectedSurvey = ddlSurveyType.SelectedValue; string surveyFullName = FollowUpUtil.GetSurveyFullName(int.Parse(month), selectedSurvey); // patient is due for a follow up letter DataRow fuRow = fuLetterPatientsDt.NewRow(); fuRow["PatientId"] = pId.ToString(); fuRow["LastName"] = dr[Patient.PtLastName].ToString(); fuRow["FirstName"] = dr[Patient.PtFirstName].ToString(); fuRow["PtName"] = dr[Patient.PtLastName].ToString() + ", " + dr[Patient.PtFirstName].ToString(); fuRow["PtMRN"] = dr[Patient.PtMRN].ToString(); fuRow["Surgeon"] = da.GetMostRecentTreatingPhysician(pId); fuRow["FUMonth"] = month.ToString(); fuRow["SurveyName"] = surveyFullName; DateTime dt; dt = Convert.ToDateTime(dr[Caisis.BOL.Action.ActionDate].ToString()); fuRow["SentDate"] = dt.ToShortDateString(); //last survey sent date //fuRow["SentDate"] = dr[Caisis.BOL.Action.ActionDate].ToString(); //last survey sent date if (string.IsNullOrEmpty(letterSentActionItem)) { fuRow["SurveyName"] = fuRow["SurveyName"].ToString() + "<BR>Invalid Action Name"; } // retrieve additional patient data if (!String.IsNullOrEmpty(dr[Patient.PtMRN].ToString())) { PatientDa ptDa = new PatientDa(); DataTable ptInfoDt = ptDa.GetPatientByMRN(dr[Patient.PtMRN].ToString()); if (ptInfoDt.Rows.Count > 0) { fuRow["Address1"] = ptInfoDt.Rows[0][Patient.PtAddress1].ToString(); fuRow["Address2"] = ptInfoDt.Rows[0][Patient.PtAddress2].ToString(); fuRow["City"] = ptInfoDt.Rows[0][Patient.PtCity].ToString(); fuRow["State"] = ptInfoDt.Rows[0][Patient.PtState].ToString(); fuRow["Zip"] = ptInfoDt.Rows[0][Patient.PtPostalCode].ToString(); } } fuLetterPatientsDt.Rows.Add(fuRow); // NOTE: all patients get the same follow up letter, but this could change? _redirectPath += "&" + dr[Patient.PatientId].ToString() + "=" + month + "_Follow Up Letter"; } } CreateBatchButton.Attributes.Add("onclick", "window.location.href='" + _redirectPath + "'"); } return(fuLetterPatientsDt); }