вроде работает отображение отчета в пдф на форме
This commit is contained in:
parent
1c68c684c6
commit
97c8230045
@ -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<CourseViewModel> GetProcedureCourses(ProcedureSearchModel model)
|
||||
@ -65,7 +69,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportProceduresViewModel> GetProceduresByMedicametsAndSymptoms(ReportBindingModel model)
|
||||
public List<ReportProceduresViewModel> 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()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<string> { "1cm", "3cm", "3cm", "4cm", "4cm", "4cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата начала процедуры", "Дата окончания процедуры", "Процедура", "Лекарство", "Симптом" },
|
||||
Texts = new List<string> { "Номер", "Период 'с'", "Период 'до'", "Процедура", "Лекарство", "Симптом" },
|
||||
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<string> { 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<string> { 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);
|
||||
}
|
||||
/// <summary>
|
@ -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<ReportProceduresViewModel> Procedures{ get; set; } = new();
|
||||
public List<MedicamentViewModel> Medicaments { get; set; } = new();
|
||||
public List<SymptomViewModel> Symptoms { get; set; } = new();
|
||||
public List<ReportProceduresViewModel> Procedures { get; set; } = new();
|
||||
|
||||
//public List<ReportProceduresViewModel> Procedures{ get; set; } = new();
|
||||
|
||||
//public List<ReportProceduresViewModel> MedicamentSymptom { get; set; } = new();
|
||||
|
||||
/*public List<(string medicamentName, string symptomName)> MedicamentSymptom { get; set; } = new();*/
|
||||
/* public List<MedicamentViewModel> Medicaments { get; set; } = new();
|
||||
public List<SymptomViewModel> Symptoms { get; set; } = new();*/
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -22,7 +22,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
List<ReportProceduresViewModel> GetProceduresByMedicametsAndSymptoms(ReportBindingModel model);
|
||||
List<ReportProceduresViewModel> GetProceduresByMedicametsAndSymptoms();
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение курсов по процедурам в файл-Word
|
||||
|
@ -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;}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
// PROCEDURESREPORT
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet]
|
||||
[HttpPost]
|
||||
public IActionResult ProceduresReport()
|
||||
/*public IActionResult ProceduresReport()
|
||||
{
|
||||
if (HttpContext.Request.Method == "POST")
|
||||
return View(new List<ReportProceduresViewModel>());
|
||||
}*/
|
||||
|
||||
[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<ReportProceduresViewModel>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[HttpPost]
|
||||
public IActionResult Login()
|
||||
|
@ -23,6 +23,7 @@ builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToWordCoursesByProcedures, SaveToWordCoursesByProcedure>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelCoursesByProcedure, SaveToExcelCoursesByProcedure>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfProcedures, SaveToPdfProcedures>();
|
||||
builder.Services.AddTransient<ISuretorReportLogic, SuretorReportLogic>();
|
||||
|
||||
builder.Services.AddTransient<IDiagnoseLogic, DiagnoseLogic>();
|
||||
|
@ -1,19 +1,17 @@
|
||||
@using PolyclinicContracts.ViewModels
|
||||
@model List<ReportProceduresViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "ProceduresReport";
|
||||
}
|
||||
|
||||
<div class="d-flex flex-column">
|
||||
<form method="post" class="form-procedures-report d-flex mb-4">
|
||||
<div class="me-5">
|
||||
<label for="dateFrom">
|
||||
Дата начала
|
||||
</label>
|
||||
<label for="dateFrom">Дата начала</label>
|
||||
<input type="date" id="dateFrom" name="dateFrom" />
|
||||
</div>
|
||||
<div class="me-5">
|
||||
<label for="dateTo">
|
||||
Дата завершения
|
||||
</label>
|
||||
<label for="dateTo">Дата завершения</label>
|
||||
<input type="date" id="dateTo" name="dateTo" />
|
||||
</div>
|
||||
<div class="me-5">
|
||||
@ -28,77 +26,41 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-sm" type="submit">
|
||||
Сформировать
|
||||
</button>
|
||||
<button class="btn btn-primary btn-sm" type="submit">Сформировать</button>
|
||||
</form>
|
||||
@if (ViewData.ContainsKey("ShowReport"))
|
||||
|
||||
@if (Model != null && Model.Any())
|
||||
{
|
||||
<table class="table mt-3 caption-top table-hover">
|
||||
<caption>Отчет по лекарствам с 01.01.2023 по 31.12.2023</caption>
|
||||
<caption>Отчет по процедурам</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
#
|
||||
</th>
|
||||
<th scope="col">
|
||||
Процедура
|
||||
</th>
|
||||
<th scope="col">
|
||||
Дата начала
|
||||
</th>
|
||||
<th scope="col">
|
||||
Дата завершения
|
||||
</th>
|
||||
<th scope="col">
|
||||
Лекарства
|
||||
</th>
|
||||
<th scope="col">
|
||||
Симптомы
|
||||
</th>
|
||||
<th scope="col">Номер</th>
|
||||
<th scope="col">Процедура</th>
|
||||
<th scope="col">Дата начала</th>
|
||||
<th scope="col">Дата завершения</th>
|
||||
<th scope="col">Лекарство</th>
|
||||
<th scope="col">Симптом</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
<tr>
|
||||
<th scope="row">
|
||||
@(i + 1)
|
||||
</th>
|
||||
<td>
|
||||
Процедура мытья спины
|
||||
</td>
|
||||
<td>
|
||||
16.03.2023
|
||||
</td>
|
||||
<td>
|
||||
20.10.2023
|
||||
</td>
|
||||
<td>
|
||||
Амоксициллин<sup>®</sup>
|
||||
</td>
|
||||
<td>
|
||||
Лихорадка
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Активированный уголь<sup>®</sup></td>
|
||||
<td>Покрасения</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Аскорбиновая кислота<sup>®</sup></td>
|
||||
<td>Головокружение</td>
|
||||
</tr>
|
||||
}
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@item.Id</td>
|
||||
<td>@item.ProcedureName</td>
|
||||
<td>@item.DateStartProcedure.ToShortDateString()</td>
|
||||
<td>@item.DateStopProcedure?.ToShortDateString()</td>
|
||||
@foreach (var ms in item.MedicamentSymptom)
|
||||
{
|
||||
<td>@ms.medicamentName</td>
|
||||
<td>@ms.symptomName</td>
|
||||
}
|
||||
|
||||
@* <td>@string.Join("<br/>", item.MedicamentSymptom.Select(ms => ms.medicamentName))</td>
|
||||
<td>@string.Join("<br/>", item.MedicamentSymptom.Select(ms => ms.symptomName))</td> *@
|
||||
</tr>
|
||||
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user