Exemplo n.º 1
0
        /// <summary>
        /// 获取EMR系统的诊断信息
        /// </summary>
        /// <param name="inpatientNo">住院号</param>
        /// <param name="inpatientBANo">病案号</param>
        /// <returns></returns>
        public static DataTable GetEmrDiagnosoisDataTable(string inpatientNo, string inpatientBANo)
        {
            try
            {
                System.Data.DataTable tb = new DataTable();
                TrasenWS.TrasenWS     ws = new TrasenHIS.TrasenWS.TrasenWS();
                string strXml            = "<message msgType=\"call\" msgId=\"1\" timestampCreated=\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\" version=\"1\">" +
                                           "<call timestampCreated=\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\" crfCallMode=\"alwaysRespond\">" +
                                           "<targetLogicService>CIS_GET_DIAGNOSIS</targetLogicService> " +
                                           "<targetLogicApp>HIS</targetLogicApp>" +
                                           "<bizid></bizid>" +
                                           "</call>" +
                                           "<body bodyId=\"1\">" +
                                           "<inhospPatient>" +
                                           "<inhospId>" + Convert.ToInt64(inpatientNo).ToString().Trim() + "</inhospId>" +
                                           "<patientid>" + inpatientBANo + "</patientid>" +
                                           "</inhospPatient>" +
                                           "</body></message>";

                string  returnXml = ws.ExeWebService("GetEmrDiagnosois", strXml);
                DataSet ds        = HisFunctions.ConvertXmlToDataSet(returnXml);
                if (ds.Tables["response"].Rows[0]["code"].ToString() == "0")
                {
                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(returnXml);

                    tb.Columns.Add("code", typeof(System.String));
                    tb.Columns.Add("name", typeof(System.String));
                    XmlNode root = xml.SelectSingleNode("/message/body/outhos");//查找<Employees>
                    if (root.ChildNodes.Count == 0)
                    {
                        root = xml.SelectSingleNode("/message/body/inhos");
                        if (root.ChildNodes.Count > 0)
                        {
                            MessageBox.Show("未获取到出院诊断,但是获取到入院诊断!");
                        }
                    }
                    foreach (XmlNode xn in root.ChildNodes)
                    {
                        System.Data.DataRow r = tb.NewRow();
                        r["code"] = xn.ChildNodes[0].InnerText.Replace("\"", "");
                        r["name"] = xn.ChildNodes[1].InnerText.Replace("\"", "");
                        if (Convertor.IsNull(r["code"], "null").ToLower() == "null" || Convertor.IsNull(r["name"], "null").ToLower() == "null")
                        {
                            continue;
                        }
                        tb.Rows.Add(r);
                    }
                }
                else
                {
                    throw new Exception("获取EMR诊断时出错!错误代码【" + ds.Tables["response"].Rows[0]["code"].ToString() + "】错误描述【" + ds.Tables["response"].Rows[0]["description"].ToString() + "】");
                }
                return(tb);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string xml     = "";
            string xml_old = "";
            string xml_v3  = "";

            xml += "<ROOT>";
            xml += "<ZYH>";
            xml += lblzyh.Text.ToString().Trim();
            xml += "</ZYH>";
            xml += "<CYRQ>";
            xml += this.dateTimePicker1.Text.ToString();
            xml += "</CYRQ>";
            xml += "<CZY>";
            xml += InstanceForm.BCurrentUser.EmployeeId.ToString();
            xml += "</CZY>";
            xml += "</ROOT>";
            TrasenHIS.TrasenWS.TrasenWS ws = new TrasenHIS.TrasenWS.TrasenWS();
            //ws.Url = "http://192.168.0.90:88/TrasenWS.asmx";
            ws.Url = "http://192.168.0.23:89/TrasenWS.asmx";
            try
            {
                xml_old = ws.ExeWebService("Update_oldSys_PatCyrq", xml);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message.ToString());
            }
            try
            {
                xml_v3 = ws.ExeWebService("Update_ThreeSys_PatCyrq", xml);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message.ToString());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 是否未预约
        /// </summary>
        /// <param name="jcNo"></param>
        /// <param name="strMsg"></param>
        /// <returns></returns>
        public static bool HasNotBooked(string jcNo, out string strMsg)
        {
            strMsg = "";

            TrasenWS.TrasenWS ts  = new TrasenHIS.TrasenWS.TrasenWS();
            string            ret = ts.ExeWebService("NewCheckOrder.IsBooked", jcNo);

            //已预约或者预约失败
            if (!ret.Trim().Equals("false"))
            {
                strMsg = ret;
                return(false);
            }

            //未预约
            return(true);
        }
Exemplo n.º 4
0
        public static bool GetOldHISInpatientInfo(string zyh, RelationalDatabase db)
        {
            //Modify By Tany 2015-01-30 如果连接不是正式库,则不验证
            string conn = db.ConnectionString;

            string[] s = conn.Split(';');
            if (s.Length > 0)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i].IndexOf("initial catalog=") >= 0)
                    {
                        if (s[i].Replace("initial catalog=", "").ToLower() != "trasen")
                        {
                            return(true);
                        }
                    }
                }
            }

            InstanceOldHISDb();

            string oldzyh = "";
            string sql    = "";
            string msg    = "";
            string xml    = "";

            try
            {
                if (zyh.Trim() == "")
                {
                    throw new Exception("住院号为空,请检查!");
                }
                oldzyh = Convert.ToInt64(zyh).ToString();
                sql    = @" select a.zyh zyh,b.id as patientid,b.xm xm,b.xb xb,b.rq as csrq,b.jg jg,b.mz mz,
                        b.hk hk,b.zycs zycs,b.zy zy,b.csd csd,b.blh blh,b.gj gj,1 zjlx,b.sfzh sfzh,b.dwmc dwmc,b.dwdz dwdz,
                        b.dwdh dwdh,b.dwyzbm dwyzbm,b.jtdz jtdz,b.jtdh jtdh,b.jtyzbm jtyzbm,b.lxr lxr,b.gx gx,b.lxrdz lxrdz,
                        b.lxrdh lxrdh,b.gfdwbm gfdwbm,b.ylzh ylzh,b.gflb as gflbmc,a.ks as deptid,a.rybq as szbq,
                        a.ryrq as inhostime,a.cyrq as outhostime,a.ryzd ryzd,a.cwh as bedno,a.zrys zrys,'Pat_In' as event
                        from zy_zybrxx a inner join zy_brjbxx b on a.zyh=b.zyh
                        inner join yw_zybrzh AS C on a.zyh=c.zyh 
                        where a.ks not in ('000041','000034','000172') and c.bz='N' and  a.zyh='" + oldzyh + "'";
                DataTable oldPatTb = InFomixDb.GetDataTable(sql);
                if (oldPatTb == null || oldPatTb.Rows.Count == 0)
                {
                    throw new Exception("在老系统未找到住院号为【" + oldzyh + "】的病人信息!");
                }
                else
                {
                    string ss = "在老系统找到病人信息如下:\r\n";
                    ss += "住院号:" + oldPatTb.Rows[0]["zyh"].ToString().Trim() + "\r\n";
                    ss += "姓名:" + oldPatTb.Rows[0]["xm"].ToString().Trim() + "\r\n";
                    ss += "入院日期:" + oldPatTb.Rows[0]["inhostime"].ToString().Trim() + "\r\n";
                    ss += "\r\n请核对病人信息是否正确,以及病人姓名是否乱码(如果是乱码请点否退出操作)\r\n是否继续?";
                    if (MessageBox.Show(ss, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return(false);
                    }
                }

                msg = GetPatMsg(oldPatTb);

                sql = "select * from vi_zy_vinpatient_all where flag<>10 and inpatient_no like '%" + zyh + "%'";
                DataTable newPatTb = db.GetDataTable(sql);

                TrasenWS.TrasenWS ws = new TrasenHIS.TrasenWS.TrasenWS();
                if (newPatTb == null || newPatTb.Rows.Count == 0)
                {
                    //如果没有找到病人信息,则要调用WS获取
                    xml = ws.ExeWebService("SaveInpatient", msg);
                    DataSet dset = HisFunctions.ConvertXmlToDataSet(xml);
                    if (dset.Tables["HEAD"].Rows.Count > 0)
                    {
                        if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "-1")
                        {
                            throw new Exception("调用WS保存病人信息时出现错误,消息格式:" + msg);
                        }
                        else if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "0")
                        {
                            MessageBox.Show("同步成功,请刷新病人列表!");
                        }
                    }
                }
                else
                {
                    //如果有病人信息,也调用WS Add By Tany 2015-02-11
                    ws.ExeWebService("SaveInpatient", msg);//只是调用,不管结果

                    //如果找到了,则需要验证新老系统病人一致性
                    sql = "select deptid from vi_zy_newhishsz where deptid=" + newPatTb.Rows[0]["dept_id"].ToString();
                    DataTable hszTb = db.GetDataTable(sql);
                    if (hszTb != null && hszTb.Rows.Count > 0)
                    {
                        //throw new Exception("该病人已经在上了新护士站的科室,请以新系统的数据为准!");
                        //如果上了新系统,则调用检查病人信息
                        if (CheckPatientInfo.Check(newPatTb.Rows[0]["inpatient_no"].ToString(), db))
                        {
                            MessageBox.Show("同步到老系统成功,请在老系统中检查病人信息!");
                        }
                    }
                    string oldKs = HisFunctions.ConvertOldhisidToNewHisid(HisFunctions.DataMapType.JC_DEPT_PROPERTY, oldPatTb.Rows[0]["deptid"].ToString().Trim(), db);
                    if (oldKs == "")
                    {
                        throw new Exception("未找到该科室[" + oldPatTb.Rows[0]["deptid"].ToString().Trim() + "]对应的科室信息!");
                    }
                    string oldCwh = oldPatTb.Rows[0]["bedno"].ToString().Trim();

                    //如果老系统科室和新系统不一样,则调用老系统到新系统的转科事件
                    if (oldKs != newPatTb.Rows[0]["dept_id"].ToString())
                    {
                        MessageBox.Show("该病人在新系统中的科室与老系统的科室不符,系统将尝试修复新系统数据!\r\n\r\n点击确定后将继续操作......", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        xml = ws.ExeWebService("TransDept", msg);
                        DataSet dset = HisFunctions.ConvertXmlToDataSet(xml);
                        if (dset.Tables["HEAD"].Rows.Count > 0)
                        {
                            if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "-1")
                            {
                                throw new Exception("调用WS病人转科时出现错误,消息格式:" + msg);
                            }
                            else if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "0")
                            {
                                MessageBox.Show("同步成功,请刷新病人列表!");
                            }
                        }
                    }
                    else if (oldCwh != "" && oldCwh != newPatTb.Rows[0]["bed_no"].ToString())
                    {
                        //如果床位不同,则调用转床
                        MessageBox.Show("该病人在新系统中的床位与老系统的床位不符,系统将尝试修复新系统数据!\r\n\r\n点击确定后将继续操作......", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        xml = ws.ExeWebService("ChangeBed", msg);
                        DataSet dset = HisFunctions.ConvertXmlToDataSet(xml);
                        if (dset.Tables["HEAD"].Rows.Count > 0)
                        {
                            if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "-1")
                            {
                                throw new Exception("调用WS病人转床时出现错误,消息格式:" + msg);
                            }
                            else if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "0")
                            {
                                MessageBox.Show("同步成功,请刷新病人列表!");
                            }
                        }
                    }
                }

                try
                {
                    //调用一下EMR的方法 Modify By Tany 2016-01-20
                    sql = "select inpatient_id from zy_inpatient where flag<>10 and inpatient_no like '%" + zyh + "%'";
                    msg = ws.GetXml("n2oFpcw.EMR", Convertor.IsNull(db.GetDataResult(sql), Guid.Empty.ToString()));
                    xml = ws.ExeWebService("n2oFpcw.EMR", msg);

                    MessageBox.Show("同步EMR成功,请刷新EMR病人信息!");
                }
                catch
                {
                    throw new Exception("同步EMR时出错,请手工同步!");
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 检查并修正病人信息
        /// </summary>
        /// <param name="zyh"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static bool Check(string zyh, RelationalDatabase db)
        {
            //Modify By Tany 2015-01-30 如果连接不是正式库,则不验证
            string conn = db.ConnectionString;

            string[] s = conn.Split(';');
            if (s.Length > 0)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i].IndexOf("initial catalog=") >= 0)
                    {
                        if (s[i].Replace("initial catalog=", "").ToLower() != "trasen")
                        {
                            return(true);
                        }
                    }
                }
            }

            InstanceOldHISDb();

            string oldzyh = "";
            string sql    = "";

            try
            {
                if (zyh.Trim() == "")
                {
                    throw new Exception("住院号为空,请检查!");
                }
                oldzyh = Convert.ToInt64(zyh).ToString();
                sql    = "select * from vi_zy_vinpatient_all where flag<>10 and inpatient_no='" + zyh + "' and dept_id in (select deptid from vi_zy_newhishsz)";
                DataTable newPatTb = db.GetDataTable(sql);
                //上线新护士站的病人才进行验证
                if (newPatTb != null && newPatTb.Rows.Count > 0)
                {
                    sql = "select * from zy_zybrxx where zyh='" + oldzyh + "'";
                    DataTable oldPatTb = InFomixDb.GetDataTable(sql);
                    if (oldPatTb == null || oldPatTb.Rows.Count == 0)
                    {
                        throw new Exception("在老系统未找到住院号为【" + oldzyh + "】的病人!");
                    }
                    string oldKs = HisFunctions.ConvertOldhisidToNewHisid(HisFunctions.DataMapType.JC_DEPT_PROPERTY, oldPatTb.Rows[0]["ks"].ToString().Trim(), db);
                    if (oldKs == "")
                    {
                        throw new Exception("未找到该科室[" + oldPatTb.Rows[0]["ks"].ToString().Trim() + "]对应的科室信息!");
                    }
                    string oldCwh = oldPatTb.Rows[0]["cwh"].ToString().Trim();

                    bool isTs = false;
                    //如果老系统科室和新系统不一样,则调用新系统到老系统的转科事件
                    if (oldKs != newPatTb.Rows[0]["dept_id"].ToString())
                    {
                        isTs = true;
                        MessageBox.Show("该病人在新系统中的科室与老系统的科室不符,系统将尝试修复老系统数据!\r\n\r\n点击确定后将继续操作......", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        //不能调用转科WS,只能直接更新数据
                        string _ks = HisFunctions.ConvertNewhisidToOldHisid(HisFunctions.DataMapType.JC_DEPT_PROPERTY, newPatTb.Rows[0]["dept_id"].ToString(), db);;
                        sql = "SELECT BQ FROM zy_bqksdzb Where KS = '" + _ks + "'";
                        string _bq = Convertor.IsNull(InFomixDb.GetDataResult(sql), "");

                        System.Data.Odbc.OdbcConnection  connection = new System.Data.Odbc.OdbcConnection(DAL.BaseDal.oldhis_constr);
                        System.Data.Odbc.OdbcTransaction tx         = null;
                        System.Data.Odbc.OdbcCommand     cmd        = new System.Data.Odbc.OdbcCommand();
                        try
                        {
                            connection.Open();
                            cmd.Connection  = connection;
                            tx              = connection.BeginTransaction();
                            cmd.Transaction = tx;

                            //清空老床位信息
                            sql             = "UPDATE ZY_CWXX Set zyh = '',xm = '',APZ = '',ZT = '空闲' Where zyh = '" + oldzyh + "'";
                            cmd.CommandText = sql;
                            cmd.ExecuteNonQuery();

                            //更新病人信息
                            sql             = "UPDATE ZY_ZYBRXX SET CWH='',BQ='" + _bq + "',ks='" + _ks + "',bf='',sfapcw='N' WHERE ZYH='" + oldzyh + "'";
                            cmd.CommandText = sql;
                            cmd.ExecuteNonQuery();

                            tx.Commit();
                        }
                        catch (Exception err)
                        {
                            tx.Rollback();
                            throw err;
                        }
                        finally
                        {
                            cmd.Dispose();
                            connection.Close();
                        }
                    }
                    //这里需要在检查一下这个病人的床位号如果不为空的情况下,在老系统床位表上是不是有信息 Modify By Tany 2015-01-22
                    string cwZyh = "";
                    if (oldCwh != "")
                    {
                        sql   = "select zyh from zy_cwxx where ks='" + oldPatTb.Rows[0]["ks"].ToString() + "' and cwh='" + oldCwh + "'";
                        cwZyh = Convertor.IsNull(InFomixDb.GetDataResult(sql), "");
                    }
                    //如果老系统科室和新系统或者床位不一样,则调用新系统到老系统的转床事件
                    //if (oldKs != newPatTb.Rows[0]["dept_id"].ToString() || oldCwh != newPatTb.Rows[0]["bed_no"].ToString() || cwZyh != oldzyh)
                    //Modify By Tany 2015-05-05 修正这里的判断,因为新老系统床位名称可能不一致,判断床位的时候,需要通过对应关系去验证床号是否正确
                    string   mapCwh = HisFunctions.ConvertNewhisidToOldHisid(HisFunctions.DataMapType.ZY_BEDDICTION, newPatTb.Rows[0]["bed_id"].ToString(), db);
                    string[] ss     = mapCwh.Replace("||", "|").Split("|".ToCharArray());
                    if (ss.Length > 1)
                    {
                        mapCwh = ss[1];
                    }
                    if (oldKs != newPatTb.Rows[0]["dept_id"].ToString() || oldCwh != mapCwh || cwZyh != oldzyh)
                    {
                        if (!isTs)
                        {
                            isTs = true;
                            MessageBox.Show("该病人在新系统中的床位与老系统的床位不符,系统将尝试修复老系统数据!\r\n\r\n点击确定后将继续操作......", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        TrasenWS.TrasenWS ws     = new TrasenHIS.TrasenWS.TrasenWS();
                        string            strXML = "";
                        strXML = ws.GetXml("n2oZc.HIS", newPatTb.Rows[0]["inpatient_id"].ToString());
                        strXML = ws.ExeWebService("n2oZc.HIS", strXML);
                        DataSet dset = HisFunctions.ConvertXmlToDataSet(strXML);
                        if (dset.Tables["HEAD"].Rows.Count > 0)
                        {
                            if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "-1")
                            {
                                throw new Exception("调用WS转床时出现错误:" + dset.Tables["HEAD"].Rows[0]["ERRTEXT"].ToString());
                            }
                        }
                    }
                    if (isTs)
                    {
                        MessageBox.Show("老系统数据修复完成,将继续完成您的操作!");
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("检查新老系统病人状态时出错,您的操作将不能继续!\r\n\r\n" + ex.Message);
                return(false);
            }
        }
Exemplo n.º 6
0
        //Add By Tany 2016-04-13
        /// <summary>
        ///  检查病人老系统是否结算,如果老系统结算新系统未结算,则同步调用结算方法
        /// </summary>
        /// <param name="zyh">住院号</param>
        /// <param name="db">新系统数据库连接</param>
        public static void CheckPatJszt(string zyh, RelationalDatabase db)
        {
            try
            {
                InstanceOldHISDb();

                bool iscyjs = false;

                string    sql = "select * from yw_zybrzh where zyh='" + Convert.ToInt64(zyh) + "'";
                DataTable tb  = InFomixDb.GetDataTable(sql);
                if (tb != null && tb.Rows.Count > 0)
                {
                    if (Convertor.IsNull(tb.Rows[0]["bz"], "").ToUpper() == "Y")
                    {
                        iscyjs = true;
                    }
                }
                if (!iscyjs)
                {
                    MessageBox.Show("住院号【" + zyh + "】的病人在老系统还未结算!");
                    return;
                }
                else
                {
                    sql = "select * from vi_zy_vinpatient_all where convert(bigint,inpatient_no)='" + Convert.ToInt64(zyh) + "'";
                    tb  = db.GetDataTable(sql);
                    if (tb == null || tb.Rows.Count == 0)
                    {
                        MessageBox.Show("住院号【" + zyh + "】的病人在新系统未找到信息!");
                        return;
                    }
                    int flag = Convert.ToInt32(tb.Rows[0]["flag"]);
                    if (flag == 2 || flag == 6)
                    {
                        MessageBox.Show("住院号【" + zyh + "】的病人在新系统已经结算!");
                        return;
                    }
                    else
                    {
                        //调用WS同步结算状态
                        string xml = "";
                        sql = "select zyh,id as patientid,xm,zt as jszt,jsdjh,cyrq,ryrq as ksrq,jsrq,0 as yjj,zfy as ylzfy,gfje as ybzf,zfje,djrq,czy as djybm from v_brfy where zyh='" + Convert.ToInt64(zyh) + "'";
                        tb  = InFomixDb.GetDataTable(sql);
                        if (tb != null && tb.Rows.Count > 0)
                        {
                            xml = ConvertToXML.DataTableToXmlEx(tb, "message");
                            TrasenWS.TrasenWS ws     = new TrasenHIS.TrasenWS.TrasenWS();
                            string            strXML = "";
                            strXML = ws.ExeWebService("SaveCyzt", xml);
                            DataSet dset = HisFunctions.ConvertXmlToDataSet(strXML);
                            if (dset.Tables["HEAD"].Rows.Count > 0)
                            {
                                if (dset.Tables["HEAD"].Rows[0]["ERRCODE"].ToString() == "-1")
                                {
                                    throw new Exception("调用WS出院结算时出现错误:" + dset.Tables["HEAD"].Rows[0]["ERRTEXT"].ToString());
                                }
                            }
                            MessageBox.Show("同步结算状态成功,请继续您的操作!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }