Exemplo n.º 1
0
        public void BMPTOJPG(string F_blh, ref string jpgname, string bglx, string bgxh)
        {
            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='" + F_blh + "'", "jcxx");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return;
            }

            ////Çå¿Õc:\tempĿ¼
            if (!System.IO.Directory.Exists(@"c:\temp\" + F_blh))
            {

                System.IO.Directory.CreateDirectory(@"c:\temp\" + F_blh);
            }
            else
            {
                try
                {
                    System.IO.Directory.Delete(@"c:\temp\" + F_blh, true);
                    System.IO.Directory.CreateDirectory(@"c:\temp\" + F_blh);
                }
                catch
                {
                }
            }

       
            DataTable txlb = aa.GetDataTable("select  * from T_tx where F_blh='" + F_blh + "' and F_sfdy='1'", "txlb");
            string txlbs = "";
            string localpath = "";
        
            downtx(F_blh, jcxx.Rows[0]["F_txml"].ToString().Trim(), aa, ref txlbs, ref localpath);
           if (localpath == "")
            {
                jpgname = "";
                return;
            }
            string sbmp = "";
            string stxsm = "";
            if (bgxh == "")
                bgxh = "0";
            string sJPGNAME = localpath + "\\" +F_blh +"_"+bglx+"_"+bgxh+ ".jpg";
           
            if(bglx=="")
               sJPGNAME = localpath + "\\" + F_blh + ".jpg";
           
        
            string sBGGSName = Application.StartupPath.ToString() + "\\rpt\\" + jcxx.Rows[0]["F_bggs"].ToString().Trim() + "-" + txlb.Rows.Count.ToString() + "ͼ.frf";
                 string bcbddytx = f.ReadString("bcbddytx", "bcbddytx", "").Replace("\0", "");
            string inibglj = f.ReadString("dybg", "dybglj", "").Replace("\0", "");
            if (inibglj != "")
            {
           
                sBGGSName = inibglj + "\\rpt\\" + jcxx.Rows[0]["F_bggs"].ToString().Trim() + "-" + txlb.Rows.Count.ToString() + "ͼ.frf";
            }

       
            for (int i = 0; i < txlb.Rows.Count; i++)
            {
                stxsm = stxsm + txlb.Rows[i]["F_txsm"].ToString().Trim() + ",";
                sbmp = sbmp + localpath + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim() + ",";
            }
            if (f.ReadInteger("rpt", "szqm", 0) == 1)
            {
                string bmppath = f.ReadString("mdbmp", "ysbmp", "d:\\pathqc\\rpt\\ysbmp").Replace("\0", "");
                stxsm = stxsm + " ,";
                sbmp = sbmp + bmppath + "\\" + jcxx.Rows[0]["F_shys"].ToString().Trim() + ".bmp,";
                sBGGSName = Application.StartupPath.ToString() + "\\rpt-szqm\\" + jcxx.Rows[0]["F_bggs"].ToString().Trim() + "-" + txlb.Rows.Count.ToString() + "ͼ.frf";
                if (inibglj != "")
                {
                    sBGGSName = inibglj + "\\rpt-szqm\\" + jcxx.Rows[0]["F_bggs"].ToString().Trim() + "-" + txlb.Rows.Count.ToString() + "ͼ.frf";
                }
            }
       

            //±¨¸æͼƬͳһÓò¡ÀíºÅ.jpg
         

            bggs = jcxx.Rows[0]["F_bggs"].ToString().Trim() + "-" + txlb.Rows.Count.ToString() + "ͼ.frf";
            string sSQL_DY = "SELECT * FROM T_JCXX,T_TBS_BG WHERE T_JCXX.F_BLH *= T_TBS_BG.F_BLH AND T_JCXX.F_BLH = '" + F_blh + "'";

            if (bglx == "bd")
            {
                string rptname="±ù¶³.frf";
                if (bcbddytx=="1")
                    rptname = "±ù¶³"+ "-" + txlb.Rows.Count.ToString() + "ͼ.frf";

                sBGGSName = Application.StartupPath.ToString() + "\\rpt\\" + rptname;
                sSQL_DY = "SELECT * FROM T_JCXX,T_BDBG WHERE T_JCXX.F_BLH = T_BDBG.F_BLH AND T_JCXX.F_BLH ='" + F_blh + "' and F_BD_BGXH='" + bgxh + "'";
                bggs = "±ù¶³.frf";
                if (inibglj != "")
                {
                    sBGGSName = inibglj + "\\rpt\\" + rptname;
                }
                sJPGNAME = localpath + "\\" + F_blh.Trim() + "_bd_"+bgxh + ".jpg";
            }
            if (bglx == "bc")
            {

                string rptname = "²¹³ä.frf";
                if (bcbddytx == "1")
                    rptname = "²¹³ä" + "-" + txlb.Rows.Count.ToString() + "ͼ.frf";

                sBGGSName = Application.StartupPath.ToString() + "\\rpt\\" + rptname;

                if (inibglj != "")
                {
                    sBGGSName = inibglj + "\\rpt\\" + rptname;
                }
                sSQL_DY = "SELECT * FROM T_JCXX,T_BCBG WHERE T_JCXX.F_BLH = T_BCBG.F_BLH AND T_JCXX.F_BLH ='" + F_blh + "' and F_BC_BGXH='" + bgxh + "'";
                bggs = "²¹³ä.frf";
                sJPGNAME = localpath + "\\" + F_blh.Trim() + "_bc_" + bgxh + ".jpg";
            }
            System.Threading.Thread.Sleep(2000);
            prreport pr = new prreport();
            //pr.printpdf(sSQL_DY, IntPtr.Zero, sbmp, stxsm, sBGGSName, sJPGNAME);
            pr.print(sSQL_DY, IntPtr.Zero, sbmp, stxsm, sBGGSName, sJPGNAME);
            // sJPGNAME = localpath + "\\" + F_blh.Trim() + ".bmp";
            // pr.print(sSQL_DY, IntPtr.Zero, sbmp, stxsm, sBGGSName, sJPGNAME);
            jpgname = localpath + "\\" + F_blh.Trim() + "_1.jpg";

            System.Threading.Thread.Sleep(2000);
         
           
        }
Exemplo n.º 2
0
        private void stzxyy()
        {
            DataTable bljc = new DataTable();
            DataTable blbd = new DataTable();
            string    brlb = "";

            bljc = aa.GetDataTable("select * from T_jcxx where F_blh='" + blh + "'", "bljc");
            blbd = aa.GetDataTable("select * from T_BDBG where F_blh='" + blh + "' and F_BD_BGZT='已审核'  and  F_BD_BGXH='" + bgxh + "'", "blbd");

            if (bljc == null)
            {
                MessageBox.Show("病理数据库设置有问题!");
                return;
            }
            if (bljc.Rows.Count < 1)
            {
                MessageBox.Show("病理号有错误!");
                return;
            }
            if (bglx == "cg" && dz == "save" && bljc.Rows[0]["F_bgzt"].ToString().Trim() != "已审核")
            {
                if (bljc.Rows[0]["F_BRBH"].ToString().Trim() != "" && bljc.Rows[0]["F_YZXM"].ToString().Trim().Contains("||"))
                {
                    string con_str = f.ReadString("savetohis", "odbcsql", "Data Source=172.16.0.30;Initial Catalog=hisdbstzx;User Id=bl;Password=bl123;");
                    //  MessageBox.Show(bljc.Rows[0]["F_YZXM"].ToString().Trim().Substring(bljc.Rows[0]["F_YZXM"].ToString().LastIndexOf("||")+2));
                    SqlConnection sqlcon = new SqlConnection(con_str);
                    try
                    {
                        sqlcon.Open();
                        SqlCommand sqlcom = new SqlCommand();
                        sqlcom.Connection  = sqlcon;
                        sqlcom.CommandText = "MzInterfacePath_getinfo_Update";
                        sqlcom.CommandType = CommandType.StoredProcedure;

                        sqlcom.Parameters.Add("@p_id", SqlDbType.VarChar, 12);
                        sqlcom.Parameters["@p_id"].Value = bljc.Rows[0]["F_BRBH"].ToString().Trim();

                        sqlcom.Parameters.Add("@jy_sn", SqlDbType.VarChar, 12);
                        sqlcom.Parameters["@jy_sn"].Value = bljc.Rows[0]["F_YZXM"].ToString().Trim().Substring(bljc.Rows[0]["F_YZXM"].ToString().LastIndexOf("||") + 2);

                        sqlcom.ExecuteNonQuery();
                        sqlcon.Close();
                    }
                    catch (Exception ee)
                    {
                        sqlcon.Close();
                        MessageBox.Show("回传his接受标记异常" + ee.ToString());
                        return;
                    }
                }
                return;
            }

            if (bljc.Rows[0]["F_brlb"].ToString().Trim() == "住院")
            {
                brlb = "2";
            }
            if (bljc.Rows[0]["F_brlb"].ToString().Trim() == "门诊")
            {
                brlb = "1";
            }
            if (brlb == "")
            {
                log.WriteMyLog("非住院或门诊病人,不处理!");
                return;
            }



            if (bglx == "bd" && dz == "save")
            {
                //冰冻审核

                if (blbd == null)
                {
                    MessageBox.Show("病理数据库设置有问题!");
                    return;
                }
                if (blbd.Rows.Count < 1)
                {
                    log.WriteMyLog("没有需要上传的病理报告");
                    return;
                }
                //生成冰冻报告,不打图
                string   ftplocal  = f.ReadString("ftp", "ftplocal", "c:\\temp").Replace("\0", "");
                string   sBGGSName = Application.StartupPath.ToString() + "\\rpt\\冰冻.frf";
                string   sJPGNAME  = ftplocal + "\\" + blh.Trim() + "_B_" + blbd.Rows[0]["F_BD_BGXH"].ToString() + ".jpg";
                string   sSQL_DY   = "SELECT * FROM T_JCXX,T_BDBG  WHERE T_JCXX.F_BLH *= T_BDBG.F_BLH AND T_JCXX.F_BLH = '" + blh + "'";
                prreport pr        = new prreport();
                pr.print(sSQL_DY, this.Handle, "", "", sBGGSName, sJPGNAME);
                Image        bgjpg = Image.FromFile(ftplocal + "\\" + blh.Trim() + "_B_" + blbd.Rows[0]["F_BD_BGXH"].ToString() + "_1.jpg");
                MemoryStream ms    = new MemoryStream();
                bgjpg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                byte[] bgbyte = ms.ToArray();
                PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[] hs = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[1];
                hs[0]       = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType();
                hs[0].Value = bgbyte;
                hs[0].Key   = blh.Trim() + "_B_" + blbd.Rows[0]["F_BD_BGXH"].ToString() + ".jpg";

                //调用生成xml字符串子程序
                string xml = sdxml_BD(bljc, blbd, blh.Trim() + "_B_" + blbd.Rows[0]["F_BD_BGXH"].ToString() + ".jpg", brlb);
                if (xml == "")
                {
                    MessageBox.Show(@"部分内容含有非法字符(<,>,@,&,\等),镜下所见和病理诊断除外,HIS写入失败!");
                    return;
                }
                bool sdwstrue  = true;
                bool sdwstrue1 = true;
                bool sdwstrue2 = true;
                bool sdwstrue3 = true;
                int  sdwsint   = 0;
                int  sdwsint1  = 0;

                //调用webservice
                try
                {
                    PathHISJK.Webstzxyy.clsWcfInterface sdws = new PathHISJK.Webstzxyy.clsWcfInterface();
                    string url = f.ReadString("stzxyy", "weburl", "");
                    if (url != "")
                    {
                        sdws.Url = url;
                    }

                    sdws.EHRInterfaceBL(xml, hs, out sdwsint, out sdwstrue, out sdwsint1, out sdwstrue1, out sdwstrue2, out sdwstrue3);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Web服务器未打开!" + e.ToString());
                    return;
                }
                if (sdwsint < 1)
                {
                    MessageBox.Show("HIS写入失败!" + sdwsint.ToString());
                }
                return;
                //------------------------------------------------------------------
            }

            else
            {
                if (bljc.Rows[0]["F_bgzt"].ToString().Trim() != "已审核")
                {
                    return;
                }

                //下载及生成报告图片
                string    ftpserver     = f.ReadString("ftp", "ftpip", "").Replace("\0", "");
                string    ftpuser       = f.ReadString("ftp", "user", "ftpuser").Replace("\0", "");
                string    ftppwd        = f.ReadString("ftp", "pwd", "ftp").Replace("\0", "");
                string    ftplocal      = f.ReadString("ftp", "ftplocal", "c:\\temp").Replace("\0", "");
                string    ftpremotepath = f.ReadString("ftp", "ftpremotepath", "pathimages").Replace("\0", "");
                FtpWeb    fw            = new FtpWeb(ftpserver, ftpremotepath, ftpuser, ftppwd);
                string    txml          = bljc.Rows[0]["F_txml"].ToString().Trim();
                DataTable txlb          = aa.GetDataTable("select * from V_dytx where F_blh='" + blh + "'", "txlb");
                string    sbmp          = "";
                string    stxsm         = "";
                string    sBGGSName     = Application.StartupPath.ToString() + "\\rpt\\" + bljc.Rows[0]["F_bggs"].ToString().Trim() + "-" + txlb.Rows.Count.ToString() + "图.frf";
                string    sJPGNAME      = ftplocal + "\\" + blh.Trim() + ".jpg";
                for (int i = 0; i < txlb.Rows.Count; i++)
                {
                    stxsm = stxsm + txlb.Rows[i]["F_txsm"].ToString().Trim() + ",";
                    string ftpstatus = "";
                    fw.Download(ftplocal, txml + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), txlb.Rows[i]["F_txm"].ToString().Trim(), out ftpstatus);
                    if (ftpstatus == "Error")
                    {
                        return;
                    }
                    sbmp = sbmp + ftplocal + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim() + ",";
                }
                //生成常规报告
                string   sSQL_DY = "SELECT * FROM T_JCXX,T_TBS_BG WHERE T_JCXX.F_BLH *= T_TBS_BG.F_BLH AND T_JCXX.F_BLH = '" + blh + "'";
                prreport pr      = new prreport();
                pr.print(sSQL_DY, this.Handle, sbmp, stxsm, sBGGSName, sJPGNAME);
                Image        bgjpg = Image.FromFile(ftplocal + "\\" + blh.Trim() + "_1.jpg");
                MemoryStream ms    = new MemoryStream();
                bgjpg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                byte[] bgbyte = ms.ToArray();
                PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[] hs = null;// = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[1];

                hs[0]       = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType();
                hs[0].Value = bgbyte;
                hs[0].Key   = blh.Trim() + "_1.jpg";


                /////// 分子病理报告单 2页

                if (File.Exists(ftplocal + "\\" + blh.Trim() + "_2.jpg"))
                {
                    try
                    {
                        log.WriteMyLog("分子病理上传多页报告");
                        PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[] hs2 = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[2];

                        hs2[0]       = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType();
                        hs2[0].Value = bgbyte;
                        hs2[0].Key   = blh.Trim() + "_1.jpg";

                        Image        bgjpg2 = Image.FromFile(ftplocal + "\\" + blh.Trim() + "_2.jpg");
                        MemoryStream ms2    = new MemoryStream();
                        bgjpg2.Save(ms2, System.Drawing.Imaging.ImageFormat.Jpeg);
                        byte[] bgbyte2 = ms2.ToArray();
                        hs2[1]       = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType();
                        hs2[1].Value = bgbyte2;
                        hs2[1].Key   = blh.Trim() + "_2.jpg";
                        hs           = hs2;
                    }
                    catch (Exception ss)
                    {
                        MessageBox.Show(ss.ToString());
                        log.WriteMyLog("分子病理上传多页失败" + ss.ToString());
                    }
                }
                else
                {
                    PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[] hs1 = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[1];
                    hs1[0]       = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType();
                    hs1[0].Value = bgbyte;
                    hs1[0].Key   = blh.Trim() + "_1.jpg";
                    hs           = hs1;
                }
                //PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[] hs = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType[1];
                //hs[0] = new PathHISJK.Webstzxyy.ArrayOfKeyValueOfanyTypeanyTypeKeyValueOfanyTypeanyType();
                //hs[0].Value = bgbyte;
                //hs[0].Key = blh.Trim() + "_1.jpg";
                // hs = hs1;

                //调用生成xml字符串子程序
                string xml = sdxml(bljc, blh.Trim() + "_1.jpg", brlb);

                if (xml == "")
                {
                    MessageBox.Show(@"部分内容含有非法字符(<,>,@,&,\等),镜下所见和病理诊断除外,HIS写入失败!");
                    return;
                }
                bool sdwstrue  = true;
                bool sdwstrue1 = true;
                bool sdwstrue2 = true;
                bool sdwstrue3 = true;
                int  sdwsint   = 0;
                int  sdwsint1  = 0;

                //调用webservice
                try
                {
                    PathHISJK.Webstzxyy.clsWcfInterface sdws = new PathHISJK.Webstzxyy.clsWcfInterface();
                    string url = f.ReadString("stzxyy", "weburl", "");
                    if (url != "")
                    {
                        sdws.Url = url;
                    }
                    sdws.EHRInterfaceBL(xml, hs, out sdwsint, out sdwstrue, out sdwsint1, out sdwstrue1, out sdwstrue2, out sdwstrue3);
                    aa.ExecuteSQL("update T_JCXX set F_SCBJ='1'  where  F_BLH='" + blh + "'");
                }
                catch (Exception e)
                { MessageBox.Show("Web服务器未打开!" + e.ToString());
                  return; }

                if (sdwsint < 1)
                {
                    MessageBox.Show("HIS写入失败!" + sdwsint.ToString());
                }
                return;
            }
            return;
        }