2024-05-30 00:08:44 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-05-30 01:46:40 +04:00
|
|
|
|
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using PolyclinicContracts.BindingModels;
|
2024-05-30 00:08:44 +04:00
|
|
|
|
using PolyclinicContracts.BusinessLogicsContracts;
|
|
|
|
|
using PolyclinicContracts.ViewModels;
|
|
|
|
|
using PolyclinicWebAppImplementer.Models;
|
|
|
|
|
|
|
|
|
|
namespace PolyclinicWebAppImplementer.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class ReportsController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly IImplementerReportLogic _reportLogic;
|
|
|
|
|
private readonly IDiagnoseLogic _diagnoseLogic;
|
|
|
|
|
|
|
|
|
|
public ReportsController(IImplementerReportLogic reportLogic, IDiagnoseLogic diagnoseLogic)
|
|
|
|
|
{
|
|
|
|
|
_reportLogic = reportLogic;
|
|
|
|
|
_diagnoseLogic = diagnoseLogic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult DiagnosesByPeriod(DiagnosesByPeriodFormModel model)
|
|
|
|
|
{
|
|
|
|
|
var currentUser = LoginManager.LogginedUser;
|
|
|
|
|
if (currentUser == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Login", "User");
|
|
|
|
|
}
|
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
|
|
|
|
{
|
|
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-05-30 01:46:40 +04:00
|
|
|
|
var report = _reportLogic.GetReportDiagnosesByPeriod(model.DateStart, model.DateEnd);
|
|
|
|
|
if (model.ReportType == ReportType.Web)
|
|
|
|
|
{
|
|
|
|
|
model.Report = report;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReportBindingModel reportInfo = new()
|
|
|
|
|
{
|
|
|
|
|
FileName = "diagnosesByPeriod.pdf",
|
|
|
|
|
DateFrom = model.DateStart,
|
|
|
|
|
DateTo = model.DateEnd
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_reportLogic.SaveReportDiagnosesByPeriodToPdfFile(reportInfo, report);
|
|
|
|
|
|
|
|
|
|
var fileName = reportInfo.FileName;
|
|
|
|
|
var filePath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
|
|
|
|
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
|
|
|
|
|
|
|
|
|
return File(fileBytes, "application/pdf", fileName);
|
|
|
|
|
}
|
2024-05-30 00:08:44 +04:00
|
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult MedicamentsByDiagnoses(MedicamentsByDiagnosesFormModel model)
|
|
|
|
|
{
|
|
|
|
|
var currentUser = LoginManager.LogginedUser;
|
|
|
|
|
if (currentUser == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Login", "User");
|
|
|
|
|
}
|
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
|
|
|
|
{
|
|
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|