/// <summary> /// 获取结果 /// </summary> /// <returns></returns> public DataTable dataRecive_again() { DataTable dt = null; string errMsg = ""; try { string paratime = ""; //开始时间 if (dateTimePicker_start.Checked == true) { paratime = paratime + dateTimePicker_start.Value.ToString("yyyy-MM-dd") + " 00:00:00" + "|"; } //结束时间 if (dateTimePicker_end.Checked == true) { if (paratime.Length > 0) { paratime = paratime + dateTimePicker_end.Value.ToString("yyyy-MM-dd") + " 23:59:59"; } else { paratime = paratime + "|" + dateTimePicker_end.Value.ToString("yyyy-MM-dd") + " 23:59:59"; } } if (paratime.Length == 0) { paratime = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00" + "|"; } //0:获取新数据 1:获取所有数据 paratime = paratime + "|" + "1"; if (yqDemo != null) { if (yqDemo.IsOpen(out errMsg) == false) { yqDemo.open(out errMsg); } dt = yqDemo.YQDataReturn(paratime, out errMsg); } else { if (yqxh.Trim().Length == 0) { timer_lis.Enabled = false; return(null); } if (yqDemo == null) { string yqVersion = XmlRW.GetValueFormXML(Common.getyqPath(yqxh), "YQ_Version", "value"); yqDemo = LisFactory.LisCreate(yqVersion); } if (yqDemo.IsOpen(out errMsg) == false) { yqDemo.open(out errMsg); } dt = yqDemo.YQDataReturn(paratime, out errMsg); } //将取得的结果保存到数据库中 if (dt != null && dt.Rows.Count > 0) { if (!dt.Columns.Contains("yybm")) { DataColumn dtcolumn = new DataColumn("yybm"); dtcolumn.DefaultValue = UserInfo.Yybm; dt.Columns.Add(dtcolumn); } if (!dt.Columns.Contains("yq")) { DataColumn dtcolumn = new DataColumn("yq"); dtcolumn.DefaultValue = timer_lis; dt.Columns.Add(dtcolumn); } //再次处理 //将获得的结果匹配体检表中的心电图的结果 dt = dt_pp(dt); DataTable dt_again = dt.Clone(); DataRow[] dtrow_again = dt.Select(" qf='1'"); if (dtrow_again.Length > 0) { for (int i = 0; i < dtrow_again.Length; i++) { dt_again.ImportRow(dtrow_again[i]); } } //新数据 DataTable dt_new = dt.Clone(); DataRow[] dtrow_new = dt.Select(" qf='2'"); if (dtrow_new.Length > 0) { for (int i = 0; i < dtrow_new.Length; i++) { dt_new.ImportRow(dtrow_new[i]); //置变量,以后不再读取此记录 MedExSqlHelper DBF = new MedExSqlHelper(); DBF.ExecuteNonQuery("update PACS_APPLY set work_status = 1 where PATIENT_ID = '" + dtrow_new[i]["ybh"].ToString() + "'"); } } Form_lisBll form_lisbll = new Form_lisBll(); if (dt_new != null && dt_new.Rows.Count > 0) { form_lisbll.Add(dt, "sql042"); string xmlPath = Common.getyqPath("MECG200"); string YQ_YQtype = XmlRW.GetValueFormXML(xmlPath, "YQ_YQType", "value"); button_save_sys(dt, YQ_YQtype); } if (dt_again != null && dt_again.Rows.Count > 0) { //更新数据 form_lisbll.Upd_all(dt_again, "sql042_update"); string xmlPath = Common.getyqPath("MECG200"); string YQ_YQtype = XmlRW.GetValueFormXML(xmlPath, "YQ_YQType", "value"); //更新数据 button_save_sys_again(dt_again, YQ_YQtype); } } } catch (Exception ex) { timer_lis.Enabled = false; Jktj_lis.msgShow(ex.Message); } return(dt); }
/// <summary> /// 其他通用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_save_sys(DataTable dt_all, string sqlcode) { try { if (dt_all.Rows.Count > 0) { DataRow[] drs = dt_all.Select("xmdh='NAME'"); for (int i = 0; i < drs.Length; i++) { DBAccess dbjkdah = new DBAccess(); DataTable dt_access = dbjkdah.ExecuteQueryBySql(@"select jkdah,sfzh from T_JK_TJRY_TXM where txmbh='" + drs[i]["ybh"].ToString() + "' and yljgbm='" + drs[i]["yybm"].ToString() + "'"); //没有对应的人员信息时直接退出 if (dt_access == null || dt_access.Rows.Count <= 0) { continue; } //更新化验结果表(T_JK_lis_result_re),确定化验结果与人员关系 DataTable dt_update = new DataTable(); //医院编码 dt_update.Columns.Add("yybm"); //仪器编码 dt_update.Columns.Add("yq"); //样本号 dt_update.Columns.Add("ybh"); //体检日期 dt_update.Columns.Add("jyrq"); //健康档案号 dt_update.Columns.Add("testno"); //年度 dt_update.Columns.Add("nd"); dt_update.Rows.Add(); dt_update.AcceptChanges(); dt_update.Rows[0]["yybm"] = UserInfo.Yybm; dt_update.Rows[0]["yq"] = "MECG200"; dt_update.Rows[0]["ybh"] = drs[i]["ybh"].ToString(); dt_update.Rows[0]["jyrq"] = Convert.ToDateTime(drs[i]["jyrq"].ToString()).ToString("yyyy-MM-dd"); //dt_update.Rows[0]["testno"] = dt_access.Rows[0]["jkdah"].ToString(); //对应字段保存样本号 dt_update.Rows[0]["testno"] = drs[i]["ybh"].ToString(); //dt_update.Rows[0]["nd"] = Convert.ToDateTime(jyrq_tem).Year .ToString(); dt_update.Rows[0]["nd"] = DateTime.Now.Year.ToString(); Form_lisBll form_lisbll = new Form_lisBll(); //标本与人员的对应关系保存 form_lisbll.Upd(dt_update, "sql_lis_result_ryxx_update"); //更新体检人员状态表 //form_lisbll.Upd(dt_update, "sql077"); //体检状态信息 ArrayList TJRYXXList = save_T_JK_TJZT(dt_access.Rows[0]["jkdah"].ToString(), dt_access.Rows[0]["sfzh"].ToString(), drs[i]["xmmc"].ToString(), dt_update.Rows[0]["jyrq"].ToString(), Common.TJTYPE.健康体检表, Common.ZT.确定状态); if (TJRYXXList != null && TJRYXXList.Count > 0) { DBAccess dbaccess = new DBAccess(); dbaccess.ExecuteNonQueryBySql(TJRYXXList); } //保存体检结果到体检结果表 string sqlWhere = ""; //医院编码 if (UserInfo.Yybm.Length > 0) { sqlWhere = sqlWhere + string.Format(" and T_JK_lis_result_re.yybm='{0}'", UserInfo.Yybm); } //仪器 if (UserInfo.Yybm.Length > 0) { sqlWhere = sqlWhere + string.Format(" and T_JK_lis_result_re.yq='{0}'", drs[i]["yq"].ToString()); } //检验日期 if (UserInfo.Yybm.Length > 0) { sqlWhere = sqlWhere + string.Format(" and T_JK_lis_result_re.jyrq='{0}'", drs[i]["jyrq"].ToString()); } //样本号 if (UserInfo.Yybm.Length > 0) { sqlWhere = sqlWhere + string.Format(" and T_JK_lis_result_re.ybh='{0}'", drs[i]["ybh"].ToString()); } //取得化验结果 DataTable dt_dyxm = form_lisbll.GetMoHuList(sqlWhere, "sql045"); //更新健康体检表 DataTable dt_tjjgUpdate = new DataTable(); dt_tjjgUpdate.Rows.Add(); for (int j = 0; j < dt_dyxm.Rows.Count; j++) { if (dt_tjjgUpdate.Columns.Contains(dt_dyxm.Rows[j]["HIS_DB"].ToString()) == false) { DataColumn dtColumn = new DataColumn(dt_dyxm.Rows[j]["HIS_DB"].ToString()); dtColumn.DefaultValue = dt_dyxm.Rows[j]["result"].ToString(); dt_tjjgUpdate.Columns.Add(dtColumn); } } if (dt_tjjgUpdate.Columns.Contains("D_GRDABH") == false) { DataColumn dtColumn = new DataColumn("D_GRDABH"); dtColumn.DefaultValue = dt_access.Rows[0]["jkdah"].ToString(); dt_tjjgUpdate.Columns.Add(dtColumn); } if (dt_tjjgUpdate.Columns.Contains("HAPPENTIME") == false) { DataColumn dtColumn = new DataColumn("HAPPENTIME"); dtColumn.DefaultValue = Convert.ToDateTime(drs[i]["jyrq"].ToString()).ToString("yyyy-MM-dd"); dt_tjjgUpdate.Columns.Add(dtColumn); } if (dt_tjjgUpdate.Columns.Contains("czy") == false) { DataColumn dtColumn = new DataColumn("czy"); dtColumn.DefaultValue = UserInfo.userId; dt_tjjgUpdate.Columns.Add(dtColumn); } if (dt_tjjgUpdate.Columns.Contains("gzz") == false) { DataColumn dtColumn = new DataColumn("gzz"); dtColumn.DefaultValue = UserInfo.gzz; dt_tjjgUpdate.Columns.Add(dtColumn); } //体检结果是否已经存在 string Guid = ""; //true:新的Guid false:已经存在的Guid bool GuidResult = true; GuidResult = getNewGuid(dt_access.Rows[0]["jkdah"].ToString(), drs[i]["jyrq"].ToString(), out Guid); if (dt_tjjgUpdate.Columns.Contains("guid") == false) { DataColumn dtColumn = new DataColumn("guid"); dtColumn.DefaultValue = Guid; dt_tjjgUpdate.Columns.Add(dtColumn); } string[] sqllist = sqlcode.Split(new char[] { '|' }); if (sqlcode.Length == 0 || sqllist.Length < 2) { MessageBox.Show("仪器sql设定错误!"); return; } //体检结果 if (GuidResult == true) { //体检结果插入 form_lisbll.Add(dt_tjjgUpdate, sqllist[0]); } else { //体检结果更新 dt_tjjgUpdate.AcceptChanges(); dt_tjjgUpdate.Rows[0]["guid"] = Guid; form_lisbll.Upd(dt_tjjgUpdate, sqllist[1]); } //签名 SaveJktjSignname(drs[i]["jyrq"].ToString(), dt_access.Rows[0]["jkdah"].ToString()); //置变量,以后不再读取此记录 MedExSqlHelper DBF = new MedExSqlHelper(); DBF.ExecuteNonQuery("update PACS_APPLY set work_status = 1 where PATIENT_ID = '" + drs[i]["ybh"].ToString() + "'"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }