⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postopfollowupreport.aspx.cs

📁 医疗决策支持系统
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using Caisis.DataAccess;

using Caisis.UI.Core.Classes;

namespace Caisis.UI.Modules.All.Reports
{
	/// <summary>
	/// Summary description for PostOpFollowUpReport.
	/// </summary>
	/// 
	// TODO 1) remove unwanted columns from Excel Export based on op report
	// 

	public class PostOpFollowUpReport : BasePage
	{
		protected HtmlContainerControl ReportContentBody;
		protected string reportTitle;
		protected Repeater RP_LP_Repeater;
		protected Repeater LN_Repeater;
		protected Panel RP_LP_Panel;
		protected Panel LN_Panel;

		protected DropDownList OpType;
		protected DropDownList OpSurgeon;
		protected DropDownList OpInstitution;
		protected DropDownList DateRange;
		protected DropDownList MonthsSincePSA;
		protected ImageButton RunReportBtn;
		protected ImageButton ExcelBtn;
		protected Label resultMessage;
		protected int recordCount;

		protected DataGrid ExcelDg;

		private string opType;// = "RP";
		private string institution = "memorial sloan kettering cancer center";
		private string surgeon;
		private int monthsSinceSurgery;
		private int monthsSincePSA;
        protected System.Web.UI.WebControls.LinkButton SortByName;
        protected System.Web.UI.WebControls.LinkButton SortByMonthsSinceSurgery;
        protected System.Web.UI.WebControls.LinkButton SortByMonthsSincePSA;
		private string datasetSql;

		override protected void Page_Load(object sender, System.EventArgs e)
		{
			//defaults
			RP_LP_Panel.Visible = false;
			LN_Panel.Visible = false;
			
			
			if(Page.IsPostBack)
			{
				resultMessage.Text = "";
				
				opType = OpType.SelectedValue;
				surgeon = OpSurgeon.SelectedValue;
				institution = OpInstitution.SelectedValue;
				monthsSinceSurgery = int.Parse(DateRange.SelectedValue);
				monthsSincePSA = int.Parse(MonthsSincePSA.SelectedValue);
				datasetSql = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
				
				// calculate date from today

				ReportDa da = new ReportDa();
				DataSet ds = da.GetPostOpFollowUp(opType, institution, surgeon, monthsSinceSurgery, monthsSincePSA, datasetSql);

				recordCount = ds.Tables[0].Rows.Count;

				if (recordCount > 0)  
				{
					string sortBy = "PtMrn ASC";

					if(Request.Form["__EVENTTARGET"] != null && !Request.Form["__EVENTTARGET"].Equals("")) 
					{
						if(Request.Form["__EVENTTARGET"].Equals("SortByName"))
						{
							sortBy = "PtLastName";
						}
						else if(Request.Form["__EVENTTARGET"].Equals("SortByMonthsSinceSurgery"))
						{
							sortBy = "MonthsSinceSurgery";
						}
						else if(Request.Form["__EVENTTARGET"].Equals("SortByMonthsSincePSA"))
						{
							sortBy = "MonthsSincePSA";
						}

					}
					
					
					if(opType.Equals("RP") || opType.Equals("LP"))
					{
						RP_LP_Panel.Visible = true;

						DataView dv1 = ds.Tables[0].DefaultView;

						dv1.Sort = sortBy;

						RP_LP_Repeater.DataSource = dv1;
						
						RP_LP_Repeater.DataBind();
					}
					else if(opType.Equals("LN"))
					{
						LN_Panel.Visible = true;

						DataView dv2 = ds.Tables[0].DefaultView;

						dv2.Sort  = sortBy;

						LN_Repeater.DataSource = dv2;
						
						LN_Repeater.DataBind();
					}
				}
				else
				{
					resultMessage.Text = "<br><br>There are no " + institution + " " + opType + " patients for " + surgeon + " outside of " + monthsSinceSurgery + " months of surgery and " + monthsSincePSA + " months of PSA for follow-up.";
				}
			
			}
			else // not a post back; set defaults
			{
				

				SurgeryDa surgDa = new SurgeryDa();
			
				// populate dropdown with distinct institutions from surgeries table
				DataTable instDt = surgDa.GetDistinctSurgeryInstitution().Tables[0];
				OpInstitution.DataSource = instDt.DefaultView;
				OpInstitution.DataTextField = instDt.Columns[0].ColumnName;
				OpInstitution.DataValueField = instDt.Columns[0].ColumnName;
				OpInstitution.DataBind();

				// populate drop down with distint surgeons from surgeries table
				DataTable surgDt = surgDa.GetDistinctSurgeons().Tables[0];
				OpSurgeon.DataSource = surgDt.DefaultView;
				OpSurgeon.DataTextField = surgDt.Columns[0].ColumnName;
				OpSurgeon.DataValueField = surgDt.Columns[0].ColumnName;
				OpSurgeon.DataBind();
				OpSurgeon.Items.Add("All");

				OpType.Items.Add("RP");
				OpType.Items.Add("LP");
				OpType.Items.Add("LN");

				DateRange.Items.Add("0");
				DateRange.Items.Add("3");
				DateRange.Items.Add("6");
				DateRange.Items.Add("12");
				DateRange.Items.Add("24");

				MonthsSincePSA.Items.Add("0");
				MonthsSincePSA.Items.Add("3");
				MonthsSincePSA.Items.Add("6");
				MonthsSincePSA.Items.Add("12");
				MonthsSincePSA.Items.Add("24");
				
				reportTitle = "Post Operation Follow Up Patients";
				ReportContentBody.Attributes.Add("onLoad","top.DataAnalysisContainer.setFormTitle('"+this.reportTitle+"');top.DataAnalysisContainer.MM_showHideLayers('buttonsLayer','','show');");
			}
		}

		protected void ExcelBtn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{	
			ReportDa da = new ReportDa();
			DataSet ds = da.GetPostOpFollowUp(opType, institution, surgeon, monthsSinceSurgery, monthsSincePSA, datasetSql);
			
			if(ds.Tables[0].Rows.Count > 0)
			{
				Response.Clear();
				Response.Buffer= true;
				Response.ContentType = "application/vnd.ms-excel";
				Response.AddHeader("Content-Disposition", "attachment;filename=PostOpFollowUpReport.xls"); 
				Response.Charset = "";
				this.EnableViewState = false; 
			
				// should remove date text and irrelevant columns
				ds.Tables[0].Columns.Remove("PatientId");
				ds.Tables[0].Columns.Remove("PtBirthDate");
				ds.Tables[0].Columns.Remove("SurgDate");
				ds.Tables[0].Columns.Remove("LabDate");
				ds.Tables[0].Columns.Remove("ActionDate");
				ds.Tables[0].Columns.Remove("LastFollowUpDate");

				// these columns only apply to ln
				if(opType.ToLower().Equals("rp") || opType.ToLower().Equals("lp"))
				{
					ds.Tables[0].Columns.Remove("PathHistology");
					ds.Tables[0].Columns.Remove("LastFollowUpDateText");
					ds.Tables[0].Columns.Remove("MonthsToLastFollowUp");
					ds.Tables[0].Columns.Remove("MonthsSinceFollowUp");
				}
				
				// these columsn only apply to rp and lp
				if(opType.ToLower().Equals("ln"))
				{
					ds.Tables[0].Columns.Remove("LabTest");
					ds.Tables[0].Columns.Remove("LabDateText");
					ds.Tables[0].Columns.Remove("LabResult");
					ds.Tables[0].Columns.Remove("PostOpPSAs");
					ds.Tables[0].Columns.Remove("MonthsSincePSA");
					ds.Tables[0].Columns.Remove("ActionDateText");
					ds.Tables[0].Columns.Remove("ActionItem");
					ds.Tables[0].Columns.Remove("ActionNotes");
				}

				ExcelDg.DataSource = ds.Tables[0];
				ExcelDg.DataBind();
		
				System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
				System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

				//this.ClearControls(ExcelDg); //if excel had files other than literals
				ExcelDg.RenderControl(oHtmlTextWriter);
				
				Response.Write(oStringWriter.ToString());

				//DataTable dt = ds.Tables[0];
				//Caisis.Controller.ExcelExporter.ProduceCSV(dt, Response.Output, true);
				Response.End();
			}
			else
			{
				resultMessage.Text = "<br><br>There are no " + institution + " " + opType + " patients for " + surgeon + " outside of " + monthsSinceSurgery + " months for follow-up.";
			}
			
		}

        private void InitializeComponent()
        {
        
        }


		protected void RP_LP_Repeater_DataBound(Object Sender, RepeaterItemEventArgs e) 
		{
			
			HtmlTableRow ActionNotesRow;
			ActionNotesRow = (HtmlTableRow) e.Item.FindControl("ActionNotesRow");

			if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 
			{
				if (((DataRowView) e.Item.DataItem )["ActionNotes"] != null && ((DataRowView) e.Item.DataItem )["ActionNotes"].ToString().Length > 0)
				{
					ActionNotesRow.Visible = true;
				}
				else
				{
					ActionNotesRow.Visible = false;
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -