Merge pull request 'Добавили модели и интерфейсы логики для отчетов' (#13) from stage7_user_web_interface_prototype into main

Reviewed-on: #13
This commit is contained in:
ekallin 2024-05-02 02:45:33 +04:00
commit 26d44557fe
10 changed files with 236 additions and 4 deletions

View File

@ -0,0 +1,107 @@
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicContracts.StoragesContracts;
using PolyclinicContracts.ViewModels;
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;
}
public List<ReportDiagnoseWithCoursesAndSymptomesViewModel> GetDiagnoses()
{
var diagnoses = _diagnoseStorage.GetFullList();
var courses = _courseStorage.GetFullList();
var symptomes = _symptomStorage.GetFullList();
var result = new List<ReportDiagnoseWithCoursesAndSymptomesViewModel>();
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)
{
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);
}
}
return result;
}
public List<ReportMedicamentsByDiagnoseViewModel> GetMedicamentsByDiagnoses(ReportBindingModel model)
{
var diagnoses = _diagnoseStorage
.GetFilteredList(new DiagnoseSearchModel
{
From = model.DateFrom,
To = model.DateTo
});
var symptomes = _symptomStorage
.GetFullList();
var medicaments = _medicamentStorage.GetFullList();
List<ReportMedicamentsByDiagnoseViewModel> result = new();
foreach (var diagnose in diagnoses)
{
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));
}
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);
}
return result;
}
public void SaveOrdersToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveSecureComponentToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveSecuresToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicContracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels;
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);
}
}

View File

@ -0,0 +1,40 @@
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicContracts.BusinessLogicsContracts
{
public interface ISuretorReportLogic
{
/// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
List<ReportCoursesByProcedureViewModel> GetProcedureCourses();
/// <summary>
/// Получение списка заказов за определенный период
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
List<ReportProceduresViewModel> GetProcedures(ReportBindingModel model);
/// <summary>
/// Сохранение компонент в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveCoursesByProcedureToWordFile(ReportBindingModel model);
/// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary>
/// <param name="model"></param>
void SaveCoursesByProcedureToExcelFile(ReportBindingModel model);
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
void SaveOrdersToPdfFile(ReportBindingModel model);
}
}

View File

@ -5,7 +5,7 @@
public int? Id { get; set; }
public string? Name { get; set; }
public int? UserId { get; set; }
public DateTime? From { get; }
public DateTime? To { get; }
public DateTime? From { get; set; }
public DateTime? To { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicContracts.ViewModels
{
public class ReportCoursesByProcedureViewModel
{
public string Name { get; set; } = string.Empty;
public List<(int countDays, int pillsPerDay, string comment)> Courses = new();
}
}

View File

@ -0,0 +1,13 @@
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

@ -0,0 +1,12 @@
namespace PolyclinicContracts.ViewModels
{
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();
}
}

View File

@ -0,0 +1,17 @@
using PolyclinicDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicContracts.ViewModels
{
public class ReportProceduresViewModel
{
public int Procedure { get; set; }
public DateTime DateStartProcedure { get; set; }
public DateTime DateStopProcedure { get; set;}
public List<(string medicamentName, string symptomName)> MedicamentSymptom { get; set; } = new();
}
}

View File

@ -10,7 +10,7 @@
<div class="procedure-info d-flex flex-column mb-5 mt-5">
<p style="font-size: 3vh">
Выберите процедуры из списка
Выберите процедуру из списка
</p>
<div class="list-procedures list-group overflow-auto">
<ul>
@ -19,7 +19,7 @@
for (int i = 1; i <= count; i++)
{
<li class="d-flex mb-2">
<input class="me-2" name="procedure-@i" type="checkbox" id="procedure-@i" />
<input class="me-2" name="procedure-@i" type="radio" id="procedure-@i" />
<label for="diagnose-@i">процедура @i</label>
</li>
}