2024-05-02 02:08:08 +04:00
|
|
|
|
using PolyclinicContracts.BindingModels;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
public ImplementerReportLogic(IDiagnoseStorage diagnoseStorage, IMedicamentStorage medicamentStorage, ICourseStorage courseStorage, ISymptomStorage symptomStorage)
|
|
|
|
|
{
|
|
|
|
|
_diagnoseStorage = diagnoseStorage;
|
|
|
|
|
_medicamentStorage = medicamentStorage;
|
|
|
|
|
_courseStorage = courseStorage;
|
|
|
|
|
_symptomStorage = symptomStorage;
|
|
|
|
|
}
|
|
|
|
|
|
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-29 23:05:17 +04:00
|
|
|
|
public List<ReportMedicamentsByDiagnoseViewModel> GetReportMedicamentsByDiagnoses(List<IDiagnoseModel> diagnoses)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
2024-05-29 23:05:17 +04:00
|
|
|
|
List<DiagnoseViewModel> diagnoseViewModels = diagnoses.Select(x => _diagnoseStorage.GetElement(new DiagnoseSearchModel { Id = x.Id })).ToList();
|
|
|
|
|
|
|
|
|
|
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 00:08:44 +04:00
|
|
|
|
public void SaveReportDiagnosesWithSymptomesAndCoursesByPeriodToPdfFile(ReportInfoModel reportInfo, ReportDiagnosesByPeriodViewModel reportModel)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-29 23:05:17 +04:00
|
|
|
|
public void SaveReportMedicamentsByDiagnosesToExcelFile(ReportInfoModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-29 23:05:17 +04:00
|
|
|
|
public void SaveReportMedicamentsByDiagnosesToWordFile(ReportInfoModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel)
|
2024-05-02 02:08:08 +04:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|