public async Task <IActionResult> GetScheduleJson(DateTime visitDate, int visitNo)
        {
            var list = await _dialysisScheduleApp.GetScheduleList(visitDate, visitNo);

            var data = list.Select(t => new
            {
                t.F_Id,
                t.F_Name,
                t.F_DialysisNo,
                t.F_DialysisType,
                t.F_GroupName,
                t.F_DialysisBedNo,
                t.F_BId
            })
                       .Join(_machineApp.GetQueryable().Select(t => new { t.F_Id, t.F_ShowOrder }),
                             a => a.F_BId,
                             b => b.F_Id,
                             (a, b) => new
            {
                a.F_Id,
                a.F_Name,
                a.F_DialysisNo,
                a.F_DialysisType,
                a.F_GroupName,
                a.F_DialysisBedNo,
                ShowOrder = b.F_ShowOrder.HasValue ? b.F_ShowOrder.ToInt() : 99
            })
                       .OrderBy(r => r.F_GroupName).ThenBy(r => r.ShowOrder)
            ;

            return(Content(data.ToJson()));
        }
        public IActionResult GetGroupListJson(string enCode)
        {
            var data = _dialysisMachineApp.GetQueryable().Select(t => new
            {
                t.F_Id,
                t.F_DefaultType,
                t.F_DialylisBedNo,
                t.F_GroupName,
                t.F_MachineName,
                t.F_MachineNo,
                t.F_ShowOrder
            }).GroupBy(t => t.F_GroupName);

            return(Content(data.ToJson()));
        }
