using System; using System.Collections.Generic; //using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Data; namespace Com.Jpsoft.Hospital.Web.Module.FllowUp.MedicalQuality { public partial class InHospital : Com.Jpsoft.Hospital.Web.Common.BasePage { /// /// 获取或设置选中项的集合 /// protected Dictionary SelectedItems { get { return (ViewState["mySelectedItems"] != null) ? (Dictionary)ViewState["mySelectedItems"] : null; } set { ViewState["mySelectedItems"] = value; } } #region 事件处理 protected override void OnInit(EventArgs e) { if (!IsPostBack) { base.AutoCheckRight = false; base.CheckRightParam = Com.Jpsoft.Hospital.Web.Common.PageFuntionType.List; } base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if ((!string.IsNullOrEmpty(Request.QueryString["date"])) && (!string.IsNullOrEmpty(Request.QueryString["day"]))) { StringBuilder strWhere = new StringBuilder(" where 1=1 and lxdh != '' "); DateTime date = DateTime.Parse(Request.QueryString["date"]); int day = int.Parse(Request.QueryString["day"]); DateTime date1 = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); DateTime date2; if (day == 0) { date2 = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59); } else { date2 = date.AddDays(day); } strWhere.Append(" and xcsfrq>='" + date1.ToString() + "' "); strWhere.Append(" and xcsfrq<='" + date2.ToString() + "' "); ViewState["SearchTerms"] = strWhere.ToString(); } if (Request.QueryString["curPage"] != null) { AspNetPager1.RecordCount = Convert.ToInt32(Request.QueryString["curPage"].ToString()) * AspNetPager1.PageSize; AspNetPager1.CurrentPageIndex = Convert.ToInt32(Request.QueryString["curPage"].ToString()); } BindKS(); BindData(0); } else { } } private void BindKS() { Com.Jpsoft.Hospital.BLL.Ex.ZY_BRSYKEx bll = new BLL.Ex.ZY_BRSYKEx(); DataTable dt = bll.GetYY_KSBMKList(" (name NOT LIKE '%门诊%') AND (name NOT LIKE '%停用%') AND (kslb = 0) "); ddlKS.Items.Add(new ListItem("请选择", "")); foreach (DataRow dr in dt.Rows) { ddlKS.Items.Add(new ListItem(dr["name"].ToString(), dr["id"].ToString())); } } protected void txtQuery_Click(object sender, EventArgs e) { Query(); } protected void btnSendSMS_Click(object sender, EventArgs e) { SendSMS(); } protected void AspNetPager1_PageChanged(object sender, EventArgs e) { BindData(1); } protected void GvList_DataBinding(object sender, EventArgs e) { CollectSelected(); } protected void GvList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1 && this.SelectedItems != null) { DataRowView row = e.Row.DataItem as DataRowView; CheckBox cb = e.Row.FindControl("chbSelect") as CheckBox; HiddenField hdf = e.Row.FindControl("hdfLxdh") as HiddenField; HyperLink hyl = e.Row.FindControl("hylTel") as HyperLink; HyperLink hylSyList = e.Row.FindControl("hylSyList") as HyperLink; string name = e.Row.Cells[1].Text; string blh = GvList.DataKeys[e.Row.RowIndex].Value.ToString(); if (this.SelectedItems.ContainsKey(blh)) cb.Checked = true; else cb.Checked = false; string url = Page.ResolveClientUrl("~/Module/FllowUp/MedicalQuality/Call.aspx?customertypeR=1&type=1&blh=" + blh + "&customertype=1&curPage=" + AspNetPager1.CurrentPageIndex); //hyl.Attributes.Add("onclick", "javascript:openwin('" + url + "'); return false;"); hyl.NavigateUrl = url; } } #endregion #region 事件方法 /// /// 绑定数据 /// private void BindData(int page) { string strWhere = " where 1=1 "; string orderby = " order by cqrq DESC"; int recordCount = 0; if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) { strWhere = ViewState["SearchTerms"].ToString(); } if (!string.IsNullOrEmpty((string)ViewState["Order"])) { orderby = ViewState["Order"].ToString(); } if (Request.QueryString["url"] != null) { if (page == 0 || page == 1) { if ((!string.IsNullOrEmpty((string)Session["Search_InHospital.aspx"]) || !string.IsNullOrEmpty((string)Session["Order_InHospital.aspx"])) && Request.QueryString["url"].ToString().IndexOf("FllowUp/MedicalQuality/Call.aspx") > 0) { if (!string.IsNullOrEmpty((string)Session["Search_InHospital.aspx"])) strWhere = Session["Search_InHospital.aspx"].ToString(); if (!string.IsNullOrEmpty((string)Session["Order_InHospital.aspx"])) orderby = Session["Order_InHospital.aspx"].ToString(); } } else { if ((!string.IsNullOrEmpty((string)Session["Search_InHospital.aspx"]) || !string.IsNullOrEmpty((string)Session["Order_InHospital.aspx"])) && Request.QueryString["url"].ToString().IndexOf("FllowUp/MedicalQuality/InHospital.aspx") > 0) { if (!string.IsNullOrEmpty((string)Session["Search_InHospital.aspx"])) strWhere = Session["Search_InHospital.aspx"].ToString(); if (!string.IsNullOrEmpty((string)Session["Order_InHospital.aspx"])) orderby = Session["Order_InHospital.aspx"].ToString(); } } } using (IDataReader idr = BLL.BaseClass.SelectPage("jp_view_brsyk_ks_zg", "*", "syxh", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, strWhere, orderby)) { if (idr.Read()) { recordCount = int.Parse(idr["RecordCount"].ToString()); } AspNetPager1.RecordCount = recordCount; idr.NextResult(); this.GvList.DataSource = idr; this.GvList.DataBind(); if (!string.IsNullOrEmpty(this.ddlKS.SelectedValue) && txtstart.Text != "" && txtEnd.Text != "") { this.labelSFL.Text = getSFL(); } } } /// /// 查询数据 /// private void Query() { StringBuilder strWhere = new StringBuilder(" where 1=1 "); if (ckbSW.Checked) { strWhere.Append(" and cyfs!='3' "); } if (ckbDH.Checked) { strWhere.Append(" and LEN(lxrdh) = 11 "); //strWhere.Append(" and (lxrdh not like '133%' and lxrdh not like '149%' and lxrdh not like '153%' and lxrdh not like '173%' and lxrdh not like '174%' and lxrdh not like '177%' and lxrdh not like '180%' and lxrdh not like '181%' and lxrdh not like '189%' and lxrdh not like '199%') "); } if (ckbST.Checked) { strWhere.Append(" and dateadd(d,3,Convert(datetime,substring(rqrq,1,8)+' '+substring(rqrq,9,8),120))<=Convert(datetime,substring(cqrq,1,8)+' '+substring(cqrq,9,8),120) "); } if (ckbFY.Checked) { strWhere.Append(" and name not like '西院%' and name not like '肿瘤%' "); } if (ckbNY.Checked) { strWhere.Append(" and name not like '北院%' "); } if (ckbBY.Checked) { strWhere.Append(" and (name like '西院%' or name like '肿瘤%' or name like '北院%') "); } if (!string.IsNullOrEmpty(this.ddlKS.SelectedValue)) { strWhere.Append(" and ksdm='" + ddlKS.SelectedValue + "'"); } if (!string.IsNullOrEmpty(this.txtCardno.Text)) { strWhere.Append(" and blh='" + this.txtCardno.Text + "' "); } if (!string.IsNullOrEmpty(this.txtHzxm.Text)) { strWhere.Append(" and hzxm like '%" + this.txtHzxm.Text + "%'"); } if (!string.IsNullOrEmpty(this.txtQtkh.Text)) { strWhere.Append(" and qtkh like '%" + this.txtQtkh.Text + "%'"); } if (!string.IsNullOrEmpty(this.txtSbh.Text)) { strWhere.Append(" and sbh like '%" + this.txtSbh.Text + "%'"); } if (!string.IsNullOrEmpty(this.txtSfzh.Text)) { strWhere.Append(" and sfzh like '%" + this.txtSfzh.Text + "%'"); } if (this.ddlOpSex.SelectedIndex > 0) { strWhere.Append(" and sex ='" + this.ddlOpSex.SelectedValue.ToString() + "'"); } if (txtstart.Text != "") { strWhere.Append(" and cqrq>='" + Convert.ToDateTime(txtstart.Text).ToString("yyyyMMdd00:00:00") + "' "); } if (txtEnd.Text != "") { strWhere.Append(" and cqrq<'" + Convert.ToDateTime(txtEnd.Text).AddDays(1).ToString("yyyyMMdd00:00:00") + "' "); } //入区日期 //if (txtouts.Text == "" && txtoute.Text == "") //{ // strWhere.Append(" and dateadd(d,3,Convert(datetime,substring(rqrq,1,8)+' '+substring(rqrq,9,8),120))<=Convert(datetime,substring(cqrq,1,8)+' '+substring(cqrq,9,8),120) "); //} //else //{ if (txtouts.Text != "") { strWhere.Append(" and rqrq>='" + Convert.ToDateTime(txtouts.Text).ToString("yyyyMMdd00:00:00") + "' "); } if (txtoute.Text != "") { strWhere.Append(" and rqrq<='" + Convert.ToDateTime(txtoute.Text).ToString("yyyyMMdd00:00:00") + "' "); } //} if (txtYSXM.Text != "") { strWhere.Append(" and ygxm like '%" + txtYSXM.Text.ToString().Trim() + "%' "); } if (txtTel.Text != "") { strWhere.Append(" and lxrdh like '%" + txtTel.Text.ToString().Trim() + "%' "); } if (txtCYZD.Text != "") { strWhere.Append(" and cyzd like '%" + txtCYZD.Text.ToString().Trim() + "%' "); } if (txtPageSize.Text != "") { int i = 0; if (int.TryParse(txtPageSize.Text.Trim(), out i)) AspNetPager1.PageSize = i; } ViewState["SearchTerms"] = strWhere.ToString(); Session["Search_InHospital.aspx"] = strWhere.ToString(); StringBuilder strOrder = new StringBuilder(); if (!string.IsNullOrEmpty(ddlOrder.SelectedValue)) strOrder.Append(" order by " + ddlOrder.SelectedValue); ViewState["Order"] = strOrder.ToString(); Session["Order_InHospital.aspx"] = strOrder.ToString(); BindData(0); } /// /// 统计随访率 /// private string getSFL() { string str = "出院患者总数:{0}。护理随访人数:{1},护理随访率:{2},护理有效随访人数:{3},护理有效随访率:{4}。医生随访人数:{5},医生随访率:{6},医生有效随访人数:{7},医生有效随访率:{8}。科室随访人数:{9},科室有效随访率:{10}。"; int total = 0; int hs = 0; int hsall = 0; int ys = 0; int ysall = 0; int ks = 0; string sql = "SELECT blh FROM jp_view_brsyk_ks_zg WHERE 1=1 "; sql += " and ksdm='" + ddlKS.SelectedValue + "'"; if (txtstart.Text != "") { sql += " and cqrq>='" + Convert.ToDateTime(txtstart.Text).ToString("yyyyMM0100:00:00") + "' "; sql += " and cqrq<'" + Convert.ToDateTime(txtstart.Text).AddMonths(1).ToString("yyyyMM0100:00:00") + "' "; } if (ckbSW.Checked) { sql += " and cyfs!='3' "; } if (ckbST.Checked) { sql += " and dateadd(d,3,Convert(datetime,substring(rqrq,1,8)+' '+substring(rqrq,9,8),120))<=Convert(datetime,substring(cqrq,1,8)+' '+substring(cqrq,9,8),120) "; } if (ckbDH.Checked) { sql += " and LEN(lxrdh) = 11 "; //sql += " and (lxrdh not like '133%' and lxrdh not like '149%' and lxrdh not like '153%' and lxrdh not like '173%' and lxrdh not like '174%' and lxrdh not like '177%' and lxrdh not like '180%' and lxrdh not like '181%' and lxrdh not like '189%' and lxrdh not like '199%') "; } DataTable dtRY = BLL.BaseClass.GetTable(sql); total = dtRY.Rows.Count; foreach (DataRow drRY in dtRY.Rows) { Com.Jpsoft.Hospital.BLL.Ex.jp_followup_recordEx bllRY = new BLL.Ex.jp_followup_recordEx(); string yshfsj = bllRY.GetScsfrq(int.Parse(drRY["blh"].ToString()), 2); string yshfsj1 = bllRY.GetScsfrq1(int.Parse(drRY["blh"].ToString()), 2); string hshfsj = bllRY.GetScsfrq(int.Parse(drRY["blh"].ToString()), 5); string hshfsj1 = bllRY.GetScsfrq1(int.Parse(drRY["blh"].ToString()), 5); if (yshfsj != "无") { ys++; } if (yshfsj1 != "无") { ysall++; } if (hshfsj != "无") { hs++; } if (hshfsj1 != "无") { hsall++; } if (yshfsj != "无" || hshfsj != "无") { ks++; } } if (total != 0) { str = String.Format(str, total, hsall, ((double)hsall / total).ToString("0.00%"), hs, ((double)hs / total).ToString("0.00%"), ysall, ((double)ysall / total).ToString("0.00%"), ys, ((double)ys / total).ToString("0.00%"), ks, ((double)ks / total).ToString("0.00%")); } return str; } /// /// 发送短信 /// private void SendSMS() { CollectSelected(); if (SelectedItems == null || SelectedItems.Count == 0) { Response.Write(""); return; } string ids = string.Empty; foreach (KeyValuePair kvp in SelectedItems) { ids += ",'" + kvp.Key + "'"; } if (ids != string.Empty) { ids = ids.Substring(1); } if (txtNextFollowUpDate.Text != "") { DateTime.Parse(txtNextFollowUpDate.Text); } Response.Redirect("../SendMsg.aspx?ct=1&ids=" + ids + "&con=" + this.txtSMSContent.Text + "&next=" + txtNextFollowUpDate.Text); //string msgContent = this.txtSMSContent.Text; //BLL.jp_followup_record bll = new Com.Jpsoft.Hospital.BLL.jp_followup_record(); //Model.jp_followup_record model; //foreach (KeyValuePair kvp in SelectedItems) //{ // string msgPhone = kvp.Value; // try // { // if (Common.SMS.SendSMG(msgPhone, msgContent)) // { // model = new Com.Jpsoft.Hospital.Model.jp_followup_record(); // model.visitway = 0; // model.visitcontent = msgContent; // model.date = DateTime.Now; // model.customerid = int.Parse(kvp.Key); // if (txtNextFollowUpDate.Text != "") // { // model.xcsfrq = DateTime.Parse(txtNextFollowUpDate.Text); // } // model.customertype = 1; // model.ksmc = txtks.Text; // model.kslxr = txtkslxr.Text; // model.zyh = txtzyh.Text; // bll.Add(model); // } // } // catch // { // Response.Write(""); // } //} ////if (!string.IsNullOrEmpty(this.txtNextFollowUpDate.Text)) ////{ //// SetNextFollowUpDate(); ////} //Response.Write(""); } /// /// 收集选中项 /// protected void CollectSelected() { Dictionary selectedItems = null; if (this.SelectedItems == null) selectedItems = new Dictionary(); else selectedItems = this.SelectedItems; for (int i = 0; i < this.GvList.Rows.Count; i++) { string lxdh = this.GvList.Rows[i].Cells[5].Text; CheckBox cb = this.GvList.Rows[i].FindControl("chbSelect") as CheckBox; string patid = this.GvList.DataKeys[i].Value.ToString(); if (selectedItems.ContainsKey(patid) && !cb.Checked) selectedItems.Remove(patid); if (!selectedItems.ContainsKey(patid) && cb.Checked) selectedItems.Add(patid, lxdh); } this.SelectedItems = selectedItems; } /// /// 设置下次随访日期 /// protected void SetNextFollowUpDate() { CollectSelected(); Jpsoft.Hospital.BLL.Ex.ZY_BRXXKEx zyBll = new Com.Jpsoft.Hospital.BLL.Ex.ZY_BRXXKEx(); if (SelectedItems == null || SelectedItems.Keys.Count == 0) { //Response.Write(""); return; } foreach (KeyValuePair kvp in SelectedItems) //for (int i = 0; i < SelectedItems.Keys.Count; i++) { decimal patid = Convert.ToDecimal(kvp.Key); DateTime date = DateTime.Parse(this.txtNextFollowUpDate.Text); zyBll.UpdateFollowUpDate(date, patid); } //Response.Write(""); } /// /// 回访数 /// private string KSHF() { int total = 0; int hs = 0; int ys = 0; int ks = 0; string sql = "SELECT blh FROM jp_view_brsyk_ks_zg WHERE 1=1 "; sql += " and ksdm='" + ddlKS.SelectedValue + "'"; if (txtstart.Text != "") { sql += " and cqrq>='" + Convert.ToDateTime(txtstart.Text).ToString("yyyyMMdd00:00:00") + "' "; sql += " and cqrq<'" + Convert.ToDateTime(txtEnd.Text).ToString("yyyyMMdd00:00:00") + "' "; } if (ckbSW.Checked) { sql += " and cyfs!='3' "; } if (ckbST.Checked) { sql += " and dateadd(d,3,Convert(datetime,substring(rqrq,1,8)+' '+substring(rqrq,9,8),120))<=Convert(datetime,substring(cqrq,1,8)+' '+substring(cqrq,9,8),120) "; } if (ckbDH.Checked) { sql += " and LEN(lxrdh) = 11 "; } DataTable dtRY = BLL.BaseClass.GetTable(sql); total = dtRY.Rows.Count; foreach (DataRow drRY in dtRY.Rows) { Com.Jpsoft.Hospital.BLL.Ex.jp_followup_recordEx bllRY = new BLL.Ex.jp_followup_recordEx(); string yshfsj = bllRY.GetScsfrq(int.Parse(drRY["blh"].ToString()), 2); string hshfsj = bllRY.GetScsfrq(int.Parse(drRY["blh"].ToString()), 5); if (yshfsj != "无") { ys++; } if (hshfsj != "无") { hs++; } if (yshfsj != "无" || hshfsj != "无") { ks++; } } return string.Format("出院患者共{0}人。医师随访{1}人,护士随访{2}人,科室总随访{3}人。", total, ys, hs, ks); } #endregion protected void LinkButton1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtstart.Text) && !string.IsNullOrEmpty(this.txtstart.Text) && !string.IsNullOrEmpty(this.ddlKS.SelectedValue)) { this.Label1.Text = KSHF(); } else { Response.Write(""); } } private void exportXls() { DataTable dt = new DataTable(); //dt.Columns.Add("科室"); dt.Columns.Add("病人姓名"); dt.Columns.Add("住院号"); dt.Columns.Add("电话号码"); dt.Columns.Add("出院时间"); dt.Columns.Add("护理有效随访"); dt.Columns.Add("医师有效随访"); dt.Columns.Add("科室随访"); int total = 0; int hs = 0; int hsall = 0; int ys = 0; int ysall = 0; int ks = 0; string sql = "SELECT * FROM jp_view_brsyk_ks_zg WHERE 1=1 "; sql += " and ksdm='" + ddlKS.SelectedValue + "'"; if (txtstart.Text != "") { sql += " and cqrq>='" + Convert.ToDateTime(txtstart.Text).ToString("yyyyMM0100:00:00") + "' "; sql += " and cqrq<'" + Convert.ToDateTime(txtstart.Text).AddMonths(1).ToString("yyyyMM0100:00:00") + "' "; } if (ckbSW.Checked) { sql += " and cyfs!='3' "; } if (ckbST.Checked) { sql += " and dateadd(d,3,Convert(datetime,substring(rqrq,1,8)+' '+substring(rqrq,9,8),120))<=Convert(datetime,substring(cqrq,1,8)+' '+substring(cqrq,9,8),120) "; } if (ckbDH.Checked) { sql += " and LEN(lxrdh) = 11 "; //sql += " and (lxrdh not like '133%' and lxrdh not like '149%' and lxrdh not like '153%' and lxrdh not like '173%' and lxrdh not like '174%' and lxrdh not like '177%' and lxrdh not like '180%' and lxrdh not like '181%' and lxrdh not like '189%' and lxrdh not like '199%') "; } DataTable dtRY = BLL.BaseClass.GetTable(sql); total = dtRY.Rows.Count; foreach (DataRow drRY in dtRY.Rows) { DataRow dr = dt.NewRow(); //dr["科室"] = Com.Jpsoft.Hospital.BLL.Ex.ZY_BRSYKEx().GetYY_KSBMKName(Eval("ksdm").ToString()); dr["病人姓名"] = drRY["hzxm"]; dr["住院号"] = drRY["blh"]; dr["电话号码"] = drRY["lxrdh"]; dr["出院时间"] = drRY["cqrq"]; Com.Jpsoft.Hospital.BLL.Ex.jp_followup_recordEx bllRY = new BLL.Ex.jp_followup_recordEx(); string yshfsj = bllRY.GetScsfrq(int.Parse(drRY["blh"].ToString()), 2); string yshfsj1 = bllRY.GetScsfrq1(int.Parse(drRY["blh"].ToString()), 2); string hshfsj = bllRY.GetScsfrq(int.Parse(drRY["blh"].ToString()), 5); string hshfsj1 = bllRY.GetScsfrq1(int.Parse(drRY["blh"].ToString()), 5); if (yshfsj != "无") { ys++; dr["医师有效随访"] = "√"; } if (yshfsj1 != "无") { ysall++; } if (hshfsj != "无") { hs++; dr["护理有效随访"] = "√"; } if (hshfsj1 != "无") { hsall++; } if (yshfsj != "无" || hshfsj != "无") { ks++; dr["科室随访"] = "√"; } dt.Rows.Add(dr); } if (total != 0) { string str = "出院患者总数:{0}。护理随访人数:{1},护理随访率:{2},护理有效随访人数:{3},护理有效随访率:{4}。医生随访人数:{5},医生随访率:{6},医生有效随访人数:{7},医生有效随访率:{8}。科室随访人数:{9},科室有效随访率:{10}。"; str = String.Format(str, total, hsall, ((double)hsall / total).ToString("0.00%"), hs, ((double)hs / total).ToString("0.00%"), ysall, ((double)ysall / total).ToString("0.00%"), ys, ((double)ys / total).ToString("0.00%"), ks, ((double)ks / total).ToString("0.00%")); DataRow drLast = dt.NewRow(); drLast["病人姓名"] = str; dt.Rows.Add(drLast); } if (dt != null) { Session["FileName"] = "医护人员电话随访率"; Session["Report"] = dt; Response.Redirect("Export.ashx"); } else { Response.Write(""); } } protected void btnXls_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.ddlKS.SelectedValue) && txtstart.Text != "" && txtEnd.Text != "") { exportXls(); } else { Response.Write(""); } } } }