public override string PivasRevPreFalse(string GroupNo, string DEmployeeID, out string msg) { msg = "退药操作"; string str = ""; string str2 = ""; string str3 = ""; string format = "update Prescription set PStatus =1 where GroupNo ='{0}'"; string str5 = "update Prescription set PStatus =3 where GroupNo ='{0}'"; string str6 = " select top 1 CensorItem , Description from CPResultRG where CheckResultID =0 and PrescriptionID =(select distinct PrescriptionID from Prescription where GroupNo ='{0}') order by insertdt desc"; DataSet pIVAsDB = this.dbHelp.GetPIVAsDB(string.Format(str6, GroupNo)); str = pIVAsDB.Tables[0].Rows[0]["Description"].ToString(); string str7 = pIVAsDB.Tables[0].Rows[0]["CensorItem"].ToString(); PivasWebServiceSoapClient serviceClient = new PivasWebServiceSoapClient(); serviceClient.BackPre(GroupNo, str7, str, out str3, out str2); serviceClient.Abort(); if ((str2 == "1") || (str3 == "1")) { msg = "退方成功"; this.dbHelp.GetPIVAsDB(string.Format(str5, GroupNo)); string sqlStr = "update ivrecord set labelover=-3 ,labelovertime=getdate() where groupno='" + GroupNo + " ' and ivstatus<9"; this.dbHelp.SetPIVAsDB(sqlStr); return("1"); } msg = str3; this.dbHelp.GetPIVAsDB(string.Format(format, GroupNo)); return("0"); }
public override string Charge(string LabelNo, string DEmployeeID, out string msg) { string str2; string str15; string str = DateTime.Now.ToString(); try { string strUpdateIVRecord = ("update IVRecord set Remark3='{0}' where LabelNo='" + LabelNo + "' ") + "update IVRecordDetail set ReturnFromHis='{1}' where IVRecordID in " + "(select IVRecordID from IVRecord where LabelNo='" + LabelNo + "')"; string str4 = "select iv.GroupNo,iv.InfusionDT,iv.Remark3,iv.PackAdvance,iv.LabelOver," + "p.PStatus from IVRecord iv inner join Prescription p on p.PrescriptionID =iv.PrescriptionID " + "where iv.LabelNo ='{0}'"; //在调用HIS计费接口前,通过pivas数据库判断是否还需要调接口 DataSet dsBeforeOfCharge = this.dbHelp.GetPIVAsDB(string.Format(str4, LabelNo)); string groupno = dsBeforeOfCharge.Tables[0].Rows[0]["groupno"].ToString(); string infusionDT = dsBeforeOfCharge.Tables[0].Rows[0]["InfusionDT"].ToString(); string str7 = dsBeforeOfCharge.Tables[0].Rows[0]["Remark3"].ToString(); string str8 = dsBeforeOfCharge.Tables[0].Rows[0]["PackAdvance"].ToString(); string str9 = dsBeforeOfCharge.Tables[0].Rows[0]["LabelOver"].ToString(); string str10 = dsBeforeOfCharge.Tables[0].Rows[0]["PStatus"].ToString(); #region 个if判断,是否可调用计费接口 if (Convert.ToInt32(str7) == 15) //已通过其他流程计费 { if (Convert.ToInt32(str8) == 1) //若已提前打包/空包,则在病区冲配。 { msg = ChargeResult_Const.PACKADVANCE_WARDCOMPOUND; return("0"); } msg = ChargeResult_Const.OTHERWAY_SUCCESS; return("1"); } if (Convert.ToInt32(str10) == 4)//医嘱已停 { msg = ChargeResult_Const.PRESCRIPTION_STOP; dbHelp.SetPIVAsDB(string.Format("update IVRecord set LabelOver={0},LabelOverID='{1}',LabelOverTime='{2}' where LabelNo='{3}'", -3, DEmployeeID, DateTime.Now, LabelNo)); return("0"); } if (Convert.ToInt32(str9) < 0)//瓶签已打印到瓶签配置扫描这段时间,被各种情况造成瓶签配置取消 { msg = ChargeResult_Const.MANUAL_CANCEL; return("0"); } #endregion #region 调HIS计费接口 string sqlStr = " select DEmployeeCode from DEmployee where DEmployeeID = '" + DEmployeeID + "'"; string userCode = this.dbHelp.GetPIVAsDB(sqlStr).Tables[0].Rows[0][0].ToString(); string strHisRtnValue, strHisRtnMsg = string.Empty; PivasWebServiceSoapClient serviceClient = new PivasWebServiceSoapClient(); serviceClient.Charge(groupno, infusionDT, userCode, out strHisRtnMsg, out strHisRtnValue); serviceClient.Abort(); str15 = DateTime.Now.ToString(); msg = strHisRtnMsg; str2 = strHisRtnValue; string str16 = groupno + "||" + infusionDT + "||" + userCode; #endregion if (strHisRtnMsg.Contains("重复"))//his对重复计费,返回值有可能不是“1”,这里做了保护 { strHisRtnValue = "1"; } this.dbHelp.GetPIVAsDB("insert into ToHisChargeLog (begintime,endtime,labelno,msg,ChargeResult,Parameters,HisReturn," + "Remark2) values ('" + str + "','" + str15 + "','" + LabelNo + "','" + strHisRtnMsg + "','" + strHisRtnValue + "' ,'" + str16 + "','" + str2 + "','" + userCode + "' )"); #region 调用HIS计费接口后的数据更新 if (strHisRtnValue.Trim().Equals("1"))//启东返回值目前枚举0:异常,1:计费成功,-1:重复或失败,-2:医嘱停止,-5:库存不存在 { if (Convert.ToInt32(str8) == 1) { //只计费,不配置液体。但在配置核对的页面显示时,怎么显示? msg = ChargeResult_Const.PACKADVANCE_WARDCOMPOUND; this.dbHelp.SetPIVAsDB(string.Format(strUpdateIVRecord, 15, str2)); return("0"); } msg = ChargeResult_Const.CHARGE_SUCCESS; dbHelp.SetPIVAsDB(string.Format(strUpdateIVRecord, 15, str2)); return("1"); } //0是属于异常,可能是网络或his短时故障,所以不等于0时才已明确配置取消 //含"ORA"的返回值为-1,但返回值为-1的还要重复情况。这里将-5的情况都不取消 if (strHisRtnValue.Trim().Equals("0") || strHisRtnValue.Trim().Equals("-5")) { return("0");//Msg默认是his返回的 } else { dbHelp.SetPIVAsDB(string.Format(strUpdateIVRecord, 12, str2)); //HIS计费失败可能多种原因,都统一更新labelover值 dbHelp.SetPIVAsDB(string.Format("update IVRecord set LabelOver={0},LabelOverID='{1}',LabelOverTime='{2}' where LabelNo='{3}'", -3, DEmployeeID, DateTime.Now, LabelNo)); return("0"); } #endregion } catch (Exception exception) { str2 = "0"; str15 = DateTime.Now.ToString(); msg = string.Format("计费接口异常({0}),计费失败", exception.Message); InternalLogger.Log.Error(msg); dbHelp.SetPIVAsDB(string.Concat(new object[] { "INSERT INTO ToHisChargeLog(BeginTime,EndTime,LabelNo,ChargeResult,HisReturn,msg,remark2) VALUES ('", str, "','", str15, "','", LabelNo, "','", 0, "','", str2, "','", msg, "') " })); return("0"); } }