diff --git a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs new file mode 100644 index 0000000..47bb243 --- /dev/null +++ b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/SuretorReportLogic.cs @@ -0,0 +1,116 @@ +using PolyclinicContracts.BindingModels; +using PolyclinicContracts.BusinessLogicsContracts; +using PolyclinicContracts.SearchModels; +using PolyclinicContracts.StoragesContracts; +using PolyclinicContracts.ViewModels; +using PolyclinicDatabaseImplement.Models; +using SecuritySystemDatabaseImplement; + +namespace PolyclinicBusinessLogic.BusinessLogics +{ + public class SuretorReportLogic : ISuretorReportLogic + { + private readonly IProcedureStorage procedureStorage; + private readonly IMedicamentStorage medicamentStorage; + private readonly ICourseStorage courseStorage; + private readonly ISymptomStorage symptomStorage; + private readonly IRecipeStorage recipeStorage; + public SuretorReportLogic(IProcedureStorage procedureStorage, IMedicamentStorage medicamentStorage, + ICourseStorage courseStorage, ISymptomStorage symptomStorage, IRecipeStorage recipeStorage) + { + this.procedureStorage = procedureStorage; + this.medicamentStorage = medicamentStorage; + this.courseStorage = courseStorage; + this.symptomStorage = symptomStorage; + this.recipeStorage = recipeStorage; + } + + public List GetProcedureCourses(ProcedureSearchModel model) + { + var procedure = procedureStorage.GetElement(model); + var courses = courseStorage.GetFullList(); + var recipes = recipeStorage.GetFullList(); + var list = new List(); + + var record = new ReportCoursesByProcedureViewModel + { + Name = procedure!.Name, + Courses = new List<(int countDays, int pillsPerDay, string comment)>() + }; + + using var context = new PolyclinicDatabase(); + + var recipeProcedureId = context.RecipeProcedures + .Where(x => x.ProcedureId == model.Id).Select(x => x.RecipeId).ToList(); + + + foreach (var recipe in recipes) + { + foreach (var recipeId in recipeProcedureId) + { + if(recipeId == recipe.Id) + { + foreach (var course in courses) + { + if(recipe.CourseId == course.Id) + { + record.Courses.Add((course.DaysCount, course.PillsPerDay, course.Comment)); + } + } + } + } + } + list.Add(record); + return list; + } + + public List GetProcedures(ReportBindingModel model) + { + var procedures = procedureStorage.GetFullList(); + var medicaments = medicamentStorage.GetFullList(); + var symptomes = symptomStorage.GetFullList(); + var list = new List(); + + foreach (var procedure in procedures) + { + var record = new ReportProceduresViewModel + { + ProcedureName = procedure.Name, + DateStartProcedure = procedure.DateStartProcedure, + DateStopProcedure = procedure.DateStopProcedure, + MedicamentSymptom = new List<(string medicamentName, string symptomName)>() + }; + foreach (var medicament in medicaments) + { + if (medicament.ProcedureId == procedure.Id) + { + foreach (var symptom in symptomes) + { + if (symptom.Id == medicament.SymptomId) + { + record.MedicamentSymptom.Add((medicament.Name, symptom.Name)); + } + } + } + } + list.Add(record); + } + return list; + } + + public void SaveCoursesByProcedureToExcelFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + + public void SaveCoursesByProcedureToWordFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + + public void SaveOrdersToPdfFile(ReportBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/Polyclinic/PolyclinicBusinessLogic/PolyclinicBusinessLogic.csproj b/Polyclinic/PolyclinicBusinessLogic/PolyclinicBusinessLogic.csproj index 329c997..f5e1d5c 100644 --- a/Polyclinic/PolyclinicBusinessLogic/PolyclinicBusinessLogic.csproj +++ b/Polyclinic/PolyclinicBusinessLogic/PolyclinicBusinessLogic.csproj @@ -12,6 +12,7 @@ + diff --git a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs index affce17..5ca5cd8 100644 --- a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs +++ b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/ISuretorReportLogic.cs @@ -1,4 +1,5 @@ using PolyclinicContracts.BindingModels; +using PolyclinicContracts.SearchModels; using PolyclinicContracts.ViewModels; using System; using System.Collections.Generic; @@ -14,7 +15,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts /// Получение списка компонент с указанием, в каких изделиях используются /// /// - List GetProcedureCourses(); + List GetProcedureCourses(ProcedureSearchModel model); /// /// Получение списка заказов за определенный период /// diff --git a/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs index 0baba92..fcac7eb 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/ReportProceduresViewModel.cs @@ -9,9 +9,9 @@ namespace PolyclinicContracts.ViewModels { public class ReportProceduresViewModel { - public int Procedure { get; set; } + public string ProcedureName { get; set; } = string.Empty; public DateTime DateStartProcedure { get; set; } - public DateTime DateStopProcedure { get; set;} + public DateTime? DateStopProcedure { get; set;} public List<(string medicamentName, string symptomName)> MedicamentSymptom { get; set; } = new(); } }