/// <summary>
        /// 自动检测
        /// </summary>
        /// <param name="recorddetialid"></param>
        /// <param name="mr_class"></param>
        /// <returns></returns>
        public void GetResultPoint(string noofinpat, string pname, string id)
        {
            try
            {
                int       hours;
                DataTable dt = new DataTable();
                string    sql;
                string    errordoctor = GetRESIDENT(noofinpat);
                //先判断有无病案首页
                //sql = string.Format(@"select t.iem_mainpage_no from IEM_MAINPAGE_BASICINFO_2012 t where t.noofinpat='{0}' ", noofinpat);
                //edit by wyt 增加有效性验证 2012-11-23
                sql = string.Format(@"select t.iem_mainpage_no from IEM_MAINPAGE_BASICINFO_2012 t where t.noofinpat='{0}' and t.valide = 1", noofinpat);
                dt  = m_App.SqlHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count < 1)
                {
                    //无病案首页

                    m_SqlManger.InsertDB(341, "5", id, noofinpat, pname, "无首页", errordoctor);
                }
                //出院(死亡)记录
                //                sql = string.Format(@"select nvl(round(to_number(to_date(r.createtime, 'yyyy-mm-dd hh24:mi:ss') - to_date(i.outhosdate, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours,
                //       r.name from inpatient i,recorddetail r where r.noofinpat = i.noofinpat  and r.noofinpat = '{0}' and (substr(r.name, 0, 4) = '出院记录' or substr(r.name, 0, 4) = '死亡记录') order by incount", noofinpat);
                //edit by wyt 增加有效性验证 edit by wyt 2012-11-23
                //sql = string.Format(@"select nvl(round(to_number(to_date(r.createtime, 'yyyy-mm-dd hh24:mi:ss') - to_date(i.outhosdate, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours,
                //r.name ,r.owner from inpatient i,recorddetail r where r.noofinpat = i.noofinpat  and r.noofinpat = '{0}' and (substr(r.name, 0, 4) = '出院记录' or substr(r.name, 0, 4) = '死亡记录') and r.valid = 1 order by incount", noofinpat);
                sql = string.Format(@"select  r.id from  recorddetail r where   r.noofinpat = '{0}' and (substr(r.name, 0, 4) = '出院记录' or substr(r.name, 0, 4) = '死亡记录') and r.valid = 1 ", noofinpat);
                dt  = m_App.SqlHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    sql = string.Format(@" select i.outhosdate  from inpatient i where i.noofinpat = '{0}' ", noofinpat);
                    dt  = m_App.SqlHelper.ExecuteDataTable(sql);
                    if (dt.Rows[0][0].ToString().Trim() != "")
                    {
                        m_SqlManger.InsertDB(343, "10", id, noofinpat, pname, "缺患者出院(死亡)记录", errordoctor);
                    }
                }
                else
                {
                    //if (dt.Rows.Count > 0)
                    //{
                    //    if (int.Parse(dt.Rows[0][0].ToString()) > 24)
                    //    {
                    //        m_SqlManger.InsertDB(343, "10", id, noofinpat, pname, "患者出院(死亡)起24小时未完成", dt.Rows[0]["OWNER"].ToString());
                    //    }
                    //}
                }
                //入院记录
                //                sql = string.Format(@"select nvl(round(to_number(to_date(r.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                       to_date(i.outhosdate, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours, r.name from inpatient i, recorddetail r
                //                       where r.noofinpat = i.noofinpat and r.noofinpat = '{0}' and substr(r.name, 0, 4) = '入院记录'", noofinpat);
                //edit by wyt 增加有效性验证 2012-11-23
                //edit by wyt 修改入院时间绑定错误 2012-11-26
                //                sql = string.Format(@"select nvl(round(to_number(to_date(r.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                       to_date(i.outhosdate, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours, r.name from inpatient i, recorddetail r
                //                       where r.noofinpat = i.noofinpat and r.noofinpat = '{0}' and substr(r.name, 0, 4) = '入院记录' and r.valid = 1", noofinpat);
                sql = string.Format(@"select t.id from recorddetail t where r.noofinpat = i.noofinpat and r.noofinpat = '{0}' and substr(r.name, 0, 4) = '入院记录' and r.valid = 1", noofinpat);
                dt  = m_App.SqlHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    //if (int.Parse(dt.Rows[0][0].ToString()) > 24)
                    //{
                    //    m_SqlManger.InsertDB(347, "25", id, noofinpat, pname, "入院记录未在患者入院后24小时内完成", dt.Rows[0]["OWNER"].ToString());
                    //}
                }
                if (dt.Rows.Count < 1)
                {
                    m_SqlManger.InsertDB(347, "25", id, noofinpat, pname, "缺入院记录", errordoctor);
                }
                //首次病程记录
                //sql = string.Format(@"select t.id from recorddetail t where  substr(t.name, 0, 4) = '首次病程' and t.FIRSTDAILYFLAG='1' and t.noofinpat= '{0}'", noofinpat);
                //edit by wyt 增加病程记录文件有效性验证 2012-11-23
                sql = string.Format(@"select t.id from recorddetail t where  substr(t.name, 0, 4) = '首次病程' and t.FIRSTDAILYFLAG='1' and t.noofinpat= '{0}' and t.valid = 1", noofinpat);
                dt  = m_App.SqlHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count < 1)
                {
                    m_SqlManger.InsertDB(370, "25", id, noofinpat, pname, "缺首次病程记录", errordoctor);
                }
                //
                else
                {
                    //                    //                    sql = string.Format(@"select nvl(round(to_number(to_date(r.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                    //                    //                       to_date(i.inwarddate, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours, r.name  from inpatient i, recorddetail r
                    //                    // where r.noofinpat = i.noofinpat    and r.noofinpat = '{0}' and substr(r.name, 0, 4) = '首次病程'", noofinpat);
                    //                    //edit by wyt 增加首次病程文件有效性验证 2012-11-23
                    //                    sql = string.Format(@"select nvl(round(to_number(to_date(r.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                    //                       to_date(i.inwarddate, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours, r.name ,r.owner  from inpatient i, recorddetail r
                    // where r.noofinpat = i.noofinpat    and r.noofinpat = '{0}' and substr(r.name, 0, 4) = '首次病程' and r.valid = 1", noofinpat);
                    //                    dt = m_App.SqlHelper.ExecuteDataTable(sql);
                    //                    if (dt.Rows.Count > 0)
                    //                    {
                    //                        hours = int.Parse(dt.Rows[0][0].ToString());
                    //                        if (hours > 8)
                    //                        {
                    //                            m_SqlManger.InsertDB(371, "25", id, noofinpat, pname, "未在入院后8小时内完成", dt.Rows[0]["OWNER"].ToString());
                    //                        }
                    //                    }
                }

                #region 注释
                //                //上级首次查房
                //                //                sql = string.Format(@"select  round(to_number(to_date(t.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                //                       to_date(r.inwarddate, 'yyyy-mm-dd hh24:mi:ss')) * 24) hours
                //                //                          from recorddetail t,inpatient r
                //                //                         where substr(t.name, 0, 4) = '上级查房'
                //                //                           and t.noofinpat = '{0}'
                //                //                          and r.noofinpat = '{0}'
                //                //                           and rownum = 1
                //                //                         order by t.createtime asc", noofinpat);
                //                //edit by wyt 增加上级查房文件有效性验证 2012-11-23
                //                sql = string.Format(@"select  round(to_number(to_date(t.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                       to_date(r.inwarddate, 'yyyy-mm-dd hh24:mi:ss')) * 24) hours , t.owner
                //                      from recorddetail t,inpatient r
                //                     where substr(t.name, 0, 4) = '上级查房'
                //                       and t.noofinpat = '{0}'
                //                      and r.noofinpat = '{0}'
                //                      /*and (r.chief=t.owner or r.ATTEND=t.owner)*/
                //                      and t.valid = 1
                //                       and rownum = 1
                //                     order by t.createtime asc", noofinpat);
                //                dt = m_App.SqlHelper.ExecuteDataTable(sql);
                //                if (dt == null || dt.Rows.Count == 0)
                //                {
                //                    m_SqlManger.InsertDB(376, "10", id, noofinpat, pname, "未在患者入院后48小时内完成", errordoctor);
                //                }
                //                else
                //                {
                //                    hours = int.Parse(dt.Rows[0][0].ToString());
                //                    if (hours > 48)
                //                    {
                //                        m_SqlManger.InsertDB(376, "10", id, noofinpat, pname, "未在患者入院后48小时内完成", dt.Rows[0]["OWNER"].ToString());
                //                    }
                //                }
                //                //主任副主任医师首次查房
                //                //                sql = string.Format(@"select  round(to_number(to_date(t.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                //                       to_date(r.inwarddate, 'yyyy-mm-dd hh24:mi:ss')) * 24) hours
                //                //                      from recorddetail t,inpatient r
                //                //                     where substr(t.name, 0, 4) = '上级查房'
                //                //                       and t.noofinpat = '{0}'
                //                //                       and r.noofinpat = '{0}'
                //                //                       and r.chief=t.owner
                //                //                       and rownum = 1
                //                //                     order by t.createtime asc", noofinpat);
                //                //edit by wyt 增加上级查房文件有效性验证 2012-11-23
                //                sql = string.Format(@"select  round(to_number(to_date(t.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                       to_date(r.inwarddate, 'yyyy-mm-dd hh24:mi:ss')) * 24) hours,t.owner
                //                      from recorddetail t,inpatient r
                //                     where substr(t.name, 0, 4) = '上级查房'
                //                       and t.noofinpat = '{0}'
                //                       and r.noofinpat = '{0}'
                //                       and r.chief=t.owner
                //                       and t.valid = 1
                //                       and rownum = 1
                //                     order by t.createtime asc", noofinpat);
                //                dt = m_App.SqlHelper.ExecuteDataTable(sql);
                //                if (dt == null || dt.Rows.Count == 0)
                //                {
                //                    m_SqlManger.InsertDB(377, "3", id, noofinpat, pname, "主任、副主任医师未在72小时内查房", errordoctor);
                //                }
                //                else
                //                {
                //                    hours = int.Parse(dt.Rows[0][0].ToString());
                //                    if (hours > 72)
                //                    {
                //                        m_SqlManger.InsertDB(377, "3", id, noofinpat, pname, "主任、副主任医师未在72小时内查房", dt.Rows[0]["OWNER"].ToString());
                //                    }
                //                }


                //                //会诊申请
                //                //                sql = string.Format(@"select nvl(round(to_number(to_date(t.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                //                       to_date(t.applytime, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours from consultapply t where t.noofinpat='{0}'", noofinpat);
                //                //edit by wyt 增加会诊申请记录有效性验证 2012-11-23
                //                sql = string.Format(@"select nvl(round(to_number(to_date(t.createtime, 'yyyy-mm-dd hh24:mi:ss') -
                //                       to_date(t.applytime, 'yyyy-mm-dd hh24:mi:ss')) * 24),-1) hours from consultapply t where t.noofinpat='{0}' and t.valid = 1", noofinpat);
                //                dt = m_App.SqlHelper.ExecuteDataTable(sql);
                //                if (dt.Rows.Count > 0)
                //                {
                //                    foreach (DataRow dr in dt.Rows)
                //                    {
                //                        if (Convert.ToInt32(dr[0]) > 48)
                //                        {
                //                            m_SqlManger.InsertDB(382, "2", id, noofinpat, pname, "在申请发出后48小时未完成一次", errordoctor);
                //                        }
                //                    }
                //                }
                #endregion
            }
            catch (Exception)
            {
                throw;
            }
        }
        ///// <summary>
        ///// AB自动检测
        ///// </summary>
        ///// <param name="recorddetialid"></param>
        ///// <param name="mr_class"></param>
        ///// <returns></returns>
        //public void GetResultPoint(string recorddetialid, string mr_class, string noofinpat, string automarkrecordid, string pname)
        //{
        //    try
        //    {
        //        XmlDocument xmlRecord = new XmlDocument();
        //        //DataTable recordContent =
        //        //    m_App.SqlHelper.ExecuteDataTable(
        //        //    string.Format(@"select content from recorddetail where id='{0}' and substr(name, 0, 4) = '入院记录' ", recorddetialid), CommandType.Text);
        //        //edit by wyt 增加住院志文件有效性筛选  2012-11-23
        //        DataTable recordContent =
        //            m_App.SqlHelper.ExecuteDataTable(
        //            string.Format(@"select content from recorddetail where id='{0}' and substr(name, 0, 4) = '入院记录' and valid = 1", recorddetialid), CommandType.Text);
        //        //如果有病历内容
        //        if (recordContent == null || recordContent.Rows.Count <= 0)
        //        {
        //            return;
        //        }
        //        xmlRecord.LoadXml(recordContent.Rows[0]["content"].ToString());
        //        XmlNode body = xmlRecord.SelectSingleNode("//body");
        //        int tipcount = body.SelectNodes("//roelement").Count;
        //        ArrayList arr_element = new ArrayList();// 元素的名称
        //        for (int i = 0; i < tipcount; i++)
        //        {
        //            arr_element.Add(body.SelectNodes("//roelement")[i].InnerText.Replace(" ", "").Replace(" ", ""));//将此病历内容中的标签加入到链表
        //        }
        //        //将取到的元素标签放到链表中,方便下面评分遍历

        //        DataTable PointConfig = new DataTable();
        //        PointConfig = m_SqlManger.GetPointConfig(mr_class);
        //        //存放要评分的项名称和规则
        //        Dictionary<string, string> m_pointconfig = new Dictionary<string, string>();
        //        if (PointConfig.Rows.Count > 0)
        //        {
        //            for (int i = 0; i < PointConfig.Rows.Count; i++)
        //            {
        //                m_pointconfig.Add(PointConfig.Rows[i]["id"].ToString(), PointConfig.Rows[i]["childname"].ToString() + PointConfig.Rows[i]["problem_desc"].ToString());
        //            }
        //        }
        //        //if (!arr_element.Contains("主诉"))
        //        //{
        //        //    m_SqlManger.InsertDB(351, "3", automarkrecordid, noofinpat, pname, "缺主诉");
        //        //}
        //        //edit by wyt 2012-11-23
        //        if (!IsConatainStr(arr_element, "主诉"))
        //        {
        //            m_SqlManger.InsertDB(351, "3", automarkrecordid, noofinpat, pname, "缺主诉");
        //        }
        //        //主诉字数
        //        else
        //        {
        //            string allstr = body.InnerText;
        //            for (int j = 0; j < tipcount; j++)
        //            {
        //                if (body.SelectNodes("//roelement")[j].InnerText.ToString().Trim().Replace(" ", "").Replace(" ", "").StartsWith("主诉"))
        //                {
        //                    string nexttip = body.SelectNodes("//roelement")[j + 1].InnerText.ToString().Replace(":", "").Replace(" ", "").Replace(" ", "");//下一个元素名称
        //                    string startstr = "主诉";
        //                    int startop = allstr.Replace(" ", "").Replace(" ", "").IndexOf(startstr, 0) + startstr.Length; //开始位置
        //                    int endop = allstr.Replace(" ", "").Replace(" ", "").IndexOf(nexttip, startop); //结束位置
        //                    string my = allstr.Replace(" ", "").Replace(" ", "").Substring(startop, endop - startop).Replace(":", ""); //取搜索的条数,用结束的位置-开始的位置,并返回
        //                    if (my.Length > 20)
        //                    {
        //                        m_SqlManger.InsertDB(352, "2", automarkrecordid, noofinpat, pname, "主诉超过20个字");
        //                        break;
        //                    }
        //                }
        //            }
        //        }
        //        //if (!arr_element.Contains("现病史"))
        //        //{
        //        //    m_SqlManger.InsertDB(353, "5", automarkrecordid, noofinpat, pname, "缺现病史");
        //        //}
        //        //if (!arr_element.Contains("既往史"))
        //        //{
        //        //    m_SqlManger.InsertDB(354, "3", automarkrecordid, noofinpat, pname, "缺既往史");
        //        //}
        //        //if (!arr_element.Contains("个人史"))
        //        //{
        //        //    m_SqlManger.InsertDB(356, "2", automarkrecordid, noofinpat, pname, "缺个人史");
        //        //}
        //        //if (!arr_element.Contains("家族史"))
        //        //{
        //        //    m_SqlManger.InsertDB(358, "1", automarkrecordid, noofinpat, pname, "缺家族史");
        //        //}
        //        //if (!arr_element.Contains("体格检查"))
        //        //{
        //        //    m_SqlManger.InsertDB(363, "5", automarkrecordid, noofinpat, pname, "缺体格检查");
        //        //}
        //        //if (!arr_element.Contains("专科情况"))
        //        //{
        //        //    m_SqlManger.InsertDB(364, "2", automarkrecordid, noofinpat, pname, "缺专科情况");
        //        //}
        //        //if (!arr_element.Contains("辅助检查"))
        //        //{
        //        //    m_SqlManger.InsertDB(365, "1", automarkrecordid, noofinpat, pname, "辅助检查结果未记录");
        //        //}
        //        //if (!arr_element.Contains("病史小结"))
        //        //{
        //        //    m_SqlManger.InsertDB(366, "1", automarkrecordid, noofinpat, pname, "缺病史小结");
        //        //}
        //        //if (!arr_element.Contains("初步诊断"))
        //        //{
        //        //    m_SqlManger.InsertDB(367, "1", automarkrecordid, noofinpat, pname, "缺初步诊断");
        //        //}
        //        //edit by wyt 2012-11-23
        //        if (!IsConatainStr(arr_element, "现病史"))
        //        {
        //            m_SqlManger.InsertDB(353, "5", automarkrecordid, noofinpat, pname, "缺现病史");
        //        }
        //        if (!IsConatainStr(arr_element, "既往史"))
        //        {
        //            m_SqlManger.InsertDB(354, "3", automarkrecordid, noofinpat, pname, "缺既往史");
        //        }
        //        if (!IsConatainStr(arr_element, "个人史"))
        //        {
        //            m_SqlManger.InsertDB(356, "2", automarkrecordid, noofinpat, pname, "缺个人史");
        //        }
        //        if (!IsConatainStr(arr_element, "家族史"))
        //        {
        //            m_SqlManger.InsertDB(358, "1", automarkrecordid, noofinpat, pname, "缺家族史");
        //        }
        //        if (!IsConatainStr(arr_element, "体格检查"))
        //        {
        //            m_SqlManger.InsertDB(363, "5", automarkrecordid, noofinpat, pname, "缺体格检查");
        //        }
        //        if (!IsConatainStr(arr_element, "专科情况"))
        //        {
        //            m_SqlManger.InsertDB(364, "2", automarkrecordid, noofinpat, pname, "缺专科情况");
        //        }
        //        if (!IsConatainStr(arr_element, "辅助检查"))
        //        {
        //            m_SqlManger.InsertDB(365, "1", automarkrecordid, noofinpat, pname, "辅助检查结果未记录");
        //        }
        //        if (IsConatainStr(arr_element, "病史小结"))
        //        {
        //            m_SqlManger.InsertDB(366, "1", automarkrecordid, noofinpat, pname, "缺病史小结");
        //        }
        //        if (!IsConatainStr(arr_element, "初步诊断"))
        //        {
        //            m_SqlManger.InsertDB(367, "1", automarkrecordid, noofinpat, pname, "缺初步诊断");
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }

        //}
        #endregion

        /// <summary>
        /// AB自动检测
        /// </summary>
        /// add by wyt 2012-11-27
        /// <param name="recorddetialid"></param>
        /// <param name="mr_class"></param>
        /// <returns></returns>
        public void GetResultPoint(string recorddetialid, string mr_class, string noofinpat, string automarkrecordid, string pname, string errordoctor)
        {
            try
            {
                XmlDocument xmlRecord = new XmlDocument();
                //DataTable recordContent =
                //    m_App.SqlHelper.ExecuteDataTable(
                //    string.Format(@"select content from recorddetail where id='{0}' and substr(name, 0, 4) = '入院记录' ", recorddetialid), CommandType.Text);
                //edit by wyt 增加住院志文件有效性筛选  2012-11-23
                DataTable recordContent =
                    m_App.SqlHelper.ExecuteDataTable(
                        string.Format(@"select content from recorddetail where id='{0}' and substr(name, 0, 4) = '入院记录' and valid = 1", recorddetialid), CommandType.Text);
                //如果有病历内容
                if (recordContent == null || recordContent.Rows.Count <= 0)
                {
                    return;
                }
                xmlRecord.LoadXml(recordContent.Rows[0]["content"].ToString());
                XmlNode body = xmlRecord.SelectSingleNode("//body");
                if (!IsHaveValue(body, "主诉", 1, 0))
                {
                    m_SqlManger.InsertDB(351, "3", automarkrecordid, noofinpat, pname, "缺主诉", errordoctor);
                }
                else if (!IsHaveValue(body, "主诉", 0, 20))
                {
                    {
                        m_SqlManger.InsertDB(352, "2", automarkrecordid, noofinpat, pname, "主诉超过20个字", errordoctor);
                    }
                }
                if (!IsHaveValue(body, "现病史", 1, 0))
                {
                    m_SqlManger.InsertDB(353, "5", automarkrecordid, noofinpat, pname, "缺现病史", errordoctor);
                }
                if (!IsHaveValue(body, "既往史", 1, 0))
                {
                    m_SqlManger.InsertDB(354, "3", automarkrecordid, noofinpat, pname, "缺既往史", errordoctor);
                }
                if (!IsHaveValue(body, "个人史", 1, 0))
                {
                    m_SqlManger.InsertDB(356, "2", automarkrecordid, noofinpat, pname, "缺个人史", errordoctor);
                }
                if (!IsHaveValue(body, "家族史", 1, 0))
                {
                    m_SqlManger.InsertDB(358, "1", automarkrecordid, noofinpat, pname, "缺家族史", errordoctor);
                }
                if (!IsHaveValue(body, "体格检查", 1, 0))
                {
                    m_SqlManger.InsertDB(363, "5", automarkrecordid, noofinpat, pname, "缺体格检查", errordoctor);
                }
                if (!IsHaveValue(body, "专科情况", 1, 0))
                {
                    m_SqlManger.InsertDB(364, "2", automarkrecordid, noofinpat, pname, "缺专科情况", errordoctor);
                }
                if (!IsHaveValue(body, "辅助检查", 1, 0))
                {
                    m_SqlManger.InsertDB(365, "1", automarkrecordid, noofinpat, pname, "辅助检查结果未记录", errordoctor);
                }
                if (!IsHaveValue(body, "病史小结", 1, 0))
                {
                    m_SqlManger.InsertDB(366, "1", automarkrecordid, noofinpat, pname, "缺病史小结", errordoctor);
                }
                if (!IsHaveValue(body, "初步诊断") && !IsHaveValue(body, "初步诊断", 1, 0))
                {
                    m_SqlManger.InsertDB(367, "1", automarkrecordid, noofinpat, pname, "缺初步诊断", errordoctor);
                }
                //DataTable PointConfig = new DataTable();
                //PointConfig = m_SqlManger.GetPointConfig(mr_class);
                ////存放要评分的项名称和规则
                //Dictionary<string, string> m_pointconfig = new Dictionary<string, string>();
                //if (PointConfig.Rows.Count > 0)
                //{
                //    for (int i = 0; i < PointConfig.Rows.Count; i++)
                //    {
                //        m_pointconfig.Add(PointConfig.Rows[i]["id"].ToString(), PointConfig.Rows[i]["childname"].ToString() + PointConfig.Rows[i]["problem_desc"].ToString());
                //    }
                //}
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public void Automark(string automarkrecordid, string noofinpat, string pname, QCType type)
        {
            try
            {
                #region 病案首页自动评分 --add by wyt 2012-12-03
                EmrAutoScore mainpage = new EmrAutoScore(m_App);
                mainpage.AutoScoreAA(noofinpat, pname, automarkrecordid);
                #endregion
                DataTable dt1 = new DataTable();
                DataTable dt2 = new DataTable();
                DataTable dt3 = new DataTable();
                dt1 = GetTypeOneAutoMark();
                if (dt1 == null || dt1.Rows.Count == 0)
                {
                    return;
                }
                if (!GetOperationStatus(noofinpat))
                {
                    dt1 = ToDataTable(dt1.Select("parents <> 'AH'"));
                }
                dt1 = ToDataTable(dt1.Select("parents <> 'AA'"));//病案首页不再判断
                if (type == QCType.PART)
                {
                    string outHosRec = GetOutHosRecord();         //出院记录
                    if (outHosRec != "")
                    {
                        dt1 = ToDataTable(dt1.Select(string.Format(@"children <> '{0}'", outHosRec)));//如果环节质控不检查出院记录
                    }
                }

                if (dt1 == null)
                {
                    return;
                }

                foreach (DataRow dr1 in dt1.Rows)
                {
                    dt2 = IsHaveRecoed(noofinpat, dr1["selectcondition"].ToString());
                    if (dt2.Rows.Count == 0)
                    {
                        m_SqlManger.InsertDB(int.Parse(dr1["id"].ToString()), dr1["REDUCEPOINT"].ToString(), automarkrecordid, noofinpat, pname, dr1["PROBLEM_DESC"].ToString(), GetRESIDENT(noofinpat));
                    }
                    else
                    {
                        dt3 = GetDetailByType(dr1);
                        if (dt3.Rows.Count > 0)
                        {
                            //当为病程记录时,只需检索病程记录
                            if (dr1["PARENTS"].ToString() == "AC")
                            {
                                IsHaveRoelement((dt2.Select("FIRSTDAILYFLAG = '1'"))[0], dt3, automarkrecordid, noofinpat, pname);
                                continue;
                            }

                            foreach (DataRow dr2 in dt2.Rows)
                            {
                                IsHaveRoelement(dr2, dt3, automarkrecordid, noofinpat, pname);
                            }
                        }
                    }
                }
                GetTimeLimitedQc(noofinpat, automarkrecordid, pname);//   时限质控
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        /// <summary>
        /// 病案首页自动评分
        /// </summary>
        /// <param name="noofinpat">病人首页序号</param>
        /// <param name="pname">病人姓名</param>
        /// <param name="id">主表记录ID</param>
        /// <returns></returns>
        public void AutoScoreAA(string noofinpat, string pname, string id)
        {
            try
            {
                if (m_dtMainpageRule == null)
                {
                    return;
                }
                DataTable basicinfo      = DataAccess.GetIemMainpageInfo(noofinpat, 0);         //病案首页基本信息表
                DataTable diag           = DataAccess.GetIemMainpageInfo(noofinpat, 1);         //病案首页诊断表
                DataTable oper           = DataAccess.GetIemMainpageInfo(noofinpat, 2);         //病案首页手术表
                DataTable baby           = DataAccess.GetIemMainpageInfo(noofinpat, 3);         //病案首页婴儿表
                DataTable dtqc           = new DataTable();                                     //临时表
                DataTable dtqc_condition = new DataTable();                                     //临时条件表
                DataTable inpat          = DataAccess.GetIemMainpageInfo(noofinpat, 4);         //病人表
                DataTable inpatinfo      = DataAccess.GetRedactPatientInfoFrm("14", noofinpat); //病人信息表
                string    createuser     = "";                                                  //责任医师
                int       aarecordid     = int.Parse(GetAARecord());
                if (aarecordid == 0)                                                            //王冀  2012 12 18 不许评分
                {
                    return;
                }
                string point = GetAARecordScore();
                if (inpatinfo.Rows.Count <= 0)
                {
                    return;
                }
                //无病案首页
                if (basicinfo == null || inpat == null || basicinfo.Rows.Count == 0 || inpat.Rows.Count == 0)
                {
                    m_SqlManger.InsertDB(aarecordid, point, id, noofinpat, pname, "无首页", inpatinfo.Rows[0]["RESIDENT"].ToString());
                    //m_SqlManger.InsertDB(aarecordid, dr["REDUCTSCORE"].ToString(), id, noofinpat, pname, dr["REDUCTREASON"].ToString(), createuser);
                    return;
                }
                pname = basicinfo.Rows[0]["NAME"].ToString();

                //遍历病案首页检查项
                foreach (DataRow dr in m_dtMainpageRule.Rows)
                {
                    #region 初始化检查项参数
                    string   tabletype          = dr["TABLETYPE"].ToString();                   //检查项表类型
                    string   fieldstr           = dr["FIELDS"].ToString().Trim();               //检查项字段
                    string   fieldvalstr        = dr["FIELDSVALUE"].ToString().Trim();          //检查项字段值
                    string[] fields             = fieldstr.Split(',');                          //检查项字段
                    string[] fieldvals          = fieldvalstr.Split(',');                       //检查项字段值
                    string   conditiontabletype = dr["CONDITIONTABLETYPE"].ToString();          //检查项条件表类型
                    string   conditionfieldstr  = dr["CONDITIONFIELDS"].ToString().Trim();      //检查项条件字段
                    string   conditionvalstr    = dr["CONDITIONFIELDSVALUE"].ToString().Trim(); //检查项条件字段值
                    string[] conditionfields    = conditionfieldstr.Split(',');                 //检查项条件字段
                    string[] conditionvals      = conditionvalstr.Split(',');                   //检查项条件字段值
                    bool     flag_condition     = false;                                        //条件标识,如果为真则检查
                    bool     flag = false;                                                      //检查标识,如果为真则该扣分不成立
                    #endregion
                    #region 判断条件是否成立,成立则检查
                    switch (conditiontabletype)
                    {
                    case "0":
                        dtqc_condition = basicinfo;
                        break;

                    case "1":
                        dtqc_condition = diag;
                        break;

                    case "2":
                        dtqc_condition = oper;
                        break;

                    case "3":
                        dtqc_condition = baby;
                        break;

                    case "4":
                        dtqc_condition = inpat;
                        break;
                    }
                    if (dtqc_condition.Rows.Count == 0 || conditionfieldstr.Length == 0)
                    {
                        flag_condition = true;      //无条件,则认为是检查条件成立
                    }
                    else
                    {
                        #region 判断条件是否成立
                        foreach (DataRow row in dtqc_condition.Rows)
                        {
                            if (flag_condition == true)
                            {
                                break;
                            }
                            foreach (string val in conditionvals)
                            {
                                if (flag_condition == true)
                                {
                                    break;
                                }
                                if (val == "不为空")
                                {
                                    foreach (string field in conditionfields)
                                    {
                                        if (!dtqc_condition.Columns.Contains(field))
                                        {
                                            continue;
                                        }
                                        if (row[field].ToString().Trim() != "")
                                        {
                                            flag_condition = true;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (string field in conditionfields)
                                    {
                                        if (!dtqc_condition.Columns.Contains(field))
                                        {
                                            continue;
                                        }
                                        if (row[field].ToString().Trim() == val)
                                        {
                                            flag_condition = true;
                                            break;
                                        }
                                    }
                                }
                            }

                            //if (hasCheck == false && flag_condition == false)
                            //{
                            //    foreach (string field in conditionfields)
                            //    {
                            //        if (!dtqc_condition.Columns.Contains(field))
                            //        {
                            //            break;
                            //        }
                            //        if (row[field].ToString().Trim() != "")
                            //        {
                            //            flag_condition = true;
                            //            break;
                            //        }
                            //    }
                            //}
                        }
                        #endregion
                    }
                    #endregion
                    #region 如果条件不成立,则不检查
                    if (flag_condition == false)
                    {
                        continue;
                    }
                    #endregion
                    #region 根据表类型号找出待校验数据
                    switch (tabletype)
                    {
                    case "0":
                        dtqc = basicinfo;
                        break;

                    case "1":
                        dtqc = diag;
                        break;

                    case "2":
                        dtqc = oper;
                        break;

                    case "3":
                        dtqc = baby;
                        break;

                    case "4":
                        dtqc = inpat;
                        break;
                    }
                    #endregion
                    #region 如果检查表为空,则该扣分成立
                    if (dtqc == null || dtqc.Rows.Count == 0)
                    {
                        m_SqlManger.InsertDB(aarecordid, dr["REDUCTSCORE"].ToString(), id, noofinpat, pname, dr["REDUCTREASON"].ToString(), inpatinfo.Rows[0]["RESIDENT"].ToString());
                    }
                    #endregion
                    #region 检查该项
                    else
                    {
                        foreach (DataRow row in dtqc.Rows)
                        {
                            createuser = row["CREATE_USER"].ToString();
                            if (flag == true)
                            {
                                break;
                            }
                            foreach (string val in fieldvals)
                            {
                                if (flag == true)
                                {
                                    break;
                                }

                                if (val == "不为空")
                                {
                                    foreach (string field in fields)
                                    {
                                        if (!dtqc.Columns.Contains(field))
                                        {
                                            break;
                                        }
                                        if (row[field].ToString().Trim() != "")
                                        {
                                            flag = true;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (string field in fields)
                                    {
                                        if (!dtqc.Columns.Contains(field))
                                        {
                                            continue;
                                        }
                                        if (row[field].ToString().Trim() == val)
                                        {
                                            flag = true;
                                            break;
                                        }
                                    }
                                }
                            }

                            //if (hasCheck == false && flag == false)
                            //{
                            //    foreach (string field in fields)
                            //    {
                            //        if (!dtqc.Columns.Contains(field))
                            //        {
                            //            break;
                            //        }
                            //        if (row[field].ToString().Trim() != "")
                            //        {
                            //            flag = true;
                            //            createuser = row["CREATE_USER"].ToString();
                            //            break;
                            //        }
                            //    }
                            //}
                        }
                        if (flag == false)//如果未检查出该项,则扣分
                        {
                            m_SqlManger.InsertDB(aarecordid, dr["REDUCTSCORE"].ToString(), id, noofinpat, pname, dr["REDUCTREASON"].ToString(), createuser);
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(1, ex);
            }
        }
        ///// <summary>
        ///// AC自动检测
        ///// </summary>
        ///// <param name="recorddetialid"></param>
        ///// <param name="mr_class"></param>
        ///// <returns></returns>
        //public void GetResultPoint(string recorddetialid, string mr_class, string noofinpat, string automarkrecordid, string pname)
        //{
        //    try
        //    {
        //        int hours;
        //        DataTable dt = new DataTable();
        //        string sql;
        //        //先判断是否首程
        //        sql = string.Format(@"select firstdailyflag from recorddetail where id='{0}' ", recorddetialid);
        //        dt = m_App.SqlHelper.ExecuteDataTable(sql);
        //        if (dt.Rows[0][0].ToString() == "1")
        //        {
        //            //判断是否在入院8小时内完成首程
        //            //sql = @"select round(to_number(to_date(r.createtime,'yyyy-mm-dd hh24:mi:ss')-to_date(t.inwarddate,'yyyy-mm-dd hh24:mi:ss'))*24) hours from inpatient t ,recorddetail r where t.noofinpat='{0}' and r.noofinpat='{0}' and r.firstdailyflag='1' and r.sortid='AC'";
        //            //sql = string.Format(sql, noofinpat);
        //            //dt = m_App.SqlHelper.ExecuteDataTable(sql);
        //            //if (dt == null || dt.Rows.Count == 0)
        //            //{
        //            //    return;
        //            //}
        //            //hours = int.Parse(dt.Rows[0][0].ToString());
        //            //if (hours > 8)
        //            //{
        //            //    m_SqlManger.InsertDB(371, "25", automarkrecordid, noofinpat, pname, "未在入院后8小时内完成");
        //            //}

        //            XmlDocument xmlRecord = new XmlDocument();
        //            //DataTable recordContent =
        //            //    m_App.SqlHelper.ExecuteDataTable(
        //            //    string.Format(@"select content from recorddetail where id='{0}'", recorddetialid), CommandType.Text);
        //            //edit by wyt 增加病程文件有效性筛选 2012-11-23
        //            DataTable recordContent =
        //                m_App.SqlHelper.ExecuteDataTable(
        //                string.Format(@"select content from recorddetail where id='{0}' and valid = 1", recorddetialid), CommandType.Text);
        //            //如果有病历内容
        //            if (recordContent == null && recordContent.Rows.Count <= 0)
        //            {
        //                return;
        //            }
        //            xmlRecord.LoadXml(recordContent.Rows[0]["content"].ToString());
        //            XmlNode body = xmlRecord.SelectSingleNode("//body");
        //            int tipcount = body.SelectNodes("//roelement").Count;
        //            ArrayList arr_element = new ArrayList();// 元素的名称
        //            //Regex rg = new Regex()
        //            for (int i = 0; i < tipcount; i++)
        //            {
        //                arr_element.Add(body.SelectNodes("//roelement")[i].InnerText.Replace(" ", "").Replace(" ", ""));//将此病历内容中的标签加入到链表
        //            }
        //            //将取到的元素标签放到链表中,方便下面评分遍历

        //            DataTable PointConfig = new DataTable();
        //            PointConfig = m_SqlManger.GetPointConfig(mr_class);
        //            //存放要评分的项名称和规则
        //            Dictionary<string, string> m_pointconfig = new Dictionary<string, string>();
        //            if (PointConfig.Rows.Count > 0)
        //            {
        //                for (int i = 0; i < PointConfig.Rows.Count; i++)
        //                {
        //                    m_pointconfig.Add(PointConfig.Rows[i]["id"].ToString(), PointConfig.Rows[i]["childname"].ToString() + PointConfig.Rows[i]["problem_desc"].ToString());
        //                }
        //            }
        //            //if (!arr_element.Contains("诊断"))
        //            //{
        //            //    m_SqlManger.InsertDB(372, "3", automarkrecordid, noofinpat, pname, "无初步诊断");
        //            //}
        //            //edit by wyt 2012-11-23
        //            if (!IsConatainStr(arr_element, "诊断"))
        //            {
        //                m_SqlManger.InsertDB(372, "3", automarkrecordid, noofinpat, pname, "无初步诊断");
        //            }

        //            //字数
        //            string allstr = body.InnerText;
        //            for (int j = 0; j < tipcount; j++)
        //            {
        //                if (body.SelectNodes("//roelement")[j].InnerText.ToString().Trim().Replace(" ", "").Replace(" ", "").StartsWith("诊断"))
        //                {
        //                    string nexttip = body.SelectNodes("//roelement")[j + 1].InnerText.ToString();//下一个元素名称
        //                    string startstr = "诊断";
        //                    int startop = allstr.Replace(" ", "").Replace(" ", "").IndexOf(startstr, 0) + startstr.Length; //开始位置
        //                    int endop = allstr.Replace(" ", "").Replace(" ", "").IndexOf(nexttip, startop); //结束位置
        //                    string my = allstr.Replace(" ", "").Replace(" ", "").Substring(startop, endop - startop).Replace(":", ""); //取搜索的条数,用结束的位置-开始的位置,并返回
        //                    if (my.Length == 0)
        //                    {
        //                        m_SqlManger.InsertDB(372, "3", automarkrecordid, noofinpat, pname, "无初步诊断");
        //                        break;
        //                    }
        //                }
        //            }
        //            //if (!arr_element.Contains("诊断依据"))
        //            //{
        //            //    m_SqlManger.InsertDB(373, "5", automarkrecordid, noofinpat, pname, "无诊断依据");
        //            //}
        //            //if (!arr_element.Contains("鉴别诊断"))
        //            //{
        //            //    m_SqlManger.InsertDB(374, "3", automarkrecordid, noofinpat, pname, "无鉴别诊断");
        //            //}
        //            //if (!arr_element.Contains("诊疗计划"))
        //            //{
        //            //    m_SqlManger.InsertDB(375, "2", automarkrecordid, noofinpat, pname, "无诊疗计划");
        //            //}
        //            //edit by wyt 2012-11-23
        //            if (!IsConatainStr(arr_element, "诊断依据"))
        //            {
        //                m_SqlManger.InsertDB(373, "5", automarkrecordid, noofinpat, pname, "无诊断依据");
        //            }
        //            if (!IsConatainStr(arr_element, "鉴别诊断"))
        //            {
        //                m_SqlManger.InsertDB(374, "3", automarkrecordid, noofinpat, pname, "无鉴别诊断");
        //            }
        //            if (!IsConatainStr(arr_element, "诊疗计划"))
        //            {
        //                m_SqlManger.InsertDB(375, "2", automarkrecordid, noofinpat, pname, "无诊疗计划");
        //            }
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }

        //}
        #endregion


        /// <summary>
        /// AC自动检测
        /// </summary>
        /// <param name="recorddetialid"></param>
        /// <param name="mr_class"></param>
        /// <returns></returns>
        public void GetResultPoint(string recorddetialid, string mr_class, string noofinpat, string automarkrecordid, string pname, string errordoctor)
        {
            try
            {
                int       hours;
                DataTable dt = new DataTable();
                string    sql;
                //先判断是否首程
                sql = string.Format(@"select firstdailyflag from recorddetail where id='{0}' ", recorddetialid);
                dt  = m_App.SqlHelper.ExecuteDataTable(sql);
                if (dt.Rows[0][0].ToString() == "1")
                {
                    XmlDocument xmlRecord = new XmlDocument();
                    //DataTable recordContent =
                    //    m_App.SqlHelper.ExecuteDataTable(
                    //    string.Format(@"select content from recorddetail where id='{0}'", recorddetialid), CommandType.Text);
                    //edit by wyt 增加病程文件有效性筛选 2012-11-23
                    DataTable recordContent =
                        m_App.SqlHelper.ExecuteDataTable(
                            string.Format(@"select content from recorddetail where id='{0}' and valid = 1", recorddetialid), CommandType.Text);
                    //如果有病历内容
                    if (recordContent == null || recordContent.Rows.Count <= 0)
                    {
                        return;
                    }
                    xmlRecord.LoadXml(recordContent.Rows[0]["content"].ToString());
                    XmlNode body = xmlRecord.SelectSingleNode("//body");

                    //DataTable PointConfig = new DataTable();
                    //PointConfig = m_SqlManger.GetPointConfig(mr_class);
                    ////存放要评分的项名称和规则
                    //Dictionary<string, string> m_pointconfig = new Dictionary<string, string>();
                    //if (PointConfig.Rows.Count > 0)
                    //{
                    //    for (int i = 0; i < PointConfig.Rows.Count; i++)
                    //    {
                    //        m_pointconfig.Add(PointConfig.Rows[i]["id"].ToString(), PointConfig.Rows[i]["childname"].ToString() + PointConfig.Rows[i]["problem_desc"].ToString());
                    //    }
                    //}
                    if (!IsHaveValue(body, "诊断") && !IsHaveValue(body, "诊断", 1, 0))
                    {
                        m_SqlManger.InsertDB(372, "3", automarkrecordid, noofinpat, pname, "无初步诊断", errordoctor);
                    }
                    if (!IsHaveValue(body, "诊断依据", 1, 0))
                    {
                        m_SqlManger.InsertDB(373, "5", automarkrecordid, noofinpat, pname, "无诊断依据", errordoctor);
                    }
                    if (!IsHaveValue(body, "诊断") && !IsHaveValue(body, "鉴别诊断", 1, 0))
                    {
                        m_SqlManger.InsertDB(374, "3", automarkrecordid, noofinpat, pname, "无鉴别诊断", errordoctor);
                    }
                    if (!IsHaveValue(body, "诊疗计划", 1, 0))
                    {
                        m_SqlManger.InsertDB(375, "2", automarkrecordid, noofinpat, pname, "无诊疗计划", errordoctor);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }