Exemplo n.º 1
0
        /// <summary>
        /// 插入符合条件后触发的时限规则
        /// </summary>
        /// <param name="patient">当前规则的责任医生代码</param>
        /// <param name="record"></param>
        public void InsertPatientRuleRecord(DoctorManagerPatient patient, QCRuleRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }
            int retxh;

            //寻找最大值
            using (IDataReader reader = _sqlHelper.ExecuteReader(cstQueryMaxID))
            {
                reader.Read();
                if (reader.IsDBNull(0))
                {
                    retxh = 0;
                }
                else
                {
                    retxh = Convert.ToInt32(reader.GetValue(0)) + 1;
                }
            }
            record.Xh = retxh;
            SqlParameter[] insertparams = InitPatientRuleParams(patient, record);


            _sqlHelper.ExecuteNoneQuery(cstInsertRuleRecord, insertparams);
            record.Xh = decimal.Parse(retxh.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加规则纪录
        /// </summary>
        /// <param name="patid">病人Id</param>
        /// <param name="eprid">病历Id</param>
        /// <param name="opdoctor">操作医生</param>
        /// <param name="conditionType">时限规则条件类别</param>
        /// <param name="conditionObject">条件对象,用来定位具体的条件</param>
        /// <param name="conditionTime">条件发生时间</param>
        public void AddRuleRecord(int patid, int eprid, string opdoctor, QCConditionType conditionType, object conditionObject, DateTime conditionTime)
        {
            DoctorManagerPatient dmp = _patientdal.SelectDoctorManagerPatient(patid);

            if (dmp == null)
            {
                return;
            }

            QCCondition qcc = QCCondition.SelectQCCondition(conditionType, conditionObject);

            if (qcc == null)
            {
                return;
            }

            IList <QCRule> rules = QCRule.GetRulesByCondition(qcc);

            foreach (QCRule rule in rules)
            {
                QCRuleRecord qcrr = new QCRuleRecord(patid, eprid, rule);
                qcrr.ConditionTime  = conditionTime;
                qcrr.ConditionState = CompleteType.Completed;
                qcrr.RuleState      = RuleRecordState.UndoIntime;
                qcrr.CreateDoctor   = opdoctor;
                SetQcRuleRecordState(rule, qcrr);
                _rulerecorddal.InsertPatientRuleRecord(dmp, qcrr);
            }
        }
Exemplo n.º 3
0
 public void TriggerRelateRuleRecord(QCRuleRecord record)
 {
     if (record == null)
     {
         throw new ArgumentNullException("record");
     }
     SqlParameter[] triggerparams = InitTriggerRelateRuleParams(record);
     _sqlHelper.ExecuteNoneQuery(cstTriggerRelateRuleRecord, triggerparams);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 同步相关规则记录
 /// </summary>
 /// <param name="record"></param>
 public void SyncRelateRuleRecord(QCRuleRecord record)
 {
     if (record == null)
     {
         throw new ArgumentNullException("record");
     }
     SqlParameter[] updateparams = InitRelateRecordParams(record);
     _sqlHelper.ExecuteNoneQuery(cstSyncRelateRuleRecord, updateparams);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 取消时限规则
 /// </summary>
 /// <param name="record"></param>
 public void CancelPatientRuleRecord(QCRuleRecord record)
 {
     if (record == null)
     {
         throw new ArgumentNullException("record");
     }
     SqlParameter[] cancelparams = InitCancelRuleParams(record);
     _sqlHelper.ExecuteNoneQuery(cstCancelRuleRecord, cancelparams);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 更新时限规则的状态
 /// </summary>
 /// <param name="patient">当前规则的责任医生代码</param>
 /// <param name="record"></param>
 public void UpdatePatientRuleRecord(DoctorManagerPatient patient, QCRuleRecord record)
 {
     if (record == null)
     {
         throw new ArgumentNullException("record");
     }
     SqlParameter[] updateparams = InitPatientRuleParams(patient, record);
     _sqlHelper.ExecuteNoneQuery(cstUpdateRuleRecord, updateparams);
 }
Exemplo n.º 7
0
        SqlParameter[] InitTriggerRelateRuleParams(QCRuleRecord record)
        {
            SqlParameter paramXh   = new SqlParameter(param_xh, SqlDbType.Decimal);
            SqlParameter paramJlzt = new SqlParameter(param_jlzt, SqlDbType.Int);

            paramXh.Value   = record.Xh;
            paramJlzt.Value = (int)RecordState.ValidWait;

            return(new SqlParameter[] { paramXh, paramJlzt });
        }
Exemplo n.º 8
0
        /// <summary>
        /// 设置规则生效,无结果限定的规则
        /// </summary>
        /// <param name="rulerecord"></param>
        /// <param name="opdoctor"></param>
        public void EffectRuleRecord(QCRuleRecord rulerecord, string opdoctor)
        {
            rulerecord.RuleState = RuleRecordState.DoIntime;
            _rulerecorddal.EffectRuleRecord(rulerecord);
            DoctorManagerPatient dmp = _patientdal.SelectDoctorManagerPatient(rulerecord.PatId);

            DataTable dtrulerecords = SelectPatientRuleRecords(rulerecord.PatId, false);
            Collection <QCRuleRecord> rulerecords = GetRuleRecordsCollection(dtrulerecords);

            DealRelateRuleRecords(rulerecords, rulerecord.PatId, rulerecord.EprId, rulerecord, dmp, DateTime.Now, opdoctor);
        }
Exemplo n.º 9
0
        SqlParameter[] InitRelateRecordParams(QCRuleRecord record)
        {
            SqlParameter paramXh   = new SqlParameter(param_xh, SqlDbType.Decimal);
            SqlParameter paramWgzt = new SqlParameter(param_wgzt, SqlDbType.Int);
            SqlParameter paramJgsj = new SqlParameter(param_jgsj, SqlDbType.VarChar, 19);

            paramXh.Value   = record.Xh;
            paramWgzt.Value = (int)record.RuleState;
            paramJgsj.Value = record.ResultTime.ToString("yyyy-MM-dd HH:mm:ss"); //record.ResultTime.ToString("yyyy-MM-dd") + " " + record.ResultTime.ToString("T");

            return(new SqlParameter[] { paramXh, paramWgzt, paramJgsj });
        }
Exemplo n.º 10
0
        SqlParameter[] InitEffectRuleParams(QCRuleRecord record)
        {
            SqlParameter paramXh = new SqlParameter(param_xh, SqlDbType.Decimal);

            paramXh.Value = record.Xh;
            SqlParameter paramWgzt = new SqlParameter(param_wgzt, SqlDbType.Int);

            paramWgzt.Value = (int)record.RuleState;
            return(new SqlParameter[] {
                paramXh, paramWgzt
            });
        }
Exemplo n.º 11
0
        SqlParameter[] InitPatientRuleParams(DoctorManagerPatient patient, QCRuleRecord record)
        {
            SqlParameter paramXh     = new SqlParameter(param_xh, SqlDbType.Decimal);
            SqlParameter paramSyxh   = new SqlParameter(param_syxh, SqlDbType.Int);
            SqlParameter paramBlxh   = new SqlParameter(param_blxh, SqlDbType.Int);
            SqlParameter paramGzdm   = new SqlParameter(param_gzdm, SqlDbType.VarChar, 64);
            SqlParameter paramTjdm   = new SqlParameter(param_tjdm, SqlDbType.VarChar, 64);
            SqlParameter paramTjsj   = new SqlParameter(param_tjsj, SqlDbType.VarChar, 19);
            SqlParameter paramTjzt   = new SqlParameter(param_tjzt, SqlDbType.Int);
            SqlParameter paramJgdm   = new SqlParameter(param_jgdm, SqlDbType.VarChar, 64);
            SqlParameter paramJgsj   = new SqlParameter(param_jgsj, SqlDbType.VarChar, 19);
            SqlParameter paramJgzt   = new SqlParameter(param_jgzt, SqlDbType.Int);
            SqlParameter paramWgzt   = new SqlParameter(param_wgzt, SqlDbType.Int);
            SqlParameter paramTsxx   = new SqlParameter(param_tsxx, SqlDbType.VarChar, 255);
            SqlParameter paramWgxx   = new SqlParameter(param_wgxx, SqlDbType.VarChar, 255);
            SqlParameter paramCzsj   = new SqlParameter(param_czsj, SqlDbType.VarChar, 19);
            SqlParameter paramZgdm   = new SqlParameter(param_zgdm, SqlDbType.VarChar, 6);
            SqlParameter paramCjzgdm = new SqlParameter(param_cjzgdm, SqlDbType.VarChar, 6);
            SqlParameter paramZrjb   = new SqlParameter(param_zrjb, SqlDbType.Int);
            SqlParameter paramXhjs   = new SqlParameter(param_xhjs, SqlDbType.Int);
            SqlParameter paramJlzt   = new SqlParameter(param_jlzt, SqlDbType.Int);
            SqlParameter paramMemo   = new SqlParameter(param_memo, SqlDbType.VarChar, 64);

            paramXh.Value   = record.Xh;
            paramSyxh.Value = record.PatId;
            paramBlxh.Value = record.EprId;
            paramGzdm.Value = record.Rule.Id;
            paramTjdm.Value = record.Rule.Condition.Id;
            paramTjsj.Value = record.ConditionTime.ToString("yyyy-MM-dd HH:mm:ss"); //record.ConditionTime.ToString("yyyy-MM-dd") + " " + record.ConditionTime.ToString("T");
            paramTjzt.Value = (int)record.ConditionState;
            if (record.Rule.Result != null)
            {
                paramJgdm.Value = record.Rule.Result.Id;
            }
            paramJgsj.Value   = record.ResultTime.ToString("yyyy-MM-dd HH:mm:ss"); //record.ResultTime.ToString("yyyy-MM-dd") + " " + record.ResultTime.ToString("T");
            paramJgzt.Value   = (int)record.ResultState;
            paramWgzt.Value   = (int)record.RuleState;
            paramTsxx.Value   = record.Rule.TipInfo;
            paramWgxx.Value   = record.Rule.WarnInfo;
            paramCzsj.Value   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("T");
            paramZgdm.Value   = GetDutyDoctorId(patient, record.Rule.Dutylevel);
            paramCjzgdm.Value = record.CreateDoctor;
            paramZrjb.Value   = (int)record.Rule.Dutylevel + ConstRes.cstDoctorLevelNo;
            paramXhjs.Value   = record.LoopCount;
            paramJlzt.Value   = (int)record.RecordState;
            paramMemo.Value   = string.Empty;

            return(new SqlParameter[] { paramXh,
                                        paramSyxh, paramBlxh, paramGzdm, paramTjdm, paramTjsj, paramTjzt,
                                        paramJgdm, paramJgsj, paramJgzt, paramWgzt, paramTsxx, paramWgxx,
                                        paramCzsj, paramZgdm, paramCjzgdm, paramZrjb, paramXhjs, paramJlzt, paramMemo });
        }
Exemplo n.º 12
0
 void DealLoopRule(int patid, int eprid, QCRuleRecord qcrr, DoctorManagerPatient dmp, DateTime resultTime, string opdoctor)
 {
     if (qcrr.LoopCount < qcrr.Rule.LoopTimes && qcrr.Rule.LoopTimes > 0)
     {
         QCRuleRecord qcrrloop = new QCRuleRecord(patid, eprid, qcrr.Rule);
         qcrrloop.ConditionTime  = resultTime;
         qcrrloop.ConditionState = CompleteType.Completed;
         qcrrloop.RuleState      = RuleRecordState.UndoIntime;
         qcrrloop.CreateDoctor   = opdoctor;
         qcrrloop.LoopCount      = qcrr.LoopCount + 1;
         _rulerecorddal.InsertPatientRuleRecord(dmp, qcrrloop);
     }
 }
Exemplo n.º 13
0
        Collection <QCRuleRecord> GetRuleRecordsCollection(DataTable table)
        {
            Collection <QCRuleRecord> qcrrs = new Collection <QCRuleRecord>();

            if (table != null)
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    QCRuleRecord qcrr = _rulerecorddal.DataRow2QCRuleRecord(table.Rows[i]);
                    qcrrs.Add(qcrr);
                }
            }

            return(qcrrs);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 取得指定处理类型的时限纪录
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public Collection <QCRuleRecord> GetRuleRecords(RuleDealType type)
        {
            Collection <QCRuleRecord> records = new Collection <QCRuleRecord>();
            DataSet ds = _rulerecorddal.GetUndoRulesDataSetByDealType(type);

            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    QCRuleRecord qcrr = _rulerecorddal.DataRow2QCRuleRecord(dt.Rows[i]);
                    if (qcrr != null)
                    {
                        records.Add(qcrr);
                    }
                }
            }
            return(records);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 由于条件取消导致规则记录取消
        /// </summary>
        /// <param name="patid"></param>
        /// <param name="eprid"></param>
        /// <param name="opdoctor"></param>
        /// <param name="conditionType"></param>
        /// <param name="conditionObject"></param>
        /// <param name="conditionTime"></param>
        public void CancelRuleRecord(int patid, int eprid, string opdoctor, QCConditionType conditionType, object conditionObject, DateTime conditionTime)
        {
            DoctorManagerPatient dmp = _patientdal.SelectDoctorManagerPatient(patid);

            if (dmp == null)
            {
                return;
            }

            QCCondition qcc = QCCondition.SelectQCCondition(conditionType, conditionObject);

            if (qcc == null)
            {
                return;
            }

            IList <QCRule> rules = QCRule.GetRulesByCondition(qcc);

            if (rules == null || rules.Count == 0)
            {
                return;
            }

            DataTable dtrulerecords = SelectPatientRuleRecords(patid, false);
            Collection <QCRuleRecord> rulerecords = GetRuleRecordsCollection(dtrulerecords);

            for (int i = 0; i < rulerecords.Count; i++)
            {
                QCRuleRecord qcrr = rulerecords[i];
                if (qcrr.ResultState == CompleteType.Completed)
                {
                    continue;
                }
                QCRule existsrule = ((List <QCRule>) rules).Find(delegate(QCRule rule)
                {
                    return(rule.Id == qcrr.Rule.Id);
                });
                qcrr.RecordState = RecordState.Invalid;
                _rulerecorddal.UpdatePatientRuleRecord(dmp, qcrr);
            }
        }
Exemplo n.º 16
0
        void SetQcRuleRecordState(QCRule rule, QCRuleRecord qcrr)
        {
            switch (rule.DealType)
            {
            case RuleDealType.Once:
            case RuleDealType.Loop:
                qcrr.RecordState = RecordState.Valid;
                break;

            case RuleDealType.NeedTrigger:
                qcrr.RecordState = RecordState.ValidWait;
                break;

            case RuleDealType.InnerForTrigger:
                qcrr.RecordState = RecordState.ValidNonVisible;
                break;

            default:
                break;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 数据行 -> 时限纪录
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public QCRuleRecord DataRow2QCRuleRecord(DataRow row)
        {
            decimal      xh     = decimal.Parse(row[col_xh].ToString());
            int          patid  = int.Parse(row[col_syxh].ToString());
            int          eprid  = int.Parse(row[col_blxh].ToString());
            QCRule       rule   = QCRule.SelectQCRule(row[col_gzdm].ToString());
            QCRuleRecord record = new QCRuleRecord(xh, patid, eprid, rule);

            record.CreateDoctor   = row[col_cjzgdm].ToString();
            record.CreateTime     = DateTime.Parse(row[col_czsj].ToString());
            record.DutyDoctor     = row[col_zgdm].ToString();
            record.ConditionTime  = DateTime.Parse(row[col_tjsj].ToString());
            record.ConditionState = (CompleteType)int.Parse(row[col_tjzt].ToString());
            record.ResultTime     = DateTime.Parse(row[col_jgsj].ToString());
            record.ResultState    = (CompleteType)int.Parse(row[col_jgzt].ToString());
            record.RuleState      = (RuleRecordState)int.Parse(row[col_wgzt].ToString());
            if (row[col_xhjs] != DBNull.Value)
            {
                record.LoopCount = int.Parse(row[col_xhjs].ToString());
            }
            return(record);
        }
Exemplo n.º 18
0
 /// <summary>
 /// 设置规则纪录完成状态
 /// </summary>
 /// <param name="rulerecord"></param>
 public void EffectRuleRecord(QCRuleRecord rulerecord)
 {
     SqlParameter[] effectparams = InitEffectRuleParams(rulerecord);
     _sqlHelper.ExecuteNoneQuery(cstEffectRuleRecord, effectparams);
 }
Exemplo n.º 19
0
        /// <summary>
        /// edit by Yanqiao.Cai 2012-12-10
        /// 1、add try ... catch
        /// 2、修复未将对象引用到实例
        /// </summary>
        /// <return></return>
        Collection <QCRuleRecord> DealRelateRuleRecords(Collection <QCRuleRecord> rulerecords, int patid, int eprid, QCRuleRecord qcrr, DoctorManagerPatient dmp, DateTime resultTime, string opdoctor)
        {
            try
            {
                //如果是循环发生的时限规则,考虑增加新的规则纪录
                //例如每日病程
                switch (qcrr.Rule.DealType)
                {
                case RuleDealType.Loop:
                    DealLoopRule(patid, eprid, qcrr, dmp, resultTime, opdoctor);
                    break;

                default:
                    break;
                }

                Collection <QCRuleRecord> relaterecords = GetRelateRuleRecords(rulerecords, qcrr);
                //处理相关规则
                if (null != qcrr && null != qcrr.Rule && qcrr.Rule.RelateRules != null && qcrr.Rule.RelateRules.Count > 0)
                {
                    switch (qcrr.Rule.RelateDealType)
                    {
                    case RelateRuleDealType.CancelRule:
                        _rulerecorddal.CancelRelateRuleRecord(qcrr);
                        break;

                    case RelateRuleDealType.SyncRule:
                        _rulerecorddal.SyncRelateRuleRecord(qcrr);
                        foreach (QCRuleRecord relateqcrr in relaterecords)
                        {
                            if (relateqcrr.Rule.DealType == RuleDealType.Loop)
                            {
                                DealLoopRule(patid, eprid, relateqcrr, dmp, resultTime, opdoctor);
                            }
                        }
                        break;

                    case RelateRuleDealType.GenRule:
                        if (qcrr.Rule.DealType == RuleDealType.InnerForTrigger)
                        {
                            _rulerecorddal.TriggerRelateRuleRecord(qcrr);
                        }
                        break;

                    default:
                        break;
                    }
                }
                return(relaterecords);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 更新规则纪录(根据发生的结果更新已经存在的规则纪录)
        /// </summary>
        /// <param name="patid"></param>
        /// <param name="eprid"></param>
        /// <param name="opdoctor"></param>
        /// <param name="resultType"></param>
        /// <param name="resultObject"></param>
        /// <param name="resultTime"></param>
        public void UpdateRuleRecord(int patid, int eprid, string opdoctor, QCResultType resultType, object resultObject, DateTime resultTime)
        {
            DoctorManagerPatient dmp = _patientdal.SelectDoctorManagerPatient(patid);

            if (dmp == null)
            {
                return;
            }

            QCResult qcr = QCResult.SelectQCResult(resultType, resultObject);

            if (qcr == null)
            {
                return;
            }

            IList <QCRule> rules = QCRule.GetRulesByResult(qcr);

            if (rules == null || rules.Count == 0)
            {
                return;
            }

            DataTable dtrulerecords = SelectPatientRuleRecords(patid, false);
            Collection <QCRuleRecord> rulerecords = GetRuleRecordsCollection(dtrulerecords);
            Collection <decimal>      dealedXhs   = new Collection <decimal>();

            for (int i = 0; i < rulerecords.Count; i++)
            {
                QCRuleRecord qcrr = rulerecords[i];
                if (qcrr.ResultState == CompleteType.Completed)
                {
                    continue;
                }
                if (((List <QCRule>) rules).Find(
                        delegate(QCRule rule)
                {
                    return(rule.Id == qcrr.Rule.Id);
                }
                        ) == null
                    )
                {
                    continue;
                }
                if (dealedXhs.IndexOf(qcrr.Xh) != -1)
                {
                    continue;
                }
                qcrr.ResultTime  = resultTime;
                qcrr.ResultState = CompleteType.Completed;
                TimeSpan timelimit = qcrr.ResultTime - qcrr.ConditionTime;
                if (timelimit <= qcrr.Rule.Timelimit)
                {
                    qcrr.RuleState = RuleRecordState.DoIntime;
                }
                else
                {
                    qcrr.RuleState = RuleRecordState.DoOuttime;
                }

                _rulerecorddal.UpdatePatientRuleRecord(dmp, qcrr);

                Collection <QCRuleRecord> dealeds = DealRelateRuleRecords(rulerecords, patid, eprid, qcrr, dmp, resultTime, opdoctor);
                foreach (QCRuleRecord dealrecord in dealeds)
                {
                    dealedXhs.Add(dealrecord.Xh);
                }
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// edit by Yanqiao.Cai 2012-12-10
 /// 1、add try ... catch
 /// 2、修复未将对象引用到实例
 /// </summary>
 /// <return></return>
 Collection <QCRuleRecord> GetRelateRuleRecords(Collection <QCRuleRecord> records, QCRuleRecord record)
 {
     try
     {
         Collection <QCRuleRecord> relaterecords = new Collection <QCRuleRecord>();
         if (records != null && record != null)
         {
             foreach (QCRuleRecord qcrr in records)
             {
                 if (qcrr.ResultState == CompleteType.NonComplete && ContainRule(null == qcrr.Rule ? "" : qcrr.Rule.Id, null == record.Rule ? null : record.Rule.RelateRules))
                 {
                     relaterecords.Add(qcrr);
                 }
             }
         }
         return(relaterecords);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }