подкорректировала логику с отчетами и ДОБАВИЛА НАКОНЕЦ надеюсь правильный метод получения курсов по процедуре...

This commit is contained in:
Елена Бакальская 2024-05-02 02:47:12 +04:00
parent c349a09117
commit e00464cc26
4 changed files with 121 additions and 3 deletions

View File

@ -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<ReportCoursesByProcedureViewModel> GetProcedureCourses(ProcedureSearchModel model)
{
var procedure = procedureStorage.GetElement(model);
var courses = courseStorage.GetFullList();
var recipes = recipeStorage.GetFullList();
var list = new List<ReportCoursesByProcedureViewModel>();
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<ReportProceduresViewModel> GetProcedures(ReportBindingModel model)
{
var procedures = procedureStorage.GetFullList();
var medicaments = medicamentStorage.GetFullList();
var symptomes = symptomStorage.GetFullList();
var list = new List<ReportProceduresViewModel>();
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();
}
}
}

View File

@ -12,6 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\PolyclinicContracts\PolyclinicContracts.csproj" />
<ProjectReference Include="..\PolyclinicDatabaseImplement\PolyclinicDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -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
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
List<ReportCoursesByProcedureViewModel> GetProcedureCourses();
List<ReportCoursesByProcedureViewModel> GetProcedureCourses(ProcedureSearchModel model);
/// <summary>
/// Получение списка заказов за определенный период
/// </summary>

View File

@ -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();
}
}