public bool AddDrug_1(DrugInfo dinfo) { DataBaseLayer db = new DataBaseLayer(); int n = 0; //string stateSql = "select prescriptionId from PrescriptionCheckState where checkStatus = 1 and prescriptionId = (select id from prescription as p where p.Pspnum = '" + dinfo.strPspnum + "' and p.hospitalid = '" + dinfo.nHospitalNum + "')"; string stateSql = "select prescriptionId from PrescriptionCheckState where checkStatus = 0 and prescriptionId in(select id from prescription as p where p.Pspnum = '" + dinfo.strPspnum + "' and p.hospitalid = '" + dinfo.nHospitalNum + "')"; db.write_log_txt("insert drug_2:" + stateSql); SqlDataReader srd = db.get_Reader(stateSql); //string q = srd["Pspnum"].ToString(); // if (srd.Read()) // { // n = 0; // } // else // { string stateSql1 = "select id from prescription as p where p.Pspnum = '" + dinfo.strPspnum + "' and p.hospitalid = '" + dinfo.nHospitalNum + "'"; SqlDataReader srd1 = db.get_Reader(stateSql1); string pid = ""; if (srd1.Read()) { pid = srd1["id"].ToString(); } string str = "select * from drug where pid='" + pid + "' and drugnum ='" + dinfo.strDrugNum + "' and drugname ='" + dinfo.strDrugName + "'"; SqlDataReader srd4 = db.get_Reader(str); if (srd4.Read()) { n = -1; } else { string strSql = "insert into drug(customid,Hospitalid,Pspnum,drugnum,drugname,drugdescription,"; strSql += "drugposition,drugallnum,drugweight,tienum,description,pid) "; strSql += "values(" + dinfo.nCustomId + "," + dinfo.nHospitalNum + ",'" + dinfo.strPspnum + "',"; strSql += "'" + dinfo.strDrugNum + "','" + dinfo.strDrugName + "','" + dinfo.strDrugDsp + "','" + dinfo.strDrugPosition + "',"; strSql += "" + dinfo.nAllNum + "," + dinfo.dWeight + "," + dinfo.nTieNum + ",'" + dinfo.strDsp + "'," + "'" + pid + "')"; db.write_log_txt("药品录入:" + strSql); n = db.cmd_Execute(strSql); } // } if (n > 0) { return(true); } else if (n == 0) { // Response.Write("<script>alert('录入药品重复');window.parent.loginview();</script>"); return(true); } else { return(true); } }
///// <returns>DataTable对象</returns> public DataTable findDrugByPspnum(string pid) { /* string sql = "select ROW_NUMBER() OVER(ORDER BY delnum desc) as ID,delnum,(select hnum from hospital as h where h.id = (select hospitalid from prescription where id = '" + pid + "')) as hnum,(select hname from hospital as h where h.id = (select hospitalid from prescription where id = '" + pid + "')) as hname," + "(select pspnum from prescription where id = d.pid) as Pspnum,Drugnum,Drugname,DrugDescription,DrugPosition,DrugAllNum,DrugWeight,TieNum,Description,WholeSalePrice,RetailPrice,WholeSaleCost,retailpricecost," + "money,Fee from drug as d where pid ='" + pid + "'"; */ string sql = "select ROW_NUMBER() OVER(ORDER BY ID desc) as ID,(select top 1 hnum from hospital as h where h.id in (select hospitalid from prescription where id = '" + pid + "')) as hnum,(select hname from hospital as h where h.id = (select hospitalid from prescription where id = '" + pid + "')) as hname," + "(select top 1 pspnum from prescription where id = d.pid) as Pspnum,Drugnum,Drugname,DrugDescription,DrugPosition,DrugAllNum,DrugWeight,TieNum,Description,WholeSalePrice,RetailPrice,WholeSaleCost,retailpricecost," + "money,Fee from drug as d where pid ='" + pid + "'"; db.write_log_txt("药品录入显示:" + sql); DataTable dt = db.get_DataTable(sql); return(dt); }
public DataTable findPackingInfo(int userid, string date, string hospital_name) { string sql = ""; string flag = ""; flag = db.get_role_by_userid(userid); string sql_1 = ""; if (hospital_name != "0") { sql_1 = "'" + hospital_name.Replace("_", "','") + "'"; } else { sql_1 = "select id from hospital"; } if (flag != "0") { sql = "select p.ID,p.Pspnum,p.customid,p.delnum,p.Hospitalid,p.name,p.sex,p.age,p.phone,p.address,p.department,p.inpatientarea,p.ward,p.sickbed,(select top 1 hnum from hospital as h where h.id = p.hospitalid) as hnum,(select top 1 hname from hospital as h where h.id = p.hospitalid) as hname," + "p.diagresult,p.dose,p.takenum,p.getdrugtime,p.getdrugnum,p.takemethod,p.decscheme,p.oncetime,p.twicetime,p.packagenum,p.dotime,p.doperson,p.dtbcompany,p.dtbaddress,p.dtbphone,p.dtbtype,p.soakwater,p.soaktime,p.labelnum,p.remark,p.doctor,p.footnote,p.ordertime,p.curstate" + ",pk.Fpactate pstatus,pk.Starttime Starttime,pk.PacTime PacTime,( select top 1 machinename from machine where mark =1 and unitnum in (select unitnum from machine where id in (select machineid from tisaneunit as t where t.pid =p.id))) as packmachine from prescription as p inner join Packing pk on p.id=pk.DecoctingNum left join hospital hs on hs.id = p.hospitalid where pk.employeeId=" + userid + " and CONVERT(varchar, pk.Starttime, 120) like '%" + date + "%' " + " and hs.id in(" + sql_1 + ")" + " order by pk.Starttime desc"; } else { sql = "select p.ID,p.Pspnum,p.customid,p.delnum,p.Hospitalid,p.name,p.sex,p.age,p.phone,p.address,p.department,p.inpatientarea,p.ward,p.sickbed,(select top 1 hnum from hospital as h where h.id = p.hospitalid) as hnum,(select top 1 hname from hospital as h where h.id = p.hospitalid) as hname," + "p.diagresult,p.dose,p.takenum,p.getdrugtime,p.getdrugnum,p.takemethod,p.decscheme,p.oncetime,p.twicetime,p.packagenum,p.dotime,p.doperson,p.dtbcompany,p.dtbaddress,p.dtbphone,p.dtbtype,p.soakwater,p.soaktime,p.labelnum,p.remark,p.doctor,p.footnote,p.ordertime,p.curstate" + ",pk.Fpactate pstatus,pk.Starttime Starttime,pk.PacTime PacTime,( select top 1 machinename from machine where mark =1 and unitnum in (select unitnum from machine where id in (select machineid from tisaneunit as t where t.pid =p.id))) as packmachine from prescription as p inner join Packing pk on p.id=pk.DecoctingNum left join hospital hs on hs.id = p.hospitalid where " + " CONVERT(varchar, pk.Starttime, 120) like '%" + date + "%'" + " and hs.id in(" + sql_1 + ")" + " order by pk.Starttime desc"; } db.write_log_txt("包装时间排序:" + sql); DataTable dt = db.get_DataTable(sql); return(dt); }
/// <summary> /// 开始煎药 插入命令表 /// </summary> /// <param name="now">开始煎药时间</param> /// <param name="db">db层</param> /// <param name="bmNum">煎药单号</param> public static void Insert_TisaneCmd(DateTime now, DataBaseLayer db, string bmNum) { //开始煎药指令 string sql12 = "select macaddress from machine where id = (select top 1 machineid from tisaneunit where pid ='" + bmNum + "' order by id asc)"; SqlDataReader sr12 = db.get_Reader(sql12); string mac = ""; if (sr12.Read()) { mac = sr12["macaddress"].ToString(); } string sql10 = "select * from prescription where id = '" + bmNum + "'"; SqlDataReader sr10 = db.get_Reader(sql10); string content = ""; if (sr10.Read()) { content = (Convert.ToInt32(sr10["dose"].ToString()) * Convert.ToInt32(sr10["takenum"].ToString())).ToString().PadLeft(2, '0') + sr10["decscheme"].ToString().PadLeft(2, '0') + bmNum.PadLeft(10, '0') + sr10["oncetime"].ToString().PadLeft(2, '0') + sr10["twicetime"].ToString().PadLeft(2, '0'); } string sql11 = "insert into cmdtable(cmd,bmip,time) values('" + content + "','" + mac + "','" + now + "')"; sr10.Close(); db.write_log_txt("煎药指令:" + sql11); db.cmd_Execute(sql11); }
public DataTable AdjustMonitors_1() { System.DateTime currentTime = new System.DateTime(); currentTime = System.DateTime.Now;//当前时间 string strS = currentTime.ToString("yyyy/MM/dd 00:00:00"); string strS2 = currentTime.ToString("yyyy/MM/dd 23:59:59"); DataBaseLayer db = new DataBaseLayer(); string sql = @" select p.id,h.Hname,p.name,a.SwapPer,p.dotime,a.wordDate,a.status from prescription as p right join adjust as a on p.ID=a.prescriptionId left join Hospital as h on h.ID=p.Hospitalid and h.DrugSendDisplayState='0' where p.curstate in('开始调剂','调剂完成') and p.ID not in (select pid from Audit ) and p.dotime >='" + strS + "' and p.dotime<='" + strS2 + "'"; db.write_log_txt("调剂大屏显示SQL:" + sql); DataTable dt = db.get_DataTable(sql); return(dt); }
public DataTable findDeliveryInfo(int userid, string date, string hospital_name) { string sql = ""; string flag = ""; flag = db.get_role_by_userid(userid); string sql_1 = ""; if (hospital_name != "0") { sql_1 = "'" + hospital_name.Replace("_", "','") + "'"; } else { sql_1 = "select id from hospital"; } if (flag != "0") { sql = "select p.ID,p.Pspnum,p.customid,p.delnum,p.Hospitalid,p.name,p.sex,p.age,p.phone,p.address,p.department,p.inpatientarea,p.ward,p.sickbed,(select hnum from hospital as h where h.id = p.hospitalid) as hnum,(select hname from hospital as h where h.id = p.hospitalid) as hname," + "p.diagresult,p.dose,p.takenum,p.getdrugtime,p.getdrugnum,p.takemethod,p.decscheme,p.oncetime,p.twicetime,p.packagenum,p.dotime,p.doperson,p.dtbcompany,p.dtbaddress,p.dtbphone,p.dtbtype,p.soakwater,p.soaktime,p.labelnum,p.remark,p.doctor,p.footnote,p.ordertime,p.curstate" + ",d.Sendstate dstatus,d.SendTime dSendTime from prescription as p inner join Delivery d on p.id=d.DecoctingNum left join hospital hs on hs.id = p.hospitalid where d.employeeId=" + userid + " and CONVERT(varchar, d.SendTime, 120) like '%" + date + "%' " + " and hs.id in(" + sql_1 + ")" + " order by d.SendTime desc"; } else { sql = "select p.ID,p.Pspnum,p.customid,p.delnum,p.Hospitalid,p.name,p.sex,p.age,p.phone,p.address,p.department,p.inpatientarea,p.ward,p.sickbed,(select hnum from hospital as h where h.id = p.hospitalid) as hnum,(select hname from hospital as h where h.id = p.hospitalid) as hname," + "p.diagresult,p.dose,p.takenum,p.getdrugtime,p.getdrugnum,p.takemethod,p.decscheme,p.oncetime,p.twicetime,p.packagenum,p.dotime,p.doperson,p.dtbcompany,p.dtbaddress,p.dtbphone,p.dtbtype,p.soakwater,p.soaktime,p.labelnum,p.remark,p.doctor,p.footnote,p.ordertime,p.curstate" + ",d.Sendstate dstatus,d.SendTime dSendTime from prescription as p inner join Delivery d on p.id=d.DecoctingNum left join hospital hs on hs.id = p.hospitalid where " + " CONVERT(varchar, d.SendTime, 120) like '%" + date + "%' " + " and hs.id in(" + sql_1 + ")" + " order by d.SendTime desc"; } db.write_log_txt("pda发货列表: " + sql); DataTable dt = db.get_DataTable(sql); return(dt); }
public DataTable findRecheckedInfoByBarcode(string barcode) { string sql = "select top 1 * from Audit where barcode='" + barcode + "'"; db.write_log_txt("调剂: " + sql); DataTable dt = db.get_DataTable(sql); return(dt); }
///// <summary> ///// 根据条码查询调剂信息 ///// </summary> ///// <param name="status">0未完成,1已完成,2全部</param> ///// <param name="begindate">开始日期</param> ///// <param name="enddate">结束日期</param> ///// <param name="eName">员工姓名</param> ///// <returns>DataTable对象</returns> public DataTable findAdjustBybarcode(string barcode) { string sql = "select a.id,wordcontent,convert(varchar, wordDate, 111) as wordDate,workload,employeeId,prescriptionId,status,barcode from adjust as a where a.barcode='" + barcode + "'"; db.write_log_txt("调剂扫码:" + sql); DataTable dt = db.get_DataTable(sql); return(dt); }
public SqlDataReader findYpcdrug(string pid) { string str = "select ROW_NUMBER() OVER(ORDER BY d.id desc) as id,d.drugdescription,d.description,d.DrugAllNum,d.DrugWeight,d.DrugPosition,d.drugname,(select ypcdrugPositionNum from DrugMatching as m where m.pspId=d.pid and m.drugId = d.id) as ypcdrugPositionNum,d.drugnum from drug as d where d.pid='" + pid + "'"; db.write_log_txt(str); SqlDataReader sr2 = db.get_Reader(str); return(sr2); }
public int AddDelivery(int userid, string wordDate, string barcode, string tisaneNum, string imgname, string userName, string kd_type, string kd_num, string demo) { // string sql = "insert into Delivery(employeeId,SendTime,barcode,DecoctingNum,imgname,Sendstate,Sendpersonnel,kd_type,kd_num,demo) values('" + // userid + "','" + wordDate + "','" + barcode + "','" + tisaneNum + "','" + imgname + "','1" + "','" // + userName + "','" + kd_type + "','" + kd_num + "','" + demo + "')"; #region 添加发货时判断包装是否完成,未完成,设置包装结束时间:包装开始时间+包装代数*预设时间 db.sp_Execute_no_return("sp_auto_packing", Convert.ToInt32(tisaneNum)); #endregion string sql = "update Delivery set employeeId='" + userid + "',SendTime='" + wordDate + "',barcode='" + barcode + "',imgname='" + imgname + "',Sendstate='1',Sendpersonnel='" + userName + "',kd_type='" + kd_type + "'" + ",kd_num='" + kd_num + "'" + ",demo='" + demo + "'" + " where DecoctingNum='" + tisaneNum + "'"; string sql2 = "update prescription set doperson ='" + userName + "',curstate = '已发货' where id = '" + tisaneNum + "'"; // Console.WriteLine("sql:" + sql); // Console.ReadLine(); // Console.WriteLine("sql:" + sql2); db.cmd_Execute(sql2); //写log文件 db.write_log_txt("sql:" + sql + "-------" + "sql:" + sql2); return(db.cmd_Execute(sql)); }
public DataTable DecoctingMonitoring(string unitnum, string roomnum) { // string sql = "select id, (select meRoomNum from MedicineRoom as m where m.meRoomName = a.roomnum) as meRoomNum, unitnum,machinename, roomnum,usingstatus,status,healthstatus,disinfectionstatus ,'待定' as CurrentTemp from machine as a where mark = 0"; string sql = "select id,unitnum,machinename,roomnum,usingstatus,status,healthstatus,disinfectionstatus ,'待定' as CurrentTemp from machine as a where mark = 0"; db.write_log_txt("大屏显示相关SQL" + sql); if (unitnum != "0" && unitnum != "") { sql += "and unitnum ='" + unitnum + "'"; } if (roomnum != "0" && roomnum != "") { sql += "and roomnum ='" + roomnum + "'"; } return(db.get_DataTable(sql)); }
//重写煎药指令 public static void Insert_TisaneCmd_orerride_pda(string bmNum, string mahineid) { //开始煎药指令 DataBaseLayer db = new DataBaseLayer(); string sql12 = "select top 1 macaddress from machine where id = mahineid"; SqlDataReader sr12 = db.get_Reader(sql12); string mac = ""; if (sr12.Read()) { mac = sr12["macaddress"].ToString(); } string sql10 = "select * from prescription where id = '" + bmNum + "'"; SqlDataReader sr10 = db.get_Reader(sql10); string content = ""; if (sr10.Read()) { //添加30分钟煎药方案 /* string str_m = "03"; * string str_w = "00"; * if (sr10["decscheme"].ToString().PadLeft(2, '0') == "02") * { * str_m = "81"; * str_w = "30"; * } * else * { * str_m = sr10["decscheme"].ToString().PadLeft(2, '0'); * str_w = sr10["oncetime"].ToString().PadLeft(2, '0'); * } * */ content = (Convert.ToInt32(sr10["dose"].ToString()) * Convert.ToInt32(sr10["takenum"].ToString())).ToString().PadLeft(2, '0') + sr10["decscheme"].ToString().PadLeft(2, '0') + bmNum.PadLeft(10, '0') + sr10["oncetime"].ToString().PadLeft(2, '0') + sr10["twicetime"].ToString().PadLeft(2, '0'); // content = (Convert.ToInt32(sr10["dose"].ToString()) * Convert.ToInt32(sr10["takenum"].ToString())).ToString().PadLeft(2, '0') + str_m + bmNum.PadLeft(10, '0') + str_w + sr10["twicetime"].ToString().PadLeft(2, '0'); } string sql11 = "insert into cmdtable(cmd,bmip,time) values('" + content + "','" + mac + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"; sr10.Close(); db.write_log_txt("煎药指令:" + sql11); db.cmd_Execute(sql11); }
//开始包装指令 重写 public static void Insert_PackCmd_override(string bmNum) { DataBaseLayer db = new DataBaseLayer(); //开始包装指令 string strtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");// string sql12 = "select macaddress from machine where mark=1 and unitnum = (select top 1 unitnum from machine where id =(select top 1 machineid from tisaneunit where pid ='" + bmNum + "'))"; db.write_log_txt("重发包装指令:" + sql12); SqlDataReader sr12 = db.get_Reader(sql12); string mac = ""; if (sr12.Read()) { mac = sr12["macaddress"].ToString(); } string sql10 = "select *, RIGHT(CAST('000000000' + RTRIM(id) AS varchar(20)), 10) as bNum from prescription where id = '" + bmNum + "'"; SqlDataReader sr10 = db.get_Reader(sql10); string content = ""; if (sr10.Read()) { string sql = "select package_machine_nums from tb_sys_add_setting"; SqlDataReader pack = db.get_Reader(sql); int PackNum = 2; if (pack.Read()) { PackNum = Convert.ToInt32(pack["package_machine_nums"].ToString()); } content = (Convert.ToInt32(sr10["dose"].ToString()) * Convert.ToInt32(sr10["takenum"].ToString()) + PackNum).ToString().PadLeft(2, '0') + bmNum.PadLeft(10, '0') + sr10["packagenum"].ToString().PadLeft(4, '0'); } sr10.Close(); string sql11 = "insert into cmdtable(cmd,bmip,time) values('" + content + "','" + mac + "','" + strtime + "');"; db.cmd_Execute(sql11); }
///// <summary> ///// 查询未审核和未匹配处方药品信息 ///// </summary> ///// <param name="hospitalId">医院id</param> ///// <param name="Pspnum">处方号</param> ///// <returns>SqlDataReader对象</returns> public DataTable findNotCheckAndMatchRecipeDrugInfo(string drugnum) { /* string sql = "SELECT DISTINCT p.ID AS pspId, p.Pspnum AS pspNum,(SELECT Hname FROM Hospital AS h WHERE (ID = p.Hospitalid)) AS hospitalName, p.Hospitalid AS hospitalId, d.ID AS drugId, d.drugnum AS hdrugNum, " + " d.drugname AS hdrugName, d.drugallnum AS hdrugTotal FROM prescription AS p LEFT OUTER JOIN PrescriptionCheckState AS pcs ON p.ID = pcs.prescriptionId RIGHT OUTER JOIN " + " (SELECT ID,pid, customid, delnum, Hospitalid, Pspnum, drugnum, drugname, drugdescription, drugposition, drugallnum, drugweight, tienum, description, wholesaleprice, retailprice, wholesalecost, retailpricecost, money, " + " fee FROM drug WHERE (drugnum = '" + drugnum + "')) AS d ON d.pid = p.id LEFT OUTER JOIN DrugMatching AS dm ON d.ID = dm.drugId AND dm.pspId = p.ID " + " WHERE (pcs.prescriptionId IS NULL) AND (dm.drugId IS NULL) AND (d.ID IS NOT NULL) AND (p.ID IS NOT NULL) AND (p.Hospitalid IS NOT NULL)"; */ string sql = "SELECT DISTINCT p.ID AS pspId, p.Pspnum AS pspNum,(SELECT top 1 Hname FROM Hospital AS h WHERE (ID = p.Hospitalid)) AS hospitalName, p.Hospitalid AS hospitalId, d.ID AS drugId, d.drugnum AS hdrugNum, " + " d.drugname AS hdrugName, d.drugallnum AS hdrugTotal FROM prescription AS p LEFT OUTER JOIN PrescriptionCheckState AS pcs ON p.ID = pcs.prescriptionId RIGHT OUTER JOIN " + " (SELECT ID,pid, customid, delnum, Hospitalid, Pspnum, drugnum, drugname, drugdescription, drugposition, drugallnum, drugweight, tienum, description, wholesaleprice, retailprice, wholesalecost, retailpricecost, money, " + " fee FROM drug WHERE (drugnum = '" + drugnum + "')) AS d ON d.pid = p.id LEFT OUTER JOIN DrugMatching AS dm ON d.ID = dm.drugId AND dm.pspId = p.ID " + " WHERE p.curstate='未匹配' AND (dm.drugId IS NULL) AND (d.ID IS NOT NULL) AND (p.ID IS NOT NULL) AND (p.Hospitalid IS NOT NULL)"; DataTable dt = db.get_DataTable(sql); db.write_log_txt("药品匹配显示new:" + sql); return(dt); }
public DataTable AdjustMonitors_2() { System.DateTime currentTime = new System.DateTime(); currentTime = System.DateTime.Now;//当前时间 string strS = currentTime.ToString("yyyy/MM/dd 00:00:00"); string strS2 = currentTime.ToString("yyyy/MM/dd 23:59:59"); DataBaseLayer db = new DataBaseLayer(); string sql = @"select p.id, Pspnum,customid,delnum,h.Hnum ,h.Hname,Hospitalid,a.SwapPer,a.wordDate,a.endDate,a.status,p.name,sex,age,department,inpatientarea,ward,sickbed, diagresult,takenum,getdrugtime,getdrugnum,decscheme,dose,packagenum,dotime,doperson,dtbcompany,dtbaddress,dtbphone,dtbtype,soakwater,soaktime,labelnum,remark, ordertime,curstate,RemarksA,RemarksB from prescription as p right join adjust as a on p.ID=a.prescriptionId left join Hospital as h on h.ID=p.Hospitalid and h.DrugSendDisplayState='0' where p.ID in (select prescriptionId from adjust ) and p.ID not in (select pid from Audit ) and p.dotime between '" + strS + "' and '" + strS2 + "'"; db.write_log_txt("综合大屏调剂显示" + sql); DataTable dt = db.get_DataTable(sql); return(dt); }
//添加匹配列表信息 public int Adddrugmatchinginfo(string hospitalname, string DrugName12, string DrugCode1, string ypcdrugname, string ypcdrugcode) { int end = 0; string strSql = "select top 1 id from Hospital where id = '" + hospitalname + "' "; // end = db.cmd_Execute(strSql); SqlDataReader sdr2 = db.get_Reader(strSql); string hid = ""; if (sdr2.Read()) { hid = sdr2["id"].ToString(); } string strSqlh = "select top 1 Hname from Hospital where id = '" + hospitalname + "' "; // end = db.cmd_Execute(strSql); SqlDataReader sdr2h = db.get_Reader(strSqlh); string hn = ""; if (sdr2h.Read()) { hn = sdr2h["Hname"].ToString(); } string strSql_a = "select count(id) as cid from DrugAdmin where DrugCode = '" + ypcdrugcode + "' "; // end = db.cmd_Execute(strSql); SqlDataReader sdr21 = db.get_Reader(strSql_a); string fid = ""; if (sdr21.Read()) { fid = sdr21["cid"].ToString(); } if (fid == "0") { string in_admin = "insert into DrugAdmin(ProductBatch, DrugType, DrugCode, PurUnits, DrugName,DrugSpecificat, PositionNum, Univalent, Mnemonic, Rmarkes, Producer, ProducingArea, StorageTime,UpperLimit,LowerLimit,Rmarkes2,Rmarkes3)" + "select '', '中药饮片','" + ypcdrugcode + "', 'kg', '" + ypcdrugname + "','', '','','', '','','','','','','',''"; end = db.cmd_Execute(in_admin); } //插入匹配 //获取医院类型 1 饮片厂匹配,2医院匹配 string sql = " select top 1 relation_drug_type_id from Hospital where ID='" + hid.ToString().Trim() + "'"; db.write_log_txt("dai1:" + sql); SqlDataReader sr1 = db.get_Reader(sql); string str = ""; while (sr1.Read()) { str = sr1["relation_drug_type_id"].ToString(); } //获取饮片库ID string yp_h_id = ""; string sql_h = " select top 1 id from Hospital where Hname='" + "饮片库".Trim() + "'"; db.write_log_txt("dai2:" + sql_h); SqlDataReader sr1_h = db.get_Reader(sql_h); while (sr1_h.Read()) { yp_h_id = sr1_h["id"].ToString(); } string strSql_b = ""; if (str == "1") //饮片库匹配 { strSql_b = "select count(id) as mid from DrugMatching where hdrugNum = '" + DrugCode1 + "' and hospitalId='" + yp_h_id + "'"; } if (str == "2") //医院匹配匹配 { strSql_b = "select count(id) as mid from DrugMatching where hdrugNum = '" + DrugCode1 + "' and hospitalId='" + hid + "'"; } db.write_log_txt("插入匹配:" + strSql_b); // end = db.cmd_Execute(strSql); SqlDataReader sdr22 = db.get_Reader(strSql_b); string mid = ""; if (sdr22.Read()) { mid = sdr22["mid"].ToString(); } if (mid == "0") { string in_m = ""; if (str == "2") //医院匹配匹配 { in_m = "insert into DrugMatching(hospitalName,hospitalId,hdrugNum,hdrugName,ypcdrugNum,ypcdrugName,ypcdrugPositionNum)" + "select '" + hn + "', '" + hid + "','" + DrugCode1 + "', '" + DrugName12 + "', '" + ypcdrugcode + "','" + ypcdrugname + "'," + "''"; } if (str == "1") //医院匹配匹配 { in_m = "insert into DrugMatching(hospitalName,hospitalId,hdrugNum,hdrugName,ypcdrugNum,ypcdrugName,ypcdrugPositionNum)" + "select '" + "饮片库" + "', '" + yp_h_id + "','" + DrugCode1 + "', '" + DrugName12 + "', '" + ypcdrugcode + "','" + ypcdrugname + "'," + "''"; } end += db.cmd_Execute(in_m); } return(end); }
public string AddRecipe(RecipeInfo rinfo) { string strResult = ""; int n = 0; string stateSql = "select Pspnum from prescription where Hospitalid =" + rinfo.nHospitalID + " and Pspnum ='" + rinfo.strPspnum + "'"; SqlDataReader srd = db.get_Reader(stateSql); //string q = srd["Pspnum"].ToString(); int cf_id = 0; if (srd.Read()) { n = 0; } else { System.DateTime currentTime = new System.DateTime(); currentTime = System.DateTime.Now;//当前时间 /* * string strSql = "insert into prescription(delnum,Hospitalid,Pspnum,name,sex,age,phone,address,department,inpatientarea,ward,sickbed,"; * strSql += "diagresult,dose,takenum,getdrugtime,getdrugnum,decscheme,oncetime,twicetime,packagenum,dotime,doperson,"; * strSql += "dtbcompany,dtbaddress,dtbphone,dtbtype,soakwater,soaktime,labelnum,remark,doctor,footnote,ordertime,curstate,decmothed,takeway,takemethod,RemarksA,RemarksB)"; * strSql += " values('" + rinfo.strDelnum + "','" + rinfo.nHospitalID + "','" + rinfo.strPspnum + "',"; * strSql += "'" + rinfo.strName + "','" + rinfo.nSex + "','" + rinfo.nAge + "','" + rinfo.strPhone + "','" + rinfo.strAddress + "',"; * strSql += "'" + rinfo.strDepartment + "','" + rinfo.strInpatientAreaNum + "','" + rinfo.strWard + "','" + rinfo.strSickBed + "',"; * strSql += "'" + rinfo.strDiagResult + "','" + rinfo.strDose + "','" + rinfo.nNum + "','" + rinfo.strDrugGetTime + "','" + rinfo.strDrugGetNum + "',"; * strSql += "'" + rinfo.strScheme + "','" + rinfo.strTimeOne + "','" + rinfo.strTimeTwo + "','" + rinfo.nPackageNum + "','" + currentTime + "',"; * strSql += "'" + rinfo.strDoPerson + "','" + rinfo.strDtbCompany + "','" + rinfo.strDtbAddress + "','" + rinfo.strDtbPhone + "','" + rinfo.strDtbStyle + "',"; * strSql += "'" + rinfo.nSoakWater + "','" + rinfo.nSoakTime + "','" + rinfo.nLabelNum + "','" + rinfo.strRemark + "','" + rinfo.strDoctor + "','" + rinfo.strFootNote + "','" + rinfo.strOrderTime + "','未匹配','" + rinfo.strDecMothed + "','" + rinfo.strTakeWay + "','" + rinfo.strTakeMethod + "','" + rinfo.strRemarksA + "','" + rinfo.strRemarksB + "')"; */ string strSql = "insert into prescription(Hospitalid,Pspnum,name,sex,age,phone,address,department,inpatientarea,ward,sickbed,"; strSql += "diagresult,dose,takenum,getdrugtime,getdrugnum,decscheme,oncetime,twicetime,packagenum,dotime,doperson,"; strSql += "dtbcompany,dtbaddress,dtbphone,dtbtype,soakwater,soaktime,labelnum,remark,doctor,footnote,ordertime,curstate,decmothed,takeway,takemethod,RemarksA,RemarksB,confirmDrug)"; strSql += " values('" + rinfo.nHospitalID + "','" + rinfo.strPspnum + "',"; strSql += "'" + rinfo.strName + "','" + rinfo.nSex + "','" + rinfo.nAge + "','" + rinfo.strPhone + "','" + rinfo.strAddress + "',"; strSql += "'" + rinfo.strDepartment + "','" + rinfo.strInpatientAreaNum + "','" + rinfo.strWard + "','" + rinfo.strSickBed + "',"; strSql += "'" + rinfo.strDiagResult + "','" + rinfo.strDose + "','" + rinfo.nNum + "','" + rinfo.strDrugGetTime + "','" + rinfo.strDrugGetNum + "',"; strSql += "'" + rinfo.strScheme + "','" + rinfo.strTimeOne + "','" + rinfo.strTimeTwo + "','" + rinfo.nPackageNum + "','" + currentTime + "',"; strSql += "'" + rinfo.strDoPerson + "','" + rinfo.strDtbCompany + "','" + rinfo.strDtbAddress + "','" + rinfo.strDtbPhone + "','" + rinfo.strDtbStyle + "',"; strSql += "'" + rinfo.nSoakWater + "','" + rinfo.nSoakTime + "','" + rinfo.nLabelNum + "','" + rinfo.strRemark + "','" + rinfo.strDoctor + "','" + rinfo.strFootNote + "','" + rinfo.strOrderTime + "','未匹配','" + rinfo.strDecMothed + "','" + rinfo.strTakeWay + "','" + rinfo.strTakeMethod + "','" + rinfo.strRemarksA + "','" + rinfo.strRemarksB + "'," + "'" + "0" + "'" + ")"; n = db.cmd_Execute(strSql); //插入处方打印功能 //获取插入处方编号 string get_cf_id_sql = "select top 1 id from " + "prescription where Hospitalid =" + rinfo.nHospitalID + " and Pspnum =" + "'" + rinfo.strPspnum.Trim() + "'"; //int cf_id = dba.get_sql_int("2", get_cf_id_sql); SqlDataReader srd_c1 = db.get_Reader(get_cf_id_sql); while (srd_c1.Read()) { cf_id = Int16.Parse(srd_c1["id"].ToString()); } //获取登录用户id string get_employee_id_sql = "select top 1 id from Employee where EName='" + rinfo.strDoPerson.Trim() + "'"; string e_id = "0"; SqlDataReader srd_c2 = db.get_Reader(get_employee_id_sql); while (srd_c2.Read()) { e_id = srd_c2["id"].ToString(); } //插入处方打印标识 string insert_cf_sql_c = " INSERT INTO PrescriptionCheckState(prescriptionId,PartyPer,PartyTime,checkStatus" + ",refusalreason,warningstatus,tisaneNumber,printstatus,warningtime" + " ,warningtype,employeeid) select " + "'" + cf_id.ToString().Trim() + "'," + "'" + rinfo.strDoPerson.Trim() + "'," + "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + "0" + "','" + "" + "','" + "0" + "','" + cf_id.ToString().Trim() + "','" + "0" + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + "暂无预警" + "','" + e_id.Trim() + "'"; db.write_log_txt("插入打印标识SQL:" + insert_cf_sql_c); //判断该处方是否已插入打印标识表 int flag_print = 0; string flag_p_sql = "select count(id) as count_id from " + "PrescriptionCheckState where prescriptionId=" + "'" + cf_id.ToString().Trim() + "'"; //int cf_id = dba.get_sql_int("2", get_cf_id_sql); SqlDataReader srd_c_p_1 = db.get_Reader(flag_p_sql); while (srd_c_p_1.Read()) { flag_print = Int16.Parse(srd_c_p_1["count_id"].ToString()); } if (flag_print == 0) { db.cmd_Execute(insert_cf_sql_c); } if (n == 1) { string str2 = "select id from prescription where hospitalid ='" + rinfo.nHospitalID + "' and Pspnum='" + rinfo.strPspnum + "'"; SqlDataReader srd2 = db.get_Reader(str2); if (srd2.Read()) { string pid = srd2["id"].ToString(); string str3 = "insert into jfInfo(pid,jiefangman,jiefangtime)values('" + pid + "','" + rinfo.strDoPerson + "','" + rinfo.strDoTime + "')"; db.cmd_Execute(str3); } } } if (n > 0) { strResult = "true"; } else { strResult = "false"; } strResult += "," + cf_id; return(strResult); }