public void pathtoTJ(string blh, string bglx, string bgxh, DataTable jcxx, string debug) { ////增加体检回写接口/////zgq if (jcxx.Rows[0]["F_BRLB"].ToString().Trim() == "体检" && jcxx.Rows[0]["F_brbh"].ToString().Trim() == "体检") { // 生成pdf string err_msg = ""; string constr = f.ReadString("savetohis", "tj_odbcsql", "Data Source=192.168.90.236;Initial Catalog=tj_xlms;User Id=xlmsuser;Password=topsky;"); SqlDB db = new SqlDB(); if (jcxx.Rows[0]["F_BGZT"].ToString().Trim() == "已审核") { string ML = DateTime.Parse(jcxx.Rows[0]["F_SDRQ"].ToString()).ToString("yyyyMM"); string jpgname = ""; string jpgpath = ""; //生成jpg bool isrtn = MD_PDF_JPG(blh, bglx, bgxh, ML, ZgqPDFJPG.Type.JPG, ref err_msg, ref jpgname, ref jpgpath); if (isrtn) { jpgname = jpgname.Substring(jpgname.LastIndexOf('\\') + 1); ZgqClass.BGHJ(blh, "体检接口", "审核", "生成jpg成功:" + ML + "\\" + jpgname, "ZGQJK", "jpg"); aa.ExecuteSQL("delete T_BG_PDF where F_BLH='" + blh + "' and F_BGLX='" + bglx + "' and F_BGXH='" + bgxh + "'"); aa.ExecuteSQL("insert into T_BG_PDF(F_BLH,F_BGLX,F_BGXH,F_ML,F_FILENAME) values('" + blh + "','" + bglx + "','" + bgxh + "','" + jpgpath + "','" + jpgname + "')"); } else { log.WriteMyLog(blh + "-" + err_msg); ZgqClass.BGHJ(blh, "体检接口", "审核", "生成jpg失败" + err_msg, "ZGQJK", "jpg"); if (debug == "1") { MessageBox.Show("病理号:" + blh + " 生成jpg失败,请重新审核!\r\n" + err_msg); } // return; } # region 回传体检报告 DataTable TJ_bljc = new DataTable(); TJ_bljc = aa.GetDataTable(" select top 1 * from T_TBS_BG where F_blh='" + blh + "'", "blxx"); // 诊断描述 string Res_char = jcxx.Rows[0]["F_jxsj"].ToString().Trim(); //诊断结论 Res_con string Res_con = jcxx.Rows[0]["F_blzd"].ToString().Trim(); if (TJ_bljc.Rows.Count > 0) { if (jcxx.Rows[0]["F_blk"].ToString().Trim().Contains("TCT")) { Res_char = Res_char + "标本满意度:" + TJ_bljc.Rows[0]["F_TBS_BBMYD"].ToString().Trim() + "\r\n"; Res_char = Res_char + TJ_bljc.Rows[0]["F_TBS_XBL"].ToString().Trim() + "\r\n" + TJ_bljc.Rows[0]["F_TBS_XBXM1"].ToString().Trim() + "\r\n" + TJ_bljc.Rows[0]["F_TBS_XBXM2"].ToString().Trim() + "\r\n" + TJ_bljc.Rows[0]["F_TBS_XBXM3"].ToString().Trim() + "\r\n病原微生物:" + TJ_bljc.Rows[0]["F_TBS_WSW2"].ToString().Trim() + "\r\n" + TJ_bljc.Rows[0]["F_TBS_WSW1"].ToString().Trim() + "\r\n" + TJ_bljc.Rows[0]["F_TBS_WSW3"].ToString().Trim() + "\r\n" + TJ_bljc.Rows[0]["F_TBS_BDXM1"].ToString().Trim() + "\r\n"; Res_char = Res_char + "炎症程度:" + TJ_bljc.Rows[0]["F_TBS_YZCD"].ToString().Trim() + "\r\n"; ///////////诊断///////////////////////// Res_con = "诊断:" + TJ_bljc.Rows[0]["F_TBSZD"].ToString().Trim() + "\r\n" + "\r\n"; if (TJ_bljc.Rows[0]["F_TBS_BCYJ1"].ToString().Trim() != "") { Res_con = Res_con + "补充意见:" + TJ_bljc.Rows[0]["F_TBS_BCYJ1"].ToString().Trim() + "\r\n"; } } } ///////////////////////////////////////////////////// string path = f.ReadString("savetohis", "jpgpath", @"\\192.10.33.84\pdfbg\"); jpgpath = path + jpgpath + "\\" + jpgname; string sql_insert = "insert into tj_pacsjgb(Djlsh,Zhxmbh,jg,jcsj,Jl,shr,Shrq,Tpzt,jcqkfzsm,Tplj,czy,Sysdatetime,Jkid,flag)" + " values('" + jcxx.Rows[0]["F_MZH"].ToString().Trim() + "','" + jcxx.Rows[0]["F_YZID"].ToString().Trim() + "','" + Res_con + "','" + Res_char + "','','" + jcxx.Rows[0]["F_SHYS"].ToString().Trim() + "','" + jcxx.Rows[0]["F_spare5"].ToString().Trim() + "','1','病理检查','" + jpgpath + ";','" + jcxx.Rows[0]["F_bgYS"].ToString().Trim() + "','" + DateTime.Now + "',2,'0')"; string sql_del = "delete from tj_pacsjgb where Djlsh='" + jcxx.Rows[0]["F_MZH"].ToString().Trim() + "' and Zhxmbh='" + jcxx.Rows[0]["F_YZID"].ToString().Trim() + "' and jcqkfzsm='病理检查'"; //删除 if (debug == "1") { log.WriteMyLog("删除体检表,语句:" + sql_del); } int x = db.ExecuteNonQuery(constr, sql_del, ref err_msg); if (debug == "1") { log.WriteMyLog("删除体检表:" + err_msg + "@" + x.ToString()); } if (debug == "1") { log.WriteMyLog("回写体检表,语句:" + sql_insert); } //插入 x = db.ExecuteNonQuery(constr, sql_insert, ref err_msg); if (debug == "1") { log.WriteMyLog("回写体检表:" + err_msg + "@" + x.ToString()); } if (x < 0) { ZgqClass.BGHJ(blh, "体检接口", "审核", "回写体检报告失败:" + err_msg, "ZGQJK", "体检接口"); log.WriteMyLog(blh + "-" + err_msg); if (debug == "1") { MessageBox.Show("病理号:" + blh + "-回写体检报告失败,请重新审核!\r\n" + err_msg); } } else { ZgqClass.BGHJ(blh, "体检接口", "审核", "回写体检报告成功", "ZGQJK", "体检接口"); aa.ExecuteSQL("update T_JCXX set F_TJBJ='2' where F_BLH='" + blh + "'"); if (debug == "1") { MessageBox.Show("病理号:" + blh + "-回写体检报告成功"); } } return; #endregion } else { if (jcxx.Rows[0]["F_TJBJ"].ToString().Trim() == "2") { DataTable dt2 = aa.GetDataTable("select top 1 * from T_BG_PDF where F_blh='" + blh + "' and F_BGXH='" + bgxh + "' and F_BGLX='" + bglx + "'", "dt2"); if (dt2.Rows.Count > 0) { aa.ExecuteSQL("delete T_BG_PDF where F_BLH='" + blh + "' and F_BGLX='" + bglx + "' and F_BGXH='" + bgxh + "'"); //删除ftp上pdf文件 ZgqPDFJPG zgq = new ZgqPDFJPG(); string rtn_msg = ""; zgq.DelPDFFile(dt2.Rows[0]["F_ML"].ToString(), dt2.Rows[0]["F_FILENAME"].ToString(), ref rtn_msg); } string sql_del = "delete from tj_pacsjgb where Djlsh='" + jcxx.Rows[0]["F_MZH"].ToString().Trim() + "' and Zhxmbh='" + jcxx.Rows[0]["F_YZID"].ToString().Trim() + "' and jcqkfzsm='病理检查'"; //删除 if (debug == "1") { log.WriteMyLog("删除体检表,语句:" + sql_del); } int x = db.ExecuteNonQuery(constr, sql_del, ref err_msg); if (debug == "1") { log.WriteMyLog("删除体检表:" + err_msg + "@" + x.ToString()); } return; } } }
/// <summary> /// 生成PDF文件并上传表 /// </summary> /// <param name="cgbcbd"></param> /// <param name="sqlcmd"></param> private void scpdf(string F_blh, string cgbcbd, SqlCommand sqlcmd, string bgxh, string debug, DataTable jcxx, SqlConnection sqlcon, dbbase.odbcdb aa) { #region 生成pdf读入二进制流 string pdfname = ""; try { string message = ""; ZgqPDFJPG zgq = new ZgqPDFJPG(); bool isrtn = zgq.CreatePDF(F_blh, cgbcbd, bgxh, ZgqPDFJPG.Type.PDF, ref message, ref pdfname); if (!isrtn) { log.WriteMyLog(F_blh + "^" + cgbcbd + "^" + bgxh + ",生成PDF失败:" + message); aa.ExecuteSQL("update T_jcxx_fs_sm set F_bz='生成PDF失败:" + message + "' where F_blh='" + F_blh + "' and F_BGLX='" + cgbcbd.ToLower() + "' and F_BGXH='" + bgxh + "' and F_BGZT='已审核'"); return; } //二进制串 if (!File.Exists(pdfname)) { log.WriteMyLog("未查询到pdf文件" + pdfname); aa.ExecuteSQL("update T_jcxx_fs_sm set F_bz='未查询到pdf文件" + pdfname + "' where F_blh='" + F_blh + "' and F_BGLX='" + cgbcbd.ToLower() + "' and F_BGXH='" + bgxh + "' and F_BGZT='已审核'"); return; } FileStream fs = null; try { fs = new FileStream(pdfname, FileMode.Open, FileAccess.Read); Byte[] image = new Byte[fs.Length]; fs.Read(image, 0, image.Length); fs.Close(); //2016-03-11 string insertsql = "insert into BLBGPDF(blh,bglx,bgxh,patientid,pdf,sdrq,patientname,bbmc,hospitalid,blk)values(@blh,@bglx,@bgxh,@patientid,@pdf,@sdrq,@patientname,@bbmc,@hospitalid,@blk)"; try { if (debug == "1") { log.WriteMyLog(insertsql); } sqlcmd.CommandText = insertsql; sqlcmd.Parameters.Add("@blh", SqlDbType.VarChar); sqlcmd.Parameters.Add("@bglx", SqlDbType.VarChar); sqlcmd.Parameters.Add("@bgxh", SqlDbType.VarChar); sqlcmd.Parameters.Add("@patientid", SqlDbType.VarChar); sqlcmd.Parameters.Add("@pdf", SqlDbType.Binary); sqlcmd.Parameters.Add("@sdrq", SqlDbType.VarChar); sqlcmd.Parameters.Add("@patientname", SqlDbType.NVarChar); sqlcmd.Parameters.Add("@bbmc", SqlDbType.NVarChar); sqlcmd.Parameters.Add("@hospitalid", SqlDbType.VarChar); sqlcmd.Parameters.Add("@blk", SqlDbType.NVarChar); sqlcmd.Parameters["@blh"].Value = F_blh; sqlcmd.Parameters["@bglx"].Value = cgbcbd; sqlcmd.Parameters["@bgxh"].Value = bgxh; sqlcmd.Parameters["@patientid"].Value = jcxx.Rows[0]["F_MZH"].ToString().Trim() + jcxx.Rows[0]["F_ZYH"].ToString().Trim(); sqlcmd.Parameters["@pdf"].Value = image; sqlcmd.Parameters["@sdrq"].Value = jcxx.Rows[0]["F_SDRQ"].ToString().Trim(); sqlcmd.Parameters["@patientname"].Value = jcxx.Rows[0]["F_XM"].ToString().Trim(); sqlcmd.Parameters["@BBMC"].Value = jcxx.Rows[0]["F_BBMC"].ToString().Trim(); if (jcxx.Rows[0]["F_BLK"].ToString().Trim().Contains("路桥")) { sqlcmd.Parameters["@hospitalid"].Value = "5760003"; } else { sqlcmd.Parameters["@hospitalid"].Value = szz(aa, "hospitalid").Trim(); } sqlcmd.Parameters["@blk"].Value = jcxx.Rows[0]["F_BLK"].ToString().Trim(); int count = sqlcmd.ExecuteNonQuery();//执行存储过程 if (count > 0) { aa.ExecuteSQL("update T_jcxx_fs_sm set F_bz='',F_ISPDF='true',F_fszt='已处理',f_fssj='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where F_blh='" + F_blh + "' and F_BGLX='" + cgbcbd + "' and F_BGXH='" + bgxh + "' and F_BGZT='已审核'"); if (debug == "1") { log.WriteMyLog(F_blh + "PDF报告上传成功!"); } if (cgbcbd == "cg" && (jcxx.Rows[0]["F_ZYH"].ToString().Trim() != "" || jcxx.Rows[0]["F_brlb"].ToString().Trim() == "住院")) { aa.ExecuteSQL("update t_jcxx set f_sfdy='是' where f_blh='" + F_blh + "'"); aa.ExecuteSQL("insert into t_bghj(f_blh,f_rq,f_czy,f_wz,f_dz,f_nr,f_exemc,f_ctmc)values('" + F_blh + "','" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "','" + f.ReadString("yh", "yhmc", "").ToString().Trim() + "','" + System.Net.Dns.GetHostName() + "','打印','" + cgbcbd + "报告" + bgxh + "发送到临床','RPT','打印或批量打印')"); } if (cgbcbd == "bc" && (jcxx.Rows[0]["F_ZYH"].ToString().Trim() != "" || jcxx.Rows[0]["F_brlb"].ToString().Trim() == "住院")) { aa.ExecuteSQL("update t_bcbg set f_bc_dyzt='是' where f_blh='" + F_blh + "' and f_bc_bgxh='" + bgxh + "'"); aa.ExecuteSQL("insert into t_bghj(f_blh,f_rq,f_czy,f_wz,f_dz,f_nr,f_exemc,f_ctmc)values('" + F_blh + "','" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "','" + f.ReadString("yh", "yhmc", "").ToString().Trim() + "','" + System.Net.Dns.GetHostName() + "','打印','" + cgbcbd + "报告" + bgxh + "发送到临床','RPT','打印或批量打印')"); } if (cgbcbd == "bd" && (jcxx.Rows[0]["F_ZYH"].ToString().Trim() != "" || jcxx.Rows[0]["F_brlb"].ToString().Trim() == "住院")) { aa.ExecuteSQL("update t_bdbg set f_bd_dyzt='是' where f_blh='" + F_blh + "' and f_bd_bgxh='" + bgxh + "'"); aa.ExecuteSQL("insert into t_bghj(f_blh,f_rq,f_czy,f_wz,f_dz,f_nr,f_exemc,f_ctmc)values('" + F_blh + "','" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "','" + f.ReadString("yh", "yhmc", "").ToString().Trim() + "','" + System.Net.Dns.GetHostName() + "','打印','" + cgbcbd + "报告" + bgxh + "发送到临床','RPT','打印或批量打印')"); } } else { log.WriteMyLog(F_blh + "回传PDF文件不成功!"); aa.ExecuteSQL("update T_jcxx_fs_sm set F_bz='回传PDF文件不成功' where F_blh='" + F_blh + "' and F_BGLX='" + cgbcbd + "' and F_BGXH='" + bgxh + "' and F_BGZT='已审核'"); } } catch (Exception e) { log.WriteMyLog("回写数据异常:" + e.Message.ToString()); aa.ExecuteSQL("update T_jcxx_fs_sm set F_bz='回写数据异常:" + e.Message.ToString() + "' where F_blh='" + F_blh + "' and F_BGLX='" + cgbcbd + "' and F_BGXH='" + bgxh + "' and F_BGZT='已审核'"); } } catch (Exception e2) { log.WriteMyLog("读取PDF异常:" + e2.Message.ToString()); aa.ExecuteSQL("update T_jcxx_fs_sm set F_bz='读取PDF异常:" + e2.Message.ToString() + "' where F_blh='" + F_blh + "' and F_BGLX='" + cgbcbd + "' and F_BGXH='" + bgxh + "' and F_BGZT='已审核'"); } finally { fs.Close(); } if (szz(aa, "scpdf") == "1") { if (System.IO.Directory.Exists(@"c:\temp\" + F_blh)) { System.IO.Directory.Delete(@"c:\temp\" + F_blh, true); } } } catch (Exception e3) { log.WriteMyLog("接口程序异常:" + e3.Message.ToString()); aa.ExecuteSQL("update T_jcxx_fs_sm set F_bz='接口程序异常:" + e3.Message.ToString() + "' where F_blh='" + F_blh + "' and F_BGLX='" + cgbcbd + "' and F_BGXH='" + bgxh + "' and F_BGZT='已审核'"); return; } #endregion }
public void pathtohis(string blh, string bglx, string bgxh, string msg1, string debug1, string[] cslb) { msg = msg1; string qxsh = ""; string xdj = ""; bglx = bglx.ToLower(); if (cslb.Length == 5) { if (cslb[4].ToLower() == "qxsh") { qxsh = "1"; //取消审核动作 } if (cslb[3].ToLower() == "new") { xdj = "1"; } } dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); DataTable jcxx = new DataTable(); try { jcxx = aa.GetDataTable("select * from T_jcxx where F_blh='" + blh + "'", "jcxx"); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); return; } if (jcxx == null) { MessageBox.Show("病理数据库设置有问题!"); return; } if (jcxx.Rows.Count < 1) { MessageBox.Show("病理号有错误!"); return; } //if (jcxx.Rows[0]["F_SQXH"].ToString().Trim()=="") //{ // LGZGQClass.log.WriteMyLog("无申请序号,不会写"); // return; //} string bgzt = jcxx.Rows[0]["F_BGZT"].ToString().Trim(); if (qxsh == "1") { bgzt = "取消审核"; } int plsc = f.ReadInteger("fsjk", "plsc", 0); string CZY = f.ReadString("yh", "yhmc", "").Replace("\0", "").Trim(); string CZYGH = f.ReadString("yh", "yhbh", "").Replace("\0", "").Trim(); string brbh = jcxx.Rows[0]["F_BRBH"].ToString().Trim(); string brlb = jcxx.Rows[0]["F_brlb"].ToString().Trim(); string sqxh = jcxx.Rows[0]["F_SQXH"].ToString().Trim(); if (brlb == "住院") { brlb = "I"; } else { brlb = "O"; } string ZYH = jcxx.Rows[0]["F_MZH"].ToString().Trim(); if (brlb == "I") { ZYH = jcxx.Rows[0]["F_ZYH"].ToString().Trim(); } string SFZH = jcxx.Rows[0]["F_SFZH"].ToString().Trim(); string XM = jcxx.Rows[0]["F_XM"].ToString().Trim(); string SJKS = jcxx.Rows[0]["F_BQ"].ToString().Trim(); string CH = jcxx.Rows[0]["F_CH"].ToString().Trim(); string YZXM = jcxx.Rows[0]["F_YZXM"].ToString().Trim(); string ML = DateTime.Parse(jcxx.Rows[0]["F_SDRQ"].ToString()).ToString("yyyyMM"); string message = ""; string jpgname = ""; ZgqPDFJPG zgq = new ZgqPDFJPG(); bool ispdf = zgq.CreatePDF(blh, bglx, bgxh, ZgqPDFJPG.Type.PDF, ref jpgname, "", ref message); return; }