diff --git a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ImplementerReportLogic.cs b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ImplementerReportLogic.cs index 9995140..dd6faf2 100644 --- a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ImplementerReportLogic.cs +++ b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ImplementerReportLogic.cs @@ -3,6 +3,7 @@ using PolyclinicContracts.BusinessLogicsContracts; using PolyclinicContracts.SearchModels; using PolyclinicContracts.StoragesContracts; using PolyclinicContracts.ViewModels; +using PolyclinicDataModels.Models; namespace PolyclinicBusinessLogic.BusinessLogics { @@ -21,13 +22,13 @@ namespace PolyclinicBusinessLogic.BusinessLogics _symptomStorage = symptomStorage; } - public List GetDiagnoses() + public ReportSymptomesCoursesViewModel GetReportDiagnosesWithSymptomesAndCoursesByPeriod(DateTime? dateStart, DateTime? dateEnd) { - var diagnoses = _diagnoseStorage.GetFullList(); + var diagnoses = _diagnoseStorage.GetFilteredList(new DiagnoseSearchModel { From = dateStart, To = dateEnd }); var courses = _courseStorage.GetFullList(); var symptomes = _symptomStorage.GetFullList(); - var result = new List(); + var report = new ReportSymptomesCoursesViewModel(); foreach (var diagnose in diagnoses) { @@ -35,38 +36,22 @@ namespace PolyclinicBusinessLogic.BusinessLogics var diagnoseSymptomes = symptomes.Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id)).ToList(); if (diagnoseCourses.Count > 0 && diagnoseSymptomes.Count > 0) { - var dianoseReportModel = new ReportDiagnoseWithCoursesAndSymptomesViewModel { - DiagnoseId = diagnose.Id, - DiagnoseName = diagnose.Name, - DiagnoseComment = diagnose.Comment, - DiagnoseDateStart = diagnose.DateStartDiagnose, - DiagnoseDateStop = diagnose.DateStopDiagnose, - Courses = diagnoseCourses.Select(x => (x.DaysCount, x.PillsPerDay)).ToList(), - Symptomes = diagnoseSymptomes.Select(x => x.Name).ToList() - }; - result.Add(dianoseReportModel); + report.DiagnosesData.Add((diagnose, diagnoseSymptomes, diagnoseCourses)); } } - return result; + return report; } - public List GetMedicamentsByDiagnoses(ReportBindingModel model) + public List GetReportMedicamentsByDiagnoses(List diagnoses) { - var diagnoses = _diagnoseStorage - .GetFilteredList(new DiagnoseSearchModel - { - From = model.DateFrom, - To = model.DateTo - }); - - var symptomes = _symptomStorage - .GetFullList(); - + List diagnoseViewModels = diagnoses.Select(x => _diagnoseStorage.GetElement(new DiagnoseSearchModel { Id = x.Id })).ToList(); + + var symptomes = _symptomStorage.GetFullList(); var medicaments = _medicamentStorage.GetFullList(); - List result = new(); + List report = new(); - foreach (var diagnose in diagnoses) + foreach (var diagnose in diagnoseViewModels) { var diagnoseSymptomes = symptomes .Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id)) @@ -76,30 +61,27 @@ namespace PolyclinicBusinessLogic.BusinessLogics { diagnoseMedicaments.AddRange(medicaments.Where(x => x.SymptomId == symptom.Id)); } - var diagnoseReportModel = new ReportMedicamentsByDiagnoseViewModel { - DiagnoseId = diagnose.Id, - DiagnoseName = diagnose.Name, - DiagnoseComment = diagnose.Comment, - DiagnoseDateStart = diagnose.DateStartDiagnose, - DiagnoseDateStop = diagnose.DateStopDiagnose, - Medicaments = diagnoseMedicaments.Distinct().Select(x => x.Name).ToList() - }; - result.Add(diagnoseReportModel); + + report.Add(new ReportMedicamentsByDiagnoseViewModel + { + Diagnose = diagnose, + Medicaments = diagnoseMedicaments.DistinctBy(x => x.Name).ToList() + }); } - return result; + return report; } - public void SaveOrdersToPdfFile(ReportBindingModel model) + public void SaveReportDiagnosesWithSymptomesAndCoursesByPeriodToPdfFile(ReportInfoModel reportInfo, ReportSymptomesCoursesViewModel reportModel) { throw new NotImplementedException(); } - public void SaveSecureComponentToExcelFile(ReportBindingModel model) + public void SaveReportMedicamentsByDiagnosesToExcelFile(ReportInfoModel reportInfo, List reportModel) { throw new NotImplementedException(); } - public void SaveSecuresToWordFile(ReportBindingModel model) + public void SaveReportMedicamentsByDiagnosesToWordFile(ReportInfoModel reportInfo, List reportModel) { throw new NotImplementedException(); } diff --git a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs index 5d831aa..b0e332b 100644 --- a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs +++ b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs @@ -104,7 +104,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics return list; } - public void SaveCoursesByProcedureToExcelFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode) + public void SaveCoursesByProcedureToExcelFile(ReportInfoModel model, ProcedureSearchModel procedureSearchMode) { saveToExcel.CreateReport(new ExcelCoursesByProceduresInfo { @@ -114,7 +114,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics }); } - public void SaveCoursesByProcedureToWordFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode) + public void SaveCoursesByProcedureToWordFile(ReportInfoModel model, ProcedureSearchModel procedureSearchMode) { saveToWord.CreateDoc(new WordCoursesByProceduresInfo { @@ -124,7 +124,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics }); } - public void SaveProceduresToPdfFile(ReportBindingModel model) + public void SaveProceduresToPdfFile(ReportInfoModel model) { saveToPdf.CreateDoc(new PdfProceduresByMedicamentsAndSymptomsInfo { diff --git a/Polyclinic/PolyclinicContracts/BindingModels/ReportBindingModel.cs b/Polyclinic/PolyclinicContracts/BindingModels/ReportInfoModel.cs similarity index 61% rename from Polyclinic/PolyclinicContracts/BindingModels/ReportBindingModel.cs rename to Polyclinic/PolyclinicContracts/BindingModels/ReportInfoModel.cs index e5f4907..8ed8b0c 100644 --- a/Polyclinic/PolyclinicContracts/BindingModels/ReportBindingModel.cs +++ b/Polyclinic/PolyclinicContracts/BindingModels/ReportInfoModel.cs @@ -1,8 +1,8 @@ namespace PolyclinicContracts.BindingModels { - public class ReportBindingModel + public class ReportInfoModel { - public string FileName { get; set; } = string.Empty; + public string? FileName { get; set; } public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } } diff --git a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IImplementerReportLogic.cs b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IImplementerReportLogic.cs index c046a8a..dc52799 100644 --- a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IImplementerReportLogic.cs +++ b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IImplementerReportLogic.cs @@ -1,14 +1,15 @@ using PolyclinicContracts.BindingModels; using PolyclinicContracts.ViewModels; +using PolyclinicDataModels.Models; namespace PolyclinicContracts.BusinessLogicsContracts { public interface IImplementerReportLogic { - List GetDiagnoses(); - List GetMedicamentsByDiagnoses(ReportBindingModel model); - void SaveSecuresToWordFile(ReportBindingModel model); - void SaveSecureComponentToExcelFile(ReportBindingModel model); - void SaveOrdersToPdfFile(ReportBindingModel model); + ReportSymptomesCoursesViewModel GetReportDiagnosesWithSymptomesAndCoursesByPeriod(DateTime? dateStart, DateTime? dateEnd); + List GetReportMedicamentsByDiagnoses(List diagnoses); + void SaveReportMedicamentsByDiagnosesToWordFile(ReportInfoModel reportInfo, List reportModel); + void SaveReportMedicamentsByDiagnosesToExcelFile(ReportInfoModel reportInfo, List reportModel); + void SaveReportDiagnosesWithSymptomesAndCoursesByPeriodToPdfFile(ReportInfoModel reportInfo, ReportSymptomesCoursesViewModel reportModel); } } diff --git a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs index b7daa2e..60c93d8 100644 --- a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs +++ b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs @@ -28,18 +28,18 @@ namespace PolyclinicContracts.BusinessLogicsContracts /// Сохранение курсов по процедурам в файл-Word /// /// - void SaveCoursesByProcedureToWordFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode); + void SaveCoursesByProcedureToWordFile(ReportInfoModel model, ProcedureSearchModel procedureSearchMode); /// /// Сохранение курсов по процедурам в файл-Excel /// /// - void SaveCoursesByProcedureToExcelFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode); + void SaveCoursesByProcedureToExcelFile(ReportInfoModel model, ProcedureSearchModel procedureSearchMode); /// /// Сохранение заказов в файл-Pdf /// /// - void SaveProceduresToPdfFile(ReportBindingModel model); + void SaveProceduresToPdfFile(ReportInfoModel model); } } diff --git a/Polyclinic/PolyclinicContracts/ViewModels/ReportDiagnoseWithCoursesAndSymptomesViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/ReportDiagnoseWithCoursesAndSymptomesViewModel.cs deleted file mode 100644 index df52d06..0000000 --- a/Polyclinic/PolyclinicContracts/ViewModels/ReportDiagnoseWithCoursesAndSymptomesViewModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace PolyclinicContracts.ViewModels -{ - public class ReportDiagnoseWithCoursesAndSymptomesViewModel - { - public int DiagnoseId { get; set; } - public string DiagnoseName { get; set; } = string.Empty; - public string DiagnoseComment { get; set; } = string.Empty; - public DateTime DiagnoseDateStart { get; set; } - public DateTime? DiagnoseDateStop { get; set; } = null; - public List Symptomes { get; set; } = new(); - public List<(int DaysCount, int PillsPerDay)> Courses = new(); - } -} diff --git a/Polyclinic/PolyclinicContracts/ViewModels/ReportMedicamentsByDiagnoseViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/ReportMedicamentsByDiagnoseViewModel.cs index e9b3bf6..9663386 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/ReportMedicamentsByDiagnoseViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/ReportMedicamentsByDiagnoseViewModel.cs @@ -2,11 +2,7 @@ { public class ReportMedicamentsByDiagnoseViewModel { - public int DiagnoseId { get; set; } - public string DiagnoseName { get; set; } = string.Empty; - public string DiagnoseComment { get; set; } = string.Empty; - public DateTime DiagnoseDateStart { get; set; } - public DateTime? DiagnoseDateStop { get; set; } = null; - public List Medicaments = new(); + public DiagnoseViewModel Diagnose { get; set; } = new(); + public List Medicaments { get; set; } = new(); } } diff --git a/Polyclinic/PolyclinicContracts/ViewModels/ReportSymptomesCoursesViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/ReportSymptomesCoursesViewModel.cs new file mode 100644 index 0000000..fcc4a54 --- /dev/null +++ b/Polyclinic/PolyclinicContracts/ViewModels/ReportSymptomesCoursesViewModel.cs @@ -0,0 +1,9 @@ +namespace PolyclinicContracts.ViewModels +{ + public class ReportSymptomesCoursesViewModel + { + public DateTime DateStart { get; set; } + public DateTime DateEnd { get; set; } + public List<(DiagnoseViewModel Diagnose, List Symptomes, List Courses)> DiagnosesData { get; set; } = new(); + } +} diff --git a/Polyclinic/PolyclinicWebAppImplementer/Program.cs b/Polyclinic/PolyclinicWebAppImplementer/Program.cs index ad50cb6..5b227d1 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/Program.cs +++ b/Polyclinic/PolyclinicWebAppImplementer/Program.cs @@ -24,6 +24,8 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index 57fe5fb..03f0365 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -359,7 +359,7 @@ namespace PolyclinicWebAppSuretor.Controllers return NotFound(" "); } - var report = new ReportBindingModel + var report = new ReportInfoModel { FileName = fileName, }; @@ -415,7 +415,7 @@ namespace PolyclinicWebAppSuretor.Controllers } else if (reportType == "email") { - var reportBindingModel = new ReportBindingModel + var reportBindingModel = new ReportInfoModel { FileName = "ProceduresReport.pdf", DateFrom = dateFrom,