/// <summary> /// 执行时效事件配置的SQL语句 /// </summary> /// <param name="szSQL">事件SQL</param> /// <param name="lstTimeQCEventResults">事件数据来源SQL返回结果信息</param> /// <returns>SystemData.ReturnValue</returns> public short ExecuteTimeEventSQL(string szSQL, ref List <TimeQCEventResult> lstTimeQCEventResults) { if (GlobalMethods.Misc.IsEmptyString(szSQL) || !szSQL.StartsWith("select", StringComparison.CurrentCultureIgnoreCase)) { LogManager.Instance.WriteLog("ConfigAccess.ExecuteTimeEventSQL", new string[] { "szSQL" } , new object[] { szSQL }, "禁止执行非select语句!"); return(SystemData.ReturnValue.PARAM_ERROR); } IDataReader dataReader = null; try { dataReader = base.MeddocAccess.ExecuteReader(szSQL, CommandType.Text); if (dataReader == null || dataReader.IsClosed || !dataReader.Read()) { return(SystemData.ReturnValue.RES_NO_FOUND); } if (lstTimeQCEventResults == null) { lstTimeQCEventResults = new List <TimeQCEventResult>(); } lstTimeQCEventResults.Clear(); do { TimeQCEventResult timeQCEventResult = new TimeQCEventResult(); if (!dataReader.IsDBNull(0)) { timeQCEventResult.EventTime = dataReader.GetDateTime(0); } if (!dataReader.IsDBNull(1)) { timeQCEventResult.EndTime = dataReader.GetDateTime(1); } lstTimeQCEventResults.Add(timeQCEventResult); } while (dataReader.Read()); return(SystemData.ReturnValue.OK); } catch (Exception ex) { LogManager.Instance.WriteLog("ConfigAccess.ExecuteTimeEventSQL", new string[] { "szSQL" }, new object[] { szSQL }, ex); return(SystemData.ReturnValue.EXCEPTION); } finally { base.MeddocAccess.CloseConnnection(false); } }
/// <summary> /// 创建一张病历正常书写的用于比对的时效检查时间表 /// </summary> /// <param name="qcCheckPoint">指定时效规则</param> /// <param name="lstTimeQCEventResults">时效事件执行结果</param> /// <returns>时效检查时间表列表</returns> public List <TimeCheckResult> CreateTimeCheckTable(QcCheckPoint qcCheckPoint , PatVisitInfo patVisitLog) { //查询事件结果 TimeEventHandler.Instance.TimeCheckQuery = new TimeCheckQuery(); TimeEventHandler.Instance.TimeCheckQuery.PatientID = patVisitLog.PATIENT_ID; TimeEventHandler.Instance.TimeCheckQuery.PatientName = patVisitLog.PATIENT_NAME; TimeEventHandler.Instance.TimeCheckQuery.VisitID = patVisitLog.VISIT_NO;//兼容新军卫 病历文书visit_id=visit_no TimeEventHandler.Instance.TimeCheckQuery.BedCode = patVisitLog.BED_CODE; TimeEventHandler.Instance.TimeCheckQuery.VisitTime = patVisitLog.VISIT_TIME; List <TimeQCEventResult> lstTimeQCEventResults = TimeEventHandler.Instance.PerformTimeEvent(qcCheckPoint.EventID); if (lstTimeQCEventResults == null || lstTimeQCEventResults.Count <= 0) { return(null); } if (TimeEventHandler.Instance.TimeCheckQuery == null) { return(null); } DateTime dtEndValidTime = patVisitLog.DISCHARGE_TIME == patVisitLog.DefaultTime ? DateTime.Now : patVisitLog.DISCHARGE_TIME; List <TimeCheckResult> lstTimeCheckResults = new List <TimeCheckResult>(); string szPatientID = TimeEventHandler.Instance.TimeCheckQuery.PatientID; string szPatientName = TimeEventHandler.Instance.TimeCheckQuery.PatientName; string szVisitID = TimeEventHandler.Instance.TimeCheckQuery.VisitID; string szBedCode = TimeEventHandler.Instance.TimeCheckQuery.BedCode; DateTime dtVisitTime = TimeEventHandler.Instance.TimeCheckQuery.VisitTime; //创建一张病历正常书写的时间表 for (int index = 0; index < lstTimeQCEventResults.Count; index++) { TimeQCEventResult timeQCEventResult = lstTimeQCEventResults[index]; if (timeQCEventResult == null) { continue; } if (!timeQCEventResult.EventTime.HasValue) { continue; } if (!timeQCEventResult.EndTime.HasValue) { continue; } DateTime dtPeriodTime = timeQCEventResult.EventTime.Value; do { TimeCheckResult timeCheckResult = new TimeCheckResult(); timeCheckResult.PatientID = szPatientID; timeCheckResult.VisitID = szVisitID; timeCheckResult.EventID = qcCheckPoint.EventID; timeCheckResult.EventName = qcCheckPoint.EventName; timeCheckResult.PatientName = szPatientName; timeCheckResult.DocTypeID = qcCheckPoint.DocTypeID; timeCheckResult.DocTypeName = qcCheckPoint.DocTypeName; timeCheckResult.BedCode = szBedCode; timeCheckResult.VisitTime = dtVisitTime; timeCheckResult.DocTitle = timeCheckResult.DocTypeName; timeCheckResult.QCScore = qcCheckPoint.Score; timeCheckResult.ResultDesc = qcCheckPoint.MsgDictMessage; timeCheckResult.IsRepeat = qcCheckPoint.IsRepeat; timeCheckResult.WrittenState = WrittenState.Uncheck; timeCheckResult.EventTime = timeQCEventResult.EventTime.Value; //timeCheckResult.InnerTime = timeCheckResult.DocTime; timeCheckResult.StartTime = dtPeriodTime; string szWrittenPeriod = qcCheckPoint.WrittenPeriod; string szPeriodDesc = null; timeCheckResult.EndTime = this.GetWrittenPeriod(szWrittenPeriod, dtPeriodTime, ref szPeriodDesc); timeCheckResult.WrittenPeriod = szPeriodDesc; timeCheckResult.DoctorLevel = timeQCEventResult.DoctorLevel; lstTimeCheckResults.Add(timeCheckResult); dtPeriodTime = timeCheckResult.EndTime; } while (qcCheckPoint.IsRepeat && dtPeriodTime < timeQCEventResult.EndTime && dtPeriodTime < dtEndValidTime); //当转院,死亡等事件发生后,不用再循环创建应书写病历,所以需要 dtPeriodTime < timeQCEventResult.EndTime(timeQCEventResult.EndTime:转院或死亡等事件发生时间) } return(lstTimeCheckResults); }
/// <summary> /// 创建一张病历正常书写的用于比对的时效检查时间表 /// </summary> /// <param name="timeQCRule">指定时效规则</param> /// <param name="lstTimeQCEventResults">时效事件执行结果</param> /// <returns>时效检查时间表列表</returns> private List <TimeCheckResult> CreateTimeCheckTable(TimeQCRule timeQCRule , List <TimeQCEventResult> lstTimeQCEventResults) { if (lstTimeQCEventResults == null || lstTimeQCEventResults.Count <= 0) { return(null); } if (TimeEventHandler.Instance.TimeCheckQuery == null) { return(null); } List <TimeCheckResult> lstTimeCheckResults = new List <TimeCheckResult>(); string szPatientID = TimeEventHandler.Instance.TimeCheckQuery.PatientID; string szPatientName = TimeEventHandler.Instance.TimeCheckQuery.PatientName; string szVisitID = TimeEventHandler.Instance.TimeCheckQuery.VisitID; string szBedCode = TimeEventHandler.Instance.TimeCheckQuery.BedCode; DateTime dtVisitTime = TimeEventHandler.Instance.TimeCheckQuery.VisitTime; //创建一张病历正常书写的时间表 for (int index = 0; index < lstTimeQCEventResults.Count; index++) { TimeQCEventResult timeQCEventResult = lstTimeQCEventResults[index]; if (timeQCEventResult == null) { continue; } if (!timeQCEventResult.EventTime.HasValue) { continue; } if (!timeQCEventResult.EndTime.HasValue) { continue; } DateTime dtPeriodTime = timeQCEventResult.EventTime.Value; do { TimeCheckResult timeCheckResult = new TimeCheckResult(); timeCheckResult.PatientID = szPatientID; timeCheckResult.VisitID = szVisitID; timeCheckResult.PatientName = szPatientName; timeCheckResult.DocTypeID = timeQCRule.DocTypeID; timeCheckResult.DocTypeName = timeQCRule.DocTypeName; timeCheckResult.BedCode = szBedCode; timeCheckResult.VisitTime = dtVisitTime; if (!GlobalMethods.Misc.IsEmptyString(timeQCRule.DocTypeAlias)) { timeCheckResult.DocTypeName = timeQCRule.DocTypeAlias; } timeCheckResult.DocTitle = timeCheckResult.DocTypeName; timeCheckResult.QCScore = timeQCRule.QCScore; timeCheckResult.ResultDesc = timeQCRule.RuleDesc; timeCheckResult.IsRepeat = timeQCRule.IsRepeat; timeCheckResult.IsStopRight = timeQCRule.IsStopRight; timeCheckResult.WrittenState = WrittenState.Uncheck; timeCheckResult.EventTime = timeQCEventResult.EventTime.Value; //timeCheckResult.InnerTime = timeCheckResult.DocTime; timeCheckResult.StartTime = dtPeriodTime; string szWrittenPeriod = timeQCRule.WrittenPeriod; string szPeriodDesc = null; timeCheckResult.EndTime = this.GetWrittenPeriod(szWrittenPeriod, dtPeriodTime, ref szPeriodDesc); timeCheckResult.WrittenPeriod = szPeriodDesc; timeCheckResult.DoctorLevel = timeQCEventResult.DoctorLevel; lstTimeCheckResults.Add(timeCheckResult); dtPeriodTime = timeCheckResult.EndTime; } while (timeQCRule.IsRepeat && dtPeriodTime < timeQCEventResult.EndTime && dtPeriodTime < timeQCRule.ValidateTime); //当转院,死亡等事件发生后, //不用再循环创建应书写病历,所以需要 dtPeriodTime < timeQCEventResult.EndTime(timeQCEventResult.EndTime:转院或死亡等事件发生时间) //while (timeQCRule.IsRepeat && dtPeriodTime < timeQCEventResult.EndTime && (!IsRuleAsDocCommited || (IsRuleAsDocCommited && dtPeriodTime < timeQCRule.ValidateTime))); } return(lstTimeCheckResults); }