Пример #3
0
        /// <summary>
        /// 根据治疗单 生成数据
        /// </summary>
        /// <param name="visitDate"></param>
        /// <param name="visitNo"></param>
        private void CreateData(DateTime visitDate, int visitNo)
        {
            //QualityResultApp resultApp = new QualityResultApp();
            var listSourse = _patVisitApp.GetList().Where(t => t.F_VisitDate == visitDate && (visitNo == 0 || t.F_VisitNo == visitNo) && t.F_DialysisStartTime != null && t.F_DialysisEndTime != null);
            var listTarget = GetList(visitDate, visitNo);
            //查询不包含的数据
            var c = (from r in listSourse
                     where !listTarget.Any(t => t.F_Vid == r.F_Id)
                     select r).ToList();

            //没有 返回
            if (c.Count == 0)
            {
                return;
            }
            //患者列表
            var patientList = from r in _patientApp.GetQueryable()
                              where c.Any(t => t.F_Pid == r.F_Id)
                              select new
            {
                r.F_Id,
                r.F_Name,
                r.F_Gender,
                r.F_DialysisNo
            };

            var bedList = from b in _dialysisMachineApp.GetQueryable()
                          select new
            {
                b.F_Id,
                b.F_GroupName,
                b.F_DialylisBedNo,
                b.F_MachineName,
                b.F_MachineNo,
                b.F_ShowOrder
            };
            //生成记录
            var addEntityList = new List <MachineProcessEntity>();

            foreach (var item in c)
            {
                var entity = new MachineProcessEntity
                {
                    F_Pid       = item.F_Pid,
                    F_Vid       = item.F_Id,
                    F_VisitDate = item.F_VisitDate,
                    F_VisitNo   = item.F_VisitNo,
                    F_Option1   = false,
                    F_Option2   = false,
                    F_Option3   = false,
                    F_Option4   = false,
                    //F_Option5 = false,
                    F_GroupName     = item.F_GroupName,
                    F_DialylisBedNo = item.F_DialysisBedNo
                };
                var p = patientList.FirstOrDefault(t => t.F_Id == item.F_Pid);
                if (p != null)
                {
                    entity.F_PName      = p.F_Name;
                    entity.F_PGender    = p.F_Gender;
                    entity.F_DialylisNo = p.F_DialysisNo;
                }
                else
                {
                    continue;
                }
                var b = bedList.FirstOrDefault(t => t.F_GroupName == item.F_GroupName && t.F_DialylisBedNo == item.F_DialysisBedNo);
                if (b != null)
                {
                    entity.F_MachineName = b.F_MachineName;
                    entity.F_MachineNo   = b.F_MachineNo;
                    entity.F_ShowOrder   = b.F_ShowOrder;
                    entity.F_Mid         = b.F_Id;
                }
                else
                {
                    continue;
                }
                entity.Create();
                entity.F_EnabledMark = true;
                addEntityList.Add(entity);
            }
            if (addEntityList.Count > 0)
            {
                //保存记录
                _service.Insert(addEntityList);
            }
            //更新记录
        }
        public async Task <IActionResult> GetTvShowList()
        {
            var visitRecords = _patVisitApp.GetList()
                               .Where(t => t.F_VisitDate == DateTime.Today && t.F_EnabledMark != false && t.F_DeleteMark != true);
            var list = from v in visitRecords
                       join d in await _drugsApp.GetList() on v.F_HeparinType equals d.F_Id into temp
                       from dt in temp.DefaultIfEmpty()
                       join b in _dialysisMachineApp.GetQueryable() on new
            { GroupName = v.F_GroupName, BedNo = v.F_DialysisBedNo } equals new
            { GroupName = b.F_GroupName, BedNo = b.F_DialylisBedNo } into btemp
            from bt in btemp.DefaultIfEmpty()
            select new
            {
                Id             = v.F_Id,
                VisitDate      = v.F_VisitDate,
                VisitNo        = v.F_VisitNo,
                DialysisType   = v.F_DialysisType,
                PId            = v.F_Pid,
                Name           = v.F_Name,
                StartTime      = v.F_DialysisStartTime,
                EndTime        = v.F_DialysisEndTime,
                Status         = v.F_DialysisStartTime == null ? 1 : v.F_DialysisEndTime == null ? 2 : 3,
                GroupName      = v.F_GroupName,
                BedNo          = v.F_DialysisBedNo,
                ShowNo         = bt == null ? 99 : bt.F_ShowOrder,
                VascularAccess = v.F_VascularAccess,
                AccessName     = v.F_AccessName,
                EstimateHours  = v.F_EstimateHours ?? 4,
                WeightYT       = v.F_WeightYT,
                Heparin        = new
                {
                    Id     = v.F_HeparinType,
                    Name   = dt == null ? "" : dt.F_DrugName,
                    Amount = v.F_HeparinAmount,
                    Unit   = v.F_HeparinUnit
                }
            };
            var data = list.GroupJoin(_dialysisObservationApp.GetList().Where(o => o.F_DeleteMark != true),
                                      l => new { pid = l.PId, visitDate = l.VisitDate },
                                      o => new { pid = o.F_Pid, visitDate = o.F_VisitDate }, (l, o) => new
            {
                Record      = l,
                Observation = o.Select(r => new
                {
                    Id           = r.F_Id,
                    OperatorTime = r.F_NurseOperatorTime,
                    NurseName    = r.F_NurseName,
                    Ssy          = r.F_SSY,
                    Szy          = r.F_SZY,
                    Hr           = r.F_HR,
                    A            = r.F_A,
                    Bf           = r.F_BF,
                    Ufr          = r.F_UFR,
                    V            = r.F_V,
                    C            = r.F_C,
                    T            = r.F_T,
                    Ufv          = r.F_UFV,
                    Tmp          = r.F_TMP,
                    Gsl          = r.F_GSL,
                    Memo         = r.F_MEMO
                })
                              .OrderByDescending(r => r.OperatorTime)
            })
                       .OrderBy(n => n.Record.VisitNo).ThenBy(n => n.Record.GroupName).ThenBy(n => n.Record.ShowNo)
            ;

            return(Ok(data
                      //    .ToList().GroupBy(t => t.Record.VisitNo, (key, rows) => new
                      //{
                      //    VisitNo = key,
                      //    Items = rows.Select(r => new
                      //    {
                      //        r.Record.Id,
                      //        r.Record.VisitDate,
                      //        r.Record.Name,
                      //        r.Record.StartTime,
                      //        r.Record.EndTime,
                      //        Status = r.Record.StartTime == null ? 1 : r.Record.EndTime == null ? 2 : 3,
                      //        r.Record.GroupName,
                      //        r.Record.BedNo,
                      //        r.Record.ShowNo,
                      //        r.Record.VascularAccess,
                      //        r.Record.AccessName,
                      //        EstimateHours = r.Record.EstimateHours ?? 4,
                      //        r.Record.Heparin,
                      //        Observation = r.Observation.OrderByDescending(o => o.OperatorTime)
                      //    }).OrderBy(i => i.GroupName).ThenBy(i => i.ShowNo)
                      //}).OrderBy(n => n.VisitNo)
                      ));
        }
