Esempio n. 1
0
        //GetTasksComByPeriod 其他任务的依从情况(不包括生理测量) LS 2010505  文本集中在ballon web暂用
        public static List<CompliacneDetailByD> GetTasksComByPeriodWeb(DataConnection pclsCache, string PatientId, string PlanNo, int StartDate, int EndDate)
        {
            List<CompliacneDetailByD> resultList = new List<CompliacneDetailByD>();

            DataTable list = new DataTable();
            list.Columns.Add(new DataColumn("Date", typeof(string)));
            list.Columns.Add(new DataColumn("ComplianceValue", typeof(double)));
            list.Columns.Add(new DataColumn("TaskType", typeof(string)));
            list.Columns.Add(new DataColumn("TaskId", typeof(string)));
            list.Columns.Add(new DataColumn("TaskName", typeof(string)));
            list.Columns.Add(new DataColumn("Status", typeof(int)));

            CacheCommand cmd = null;
            CacheDataReader cdr = null;
            try
            {
                if (!pclsCache.Connect())
                {
                    return null;
                }
                cmd = new CacheCommand();
                cmd = Ps.Compliance.GetTasksComByPeriod(pclsCache.CacheConnectionObject);
                cmd.Parameters.Add("PatientId", CacheDbType.NVarChar).Value = PatientId;
                cmd.Parameters.Add("PlanNo", CacheDbType.NVarChar).Value = PlanNo;
                cmd.Parameters.Add("StartDate", CacheDbType.Int).Value = StartDate;
                cmd.Parameters.Add("EndDate", CacheDbType.Int).Value = EndDate;

                cdr = cmd.ExecuteReader();
                while (cdr.Read())
                {
                    if (cdr["TaskType"].ToString() != "体征测量")
                    {
                        list.Rows.Add(cdr["Date"].ToString(), Convert.ToDouble(cdr["ComplianceValue"]), cdr["TaskType"].ToString(), cdr["TaskId"].ToString(), cdr["TaskName"].ToString(), Convert.ToInt32(cdr["Status"]));
                    }
                }

                //确保排序
                DataView dv = list.DefaultView;
                dv.Sort = "Date Asc, TaskType Asc, Status Asc";
                DataTable list_sort = dv.ToTable();
                list_sort.Rows.Add("end", 0, "", "", "", 0);  //用于最后一天输出

                if (list_sort.Rows.Count > 1)
                {
                    string temp_date = list_sort.Rows[0]["Date"].ToString();
                    string temp_type = list_sort.Rows[0]["TaskType"].ToString();
                    string temp_str = "";
                    temp_str += "该天依从率:" + list_sort.Rows[0]["ComplianceValue"].ToString() + "<br>";

                    if (list_sort.Rows[0]["TaskType"].ToString() == "生活方式")
                    { }
                    temp_str += "<b><span style='font-size:14px;'>" + list_sort.Rows[0]["TaskType"].ToString() + ":</span></b>";

                    CompliacneDetailByD CompliacneDetailByD = new CompliacneDetailByD();
                    CompliacneDetailByD.Date = list_sort.Rows[0]["Date"].ToString();
                    // CompliacneDetailByD.ComplianceValue = list_sort.Rows[0]["ComplianceValue"].ToString();

                    if (Convert.ToDouble(list_sort.Rows[0]["ComplianceValue"]) == 0)  //某天依从率
                    {
                        CompliacneDetailByD.drugBullet = "";
                        CompliacneDetailByD.drugColor = "#DADADA";
                    }
                    else if (Convert.ToDouble(list_sort.Rows[0]["ComplianceValue"]) == 1)
                    {
                        CompliacneDetailByD.drugBullet = "";
                        CompliacneDetailByD.drugColor = "#777777";
                    }
                    else
                    {
                        CompliacneDetailByD.drugBullet = "amcharts-images/drug.png";
                        CompliacneDetailByD.drugColor = "";
                    }

                    if (Convert.ToInt32(list_sort.Rows[0]["Status"]) == 1)  //某天某项任务的完成情况
                    {
                        temp_str += list_sort.Rows[0]["TaskName"].ToString() + "complete  ";
                    }
                    else
                    {
                        //temp_str += list_sort.Rows[0]["TaskName"].ToString() + "noncomplete  ";
                        temp_str += "<b><span style='font-size:14px;color:red;'>" + list_sort.Rows[0]["TaskName"].ToString() + "noncomplete  " + "</span></b>";
                    }

                    //只有一条数据
                    if (list_sort.Rows.Count == 2)
                    {
                        CompliacneDetailByD.Events = temp_str;
                        resultList.Add(CompliacneDetailByD);
                    }

                    //>一条数据
                    if (list_sort.Rows.Count > 2)
                    {
                        for (int i = 1; i <= list_sort.Rows.Count - 1; i++)
                        {
                            if (temp_date == list_sort.Rows[i]["Date"].ToString())  //同一天
                            {
                                if (temp_type == list_sort.Rows[i]["TaskType"].ToString())     //同天同任务类型
                                {
                                    if (Convert.ToInt32(list_sort.Rows[i]["Status"]) == 1)  //某天某项任务的完成情况
                                    {
                                        temp_str += list_sort.Rows[i]["TaskName"].ToString() + "complete  ";
                                    }
                                    else
                                    {
                                        //temp_str += list_sort.Rows[i]["TaskName"].ToString() + "noncomplete  ";
                                        temp_str += "<b><span style='font-size:14px;color:red;'>" + list_sort.Rows[i]["TaskName"].ToString() + "noncomplete " + "</span></b>";
                                    }
                                }
                                else   //同天不同任务类型
                                {
                                    temp_str += "<br>";
                                    temp_str += "<b><span style='font-size:14px;'>" + list_sort.Rows[i]["TaskType"].ToString() + ":</span></b>";

                                    if (Convert.ToInt32(list_sort.Rows[i]["Status"]) == 1)  //某天某项任务的完成情况
                                    {
                                        temp_str += list_sort.Rows[i]["TaskName"].ToString() + "complete  ";
                                    }
                                    else
                                    {
                                        //temp_str += list_sort.Rows[i]["TaskName"].ToString() + "noncomplete  ";
                                        temp_str += "<b><span style='font-size:14px;color:red;'>" + list_sort.Rows[i]["TaskName"].ToString() + "noncomplete  </span></b>";
                                    }

                                    temp_type = list_sort.Rows[i]["TaskType"].ToString();
                                }

                            }
                            else   //不同天
                            {
                                //上一天输出
                                CompliacneDetailByD.Events = temp_str;
                                resultList.Add(CompliacneDetailByD);

                                if (list_sort.Rows[i]["Date"].ToString() != "end")
                                {
                                    //获取新一天
                                    CompliacneDetailByD = new CompliacneDetailByD();
                                    CompliacneDetailByD.Date = list_sort.Rows[i]["Date"].ToString();
                                    //CompliacneDetailByD.ComplianceValue = list_sort.Rows[i]["ComplianceValue"].ToString();

                                    if (Convert.ToDouble(list_sort.Rows[i]["ComplianceValue"]) == 0)  //某天依从率
                                    {
                                        CompliacneDetailByD.drugBullet = "";
                                        CompliacneDetailByD.drugColor = "#DADADA";
                                    }
                                    else if (Convert.ToDouble(list_sort.Rows[i]["ComplianceValue"]) == 1)
                                    {
                                        CompliacneDetailByD.drugBullet = "";
                                        CompliacneDetailByD.drugColor = "#777777";
                                    }
                                    else
                                    {
                                        CompliacneDetailByD.drugBullet = "amcharts-images/drug.png";
                                        CompliacneDetailByD.drugColor = "";
                                    }

                                    temp_str = "";
                                    temp_str += "该天依从率:" + list_sort.Rows[i]["ComplianceValue"].ToString() + "<br>";
                                    temp_str += "<b><span style='font-size:14px;'>" + list_sort.Rows[i]["TaskType"].ToString() + ":</span></b>";

                                    if (Convert.ToInt32(list_sort.Rows[i]["Status"]) == 1)  //某天某项任务的完成情况
                                    {
                                        temp_str += list_sort.Rows[i]["TaskName"].ToString() + "complete  ";
                                    }
                                    else
                                    {
                                        //temp_str += list_sort.Rows[i]["TaskName"].ToString() + "noncomplete  ";
                                        temp_str += "<b><span style='font-size:14px;color:red;'>" + list_sort.Rows[i]["TaskName"].ToString() + "noncomplete  </span></b>";
                                    }

                                    temp_date = list_sort.Rows[i]["Date"].ToString();
                                    temp_type = list_sort.Rows[i]["TaskType"].ToString();
                                }
                            }
                        }

                    }

                }

                return resultList;
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "Ps.Compliance.GetTasksComByPeriod", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                return null;
            }
            finally
            {
                if ((cdr != null))
                {
                    cdr.Close();
                    cdr.Dispose(true);
                    cdr = null;
                }
                if ((cmd != null))
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    cmd = null;
                }
                pclsCache.DisConnect();
            }
        }
