/// <summary> /// 取消门诊发药状态 /// </summary> /// <param name="dset"></param> /// <param name="db"></param> /// <returns></returns> public static string SaveMzQxFyzt(DataSet dset, RelationalDatabase db) { try { DataTable tb = dset.Tables[0]; string ssql = ""; DataRow row = tb.Rows[0]; string BIZID = row["BIZID"].ToString(); string DH = row["DH"].ToString(); #region 老HIS事务处理 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; cmd.CommandText = "update MZ_CFD_ZB set sfty='N',qrty='',tyr='', tyrq=null where dh='" + DH + "' and sftf='N'"; cmd.ExecuteNonQuery(); cmd.CommandText = "update MZ_CFD_CB set sfty='N',qrty='',tyr='' where dh='" + DH + "'"; cmd.ExecuteNonQuery(); tx.Commit(); cmd.Dispose(); connection.Close(); } catch (Exception ex) { //事务回滚 tx.Rollback(); cmd.Dispose(); connection.Close(); tx.Dispose(); throw new Exception(ex.Message); } #endregion #region 回填新HIS记录 for (int nrow = 0; nrow <= tb.Rows.Count - 1; nrow++) { ssql = "update EVENTLOG set FINISH=1 ,FINISH_DATE='" + DateTime.Now.ToString() + "' where EVENT='MZQXFYZT' AND BIZID='" + BIZID + "'"; db.DoCommand(ssql); } #endregion System.String[] str = { "0", "保存成功" }; return(HisFunctions.GetResponseString("SaveKcph", str)); } catch (Exception err) { throw err; } }
public static object ExecuteScalarOnDB(string sSQL, string s_ConnectionString) { System.Data.Odbc.OdbcConnection QConnection = null; System.Data.Odbc.OdbcCommand QCommand = null; try { QConnection = new System.Data.Odbc.OdbcConnection(s_ConnectionString); QCommand = new System.Data.Odbc.OdbcCommand(sSQL, QConnection); QConnection.Open(); return(QCommand.ExecuteScalar()); } finally { if (QCommand != null) { QCommand.Dispose(); } QCommand = null; if (QConnection != null && QConnection.State != System.Data.ConnectionState.Closed) { QConnection.Close(); } if (QConnection != null) { QConnection.Dispose(); } QConnection = null; } }
/// <summary> /// 获取医保结算结果 /// </summary> /// <returns></returns> public static int GetSiResult(string path, string tablename, ref Neusoft.HISFC.Models.RADT.PatientInfo p, ref string errTxt) { if (tablename.Substring(0, 1).ToUpper() != "S") { tablename = "S" + tablename; } string connect = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277; Dbq=" + path; System.Data.Odbc.OdbcConnection myconn = new System.Data.Odbc.OdbcConnection(connect); //个人身份号码 住院号 在院总金额 社保支付金额 个人自费金额 纯自费金额 起伏金额 按比例自负 统筹记账金额 大额记账金额 公务员记账金额 帐户支付金额 现金支付金额 医保记账总额 医保帐户余额 就诊记录号 //GMSFHM ZYH ZYZJE SBZFJE GRZFJE ZFYY CZFJE BFZFJE QFJE ABLZF TCJZJE DEJZJE GWYJZJE ZHZFJE XJZFJE YBJZZE YBZHYE JZJLH string select = "select * from " + tablename; System.Data.Odbc.OdbcCommand cmSelect = new System.Data.Odbc.OdbcCommand(select, myconn); System.Data.Odbc.OdbcDataReader cmReader; try { myconn.Open(); cmReader = cmSelect.ExecuteReader(); } catch (Exception ex) { errTxt = "导出医保信息失败!" + ex.Message; return(-1); } if (!cmReader.Read()) { errTxt = "医保结算数据不存在!"; return(-2); } try { p.IDCard = cmReader["GMSFHM"].ToString(); //公民身份号码 p.SIMainInfo.RegNo = cmReader["ZYH"].ToString(); //住院号 p.SIMainInfo.TotCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["ZYZJE"]); //住院总金额 p.SIMainInfo.OwnCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["XJZFJE"]); //现金支付 p.SIMainInfo.PayCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["ZHZFJE"]); //账户支付 p.SIMainInfo.PubCost = p.SIMainInfo.TotCost - p.SIMainInfo.OwnCost - p.SIMainInfo.PayCost; //统筹支付 p.SIMainInfo.OverCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["DEJZJE"]); //大额记账金额 p.SIMainInfo.BaseCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["QFJE"]); //起付金额 p.SIMainInfo.IndividualBalance = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["YBZHYE"]); //医保账户余额 cmReader.Close(); cmSelect.Dispose(); myconn.Close(); } catch (Exception e) { errTxt = e.ToString(); return(-1); } return(1); }
public DataTable GetDataTable(string SQLstr) { DataTable dt = new DataTable(); System.Data.Odbc.OdbcDataAdapter da; System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(SQLstr, this.mCon); da = new System.Data.Odbc.OdbcDataAdapter(cmd); da.Fill(dt); this.mCon.Close(); cmd.Dispose(); return(dt); }
public DataTable GetSchema(string SQLstr) { System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(SQLstr, this.mCon); System.Data.Odbc.OdbcDataReader dr; DataTable dt = new DataTable(); this.mCon.Open(); dr = cmd.ExecuteReader(CommandBehavior.KeyInfo); dt = dr.GetSchemaTable(); dr.Close(); cmd.Dispose(); this.mCon.Close(); return(dt); }
public int GetFeeItemList(string path, string tablename, ref Neusoft.HISFC.Models.RADT.PatientInfo p, ref ArrayList al) { //string path = filePath.Substring(0, filePath.LastIndexOf(@"\") + 1); //string tablename = filePath.Substring(filePath.LastIndexOf(@"\") + 1, filePath.Length - filePath.LastIndexOf(@"\") - 1); string connect = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277; Dbq=" + path; System.Data.Odbc.OdbcConnection myconn = new System.Data.Odbc.OdbcConnection(connect); string sql = "select GRSHBZH,ZYH,XMXH,XMBH,XMMC,FLDM,YPGG,YPJX,JG,MCYL,JE,ZFBL,ZFJE,CZFBZ,BZ1,BZ2,BZ3 from " + tablename; System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(sql, myconn); System.Data.Odbc.OdbcDataReader cmReader; try { myconn.Open(); cmReader = cmd.ExecuteReader(); } catch { return(-1); } Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList f = null; while (cmReader.Read()) { f = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList(); p.IDCard = cmReader[0].ToString(); p.PID.PatientNO = cmReader[1].ToString(); f = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList(); f.Item.User02 = cmReader[2].ToString(); f.Item.UserCode = cmReader[3].ToString(); f.Item.Name = cmReader[4].ToString(); f.Item.SysClass.Name = cmReader[5].ToString(); f.Item.Specs = cmReader[6].ToString(); f.Item.User01 = cmReader[7].ToString(); f.Item.Price = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader[8]); f.NoBackQty = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader[9]); f.FT.OwnCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader[10]); al.Add(f); } cmReader.Close(); cmd.Dispose(); myconn.Close(); return(1); }
/// <summary> /// 获取医保结算结果 /// </summary> /// <returns></returns> public int GetSiResult(string path, string tablename, ref Neusoft.HISFC.Models.RADT.PatientInfo p, ref string errTxt) { //string path = filePath.Substring(0, filePath.LastIndexOf(@"\") + 1); //string tablename = filePath.Substring(filePath.LastIndexOf(@"\") + 1, filePath.Length - filePath.LastIndexOf(@"\") - 1); string connect = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277; Dbq=" + path; System.Data.Odbc.OdbcConnection myconn = new System.Data.Odbc.OdbcConnection(connect); string select = "select GRSHBZH ,ZYH ,ZYZJE ,SBZFJE ,GWYBZJE ,GRZFJE ,ZFYY from "+ tablename; System.Data.Odbc.OdbcCommand cmSelect = new System.Data.Odbc.OdbcCommand(select, myconn); System.Data.Odbc.OdbcDataReader cmReader; try { myconn.Open(); cmReader = cmSelect.ExecuteReader(); } catch (Exception ex) { errTxt = "导出医保信息失败!" + ex.Message; return(-1); } if (!cmReader.Read()) { errTxt = "医保结算数据不存在!"; return(-1); } p.IDCard = cmReader[0].ToString(); p.PID.PatientNO = cmReader[1].ToString(); p.SIMainInfo.TotCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader[2]); p.SIMainInfo.PubCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader[3]); p.SIMainInfo.OfficalCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader[4]); p.SIMainInfo.OwnCost = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader[5]); p.SIMainInfo.ID = cmReader[6].ToString();//自费原因 cmReader.Close(); cmSelect.Dispose(); myconn.Dispose(); return(1); }
public static System.Data.Odbc.OdbcDataReader ExecuteReaderQueryOnDB(string sSQL, string s_ConnectionString) { System.Data.Odbc.OdbcConnection QConnection = null; System.Data.Odbc.OdbcCommand QCommand = null; try { QConnection = new System.Data.Odbc.OdbcConnection(s_ConnectionString); QCommand = new System.Data.Odbc.OdbcCommand(sSQL, QConnection); QConnection.Open(); return QCommand.ExecuteReader(); } finally { if (QCommand != null) QCommand.Dispose(); QCommand = null; if (QConnection != null && QConnection.State != System.Data.ConnectionState.Closed) QConnection.Close(); if (QConnection != null) QConnection.Dispose(); QConnection = null; } }
/// <summary> /// 导出患者费用信息 /// </summary> /// <param name="path">路径</param> /// <param name="tablename">表名,同文件名</param> /// <param name="idCard">身份号码</param> /// <param name="regNO">医保端流水号</param> /// <param name="alFeeDetail">费用信息</param> /// <param name="errTxt">错误信息</param> /// <returns>1成功 -1失败</returns> public static int ExportFeedetails(string path, string tablename, string idCard, string regNO, ArrayList alFeeDetail, ref string errTxt) { if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } if (tablename.Substring(0, 1).ToUpper() != "Y") { tablename = "Y" + tablename; } string connect = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277; Dbq=" + path; System.Data.Odbc.OdbcConnection myconn = new System.Data.Odbc.OdbcConnection(connect); string drop = "drop table " + tablename; string create = "create table " + tablename + @"(GMSFHM CHAR(20) , ZYH CHAR(14) , XMXH NUMERIC , XMBH CHAR(20) , XMMC CHAR(50) , FLDM CHAR(10), YPGG CHAR(30),YPJX CHAR(10), JG NUMERIC , MCYL NUMERIC , JE NUMERIC , ZFBL NUMERIC , ZFJE NUMERIC , BZ1 CHAR(20) , BZ2 CHAR(20) , BZ3 CHAR(20), FYRQ CHAR(20))"; System.Data.Odbc.OdbcCommand cmDrop = new System.Data.Odbc.OdbcCommand(drop, myconn); System.Data.Odbc.OdbcCommand cmCreate = new System.Data.Odbc.OdbcCommand(create, myconn); System.Data.Odbc.OdbcTransaction trans = null; myconn.Open(); try { cmDrop.ExecuteNonQuery(); } catch (Exception e) { } try { cmCreate.ExecuteNonQuery(); } catch (Exception ex) { errTxt = "导出文件出错" + ex.Message; return(-1); } trans = myconn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); System.Data.Odbc.OdbcCommand cmInsert = new System.Data.Odbc.OdbcCommand(); cmInsert.Connection = myconn; cmInsert.Transaction = trans; int i = 1; foreach (Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList f in alFeeDetail) { //个人身份号码 住院号 项目序号 项目编号 项目名称 分类代码 规范 药品剂型 价格 //每次用量 金额 自费比例 自费金额 处方号 费用日期 标志3 费用日期 string insert = "insert into " + tablename + @"(GMSFHM, ZYH, XMXH, XMBH , XMMC , FLDM ,YPGG ,YPJX ,JG , MCYL, JE, ZFBL,ZFJE, BZ1, BZ2, BZ3, FYRQ ) values ( '{0}','{1}',{2},'{3}', '{4}', '{5}','{6}','{7}',{8},{9},{10},{11},{12},'{13}','{14}','{15}','{16}' )"; try { insert = string.Format(insert, idCard, regNO, i.ToString(), f.Compare.CenterItem.ID, f.Compare.CenterItem.Name, f.Compare.CenterItem.SysClass, f.Compare.CenterItem.Specs, f.Compare.CenterItem.DoseCode, f.Item.Price, f.Item.Qty, f.Item.Price * f.Item.Qty, f.Compare.CenterItem.Rate, f.Item.Price * f.Item.Qty * f.Compare.CenterItem.Rate, f.RecipeNO + f.SequenceNO.ToString().PadLeft(2, '0'), f.FeeOper.OperTime.ToString("yyyy.MM.dd"), "", f.FeeOper.OperTime.ToString("yyyyMMdd")); } catch (Exception ex) { trans.Rollback(); errTxt = "导出文件出错" + ex.Message; return(0); } i++; cmInsert.CommandText = insert; try { cmInsert.ExecuteNonQuery(); } catch (Exception ex) { trans.Rollback(); errTxt = "导出文件出错" + ex.Message; return(-1); } } trans.Commit(); cmInsert.Dispose(); cmCreate.Dispose(); cmDrop.Dispose(); myconn.Close(); try { string file = path + "\\" + tablename + ".dbf"; System.IO.FileInfo fileInfo = new System.IO.FileInfo(file); if (!System.IO.Directory.Exists(path + "\\Backup")) { System.IO.Directory.CreateDirectory(path + "\\Backup"); } fileInfo.CopyTo(path + "\\Backup\\" + tablename + ".dbf"); } catch { } return(1); }
private string GetColumnImage(string imageID, string column, string fileName) { string retImageFullName = ""; if (_odbcConnection == null) { return(retImageFullName); } //ODBC Access System.Data.Odbc.OdbcCommand odbcCommand = null; System.Data.Odbc.OdbcDataReader odbcRead = null; try { odbcCommand = new System.Data.Odbc.OdbcCommand(); odbcCommand.CommandText = "SELECT " + column + " FROM DBSDESX.CHVT34A0_IMAGENS WHERE CREFARQ = '" + imageID + "'"; odbcCommand.Connection = _odbcConnection; odbcRead = odbcCommand.ExecuteReader(); //System.Data.CommandBehavior.SequentialAccess //byte[] _buf = (byte[]) odbcCommand.ExecuteScalar(); //if (!odbcRead.Read()) // return retImageFullName; //not found } catch (System.Exception ex) { throw ex; } //Read BLOB System.Text.StringBuilder sb = new System.Text.StringBuilder(); int bufferSize = 100; byte[] outByte = new byte[bufferSize]; long retval; long startIndex = 0; try { // Read bytes into outByte[] and retain the number of bytes returned. retval = odbcRead.GetBytes(0, startIndex, outByte, 0, bufferSize); // Continue while there are bytes beyond the size of the buffer. while (retval == bufferSize) { //Write the buffer. (convert byte to char) for (int i = 0; i < retval; i++) { sb.Append(System.Convert.ToChar(outByte[i])); } // Reposition start index to end of last buffer and fill buffer. startIndex += bufferSize; retval = odbcRead.GetBytes(0, startIndex, outByte, 0, bufferSize); } // Write the remaining buffer. (convert byte to char) for (int i = 0; i < retval; i++) { sb.Append(System.Convert.ToChar(outByte[i])); } } catch { } //Close DB2 reader try { odbcRead.Close(); odbcCommand.Dispose(); } catch (System.Exception ex) { throw ex; } //Create file try { if (sb.Length > 0) { string myDocFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonPictures) + "\\"; string text = sb.ToString(); byte[] base64EncodedBytes = System.Convert.FromBase64String(text); System.IO.File.WriteAllBytes(myDocFolder + fileName, base64EncodedBytes); retImageFullName = myDocFolder + fileName; } } catch (System.Exception ex) { throw ex; } return(retImageFullName); }
/// <summary> /// 发药状态更新到老HIS 门诊状态 /// </summary> /// <param name="dset"></param> /// <param name="db"></param> /// <returns></returns> public static string SaveMzFyzt(DataSet dset, RelationalDatabase db) { try { DataTable tb = dset.Tables[0]; string ssql = ""; DataRow row = tb.Rows[0]; string BIZID = row["BIZID"].ToString(); string FY_DATE = Convert.ToDateTime(row["FY_DATE"]).ToString("yyyy-MM-dd HH:mm:ss"); string FY_USER = row["FY_USER"].ToString(); string PY_USER = row["PY_USER"].ToString(); string DH = row["DH"].ToString(); decimal ZJE = Convert.ToDecimal(row["zje"]); FY_USER = HisFunctions.ConvertNewhisidToOldHisid(HisFunctions.DataMapType.JC_EMPLOYEE_PROPERTY, FY_USER, db); PY_USER = HisFunctions.ConvertNewhisidToOldHisid(HisFunctions.DataMapType.JC_EMPLOYEE_PROPERTY, PY_USER, db); #region 老HIS事务处理 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; if (ZJE >= 0) { cmd.CommandText = "update MZ_CFD_ZB set sffy='Y',fyy='" + FY_USER + "', fysj='" + FY_DATE + "',pzr='" + PY_USER + "' where dh='" + DH + "'"; cmd.ExecuteNonQuery(); cmd.CommandText = "update MZ_CFD_CB set sffy='Y',fyy='" + FY_USER + "' where dh='" + DH + "'"; cmd.ExecuteNonQuery(); } else { cmd.CommandText = "update MZ_CFD_ZB set sfty='Y',qrty='" + FY_USER + "',tyr='" + FY_USER + "', tyrq='" + FY_DATE + "' where dh='" + DH + "'"; cmd.ExecuteNonQuery(); cmd.CommandText = "update MZ_CFD_CB set sfty='Y',qrty='" + FY_USER + "',tyr='" + FY_USER + "' where dh='" + DH + "'"; cmd.ExecuteNonQuery(); } tx.Commit(); cmd.Dispose(); connection.Close(); } catch (Exception ex) { //事务回滚 tx.Rollback(); cmd.Dispose(); connection.Close(); tx.Dispose(); throw new Exception(ex.Message); } #endregion #region 回填新HIS记录 if (ZJE > 0) { ssql = "update EVENTLOG set FINISH=1 ,FINISH_DATE='" + DateTime.Now.ToString() + "' where EVENT='MZFYZT' AND BIZID='" + BIZID + "'"; } else { ssql = "update EVENTLOG set FINISH=1 ,FINISH_DATE='" + DateTime.Now.ToString() + "' where EVENT='MZFYZTTY' AND BIZID='" + BIZID + "'"; } db.DoCommand(ssql); #endregion System.String[] str = { "0", "保存成功" }; return(HisFunctions.GetResponseString("SaveKcph", str)); } catch (Exception err) { throw err; } }
/// <summary> /// 发药状态更新到老HIS 住院状态 /// </summary> /// <param name="dset"></param> /// <param name="db"></param> /// <returns></returns> public static string SaveFyzt(DataSet dset, RelationalDatabase db) { try { DataTable tb = dset.Tables[0]; string ssql = ""; DataRow row = tb.Rows[0]; string BIZID = row["BIZID"].ToString(); string FY_DATE = Convert.ToDateTime(row["FY_DATE"]).ToString("yyyy-MM-dd HH:mm:ss"); string FY_USER = row["FY_USER"].ToString(); string PY_USER = row["PY_USER"].ToString(); string ZYH = row["ZYH"].ToString(); string YZXH = row["YZXH"].ToString(); string YZZXH = row["YZZXH"].ToString(); decimal num = Convert.ToDecimal(row["NUM"].ToString()); FY_USER = HisFunctions.ConvertNewhisidToOldHisid(HisFunctions.DataMapType.JC_EMPLOYEE_PROPERTY, FY_USER, db); PY_USER = HisFunctions.ConvertNewhisidToOldHisid(HisFunctions.DataMapType.JC_EMPLOYEE_PROPERTY, PY_USER, db); #region 老HIS事务处理 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; if (num > 0) { cmd.CommandText = "update zy_yzlxd set zjfysj='" + FY_DATE + "' where zyh='" + ZYH + "' and xh=" + YZXH + " and zxh=" + YZZXH + ""; cmd.ExecuteNonQuery(); cmd.CommandText = "update zy_cqlsyzd set sffy='Y' where zyh='" + ZYH + "' and xh=" + YZXH + " and zxh=" + YZZXH + ""; cmd.ExecuteNonQuery(); } else { cmd.CommandText = "update zy_yzlxd set sfty='Y' where zyh='" + ZYH + "' and xh=" + YZXH + " and zxh=" + YZZXH + ""; cmd.ExecuteNonQuery(); cmd.CommandText = "update zy_cqlsyzd set sfty='Y' where zyh='" + ZYH + "' and xh=" + YZXH + " and zxh=" + YZZXH + ""; cmd.ExecuteNonQuery(); } tx.Commit(); cmd.Dispose(); connection.Close(); } catch (Exception ex) { //事务回滚 tx.Rollback(); cmd.Dispose(); connection.Close(); tx.Dispose(); throw new Exception(ex.Message); } #endregion #region 回填新HIS记录 for (int nrow = 0; nrow <= tb.Rows.Count - 1; nrow++) { ssql = "update EVENTLOG set FINISH=1 ,FINISH_DATE='" + DateTime.Now.ToString() + "' where EVENT='FYZT' AND BIZID='" + BIZID + "'"; db.DoCommand(ssql); } #endregion System.String[] str = { "0", "保存成功" }; return(HisFunctions.GetResponseString("SaveKcph", str)); } catch (Exception err) { throw err; } }
/// <summary> /// 同步批号 /// </summary> /// <param name="dset"></param> /// <param name="db"></param> /// <returns></returns> public static string SaveKcph(DataSet dset, RelationalDatabase db) { try { DataTable tb = dset.Tables[0]; string ssql = ""; List <System.String[]> listUpdate = new List <System.String[]>(); List <System.String[]> listInsert = new List <System.String[]>(); for (int nrow = 0; nrow <= tb.Rows.Count - 1; nrow++) { #region 变量 DataRow row = tb.Rows[nrow]; ParameterEx[] parameters = new ParameterEx[13]; string _sdeptid = HisFunctions.ConvertNewhisidToOldHisid(HisFunctions.DataMapType.JC_DEPT_PROPERTY, Convertor.IsNull(row["deptid"], ""), db); if (_sdeptid == "") { throw new Exception("没有找到科室匹配信息"); } parameters[0].Text = "yfh"; parameters[0].DataType = System.Data.DbType.String; parameters[0].Value = _sdeptid; string yppc = _sdeptid.ToString() + row["cjid"].ToString(); // yppm=left('0000000000', string temp = "0000000000"; int N = yppc.Length; if (N < 10) { yppc = temp.Substring(0, 10 - N) + yppc; } yppc = "10" + yppc; parameters[1].Text = "yppc"; parameters[1].DataType = System.Data.DbType.String; parameters[1].Value = yppc; string cjid = row["cjid"].ToString(); parameters[2].Text = "ypbm"; parameters[2].Value = row["cjid"]; parameters[3].Text = "ypmc"; parameters[3].DataType = System.Data.DbType.String; parameters[3].Value = row["s_yppm"].ToString().Replace("'", ""); parameters[4].Text = "czgg"; parameters[4].DataType = System.Data.DbType.String; parameters[4].Value = row["s_ypgg"].ToString().Replace("'", ""); parameters[5].Text = "dw"; parameters[5].DataType = System.Data.DbType.String; parameters[5].Value = Convertor.IsNull(row["s_zxdw"], ""); parameters[6].Text = "cjbm"; parameters[6].Value = row["sccj"].ToString(); parameters[7].Text = "grdj"; parameters[7].Value = row["grdj"].ToString(); parameters[8].Text = "pfj"; parameters[8].Value = row["pfj"].ToString(); parameters[9].Text = "lsj"; parameters[9].Value = row["lsj"].ToString(); parameters[10].Text = "ccrq"; parameters[10].DataType = System.Data.DbType.String; parameters[10].Value = Convert.ToDateTime(row["djsj"]).ToString("yyyy-MM-dd HH:mm:ss"); parameters[11].Text = "sxrq"; parameters[11].DataType = System.Data.DbType.String; parameters[11].Value = Convert.ToDateTime(row["ypxq"]).ToString("yyyy-MM-dd HH:mm:ss"); parameters[12].Text = "sl"; parameters[12].Value = Convertor.IsNull(row["kcl"], ""); #endregion #region 插入语句 ssql = "insert into yk_kcb("; for (int i = 0; i <= parameters.Length - 1; i++) { ssql = ssql + parameters[i].Text + ","; } ssql = ssql.Substring(0, ssql.Length - 1) + ")"; ssql = ssql + "values("; for (int i = 0; i <= parameters.Length - 1; i++) { if (parameters[i].DataType != null) { ssql = ssql + "'" + TrasenHIS.DAL.BaseDal.GetEncodingStringToInforMix(parameters[i].Value.ToString()) + "',";//TrasenHIS.DAL.BaseDal.GetEncodingStringToInforMix(parameters[i].Value.ToString()) } else { ssql = ssql + parameters[i].Value + ","; } } ssql = ssql.Substring(0, ssql.Length - 1) + ")"; //用于记录生成的SQL语句,医嘱主键,操作类型。。在一面的事务中一次性处理 System.String[] str_insert = { row["id"].ToString(), _sdeptid, yppc, cjid, ssql, "add" }; listInsert.Add(str_insert); #endregion #region 更新语句 ssql = "update yk_kcb set "; for (int i = 0; i <= parameters.Length - 1; i++) { if (parameters[i].DataType != null) { ssql = ssql + " " + parameters[i].Text + "= '" + TrasenHIS.DAL.BaseDal.GetEncodingStringToInforMix(parameters[i].Value.ToString()) + "',";//TrasenHIS.DAL.BaseDal.GetEncodingStringToInforMix(parameters[i].Value.ToString()) } else { ssql = ssql + " " + parameters[i].Text + "= " + parameters[i].Value + ","; } } ssql = ssql.Substring(0, ssql.Length - 1) + ""; ssql = ssql + " where yfh='" + _sdeptid + "' and yppc='" + yppc + "' and ypbm=" + cjid + ""; //用于记录生成的SQL语句,医嘱主键,操作类型。。在一面的事务中一次性处理 System.String[] str_update = { row["id"].ToString(), _sdeptid, yppc, cjid, ssql, "update" }; listUpdate.Add(str_update); #endregion } #region 老HIS事务处理 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; for (int i = 0; i <= listInsert.Count - 1; i++) { //插入和更新老HIS ssql = "select * from yk_kcb where yfh='" + listInsert[i][1].ToString() + "' and yppc='" + listInsert[i][2].ToString() + "' and ypbm=" + listInsert[i][3].ToString() + ""; cmd.CommandText = ssql; object o = cmd.ExecuteScalar(); if (o != null) { cmd.CommandText = listUpdate[i][4]; } else { cmd.CommandText = listInsert[i][4]; } cmd.ExecuteNonQuery(); } tx.Commit(); cmd.Dispose(); connection.Close(); } catch (Exception ex) { //事务回滚 tx.Rollback(); cmd.Dispose(); connection.Close(); tx.Dispose(); throw new Exception(ex.Message); } #endregion #region 回填新HIS记录 for (int nrow = 0; nrow <= tb.Rows.Count - 1; nrow++) { ssql = "update EVENTLOG set FINISH=1 ,FINISH_DATE='" + DateTime.Now.ToString() + "' where EVENT='KCBH' AND BIZID='" + tb.Rows[nrow]["ID"].ToString() + "'"; db.DoCommand(ssql); } #endregion System.String[] str = { "0", "保存成功" }; return(HisFunctions.GetResponseString("SaveKcph", str)); } catch (Exception err) { throw err; } }
/// <summary> /// 导出患者费用信息 /// </summary> /// <param name="path">路径</param> /// <param name="tablename">表名,同文件名</param> /// <param name="p">患者信息</param> /// <param name="alFeeDetail">费用信息</param> /// <param name="errTxt">错误信息</param> /// <returns>1成功 -1失败</returns> public static int ExportInpatientFeedetail(string path, string tablename, ref string errTxt) { if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } if (tablename.Substring(0, 1).ToUpper() != "Y") { tablename = "Y" + tablename; } string connect = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277; Dbq=" + path; System.Data.Odbc.OdbcConnection myconn = new System.Data.Odbc.OdbcConnection(connect); string drop = "drop table " + tablename; string create = "create table " + tablename + @"(GMSFHM CHAR(20) , ZYH CHAR(14) , XMXH NUMERIC , XMBH CHAR(20) , XMMC CHAR(50) , FLDM CHAR(10), YPGG CHAR(30),YPJX CHAR(10), JG NUMERIC , MCYL NUMERIC , JE NUMERIC , ZFBL NUMERIC , ZFJE NUMERIC , BZ1 CHAR(20) , BZ2 CHAR(20) , BZ3 CHAR(20), FYRQ CHAR(20))"; System.Data.Odbc.OdbcCommand cmDrop = new System.Data.Odbc.OdbcCommand(drop, myconn); System.Data.Odbc.OdbcCommand cmCreate = new System.Data.Odbc.OdbcCommand(create, myconn); myconn.Open(); try { cmDrop.ExecuteNonQuery(); } catch (Exception e) {} try { cmCreate.ExecuteNonQuery(); } catch (Exception ex) { errTxt = "导出文件出错" + ex.Message; return(-1); } System.Data.Odbc.OdbcCommand cmInsert = new System.Data.Odbc.OdbcCommand(); cmInsert.Connection = myconn; int i = 1; //个人身份号码 住院号 项目序号 项目编号 项目名称 分类代码 规范 药品剂型 价格 //每次用量 金额 自费比例 自费金额 处方号 费用日期 标志3 费用日期 string insert = "insert into " + tablename + @"(GMSFHM, ZYH, XMXH, XMBH , XMMC , FLDM ,YPGG ,YPJX ,JG , MCYL, JE, ZFBL,ZFJE, BZ1, BZ2, BZ3, FYRQ ) values ( '{0}','{1}',{2},'{3}', '{4}', '{5}','{6}','{7}',{8},{9},{10},{11},{12},'{13}','{14}','{15}','{16}' )"; try { insert = string.Format(insert, "50023919851113319X", "0000001", "1", "001", "阿莫西林颗粒", "sys", "specs", "dosecode", 10, 2, 20, 0.8, 16, "F12345678901", System.DateTime.Now.ToString("yyyy.MM.dd"), "", System.DateTime.Now.ToString("yyyyMMdd")); } catch (Exception ex) { errTxt = "导出文件出错" + ex.Message; return(0); } i++; cmInsert.CommandText = insert; try { cmInsert.ExecuteNonQuery(); } catch (Exception ex) { errTxt = "导出文件出错" + ex.Message; return(-1); } cmInsert.Dispose(); cmCreate.Dispose(); cmDrop.Dispose(); myconn.Close(); try { string file = path + "\\" + tablename + ".dbf"; System.IO.FileInfo fileInfo = new System.IO.FileInfo(file); if (!System.IO.Directory.Exists(path + "\\Backup")) { System.IO.Directory.CreateDirectory(path + "\\Backup"); } fileInfo.MoveTo(path + "\\Backup\\" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + tablename + ".dbf"); } catch { } return(1); }
/// <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); } }
/// <summary> /// 导出患者费用信息 /// </summary> /// <param name="alFeeDetail">费用信息</param> /// <param name="p">患者信息</param> /// <param name="errTxt">错误信息</param> /// <returns>1成功 -1失败</returns> public int ExportInpatientFeedetail(string path, string tablename, Neusoft.HISFC.Models.RADT.Patient p, ArrayList alFeeDetail, ref string errTxt) { if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } //try //{ // foreach (string file in System.IO.Directory.GetFiles(path)) // { // System.IO.File.Delete(file); // } //} //catch { } string connect = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277; Dbq=" + path; System.Data.Odbc.OdbcConnection myconn = new System.Data.Odbc.OdbcConnection(connect); string drop = "drop table " + tablename; string create = "create table " + tablename + @"(GRSHBZH CHAR(20) , ZYH CHAR(12) , XMXH NUMERIC , XMBH CHAR(15) , XMMC CHAR(40) , FLDM CHAR(3), YPGG CHAR(15),YPJX CHAR(8), JG NUMERIC , MCYL NUMERIC , JE NUMERIC , ZFBL NUMERIC , ZFJE NUMERIC , CZFBZ CHAR(3) , BZ1 CHAR(20) , BZ2 CHAR(20) , BZ3 CHAR(20))"; System.Data.Odbc.OdbcCommand cmDrop = new System.Data.Odbc.OdbcCommand(drop, myconn); System.Data.Odbc.OdbcCommand cmCreate = new System.Data.Odbc.OdbcCommand(create, myconn); myconn.Open(); //try //{ // cmDrop.ExecuteNonQuery(); //} //catch { } try { cmCreate.ExecuteNonQuery(); } catch (Exception ex) { errTxt = "导出文件出错" + ex.Message; return(-1); } System.Data.Odbc.OdbcCommand cmInsert = new System.Data.Odbc.OdbcCommand(); cmInsert.Connection = myconn; int i = 1; //System.Data.Odbc.OdbcTransaction trans = myconn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); foreach (Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList f in alFeeDetail) { string insert = "insert into " + tablename + @"(GRSHBZH, ZYH, XMXH, XMBH , XMMC , FLDM ,YPGG ,YPJX ,JG , MCYL, JE, ZFBL,ZFJE, CZFBZ, BZ1, BZ2, BZ3 ) values ( '{0}','{1}',{2},'{3}', '{4}', '{5}','{6}','{7}',{8},{9},{10},{11},{12},'{13}','{14}','{15}','{16}' )"; //传过去的价格应该是优惠之后的价格 try { insert = string.Format(insert, p.IDCard, p.PID.PatientNO, f.Item.User02, f.Item.UserCode, f.Item.Name, f.Item.SysClass.Name, f.Item.Specs, f.Item.User01, f.Item.Price, f.NoBackQty, f.FT.OwnCost, 0, 0, 0, "", "", ""); } catch (Exception ex) { //trans.Rollback(); errTxt = "导出文件出错" + ex.Message; return(0); } i++; cmInsert.CommandText = insert; //cmInsert.Transaction = trans; try { cmInsert.ExecuteNonQuery(); } catch (Exception ex) { //trans.Rollback(); errTxt = "导出文件出错" + ex.Message; return(-1); } } //trans.Commit(); cmInsert.Dispose(); cmCreate.Dispose(); cmDrop.Dispose(); myconn.Close(); try { string file = System.IO.Directory.GetFiles(path)[0]; System.IO.FileInfo fileInfo = new System.IO.FileInfo(file); fileInfo.MoveTo(path + @"\" + tablename); } catch { } return(1); }