Поправил логику отчетов исполнителя

This commit is contained in:
Никита Потапов 2024-05-29 23:05:17 +04:00
parent 3e78e51f7c
commit 490216b6c1
10 changed files with 51 additions and 74 deletions

View File

@ -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<ReportDiagnoseWithCoursesAndSymptomesViewModel> 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<ReportDiagnoseWithCoursesAndSymptomesViewModel>();
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<ReportMedicamentsByDiagnoseViewModel> GetMedicamentsByDiagnoses(ReportBindingModel model)
public List<ReportMedicamentsByDiagnoseViewModel> GetReportMedicamentsByDiagnoses(List<IDiagnoseModel> diagnoses)
{
var diagnoses = _diagnoseStorage
.GetFilteredList(new DiagnoseSearchModel
{
From = model.DateFrom,
To = model.DateTo
});
var symptomes = _symptomStorage
.GetFullList();
List<DiagnoseViewModel> diagnoseViewModels = diagnoses.Select(x => _diagnoseStorage.GetElement(new DiagnoseSearchModel { Id = x.Id })).ToList();
var symptomes = _symptomStorage.GetFullList();
var medicaments = _medicamentStorage.GetFullList();
List<ReportMedicamentsByDiagnoseViewModel> result = new();
List<ReportMedicamentsByDiagnoseViewModel> 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<ReportMedicamentsByDiagnoseViewModel> reportModel)
{
throw new NotImplementedException();
}
public void SaveSecuresToWordFile(ReportBindingModel model)
public void SaveReportMedicamentsByDiagnosesToWordFile(ReportInfoModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel)
{
throw new NotImplementedException();
}

View File

@ -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
{

View File

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

View File

@ -1,14 +1,15 @@
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
namespace PolyclinicContracts.BusinessLogicsContracts
{
public interface IImplementerReportLogic
{
List<ReportDiagnoseWithCoursesAndSymptomesViewModel> GetDiagnoses();
List<ReportMedicamentsByDiagnoseViewModel> GetMedicamentsByDiagnoses(ReportBindingModel model);
void SaveSecuresToWordFile(ReportBindingModel model);
void SaveSecureComponentToExcelFile(ReportBindingModel model);
void SaveOrdersToPdfFile(ReportBindingModel model);
ReportSymptomesCoursesViewModel GetReportDiagnosesWithSymptomesAndCoursesByPeriod(DateTime? dateStart, DateTime? dateEnd);
List<ReportMedicamentsByDiagnoseViewModel> GetReportMedicamentsByDiagnoses(List<IDiagnoseModel> diagnoses);
void SaveReportMedicamentsByDiagnosesToWordFile(ReportInfoModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel);
void SaveReportMedicamentsByDiagnosesToExcelFile(ReportInfoModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel);
void SaveReportDiagnosesWithSymptomesAndCoursesByPeriodToPdfFile(ReportInfoModel reportInfo, ReportSymptomesCoursesViewModel reportModel);
}
}

View File

@ -28,18 +28,18 @@ namespace PolyclinicContracts.BusinessLogicsContracts
/// Сохранение курсов по процедурам в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveCoursesByProcedureToWordFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode);
void SaveCoursesByProcedureToWordFile(ReportInfoModel model, ProcedureSearchModel procedureSearchMode);
/// <summary>
/// Сохранение курсов по процедурам в файл-Excel
/// </summary>
/// <param name="model"></param>
void SaveCoursesByProcedureToExcelFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode);
void SaveCoursesByProcedureToExcelFile(ReportInfoModel model, ProcedureSearchModel procedureSearchMode);
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
void SaveProceduresToPdfFile(ReportBindingModel model);
void SaveProceduresToPdfFile(ReportInfoModel model);
}
}

View File

@ -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<string> Symptomes { get; set; } = new();
public List<(int DaysCount, int PillsPerDay)> Courses = new();
}
}

View File

@ -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<string> Medicaments = new();
public DiagnoseViewModel Diagnose { get; set; } = new();
public List<MedicamentViewModel> Medicaments { get; set; } = new();
}
}

View File

@ -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<SymptomViewModel> Symptomes, List<CourseViewModel> Courses)> DiagnosesData { get; set; } = new();
}
}

View File

@ -24,6 +24,8 @@ builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicamentLogic, MedicamentLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IImplementerReportLogic, ImplementerReportLogic>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();

View File

@ -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,