2024-05-30 01:46:40 +04:00
|
|
|
|
using PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports;
|
|
|
|
|
using PolyclinicBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel;
|
|
|
|
|
using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF;
|
|
|
|
|
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word;
|
|
|
|
|
using PolyclinicContracts.BindingModels;
|
2024-05-02 02:08:08 +04:00
|
|
|
|
using PolyclinicContracts.BusinessLogicsContracts;
|
|
|
|
|
using PolyclinicContracts.SearchModels;
|
|
|
|
|
using PolyclinicContracts.StoragesContracts;
|
|
|
|
|
using PolyclinicContracts.ViewModels;
|
2024-05-29 23:05:17 +04:00
|
|
|
|
using PolyclinicDataModels.Models;
|
2024-05-02 02:08:08 +04:00
|
|
|
|
|
|
|
|
|
namespace PolyclinicBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
|
|
|
|
public class ImplementerReportLogic : IImplementerReportLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly IDiagnoseStorage _diagnoseStorage;
|
|
|
|
|
private readonly IMedicamentStorage _medicamentStorage;
|
|
|
|
|
private readonly ICourseStorage _courseStorage;
|
|
|
|
|
private readonly ISymptomStorage _symptomStorage;
|
|
|
|
|
|
2024-05-30 02:06:44 +04:00
|
|
|
|
private readonly AbstractReportMedicamentsByDiagnosesSaveToExcel _saveToExcel;
|
|
|
|
|
private readonly AbstractReportMedicamentsByDiagnosesSaveToWord _saveToWord;
|
|
|
|
|
private readonly AbstractReportDiagnosesByPeriodSaveToPdf _saveToPdf;
|
2024-05-30 01:46:40 +04:00
|
|
|
|
|
|
|
|
|
public ImplementerReportLogic(
|
|
|
|
|
IDiagnoseStorage diagnoseStorage,
|
|
|
|
|
IMedicamentStorage medicamentStorage,
|
|
|
|
|
ICourseStorage courseStorage,
|
|
|
|
|
ISymptomStorage symptomStorage,
|
2024-05-30 02:06:44 +04:00
|
|
|
|
AbstractReportMedicamentsByDiagnosesSaveToWord saveToWord,
|
|
|
|
|
AbstractReportDiagnosesByPeriodSaveToPdf saveToPdf,
|
|
|
|
|
AbstractReportMedicamentsByDiagnosesSaveToExcel saveToExcel)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
|
|
|
|
_diagnoseStorage = diagnoseStorage;
|
|
|
|
|
_medicamentStorage = medicamentStorage;
|
|
|
|
|
_courseStorage = courseStorage;
|
|
|
|
|
_symptomStorage = symptomStorage;
|
2024-05-30 01:46:40 +04:00
|
|
|
|
_saveToWord = saveToWord;
|
|
|
|
|
_saveToPdf = saveToPdf;
|
|
|
|
|
_saveToExcel = saveToExcel;
|
2024-05-02 02:08:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 00:08:44 +04:00
|
|
|
|
public ReportDiagnosesByPeriodViewModel GetReportDiagnosesByPeriod(DateTime? dateStart, DateTime? dateEnd)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
2024-05-29 23:05:17 +04:00
|
|
|
|
var diagnoses = _diagnoseStorage.GetFilteredList(new DiagnoseSearchModel { From = dateStart, To = dateEnd });
|
2024-05-02 02:19:56 +04:00
|
|
|
|
var courses = _courseStorage.GetFullList();
|
|
|
|
|
var symptomes = _symptomStorage.GetFullList();
|
|
|
|
|
|
2024-05-30 00:08:44 +04:00
|
|
|
|
var report = new ReportDiagnosesByPeriodViewModel();
|
2024-05-02 02:19:56 +04:00
|
|
|
|
|
|
|
|
|
foreach (var diagnose in diagnoses)
|
|
|
|
|
{
|
|
|
|
|
var diagnoseCourses = courses.Where(x => x.CourseDiagnoses.ContainsKey(diagnose.Id)).ToList();
|
|
|
|
|
var diagnoseSymptomes = symptomes.Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id)).ToList();
|
|
|
|
|
if (diagnoseCourses.Count > 0 && diagnoseSymptomes.Count > 0)
|
|
|
|
|
{
|
2024-05-29 23:05:17 +04:00
|
|
|
|
report.DiagnosesData.Add((diagnose, diagnoseSymptomes, diagnoseCourses));
|
2024-05-02 02:19:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-30 00:08:44 +04:00
|
|
|
|
report.DateStart = dateStart;
|
|
|
|
|
report.DateEnd = dateEnd;
|
2024-05-29 23:05:17 +04:00
|
|
|
|
return report;
|
2024-05-02 02:08:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 02:36:31 +04:00
|
|
|
|
public List<ReportMedicamentsByDiagnoseViewModel> GetReportMedicamentsByDiagnoses(int[] diagnosesIds)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
2024-05-30 02:36:31 +04:00
|
|
|
|
List<DiagnoseViewModel> diagnoseViewModels = diagnosesIds.Select(x => _diagnoseStorage.GetElement(new DiagnoseSearchModel { Id = x })).ToList();
|
2024-05-29 23:05:17 +04:00
|
|
|
|
|
|
|
|
|
var symptomes = _symptomStorage.GetFullList();
|
2024-05-02 02:08:08 +04:00
|
|
|
|
var medicaments = _medicamentStorage.GetFullList();
|
|
|
|
|
|
2024-05-29 23:05:17 +04:00
|
|
|
|
List<ReportMedicamentsByDiagnoseViewModel> report = new();
|
2024-05-02 02:08:08 +04:00
|
|
|
|
|
2024-05-29 23:05:17 +04:00
|
|
|
|
foreach (var diagnose in diagnoseViewModels)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
|
|
|
|
var diagnoseSymptomes = symptomes
|
|
|
|
|
.Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id))
|
|
|
|
|
.ToList();
|
|
|
|
|
var diagnoseMedicaments = new List<MedicamentViewModel>();
|
|
|
|
|
foreach (var symptom in diagnoseSymptomes)
|
|
|
|
|
{
|
|
|
|
|
diagnoseMedicaments.AddRange(medicaments.Where(x => x.SymptomId == symptom.Id));
|
|
|
|
|
}
|
2024-05-29 23:05:17 +04:00
|
|
|
|
|
|
|
|
|
report.Add(new ReportMedicamentsByDiagnoseViewModel
|
|
|
|
|
{
|
|
|
|
|
Diagnose = diagnose,
|
|
|
|
|
Medicaments = diagnoseMedicaments.DistinctBy(x => x.Name).ToList()
|
|
|
|
|
});
|
2024-05-02 02:08:08 +04:00
|
|
|
|
}
|
2024-05-29 23:05:17 +04:00
|
|
|
|
return report;
|
2024-05-02 02:08:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 01:46:40 +04:00
|
|
|
|
public void SaveReportDiagnosesByPeriodToPdfFile(ReportBindingModel reportInfo, ReportDiagnosesByPeriodViewModel reportModel)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
2024-05-30 01:46:40 +04:00
|
|
|
|
_saveToPdf.CreateDoc(new PdfDiagnosesByPeriodInfo
|
|
|
|
|
{
|
|
|
|
|
Title = "Отчет по болезням за период с расшифровкой по симптомам и курсам",
|
|
|
|
|
DateFrom = reportModel.DateStart,
|
|
|
|
|
DateTo = reportModel.DateEnd,
|
|
|
|
|
FileName = reportInfo.FileName,
|
|
|
|
|
Report = reportModel
|
|
|
|
|
});
|
2024-05-02 02:08:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 01:46:40 +04:00
|
|
|
|
public void SaveReportMedicamentsByDiagnosesToExcelFile(ReportBindingModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
2024-05-30 01:46:40 +04:00
|
|
|
|
_saveToExcel.CreateReport(new ReportMedicamentsByDiagnosesInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = reportInfo.FileName,
|
|
|
|
|
Title = "Лекарства по болезням",
|
|
|
|
|
ReportModel = reportModel
|
|
|
|
|
});
|
2024-05-02 02:08:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 01:46:40 +04:00
|
|
|
|
public void SaveReportMedicamentsByDiagnosesToWordFile(ReportBindingModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
2024-05-30 01:46:40 +04:00
|
|
|
|
_saveToWord.CreateDoc(new ReportMedicamentsByDiagnosesInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = reportInfo.FileName,
|
|
|
|
|
Title = "Лекарства по болезням",
|
|
|
|
|
ReportModel = reportModel
|
|
|
|
|
});
|
2024-05-02 02:08:08 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|