public void GetImplementationForPhone(string PatientId, string Module) { ImplementationPhone ImplementationPhone = new ImplementationPhone(); string str_result = ""; try { //注释 //注释 //病人基本信息-头像、姓名.. (由于手机版只针对换换咋用户,基本信息可不用获取 // CacheSysList patientList = PsBasicInfo.GetPatientBasicInfo(_cnCache, PatientId); //if (patientList != null) //{ //ImplementationPhone.PatientInfo.PatientName = patientList[0]; //} int planStartDate = 0; int planEndDate = 0; string PlanNo = ""; InterSystems.Data.CacheTypes.CacheSysList planInfo = null; planInfo = PsPlan.GetExecutingPlanByM(_cnCache, PatientId, Module); if (planInfo != null) { PlanNo = planInfo[0].ToString(); planStartDate = Convert.ToInt32(planInfo[2]); planEndDate = Convert.ToInt32(planInfo[3]); //未用到 } if ((PlanNo != "") && (PlanNo != null)) //存在正在执行的计划 { //剩余天数和进度 InterSystems.Data.CacheTypes.CacheSysList PRlist = null; PRlist = PsPlan.GetProgressRate(_cnCache, PlanNo); if (PRlist != null) { ImplementationPhone.RemainingDays = PRlist[0].ToString(); //"距离本次计划结束还剩"+PRlist[0]+"天"; ImplementationPhone.ProgressRate = (Convert.ToDouble(PRlist[1]) * 100).ToString(); //"进度:"++"%"; } //最近一周的依从率 InterSystems.Data.CacheTypes.CacheSysList weekPeriod = null; weekPeriod = PsPlan.GetWeekPeriod(_cnCache, planStartDate); if (weekPeriod != null) { ImplementationPhone.CompliacneValue = PsCompliance.GetCompliacneRate(_cnCache, PatientId, PlanNo, Convert.ToInt32(weekPeriod[0]), Convert.ToInt32(weekPeriod[1])); ImplementationPhone.StartDate = Convert.ToInt32(weekPeriod[0]); //用于获取血压的详细数据 ImplementationPhone.EndDate = Convert.ToInt32(weekPeriod[1]); } #region 读取任务执行情况,血压、用药-最近一周的数据 //读取任务 phone版 只显示测量和用药任务 DataTable TaskList = new DataTable(); TaskList = PsTask.GetTaskList(_cnCache, PlanNo); //测试-血压(因为血压分级表的单独存在,决定了可以直接用收缩压/舒张压作为输入 //默认显示 图-收缩压 string condition = " Code = 'Bloodpressure|Bloodpressure_1' or Code = 'Bloodpressure|Bloodpressure_2'"; DataRow[] BPRows = TaskList.Select(condition); List<MstBloodPressure> reference = new List<MstBloodPressure>(); chartData chartData = new chartData(); List<Graph> graphList = new List<Graph>(); List<GuideList> BPGuide = new List<GuideList>(); SignDetailByP SignDetailByP = new SignDetailByP(); if ((BPRows != null) && (BPRows.Length == 2)) { //获取分级原则 reference = CmMstBloodPressure.GetBPGrades(_cnCache); //血压数据 graphList = CmMstBloodPressure.GetBPInfo(_cnCache, PatientId, PlanNo, "Bloodpressure", Convert.ToInt32(weekPeriod[0]), Convert.ToInt32(weekPeriod[1]), reference); //初始值、目标值、分级范围加工 if (graphList.Count > 0) { BPGuide = CmMstBloodPressure.GetBPGuide(_cnCache, PlanNo, "Bloodpressure", reference); chartData.BPGuide = BPGuide; } } //用药情况 #region 用药情况 condition = " Type = 'Drug' "; DataRow[] DrugRows = TaskList.Select(condition); if ((DrugRows != null) && (DrugRows.Length != 0)) { List<CompliacneDetailByD> DrugComByPeriod = new List<CompliacneDetailByD>(); DrugComByPeriod = PsCompliance.GetDrugComByPeriod(_cnCache, PatientId, PlanNo, Convert.ToInt32(weekPeriod[0]), Convert.ToInt32(weekPeriod[1])); if ((DrugComByPeriod != null) && (DrugComByPeriod.Count == graphList.Count)) { for (int rowsCount = 0; rowsCount < DrugComByPeriod.Count; rowsCount++) { graphList[rowsCount].drugValue = "1"; graphList[rowsCount].drugBullet = DrugComByPeriod[rowsCount].drugBullet; graphList[rowsCount].drugColor = DrugComByPeriod[rowsCount].drugColor; graphList[rowsCount].drugDescription = DrugComByPeriod[rowsCount].Events; } } } else //没有用药任务 { for (int m = 0; m < graphList.Count; m++) { graphList[m].drugBullet = ""; graphList[m].drugValue = "1"; graphList[m].drugColor = "#FFFFFF"; graphList[m].drugDescription = "无用药任务"; } } #region // #region // //获取本次计划内的用药数据 不同药不同表 一般药不会很多 // //不同用药情况归化在同一天 表行数是一样多的 // DataSet ds_DrugCompliacneDetails = new DataSet(); // for (int n = 0; n < DrugRows.Length; n++) // { // //放在dataset // DataTable dt_DrugCompliacneDetail = new DataTable(); // dt_DrugCompliacneDetail = PsCompliance.GetDrugCompliacneDetailByPeriod(_cnCache, PatientId, PlanNo, Convert.ToInt32(weekPeriod[0]), Convert.ToInt32(weekPeriod[1]), DrugRows[n]["Id"].ToString(), DrugRows[n]["Code"].ToString()); // ds_DrugCompliacneDetails.Tables.Add(dt_DrugCompliacneDetail); // } // //各药的整合 并和血压数据整合成一份 // string a = "已吃:"; //已吃 // int aa = 0; // string b = "未吃:"; //未吃 // int bb = 0; // if (ds_DrugCompliacneDetails.Tables[0].Rows.Count == graphList.Count) // { // for (int rowsCount = 0; rowsCount < ds_DrugCompliacneDetails.Tables[0].Rows.Count; rowsCount++) // { // string drugResultText = ""; // //drugResultText = "<b><span style='font-size:14px;'> 用药情况:</span></b><br>"; // for (int tableCount = 0; tableCount < ds_DrugCompliacneDetails.Tables.Count; tableCount++) // { // if (ds_DrugCompliacneDetails.Tables[tableCount].Rows[rowsCount]["Status"].ToString() == "1") // { // a += ds_DrugCompliacneDetails.Tables[tableCount].TableName + "、"; // //drugResultText += ds_DrugCompliacneDetails.Tables[tableCount].TableName + "complete "; // aa++; // } // else // { // //drugResultText += "<b><span style='font-size:14px;color:red;'>" + ds_DrugCompliacneDetails.Tables[tableCount].TableName + "noncomplete " + ":</span></b>"; // b += ds_DrugCompliacneDetails.Tables[tableCount].TableName + "、"; // bb++; // } // } // //去除尾部、 // if (a.Substring(a.Length - 1, 1) == "、") // { // a = a.Remove(a.LastIndexOf("、")); // } // if (b.Substring(b.Length - 1, 1) == "、") // { // b = b.Remove(b.LastIndexOf("、")); // } // //输出结果 // Graph Graph = new Graph(); // graphList[rowsCount].drugValue = "1"; // //Graph.drugBullet=""; // if (aa == 0) //根本没吃 // { // drugResultText = "完全未吃;"; // drugResultText += b; // graphList[rowsCount].drugColor = "#DADADA"; // } // else if ((aa > 0) && (aa < ds_DrugCompliacneDetails.Tables.Count)) //吃了部分 // { // drugResultText = "部分完成;"; // drugResultText += b; // drugResultText += ";"; // drugResultText += a; // graphList[rowsCount].drugBullet = "amcharts-images/drug.png"; // graphList[rowsCount].drugColor = ""; // } // else //全吃了 // { // drugResultText = "完成;"; // drugResultText += a; // graphList[rowsCount].drugColor = "#777777"; // } // graphList[rowsCount].drugDescription = drugResultText; // a = "吃了:"; aa = 0; // b = "没吃:"; bb = 0; // } // } //} // #endregion #endregion #endregion chartData.graphList = graphList; #endregion ImplementationPhone.chartData = chartData; } str_result = JSONHelper.ObjectToJson(ImplementationPhone); 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, "GetImplementationForPhone", "WebService调用异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); //return null; throw (ex); } }
public void GetSignsDetailByPeriod(string PatientId, string Module, int StartDate, int Num) { SignDetailByP result = new SignDetailByP(); try { int CacheStartDate = 0; int CacheEndDate = 0; /*严格天数平移 string str_CacheEndDate = PsVitalSigns.GetLatestVitalSignDate(_cnCache, PatientId, StartDate); if ((str_CacheEndDate != "") && (str_CacheEndDate != null)) { CacheEndDate = Convert.ToInt32(str_CacheEndDate); string time = str_CacheEndDate.Substring(0, 4) + "-" + str_CacheEndDate.Substring(4, 2) + "-" + str_CacheEndDate.Substring(6, 2); DateTime starttime = Convert.ToDateTime(time); CacheStartDate = Convert.ToInt32(starttime.AddDays(-Num).ToString("yyyyMMdd")); result.NextStartDate = CacheStartDate; } else { } */ //按有数据的天数平移 CacheSysList dateList = PsVitalSigns.GetVitalSignDates(_cnCache, PatientId, StartDate, Num); if (dateList != null) { if ((dateList[0] != null) && (dateList[1] != null)) { CacheStartDate = Convert.ToInt32(dateList[0]); CacheEndDate = Convert.ToInt32(dateList[1]); result.NextStartDate = CacheStartDate; } else if ((dateList[0] == null) && (dateList[1] != null)) { //CacheStartDate =0; CacheEndDate = Convert.ToInt32(dateList[1]); result.NextStartDate = -1; //取完的标志 } else if ((dateList[0] == null) && (dateList[1] == null)) { //CacheStartDate = 0; // CacheEndDate = 0; result.NextStartDate = -1; } } //收缩压 DataTable sysInfo = new DataTable(); sysInfo = PsVitalSigns.GetTypedSignDetailByPeriod(_cnCache, PatientId, "Bloodpressure", "Bloodpressure_1", CacheStartDate, CacheEndDate); //舒张压 DataTable diaInfo = new DataTable(); diaInfo = PsVitalSigns.GetTypedSignDetailByPeriod(_cnCache, PatientId, "Bloodpressure", "Bloodpressure_2", CacheStartDate, CacheEndDate); //脉率 DataTable pulInfo = new DataTable(); pulInfo = PsVitalSigns.GetTypedSignDetailByPeriod(_cnCache, PatientId, "Pulserate", "Pulserate_1", CacheStartDate, CacheEndDate); //list.PrimaryKey = new DataColumn[] { list.Columns["RecordDate"], list.Columns["RecordTime"], list.Columns["SignType"], }; //三张表整合,按时间排序 避免条数可能不一致造成的问题 sysInfo.Merge(diaInfo); sysInfo.Merge(pulInfo); //按RecordDate、RecordTime、SignType排序 再合并成收集需要的形式 DataView dv = sysInfo.DefaultView; dv.Sort = "RecordDate desc, RecordTime asc,SignType asc"; DataTable dt_Sort = dv.ToTable(); //1 收缩压, 2 舒张压, 3 脉率 //整理成日期、时刻、数值的形式 //整理成列表形式 2011/01/03 星期三 //08:00 137 95 66 //09:00 134 78 66 if (dt_Sort.Rows.Count > 0) { SignDetail SignDetail = new SignDetail(); SignDetail.DetailTime = dt_Sort.Rows[0]["RecordTime"].ToString(); if (dt_Sort.Rows[0]["SignType"].ToString() == "1") { SignDetail.SBPValue = dt_Sort.Rows[0]["Value"].ToString(); } else if (dt_Sort.Rows[0]["SignType"].ToString() == "2") { SignDetail.DBPValue = dt_Sort.Rows[0]["Value"].ToString(); } else { SignDetail.PulseValue = dt_Sort.Rows[0]["Value"].ToString(); } SignDetailByD SignDetailByD = new SignDetailByD(); SignDetailByD.Date = dt_Sort.Rows[0]["RecordDate"].ToString(); SignDetailByD.WeekDay = PsCompliance.CaculateWeekDay(dt_Sort.Rows[0]["RecordDate"].ToString()); if (dt_Sort.Rows.Count == 1) { SignDetailByD.SignDetailList.Add(SignDetail); result.SignDetailByDs.Add(SignDetailByD); } else { string temp_date = dt_Sort.Rows[0]["RecordDate"].ToString(); string temp_hour = dt_Sort.Rows[0]["RecordTime"].ToString(); for (int rowsCount = 1; rowsCount < dt_Sort.Rows.Count; rowsCount++) { if (rowsCount != dt_Sort.Rows.Count - 1) { #region 不是最后一条 if (temp_date == dt_Sort.Rows[rowsCount]["RecordDate"].ToString()) { #region 同一天 if (temp_hour == dt_Sort.Rows[rowsCount]["RecordTime"].ToString()) { if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "1") { SignDetail.SBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "2") { SignDetail.DBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else { SignDetail.PulseValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } } else { SignDetailByD.SignDetailList.Add(SignDetail); SignDetail = new SignDetail(); SignDetail.DetailTime = dt_Sort.Rows[rowsCount]["RecordTime"].ToString(); if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "1") { SignDetail.SBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "2") { SignDetail.DBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else { SignDetail.PulseValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } temp_hour = dt_Sort.Rows[rowsCount]["RecordTime"].ToString(); } #endregion } else { #region 不同天 SignDetailByD.SignDetailList.Add(SignDetail); result.SignDetailByDs.Add(SignDetailByD); SignDetailByD = new SignDetailByD(); SignDetail = new SignDetail(); SignDetail.DetailTime = dt_Sort.Rows[rowsCount]["RecordTime"].ToString(); if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "1") { SignDetail.SBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "2") { SignDetail.DBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else { SignDetail.PulseValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } SignDetailByD.Date = dt_Sort.Rows[rowsCount]["RecordDate"].ToString(); SignDetailByD.WeekDay = PsCompliance.CaculateWeekDay(dt_Sort.Rows[rowsCount]["RecordDate"].ToString()); temp_date = dt_Sort.Rows[rowsCount]["RecordDate"].ToString(); temp_hour = dt_Sort.Rows[rowsCount]["RecordTime"].ToString(); #endregion } #endregion } else { #region 最后一条 if (temp_date == dt_Sort.Rows[rowsCount]["RecordDate"].ToString()) { #region 同一天 if (temp_hour == dt_Sort.Rows[rowsCount]["RecordTime"].ToString()) { if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "1") { SignDetail.SBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "2") { SignDetail.DBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else { SignDetail.PulseValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } SignDetailByD.SignDetailList.Add(SignDetail); result.SignDetailByDs.Add(SignDetailByD); } else { SignDetailByD.SignDetailList.Add(SignDetail); SignDetail = new SignDetail(); SignDetail.DetailTime = dt_Sort.Rows[rowsCount]["RecordTime"].ToString(); if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "1") { SignDetail.SBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "2") { SignDetail.DBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else { SignDetail.PulseValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } temp_hour = dt_Sort.Rows[rowsCount]["RecordTime"].ToString(); SignDetailByD.SignDetailList.Add(SignDetail); result.SignDetailByDs.Add(SignDetailByD); } #endregion } else { #region 不同天 SignDetailByD.SignDetailList.Add(SignDetail); result.SignDetailByDs.Add(SignDetailByD); SignDetailByD = new SignDetailByD(); SignDetail = new SignDetail(); SignDetail.DetailTime = dt_Sort.Rows[rowsCount]["RecordTime"].ToString(); if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "1") { SignDetail.SBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else if (dt_Sort.Rows[rowsCount]["SignType"].ToString() == "2") { SignDetail.DBPValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } else { SignDetail.PulseValue = dt_Sort.Rows[rowsCount]["Value"].ToString(); } SignDetailByD.Date = dt_Sort.Rows[rowsCount]["RecordDate"].ToString(); SignDetailByD.WeekDay = PsCompliance.CaculateWeekDay(dt_Sort.Rows[rowsCount]["RecordDate"].ToString()); temp_date = dt_Sort.Rows[rowsCount]["RecordDate"].ToString(); SignDetailByD.SignDetailList.Add(SignDetail); result.SignDetailByDs.Add(SignDetailByD); #endregion } #endregion } } } } //return result; string a = JSONHelper.ObjectToJson(result); Context.Response.BinaryWrite(new byte[] { 0xEF, 0xBB, 0xBF }); Context.Response.Write(a); //Context.Response.End(); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "GetSignsDetailByPeriod", "WebService调用异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); //return null; throw (ex); } }
public void GetBPDetailByPeriod(string PatientId, string ItemType, int StartDate, int EndDate) { SignDetailByP result = new SignDetailByP(); try { DataTable sysInfo = new DataTable(); sysInfo = PsVitalSigns.GetSignDetailByPeriod(_cnCache, PatientId, "Bloodpressure", "Bloodpressure_1", StartDate, EndDate); //舒张压表 DataTable diaInfo = new DataTable(); diaInfo = PsVitalSigns.GetSignDetailByPeriod(_cnCache, PatientId, "Bloodpressure", "Bloodpressure_2", StartDate, EndDate); if ((sysInfo.Rows.Count == diaInfo.Rows.Count) && (sysInfo.Rows.Count > 0)) { SignDetail SignDetail = new SignDetail(); SignDetail.DetailTime = sysInfo.Rows[0]["RecordTime"].ToString(); SignDetail.Value = sysInfo.Rows[0]["Value"].ToString() + "/" + diaInfo.Rows[0]["Value"].ToString(); SignDetailByD SignDetailByD = new SignDetailByD(); SignDetailByD.Date = sysInfo.Rows[0]["RecordDate"].ToString(); SignDetailByD.WeekDay = PsCompliance.CaculateWeekDay(sysInfo.Rows[0]["RecordDate"].ToString()); SignDetailByD.SignDetailList.Add(SignDetail); //SignDetailByD.Count++; if (sysInfo.Rows.Count == 1) { result.SignDetailByDs.Add(SignDetailByD); } else { string temp = sysInfo.Rows[0]["RecordDate"].ToString(); for (int rowsCount = 1; rowsCount < sysInfo.Rows.Count; rowsCount++) { //2011/01/03-2011/01/09 血压详细记录 单位:mmph //列表形式 -2011/01/03 星期三 //08:00 137/95 //09:00 134/78 if (rowsCount != sysInfo.Rows.Count - 1) { if (temp == sysInfo.Rows[rowsCount]["RecordDate"].ToString()) { SignDetail = new SignDetail(); SignDetail.DetailTime = sysInfo.Rows[rowsCount]["RecordTime"].ToString(); SignDetail.Value = sysInfo.Rows[rowsCount]["Value"].ToString() + "/" + diaInfo.Rows[rowsCount]["Value"].ToString(); SignDetailByD.SignDetailList.Add(SignDetail); //SignDetailByD.Count++; } else { result.SignDetailByDs.Add(SignDetailByD); SignDetailByD = new SignDetailByD(); SignDetailByD.Date = sysInfo.Rows[rowsCount]["RecordDate"].ToString(); SignDetailByD.WeekDay = PsCompliance.CaculateWeekDay(sysInfo.Rows[rowsCount]["RecordDate"].ToString()); SignDetail = new SignDetail(); SignDetail.DetailTime = sysInfo.Rows[rowsCount]["RecordTime"].ToString(); SignDetail.Value = sysInfo.Rows[rowsCount]["Value"].ToString() + "/" + diaInfo.Rows[rowsCount]["Value"].ToString(); SignDetailByD.SignDetailList.Add(SignDetail); //SignDetailByD.Count++; temp = sysInfo.Rows[rowsCount]["RecordDate"].ToString(); } } else { if (temp == sysInfo.Rows[rowsCount]["RecordDate"].ToString()) { SignDetail = new SignDetail(); SignDetail.DetailTime = sysInfo.Rows[rowsCount]["RecordTime"].ToString(); SignDetail.Value = sysInfo.Rows[rowsCount]["Value"].ToString() + "/" + diaInfo.Rows[rowsCount]["Value"].ToString(); SignDetailByD.SignDetailList.Add(SignDetail); //SignDetailByD.Count++; result.SignDetailByDs.Add(SignDetailByD); } else { result.SignDetailByDs.Add(SignDetailByD); SignDetailByD = new SignDetailByD(); SignDetailByD.Date = sysInfo.Rows[rowsCount]["RecordDate"].ToString(); SignDetailByD.WeekDay = PsCompliance.CaculateWeekDay(sysInfo.Rows[rowsCount]["RecordDate"].ToString()); SignDetail = new SignDetail(); SignDetail.DetailTime = sysInfo.Rows[rowsCount]["RecordTime"].ToString(); SignDetail.Value = sysInfo.Rows[rowsCount]["Value"].ToString() + "/" + diaInfo.Rows[rowsCount]["Value"].ToString(); SignDetailByD.SignDetailList.Add(SignDetail); //SignDetailByD.Count++; result.SignDetailByDs.Add(SignDetailByD); temp = sysInfo.Rows[rowsCount]["RecordDate"].ToString(); } } } } } //return result; string a = JSONHelper.ObjectToJson(result); Context.Response.BinaryWrite(new byte[] { 0xEF, 0xBB, 0xBF }); Context.Response.Write(a); Context.Response.End(); } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "GetBPDetailByPeriod", "WebService调用异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); //return null; throw (ex); } }