Exemplo n.º 1
0
        public async Task <IActionResult> CreateReport([FromBody] CreateReportInput input)
        {
            //选择的床位Id
            var bedIds  = input.Ids.Split(',');
            var records = _machineDisinfectionApp.GetListByDate(input.StartDate, input.EndDate)
                          .Where(t => t.F_OperatePerson != null)
                          .Where(t => bedIds.Contains(t.F_Mid))
                          .Select(t => new
            {
                t.F_CheckPerson,
                t.F_DialylisBedNo,
                t.F_EndTime,
                t.F_GroupName,
                t.F_MachineName,
                t.F_MachineNo,
                t.F_Memo,
                t.F_Mid,
                t.F_OperatePerson,
                t.F_Option1,
                t.F_Option1Value,
                t.F_Option2,
                t.F_Option2Value,
                t.F_Option3,
                t.F_Option4,
                t.F_Option5,
                t.F_Option6,
                t.F_Option6Value,
                t.F_PGender,
                t.F_Pid,
                t.F_PName,
                t.F_ShowOrder,
                t.F_StartTime,
                t.F_Vid,
                t.F_VisitDate,
                t.F_VisitNo,
                t.F_WipeStartTime,
                t.F_WipeEndTime
            })
                          //.GroupBy(t => t.F_Mid)
                          .OrderBy(t => t.F_ShowOrder).ThenBy(t => t.F_VisitDate).ThenBy(t => t.F_VisitNo)
                          .ToList();
            var category = new MachineDisinfectionCategory
            {
                //StartDate = startDate,
                //EndDate = endDate
            };
            //var patVisitApp = new PatVisitApp();
            var users = _usersService.GetUserNameDict("").Select(t => new
            {
                t.F_Id,
                t.F_RealName
            }).ToList();

            foreach (var item in records)
            {
                var findrow = category.MachineInfos.FirstOrDefault(t => t.Mid == item.F_Mid);
                if (findrow == null)
                {
                    findrow = new MachineInfo
                    {
                        Mid           = item.F_Mid,
                        DialylisBedNo = item.F_DialylisBedNo,
                        GroupName     = item.F_GroupName,
                        MachineName   = item.F_MachineName,
                        MachineNo     = item.F_MachineNo,
                        StartDate     = input.StartDate.ToDateString(),
                        EndDate       = input.EndDate.ToDateString()
                    };
                    category.MachineInfos.Add(findrow);
                }

                var element = new DisinfectionInfo
                {
                    CheckPerson       = "",
                    DialysisEndTime   = "",
                    DialysisStartTime = "",
                    DisinfectType     = "",
                    Memo          = item.F_Memo,
                    OperatePerson = "",
                    PGender       = item.F_PGender,
                    PName         = item.F_PName,
                    SurfaceType   = item.F_Option6Value ?? "",
                    VisitDate     = item.F_VisitDate.ToDate().ToDateString(),
                    VisitNo       = item.F_VisitNo.ToInt().ToString(),
                    StartTime     = item.F_StartTime == null
                        ? ""
                        : item.F_StartTime.ToDate().ToDateTimeString(true).Substring(11),
                    EndTime =
                        item.F_EndTime == null ? "" : item.F_EndTime.ToDate().ToDateTimeString(true).Substring(11),
                    WipeEndTime = item.F_WipeEndTime == null
                        ? ""
                        : item.F_WipeEndTime.ToDate().ToDateTimeString(true).Substring(11),
                    WipeStartTime = item.F_WipeStartTime == null
                        ? ""
                        : item.F_WipeStartTime.ToDate().ToDateTimeString(true).Substring(11)
                };
                if (item.F_Option1 == true)
                {
                    element.DisinfectType = "热化学消毒(" + item.F_Option1Value + ")";
                }
                if (item.F_Option2 == true)
                {
                    element.DisinfectType = string.IsNullOrEmpty(element.DisinfectType) ? "化学消毒(" + item.F_Option2Value + ")" : element.DisinfectType + ";" + "化学消毒(" + item.F_Option2Value + ")";
                }
                if (item.F_Option3 == true)
                {
                    element.DisinfectType = string.IsNullOrEmpty(element.DisinfectType) ? "热消毒" : element.DisinfectType + ";" + "热消毒";
                }
                var visitRecord = await _patVisitApp.GetForm(item.F_Vid);

                if (visitRecord != null)
                {
                    element.DialysisStartTime = visitRecord.F_DialysisStartTime == null ? "" : visitRecord.F_DialysisStartTime.ToDate().ToDateTimeString(true).Substring(11);
                    element.DialysisEndTime   = visitRecord.F_DialysisEndTime == null ? "" : visitRecord.F_DialysisEndTime.ToDate().ToDateTimeString(true).Substring(11);
                }
                if (item.F_OperatePerson != null)
                {
                    var finduser = users.FirstOrDefault(t => t.F_Id == item.F_OperatePerson);
                    element.OperatePerson = finduser == null ? "" : finduser.F_RealName;
                }
                if (item.F_CheckPerson != null)
                {
                    var finduser = users.FirstOrDefault(t => t.F_Id == item.F_CheckPerson);
                    element.CheckPerson = finduser == null ? "" : finduser.F_RealName;
                }
                findrow.DisinfectionInfos.Add(element);
            }
            return(Content(_machineDisinfectionApp.GetImageReport(category.MachineInfos)));
        }
        public IActionResult GetList(GetListInput input)
        {
            var list = _patVisitApp.GetList(input.visitDate, input.visitNo).ToList();

            if (!string.IsNullOrEmpty(input.bedNo))
            {
                list = list.Where(t => t.F_DialysisBedNo.Equals(input.bedNo)).ToList();
            }
            var groups = (input.groupNames + "").Split(',');

            list = list.Where(t => groups.Contains(t.F_GroupName))
                   .Where(t => t.F_DialysisStartTime != null && t.F_DialysisEndTime != null)
                   .ToList();
            var target = _machineDisinfectionApp.GetListByDate(input.visitDate, input.visitDate)
                         .Select(t => new
            {
                t.F_Id,
                t.F_Vid,
                t.F_StartTime,
                t.F_EndTime,
                t.F_Option1,
                t.F_Option1Value,
                t.F_Option2,
                t.F_Option2Value,
                t.F_Option3,
                t.F_Option4,
                t.F_Option5,
                t.F_OperatePerson,
                t.F_WipeStartTime,
                t.F_WipeEndTime,
                t.F_Option6,
                t.F_Option6Value,
                t.F_CheckPerson
            });
            var output = new GetListOutput();
            //保存操作用户字典
            //Hashtable table = new Hashtable();
            var users = _usersService.GetUserNameDict("").Select(t => new
            {
                id   = t.F_Id,
                name = t.F_RealName
            }).ToList();

            foreach (var item in list)
            {
                DisinfectionInfo disinfection = new DisinfectionInfo
                {
                    vId               = item.F_Id,
                    groupName         = item.F_GroupName,
                    bedNo             = item.F_DialysisBedNo,
                    visitNo           = item.F_VisitNo.ToInt(),
                    patientName       = item.F_Name,
                    dialysisStartTime = item.F_DialysisStartTime,
                    dialysisEndTime   = item.F_DialysisEndTime
                };
                var find = target.FirstOrDefault(t => t.F_Vid.Equals(item.F_Id));
                if (find == null)
                {
                    disinfection.beDisinfected = false;
                }
                else
                {
                    if (string.IsNullOrEmpty(find.F_OperatePerson) || string.IsNullOrEmpty(find.F_CheckPerson))
                    {
                        disinfection.beDisinfected = false;
                    }
                    else
                    {
                        disinfection.beDisinfected = true;
                    }
                    disinfection.StartTime     = find.F_StartTime;
                    disinfection.EndTime       = find.F_EndTime;
                    disinfection.Option1       = find.F_Option1;
                    disinfection.Option1Value  = find.F_Option1Value;
                    disinfection.Option2       = find.F_Option2;
                    disinfection.Option2Value  = find.F_Option2Value;
                    disinfection.Option3       = find.F_Option3;
                    disinfection.Option4       = find.F_Option4;
                    disinfection.Option5       = find.F_Option5;
                    disinfection.Option6       = find.F_Option6;
                    disinfection.Option6Value  = find.F_Option6Value;
                    disinfection.WipeStartTime = find.F_WipeStartTime;
                    disinfection.WipeEndTime   = find.F_WipeEndTime;
                    disinfection.OperatePerson = find.F_OperatePerson == null ? "" : users.First(t => t.id.Equals(find.F_OperatePerson)).name;
                    disinfection.CheckPerson   = find.F_CheckPerson == null ? "" : users.First(t => t.id.Equals(find.F_CheckPerson)).name;
                }
                output.items.Add(disinfection);
            }
            output.bedNo      = input.bedNo;
            output.groupNames = input.groupNames;
            output.visitDate  = input.visitDate;
            output.visitNo    = input.visitNo;
            return(Ok(output));
        }