Пример #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());
        }
Пример #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);
            }
        }
Пример #3
0
        string GetDutyDoctorId(DoctorManagerPatient patient, DutyLevel dutylevel)
        {
            if (patient == null)
            {
                return(string.Empty);
            }

            string doctor = string.Empty;

            switch (dutylevel)
            {
            case DutyLevel.All:
                break;

            case DutyLevel.CWYS:
                doctor = patient.Resident;
                break;

            case DutyLevel.ZZYS:
                doctor = patient.Attend;
                break;

            case DutyLevel.ZRYS:
                doctor = patient.Chief;
                break;

            default:
                break;
            }
            return(doctor);
        }
Пример #4
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);
 }
Пример #5
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);
        }
Пример #6
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 });
        }
Пример #7
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);
     }
 }
Пример #8
0
        /// <summary>
        /// 取得当前医生分管的病人列表(包括下级医生)
        /// <param name="doctorid"></param>
        /// <param name="includeSubDoctor"></param>
        /// </summary>
        public Collection <DoctorManagerPatient> SelectDoctorPatients(string doctorid, bool includeSubDoctor, int NoOfInpat)
        {
            Collection <DoctorManagerPatient> cdmps = new Collection <DoctorManagerPatient>();
            DataTable    doctorzPatients            = null;
            SqlParameter paramYsdm = new SqlParameter("UserId", SqlDbType.VarChar, 6);

            paramYsdm.Value = doctorid;
            if (NoOfInpat > 0)
            {
                SqlParameter paramSyxh = new SqlParameter("NoOfInpat", SqlDbType.Int);
                paramSyxh.Value = NoOfInpat;
                doctorzPatients = _sqlHelper.ExecuteDataTable(
                    CstSelectPatientBySyxhYsdm, new SqlParameter[] { paramYsdm, paramSyxh });
            }
            else
            {
                string sql = CstSelectPatientsOnlySelf;
                if (includeSubDoctor)
                {
                    sql = CstSelectPatientsIncludeSub;
                }
                doctorzPatients = _sqlHelper.ExecuteDataTable(
                    sql, new SqlParameter[] { paramYsdm });
            }
            if (doctorzPatients != null)
            {
                for (int i = 0; i < doctorzPatients.Rows.Count; i++)
                {
                    DataRow dr = doctorzPatients.Rows[i];
                    DoctorManagerPatient dmp =
                        new DoctorManagerPatient(int.Parse(dr["NoOfInpat"].ToString()),
                                                 dr["Name"].ToString(),
                                                 dr["PatID"].ToString(),
                                                 dr["Resident"].ToString(),
                                                 dr["Attend"].ToString(),
                                                 dr["Chief "].ToString());
                    cdmps.Add(dmp);
                }
            }

            return(cdmps);
        }
Пример #9
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);
            }
        }
Пример #10
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);
            }
        }
Пример #11
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);
                }
            }
        }