public static bool GetEmrDiagnosis(string inpNo, out string strMsg) { strMsg = ""; try { TrasenWS.TrasenWS ws = new TrasenHIS.TrasenWS.TrasenWS(); ws.Url = "http://192.168.0.90:88/TrasenWS.asmx"; strMsg = ws.GetXml("Emr.GetEmrDiagnosis", inpNo); if (strMsg.Trim().Equals("")) { strMsg = "未获取到Emr入院诊断"; return(false); } return(true); } catch (Exception ex) { strMsg = ex.Message; return(false); } }
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); } }
/// <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); } }