public void check_and_set_over() { Dictionary <String, bool> result = check_us_exam_status(); if (null == result) { return; } if (result.Count < 1) { return; } ExamQueue queue = new ExamQueue(); foreach (String key in result.Keys) { //返回结果为true表示检查已经完成 if (result[key]) { try { //设置对应的检查为已完成 String sql = String.Format("Update JiaohaoTable Set " + "QueueActive=0,status=1,IsChecking=0,IsOver=1,IsNeedQueue=1,EndTime=NOW() " +//无EndTime则被认为正在检查中 "Where RoomID='[超声科]' And DJLSH='{0}'", key); queue.getDB().update(sql); } catch (Exception exp) { System.Console.WriteLine(exp.Message); } } } }
//获取RISServer的当前时间 private DateTime getRISServerTime() { DateTime dt = new DateTime(); try { //1.连接服务器,取得时间 ExamQueue queue = new ExamQueue(); String sql = "select date_format(now(),'%Y') as nYear," + "date_format(now(),'%m') as nMonth," + "date_format(now(),'%d') as nDay," + "date_format(now(),'%H') as nHour," + "date_format(now(),'%i') as nMinute," + "date_format(now(),'%s') as nSecond"; DataTable tbl = queue.getDB().query(sql); if (CSTR.IsTableEmpty(tbl)) { return(dt); } //2.转换 String strYear = CSTR.ObjectTrim(tbl.Rows[0]["nYear"]); String strMonth = CSTR.ObjectTrim(tbl.Rows[0]["nMonth"]); String strDay = CSTR.ObjectTrim(tbl.Rows[0]["nDay"]); String strHour = CSTR.ObjectTrim(tbl.Rows[0]["nHour"]); String strMinute = CSTR.ObjectTrim(tbl.Rows[0]["nMinute"]); String strSecond = CSTR.ObjectTrim(tbl.Rows[0]["nSecond"]); if (CSTR.isEmpty(strYear) || CSTR.isEmpty(strMonth) || CSTR.isEmpty(strDay) || CSTR.isEmpty(strHour) || CSTR.isEmpty(strMinute) || CSTR.isEmpty(strSecond)) { return(dt); } //3.生成DateTime格式时间 int nYear = Int16.Parse(strYear); int nMonth = Int16.Parse(strMonth); int nDay = Int16.Parse(strDay); int nHour = Int16.Parse(strHour); int nMinute = Int16.Parse(strMinute); int nSecond = Int16.Parse(strSecond); dt = new DateTime(nYear, nMonth, nDay, nHour, nMinute, nSecond); } catch (Exception exp) { Console.Out.WriteLine(exp.Message); } return(dt); }
//登记成功,返回NEW_DJLSH,登记失败,返回null; public String register() { String str_ret_DJLSH = null; if (CSTR.IsTableEmpty(register_table)) { return(null); } if (CSTR.isEmpty(rfid_no)) { return(null); } if (CSTR.isEmpty(ring_no)) { return(null); } ExamQueue queue = new ExamQueue(); try { //生成每个检查的检查房间------------------------------------------------------------------------- List <String> reg_list_RoomID = parse_and_allot_RoomID_for_STUDY(); if (null == reg_list_RoomID) { return(null); } if (reg_list_RoomID.Count <= 0) { return(null); } //生成每个检查的检查房间------------------------------------------------------------------------- //通用数据以第一条记录为准------------------------------------------------------------------------ DataRow rowFirst = register_table.Rows[0]; //PatientInfo级别的信息(同一使用第一行的数据) String PatientNameChinese = CSTR.ObjectTrim(rowFirst["XM"]); String PatientGender = CSTR.ObjectTrim(rowFirst["XB"]); if (PatientGender.Equals("0")) { PatientGender = "女"; } else { PatientGender = "男"; //0:女 1:男 %:未知 } String SFZH = CSTR.ObjectTrim(rowFirst["SFZH"]); //身份证号 String Phone = (CSTR.ObjectTrim(rowFirst["p_Phone"]).Length > //两个电话取长度长的那个 CSTR.ObjectTrim(rowFirst["d_Phone"]).Length) ? CSTR.ObjectTrim(rowFirst["p_Phone"]) : CSTR.ObjectTrim(rowFirst["d_Phone"]); String PatientIntraID = CSTR.ObjectTrim(rowFirst["TJBH"]); String DJLSH = CSTR.ObjectTrim(rowFirst["DJLSH"]); String TJLB = CSTR.ObjectTrim(rowFirst["TJLB"]); String TJLBMC = CSTR.ObjectTrim(rowFirst["TJLBMC"]); String DWBH = CSTR.ObjectTrim(rowFirst["DWBH"]); String DWMC = CSTR.ObjectTrim(rowFirst["DWMC"]); String ExamAccessionID = this.ring_no;//用于显示序号 //获取激活时间 DateTime arrivalTime = DateTime.Now; String strArrivalTime = arrivalTime.ToString("HH:mm:ss"); //只取得时间部分,用以生成QueueID String strArrivalDateTime = arrivalTime.ToString("yyyyMMdd HH:mm:ss"); //取得日期及时间(格式化时间) //生成QueueID String QueueID = String.Format("time_to_sec('{0}')", strArrivalTime); String ExamArrivalDateTime = "NOW()"; //生成检查来源(类别) String PreExamFrom = "个检";//体检来源(类别) if (STUDY_is_vacation_exam) { PreExamFrom = "职检"; } //PatientInfo级别的信息同一使用第一行的数据为准---------------------------------------------------- //生成每一个Exam的JiaohaoTable和JiaohaoExamInfo的Insert的Sql语句 List <String> reg_list_sql_JiaohaoTable = new List <string>(); List <String> reg_list_sql_JiaohaoExamInfo = new List <string>(); String reg_str_RoomID_registed_cluster = "";//记录已经登记了的RoomID列表 for (int i = 0; i < register_table.Rows.Count; i++) { //取得行数据 DataRow row = register_table.Rows[i]; //ExamInfo级别的数据,每个Row会有不同--------------------------------- String ModalityID = CSTR.ObjectTrim(row["CheckRoom"]); String OrderProcedureName = CSTR.ObjectTrim(row["ExamTypeMC"]); String ProcedureStepID = CSTR.ObjectTrim(row["TJXMBH"]); String ProcedureStepName = CSTR.ObjectTrim(row["TJXMMC"]); String ExamType = CSTR.ObjectTrim(row["ExamType"]); String ReorderReason = "";// CSTR.ObjectTrim(row["TSXX"]);//提示信息 //ExamInfo级别的数据,每个Row会有不同--------------------------------- //获取RoomID String RoomID = reg_list_RoomID[i]; if (CSTR.isEmpty(RoomID) || RoomID.Equals(VALID_ROOM_ID)) { //如果是无效房间,则生成空的SQL语句 reg_list_sql_JiaohaoExamInfo.Add(""); reg_list_sql_JiaohaoTable.Add(""); //处理下一个 continue; } //有了唯一的RoomID后,定义OrderID,用于同一房间检查的详细信息查询 String OrderID = CSTR.trim(DJLSH + RoomID); //ExamID也要写入到JiaohaoExamInfo,用于和IndexID的对应,需要保证每个Exam不同 String ExamID = String.Format("{0}.{1}.{2}", OrderID, ProcedureStepID, i.ToString()); //合并相同房间的RoomID字段和检查方法字段,保存到JiaohaoTable.ArrayRoomID和JiaohaoTable.ArrayProcedureStepName String ArrayRoomID = ""; String ArrayProcedureStepName = ""; for (int reg_point = 0; reg_point < reg_list_RoomID.Count; reg_point++) { String reg_room_id = reg_list_RoomID[reg_point]; if (RoomID.Equals(reg_room_id)) { String roomid_for_arr = CSTR.ObjectTrim(register_table.Rows[reg_point]["CheckRoom"]); String procedureName_for_arr = CSTR.ObjectTrim(register_table.Rows[reg_point]["TJXMMC"]); //去掉敏感字符';' roomid_for_arr = roomid_for_arr.Replace(";", ""); procedureName_for_arr = procedureName_for_arr.Replace(";", ""); //加入到Array字段 if (ArrayRoomID.Length > 0) { ArrayRoomID += ";"; } ArrayRoomID += roomid_for_arr; if (ArrayProcedureStepName.Length > 0) { ArrayProcedureStepName += ";"; } ArrayProcedureStepName += procedureName_for_arr; } } //检查状态的确定 String ExamSatus = "2"; //默认为未检 String status = "0"; //默认为未检 String IsOver = "0"; //默认为未检 String IsNeedQueue = "1"; //默认需要排队 String IsNeedVoice = "1"; //默认需要TTS语音 //对roomID,查询房间的三个状态 active/needQueue/needVoice bool bActive = DatabaseCache.RoomInfo_is_active(RoomID); bool bNeedQueue = DatabaseCache.RoomInfo_is_need_queue(RoomID); bool bNeedVoice = DatabaseCache.RoomInfo_is_need_voice(RoomID); //只有NeedQueue为false才无需排队,不论房间是否active或disactive if (bNeedQueue == false) { ExamSatus = "3"; status = "1"; IsOver = "1"; IsNeedQueue = "0"; IsNeedVoice = "0"; } else { ExamSatus = "2"; status = "0"; IsOver = "0"; IsNeedQueue = "1"; if (bNeedVoice) { IsNeedVoice = "1"; } else { IsNeedVoice = "0"; } } //生成插入到JiaohaoTable的语句 String sql_JiaohaoTable = String.Format("insert into JiaohaoTable " + " (QueueID,PatientNameChinese,PatientGender," +//1 "SFZH,Phone,PatientIntraID," + "DJLSH,Rfid,RfidName," +//2 "TJLB,TJLBMC,DWBH," + "DWMC,ExamID,OrderID," +//3 "ExamAccessionID,ExamArrivalDateTime,ModalityID," + "OrderProcedureName,ProcedureStepID,ProcedureStepName," +//4 "ExamType,RoomID,ReorderReason," + "PreExamFrom,ExamSatus,status," +//5 "IsOver,IsNeedQueue,IsNeedVoice," + "ArrayRoomID,ArrayProcedureStepName) VALUES " + " ({0},'{1}','{2}'," +//1 " '{3}','{4}','{5}'," + " '{6}','{7}','{8}'," +//2 " '{9}','{10}','{11}'," + " '{12}','{13}','{14}'," +//3 " '{15}',{16},'{17}'," + " '{18}','{19}','{20}'," +//4 " '{21}','{22}','{23}'," + "'{24}',{25},{26}," +//5 "{27},{28},{29}," + "'{30}','{31}')", QueueID, PatientNameChinese, PatientGender,//1 SFZH, Phone, PatientIntraID, DJLSH, this.rfid_no, this.ring_no,//2 TJLB, TJLBMC, DWBH, DWMC, ExamID, OrderID,//3 ExamAccessionID, ExamArrivalDateTime, ModalityID, OrderProcedureName, ProcedureStepID, ProcedureStepName,//4 ExamType, RoomID, ReorderReason, PreExamFrom, ExamSatus, status,//5 IsOver, IsNeedQueue, IsNeedVoice, ArrayRoomID, ArrayProcedureStepName ); //生成插入到JiaohaoExamInfo的语句 String sql_JiaohaoExamInfo = String.Format("insert into JiaohaoExamInfo " + " (ExamID,OrderID,RoomID,CheckRoom," + "ProcedureStepID,ProcedureStepName,ExamType,RfidName) VALUES " + " ('{0}','{1}','{2}','{3}'," + "'{4}','{5}','{6}','{7}')", ExamID, OrderID, RoomID, ModalityID, ProcedureStepID, ProcedureStepName, ExamType, this.ring_no); //对于相同的RoomID,在JiaohaoTable中只能写入一次 if (reg_str_RoomID_registed_cluster.IndexOf(RoomID) >= 0) { //如果此Exam的RoomID已经登记了,则不再写入相同的JiaohaoTable记录 sql_JiaohaoTable = ""; } else { //记录本次的RoomID到已完成房间串 reg_str_RoomID_registed_cluster += RoomID; } //保存SQL语句 reg_list_sql_JiaohaoTable.Add(sql_JiaohaoTable); reg_list_sql_JiaohaoExamInfo.Add(sql_JiaohaoExamInfo); }//end for (int i = 0; i < register_table.Rows.Count; i++) //重置返回值 str_ret_DJLSH = null; //逐条写入数据库 int nCount = queue.getDB().update_use_Transaction(reg_list_sql_JiaohaoTable); if (nCount > 0) { //不再插入检查到JiaohaoExamInfo //int nCount2 = queue.getDB().update_use_Transaction(reg_list_sql_JiaohaoExamInfo); str_ret_DJLSH = DJLSH;//设置返回值 } } catch (Exception exp) { str_ret_DJLSH = null; } return(str_ret_DJLSH); }