Esempio n. 2
0
        //GetTasksComCountByPeriod 所有任务的依从情况简化版 不再全部显示,只对完成数量就行统计  pad、phone使用中
        public static List<CompliacneDetailByD> GetTasksComCountByPeriod(DataConnection pclsCache, string PatientId, string PlanNo, int StartDate, int EndDate)
        {
            List<CompliacneDetailByD> resultList = new List<CompliacneDetailByD>();

            CacheCommand cmd = null;
            CacheDataReader cdr = null;
            try
            {
                /*
                //读取各类型任务的数量
                int signCount = 0;
                int lifeCount = 0;
                int drugCount = 0;

                DataTable TaskList = new DataTable();
                TaskList = PsTask.GetTaskList(pclsCache, PlanNo);

                //体征测量
                string condition = " Type = 'VitalSign'";
                DataRow[] VitalSignRows = TaskList.Select(condition);
                if (VitalSignRows != null)
                {
                    signCount = VitalSignRows.Length;
                }

                //生活方式
                condition = " Type = 'LifeStyle'";
                DataRow[] LifeStyleRows = TaskList.Select(condition);
                if (LifeStyleRows != null)
                {
                    lifeCount = LifeStyleRows.Length;
                }

                //用药情况
                condition = " Type = 'Drug'";
                DataRow[] DrugRows = TaskList.Select(condition);
                if (DrugRows != null)
                {
                    drugCount = DrugRows.Length;
                }
                */

                DataTable list = new DataTable();
                list = PsCompliance.GetTasksComByPeriodDT(pclsCache, PatientId, PlanNo, StartDate, EndDate);

                //确保排序
                DataView dv = list.DefaultView;
                dv.Sort = "Date Asc, Type desc, Status Asc"; //体征s 生活l 用药d   前提:某计划内任务维持不变  即计划内每天的任务是一样的
                DataTable list_sort = dv.ToTable();
                list_sort.Rows.Add("end", 0, "", "", "", 0);  //用于最后一天输出

                if (list_sort.Rows.Count > 1)
                {
                    string temp_date = list_sort.Rows[0]["Date"].ToString();
                    string temp_type = list_sort.Rows[0]["TaskType"].ToString();  //中文
                    int complete = 0; int count = 0;  //完成数量统计

                    string temp_str = "";
                    temp_str += "该天依从率:" + list_sort.Rows[0]["ComplianceValue"].ToString() + "<br>";
                    temp_str += "<b><span style='font-size:14px;'>" + list_sort.Rows[0]["TaskType"].ToString() + ":</span></b>";

                    CompliacneDetailByD CompliacneDetailByD = new CompliacneDetailByD();
                    CompliacneDetailByD.Date = list_sort.Rows[0]["Date"].ToString();
                    //CompliacneDetailByD.ComplianceValue = list_sort.Rows[0]["ComplianceValue"].ToString();

                    if (Convert.ToDouble(list_sort.Rows[0]["ComplianceValue"]) == 0)  //点的颜色由该天依从率决定
                    {
                        CompliacneDetailByD.drugBullet = "";
                        CompliacneDetailByD.drugColor = "#DADADA";
                    }
                    else if (Convert.ToDouble(list_sort.Rows[0]["ComplianceValue"]) == 1)
                    {
                        CompliacneDetailByD.drugBullet = "";
                        CompliacneDetailByD.drugColor = "#777777";
                    }
                    else
                    {
                        CompliacneDetailByD.drugBullet = "amcharts-images/drug.png";
                        CompliacneDetailByD.drugColor = "";
                    }

                    if (Convert.ToInt32(list_sort.Rows[0]["Status"]) == 1)  //某天某项任务的完成情况
                    {
                        complete++;
                        count++;
                    }
                    else
                    {
                        count++;
                    }

                    //只有一条数据
                    if (list_sort.Rows.Count == 2)
                    {
                        temp_str += complete + "/" + count;
                        CompliacneDetailByD.Events = temp_str;
                        resultList.Add(CompliacneDetailByD);
                    }

                    //>一条数据
                    if (list_sort.Rows.Count > 2)
                    {
                        for (int i = 1; i <= list_sort.Rows.Count - 1; i++)
                        {
                            if (temp_date == list_sort.Rows[i]["Date"].ToString())  //同一天
                            {
                                if (temp_type == list_sort.Rows[i]["TaskType"].ToString())     //同天同任务类型
                                {
                                    if (Convert.ToInt32(list_sort.Rows[i]["Status"]) == 1)  //某天某项任务的完成情况
                                    {
                                        complete++;
                                        count++;
                                    }
                                    else
                                    {
                                        count++;
                                    }
                                }
                                else   //同天不同任务类型
                                {
                                    temp_str += complete + "/" + count;
                                    complete = 0; count = 0;  //清空统计量
                                    temp_str += "<br><b><span style='font-size:14px;'>" + list_sort.Rows[i]["TaskType"].ToString() + ":</span></b>";

                                    if (Convert.ToInt32(list_sort.Rows[i]["Status"]) == 1)  //某天某项任务的完成情况
                                    {
                                        complete++;
                                        count++;
                                    }
                                    else
                                    {
                                        count++;
                                    }

                                    temp_type = list_sort.Rows[i]["TaskType"].ToString();
                                }

                            }
                            else   //不同天
                            {
                                //上一天输出

                                temp_str += complete + "/" + count;
                                complete = 0; count = 0;  //清空统计量
                                CompliacneDetailByD.Events = temp_str;
                                resultList.Add(CompliacneDetailByD);

                                if (list_sort.Rows[i]["Date"].ToString() != "end")
                                {
                                    //获取新一天
                                    CompliacneDetailByD = new CompliacneDetailByD();
                                    CompliacneDetailByD.Date = list_sort.Rows[i]["Date"].ToString();
                                    //CompliacneDetailByD.ComplianceValue = list_sort.Rows[i]["ComplianceValue"].ToString();

                                    if (Convert.ToDouble(list_sort.Rows[i]["ComplianceValue"]) == 0)  //某天依从率
                                    {
                                        CompliacneDetailByD.drugBullet = "";
                                        CompliacneDetailByD.drugColor = "#DADADA";
                                    }
                                    else if (Convert.ToDouble(list_sort.Rows[i]["ComplianceValue"]) == 1)
                                    {
                                        CompliacneDetailByD.drugBullet = "";
                                        CompliacneDetailByD.drugColor = "#777777";
                                    }
                                    else
                                    {
                                        CompliacneDetailByD.drugBullet = "amcharts-images/drug.png";
                                        CompliacneDetailByD.drugColor = "";
                                    }

                                    temp_str = "";
                                    temp_str += "该天依从率:" + list_sort.Rows[i]["ComplianceValue"].ToString() + "<br>";
                                    temp_str += "<b><span style='font-size:14px;'>" + list_sort.Rows[i]["TaskType"].ToString() + ":</span></b>";

                                    if (Convert.ToInt32(list_sort.Rows[i]["Status"]) == 1)  //某天某项任务的完成情况
                                    {
                                        complete++;
                                        count++;
                                    }
                                    else
                                    {
                                        count++;
                                    }

                                    temp_date = list_sort.Rows[i]["Date"].ToString();
                                    temp_type = list_sort.Rows[i]["TaskType"].ToString();
                                }
                            }
                        }

                    }

                }

                return resultList;
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "PsCompliance.GetTasksComCountByPeriod", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                return null;
            }
            finally
            {
                if ((cdr != null))
                {
                    cdr.Close();
                    cdr.Dispose(true);
                    cdr = null;
                }
                if ((cmd != null))
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    cmd = null;
                }
                pclsCache.DisConnect();
            }
        }