Exemple #1
0
        public async Task <string> HistoryPlanningReportExcelExport(HistoryPlanningInputModel input)
        {
            AppSettings.SetSiteLanguage(input.LangId);

            var parentDirectory = Directory.GetParent(Environment.CurrentDirectory).FullName;
            var fileName        = string.Format("History_Plannings_{0}.xlsx", Guid.NewGuid().ToString());

            FileStream fs           = new FileStream(Path.Combine(parentDirectory, "Surgicalogic.Web", "static", fileName), FileMode.CreateNew);
            var        excelService = new ExcelDocumentService();

            var items = await _operationPlanHistoryStoreService.GetExportAsync <HistoryPlanningReportExportModel>(input);

            await excelService.WriteAsync(fs, "Worksheet", items, typeof(HistoryPlanningReportExportModel), System.Globalization.CultureInfo.CurrentCulture);

            return(fileName);
        }
        public async Task <ResultModel <OperationPlanHistoryOutputModel> > GetAsync <TOutputModel>(HistoryPlanningInputModel input)
        {
            var query = _context.OperationPlans.Where(x => x.IsActive);

            var operatingRoomIds = input.OperatingRoomId?.Split(',').Select(int.Parse).ToList();
            var operationIds     = input.OperationId?.Split(',').Select(int.Parse).ToList();

            if (!string.IsNullOrEmpty(input.SortBy))
            {
                Expression <Func <OperationPlan, object> > orderBy = null;

                switch (input.SortBy)
                {
                case "operationName":
                    orderBy = x => x.Operation.Name;
                    break;

                case "operationRoomName":
                    orderBy = x => x.OperatingRoom.Name;
                    break;

                case "operationDate":
                    orderBy = x => x.OperationDate;
                    break;

                case "identityNumber":
                    orderBy = x => x.Operation.Patient.IdentityNumber;
                    break;

                default:
                    orderBy = x => x.Id;
                    break;
                }

                if (input.Descending == true)
                {
                    query = query.OrderByDescending(orderBy);
                }

                else
                {
                    query = query.OrderBy(orderBy);
                }
            }

            if (operatingRoomIds?.Count > 0)
            {
                query = query.Where(x => operatingRoomIds.Contains(x.OperatingRoomId));
            }

            if (operationIds?.Count > 0)
            {
                query = query.Where(x => operationIds.Contains(x.OperationId));
            }

            if (input.OperationStartDate != null && input.OperationStartDate != DateTime.MinValue)
            {
                query = query.Where(x => x.OperationDate >= input.OperationStartDate);
            }

            if (input.OperationEndDate != null && input.OperationEndDate != DateTime.MinValue)
            {
                query = query.Where(x => x.OperationDate <= input.OperationEndDate.AddDays(1));
            }

            if (!string.IsNullOrEmpty(input.IdentityNumber))
            {
                query = query.Where(x => x.Operation.Patient.IdentityNumber == input.IdentityNumber);
            }

            if (!string.IsNullOrEmpty(input.Search))
            {
                query = query.Where(x =>
                                    x.Operation.Name.IndexOf(input.Search, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                                    x.OperatingRoom.Name.IndexOf(input.Search, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                                    x.Operation.Patient.IdentityNumber.IndexOf(input.Search, StringComparison.CurrentCultureIgnoreCase) >= 0
                                    );
            }

            int totalCount = await query.CountAsync();

            if (input.PageSize > 0)
            {
                query = query.Skip((input.CurrentPage - 1) * input.PageSize).Take(input.PageSize);
            }

            var result = await query.ProjectTo <OperationPlanHistoryModel>().ToListAsync();

            return(new ResultModel <OperationPlanHistoryOutputModel>
            {
                Result = AutoMapper.Mapper.Map <List <OperationPlanHistoryOutputModel> >(result),
                TotalCount = totalCount,
                Info = new Info {
                    Succeeded = true
                }
            });

            //return base.GetAsync<TOutputModel>(input, expression);
        }
        public async Task <List <HistoryPlanningReportExportModel> > GetExportAsync <OperationPlanHistoryOutputModel>(HistoryPlanningInputModel input)
        {
            var query = _context.OperationPlans.Where(x => x.IsActive);

            var operatingRoomIds = input.OperatingRoomId?.Split(',').Select(int.Parse).ToList();
            var operationIds     = input.OperationId?.Split(',').Select(int.Parse).ToList();


            if (operatingRoomIds?.Count > 0)
            {
                query = query.Where(x => operatingRoomIds.Contains(x.OperatingRoomId));
            }

            if (operationIds?.Count > 0)
            {
                query = query.Where(x => operationIds.Contains(x.OperationId));
            }

            if (input.OperationStartDate != null && input.OperationStartDate != DateTime.MinValue)
            {
                query = query.Where(x => x.OperationDate >= input.OperationStartDate);
            }

            if (input.OperationEndDate != null && input.OperationEndDate != DateTime.MinValue)
            {
                query = query.Where(x => x.OperationDate <= input.OperationEndDate.AddDays(1));
            }

            if (!string.IsNullOrEmpty(input.IdentityNumber))
            {
                query = query.Where(x => x.Operation.Patient.IdentityNumber == input.IdentityNumber);
            }

            if (!string.IsNullOrEmpty(input.Search))
            {
                query = query.Where(x =>
                                    x.Operation.Name.IndexOf(input.Search, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                                    x.OperatingRoom.Name.IndexOf(input.Search, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                                    x.Operation.Patient.IdentityNumber.IndexOf(input.Search, StringComparison.CurrentCultureIgnoreCase) >= 0
                                    );
            }

            return(await query.ProjectTo <HistoryPlanningReportExportModel>().ToListAsync());
        }
Exemple #4
0
 public async Task <ResultModel <OperationPlanHistoryOutputModel> > GetOperationPlanHistory(HistoryPlanningInputModel input)
 {
     return(await _operationPlanHistoryStoreService.GetAsync <OperationPlanHistoryOutputModel>(input));
 }