From 97c8230045db9f3511e36666f7760d5c750179fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Wed, 29 May 2024 21:16:38 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BE=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=82=D1=87?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20=D0=B2=20=D0=BF=D0=B4=D1=84=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/SuretorReportLogic.cs | 20 +++- ...dure.cs => AbstractSaveToPdfProcedures.cs} | 28 ++--- ...fProceduresByMedicamentsAndSymptomsInfo.cs | 12 ++- ...sByProcedure.cs => SaveToPdfProcedures.cs} | 2 +- .../ISuretorReportLogic.cs | 2 +- .../ViewModels/ReportProceduresViewModel.cs | 1 + .../Controllers/HomeController.cs | 54 ++++++++-- Polyclinic/PolyclinicWebAppSuretor/Program.cs | 1 + .../Views/Home/ProceduresReport.cshtml | 100 ++++++------------ 9 files changed, 121 insertions(+), 99 deletions(-) rename Polyclinic/PolyclinicBusinessLogic/OfficePackage/{AbstractSaveToPdfCoursesByProcedure.cs => AbstractSaveToPdfProcedures.cs} (71%) rename Polyclinic/PolyclinicBusinessLogic/OfficePackage/Implements/{SaveToPdfCoursesByProcedure.cs => SaveToPdfProcedures.cs} (97%) diff --git a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs index e35d8cb..5d831aa 100644 --- a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs +++ b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs @@ -1,5 +1,6 @@ using PolyclinicBusinessLogic.OfficePackage; using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel; +using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF; using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word; using PolyclinicContracts.BindingModels; using PolyclinicContracts.BusinessLogicsContracts; @@ -21,9 +22,11 @@ namespace PolyclinicBusinessLogic.BusinessLogics private readonly AbstractSaveToWordCoursesByProcedures saveToWord; private readonly AbstractSaveToExcelCoursesByProcedure saveToExcel; + private readonly AbstractSaveToPdfProcedures saveToPdf; public SuretorReportLogic(IProcedureStorage procedureStorage, IMedicamentStorage medicamentStorage, ICourseStorage courseStorage, ISymptomStorage symptomStorage, IRecipeStorage recipeStorage, - AbstractSaveToWordCoursesByProcedures saveToWord, AbstractSaveToExcelCoursesByProcedure saveToExcel) + AbstractSaveToWordCoursesByProcedures saveToWord, AbstractSaveToExcelCoursesByProcedure saveToExcel, + AbstractSaveToPdfProcedures saveToPdf) { this.procedureStorage = procedureStorage; this.medicamentStorage = medicamentStorage; @@ -32,6 +35,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics this.recipeStorage = recipeStorage; this.saveToWord = saveToWord; this.saveToExcel = saveToExcel; + this.saveToPdf = saveToPdf; } public List GetProcedureCourses(ProcedureSearchModel model) @@ -65,7 +69,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics return list; } - public List GetProceduresByMedicametsAndSymptoms(ReportBindingModel model) + public List GetProceduresByMedicametsAndSymptoms() { var procedures = procedureStorage.GetFullList(); var medicaments = medicamentStorage.GetFullList(); @@ -76,9 +80,10 @@ namespace PolyclinicBusinessLogic.BusinessLogics { var record = new ReportProceduresViewModel { + Id = procedure.Id, ProcedureName = procedure.Name, DateStartProcedure = procedure.DateStartProcedure, - DateStopProcedure = procedure.DateStopProcedure, + DateStopProcedure = procedure.DateStopProcedure ?? DateTime.MaxValue, MedicamentSymptom = new List<(string medicamentName, string symptomName)>() }; foreach (var medicament in medicaments) @@ -121,7 +126,14 @@ namespace PolyclinicBusinessLogic.BusinessLogics public void SaveProceduresToPdfFile(ReportBindingModel model) { - throw new NotImplementedException(); + saveToPdf.CreateDoc(new PdfProceduresByMedicamentsAndSymptomsInfo + { + FileName= model.FileName, + Title = "Отчет по процедурам с расшифровкой по симптомам и лекарствам", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo.Value, + Procedures = GetProceduresByMedicametsAndSymptoms() + }); } } } diff --git a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToPdfCoursesByProcedure.cs b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToPdfProcedures.cs similarity index 71% rename from Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToPdfCoursesByProcedure.cs rename to Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToPdfProcedures.cs index 6660d16..f0630f9 100644 --- a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToPdfCoursesByProcedure.cs +++ b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToPdfProcedures.cs @@ -3,7 +3,7 @@ using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF; namespace PolyclinicBusinessLogic.OfficePackage { - public abstract class AbstractSaveToPdfCoursesByProcedure + public abstract class AbstractSaveToPdfProcedures { public void CreateDoc(PdfProceduresByMedicamentsAndSymptomsInfo info) { @@ -23,25 +23,25 @@ namespace PolyclinicBusinessLogic.OfficePackage CreateTable(new List { "1cm", "3cm", "3cm", "4cm", "4cm", "4cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата начала процедуры", "Дата окончания процедуры", "Процедура", "Лекарство", "Симптом" }, + Texts = new List { "Номер", "Период 'с'", "Период 'до'", "Процедура", "Лекарство", "Симптом" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - foreach (var order in info.Orders) + foreach (var procedure in info.Procedures) { - CreateRow(new PdfRowParameters + foreach (var ms in procedure.MedicamentSymptom) { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.Status.ToString(), order.SushiName, order.Sum.ToString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left, - }); + CreateRow(new PdfRowParameters + { + Texts = new List { procedure.Id.ToString(), procedure.DateStartProcedure.ToShortTimeString(), + procedure.DateStopProcedure?.ToShortTimeString() ?? "нет даты окончания процедуры", + procedure.ProcedureName, ms.medicamentName, ms.symptomName}, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left, + }); + } + } - CreateParagraph(new PdfParagraph - { - Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Rigth - }); SavePdf(info); } /// diff --git a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/HelperModels/PDF/PdfProceduresByMedicamentsAndSymptomsInfo.cs b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/HelperModels/PDF/PdfProceduresByMedicamentsAndSymptomsInfo.cs index 1bfa644..5b1129b 100644 --- a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/HelperModels/PDF/PdfProceduresByMedicamentsAndSymptomsInfo.cs +++ b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/HelperModels/PDF/PdfProceduresByMedicamentsAndSymptomsInfo.cs @@ -8,8 +8,14 @@ namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF public string FileName { get; set; } = string.Empty; public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } - public List Procedures{ get; set; } = new(); - public List Medicaments { get; set; } = new(); - public List Symptoms { get; set; } = new(); + public List Procedures { get; set; } = new(); + + //public List Procedures{ get; set; } = new(); + + //public List MedicamentSymptom { get; set; } = new(); + + /*public List<(string medicamentName, string symptomName)> MedicamentSymptom { get; set; } = new();*/ + /* public List Medicaments { get; set; } = new(); + public List Symptoms { get; set; } = new();*/ } } diff --git a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/Implements/SaveToPdfCoursesByProcedure.cs b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/Implements/SaveToPdfProcedures.cs similarity index 97% rename from Polyclinic/PolyclinicBusinessLogic/OfficePackage/Implements/SaveToPdfCoursesByProcedure.cs rename to Polyclinic/PolyclinicBusinessLogic/OfficePackage/Implements/SaveToPdfProcedures.cs index 44ac638..dbd07ba 100644 --- a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/Implements/SaveToPdfCoursesByProcedure.cs +++ b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/Implements/SaveToPdfProcedures.cs @@ -6,7 +6,7 @@ using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF; namespace PolyclinicBusinessLogic.OfficePackage.Implements { - public class SaveToPdfCoursesByProcedure : AbstractSaveToPdfCoursesByProcedure + public class SaveToPdfProcedures : AbstractSaveToPdfProcedures { private Document? _document; private Section? _section; diff --git a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs index e30630f..b7daa2e 100644 --- a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs +++ b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs @@ -22,7 +22,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts /// /// /// - List GetProceduresByMedicametsAndSymptoms(ReportBindingModel model); + List GetProceduresByMedicametsAndSymptoms(); /// /// Сохранение курсов по процедурам в файл-Word diff --git a/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs index babd3cc..0c92427 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs @@ -2,6 +2,7 @@ { public class ReportProceduresViewModel { + public int Id { get; set; } public string ProcedureName { get; set; } = string.Empty; public DateTime DateStartProcedure { get; set; } public DateTime? DateStopProcedure { get; set;} diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index aba598d..af24ea7 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -372,7 +372,7 @@ namespace PolyclinicWebAppSuretor.Controllers { _suretorReportLogic.SaveCoursesByProcedureToWordFile(report, procedureSearch); } - else if(fileFormat == "xlsx") + else if (fileFormat == "xlsx") { _suretorReportLogic.SaveCoursesByProcedureToExcelFile(report, procedureSearch); } @@ -383,21 +383,61 @@ namespace PolyclinicWebAppSuretor.Controllers return File(fileBytes, mimeType, fileName); } + /// + // PROCEDURESREPORT + /// + /// + [HttpGet] - [HttpPost] - public IActionResult ProceduresReport() + /*public IActionResult ProceduresReport() { - if (HttpContext.Request.Method == "POST") + return View(new List()); + }*/ + + [HttpPost] + public IActionResult ProceduresReport(DateTime? dateFrom, DateTime? dateTo, string reportType) + { + if (reportType == "form") { - ViewData["ShowReport"] = true; - return View(); + var proceduresReport = _suretorReportLogic.GetProceduresByMedicametsAndSymptoms(); + + // ( ) + if (dateFrom.HasValue) + { + proceduresReport = proceduresReport.Where(p => p.DateStartProcedure >= dateFrom.Value).ToList(); + } + if (dateTo.HasValue) + { + proceduresReport = proceduresReport.Where(p => p.DateStopProcedure <= dateTo.Value).ToList(); + } + + return View(proceduresReport); + } + else if (reportType == "email") + { + var reportBindingModel = new ReportBindingModel + { + FileName = "ProceduresReport.pdf", + DateFrom = dateFrom, + DateTo = dateTo + }; + + _suretorReportLogic.SaveProceduresToPdfFile(reportBindingModel); + + // + var fileBytes = System.IO.File.ReadAllBytes(reportBindingModel.FileName); + var fileName = "ProceduresReport.pdf"; + + // + return File(fileBytes, "application/pdf", fileName); } else { - return View(); + return View(new List()); } } + [HttpGet] [HttpPost] public IActionResult Login() diff --git a/Polyclinic/PolyclinicWebAppSuretor/Program.cs b/Polyclinic/PolyclinicWebAppSuretor/Program.cs index 41ffe86..bedfa0a 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Program.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Program.cs @@ -23,6 +23,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/ProceduresReport.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/ProceduresReport.cshtml index edf4ce9..eef3798 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/ProceduresReport.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/ProceduresReport.cshtml @@ -1,19 +1,17 @@ @using PolyclinicContracts.ViewModels +@model List @{ ViewData["Title"] = "ProceduresReport"; } +
- +
- +
@@ -28,77 +26,41 @@
- + - @if (ViewData.ContainsKey("ShowReport")) + + @if (Model != null && Model.Any()) { - + - - - - - - + + + + + + - @{ - for (int i = 0; i < 5; i++) - { - - - - - - - - - - - - - - - - - - - - - - - - - } + @foreach (var item in Model) + { + + + + + + @foreach (var ms in item.MedicamentSymptom) + { + + + } + + @* + *@ + + }
Отчет по лекарствам с 01.01.2023 по 31.12.2023Отчет по процедурам
- # - - Процедура - - Дата начала - - Дата завершения - - Лекарства - - Симптомы - НомерПроцедураДата началаДата завершенияЛекарствоСимптом
- @(i + 1) - - Процедура мытья спины - - 16.03.2023 - - 20.10.2023 - - Амоксициллин® - - Лихорадка -
Активированный уголь®Покрасения
Аскорбиновая кислота®Головокружение
@item.Id@item.ProcedureName@item.DateStartProcedure.ToShortDateString()@item.DateStopProcedure?.ToShortDateString()@ms.medicamentName@ms.symptomName@string.Join("
", item.MedicamentSymptom.Select(ms => ms.medicamentName))
@string.Join("
", item.MedicamentSymptom.Select(ms => ms.symptomName))