Пример #5
0
        public IActionResult GetRecordSummary()
        {
            //总数
            var bedCount = _machineApp.GetQueryable().Count();

            //今日记录
            var records = _patVisitApp.GetList().Where(t => t.F_VisitDate == DateTime.Today && t.F_EnabledMark == true && t.F_DeleteMark != true);//.FindAll(t => t.F_DialysisStartTime != null && t.F_DialysisEndTime == null)

            //透析中数量
            var usingCount = records.Count(t => t.F_DialysisStartTime != null && t.F_DialysisEndTime == null);

            //已透析数量
            var finishCount = records.Count(t => t.F_DialysisEndTime != null);

            var todoCount = records.Count(t => t.F_DialysisStartTime == null);

            var leftBedCount = bedCount - usingCount;

            leftBedCount = leftBedCount < 0 ? 0 : leftBedCount;

            //本月透析人数
            var monthStartDay = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date;
            var monthCount    = (from r in _patVisitApp.GetList()
                                 where r.F_VisitDate >= monthStartDay && r.F_DialysisEndTime != null
                                 select r.F_Id).Count();

            //统计最近15天的数据
            var startDate      = DateTime.Now.AddDays(-14).Date;
            var endDate        = DateTime.Now.Date;
            var _15daysRecords = (from r in _patVisitApp.GetList()
                                  where r.F_VisitDate >= startDate && r.F_VisitDate <= endDate && r.F_DialysisEndTime != null
                                  orderby r.F_VisitDate
                                  select new
            {
                date = r.F_VisitDate.ToDateString().Substring(5),
                mode = r.F_DialysisType
            }).ToList();
            var lineX   = new List <string>();
            var lineY   = new List <int>();
            var circleX = new List <string>();
            var circleY = new List <int>();

            foreach (var item in _15daysRecords)
            {
                if (lineX.IndexOf(item.date) < 0)
                {
                    lineX.Add(item.date);
                    lineY.Add(_15daysRecords.Count(t => t.date.Equals(item.date)));
                }

                if (circleX.IndexOf(item.mode) < 0)
                {
                    circleX.Add(item.mode);
                    circleY.Add(_15daysRecords.Count(t => t.mode.Equals(item.mode)));
                }
            }

            var data = new
            {
                todoCount,
                finishCount,
                usingCount,
                leftBedCount,
                bedCount,
                monthCount,
                line = new
                {
                    lineX,
                    lineY
                },
                circle = new
                {
                    circleX,
                    circleY
                }
            };

            return(Content(data.ToJson()));
        }
        public IActionResult GetWeeklyList(GetWeeklyListInput input = null)
        {
            if (input == null)
            {
                input = new GetWeeklyListInput();
            }
            var startDate = input.scheduleDate.ToDate().Date;

            startDate = startDate.DayOfWeek == DayOfWeek.Monday ? startDate
                : startDate.DayOfWeek == DayOfWeek.Tuesday ? startDate.AddDays(-1)
                : startDate.DayOfWeek == DayOfWeek.Wednesday ? startDate.AddDays(-2)
                : startDate.DayOfWeek == DayOfWeek.Thursday ? startDate.AddDays(-3)
                : startDate.DayOfWeek == DayOfWeek.Friday ? startDate.AddDays(-4)
                : startDate.DayOfWeek == DayOfWeek.Saturday ? startDate.AddDays(-5)
                : startDate.DayOfWeek == DayOfWeek.Sunday ? startDate.AddDays(-6)
                : startDate;
            var endDate = startDate.AddDays(6);
            var visitNo = input.visitNo.ToInt();

            var beds = _dialysisMachineApp.GetQueryable().Select(t => new
            {
                groupName   = t.F_GroupName,
                bedId       = t.F_Id,
                bedNo       = t.F_DialylisBedNo,
                showOrder   = t.F_ShowOrder,
                machineName = t.F_MachineName,
                machineNo   = t.F_MachineNo,
                defaultType = t.F_DefaultType
            }).ToList();

            var query = _dialysisScheduleApp.GetList()
                        .Where(t => t.F_VisitDate >= startDate && t.F_VisitDate <= endDate)
                        .Where(t => t.F_VisitNo == visitNo);

            if (!string.IsNullOrEmpty(input.dialysisTypes))
            {
                var typesArr = input.dialysisTypes.Split(',');
                query = query.Where(t => typesArr.Contains(t.F_DialysisType));
            }
            if (!string.IsNullOrEmpty(input.patientId))
            {
                query = query.Where(t => t.F_PId.Equals(input.patientId));
            }
            var sourse = query.Select(t => new
            {
                scheduleId   = t.F_Id,
                visitDate    = t.F_VisitDate,
                pid          = t.F_PId,
                patientName  = t.F_Name,
                dialysisType = t.F_DialysisType,
                bid          = t.F_BId
            }).ToList();
            var list = sourse.Select(t => new
            {
                bedId = t.bid,
                t.scheduleId,
                t.visitDate,
                dayOfWeek = t.visitDate.ToDate().DayOfWeek,
                patientId = t.pid,
                t.patientName,
                t.dialysisType
            });

            var data = beds.GroupBy(t => t.groupName).Select(t => new
            {
                groupName = t.Key,
                rows      = t.GroupJoin(list, a => a.bedId, b => b.bedId, (a, b) => new
                {
                    a.bedId,
                    a.bedNo,
                    a.showOrder,
                    a.machineName,
                    a.machineNo,
                    a.defaultType,
                    items = b.OrderBy(v => v.visitDate)
                }).OrderBy(s => s.showOrder)
            }).OrderBy(g => g.groupName);

            return(Ok(data));
        }