Esempio n. 1
0
        /// <summary>
        /// 执行病历时效审核计算
        /// </summary>
        /// <param name="arrTimeCheckQuery">患者列表</param>
        /// <returns>检查结果列表</returns>
        public short PerformTimeCheck(params TimeCheckQuery[] arrTimeCheckQuery)
        {
            short shRet = 0;

            if (this.m_lstTimeCheckResults == null)
            {
                this.m_lstTimeCheckResults = new List <TimeCheckResult>();
            }
            this.m_lstTimeCheckResults.Clear();
            if (arrTimeCheckQuery == null || arrTimeCheckQuery.Length <= 0)
            {
                return(SystemData.ReturnValue.CANCEL);
            }

            if (this.m_lstTimeQCRules == null || arrTimeCheckQuery[0].PatientID != this.m_szPatientID || arrTimeCheckQuery[0].VisitID != this.m_szVisitID)
            {
                if (this.m_lstTimeQCRules == null)
                {
                    shRet = TimeQCRuleAccess.Instance.GetTimeQCRules(ref this.m_lstTimeQCRules);
                    if (shRet != SystemData.ReturnValue.OK)
                    {
                        return(shRet);
                    }
                    if (this.m_lstTimeQCRules == null)
                    {
                        return(shRet);
                    }
                }

                this.m_szPatientID = arrTimeCheckQuery[0].PatientID;
                this.m_szVisitID   = arrTimeCheckQuery[0].VisitID;
            }

            for (int index = 0; index < arrTimeCheckQuery.Length; index++)
            {
                TimeCheckQuery timeCheckQuery = arrTimeCheckQuery[index];
                if (timeCheckQuery == null)
                {
                    continue;
                }
                TimeEventHandler.Instance.TimeCheckQuery = timeCheckQuery;
                TimeEventHandler.Instance.ClearEventResult();
                DocumentHandler.Instance.ClearDocumentList();
                for (int ruleIndex = 0; ruleIndex < this.m_lstTimeQCRules.Count; ruleIndex++)
                {
                    TimeQCRule             timeQCRule          = this.m_lstTimeQCRules[ruleIndex];
                    List <TimeCheckResult> lstTimeCheckResults = this.PerformTimeRule(timeQCRule);
                    if (lstTimeCheckResults != null && lstTimeCheckResults.Count > 0)
                    {
                        this.m_lstTimeCheckResults.AddRange(lstTimeCheckResults);
                    }
                }
            }
            this.m_lstTimeQCRules.Clear();
            this.m_lstTimeQCRules = null;
            return(SystemData.ReturnValue.OK);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条病历时效规则配置信息
        /// </summary>
        /// <param name="timeQCRule">病历时效规则配置信息</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short UpdateTimeQCRule(TimeQCRule timeQCRule)
        {
            if (timeQCRule == null)
            {
                LogManager.Instance.WriteLog("ConfigAccess.UpdateTimeQCRule", new string[] { "timeQCRule" }
                                             , new object[] { timeQCRule }, "参数不能为空");
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            if (base.MeddocAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            string szField = string.Format("{0}='{1}',{2}='{3}',{4}={5},{6}={7},{8}='{9}',{10}='{11}',{12}={13},{14}={15},{16}={17},{18}={19},{20}='{21}'"
                                           , SystemData.TimeRuleTable.RULE_ID, timeQCRule.RuleID
                                           , SystemData.TimeRuleTable.EVENT_ID, timeQCRule.EventID
                                           , SystemData.TimeRuleTable.DOCTYPE_ID, base.MeddocAccess.GetSqlParamName("DocTypeID")
                                           , SystemData.TimeRuleTable.DOCTYPE_NAME, base.MeddocAccess.GetSqlParamName("DocTypeName")
                                           , SystemData.TimeRuleTable.DOCTYPE_ALIAS, timeQCRule.DocTypeAlias
                                           , SystemData.TimeRuleTable.WRITTEN_PERIOD, timeQCRule.WrittenPeriod
                                           , SystemData.TimeRuleTable.IS_REPEAT, timeQCRule.IsRepeat ? 1 : 0
                                           , SystemData.TimeRuleTable.IS_VALID, timeQCRule.IsValid ? 1 : 0
                                           , SystemData.TimeRuleTable.QC_SCORE, timeQCRule.QCScore.ToString()
                                           , SystemData.TimeRuleTable.ORDER_VALUE, timeQCRule.OrderValue.ToString()
                                           , SystemData.TimeRuleTable.RULE_DESC, timeQCRule.RuleDesc);

            string szCondition = string.Format("{0}='{1}'", SystemData.TimeRuleTable.RULE_ID, timeQCRule.RuleID);
            string szSQL       = string.Format(SystemData.SQL.UPDATE, SystemData.DataTable.TIME_RULE, szField, szCondition);

            DbParameter[] pmi = new DbParameter[2];
            pmi[0] = new DbParameter("DocTypeID", timeQCRule.DocTypeID);
            pmi[1] = new DbParameter("DocTypeName", timeQCRule.DocTypeName);

            int nCount = 0;

            try
            {
                nCount = base.MeddocAccess.ExecuteNonQuery(szSQL, CommandType.Text, ref pmi);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("ConfigAccess.UpdateTimeQCRule", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            if (nCount <= 0)
            {
                LogManager.Instance.WriteLog("ConfigAccess.UpdateTimeQCRule", new string[] { "szSQL" }, new object[] { szSQL }, "SQL语句执行后返回0!");
                return(SystemData.ReturnValue.EXCEPTION);
            }
            return(SystemData.ReturnValue.OK);
        }
Esempio n. 3
0
        /// <summary>
        /// 执行指定的时效检查规则
        /// </summary>
        /// <param name="timeQCRule">时效规则信息</param>
        private List <TimeCheckResult> PerformTimeRule(TimeQCRule timeQCRule)
        {
            if (timeQCRule == null || !timeQCRule.IsValid)
            {
                return(null);
            }

            List <TimeQCEventResult> lstTimeQCEventResults = null;

            lstTimeQCEventResults = TimeEventHandler.Instance.PerformTimeEvent(timeQCRule.EventID);
            if (lstTimeQCEventResults == null || lstTimeQCEventResults.Count <= 0)
            {
                return(null);
            }

            return(DocumentHandler.Instance.CheckDocumentTime(timeQCRule, lstTimeQCEventResults));
        }
Esempio n. 4
0
 /// <summary>
 /// 设置指定行显示的数据,以及绑定的数据
 /// </summary>
 /// <param name="row">指定行</param>
 /// <param name="timeQCRule">绑定的数据</param>
 private void SetRowData(DataTableViewRow row, TimeQCRule timeQCRule)
 {
     if (row == null || row.Index < 0 || timeQCRule == null)
     {
         return;
     }
     row.Tag = timeQCRule;
     row.Cells[this.colRuleID.Index].Value        = timeQCRule.RuleID;
     row.Cells[this.colEvent.Index].Tag           = timeQCRule.EventID;
     row.Cells[this.colEvent.Index].Value         = timeQCRule.EventName;
     row.Cells[this.colDocType.Index].Tag         = timeQCRule.DocTypeID;
     row.Cells[this.colDocType.Index].Value       = timeQCRule.DocTypeName;
     row.Cells[this.colDocTypeAlias.Index].Value  = timeQCRule.DocTypeAlias;
     row.Cells[this.colWrittenPeriod.Index].Value = timeQCRule.WrittenPeriod;
     row.Cells[this.colIsRepeat.Index].Value      = timeQCRule.IsRepeat;
     if (timeQCRule.QCScore > 0)
     {
         row.Cells[this.colQCScore.Index].Value = timeQCRule.QCScore;
     }
     row.Cells[this.colIsValid.Index].Value  = timeQCRule.IsValid;
     row.Cells[this.colRuleDesc.Index].Value = timeQCRule.RuleDesc;
 }
Esempio n. 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            TimeQCRule       timeQCRule = null;
            DataTableViewRow currRow    = this.dataGridView1.CurrentRow;

            if (currRow != null && currRow.Index >= 0)
            {
                timeQCRule = currRow.Tag as TimeQCRule;
            }
            if (timeQCRule == null)
            {
                timeQCRule = new TimeQCRule();
            }
            else
            {
                timeQCRule = timeQCRule.Clone() as TimeQCRule;
            }
            timeQCRule.RuleID = timeQCRule.MakeRuleID();
            int nRowIndex = 0;

            if (currRow != null)
            {
                nRowIndex = currRow.Index + 1;
                DataTableViewRow dataTableViewRow = new DataTableViewRow();
                this.dataGridView1.Rows.Insert(nRowIndex, dataTableViewRow);
            }
            else
            {
                nRowIndex = this.dataGridView1.Rows.Add();
            }
            DataTableViewRow row = this.dataGridView1.Rows[nRowIndex];

            this.SetRowData(row, timeQCRule);
            this.dataGridView1.Focus();
            this.dataGridView1.SelectRow(row);
            this.dataGridView1.SetRowState(row, RowState.New);
        }
Esempio n. 6
0
        /// <summary>
        /// 读取数据库,装载当前DataGridView各行数据
        /// </summary>
        private void LoadGridViewData()
        {
            this.dataGridView1.Rows.Clear();

            //加载时效事件名称字典表,以便下面使用
            Dictionary <string, string> dicTimeEventName = null;

            dicTimeEventName = new Dictionary <string, string>();
            List <TimeQCEvent> lstTimeQCEvents = null;
            short result = EMRDBLib.DbAccess.TimeQCEventAccess.Instance.GetTimeQCEvents(ref lstTimeQCEvents);

            if (result != EMRDBLib.SystemData.ReturnValue.OK &&
                result != EMRDBLib.SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.ShowError("病历时效事件列表下载失败!");
                return;
            }
            for (int index = 0; lstTimeQCEvents != null; index++)
            {
                if (index >= lstTimeQCEvents.Count)
                {
                    break;
                }
                if (lstTimeQCEvents[index] == null)
                {
                    continue;
                }
                string szEventID = lstTimeQCEvents[index].EventID;
                if (string.IsNullOrEmpty(szEventID))
                {
                    continue;
                }
                string szEventName = lstTimeQCEvents[index].EventName;
                if (string.IsNullOrEmpty(szEventName))
                {
                    continue;
                }
                dicTimeEventName.Add(szEventID, szEventName);
            }

            //加载时效事件列表
            List <TimeQCRule> lstTimeQCRules = null;

            result = EMRDBLib.DbAccess.TimeQCRuleAccess.Instance.GetTimeQCRules(ref lstTimeQCRules);
            if (result != EMRDBLib.SystemData.ReturnValue.OK &&
                result != EMRDBLib.SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.Show("病历时效规则列表下载失败!");
                return;
            }
            if (lstTimeQCRules == null || lstTimeQCRules.Count <= 0)
            {
                return;
            }
            for (int index = 0; index < lstTimeQCRules.Count; index++)
            {
                TimeQCRule timeQCRule = lstTimeQCRules[index];
                if (timeQCRule == null)
                {
                    continue;
                }
                string szEventName = timeQCRule.EventID;
                if (!string.IsNullOrEmpty(szEventName))
                {
                    if (dicTimeEventName.ContainsKey(szEventName))
                    {
                        szEventName = dicTimeEventName[szEventName];
                    }
                }
                timeQCRule.EventName = szEventName;

                int nRowIndex        = this.dataGridView1.Rows.Add();
                DataTableViewRow row = this.dataGridView1.Rows[nRowIndex];
                this.SetRowData(row, timeQCRule);
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 保存指定行的数据到远程数据表,需要注意的是:行的删除状态会与其他状态共存
        /// </summary>
        /// <param name="row">指定行</param>
        /// <returns>SystemConsts.ReturnValue</returns>
        private short SaveRowData(DataTableViewRow row)
        {
            if (row == null || row.Index < 0)
            {
                return(EMRDBLib.SystemData.ReturnValue.FAILED);
            }
            if (this.dataGridView1.IsNormalRow(row) || this.dataGridView1.IsUnknownRow(row))
            {
                if (!this.dataGridView1.IsDeletedRow(row))
                {
                    return(EMRDBLib.SystemData.ReturnValue.CANCEL);
                }
            }

            TimeQCRule timeQCRule = row.Tag as TimeQCRule;

            if (timeQCRule == null)
            {
                return(EMRDBLib.SystemData.ReturnValue.FAILED);
            }

            string szRuleID = timeQCRule.RuleID;

            timeQCRule = null;
            if (!this.MakeRowData(row, ref timeQCRule))
            {
                return(EMRDBLib.SystemData.ReturnValue.FAILED);
            }

            short result = EMRDBLib.SystemData.ReturnValue.OK;

            if (this.dataGridView1.IsDeletedRow(row))
            {
                if (!this.dataGridView1.IsNewRow(row))
                {
                    result = EMRDBLib.DbAccess.TimeQCRuleAccess.Instance.DeleteTimeQCRule(szRuleID);
                }
                if (result != EMRDBLib.SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法删除当前记录!");
                    return(EMRDBLib.SystemData.ReturnValue.FAILED);
                }
                this.dataGridView1.Rows.Remove(row);
            }
            else if (this.dataGridView1.IsModifiedRow(row))
            {
                result = EMRDBLib.DbAccess.TimeQCRuleAccess.Instance.UpdateTimeQCRule(timeQCRule);
                if (result != EMRDBLib.SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法更新当前记录!");
                    return(EMRDBLib.SystemData.ReturnValue.FAILED);
                }
                row.Tag = timeQCRule;
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
            else if (this.dataGridView1.IsNewRow(row))
            {
                result = EMRDBLib.DbAccess.TimeQCRuleAccess.Instance.SaveTimeQCRule(timeQCRule);
                if (result != EMRDBLib.SystemData.ReturnValue.OK)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("无法保存当前记录!");
                    return(EMRDBLib.SystemData.ReturnValue.FAILED);
                }
                row.Tag = timeQCRule;
                this.dataGridView1.SetRowState(row, RowState.Normal);
            }
            //刷新orderValue
            EMRDBLib.DbAccess.TimeQCRuleAccess.Instance.UpdateTimeQCRule(timeQCRule);
            return(EMRDBLib.SystemData.ReturnValue.OK);
        }
Esempio n. 8
0
        /// <summary>
        /// 获取指定行最新修改后的数据
        /// </summary>
        /// <param name="row">指定行</param>
        /// <param name="timeQCRule">最新修改后的数据</param>
        /// <returns>bool</returns>
        private bool MakeRowData(DataTableViewRow row, ref TimeQCRule timeQCRule)
        {
            if (row == null || row.Index < 0)
            {
                return(false);
            }
            timeQCRule = new TimeQCRule();

            object cellValue = row.Cells[this.colRuleID.Index].Value;

            if (cellValue != null)
            {
                timeQCRule.RuleID = cellValue.ToString();
            }

            if (this.dataGridView1.IsDeletedRow(row))
            {
                return(true);
            }

            cellValue = row.Cells[this.colEvent.Index].Tag;
            if (cellValue == null || cellValue.ToString().Trim() == string.Empty)
            {
                this.dataGridView1.SelectRow(row);
                MessageBoxEx.Show("您必须给规则选择一个事件!");
                return(false);
            }
            timeQCRule.EventID = cellValue.ToString();

            cellValue = row.Cells[this.colEvent.Index].Value;
            if (cellValue == null || cellValue.ToString().Trim() == string.Empty)
            {
                this.dataGridView1.SelectRow(row);
                MessageBoxEx.Show("您必须给规则选择一个事件!");
                return(false);
            }
            timeQCRule.EventName = cellValue.ToString();

            cellValue = row.Cells[this.colDocType.Index].Tag;
            if (cellValue == null || cellValue.ToString().Trim() == string.Empty)
            {
                this.dataGridView1.SelectRow(row);
                MessageBoxEx.Show("您必须选择病历类型!");
                return(false);
            }
            timeQCRule.DocTypeID = cellValue.ToString();

            cellValue = row.Cells[this.colDocType.Index].Value;
            if (cellValue == null || cellValue.ToString().Trim() == string.Empty)
            {
                this.dataGridView1.SelectRow(row);
                MessageBoxEx.Show("您必须选择病历类型!");
                return(false);
            }
            timeQCRule.DocTypeName = cellValue.ToString();

            cellValue = row.Cells[this.colDocTypeAlias.Index].Value;
            if (cellValue != null)
            {
                timeQCRule.DocTypeAlias = cellValue.ToString();
            }

            cellValue = row.Cells[this.colWrittenPeriod.Index].Value;
            if (cellValue == null || cellValue.ToString().Trim() == string.Empty)
            {
                this.dataGridView1.SelectRow(row);
                MessageBoxEx.Show("您必须输入书写时限!");
                return(false);
            }
            timeQCRule.WrittenPeriod = cellValue.ToString();

            cellValue = row.Cells[this.colIsRepeat.Index].Value;
            if (cellValue != null)
            {
                bool value = false;
                if (bool.TryParse(cellValue.ToString(), out value))
                {
                    timeQCRule.IsRepeat = value;
                }
            }

            cellValue = row.Cells[this.colIsValid.Index].Value;
            if (cellValue != null)
            {
                bool value = false;
                if (bool.TryParse(cellValue.ToString(), out value))
                {
                    timeQCRule.IsValid = value;
                }
            }

            cellValue = row.Cells[this.colQCScore.Index].Value;
            if (cellValue != null && cellValue.ToString().Trim() != "")
            {
                float value = 0f;
                if (!float.TryParse(cellValue.ToString(), out value) ||
                    value < 0 || value >= 100)
                {
                    this.dataGridView1.SelectRow(row);
                    MessageBoxEx.Show("请正确输入质控扣分!");
                    return(false);
                }
                timeQCRule.QCScore = value;
            }

            timeQCRule.OrderValue = row.Index;

            cellValue = row.Cells[this.colRuleDesc.Index].Value;
            if (cellValue != null)
            {
                timeQCRule.RuleDesc = cellValue.ToString();
            }
            return(true);
        }
Esempio n. 9
0
        /// <summary>
        /// 获取所有病历时效规则配置信息列表
        /// </summary>
        /// <param name="lstTimeQCRules">时效规则配置信息列表</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short GetTimeQCRules(ref List <TimeQCRule> lstTimeQCRules)
        {
            if (base.MeddocAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            string szField = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}"
                                           , SystemData.TimeRuleTable.RULE_ID, SystemData.TimeRuleTable.EVENT_ID
                                           , SystemData.TimeRuleTable.DOCTYPE_ID, SystemData.TimeRuleTable.DOCTYPE_NAME
                                           , SystemData.TimeRuleTable.DOCTYPE_ALIAS, SystemData.TimeRuleTable.WRITTEN_PERIOD
                                           , SystemData.TimeRuleTable.IS_REPEAT, SystemData.TimeRuleTable.IS_VALID
                                           , SystemData.TimeRuleTable.QC_SCORE, SystemData.TimeRuleTable.ORDER_VALUE
                                           , SystemData.TimeRuleTable.RULE_DESC);

            string szSQL = string.Format(SystemData.SQL.SELECT_ORDER_ASC
                                         , szField, SystemData.DataTable.TIME_RULE, SystemData.TimeRuleTable.ORDER_VALUE);

            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 (lstTimeQCRules == null)
                {
                    lstTimeQCRules = new List <TimeQCRule>();
                }
                do
                {
                    TimeQCRule timeQCRule = new TimeQCRule();
                    timeQCRule.RuleID = dataReader.GetString(0);
                    if (!dataReader.IsDBNull(1))
                    {
                        timeQCRule.EventID = dataReader.GetString(1);
                    }
                    if (!dataReader.IsDBNull(2))
                    {
                        timeQCRule.DocTypeID = dataReader.GetString(2);
                    }
                    if (!dataReader.IsDBNull(3))
                    {
                        timeQCRule.DocTypeName = dataReader.GetString(3);
                    }
                    if (!dataReader.IsDBNull(4))
                    {
                        timeQCRule.DocTypeAlias = dataReader.GetString(4);
                    }
                    if (!dataReader.IsDBNull(5))
                    {
                        timeQCRule.WrittenPeriod = dataReader.GetString(5);
                    }
                    if (!dataReader.IsDBNull(6))
                    {
                        timeQCRule.IsRepeat = dataReader.GetValue(6).ToString() == "1";
                    }
                    if (!dataReader.IsDBNull(7))
                    {
                        timeQCRule.IsValid = dataReader.GetValue(7).ToString() == "1";
                    }
                    if (!dataReader.IsDBNull(8))
                    {
                        timeQCRule.QCScore = float.Parse(dataReader.GetValue(8).ToString());
                    }
                    if (!dataReader.IsDBNull(9))
                    {
                        timeQCRule.OrderValue = int.Parse(dataReader.GetValue(9).ToString());
                    }
                    if (!dataReader.IsDBNull(10))
                    {
                        timeQCRule.RuleDesc = dataReader.GetString(10);
                    }
                    lstTimeQCRules.Add(timeQCRule);
                } while (dataReader.Read());
                return(SystemData.ReturnValue.OK);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("ConfigAccess.GetTimeQCRules", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            finally { base.MeddocAccess.CloseConnnection(false); }
        }
Esempio n. 10
0
        /// <summary>
        /// 根据指定时效规则以及规则对应的时效事件执行结果,检查已写病历列表
        /// </summary>
        /// <param name="timeQCRule">时效规则</param>
        /// <param name="lstTimeQCEventResults">规则对应的时效事件执行结果</param>
        /// <returns>已写病历列表时效检查结果</returns>
        public List <TimeCheckResult> CheckDocumentTime(TimeQCRule timeQCRule
                                                        , List <TimeQCEventResult> lstTimeQCEventResults)
        {
            if (timeQCRule == null || string.IsNullOrEmpty(timeQCRule.DocTypeID))
            {
                return(null);
            }

            //获取时效事件名称等信息
            TimeQCEvent timeQCEvent =
                TimeEventHandler.Instance.GetTimeQCEvent(timeQCRule.EventID);

            if (timeQCEvent == null)
            {
                return(null);
            }

            //创建应书写的病历时间表
            List <TimeCheckResult> lstTimeCheckResults =
                this.CreateTimeCheckTable(timeQCRule, lstTimeQCEventResults);

            if (lstTimeCheckResults == null || lstTimeCheckResults.Count <= 0)
            {
                return(null);
            }
            //附加本规则未书写的病历数到未写病历计数器
            TimeCheckEngine.Instance.UnwriteCount += lstTimeCheckResults.Count;
            List <MedDocInfo> lstDocInfos = null;

            for (int index = 0; index < lstTimeCheckResults.Count; index++)
            {
                TimeCheckResult timeCheckResult = lstTimeCheckResults[index];
                if (timeCheckResult == null)
                {
                    continue;
                }
                timeCheckResult.EventID   = timeQCEvent.EventID;
                timeCheckResult.EventName = timeQCEvent.EventName;
                timeCheckResult.IsVeto    = timeQCRule.IsVeto;

                //查找当前时效检查表记录对应的文档
                string szDocTypeIDList = timeCheckResult.DocTypeID;
                lstDocInfos = this.GetDocumentList(szDocTypeIDList);
                if (lstDocInfos == null || lstDocInfos.Count <= 0)
                {
                    timeCheckResult.WrittenState = WrittenState.Unwrite;
                    continue;
                }
                lstDocInfos.Sort(this.CompareByDocTime);
                //核对病历内部时间以及实际书写时间
                for (int nDocIndex = 0; nDocIndex < lstDocInfos.Count; nDocIndex++)
                {
                    MedDocInfo docInfo = lstDocInfos[nDocIndex];

                    //RecordTime作为文档补写依据。文档内部时间在时效规则开始时间和截止时间之间的作为补写文档
                    //然后通过DocTime文档的真实时间来判断超时情况。
                    if (docInfo.RECORD_TIME != docInfo.DefaultTime &&
                        timeCheckResult.IsRepeat &&
                        (docInfo.RECORD_TIME < timeCheckResult.StartTime || docInfo.RECORD_TIME > timeCheckResult.EndTime))
                    {
                        continue;
                    }
                    if (timeCheckResult.EventTime > docInfo.DOC_TIME &&
                        timeCheckResult.EventTime.AddHours(-3) > docInfo.RECORD_TIME &&
                        (docInfo.DOC_TITLE.Contains("首次病程记录") || docInfo.DOC_TITLE.Contains("手术记录") || docInfo.DOC_TITLE.Contains("术后")))
                    {
                        continue;
                    }
                    if ((docInfo.DOC_TITLE.Contains("术前小结") || docInfo.DOC_TITLE.Contains("术前讨论")) &&
                        timeCheckResult.EventTime > docInfo.RECORD_TIME.AddDays(3))
                    {
                        //术前三天以上的术前讨论和术前小结,不作为本次手术的文档
                        continue;
                    }
                    long nCurrSpan = timeCheckResult.TimeSpan(docInfo); //DocTime-StartTime
                    if (nCurrSpan < 0)
                    {
                        timeCheckResult.WrittenState = WrittenState.Early;
                    }
                    else if (docInfo.DOC_TIME.CompareTo(timeCheckResult.EndTime) <= 0)
                    {
                        timeCheckResult.WrittenState = WrittenState.Normal;
                    }
                    else
                    {
                        timeCheckResult.WrittenState = WrittenState.Timeout;
                    }
                    timeCheckResult.DocTime     = docInfo.DOC_TIME;
                    timeCheckResult.RecordTime  = docInfo.RECORD_TIME;
                    timeCheckResult.DocID       = docInfo.DOC_ID;
                    timeCheckResult.CreatorName = docInfo.CREATOR_NAME;
                    timeCheckResult.CreatorID   = docInfo.CREATOR_ID;
                    break;
                }
            }

            //病历书写情况统计
            foreach (TimeCheckResult result in lstTimeCheckResults)
            {
                switch (result.WrittenState)
                {
                case WrittenState.Early:
                    TimeCheckEngine.Instance.EarlyCount += 1;
                    break;

                case WrittenState.Normal:
                    TimeCheckEngine.Instance.NormalCount += 1;
                    break;

                case WrittenState.Unwrite:
                    TimeCheckEngine.Instance.UnwriteCount += 1;
                    break;

                case WrittenState.Timeout:
                    TimeCheckEngine.Instance.TimeoutCount += 1;
                    break;

                case WrittenState.Uncheck:
                    result.WrittenState = WrittenState.Unwrite;
                    break;

                default:
                    break;
                }
            }
            return(lstTimeCheckResults);
        }
Esempio n. 11
0
        /// <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);
        }