Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }