private FileContentResult GenerateSpecialReport(SpecialReportFilter specialReportFilter)
        {
            dynamic data;

            if (specialReportFilter.ReportType == 1)
            {
                data = _specialReportService.GetSpecialSummaryReport(specialReportFilter);
            }
            else
            {
                data = _specialReportService.GetSpecialDetailedReport(specialReportFilter);
            }
            var rootPath  = Path.Combine(_hostingEnvironment.WebRootPath, "Temp");
            var excelFile = _excelReportService.GenerateExcelReport(rootPath, data.Result);
            var response  = new HttpResponseMessage(HttpStatusCode.OK);
            var bytes     = System.IO.File.ReadAllBytes(excelFile);
            var fileName  = Path.GetFileNameWithoutExtension(excelFile);

            response.Content = new ByteArrayContent(bytes);

            response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            response.Content.Headers.ContentDisposition.FileName = fileName + ".xlsx";

            return(File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName + ".xlsx"));
        }
Esempio n. 2
0
        public IEnumerable <SpecialDetailedReport> GetSpecialDetailedReport(SpecialReportFilter specialReportFilter)
        {
            var detailedReportQuery = SpecialReportQuerys.GetDetailedReport;

            if (!string.IsNullOrEmpty(specialReportFilter.InitialDateIni))
            {
                detailedReportQuery += " AND Ags.[InitialDate] > CONVERT(DATE, @InitialDateIni, 105) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.InitialDateEnd))
            {
                detailedReportQuery += " AND Ags.[InitialDate] < CONVERT(DATE, @InitialDateEnd, 105) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.VisitDateIni))
            {
                detailedReportQuery += " AND Asd.StateId = 2 AND Asd.[DateVisit] > CONVERT(DATE, @VisitDateIni, 105) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.VisitDateEnd))
            {
                detailedReportQuery += " AND Asd.[DateVisit] < CONVERT(DATE, @VisitDateEnd, 105) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.RequestDateIni))
            {
                detailedReportQuery += " AND Asd.[RecordDate] > CONVERT(DATE, @RequestDateIni, 105) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.RequestDateEnd))
            {
                detailedReportQuery += " AND Asd.[RecordDate] < CONVERT(DATE, @RequestDateEnd,105) ";
            }
            if (specialReportFilter.EntityId > 0)
            {
                detailedReportQuery += "AND Ags.[EntityId] = @EntityId ";
            }
            if (specialReportFilter.PatientType > 0)
            {
                detailedReportQuery += "AND pt.[Id] = @PatientType ";
            }
            if (specialReportFilter.ServiceId > 0)
            {
                detailedReportQuery += "AND Ags.[ServiceId] = @ServiceId ";
            }

            detailedReportQuery += " ORDER BY Asd.AssignServiceDetailId DESC ";

            var detailedReport = _dbConnection.Query <SpecialDetailedReport>(detailedReportQuery, specialReportFilter).ToList();

            foreach (var row in detailedReport)
            {
                row.QualityQuestions = _dbConnection.Query <QualityQuestion>(SpecialReportQuerys.GetQualityQuestions,
                                                                             new
                {
                    row.AssignServiceDetailId
                });
            }
            return(detailedReport.OrderByDescending(x => x.QualityQuestions.Count()));;
        }
Esempio n. 3
0
        public IEnumerable <SpecialSummaryReport> GetSpecialSummaryReport(SpecialReportFilter specialReportFilter)
        {
            var summaryReport = SpecialReportQuerys.GetSummaryReport;

            if (!string.IsNullOrEmpty(specialReportFilter.InitialDateIni))
            {
                summaryReport += " AND Ags.[InitialDate] >= CONVERT(DATE, @InitialDateIni, 105) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.InitialDateEnd))
            {
                summaryReport += " AND Ags.[InitialDate] <= CONVERT(DATE, @InitialDateEnd, 105) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.VisitDateIni))
            {
                summaryReport += " AND Ags.StateId = 2 AND EXISTS(SELECT 1 FROM[sas].[AssignServiceDetails] WHERE DateVisit >= CONVERT(DATE, @VisitDateIni, 105)) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.VisitDateEnd))
            {
                summaryReport += " AND EXISTS(SELECT 1 FROM[sas].[AssignServiceDetails] WHERE DateVisit <= CONVERT(DATE, @VisitDateEnd,105)) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.RequestDateIni))
            {
                summaryReport += " AND EXISTS(SELECT 1 FROM[sas].[AssignServiceDetails] WHERE RecordDate >= CONVERT(DATE, @RequestDateIni, 105)) ";
            }
            if (!string.IsNullOrEmpty(specialReportFilter.RequestDateEnd))
            {
                summaryReport += " AND EXISTS(SELECT 1 FROM[sas].[AssignServiceDetails] WHERE RecordDate <= CONVERT(DATE, @RequestDateEnd,105)) ";
            }
            if (specialReportFilter.EntityId > 0)
            {
                summaryReport += "AND Ags.[EntityId] = @EntityId ";
            }
            if (specialReportFilter.PatientType > 0)
            {
                summaryReport += "AND pt.[Id] = @PatientType ";
            }
            if (specialReportFilter.ServiceId > 0)
            {
                summaryReport += "AND Ags.[ServiceId] = @ServiceId ";
            }
            var specialReport = _dbConnection.Query <SpecialSummaryReport>(summaryReport, specialReportFilter).ToList();

            foreach (var specialSummaryReport in specialReport)
            {
                specialSummaryReport.AssignedProfessionals = _dbConnection.Query <AssignedProfessional>(SpecialReportQuerys.GetAssignedProfessionals, new
                {
                    specialSummaryReport.AssignServiceId
                });
            }
            return(specialReport.OrderByDescending(x => x.AssignedProfessionals.Count()));
        }
Esempio n. 4
0
        public ServiceResult <IEnumerable <SpecialDetailedReport> > GetSpecialDetailedReport(SpecialReportFilter specialReportFilter)
        {
            var result = _specialReportRepository.GetSpecialDetailedReport(specialReportFilter);

            return(new ServiceResult <IEnumerable <SpecialDetailedReport> >
            {
                Result = result,
                Errors = new[] { string.Empty },
                Success = true
            });
        }
 public FileContentResult Post([FromBody] SpecialReportFilter specialReportFilter)
 {
     //return Json(specialReportFilter);
     return(GenerateSpecialReport(specialReportFilter));
 }