Ejemplo n.º 1
0
        //GetImplementationByDate 某天所有任务的依从情况 整理加工  LS 2010706
        public static TaskComDetailByD GetImplementationByDate(DataConnection pclsCache, string PatientId, string PlanNo, int Date)
        {
            TaskComDetailByD TaskComDetailByD = new TaskComDetailByD();

            try
            {
                TaskComDetailByD.Date = Date.ToString().Substring(0, 4) + "-" + Date.ToString().Substring(4, 2) + "-" + Date.ToString().Substring(6, 2);
                TaskComDetailByD.WeekDay = PsCompliance.CaculateWeekDay(TaskComDetailByD.Date);

                DataTable ComplianceList = new DataTable();
                ComplianceList = PsCompliance.GetTasksComListByDate(pclsCache, PatientId, PlanNo, Date);

                #region 后期可能用于优化
                //先读任务表,读取体征,拿出新数据;再读药物表,超过三个则省略号
                //DataTable TaskList = new DataTable();
                //TaskList = PsTask.GetTaskList(pclsCache, PlanNo);

                ////读取体征,拿出当天最新数据
                //string condition = " Type = 'VitalSign'";
                //DataRow[] VitalSignRows = TaskList.Select(condition);

                //CacheSysList VitalSignList = new InterSystems.Data.CacheTypes.CacheSysList(System.Text.Encoding.Unicode, true, true);
                //for (int j=0; j < VitalSignRows.Length; j++)
                //{
                //    string code = VitalSignRows[j]["Type"].ToString();
                //    string[] sArray = code.Split(new char[] { '|' });;//拆分
                //    string type = sArray[0].ToString();
                //    VitalSignList = new InterSystems.Data.CacheTypes.CacheSysList(System.Text.Encoding.Unicode, true, true);
                //    VitalSignList = PsVitalSigns.GetSignByDay(pclsCache, PatientId, code, type, Date);
                //    if (VitalSignList != null)
                //    {

                //    }
                //}

                //体征
                /*
                string condition = " Type = 'VitalSign'";
                DataRow[] VitalSignRows = ComplianceList.Select(condition);

                List<TaskCom> TaskComList = new List<TaskCom>();
                TaskCom TaskCom = new TaskCom();
                for (int j = 0; j < VitalSignRows.Length; j++)
                {
                    VitalTaskCom = new VitalTaskCom();
                    VitalTaskCom.SignName = VitalSignRows[j]["TaskName"].ToString();
                    VitalTaskCom.Status = VitalSignRows[j]["Status"].ToString();
                    if (TaskCom.TaskStatus == "1")
                    {
                        string code = VitalSignRows[j]["TaskCode"].ToString();
                        string[] sArray = code.Split(new char[] { '|' }); ;//拆分
                        string type = sArray[0].ToString();
                        //CacheSysList VitalSignList = new InterSystems.Data.CacheTypes.CacheSysList(System.Text.Encoding.Unicode, true, true);
                        CacheSysList VitalSignList = new InterSystems.Data.CacheTypes.CacheSysList(System.Text.Encoding.Unicode, true, true);
                        VitalSignList = PsVitalSigns.GetSignByDay(pclsCache, PatientId, code, type, Date);
                        if (VitalSignList != null)
                        {

                            VitalTaskCom.Time = PulList[1].ToString();
                            VitalTaskCom.Value = PulList[2].ToString();
                            VitalTaskCom.Unit = PulList[3].ToString();

                        }
                    }
                    VitalTaskComList.Add(VitalTaskCom);
                }
                TaskComDetailByD.VitalTaskComList = VitalTaskComList;

                 string vitalCondition = " Type = 'VitalSign'";
                    DataRow[] VitalSignRows = ComplianceList.Select(vitalCondition);

                    if ((VitalSignRows != null) && (VitalSignRows.Length >= 2))
                    {

                        if (VitalSignRows.Length == 2)  //只有血压
                        {

                        }
                        else //血压和脉率
                        {

                        }
                    }

                */
                #endregion

                //取出当天的体征测量 若有与测试任务拼接好了
                //先写死取的生理参数
                List<VitalTaskCom> VitalTaskComList = new List<VitalTaskCom>();
                VitalTaskCom VitalTaskCom = new VitalTaskCom();

                string Module = "";
                InterSystems.Data.CacheTypes.CacheSysList planInfo = null;
                planInfo = PsPlan.GetPlanInfo(pclsCache, PlanNo);
                if (planInfo != null)
                {

                    Module = planInfo[4].ToString();

                }

                if (Module == "M1")
                {
                    #region  高血压模块  需要考虑没有脉率任务的情况

                    //血压任务肯定有
                    int BPTime = 0;
                    int mark = 0;
                    string SysValue = "";
                    string DiaValue = "";
                    string Unit = "";
                    CacheSysList SysList = PsVitalSigns.GetSignByDay(pclsCache, PatientId, "Bloodpressure", "Bloodpressure_1", Date);
                    if (SysList != null)
                    {
                        mark = 1;
                        BPTime = Convert.ToInt32(SysList[1].ToString());  //时刻数据库是"1043"形式,需要转换  取两者最新的那个时间好了 即谁大取谁
                        SysValue = SysList[2].ToString();
                        Unit = SysList[3].ToString();
                    }
                    CacheSysList DiaList = PsVitalSigns.GetSignByDay(pclsCache, PatientId, "Bloodpressure", "Bloodpressure_2", Date);
                    if (DiaList != null)
                    {
                        mark = 1;
                        int BPTime1 = Convert.ToInt32(DiaList[1].ToString());
                        if (BPTime <= BPTime1)
                        {
                            BPTime = BPTime1;
                        }
                        DiaValue = DiaList[2].ToString();
                    }

                    VitalTaskCom = new VitalTaskCom();
                    VitalTaskCom.SignName = "血压";
                    if (mark == 1)
                    {
                        VitalTaskCom.Status = "1";
                        VitalTaskCom.Time = PsVitalSigns.TransTime(BPTime.ToString());
                        VitalTaskCom.Value = SysValue + "/" + DiaValue;
                        VitalTaskCom.Unit = Unit;
                    }
                    else
                    {
                        VitalTaskCom.Status = "0";
                    }
                    VitalTaskComList.Add(VitalTaskCom);

                    //脉率任务可能没没有,需要确认
                    string condition1 = " TaskCode = 'Pulserate|Pulserate_1'";
                    DataRow[] PulserateRows = ComplianceList.Select(condition1);

                    if ((PulserateRows != null) && (PulserateRows.Length == 1))
                    {
                        VitalTaskCom = new VitalTaskCom();
                        VitalTaskCom.SignName = "脉率";

                        CacheSysList PulList = PsVitalSigns.GetSignByDay(pclsCache, PatientId, "Pulserate", "Pulserate_1", Date);
                        if (PulList != null)
                        {

                            VitalTaskCom.Status = "1";
                            VitalTaskCom.Time = PsVitalSigns.TransTime(PulList[1].ToString());
                            VitalTaskCom.Value = PulList[2].ToString();
                            VitalTaskCom.Unit = PulList[3].ToString();
                        }
                        else
                        {
                            VitalTaskCom.Status = "0";

                        }
                        VitalTaskComList.Add(VitalTaskCom);
                    }
                    #endregion
                }

                TaskComDetailByD.VitalTaskComList = VitalTaskComList;

                TaskComByType TaskComByType = new TaskComByType();
                List<TaskCom> TaskComList = new List<TaskCom>();
                TaskCom TaskCom = new TaskCom();

                //生活方式
                string condition = " Type = 'LifeStyle'";
                DataRow[] LifeStyleRows = ComplianceList.Select(condition);

                if ((LifeStyleRows != null) && (LifeStyleRows.Length > 0))
                {
                    TaskComByType = new TaskComByType();
                    TaskComByType.TaskType = "生活方式";
                    TaskComList = new List<TaskCom>();
                    TaskCom = new TaskCom();

                    for (int j = 0; j < LifeStyleRows.Length; j++)
                    {
                        TaskCom = new TaskCom();
                        TaskCom.TaskName = LifeStyleRows[j]["TaskName"].ToString();
                        TaskCom.TaskStatus = LifeStyleRows[j]["Status"].ToString();
                        TaskComList.Add(TaskCom);
                    }
                    TaskComByType.TaskComList = TaskComList;
                    TaskComDetailByD.TaskComByTypeList.Add(TaskComByType);
                }

                //用药情况
                condition = " Type = 'Drug'";
                DataRow[] DrugRows = ComplianceList.Select(condition);

                if ((DrugRows != null) && (DrugRows.Length > 0))
                {
                    TaskComByType = new TaskComByType();
                    TaskComByType.TaskType = "用药情况";
                    TaskComList = new List<TaskCom>();
                    TaskCom = new TaskCom();
                    for (int j = 0; j < DrugRows.Length; j++)
                    {
                        TaskCom = new TaskCom();
                        TaskCom.TaskName = DrugRows[j]["TaskName"].ToString();
                        TaskCom.TaskStatus = DrugRows[j]["Status"].ToString();
                        TaskComList.Add(TaskCom);
                    }
                    TaskComByType.TaskComList = TaskComList;
                    TaskComDetailByD.TaskComByTypeList.Add(TaskComByType);
                }

                return TaskComDetailByD;
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "PsCompliance.GetImplementationByDate", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                return null;
            }
        }
Ejemplo n.º 2
0
        public void GetImplementationByDate(string PatientId, string PlanNo, string DateSelected)
        {
            TaskComDetailByD TaskComDetailByD = new TaskComDetailByD(); //voidDateTime
            string str_result = "";  //最终的输出-ImplementationInfo转化成json格式
            try
            {
                //DateSelected形式"20150618" 或"15/06/18"  目前使用前者
                int Date = Convert.ToInt32(DateSelected);
                //string temp = "20" + DateSelected;
                //int Date = Convert.ToInt32(Convert.ToDateTime(temp).ToString("yyyyMMdd"));
                //int Date = Convert.ToInt32(DateSelected.ToString("yyyyMMdd"));
                TaskComDetailByD = PsCompliance.GetImplementationByDate(_cnCache, PatientId, PlanNo, Convert.ToInt32(Date));

                str_result = JSONHelper.ObjectToJson(TaskComDetailByD);
                Context.Response.BinaryWrite(new byte[] { 0xEF, 0xBB, 0xBF });
                Context.Response.Write(str_result);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                //Context.Response.End();
                //return ImplementationInfo;
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "GetImplementationByDate", "WebService调用异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                //return null;
                throw (ex);
            }
        }