//创建计划 GL 2015-10-13 public int CreateTask(DataConnection pclsCache, string PlanNo, string Type, string Code, string SortNo, string Instruction, string UserId, string TerminalName, string TerminalIP, int DeviceType) { try { int ret = 3; ret = new PlanInfoMethod().PsTaskSetData(pclsCache, PlanNo, Type, Code, SortNo,Instruction, UserId, TerminalName, TerminalIP, DeviceType); return ret; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "CreateTask ", "PlanInfoRepository! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return 2; throw (ex); } }
public List<PatientListTable> GetPatientsPlan(DataConnection pclsCache, string DoctorId, string Module, string VitalType, string VitalCode) { List<PatientListTable> items = new List<PatientListTable>(); if (Module == "{Module}") { string[] Mu = new string[] { "HM1", "HM2", "HM3" }; for (int i = 0; i<Mu.Length; i++) { List<PatientListTable> item = new List<PatientListTable>(); item = new PlanInfoMethod().GetPatientsPlan(pclsCache, DoctorId, Mu[i], VitalType, VitalCode); if (item != null) { items.AddRange(item); } } } else { items = new PlanInfoMethod().GetPatientsPlan(pclsCache, DoctorId, Module, VitalType, VitalCode); } for (int i = 0; i < items.Count; i++) { for(int j=i+1; j<items.Count; j++) { if(items[i].PatientId == items[j].PatientId) { items[i].Module = items[i].Module + "/" + items[j].Module; items.RemoveAt(j); j--; } } } return items; }
//输入PlanNo获取该计划下所有任务的完成情况(即依从情况) 施宇帆 20150104 public List<TaskCompliance> GetTaskCompliance(DataConnection pclsCache, string PlanNo) { List<TaskCompliance> TaskCompliance = new List<TaskCompliance>(); try { List<PsTask> list1 = new List<PsTask>(); list1 = new PlanInfoMethod().GetAllTask(pclsCache, PlanNo); if(list1 != null) { for(int i=0; i<list1.Count; i++) { List<ItemCompliance> list2 = new List<ItemCompliance>(); list2 = new PlanInfoMethod().GetItemCompliance(pclsCache, PlanNo, list1[i].Type, list1[i].Code); if(list2.Count != 0) { TaskCompliance NewLine = new TaskCompliance(); NewLine.AllDays = 0; NewLine.DoDays = 0; NewLine.UndoDays = 0; NewLine.CategoryCode = list2[0].CategoryCode; NewLine.Code = list2[0].Code; NewLine.Name = list2[0].Name; NewLine.Instruction = list1[i].Instruction; for(int j=0; j<list2.Count; j++) { if(list2[j].Status == "0") { NewLine.UndoDays++; } else if(list2[j].Status == "1") { NewLine.DoDays++; } NewLine.AllDays++; } TaskCompliance.Add(NewLine); } } } return TaskCompliance; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "PlanInfoMethod.GetTaskCompliance", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return null; } finally { } }
/// <summary> /// 获取某个病人某个模块指定时间段内的依从率 SYF 20151102 /// </summary> /// <param name="pclsCache"></param> /// <param name="PatientId"></param> /// <param name="StartDate"></param> /// <param name="EndDate"></param> /// <param name="Module"></param> /// <returns></returns> public List<ComplianceDate> GetComplianceListInC(DataConnection pclsCache, string PatientId, string StartDate, string EndDate, string Module) { List<ComplianceDate> ComplianceList = new List<ComplianceDate>(); try { List<GPlanInfo> list1 = new List<GPlanInfo>(); List<ComplianceListByPeriod> list2 = new List<ComplianceListByPeriod>(); list1 = new PlanInfoMethod().GetPlanListByMS(pclsCache, PatientId, Module, 0); int i = 0; int j = 0;//为了找两个特殊的计划,即包括输入的StartDate和EndDate的两个计划,后面取依从率就在这两个计划之间取 int k = 0; if (list1 != null) { for (; i < list1.Count; i++)// && (int.Parse(list1[i].EndDate) >= int.Parse(StartDate)) { if ((int.Parse(list1[i].StartDate) <= int.Parse(StartDate))) { break; } } if (i == list1.Count) { i--; } for (; j < list1.Count; j++)//(int.Parse(list1[j].StartDate) <= int.Parse(EndDate)) && { if ((int.Parse(list1[j].EndDate) >= int.Parse(EndDate))) { break; } } if (j == list1.Count) { j--; } for (k = i; k >= j; k--) {//每次取一个计划的信息,但每个计划里面还是有多条信息 int SD = int.Parse(list1[k].StartDate) > int.Parse(StartDate) ? int.Parse(list1[k].StartDate) : int.Parse(StartDate); int ED = int.Parse(list1[k].EndDate) < int.Parse(EndDate) ? int.Parse(list1[k].EndDate) : int.Parse(EndDate); list2 = new PlanInfoMethod().GetComplianceListByPeriod(pclsCache, list1[k].PlanNo, SD, ED); if (list2 != null) { for (int m = 0; m < list2.Count; m++) { ComplianceDate oneday = new ComplianceDate(); //输出 oneday.Date = list2[m].Date; oneday.PlanNo = list1[k].PlanNo; oneday.Compliance = list2[m].Compliance; ComplianceList.Add(oneday); } } } } return ComplianceList; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "PlanInfoMethod.GetComplianceListInC", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return null; } finally { } }
public int GetOnPlanPatientNumByDoctorId(DataConnection pclsCache, string DoctorId) { int ret = 0; string[] Category = { "M1", "M2", "M3", "HM1", "HM2", "HM3" }; for (int i = 0; i < Category.Length; i++) { List<PatientNum> items = new List<PatientNum>(); items = GetPatientsByDoctorId(pclsCache, DoctorId, Category[i]); if (items != null) { for(int MouN=1; i<items.Count; i++) { string PatId = items[i].PatientId; GPlanInfo GPlanInfo = new GPlanInfo(); //string DocId = ""; GPlanInfo = new PlanInfoMethod().GetExecutingPlan(pclsCache, PatId); if((GPlanInfo != null) &&(DoctorId == GPlanInfo.DoctorId)) { ret++; } } } } return ret; }
/// <summary> /// 需要修改 20151029 /// </summary> /// <param name="UserId"></param> /// <param name="PlanNo"></param> /// <param name="StartDate"></param> /// <param name="EndDate"></param> /// <param name="ItemType"></param> /// <param name="ItemCode"></param> /// <returns></returns> public List<ComplianceAllSignsListByPeriod> GetComplianceAllSignsListByPeriod(DataConnection pclsCache, string UserId, string PlanNo, int StartDate, int EndDate, string ItemType, string ItemCode) { List<ComplianceAllSignsListByPeriod> items = new List<ComplianceAllSignsListByPeriod>(); //依从率 List<ComplianceListByPeriod> items1 = new PlanInfoMethod().GetComplianceListByPeriod(pclsCache, PlanNo, StartDate, EndDate); //体征 List<SignByPeriod> items2 = new PlanInfoMethod().GetSignByPeriod(pclsCache,UserId,ItemType,ItemCode,StartDate,EndDate); //List<VitalInfo> items2 = new VitalInfoMethod().GetAllSignsByPeriod(pclsCache, UserId, StartDate, EndDate); if (items1 != null) { for (int i = 0; i < items1.Count; i++) { ComplianceAllSignsListByPeriod item = new ComplianceAllSignsListByPeriod(); item.Date = items1[i].Date.ToString(); item.Compliance = Math.Round(items1[i].Compliance * 100, 0) + "%"; item.Description = items1[i].Description; if (items1[i].Compliance == 1) { item.BulletColor = "#77777"; } else if (items1[i].Compliance == 0) { item.BulletColor = "#DADADA"; } else { item.CustomBullet = "img/amcharts/customBullet.png"; } item.BulletValue = "1"; List<PsTask> tasks = new PlanInfoMethod().GetTasks(pclsCache, PlanNo, "T", item.Date, ""); string str = ""; if (tasks != null) { for (int j = 0; j < tasks.Count; j++) { if (j % 2 == 0) { //str = str + tasks[j].Name + ":" + tasks[j].Status + " "; str = str + tasks[j].Name + " "; } else { //str = str + tasks[j].Name + ":" + tasks[j].Status + "<br>"; str = str + tasks[j].Name + "<br>"; } } } item.Task = str; //需要修改 if (items2 != null) { SignByPeriod vitalSign = items2.Find(s => s.RecordDate == item.Date); if (vitalSign != null) { item.VitalCode = ItemCode; item.Value = vitalSign.Value; //需要修改 } else { item.VitalCode = ItemCode; item.Value = "#"; //需要修改 } } items.Add(item); } } return items; }
public List<TasksForClick> GetTasksForClick(DataConnection pclsCache, string PlanNo, string ParentCode, string Date) { List<TasksForClick> tasks = new List<TasksForClick>(); List<PsTask> tasksOne = new PlanInfoMethod().GetTasks(pclsCache, PlanNo, ParentCode, Date, ""); if (tasksOne != null) { for (int i = 0; i < tasksOne.Count; i++) { if (tasksOne[i].InvalidFlag == "1") { TasksForClick task = new TasksForClick(); task.Type = tasksOne[i].Type; task.Code = tasksOne[i].Code; task.Name = tasksOne[i].Name; task.Status = tasksOne[i].Status; List<PsTask> tasksTwo = new PlanInfoMethod().GetTasks(pclsCache, PlanNo, tasksOne[i].Code, Date, ""); if (tasksTwo != null) { for (int j = 0; j < tasksTwo.Count; j++) { TasksForClickDtl dtl = new TasksForClickDtl(); dtl.Code = tasksTwo[j].Code; dtl.Name = tasksTwo[j].Name; dtl.Status = tasksTwo[j].Status; task.SubTasks.Add(dtl); } } tasks.Add(task); } } } return tasks; }
//获取某体征的数据和画图信息(收缩压、舒张压、脉率) Pad和Phone都要用 GL 2015-10-13 //关于输入 StartDate,EndDate Pad首次没有拿出StartDate,EndDate Phone拿出了 这样规划比较好 public ChartData GetSignInfoByCode(DataConnection pclsCache, string PatientId, string PlanNo, string ItemCode, int StartDate, int EndDate) { ChartData ChartData = new ChartData(); List<Graph> GraphList = new List<Graph>(); GraphGuide GraphGuide = new GraphGuide(); List<MstBloodPressure> reference = new List<MstBloodPressure>(); try { string Module = ""; GPlanInfo planInfo = new PlanInfoMethod().GetPlanInfo(pclsCache, PlanNo); if (planInfo != null) { Module = planInfo.Module; } if (Module == "M1") { if ((ItemCode == "Bloodpressure|Bloodpressure_1") || (ItemCode == "Bloodpressure|Bloodpressure_2")) { reference = new PlanInfoMethod().GetBPGrades(pclsCache); } GraphList = new PlanInfoMethod().GetSignInfoByM1(pclsCache, PatientId, PlanNo, ItemCode, StartDate, EndDate, reference); //初始值、目标值、分级规则加工 if (GraphList != null) { if (GraphList.Count > 0) { GraphGuide = new PlanInfoMethod().GetGuidesByCode(pclsCache, PlanNo, ItemCode, reference); ChartData.GraphGuide = GraphGuide; } } } //读取任务列表 必有测量任务,其他任务(例如吃药)可能没有 20151027 需要修改 //List<PsTask> TaskList = new PlanInfoMethod().GetTaskList(pclsCache, PlanNo); List<PsTask> TaskList = new List<PsTask>(); List<PsTask> VitalSignRows = new List<PsTask>(); foreach (PsTask item in TaskList) { if (item.Type == "VitalSign") { VitalSignRows.Add(item); } } //其他任务依从情况 List<CompliacneDetailByD> TasksComByPeriod = new List<CompliacneDetailByD>(); //是否有其他任务 if (TaskList.Count == VitalSignRows.Count) { ChartData.OtherTasks = "0"; } else { ChartData.OtherTasks = "1"; TasksComByPeriod = new PlanInfoMethod().GetTasksComCountByPeriod(pclsCache, PatientId, PlanNo, StartDate, EndDate); if ((TasksComByPeriod != null) && (TasksComByPeriod.Count == GraphList.Count)) { for (int rowsCount = 0; rowsCount < TasksComByPeriod.Count; rowsCount++) { GraphList[rowsCount].DrugValue = "1"; //已经初始化过 GraphList[rowsCount].DrugBullet = TasksComByPeriod[rowsCount].drugBullet; GraphList[rowsCount].DrugColor = TasksComByPeriod[rowsCount].drugColor; GraphList[rowsCount].DrugDescription = TasksComByPeriod[rowsCount].Events; } } } ChartData.GraphList = GraphList; return ChartData; //string a = JSONHelper.ObjectToJson(ChartData); //Context.Response.BinaryWrite(new byte[] { 0xEF, 0xBB, 0xBF }); //Context.Response.Write(a); //HttpContext.Current.ApplicationInstance.CompleteRequest(); //Context.Response.End(); } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "GetSignInfoByCode", "PlanInfoRepository error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return null; //throw (ex); } }
//获取健康专员负责的所有患者(最新结束但未达标的)计划列表 GL 2015-10-13 public List<OverDuePlanDetail> GetOverDuePlanList(DataConnection pclsCache, string DoctorId, string ModuleType) { List<OverDuePlanDetail> PlanList = new List<OverDuePlanDetail>(); try { int nowDate = new CommonFunction().GetServerDate(); List<PatientPlan> DT_Patients = new PlanInfoMethod().GetOverDuePlanByDoctorId(pclsCache, DoctorId, ModuleType); if (DT_Patients == null) { return null; } foreach (PatientPlan item in DT_Patients) { string patientId = item.PatientId; string planNo = item.PlanNo; string startDate = item.StartDate; string endDate = item.EndDate; string totalDays = item.TotalDays; string remainingDays = item.RemainingDays; double process = 0.0; //VitalSign List<string> vitalsigns = new List<string>(); if (planNo != "") { //double complianceRate = PsCompliance.GetComplianceByDay(pclsCache, patientId, nowDate, planNo); string itemType = "Bloodpressure"; string itemCode = "Bloodpressure_1"; int recordDate = Convert.ToInt32(endDate); VitalInfo list = new VitalInfoMethod().GetLatestVitalSignsByDate(pclsCache, patientId, itemType, itemCode, recordDate); if (list != null) { vitalsigns.Add(list.Value); } TargetByCode targetlist = new PlanInfoMethod().GetTarget(pclsCache, planNo, itemType, itemCode); if (targetlist != null) { vitalsigns.Add(targetlist.Value); //value } //非法数据判断 zam 2015-5-18 //OverDue Check if (list != null && targetlist != null) { double m, n; bool misNumeric = double.TryParse(list.Value, out m); bool nisNumeric = double.TryParse(targetlist.Value, out n); if (misNumeric && nisNumeric) { //if (Convert.ToInt32(list[2]) <= Convert.ToInt32(targetlist[3])) //已达标 if (m <= n) { continue; } } } } //PhotoAddress string photoAddress = ""; PatDetailInfo patientInfolist = new ModuleInfoMethod().PsBasicInfoDetailGetPatientDetailInfo(pclsCache, patientId); if (patientInfolist != null) { photoAddress = patientInfolist.PhotoAddress; } string patientName = ""; patientName = new UsersMethod().GetNameByUserId(pclsCache, patientId); OverDuePlanDetail PlanItem = new OverDuePlanDetail(); PlanItem.PatientId = patientId; PlanItem.PatientName = patientName; PlanItem.PhotoAddress = photoAddress; PlanItem.PlanNo = planNo; PlanItem.StartDate = startDate; PlanItem.Process = process; PlanItem.RemainingDays = remainingDays; PlanItem.VitalSign = vitalsigns; PlanList.Add(PlanItem); } return PlanList; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "GetOverDuePlanList", "PlanInfoRepository error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return null; throw (ex); } }
//通过某计划的日期,获取该天的任务完成详情 用于图上点点击时弹框内容 GL 2015-10-13 public TaskComDetailByD GetImplementationByDate(DataConnection pclsCache, 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); TaskComDetailByD = new PlanInfoMethod().GetImplementationByDate(pclsCache, 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 TaskComDetailByD; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "GetImplementationByDate", "PlanInfoRepository error information : " + ex.Message + Environment.NewLine + ex.StackTrace); //return null; throw (ex); } }
//根据模块获取正在执行的计划 GL 2015-10-13 public GPlanInfo GetExecutingPlanByModule(DataConnection pclsCache, string PatientId, string Module) { try { //string ret = ""; GPlanInfo planInfo = new PlanInfoMethod().GetExecutingPlanByM(pclsCache, PatientId, Module); planInfo.RemainingDays = ""; Progressrate temp2 = new PlanInfoMethod().GetProgressRate(pclsCache, planInfo.PlanNo); if (temp2 != null) { planInfo.RemainingDays = temp2.RemainingDays; } if (planInfo != null) { //ret = planInfo.PlanNo; TypeAndName Doctor = new ModuleInfoMethod().PsBasicInfoDetailGetSDoctor(pclsCache, PatientId); if (Doctor != null && Doctor.Type != null) //Doctor.Count > 1 { planInfo.DoctorId = Doctor.Type; planInfo.DoctorName = Doctor.Name; } } return planInfo; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "GetExecutingPlanByModule", "PlanInfoRepository error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return null; throw ex; } }
//GetPlanList34ByM 获取某模块患者的正在执行的和结束的计划列表 GL 2015-10-12 public List<GPlanInfo> GetPlanList34ByM(DataConnection pclsCache, string PatientId, string Module) { List<GPlanInfo> result = new List<GPlanInfo>(); try { GPlanInfo list = GetExecutingPlanByM(pclsCache, PatientId, Module); if (list != null) { //GPlanInfo PlanDeatil = new GPlanInfo(); //PlanDeatil.PlanNo = list.PlanNo; //PlanDeatil.StartDate = Convert.ToInt32(list.StartDate); //PlanDeatil.EndDate = Convert.ToInt32(list.EndDate); string temp = list.StartDate.ToString().Substring(0, 4) + "/" + list.StartDate.ToString().Substring(4, 2) + "/" + list.StartDate.ToString().Substring(6, 2); string temp1 = list.EndDate.ToString().Substring(0, 4) + "/" + list.EndDate.ToString().Substring(4, 2) + "/" + list.EndDate.ToString().Substring(6, 2); list.PlanName = "当前计划:" + temp + "-" + temp1; list.PlanCompliance = GetComplianceByPlanNo(pclsCache, list.PlanNo).ToString(); Progressrate temp2 = new PlanInfoMethod().GetProgressRate(pclsCache, list.PlanNo); list.RemainingDays = ""; if(temp2 != null) { list.RemainingDays = temp2.RemainingDays; } } else { //PlanDeatil PlanDeatil = new PlanDeatil(); //PlanDeatil.PlanNo = ""; list.PlanName = "当前计划"; } result.Add(list); List<PlanDeatil> endingPlanList = new List<PlanDeatil>(); endingPlanList = GetEndingPlan(pclsCache, PatientId, Module); if (endingPlanList!= null) { foreach (PlanDeatil item in endingPlanList) { GPlanInfo PlanDeatil = new GPlanInfo(); PlanDeatil.PlanNo = item.PlanNo; PlanDeatil.StartDate = item.StartDate.ToString(); PlanDeatil.EndDate = item.EndDate.ToString(); string temp = PlanDeatil.StartDate.ToString().Substring(0, 4) + "/" + PlanDeatil.StartDate.ToString().Substring(4, 2) + "/" + PlanDeatil.StartDate.ToString().Substring(6, 2); string temp1 = PlanDeatil.EndDate.ToString().Substring(0, 4) + "/" + PlanDeatil.EndDate.ToString().Substring(4, 2) + "/" + PlanDeatil.EndDate.ToString().Substring(6, 2); PlanDeatil.PlanName = "往期:" + temp + "-" + temp1; PlanDeatil.PlanCompliance = GetComplianceByPlanNo(pclsCache, list.PlanNo).ToString(); PlanDeatil.RemainingDays = ""; Progressrate temp2 = new PlanInfoMethod().GetProgressRate(pclsCache, list.PlanNo); if (temp2 != null) { PlanDeatil.RemainingDays = temp2.RemainingDays; } result.Add(PlanDeatil); } } return result; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "PlanInfoMethod.GetPlanList34ByM", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return null; } finally { pclsCache.DisConnect(); } }