Merge pull request 'stage9_10' (#16) from stage9_10 into main

Reviewed-on: #16
This commit is contained in:
Никита Потапов 2024-05-30 04:28:50 +04:00
commit b7a763b785
166 changed files with 5436 additions and 1312 deletions

3
.gitignore vendored
View File

@ -398,3 +398,6 @@ FodyWeavers.xsd
# JetBrains Rider # JetBrains Rider
*.sln.iml *.sln.iml
*.docx
*.xlsx
*.pdf

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger; private ILogger _logger;
private ICourseStorage _courseStorage; private ICourseStorage _courseStorage;
public CourseLogic(ILogger logger, ICourseStorage courseStorage) public CourseLogic(ILogger<CourseLogic> logger, ICourseStorage courseStorage)
{ {
_logger = logger; _logger = logger;
_courseStorage = courseStorage; _courseStorage = courseStorage;
@ -58,14 +58,14 @@ namespace PolyclinicBusinessLogic.BusinessLogics
return element; return element;
} }
public List<CourseViewModel>? ReadList(CourseSearchModel? model) public List<CourseViewModel> ReadList(CourseSearchModel? model = null)
{ {
_logger.LogInformation("ReadList. Id:{Id}", model?.Id); _logger.LogInformation("ReadList. Id:{Id}", model?.Id);
var list = model == null ? _courseStorage.GetFullList() : _courseStorage.GetFilteredList(model); var list = model == null ? _courseStorage.GetFullList() : _courseStorage.GetFilteredList(model);
if (list == null) if (list == null)
{ {
_logger.LogWarning("ReadList return null list"); _logger.LogWarning("ReadList return null list");
return null; return new List<CourseViewModel>();
} }
_logger.LogInformation("ReadList. Count:{Count}", list.Count); _logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger; private ILogger _logger;
private IDiagnoseStorage _diagnoseStorage; private IDiagnoseStorage _diagnoseStorage;
public DiagnoseLogic(ILogger logger, IDiagnoseStorage diagnoseStorage) public DiagnoseLogic(ILogger<DiagnoseLogic> logger, IDiagnoseStorage diagnoseStorage)
{ {
_logger = logger; _logger = logger;
_diagnoseStorage = diagnoseStorage; _diagnoseStorage = diagnoseStorage;
@ -58,14 +58,14 @@ namespace PolyclinicBusinessLogic.BusinessLogics
return element; return element;
} }
public List<DiagnoseViewModel>? ReadList(DiagnoseSearchModel? model) public List<DiagnoseViewModel> ReadList(DiagnoseSearchModel? model = null)
{ {
_logger.LogInformation("ReadList. Name:{Name} Id:{Id}, UserId:{UserId}", model?.Name, model?.Id, model?.UserId); _logger.LogInformation("ReadList. Name:{Name} Id:{Id}, UserId:{UserId}", model?.Name, model?.Id, model?.UserId);
var list = model == null ? _diagnoseStorage.GetFullList() : _diagnoseStorage.GetFilteredList(model); var list = model == null ? _diagnoseStorage.GetFullList() : _diagnoseStorage.GetFilteredList(model);
if (list == null) if (list == null)
{ {
_logger.LogWarning("ReadList return null list"); _logger.LogWarning("ReadList return null list");
return null; return new List<DiagnoseViewModel>();
} }
_logger.LogInformation("ReadList. Count:{Count}", list.Count); _logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;

View File

@ -1,8 +1,14 @@
using PolyclinicContracts.BindingModels; using PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports;
using PolyclinicBusinessLogic.OfficePackage.HelperModels;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts; using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels; using PolyclinicContracts.SearchModels;
using PolyclinicContracts.StoragesContracts; using PolyclinicContracts.StoragesContracts;
using PolyclinicContracts.ViewModels; using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
namespace PolyclinicBusinessLogic.BusinessLogics namespace PolyclinicBusinessLogic.BusinessLogics
{ {
@ -13,21 +19,35 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private readonly ICourseStorage _courseStorage; private readonly ICourseStorage _courseStorage;
private readonly ISymptomStorage _symptomStorage; private readonly ISymptomStorage _symptomStorage;
public ImplementerReportLogic(IDiagnoseStorage diagnoseStorage, IMedicamentStorage medicamentStorage, ICourseStorage courseStorage, ISymptomStorage symptomStorage) private readonly AbstractReportMedicamentsByDiagnosesSaveToExcel _saveToExcel;
private readonly AbstractReportMedicamentsByDiagnosesSaveToWord _saveToWord;
private readonly AbstractReportDiagnosesByPeriodSaveToPdf _saveToPdf;
public ImplementerReportLogic(
IDiagnoseStorage diagnoseStorage,
IMedicamentStorage medicamentStorage,
ICourseStorage courseStorage,
ISymptomStorage symptomStorage,
AbstractReportMedicamentsByDiagnosesSaveToWord saveToWord,
AbstractReportDiagnosesByPeriodSaveToPdf saveToPdf,
AbstractReportMedicamentsByDiagnosesSaveToExcel saveToExcel)
{ {
_diagnoseStorage = diagnoseStorage; _diagnoseStorage = diagnoseStorage;
_medicamentStorage = medicamentStorage; _medicamentStorage = medicamentStorage;
_courseStorage = courseStorage; _courseStorage = courseStorage;
_symptomStorage = symptomStorage; _symptomStorage = symptomStorage;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
_saveToExcel = saveToExcel;
} }
public List<ReportDiagnoseWithCoursesAndSymptomesViewModel> GetDiagnoses() public ReportDiagnosesByPeriodViewModel GetReportDiagnosesByPeriod(DateTime? dateStart, DateTime? dateEnd)
{ {
var diagnoses = _diagnoseStorage.GetFullList(); var diagnoses = _diagnoseStorage.GetFilteredList(new DiagnoseSearchModel { From = dateStart, To = dateEnd });
var courses = _courseStorage.GetFullList(); var courses = _courseStorage.GetFullList();
var symptomes = _symptomStorage.GetFullList(); var symptomes = _symptomStorage.GetFullList();
var result = new List<ReportDiagnoseWithCoursesAndSymptomesViewModel>(); var report = new ReportDiagnosesByPeriodViewModel();
foreach (var diagnose in diagnoses) foreach (var diagnose in diagnoses)
{ {
@ -35,38 +55,24 @@ namespace PolyclinicBusinessLogic.BusinessLogics
var diagnoseSymptomes = symptomes.Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id)).ToList(); var diagnoseSymptomes = symptomes.Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id)).ToList();
if (diagnoseCourses.Count > 0 && diagnoseSymptomes.Count > 0) if (diagnoseCourses.Count > 0 && diagnoseSymptomes.Count > 0)
{ {
var dianoseReportModel = new ReportDiagnoseWithCoursesAndSymptomesViewModel { report.DiagnosesData.Add((diagnose, diagnoseSymptomes, diagnoseCourses));
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; report.DateStart = dateStart;
report.DateEnd = dateEnd;
return report;
} }
public List<ReportMedicamentsByDiagnoseViewModel> GetMedicamentsByDiagnoses(ReportBindingModel model) public List<ReportMedicamentsByDiagnoseViewModel> GetReportMedicamentsByDiagnoses(int[] diagnosesIds)
{ {
var diagnoses = _diagnoseStorage List<DiagnoseViewModel> diagnoseViewModels = diagnosesIds.Select(x => _diagnoseStorage.GetElement(new DiagnoseSearchModel { Id = x })).ToList();
.GetFilteredList(new DiagnoseSearchModel
{ var symptomes = _symptomStorage.GetFullList();
From = model.DateFrom,
To = model.DateTo
});
var symptomes = _symptomStorage
.GetFullList();
var medicaments = _medicamentStorage.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 var diagnoseSymptomes = symptomes
.Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id)) .Where(x => x.SymptomDiagnoses.ContainsKey(diagnose.Id))
@ -76,32 +82,47 @@ namespace PolyclinicBusinessLogic.BusinessLogics
{ {
diagnoseMedicaments.AddRange(medicaments.Where(x => x.SymptomId == symptom.Id)); diagnoseMedicaments.AddRange(medicaments.Where(x => x.SymptomId == symptom.Id));
} }
var diagnoseReportModel = new ReportMedicamentsByDiagnoseViewModel {
DiagnoseId = diagnose.Id, report.Add(new ReportMedicamentsByDiagnoseViewModel
DiagnoseName = diagnose.Name, {
DiagnoseComment = diagnose.Comment, Diagnose = diagnose,
DiagnoseDateStart = diagnose.DateStartDiagnose, Medicaments = diagnoseMedicaments.DistinctBy(x => x.Name).ToList()
DiagnoseDateStop = diagnose.DateStopDiagnose, });
Medicaments = diagnoseMedicaments.Distinct().Select(x => x.Name).ToList()
};
result.Add(diagnoseReportModel);
} }
return result; return report;
} }
public void SaveOrdersToPdfFile(ReportBindingModel model) public void SaveReportDiagnosesByPeriodToPdfFile(ReportBindingModel reportInfo, ReportDiagnosesByPeriodViewModel reportModel)
{ {
throw new NotImplementedException(); _saveToPdf.CreateDoc(new PdfDiagnosesByPeriodInfo
{
Title = "Отчет по болезням за период с расшифровкой по симптомам и курсам",
DateFrom = reportModel.DateStart,
DateTo = reportModel.DateEnd,
FileName = reportInfo.FileName,
PeriodString = reportInfo.GetPeriodString(),
Report = reportModel
});
} }
public void SaveSecureComponentToExcelFile(ReportBindingModel model) public void SaveReportMedicamentsByDiagnosesToExcelFile(ReportBindingModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel)
{ {
throw new NotImplementedException(); _saveToExcel.CreateReport(new ReportMedicamentsByDiagnosesInfo
{
FileName = reportInfo.FileName,
Title = "Лекарства по болезням",
ReportModel = reportModel
});
} }
public void SaveSecuresToWordFile(ReportBindingModel model) public void SaveReportMedicamentsByDiagnosesToWordFile(ReportBindingModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel)
{ {
throw new NotImplementedException(); _saveToWord.CreateDoc(new ReportMedicamentsByDiagnosesInfo
{
FileName = reportInfo.FileName,
Title = "Лекарства по болезням",
ReportModel = reportModel
});
} }
} }
} }

View File

@ -95,14 +95,6 @@ namespace PolyclinicBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException("Какой-то неправильный идентификатор симптома...", nameof(model)); throw new ArgumentNullException("Какой-то неправильный идентификатор симптома...", nameof(model));
} }
if (model.ProcedureId <= 0)
{
throw new ArgumentNullException("Какой-то неправильный идентификатор процедуры...", nameof(model));
}
if (string.IsNullOrEmpty(model.Comment))
{
throw new ArgumentNullException("Нет комментария", nameof(model.Comment));
}
if (string.IsNullOrEmpty(model.Name)) if (string.IsNullOrEmpty(model.Name))
{ {
throw new ArgumentNullException("Нет названия у препарата", nameof(model.Comment)); throw new ArgumentNullException("Нет названия у препарата", nameof(model.Comment));

View File

@ -66,7 +66,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
if (list == null) if (list == null)
{ {
logger.LogWarning("ReadList return null list"); logger.LogWarning("ReadList return null list");
return null; return new List<ProcedureViewModel>();
} }
logger.LogInformation("ReadList. Count:{Count}", list.Count); logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;

View File

@ -58,14 +58,14 @@ namespace PolyclinicBusinessLogic.BusinessLogics
return element; return element;
} }
public List<RecipeViewModel>? ReadList(RecipeSearchModel? model) public List<RecipeViewModel>? ReadList(RecipeSearchModel? model = null)
{ {
logger.LogInformation("ReadList. Comment:{Comment}. Id:{ Id}", model?.Comment, model?.Id); logger.LogInformation("ReadList. Comment:{Comment}. Id:{ Id}", model?.Comment, model?.Id);
var list = model == null ? recipeStorage.GetFullList() : recipeStorage.GetFilteredList(model); var list = model == null ? recipeStorage.GetFullList() : recipeStorage.GetFilteredList(model);
if (list == null) if (list == null)
{ {
logger.LogWarning("ReadList return null list"); logger.LogWarning("ReadList return null list");
return null; return new List<RecipeViewModel>();
} }
logger.LogInformation("ReadList. Count:{Count}", list.Count); logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;
@ -96,10 +96,6 @@ namespace PolyclinicBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException("Количество процедур не может быть равно нулю или быть меньше нуля", nameof(model)); throw new ArgumentNullException("Количество процедур не может быть равно нулю или быть меньше нуля", nameof(model));
} }
if (string.IsNullOrEmpty(model.Comment))
{
throw new ArgumentNullException("Нет комментария", nameof(model.Comment));
}
logger.LogInformation("Recipe. Comment:{Comment}. Id: { Id}", model.Comment, model.Id); logger.LogInformation("Recipe. Comment:{Comment}. Id: { Id}", model.Comment, model.Id);
} }
} }

View File

@ -0,0 +1,44 @@
using Microsoft.Extensions.Configuration;
using System.Net.Mail;
using System.Net;
namespace PolyclinicBusinessLogic.BusinessLogics
{
public class SendMailLogic
{
private readonly IConfiguration _configuration;
public SendMailLogic(IConfiguration configuration)
{
_configuration = configuration;
}
public void SendEmail(string toEmail, string subject, string attachmentPath)
{
var smtpSection = _configuration.GetSection("Smtp");
var client = new SmtpClient(smtpSection["Host"])
{
Port = int.Parse(smtpSection["Port"]),
Credentials = new NetworkCredential(smtpSection["Username"], smtpSection["Password"]),
EnableSsl = bool.Parse(smtpSection["EnableSsl"]),
};
var mailMessage = new MailMessage
{
From = new MailAddress(smtpSection["Username"]),
Subject = subject,
};
mailMessage.To.Add(toEmail);
if (!string.IsNullOrEmpty(attachmentPath))
{
Attachment attachment = new Attachment(attachmentPath);
mailMessage.Attachments.Add(attachment);
}
client.Send(mailMessage);
}
}
}

View File

@ -1,4 +1,8 @@
using PolyclinicContracts.BindingModels; using PolyclinicBusinessLogic.OfficePackage;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts; using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels; using PolyclinicContracts.SearchModels;
using PolyclinicContracts.StoragesContracts; using PolyclinicContracts.StoragesContracts;
@ -15,34 +19,36 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private readonly ICourseStorage courseStorage; private readonly ICourseStorage courseStorage;
private readonly ISymptomStorage symptomStorage; private readonly ISymptomStorage symptomStorage;
private readonly IRecipeStorage recipeStorage; private readonly IRecipeStorage recipeStorage;
private readonly AbstractSaveToWordCoursesByProcedures saveToWord;
private readonly AbstractSaveToExcelCoursesByProcedure saveToExcel;
private readonly AbstractSaveToPdfProcedures saveToPdf;
public SuretorReportLogic(IProcedureStorage procedureStorage, IMedicamentStorage medicamentStorage, public SuretorReportLogic(IProcedureStorage procedureStorage, IMedicamentStorage medicamentStorage,
ICourseStorage courseStorage, ISymptomStorage symptomStorage, IRecipeStorage recipeStorage) ICourseStorage courseStorage, ISymptomStorage symptomStorage, IRecipeStorage recipeStorage,
AbstractSaveToWordCoursesByProcedures saveToWord, AbstractSaveToExcelCoursesByProcedure saveToExcel,
AbstractSaveToPdfProcedures saveToPdf)
{ {
this.procedureStorage = procedureStorage; this.procedureStorage = procedureStorage;
this.medicamentStorage = medicamentStorage; this.medicamentStorage = medicamentStorage;
this.courseStorage = courseStorage; this.courseStorage = courseStorage;
this.symptomStorage = symptomStorage; this.symptomStorage = symptomStorage;
this.recipeStorage = recipeStorage; this.recipeStorage = recipeStorage;
this.saveToWord = saveToWord;
this.saveToExcel = saveToExcel;
this.saveToPdf = saveToPdf;
} }
public List<ReportCoursesByProcedureViewModel> GetProcedureCourses(ProcedureSearchModel model) public List<CourseViewModel> GetProcedureCourses(ProcedureSearchModel model)
{ {
var procedure = procedureStorage.GetElement(model); var procedure = procedureStorage.GetElement(model);
var courses = courseStorage.GetFullList(); var courses = courseStorage.GetFullList();
var recipes = recipeStorage.GetFullList(); var recipes = recipeStorage.GetFullList();
var list = new List<ReportCoursesByProcedureViewModel>(); var list = new List<CourseViewModel>();
var record = new ReportCoursesByProcedureViewModel
{
Name = procedure!.Name,
Courses = new List<(int countDays, int pillsPerDay, string comment)>()
};
using var context = new PolyclinicDatabase(); using var context = new PolyclinicDatabase();
var recipeProcedureId = context.RecipeProcedures var recipeProcedureId = context.RecipeProcedures
.Where(x => x.ProcedureId == model.Id).Select(x => x.RecipeId).ToList(); .Where(x => x.ProcedureId == model.Id).Select(x => x.RecipeId).ToList();
foreach (var recipe in recipes) foreach (var recipe in recipes)
{ {
@ -54,17 +60,16 @@ namespace PolyclinicBusinessLogic.BusinessLogics
{ {
if(recipe.CourseId == course.Id) if(recipe.CourseId == course.Id)
{ {
record.Courses.Add((course.DaysCount, course.PillsPerDay, course.Comment)); list.Add(course);
} }
} }
} }
} }
} }
list.Add(record);
return list; return list;
} }
public List<ReportProceduresViewModel> GetProcedures(ReportBindingModel model) public List<ReportProceduresViewModel> GetProceduresByMedicametsAndSymptoms()
{ {
var procedures = procedureStorage.GetFullList(); var procedures = procedureStorage.GetFullList();
var medicaments = medicamentStorage.GetFullList(); var medicaments = medicamentStorage.GetFullList();
@ -75,9 +80,10 @@ namespace PolyclinicBusinessLogic.BusinessLogics
{ {
var record = new ReportProceduresViewModel var record = new ReportProceduresViewModel
{ {
Id = procedure.Id,
ProcedureName = procedure.Name, ProcedureName = procedure.Name,
DateStartProcedure = procedure.DateStartProcedure, DateStartProcedure = procedure.DateStartProcedure,
DateStopProcedure = procedure.DateStopProcedure, DateStopProcedure = procedure.DateStopProcedure ?? DateTime.MaxValue,
MedicamentSymptom = new List<(string medicamentName, string symptomName)>() MedicamentSymptom = new List<(string medicamentName, string symptomName)>()
}; };
foreach (var medicament in medicaments) foreach (var medicament in medicaments)
@ -98,19 +104,36 @@ namespace PolyclinicBusinessLogic.BusinessLogics
return list; return list;
} }
public void SaveCoursesByProcedureToExcelFile(ReportBindingModel model) public void SaveCoursesByProcedureToExcelFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode)
{ {
throw new NotImplementedException(); saveToExcel.CreateReport(new ExcelCoursesByProceduresInfo
{
FileName = model.FileName,
Title = "Курсы по процедуре" + $" '{procedureSearchMode.Name}'",
Courses = GetProcedureCourses(procedureSearchMode)
});
} }
public void SaveCoursesByProcedureToWordFile(ReportBindingModel model) public void SaveCoursesByProcedureToWordFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode)
{ {
throw new NotImplementedException(); saveToWord.CreateDoc(new WordCoursesByProceduresInfo
{
FileName = model.FileName,
Title = "Курсы по процедуре" + $" '{procedureSearchMode.Name}'",
Courses = GetProcedureCourses(procedureSearchMode)
});
} }
public void SaveOrdersToPdfFile(ReportBindingModel model) public void SaveProceduresToPdfFile(ReportBindingModel model)
{ {
throw new NotImplementedException(); saveToPdf.CreateDoc(new PdfProceduresByMedicamentsAndSymptomsInfo
{
FileName= model.FileName,
Title = "Отчет по процедурам с расшифровкой по симптомам и лекарствам",
DateFrom = model.DateFrom!.Value,
DateTo = model.DateTo.Value,
Procedures = GetProceduresByMedicametsAndSymptoms()
});
} }
} }
} }

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger; private ILogger _logger;
private ISymptomStorage _symptomStorage; private ISymptomStorage _symptomStorage;
public SymptomLogic(ILogger logger, ISymptomStorage symptomStorage) public SymptomLogic(ILogger<SymptomLogic> logger, ISymptomStorage symptomStorage)
{ {
_logger = logger; _logger = logger;
_symptomStorage = symptomStorage; _symptomStorage = symptomStorage;
@ -58,14 +58,14 @@ namespace PolyclinicBusinessLogic.BusinessLogics
return element; return element;
} }
public List<SymptomViewModel>? ReadList(SymptomSearchModel? model) public List<SymptomViewModel> ReadList(SymptomSearchModel? model = null)
{ {
_logger.LogInformation("ReadList. Name:{Name} Id:{Id}", model?.Name, model?.Id); _logger.LogInformation("ReadList. Name:{Name} Id:{Id}", model?.Name, model?.Id);
var list = model == null ? _symptomStorage.GetFullList() : _symptomStorage.GetFilteredList(model); var list = model == null ? _symptomStorage.GetFullList() : _symptomStorage.GetFilteredList(model);
if (list == null) if (list == null)
{ {
_logger.LogWarning("ReadList return null list"); _logger.LogWarning("ReadList return null list");
return null; return new List<SymptomViewModel>();
} }
_logger.LogInformation("ReadList. Count:{Count}", list.Count); _logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;
@ -73,7 +73,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
public bool Update(SymptomBindingModel model) public bool Update(SymptomBindingModel model)
{ {
CheckModel(model); CheckModel(model, false);
if (_symptomStorage.Update(model) == null) if (_symptomStorage.Update(model) == null)
{ {
_logger.LogWarning("Update operation failed"); _logger.LogWarning("Update operation failed");

View File

@ -12,7 +12,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
private ILogger _logger; private ILogger _logger;
private IUserStorage _userStorage; private IUserStorage _userStorage;
public UserLogic(ILogger logger, IUserStorage userStorage) public UserLogic(ILogger<UserLogic> logger, IUserStorage userStorage)
{ {
_logger = logger; _logger = logger;
_userStorage = userStorage; _userStorage = userStorage;

View File

@ -0,0 +1,76 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF;
using PolyclinicContracts.ViewModels;
namespace PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports
{
public abstract class AbstractReportDiagnosesByPeriodSaveToPdf
{
public void CreateDoc(PdfDiagnosesByPeriodInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = info.PeriodString,
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "3cm", "3cm", "3cm", "4cm", "5cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Название", "Начало", "Конец", "Симптомы", "Курсы" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var diagnoseData in info.Report.DiagnosesData)
{
var diagnose = diagnoseData.Diagnose;
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
diagnose.Name,
diagnose.DateStartDiagnose.ToShortDateString(),
diagnose.DateStopDiagnose?.ToShortDateString() ?? string.Empty,
"",
""
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left,
});
int maxLength = Math.Max(diagnoseData.Symptomes.Count(), diagnoseData.Courses.Count());
for (int i = 0; i < maxLength; i++)
{
SymptomViewModel? symptom = diagnoseData.Symptomes.Count() > i ? diagnoseData.Symptomes[i] : null;
CourseViewModel? course = diagnoseData.Courses.Count() > i ? diagnoseData.Courses[i] : null;
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
"",
"",
symptom?.Name ?? string.Empty,
(course == null ? string.Empty : $"#{course.Id} {course.Comment}")
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left,
});
}
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfDiagnosesByPeriodInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfDiagnosesByPeriodInfo info);
}
}

View File

@ -0,0 +1,58 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel;
namespace PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports
{
public abstract class AbstractReportMedicamentsByDiagnosesSaveToExcel
{
public void CreateReport(ReportMedicamentsByDiagnosesInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var diagnoseMedicaments in info.ReportModel)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = diagnoseMedicaments.Diagnose.Name,
StyleInfo = ExcelStyleInfoType.Text
});
if (diagnoseMedicaments.Medicaments.Count() > 0)
{
rowIndex++;
}
foreach (var medicament in diagnoseMedicaments.Medicaments)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = medicament.Name,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(ReportMedicamentsByDiagnosesInfo info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ReportMedicamentsByDiagnosesInfo info);
}
}

View File

@ -0,0 +1,62 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word;
namespace PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports
{
public abstract class AbstractReportMedicamentsByDiagnosesSaveToWord
{
public void CreateDoc(ReportMedicamentsByDiagnosesInfo info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{
(info.Title, new WordTextProperties { Bold = true, Size = "32", })
},
TextProperties = new WordTextProperties
{
Size = "32",
JustificationType = WordJustificationType.Center
}
});
foreach (var diagnoseMedicaments in info.ReportModel)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{
(diagnoseMedicaments.Diagnose.Name, new WordTextProperties{ Size = "24"}),
},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
foreach (var med in diagnoseMedicaments.Medicaments)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{
(med.Name, new WordTextProperties{ Size = "24"}),
},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
}
}
SaveWord(info);
}
protected abstract void CreateWord(ReportMedicamentsByDiagnosesInfo info);
protected abstract void CreateParagraph(WordParagraph paragraph);
protected abstract void SaveWord(ReportMedicamentsByDiagnosesInfo info);
}
}

View File

@ -0,0 +1,65 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel;
namespace PolyclinicBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcelCoursesByProcedure
{
public void CreateReport(ExcelCoursesByProceduresInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var course in info.Courses)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Количество пилюль в день: " + course.PillsPerDay.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = "Количество дней: " + course.DaysCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
/// <summary>
/// Создание excel-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateExcel(ExcelCoursesByProceduresInfo info);
/// <summary>
/// Добавляем новую ячейку в лист
/// </summary>
/// <param name="cellParameters"></param>
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
/// <summary>
/// Объединение ячеек
/// </summary>
/// <param name="mergeParameters"></param>
protected abstract void MergeCells(ExcelMergeParameters excelParams);
/// <summary>
/// Сохранение файла
/// </summary>
/// <param name="info"></param>
protected abstract void SaveExcel(ExcelCoursesByProceduresInfo info);
}
}

View File

@ -0,0 +1,76 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF;
namespace PolyclinicBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfProcedures
{
public void CreateDoc(PdfProceduresByMedicamentsAndSymptomsInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "3cm", "4cm", "4cm", "4cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Период 'с'", "Период 'до'", "Процедура", "Лекарство", "Симптом" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var procedure in info.Procedures)
{
// Добавление строки с основной информацией о процедуре
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
procedure.Id.ToString(),
procedure.DateStartProcedure.ToShortDateString(),
procedure.DateStopProcedure?.ToShortDateString() ?? "нет даты окончания процедуры",
procedure.ProcedureName,
"",
""
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left,
});
foreach (var ms in procedure.MedicamentSymptom)
{
// Добавление строки для каждого лекарства и симптома без дублирования названия процедуры
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
"",
"",
"",
ms.medicamentName,
ms.symptomName
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left,
});
}
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfProceduresByMedicamentsAndSymptomsInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfProceduresByMedicamentsAndSymptomsInfo info);
}
}

View File

@ -0,0 +1,59 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word;
namespace PolyclinicBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWordCoursesByProcedures
{
public void CreateDoc(WordCoursesByProceduresInfo info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{
(info.Title, new WordTextProperties { Bold = true, Size = "32", })
},
TextProperties = new WordTextProperties
{
Size = "32",
JustificationType = WordJustificationType.Center
}
});
foreach (var course in info.Courses)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{
("Количество пилюль в день: " + course.PillsPerDay.ToString() + " единиц\t", new WordTextProperties{ Size = "24"}),
("Количество дней приёма: " + course.DaysCount.ToString() + " дней", new WordTextProperties{ Size = "24"}),
},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
SaveWord(info);
}
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateWord(WordCoursesByProceduresInfo info);
/// <summary>
/// Создание абзаца с текстом
/// </summary>
/// <param name="paragraph"></param>
/// <returns></returns>
protected abstract void CreateParagraph(WordParagraph paragraph);
/// <summary>
/// Сохранение файла
/// </summary>
/// <param name="info"></param>
protected abstract void SaveWord(WordCoursesByProceduresInfo info);
}
}

View File

@ -0,0 +1,9 @@
namespace PolyclinicBusinessLogic.OfficePackage.HelperEnums
{
public enum ExcelStyleInfoType
{
Title,
Text,
TextWithBorder
}
}

View File

@ -0,0 +1,9 @@
namespace PolyclinicBusinessLogic.OfficePackage.HelperEnums
{
public enum PdfParagraphAlignmentType
{
Center,
Left,
Rigth
}
}

View File

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace PolyclinicBusinessLogic.OfficePackage.HelperEnums
{
public enum ReportType
{
Web = 0,
Email = 1,
Word = 2,
Excel = 3,
Pdf = 4,
}
}

View File

@ -0,0 +1,8 @@
namespace PolyclinicBusinessLogic.OfficePackage.HelperEnums
{
public enum WordJustificationType
{
Center,
Both
}
}

View File

@ -0,0 +1,13 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel
{
public class ExcelCellParameters
{
public string ColumnName { get; set; } = string.Empty;
public uint RowIndex { get; set; }
public string Text { get; set; } = string.Empty;
public string CellReference => $"{ColumnName}{RowIndex}";
public ExcelStyleInfoType StyleInfo { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using PolyclinicContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel
{
public class ExcelCoursesByProceduresInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string ProcedureName { get; set; } = string.Empty;
public List<CourseViewModel> Courses { get; set; } = new();
}
}

View File

@ -0,0 +1,9 @@
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel
{
public class ExcelMergeParameters
{
public string CellFromName { get; set; } = string.Empty;
public string CellToName { get; set; } = string.Empty;
public string Merge => $"{CellFromName}:{CellToName}";
}
}

View File

@ -0,0 +1,14 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF
{
public class PdfDiagnosesByPeriodInfo
{
public string Title { get; set; } = string.Empty;
public string FileName { get; set; } = string.Empty;
public string PeriodString { get; set; } = string.Empty;
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public ReportDiagnosesByPeriodViewModel Report { get; set; } = new();
}
}

View File

@ -0,0 +1,11 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF
{
public class PdfParagraph
{
public string Text { get; set; } = string.Empty;
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF
{
public class PdfProceduresByMedicamentsAndSymptomsInfo
{
public string Title { get; set; } = string.Empty;
public string FileName { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportProceduresViewModel> Procedures { get; set; } = new();
}
}

View File

@ -0,0 +1,11 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF
{
public class PdfRowParameters
{
public List<string> Texts { get; set; } = new();
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels
{
public class ReportMedicamentsByDiagnosesInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportMedicamentsByDiagnoseViewModel> ReportModel { get; set; } = new();
}
}

View File

@ -0,0 +1,12 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.Word
{
public class WordCoursesByProceduresInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string ProcedureName { get; set; } = string.Empty;
public List<CourseViewModel> Courses { get; set; } = new();
}
}

View File

@ -0,0 +1,8 @@
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.Word
{
public class WordParagraph
{
public List<(string, WordTextProperties)> Texts { get; set; } = new();
public WordTextProperties? TextProperties { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.Word
{
public class WordTextProperties
{
public string Size { get; set; } = string.Empty;
public bool Bold { get; set; }
public WordJustificationType JustificationType { get; set; }
}
}

View File

@ -0,0 +1,99 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports;
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF;
namespace PolyclinicBusinessLogic.OfficePackage.Implements.ImplementerReports
{
public class ReportDiagnosesByPeriodSaveToPdf : AbstractReportDiagnosesByPeriodSaveToPdf
{
private Document? _document;
private Section? _section;
private Table? _table;
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
{
return type switch
{
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
_ => ParagraphAlignment.Justify,
};
}
/// <summary>
/// Создание стилей для документа
/// </summary>
/// <param name="document"></param>
private static void DefineStyles(Document document)
{
var style = document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
style = document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
}
protected override void CreatePdf(PdfDiagnosesByPeriodInfo info)
{
_document = new Document();
DefineStyles(_document);
_section = _document.AddSection();
}
protected override void CreateParagraph(PdfParagraph pdfParagraph)
{
if (_section == null)
{
return;
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
protected override void CreateTable(List<string> columns)
{
if (_document == null)
{
return;
}
_table = _document.LastSection.AddTable();
foreach (var elem in columns)
{
_table.AddColumn(elem);
}
}
protected override void CreateRow(PdfRowParameters rowParameters)
{
if (_table == null)
{
return;
}
var row = _table.AddRow();
for (int i = 0; i < rowParameters.Texts.Count; ++i)
{
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
if (!string.IsNullOrEmpty(rowParameters.Style))
{
row.Cells[i].Style = rowParameters.Style;
}
Unit borderWidth = 0.5;
row.Cells[i].Borders.Left.Width = borderWidth;
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}
}
protected override void SavePdf(PdfDiagnosesByPeriodInfo info)
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -0,0 +1,336 @@
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel;
using PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports;
using PolyclinicBusinessLogic.OfficePackage.HelperModels;
namespace PolyclinicBusinessLogic.OfficePackage.Implements.ImplementerReports
{
public class ReportMedicamentsByDiagnosesSaveToExcel : AbstractReportMedicamentsByDiagnosesSaveToExcel
{
private SpreadsheetDocument? _spreadsheetDocument;
private SharedStringTablePart? _shareStringPart;
private Worksheet? _worksheet;
/// <summary>
/// Настройка стилей для файла
/// </summary>
/// <param name="workbookpart"></param>
private static void CreateStyles(WorkbookPart workbookpart)
{
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
sp.Stylesheet = new Stylesheet();
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
var fontUsual = new Font();
fontUsual.Append(new FontSize() { Val = 12D });
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Theme = 1U });
fontUsual.Append(new FontName() { Val = "Times New Roman" });
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
var fontTitle = new Font();
fontTitle.Append(new Bold());
fontTitle.Append(new FontSize() { Val = 14D });
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Theme = 1U });
fontTitle.Append(new FontName() { Val = "Times New Roman" });
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
fonts.Append(fontUsual);
fonts.Append(fontTitle);
var fills = new Fills() { Count = 2U };
var fill1 = new Fill();
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
var fill2 = new Fill();
fill2.Append(new PatternFill()
{
PatternType = PatternValues.Gray125
});
fills.Append(fill1);
fills.Append(fill2);
var borders = new Borders() { Count = 2U };
var borderNoBorder = new Border();
borderNoBorder.Append(new LeftBorder());
borderNoBorder.Append(new RightBorder());
borderNoBorder.Append(new TopBorder());
borderNoBorder.Append(new BottomBorder());
borderNoBorder.Append(new DiagonalBorder());
var borderThin = new Border();
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
var rightBorder = new RightBorder()
{
Style = BorderStyleValues.Thin
};
rightBorder.Append(new
DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
var bottomBorder = new BottomBorder()
{
Style =
BorderStyleValues.Thin
};
bottomBorder.Append(new
DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
borderThin.Append(leftBorder);
borderThin.Append(rightBorder);
borderThin.Append(topBorder);
borderThin.Append(bottomBorder);
borderThin.Append(new DiagonalBorder());
borders.Append(borderNoBorder);
borders.Append(borderThin);
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
var cellFormatStyle = new CellFormat()
{
NumberFormatId = 0U,
FontId
= 0U,
FillId = 0U,
BorderId = 0U
};
cellStyleFormats.Append(cellFormatStyle);
var cellFormats = new CellFormats() { Count = 3U };
var cellFormatFont = new CellFormat()
{
NumberFormatId = 0U,
FontId =
0U,
FillId = 0U,
BorderId = 0U,
FormatId = 0U,
ApplyFont = true
};
var cellFormatFontAndBorder = new CellFormat()
{
NumberFormatId = 0U,
FontId = 0U,
FillId = 0U,
BorderId = 1U,
FormatId = 0U,
ApplyFont = true,
ApplyBorder = true
};
var cellFormatTitle = new CellFormat()
{
NumberFormatId = 0U,
FontId
= 1U,
FillId = 0U,
BorderId = 0U,
FormatId = 0U,
Alignment = new Alignment()
{
Vertical = VerticalAlignmentValues.Center,
WrapText = true,
Horizontal =
HorizontalAlignmentValues.Center
},
ApplyFont = true
};
cellFormats.Append(cellFormatFont);
cellFormats.Append(cellFormatFontAndBorder);
cellFormats.Append(cellFormatTitle);
var cellStyles = new CellStyles() { Count = 1U };
cellStyles.Append(new CellStyle()
{
Name = "Normal",
FormatId = 0U,
BuiltinId = 0U
});
var differentialFormats = new
DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
{ Count = 0U };
var tableStyles = new TableStyles()
{
Count = 0U,
DefaultTableStyle = "TableStyleMedium2",
DefaultPivotStyle = "PivotStyleLight16"
};
var stylesheetExtensionList = new StylesheetExtensionList();
var stylesheetExtension1 = new StylesheetExtension()
{
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
};
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
stylesheetExtension1.Append(new SlicerStyles()
{
DefaultSlicerStyle = "SlicerStyleLight1"
});
var stylesheetExtension2 = new StylesheetExtension()
{
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
};
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
stylesheetExtension2.Append(new TimelineStyles()
{
DefaultTimelineStyle = "TimeSlicerStyleLight1"
});
stylesheetExtensionList.Append(stylesheetExtension1);
stylesheetExtensionList.Append(stylesheetExtension2);
sp.Stylesheet.Append(fonts);
sp.Stylesheet.Append(fills);
sp.Stylesheet.Append(borders);
sp.Stylesheet.Append(cellStyleFormats);
sp.Stylesheet.Append(cellFormats);
sp.Stylesheet.Append(cellStyles);
sp.Stylesheet.Append(differentialFormats);
sp.Stylesheet.Append(tableStyles);
sp.Stylesheet.Append(stylesheetExtensionList);
}
/// <summary>
/// Получение номера стиля из типа
/// </summary>
/// <param name="styleInfo"></param>
/// <returns></returns>
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
{
return styleInfo switch
{
ExcelStyleInfoType.Title => 2U,
ExcelStyleInfoType.TextWithBorder => 1U,
ExcelStyleInfoType.Text => 0U,
_ => 0U,
};
}
protected override void CreateExcel(ReportMedicamentsByDiagnosesInfo info)
{
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
SpreadsheetDocumentType.Workbook);
// Создаем книгу (в ней хранятся листы)
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
CreateStyles(workbookpart);
// Получаем/создаем хранилище текстов для книги
_shareStringPart =
_spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
?
_spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
:
_spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
// Создаем SharedStringTable, если его нет
if (_shareStringPart.SharedStringTable == null)
{
_shareStringPart.SharedStringTable = new SharedStringTable();
}
// Создаем лист в книгу
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
// Добавляем лист в книгу
var sheets =
_spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
var sheet = new Sheet()
{
Id =
_spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Лист"
};
sheets.Append(sheet);
_worksheet = worksheetPart.Worksheet;
}
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
{
if (_worksheet == null || _shareStringPart == null)
{
return;
}
var sheetData = _worksheet.GetFirstChild<SheetData>();
if (sheetData == null)
{
return;
}
// Ищем строку, либо добавляем ее
Row row;
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
{
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
}
else
{
row = new Row() { RowIndex = excelParams.RowIndex };
sheetData.Append(row);
}
// Ищем нужную ячейку
Cell cell;
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
{
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
}
else
{
// Все ячейки должны быть последовательно друг за другом расположены
// нужно определить, после какой вставлять
Cell? refCell = null;
foreach (Cell rowCell in row.Elements<Cell>())
{
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
{
refCell = rowCell;
break;
}
}
var newCell = new Cell()
{
CellReference = excelParams.CellReference
};
row.InsertBefore(newCell, refCell);
cell = newCell;
}
// вставляем новый текст
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
_shareStringPart.SharedStringTable.Save();
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
}
protected override void MergeCells(ExcelMergeParameters excelParams)
{
if (_worksheet == null)
{
return;
}
MergeCells mergeCells;
if (_worksheet.Elements<MergeCells>().Any())
{
mergeCells = _worksheet.Elements<MergeCells>().First();
}
else
{
mergeCells = new MergeCells();
if (_worksheet.Elements<CustomSheetView>().Any())
{
_worksheet.InsertAfter(mergeCells,
_worksheet.Elements<CustomSheetView>().First());
}
else
{
_worksheet.InsertAfter(mergeCells,
_worksheet.Elements<SheetData>().First());
}
}
var mergeCell = new MergeCell()
{
Reference = new StringValue(excelParams.Merge)
};
mergeCells.Append(mergeCell);
}
protected override void SaveExcel(ReportMedicamentsByDiagnosesInfo info)
{
if (_spreadsheetDocument == null)
{
return;
}
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
_spreadsheetDocument.Dispose();
}
}
}

View File

@ -0,0 +1,121 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports;
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word;
namespace PolyclinicBusinessLogic.OfficePackage.Implements.ImplementerReports
{
public class ReportMedicamentsByDiagnosesSaveToWord : AbstractReportMedicamentsByDiagnosesSaveToWord
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
/// <summary>
/// Получение типа выравнивания
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private static JustificationValues GetJustificationValues(WordJustificationType type)
{
return type switch
{
WordJustificationType.Both => JustificationValues.Both,
WordJustificationType.Center => JustificationValues.Center,
_ => JustificationValues.Left,
};
}
/// <summary>
/// Настройки страницы
/// </summary>
/// <returns></returns>
private static SectionProperties CreateSectionProperties()
{
var properties = new SectionProperties();
var pageSize = new PageSize
{
Orient = PageOrientationValues.Portrait
};
properties.AppendChild(pageSize);
return properties;
}
/// <summary>
/// Задание форматирования для абзаца
/// </summary>
/// <param name="paragraphProperties"></param>
/// <returns></returns>
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
{
if (paragraphProperties == null)
{
return null;
}
var properties = new ParagraphProperties();
properties.AppendChild(new Justification()
{
Val = GetJustificationValues(paragraphProperties.JustificationType)
});
properties.AppendChild(new SpacingBetweenLines
{
LineRule = LineSpacingRuleValues.Auto
});
properties.AppendChild(new Indentation());
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
if (!string.IsNullOrEmpty(paragraphProperties.Size))
{
paragraphMarkRunProperties.AppendChild(new FontSize
{
Val = paragraphProperties.Size
});
}
properties.AppendChild(paragraphMarkRunProperties);
return properties;
}
protected override void CreateWord(ReportMedicamentsByDiagnosesInfo info)
{
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
}
protected override void CreateParagraph(WordParagraph paragraph)
{
if (_docBody == null || paragraph == null)
{
return;
}
var docParagraph = new Paragraph();
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
foreach (var run in paragraph.Texts)
{
var docRun = new Run();
var properties = new RunProperties();
properties.AppendChild(new FontSize { Val = run.Item2.Size });
if (run.Item2.Bold)
{
properties.AppendChild(new Bold());
}
docRun.AppendChild(properties);
docRun.AppendChild(new Text
{
Text = run.Item1,
Space = SpaceProcessingModeValues.Preserve
});
docParagraph.AppendChild(docRun);
}
_docBody.AppendChild(docParagraph);
}
protected override void SaveWord(ReportMedicamentsByDiagnosesInfo info)
{
if (_docBody == null || _wordDocument == null)
{
return;
}
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Dispose();
}
}
}

View File

@ -0,0 +1,334 @@
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Excel;
namespace PolyclinicBusinessLogic.OfficePackage.Implements
{
public class SaveToExcelCoursesByProcedure : AbstractSaveToExcelCoursesByProcedure
{
private SpreadsheetDocument? _spreadsheetDocument;
private SharedStringTablePart? _shareStringPart;
private Worksheet? _worksheet;
/// <summary>
/// Настройка стилей для файла
/// </summary>
/// <param name="workbookpart"></param>
private static void CreateStyles(WorkbookPart workbookpart)
{
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
sp.Stylesheet = new Stylesheet();
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
var fontUsual = new Font();
fontUsual.Append(new FontSize() { Val = 12D });
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Theme = 1U });
fontUsual.Append(new FontName() { Val = "Times New Roman" });
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
var fontTitle = new Font();
fontTitle.Append(new Bold());
fontTitle.Append(new FontSize() { Val = 14D });
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Theme = 1U });
fontTitle.Append(new FontName() { Val = "Times New Roman" });
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
fonts.Append(fontUsual);
fonts.Append(fontTitle);
var fills = new Fills() { Count = 2U };
var fill1 = new Fill();
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
var fill2 = new Fill();
fill2.Append(new PatternFill()
{
PatternType = PatternValues.Gray125
});
fills.Append(fill1);
fills.Append(fill2);
var borders = new Borders() { Count = 2U };
var borderNoBorder = new Border();
borderNoBorder.Append(new LeftBorder());
borderNoBorder.Append(new RightBorder());
borderNoBorder.Append(new TopBorder());
borderNoBorder.Append(new BottomBorder());
borderNoBorder.Append(new DiagonalBorder());
var borderThin = new Border();
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
var rightBorder = new RightBorder()
{
Style = BorderStyleValues.Thin
};
rightBorder.Append(new
DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
var bottomBorder = new BottomBorder()
{
Style =
BorderStyleValues.Thin
};
bottomBorder.Append(new
DocumentFormat.OpenXml.Office2010.Excel.Color()
{ Indexed = 64U });
borderThin.Append(leftBorder);
borderThin.Append(rightBorder);
borderThin.Append(topBorder);
borderThin.Append(bottomBorder);
borderThin.Append(new DiagonalBorder());
borders.Append(borderNoBorder);
borders.Append(borderThin);
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
var cellFormatStyle = new CellFormat()
{
NumberFormatId = 0U,
FontId
= 0U,
FillId = 0U,
BorderId = 0U
};
cellStyleFormats.Append(cellFormatStyle);
var cellFormats = new CellFormats() { Count = 3U };
var cellFormatFont = new CellFormat()
{
NumberFormatId = 0U,
FontId =
0U,
FillId = 0U,
BorderId = 0U,
FormatId = 0U,
ApplyFont = true
};
var cellFormatFontAndBorder = new CellFormat()
{
NumberFormatId = 0U,
FontId = 0U,
FillId = 0U,
BorderId = 1U,
FormatId = 0U,
ApplyFont = true,
ApplyBorder = true
};
var cellFormatTitle = new CellFormat()
{
NumberFormatId = 0U,
FontId
= 1U,
FillId = 0U,
BorderId = 0U,
FormatId = 0U,
Alignment = new Alignment()
{
Vertical = VerticalAlignmentValues.Center,
WrapText = true,
Horizontal =
HorizontalAlignmentValues.Center
},
ApplyFont = true
};
cellFormats.Append(cellFormatFont);
cellFormats.Append(cellFormatFontAndBorder);
cellFormats.Append(cellFormatTitle);
var cellStyles = new CellStyles() { Count = 1U };
cellStyles.Append(new CellStyle()
{
Name = "Normal",
FormatId = 0U,
BuiltinId = 0U
});
var differentialFormats = new
DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
{ Count = 0U };
var tableStyles = new TableStyles()
{
Count = 0U,
DefaultTableStyle = "TableStyleMedium2",
DefaultPivotStyle = "PivotStyleLight16"
};
var stylesheetExtensionList = new StylesheetExtensionList();
var stylesheetExtension1 = new StylesheetExtension()
{
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
};
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
stylesheetExtension1.Append(new SlicerStyles()
{
DefaultSlicerStyle = "SlicerStyleLight1"
});
var stylesheetExtension2 = new StylesheetExtension()
{
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
};
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
stylesheetExtension2.Append(new TimelineStyles()
{
DefaultTimelineStyle = "TimeSlicerStyleLight1"
});
stylesheetExtensionList.Append(stylesheetExtension1);
stylesheetExtensionList.Append(stylesheetExtension2);
sp.Stylesheet.Append(fonts);
sp.Stylesheet.Append(fills);
sp.Stylesheet.Append(borders);
sp.Stylesheet.Append(cellStyleFormats);
sp.Stylesheet.Append(cellFormats);
sp.Stylesheet.Append(cellStyles);
sp.Stylesheet.Append(differentialFormats);
sp.Stylesheet.Append(tableStyles);
sp.Stylesheet.Append(stylesheetExtensionList);
}
/// <summary>
/// Получение номера стиля из типа
/// </summary>
/// <param name="styleInfo"></param>
/// <returns></returns>
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
{
return styleInfo switch
{
ExcelStyleInfoType.Title => 2U,
ExcelStyleInfoType.TextWithBorder => 1U,
ExcelStyleInfoType.Text => 0U,
_ => 0U,
};
}
protected override void CreateExcel(ExcelCoursesByProceduresInfo info)
{
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
SpreadsheetDocumentType.Workbook);
// Создаем книгу (в ней хранятся листы)
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
CreateStyles(workbookpart);
// Получаем/создаем хранилище текстов для книги
_shareStringPart =
_spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
?
_spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
:
_spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
// Создаем SharedStringTable, если его нет
if (_shareStringPart.SharedStringTable == null)
{
_shareStringPart.SharedStringTable = new SharedStringTable();
}
// Создаем лист в книгу
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
// Добавляем лист в книгу
var sheets =
_spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
var sheet = new Sheet()
{
Id =
_spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Лист"
};
sheets.Append(sheet);
_worksheet = worksheetPart.Worksheet;
}
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
{
if (_worksheet == null || _shareStringPart == null)
{
return;
}
var sheetData = _worksheet.GetFirstChild<SheetData>();
if (sheetData == null)
{
return;
}
// Ищем строку, либо добавляем ее
Row row;
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
{
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
}
else
{
row = new Row() { RowIndex = excelParams.RowIndex };
sheetData.Append(row);
}
// Ищем нужную ячейку
Cell cell;
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
{
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
}
else
{
// Все ячейки должны быть последовательно друг за другом расположены
// нужно определить, после какой вставлять
Cell? refCell = null;
foreach (Cell rowCell in row.Elements<Cell>())
{
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
{
refCell = rowCell;
break;
}
}
var newCell = new Cell()
{
CellReference = excelParams.CellReference
};
row.InsertBefore(newCell, refCell);
cell = newCell;
}
// вставляем новый текст
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
_shareStringPart.SharedStringTable.Save();
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
}
protected override void MergeCells(ExcelMergeParameters excelParams)
{
if (_worksheet == null)
{
return;
}
MergeCells mergeCells;
if (_worksheet.Elements<MergeCells>().Any())
{
mergeCells = _worksheet.Elements<MergeCells>().First();
}
else
{
mergeCells = new MergeCells();
if (_worksheet.Elements<CustomSheetView>().Any())
{
_worksheet.InsertAfter(mergeCells,
_worksheet.Elements<CustomSheetView>().First());
}
else
{
_worksheet.InsertAfter(mergeCells,
_worksheet.Elements<SheetData>().First());
}
}
var mergeCell = new MergeCell()
{
Reference = new StringValue(excelParams.Merge)
};
mergeCells.Append(mergeCell);
}
protected override void SaveExcel(ExcelCoursesByProceduresInfo info)
{
if (_spreadsheetDocument == null)
{
return;
}
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
_spreadsheetDocument.Dispose();
}
}
}

View File

@ -0,0 +1,98 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF;
namespace PolyclinicBusinessLogic.OfficePackage.Implements
{
public class SaveToPdfProcedures : AbstractSaveToPdfProcedures
{
private Document? _document;
private Section? _section;
private Table? _table;
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
{
return type switch
{
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
_ => ParagraphAlignment.Justify,
};
}
/// <summary>
/// Создание стилей для документа
/// </summary>
/// <param name="document"></param>
private static void DefineStyles(Document document)
{
var style = document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
style = document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
}
protected override void CreatePdf(PdfProceduresByMedicamentsAndSymptomsInfo info)
{
_document = new Document();
DefineStyles(_document);
_section = _document.AddSection();
}
protected override void CreateParagraph(PdfParagraph pdfParagraph)
{
if (_section == null)
{
return;
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
protected override void CreateTable(List<string> columns)
{
if (_document == null)
{
return;
}
_table = _document.LastSection.AddTable();
foreach (var elem in columns)
{
_table.AddColumn(elem);
}
}
protected override void CreateRow(PdfRowParameters rowParameters)
{
if (_table == null)
{
return;
}
var row = _table.AddRow();
for (int i = 0; i < rowParameters.Texts.Count; ++i)
{
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
if (!string.IsNullOrEmpty(rowParameters.Style))
{
row.Cells[i].Style = rowParameters.Style;
}
Unit borderWidth = 0.5;
row.Cells[i].Borders.Left.Width = borderWidth;
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}
}
protected override void SavePdf(PdfProceduresByMedicamentsAndSymptomsInfo info)
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -0,0 +1,122 @@
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicBusinessLogic.OfficePackage.HelperModels.Word;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace PolyclinicBusinessLogic.OfficePackage.Implements
{
public class SaveToWordCoursesByProcedure : AbstractSaveToWordCoursesByProcedures
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
/// <summary>
/// Получение типа выравнивания
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private static JustificationValues GetJustificationValues(WordJustificationType type)
{
return type switch
{
WordJustificationType.Both => JustificationValues.Both,
WordJustificationType.Center => JustificationValues.Center,
_ => JustificationValues.Left,
};
}
/// <summary>
/// Настройки страницы
/// </summary>
/// <returns></returns>
private static SectionProperties CreateSectionProperties()
{
var properties = new SectionProperties();
var pageSize = new PageSize
{
Orient = PageOrientationValues.Portrait
};
properties.AppendChild(pageSize);
return properties;
}
/// <summary>
/// Задание форматирования для абзаца
/// </summary>
/// <param name="paragraphProperties"></param>
/// <returns></returns>
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
{
if (paragraphProperties == null)
{
return null;
}
var properties = new ParagraphProperties();
properties.AppendChild(new Justification()
{
Val = GetJustificationValues(paragraphProperties.JustificationType)
});
properties.AppendChild(new SpacingBetweenLines
{
LineRule = LineSpacingRuleValues.Auto
});
properties.AppendChild(new Indentation());
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
if (!string.IsNullOrEmpty(paragraphProperties.Size))
{
paragraphMarkRunProperties.AppendChild(new FontSize
{
Val = paragraphProperties.Size
});
}
properties.AppendChild(paragraphMarkRunProperties);
return properties;
}
protected override void CreateWord(WordCoursesByProceduresInfo info)
{
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
}
protected override void CreateParagraph(WordParagraph paragraph)
{
if (_docBody == null || paragraph == null)
{
return;
}
var docParagraph = new Paragraph();
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
foreach (var run in paragraph.Texts)
{
var docRun = new Run();
var properties = new RunProperties();
properties.AppendChild(new FontSize { Val = run.Item2.Size });
if (run.Item2.Bold)
{
properties.AppendChild(new Bold());
}
docRun.AppendChild(properties);
docRun.AppendChild(new Text
{
Text = run.Item1,
Space = SpaceProcessingModeValues.Preserve
});
docParagraph.AppendChild(docRun);
}
_docBody.AppendChild(docParagraph);
}
protected override void SaveWord(WordCoursesByProceduresInfo info)
{
if (_docBody == null || _wordDocument == null)
{
return;
}
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Dispose();
}
}
}

View File

@ -7,7 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.9" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BindingModels
{ {
public int DaysCount { get; set; } public int DaysCount { get; set; }
public int PillsPerDay { get; set; } public int PillsPerDay { get; set; }
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
public Dictionary<int, IDiagnoseModel> CourseDiagnoses { get; set; } = new(); public Dictionary<int, IDiagnoseModel> CourseDiagnoses { get; set; } = new();
public int Id { get; set; } public int Id { get; set; }
} }

View File

@ -5,10 +5,10 @@ namespace PolyclinicContracts.BindingModels
public class DiagnoseBindingModel : IDiagnoseModel public class DiagnoseBindingModel : IDiagnoseModel
{ {
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
public int Id { get; set; } public int Id { get; set; }
public DateTime DateStartDiagnose { get; } public DateTime DateStartDiagnose { get; set; }
public DateTime? DateStopDiagnose { get; } public DateTime? DateStopDiagnose { get; set; }
} }
} }

View File

@ -6,8 +6,8 @@ namespace PolyclinicContracts.BindingModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int? SymptomId { get; set; } public int? SymptomId { get; set; }
public int ProcedureId { get; set; } public int? ProcedureId { get; set; }
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
} }
} }

View File

@ -7,7 +7,7 @@ namespace PolyclinicContracts.BindingModels
public int Id { get; set; } public int Id { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
public DateTime DateStartProcedure { get; set; } = DateTime.Now; public DateTime DateStartProcedure { get; set; } = DateTime.Now;
public DateTime? DateStopProcedure { get; set; } public DateTime? DateStopProcedure { get; set; }

View File

@ -7,7 +7,7 @@ namespace PolyclinicContracts.BindingModels
public int Id { get; set; } public int Id { get; set; }
public int? CourseId { get; set; } public int? CourseId { get; set; }
public int ProceduresCount { get; set; } public int ProceduresCount { get; set; }
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new(); public Dictionary<int, IProcedureModel> RecipeProcedures { get; set; } = new();
} }
} }

View File

@ -1,15 +1,33 @@
using System; using static System.Net.Mime.MediaTypeNames;
using System.Collections.Generic; using System.Reflection;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicContracts.BindingModels namespace PolyclinicContracts.BindingModels
{ {
public class ReportBindingModel public class ReportBindingModel
{ {
public string FileName { get; set; } = string.Empty; public string? FileName { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
public string GetPeriodString()
{
string txt = "";
if (DateFrom == null && DateTo == null)
{
txt = "за все время";
}
else if (DateFrom == null)
{
txt = $"по {DateTo?.ToShortDateString()}";
}
else if (DateTo == null)
{
txt = $"с {DateFrom?.ToShortDateString()}";
}
else
{
txt = $"с {DateFrom?.ToShortDateString()} по {DateTo?.ToShortDateString()}";
}
return txt;
}
} }
} }

View File

@ -5,7 +5,7 @@ namespace PolyclinicContracts.BindingModels
public class SymptomBindingModel : ISymptomModel public class SymptomBindingModel : ISymptomModel
{ {
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
public Dictionary<int, IDiagnoseModel> SymptomDiagnoses { get; set; } = new(); public Dictionary<int, IDiagnoseModel> SymptomDiagnoses { get; set; } = new();
public int Id { get; set; } public int Id { get; set; }
} }

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface ICourseLogic public interface ICourseLogic
{ {
List<CourseViewModel>? ReadList(CourseSearchModel? model); List<CourseViewModel> ReadList(CourseSearchModel? model = null);
CourseViewModel? ReadElement(CourseSearchModel model); CourseViewModel? ReadElement(CourseSearchModel model);
bool Create(CourseBindingModel model); bool Create(CourseBindingModel model);
bool Update(CourseBindingModel model); bool Update(CourseBindingModel model);

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface IDiagnoseLogic public interface IDiagnoseLogic
{ {
List<DiagnoseViewModel>? ReadList(DiagnoseSearchModel? model); List<DiagnoseViewModel> ReadList(DiagnoseSearchModel? model = null);
DiagnoseViewModel? ReadElement(DiagnoseSearchModel model); DiagnoseViewModel? ReadElement(DiagnoseSearchModel model);
bool Create(DiagnoseBindingModel model); bool Create(DiagnoseBindingModel model);
bool Update(DiagnoseBindingModel model); bool Update(DiagnoseBindingModel model);

View File

@ -1,14 +1,15 @@
using PolyclinicContracts.BindingModels; using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels; using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
namespace PolyclinicContracts.BusinessLogicsContracts namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface IImplementerReportLogic public interface IImplementerReportLogic
{ {
List<ReportDiagnoseWithCoursesAndSymptomesViewModel> GetDiagnoses(); ReportDiagnosesByPeriodViewModel GetReportDiagnosesByPeriod(DateTime? dateStart, DateTime? dateEnd);
List<ReportMedicamentsByDiagnoseViewModel> GetMedicamentsByDiagnoses(ReportBindingModel model); List<ReportMedicamentsByDiagnoseViewModel> GetReportMedicamentsByDiagnoses(int[] diagnosesIds);
void SaveSecuresToWordFile(ReportBindingModel model); void SaveReportMedicamentsByDiagnosesToWordFile(ReportBindingModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel);
void SaveSecureComponentToExcelFile(ReportBindingModel model); void SaveReportMedicamentsByDiagnosesToExcelFile(ReportBindingModel reportInfo, List<ReportMedicamentsByDiagnoseViewModel> reportModel);
void SaveOrdersToPdfFile(ReportBindingModel model); void SaveReportDiagnosesByPeriodToPdfFile(ReportBindingModel reportInfo, ReportDiagnosesByPeriodViewModel reportModel);
} }
} }

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface IProcedureLogic public interface IProcedureLogic
{ {
List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model); List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model = null);
ProcedureViewModel? ReadElement(ProcedureSearchModel model); ProcedureViewModel? ReadElement(ProcedureSearchModel model);
bool Create(ProcedureBindingModel model); bool Create(ProcedureBindingModel model);
bool Update(ProcedureBindingModel model); bool Update(ProcedureBindingModel model);

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface IRecipeLogic public interface IRecipeLogic
{ {
List<RecipeViewModel>? ReadList(RecipeSearchModel? model); List<RecipeViewModel>? ReadList(RecipeSearchModel? model = null);
RecipeViewModel? ReadElement(RecipeSearchModel model); RecipeViewModel? ReadElement(RecipeSearchModel model);
bool Create(RecipeBindingModel model); bool Create(RecipeBindingModel model);
bool Update(RecipeBindingModel model); bool Update(RecipeBindingModel model);

View File

@ -12,30 +12,34 @@ namespace PolyclinicContracts.BusinessLogicsContracts
public interface ISuretorReportLogic public interface ISuretorReportLogic
{ {
/// <summary> /// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются /// Получение данных (списка) курсов по выбранным процедурам
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
List<ReportCoursesByProcedureViewModel> GetProcedureCourses(ProcedureSearchModel model); List<CourseViewModel> GetProcedureCourses(ProcedureSearchModel model);
/// <summary> /// <summary>
/// Получение списка заказов за определенный период /// Получение списка процедур
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
List<ReportProceduresViewModel> GetProcedures(ReportBindingModel model); List<ReportProceduresViewModel> GetProceduresByMedicametsAndSymptoms();
/// <summary> /// <summary>
/// Сохранение компонент в файл-Word /// Сохранение курсов по процедурам в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveCoursesByProcedureToWordFile(ReportBindingModel model); void SaveCoursesByProcedureToWordFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode);
/// <summary> /// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel /// Сохранение курсов по процедурам в файл-Excel
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveCoursesByProcedureToExcelFile(ReportBindingModel model); void SaveCoursesByProcedureToExcelFile(ReportBindingModel model, ProcedureSearchModel procedureSearchMode);
/// <summary> /// <summary>
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveOrdersToPdfFile(ReportBindingModel model); void SaveProceduresToPdfFile(ReportBindingModel model);
} }
} }

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface ISymptomLogic public interface ISymptomLogic
{ {
List<SymptomViewModel>? ReadList(SymptomSearchModel? model); List<SymptomViewModel> ReadList(SymptomSearchModel? model = null);
SymptomViewModel? ReadElement(SymptomSearchModel model); SymptomViewModel? ReadElement(SymptomSearchModel model);
bool Create(SymptomBindingModel model); bool Create(SymptomBindingModel model);
bool Update(SymptomBindingModel model); bool Update(SymptomBindingModel model);

View File

@ -3,6 +3,6 @@
public class SymptomSearchModel public class SymptomSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string?Name { get; set; } public string? Name { get; set; }
} }
} }

View File

@ -10,7 +10,7 @@ namespace PolyclinicContracts.ViewModels
[DisplayName("Препарата в день")] [DisplayName("Препарата в день")]
public int PillsPerDay { get; set; } public int PillsPerDay { get; set; }
[DisplayName("Комментарий")] [DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
public Dictionary<int, IDiagnoseModel> CourseDiagnoses { get; set; } = new(); public Dictionary<int, IDiagnoseModel> CourseDiagnoses { get; set; } = new();
public int Id { get; set; } public int Id { get; set; }
} }

View File

@ -1,5 +1,6 @@
using PolyclinicDataModels.Models; using PolyclinicDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace PolyclinicContracts.ViewModels namespace PolyclinicContracts.ViewModels
{ {
@ -9,7 +10,7 @@ namespace PolyclinicContracts.ViewModels
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Комментарий")] [DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
[DisplayName("Дата 'от'")] [DisplayName("Дата 'от'")]
public DateTime DateStartDiagnose { get; set; } public DateTime DateStartDiagnose { get; set; }

View File

@ -6,11 +6,21 @@ namespace PolyclinicContracts.ViewModels
public class MedicamentViewModel : IMedicamentModel public class MedicamentViewModel : IMedicamentModel
{ {
public int Id { get; set; } public int Id { get; set; }
public int ProcedureId { get; set; } public int? ProcedureId { get; set; }
public int? SymptomId { get; set; } public int? SymptomId { get; set; }
[DisplayName("Название медикамента")] [DisplayName("Название медикамента")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Комментарий")] [DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
[DisplayName("Название симптома")]
public string SymptomName { get; set; } = string.Empty;
[DisplayName("Название процедуры")]
public string ProcedureName { get; set; } = string.Empty;
} }
} }

View File

@ -12,7 +12,7 @@ namespace PolyclinicContracts.ViewModels
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Комментарий")] [DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
[DisplayName("Дата 'от'")] [DisplayName("Дата 'от'")]
public DateTime DateStartProcedure { get; set; } = DateTime.Now; public DateTime DateStartProcedure { get; set; } = DateTime.Now;

View File

@ -11,7 +11,9 @@ namespace PolyclinicContracts.ViewModels
public int ProceduresCount { get; set; } public int ProceduresCount { get; set; }
[DisplayName("Комментарий")] [DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
[DisplayName("Номер курса")]
public int? CourseId { get; set; } public int? CourseId { get; set; }
public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new(); public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new();
} }

View File

@ -1,10 +1,4 @@
using System; namespace PolyclinicContracts.ViewModels
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicContracts.ViewModels
{ {
public class ReportCoursesByProcedureViewModel public class ReportCoursesByProcedureViewModel
{ {

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

@ -0,0 +1,9 @@
namespace PolyclinicContracts.ViewModels
{
public class ReportDiagnosesByPeriodViewModel
{
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

@ -2,11 +2,7 @@
{ {
public class ReportMedicamentsByDiagnoseViewModel public class ReportMedicamentsByDiagnoseViewModel
{ {
public int DiagnoseId { get; set; } public DiagnoseViewModel Diagnose { get; set; } = new();
public string DiagnoseName { get; set; } = string.Empty; public List<MedicamentViewModel> Medicaments { get; set; } = new();
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

@ -1,14 +1,8 @@
using PolyclinicDataModels.Models; namespace PolyclinicContracts.ViewModels
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PolyclinicContracts.ViewModels
{ {
public class ReportProceduresViewModel public class ReportProceduresViewModel
{ {
public int Id { get; set; }
public string ProcedureName { get; set; } = string.Empty; public string ProcedureName { get; set; } = string.Empty;
public DateTime DateStartProcedure { get; set; } public DateTime DateStartProcedure { get; set; }
public DateTime? DateStopProcedure { get; set;} public DateTime? DateStopProcedure { get; set;}

View File

@ -8,7 +8,7 @@ namespace PolyclinicContracts.ViewModels
[DisplayName("Название")] [DisplayName("Название")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Комментарий")] [DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
public Dictionary<int, IDiagnoseModel> SymptomDiagnoses { get; set; } = new(); public Dictionary<int, IDiagnoseModel> SymptomDiagnoses { get; set; } = new();
public int Id { get; set; } public int Id { get; set; }
} }

View File

@ -2,10 +2,8 @@
{ {
public enum UserRole public enum UserRole
{ {
Неизвестный = -1, Неизвестный = 0,
Администратор = 0,
Исполнитель = 1, Исполнитель = 1,
Поручитель = 2, Поручитель = 2,
Клиент = 3
} }
} }

View File

@ -4,7 +4,7 @@
{ {
int DaysCount { get; } int DaysCount { get; }
int PillsPerDay { get; } int PillsPerDay { get; }
string Comment { get; } string? Comment { get; }
Dictionary<int, IDiagnoseModel> CourseDiagnoses { get; } Dictionary<int, IDiagnoseModel> CourseDiagnoses { get; }
} }
} }

View File

@ -3,7 +3,7 @@
public interface IDiagnoseModel : IId public interface IDiagnoseModel : IId
{ {
string Name { get; } string Name { get; }
string Comment { get; } string? Comment { get; }
int UserId { get; } int UserId { get; }
DateTime DateStartDiagnose { get; } DateTime DateStartDiagnose { get; }
DateTime? DateStopDiagnose { get; } DateTime? DateStopDiagnose { get; }

View File

@ -3,8 +3,8 @@
public interface IMedicamentModel : IId public interface IMedicamentModel : IId
{ {
string Name { get; } string Name { get; }
string Comment { get; } string? Comment { get; }
int ProcedureId { get; } int? ProcedureId { get; }
int? SymptomId { get; } int? SymptomId { get; }
} }
} }

View File

@ -3,7 +3,7 @@
public interface IProcedureModel : IId public interface IProcedureModel : IId
{ {
string Name { get; } string Name { get; }
string Comment { get; } string? Comment { get; }
int UserId { get; } int UserId { get; }
DateTime DateStartProcedure { get; } DateTime DateStartProcedure { get; }
DateTime? DateStopProcedure { get; } DateTime? DateStopProcedure { get; }

View File

@ -3,7 +3,7 @@
public interface IRecipeModel : IId public interface IRecipeModel : IId
{ {
int ProceduresCount { get; set; } int ProceduresCount { get; set; }
string Comment { get; set; } string? Comment { get; set; }
int? CourseId { get; set; } int? CourseId { get; set; }
Dictionary<int, IProcedureModel> RecipeProcedures { get; } Dictionary<int, IProcedureModel> RecipeProcedures { get; }
} }

View File

@ -3,7 +3,7 @@
public interface ISymptomModel : IId public interface ISymptomModel : IId
{ {
string Name { get; } string Name { get; }
string Comment { get; } string? Comment { get; }
Dictionary<int, IDiagnoseModel> SymptomDiagnoses { get; } Dictionary<int, IDiagnoseModel> SymptomDiagnoses { get; }
} }
} }

View File

@ -31,12 +31,9 @@ namespace PolyclinicDatabaseImplement.Implements
public List<CourseViewModel> GetFilteredList(CourseSearchModel model) public List<CourseViewModel> GetFilteredList(CourseSearchModel model)
{ {
var elements = GetFullList(); var elements = GetFullList();
foreach (var prop in model.GetType().GetProperties()) if (model.Id != null)
{ {
if (model.GetType().GetProperty(prop.Name)?.GetValue(model, null) != null) elements = elements.Where(x => x.Id == model.Id).ToList();
{
elements = elements.Where(x => x.GetType().GetProperty(prop.Name)?.GetValue(x, null) == model.GetType().GetProperty(prop.Name)?.GetValue(model, null)).ToList();
}
} }
return elements; return elements;
} }
@ -67,14 +64,25 @@ namespace PolyclinicDatabaseImplement.Implements
public CourseViewModel? Update(CourseBindingModel model) public CourseViewModel? Update(CourseBindingModel model)
{ {
using var context = new PolyclinicDatabase(); using var context = new PolyclinicDatabase();
var element = context.Courses.FirstOrDefault(x => x.Id == model.Id); using var transaction = context.Database.BeginTransaction();
if (element == null) try
{ {
return null; var element = context.Courses.FirstOrDefault(x => x.Id == model.Id);
if (element == null)
{
return null;
}
element.Update(model);
context.SaveChanges();
element.UpdateDiagnoses(context, model);
transaction.Commit();
return element.GetViewModel;
}
catch (Exception ex)
{
transaction.Rollback();
throw;
} }
element.Update(model);
context.SaveChanges();
return element.GetViewModel;
} }
} }
} }

View File

@ -37,7 +37,7 @@ namespace PolyclinicDatabaseImplement.Implements
public RecipeViewModel? GetElement(RecipeSearchModel bindingModel) public RecipeViewModel? GetElement(RecipeSearchModel bindingModel)
{ {
if (!bindingModel.Id.HasValue || string.IsNullOrEmpty(bindingModel.Comment)) if (!bindingModel.Id.HasValue)
{ {
return null; return null;
} }

View File

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using PolyclinicContracts.BindingModels; using PolyclinicContracts.BindingModels;
using PolyclinicContracts.SearchModels; using PolyclinicContracts.SearchModels;
using PolyclinicContracts.StoragesContracts; using PolyclinicContracts.StoragesContracts;
@ -31,12 +32,13 @@ namespace PolyclinicDatabaseImplement.Implements
public List<SymptomViewModel> GetFilteredList(SymptomSearchModel model) public List<SymptomViewModel> GetFilteredList(SymptomSearchModel model)
{ {
var elements = GetFullList(); var elements = GetFullList();
foreach (var prop in model.GetType().GetProperties()) if (model.Id != null)
{ {
if (model.GetType().GetProperty(prop.Name)?.GetValue(model, null) != null) elements = elements.Where(x => x.Id == model.Id).ToList();
{ }
elements = elements.Where(x => x.GetType().GetProperty(prop.Name)?.GetValue(x, null) == model.GetType().GetProperty(prop.Name)?.GetValue(model, null)).ToList(); if (!model.Name.IsNullOrEmpty())
} {
elements = elements.Where(x => x.Name == model.Name).ToList();
} }
return elements; return elements;
} }
@ -67,14 +69,26 @@ namespace PolyclinicDatabaseImplement.Implements
public SymptomViewModel? Update(SymptomBindingModel model) public SymptomViewModel? Update(SymptomBindingModel model)
{ {
using var context = new PolyclinicDatabase(); using var context = new PolyclinicDatabase();
var element = context.Symptomes.FirstOrDefault(x => x.Id == model.Id); using var transaction = context.Database.BeginTransaction();
if (element == null) try
{ {
return null; var element = context.Symptomes.FirstOrDefault(x => x.Id == model.Id);
if (element == null)
{
return null;
}
element.Update(model);
context.SaveChanges();
element.UpdateDiagnoses(context, model);
transaction.Commit();
return element.GetViewModel;
} }
element.Update(model); catch (Exception ex)
context.SaveChanges(); {
return element.GetViewModel; transaction.Rollback();
throw;
}
} }
} }
} }

View File

@ -31,13 +31,20 @@ namespace PolyclinicDatabaseImplement.Implements
public List<UserViewModel> GetFilteredList(UserSearchModel model) public List<UserViewModel> GetFilteredList(UserSearchModel model)
{ {
var elements = GetFullList(); var elements = GetFullList();
foreach (var prop in model.GetType().GetProperties()) if (model.Id != null)
{ {
if (model.GetType().GetProperty(prop.Name)?.GetValue(model, null) != null) elements = elements.Where(x => x.Id == model.Id).ToList();
{ }
elements = elements.Where(x => x.GetType().GetProperty(prop.Name)?.GetValue(x, null) == model.GetType().GetProperty(prop.Name)?.GetValue(model, null)).ToList(); if (!model.Email.IsNullOrEmpty())
} {
} elements = elements.Where(x => x.Email == model.Email).ToList();
}
if (!model.Password.IsNullOrEmpty())
{
elements = elements.Where(x => x.Password == model.Password).ToList();
}
return elements; return elements;
} }

View File

@ -19,7 +19,7 @@ namespace PolyclinicDatabaseImplement.Migrations
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
DaysCount = table.Column<int>(type: "int", nullable: false), DaysCount = table.Column<int>(type: "int", nullable: false),
PillsPerDay = table.Column<int>(type: "int", nullable: false), PillsPerDay = table.Column<int>(type: "int", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false) Comment = table.Column<string>(type: "nvarchar(max)", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -33,7 +33,7 @@ namespace PolyclinicDatabaseImplement.Migrations
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false) Comment = table.Column<string>(type: "nvarchar(max)", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -63,7 +63,7 @@ namespace PolyclinicDatabaseImplement.Migrations
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
ProceduresCount = table.Column<int>(type: "int", nullable: false), ProceduresCount = table.Column<int>(type: "int", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false), Comment = table.Column<string>(type: "nvarchar(max)", nullable: true),
CourseId = table.Column<int>(type: "int", nullable: true) CourseId = table.Column<int>(type: "int", nullable: true)
}, },
constraints: table => constraints: table =>
@ -83,7 +83,7 @@ namespace PolyclinicDatabaseImplement.Migrations
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false), Comment = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserId = table.Column<int>(type: "int", nullable: false), UserId = table.Column<int>(type: "int", nullable: false),
DateStartDiagnose = table.Column<DateTime>(type: "datetime2", nullable: false), DateStartDiagnose = table.Column<DateTime>(type: "datetime2", nullable: false),
DateStopDiagnose = table.Column<DateTime>(type: "datetime2", nullable: true) DateStopDiagnose = table.Column<DateTime>(type: "datetime2", nullable: true)
@ -109,7 +109,7 @@ namespace PolyclinicDatabaseImplement.Migrations
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
DateStartProcedure = table.Column<DateTime>(type: "datetime2", nullable: false), DateStartProcedure = table.Column<DateTime>(type: "datetime2", nullable: false),
DateStopProcedure = table.Column<DateTime>(type: "datetime2", nullable: true), DateStopProcedure = table.Column<DateTime>(type: "datetime2", nullable: true),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false) Comment = table.Column<string>(type: "nvarchar(max)", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -207,7 +207,7 @@ namespace PolyclinicDatabaseImplement.Migrations
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false), Comment = table.Column<string>(type: "nvarchar(max)", nullable: true),
ProcedureId = table.Column<int>(type: "int", nullable: false), ProcedureId = table.Column<int>(type: "int", nullable: false),
SymptomId = table.Column<int>(type: "int", nullable: false) SymptomId = table.Column<int>(type: "int", nullable: false)
}, },

View File

@ -0,0 +1,445 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SecuritySystemDatabaseImplement;
#nullable disable
namespace PolyclinicDatabaseImplement.Migrations
{
[DbContext(typeof(PolyclinicDatabase))]
[Migration("20240529231348_For-Medicaments")]
partial class ForMedicaments
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Course", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<int>("DaysCount")
.HasColumnType("int");
b.Property<int>("PillsPerDay")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Courses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.CourseDiagnose", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CourseId")
.HasColumnType("int");
b.Property<int>("DiagnoseId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CourseId");
b.HasIndex("DiagnoseId");
b.ToTable("CourseDiagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Diagnose", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartDiagnose")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateStopDiagnose")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Diagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Medicament", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ProcedureId")
.HasColumnType("int");
b.Property<int?>("SymptomId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProcedureId");
b.HasIndex("SymptomId");
b.ToTable("Medicaments");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Procedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartProcedure")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateStopProcedure")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Procedures");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CourseId")
.HasColumnType("int");
b.Property<int>("ProceduresCount")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CourseId");
b.ToTable("Recipes");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.RecipeProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProcedureId");
b.HasIndex("RecipeId");
b.ToTable("RecipeProcedures");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Symptom", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Symptomes");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomDiagnose", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DiagnoseId")
.HasColumnType("int");
b.Property<int>("SymptomId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DiagnoseId");
b.HasIndex("SymptomId");
b.ToTable("SymptomDiagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomRecipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("RecipeId")
.HasColumnType("int");
b.Property<int>("SymptomId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RecipeId");
b.HasIndex("SymptomId");
b.ToTable("SymptomRecipes");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Role")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.CourseDiagnose", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course")
.WithMany("Diagnoses")
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Diagnose", "Diagnose")
.WithMany()
.HasForeignKey("DiagnoseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Course");
b.Navigation("Diagnose");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Diagnose", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Medicament", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure")
.WithMany()
.HasForeignKey("ProcedureId");
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany()
.HasForeignKey("SymptomId");
b.Navigation("Procedure");
b.Navigation("Symptom");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Procedure", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course")
.WithMany()
.HasForeignKey("CourseId");
b.Navigation("Course");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.RecipeProcedure", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure")
.WithMany()
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Recipe", "Recipe")
.WithMany("Procedures")
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Procedure");
b.Navigation("Recipe");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomDiagnose", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Diagnose", "Diagnose")
.WithMany()
.HasForeignKey("DiagnoseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany("Diagnoses")
.HasForeignKey("SymptomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Diagnose");
b.Navigation("Symptom");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomRecipe", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Recipe", "Recipe")
.WithMany()
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany()
.HasForeignKey("SymptomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Recipe");
b.Navigation("Symptom");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Course", b =>
{
b.Navigation("Diagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b =>
{
b.Navigation("Procedures");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Symptom", b =>
{
b.Navigation("Diagnoses");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,208 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PolyclinicDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class ForMedicaments : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments");
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Symptomes",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Recipes",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Procedures",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<int>(
name: "SymptomId",
table: "Medicaments",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<int>(
name: "ProcedureId",
table: "Medicaments",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Medicaments",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Diagnoses",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Courses",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments",
column: "ProcedureId",
principalTable: "Procedures",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments",
column: "SymptomId",
principalTable: "Symptomes",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments");
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Symptomes",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Recipes",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Procedures",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "SymptomId",
table: "Medicaments",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ProcedureId",
table: "Medicaments",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Medicaments",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Diagnoses",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Courses",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments",
column: "ProcedureId",
principalTable: "Procedures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments",
column: "SymptomId",
principalTable: "Symptomes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -31,7 +31,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("DaysCount") b.Property<int>("DaysCount")
@ -77,7 +76,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartDiagnose") b.Property<DateTime>("DateStartDiagnose")
@ -109,18 +107,16 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("ProcedureId") b.Property<int?>("ProcedureId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int?>("SymptomId") b.Property<int?>("SymptomId")
.IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -141,7 +137,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartProcedure") b.Property<DateTime>("DateStartProcedure")
@ -173,7 +168,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int?>("CourseId") b.Property<int?>("CourseId")
@ -221,7 +215,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Name") b.Property<string>("Name")
@ -341,15 +334,11 @@ namespace PolyclinicDatabaseImplement.Migrations
{ {
b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure") b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure")
.WithMany() .WithMany()
.HasForeignKey("ProcedureId") .HasForeignKey("ProcedureId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom") b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany() .WithMany()
.HasForeignKey("SymptomId") .HasForeignKey("SymptomId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Procedure"); b.Navigation("Procedure");

View File

@ -14,7 +14,7 @@ namespace PolyclinicDatabaseImplement.Models
public int DaysCount { get; set; } public int DaysCount { get; set; }
[Required] [Required]
public int PillsPerDay { get; set; } public int PillsPerDay { get; set; }
public string Comment { get; set; } = string.Empty; public string? Comment { get; set; } = string.Empty;
[ForeignKey("CourseId")] [ForeignKey("CourseId")]
public virtual List<CourseDiagnose> Diagnoses { get; set; } = new(); public virtual List<CourseDiagnose> Diagnoses { get; set; } = new();
private Dictionary<int, IDiagnoseModel>? _courseDiagnoses = null; private Dictionary<int, IDiagnoseModel>? _courseDiagnoses = null;
@ -34,7 +34,7 @@ namespace PolyclinicDatabaseImplement.Models
} }
} }
public static Course Create(PolyclinicDatabase context, CourseBindingModel model) public static Course? Create(PolyclinicDatabase context, CourseBindingModel model)
{ {
return new Course() return new Course()
{ {
@ -71,8 +71,7 @@ namespace PolyclinicDatabaseImplement.Models
if (courseDiagnoses != null && courseDiagnoses.Count > 0) if (courseDiagnoses != null && courseDiagnoses.Count > 0)
{ {
// удалили те, которых нет в модели // удалили те, которых нет в модели
context.CourseDiagnoses.RemoveRange(courseDiagnoses context.CourseDiagnoses.RemoveRange(courseDiagnoses);
.Where(rec => !model.CourseDiagnoses.ContainsKey(rec.DiagnoseId)));
context.SaveChanges(); context.SaveChanges();
} }
var course = context.Courses.First(x => x.Id == Id); var course = context.Courses.First(x => x.Id == Id);

View File

@ -9,7 +9,7 @@ namespace PolyclinicDatabaseImplement.Models
public int CourseId { get; set; } public int CourseId { get; set; }
[Required] [Required]
public int DiagnoseId { get; set; } public int DiagnoseId { get; set; }
public virtual Course Course { get; set; } = new(); public virtual Course? Course { get; set; }
public virtual Diagnose Diagnose { get; set; } = new(); public virtual Diagnose? Diagnose { get; set; }
} }
} }

View File

@ -9,8 +9,7 @@ namespace PolyclinicDatabaseImplement.Models
{ {
[Required] [Required]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[Required] public string? Comment { get; set; }
public string Comment { get; set; } = string.Empty;
[Required] [Required]
public int UserId { get; set; } public int UserId { get; set; }
@ -18,7 +17,7 @@ namespace PolyclinicDatabaseImplement.Models
public DateTime DateStartDiagnose { get; set; } = DateTime.Now; public DateTime DateStartDiagnose { get; set; } = DateTime.Now;
public DateTime? DateStopDiagnose { get; set; } public DateTime? DateStopDiagnose { get; set; }
public int Id { get; set; } public int Id { get; set; }
public virtual User User { get; set; } = new(); public virtual User? User { get; set; }
public static Diagnose? Create(DiagnoseBindingModel? model) public static Diagnose? Create(DiagnoseBindingModel? model)
{ {
@ -45,6 +44,8 @@ namespace PolyclinicDatabaseImplement.Models
} }
Name = model.Name; Name = model.Name;
Comment = model.Comment; Comment = model.Comment;
DateStartDiagnose = model.DateStartDiagnose;
DateStopDiagnose = model.DateStopDiagnose;
} }
public DiagnoseViewModel GetViewModel => new() public DiagnoseViewModel GetViewModel => new()

View File

@ -13,19 +13,16 @@ namespace PolyclinicDatabaseImplement.Models
[Required] [Required]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[Required] public string? Comment { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty;
[Required] public int? ProcedureId { get; set; }
public int ProcedureId { get; set; }
[Required]
public int? SymptomId { get; set; } public int? SymptomId { get; set; }
public virtual Symptom? Symptom { get; set; } public virtual Symptom? Symptom { get; set; }
public virtual Procedure? Procedure { get; set; } public virtual Procedure? Procedure { get; set; }
public static Medicament Create(MedicamentBindingModel bindingModel) public static Medicament? Create(MedicamentBindingModel bindingModel)
{ {
return new Medicament() return new Medicament()
{ {
@ -41,6 +38,8 @@ namespace PolyclinicDatabaseImplement.Models
{ {
Name = bindingModel.Name; Name = bindingModel.Name;
Comment = bindingModel.Comment; Comment = bindingModel.Comment;
ProcedureId = bindingModel.ProcedureId;
SymptomId = bindingModel.SymptomId;
} }
public MedicamentViewModel GetViewModel => new() public MedicamentViewModel GetViewModel => new()
@ -48,8 +47,10 @@ namespace PolyclinicDatabaseImplement.Models
Id = Id, Id = Id,
Name = Name, Name = Name,
Comment = Comment, Comment = Comment,
ProcedureId = ProcedureId, ProcedureId = Procedure?.Id ?? null,
SymptomId = Symptom?.Id ?? null SymptomId = Symptom?.Id ?? null,
SymptomName = Symptom?.Name ?? string.Empty,
ProcedureName = Procedure?.Name ?? string.Empty,
}; };
} }
} }

View File

@ -1,7 +1,6 @@
using PolyclinicContracts.BindingModels; using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels; using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models; using PolyclinicDataModels.Models;
using SecuritySystemDatabaseImplement;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace PolyclinicDatabaseImplement.Models namespace PolyclinicDatabaseImplement.Models
@ -19,13 +18,14 @@ namespace PolyclinicDatabaseImplement.Models
[Required] [Required]
public DateTime DateStartProcedure { get; set; } = DateTime.Now; public DateTime DateStartProcedure { get; set; } = DateTime.Now;
public DateTime? DateStopProcedure { get; set; } public DateTime? DateStopProcedure { get; set; }
public virtual User User { get; set; } = new(); public virtual User? User { get; set; }
[Required] public string? Comment { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty;
public static Procedure Create(ProcedureBindingModel bindingModel) public static Procedure? Create(ProcedureBindingModel bindingModel)
{ {
if (bindingModel == null) return null;
return new Procedure() return new Procedure()
{ {
Id = bindingModel.Id, Id = bindingModel.Id,
@ -37,10 +37,17 @@ namespace PolyclinicDatabaseImplement.Models
}; };
} }
public void Update(ProcedureBindingModel bindingModel) public void Update(ProcedureBindingModel? bindingModel)
{ {
if (bindingModel == null)
{
return;
}
Name = bindingModel.Name; Name = bindingModel.Name;
Comment = bindingModel.Comment; Comment = bindingModel.Comment;
DateStartProcedure = bindingModel.DateStartProcedure;
DateStopProcedure = bindingModel.DateStopProcedure;
} }
public ProcedureViewModel GetViewModel => new() public ProcedureViewModel GetViewModel => new()
@ -51,6 +58,6 @@ namespace PolyclinicDatabaseImplement.Models
Comment = Comment, Comment = Comment,
DateStartProcedure = DateStartProcedure, DateStartProcedure = DateStartProcedure,
DateStopProcedure = DateStopProcedure, DateStopProcedure = DateStopProcedure,
}; };
} }
} }

View File

@ -14,10 +14,9 @@ namespace PolyclinicDatabaseImplement.Models
[Required] [Required]
public int ProceduresCount { get; set; } public int ProceduresCount { get; set; }
[Required] public string? Comment { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty;
public int? CourseId { get; set; } public int? CourseId { get; set; }
public virtual Course Course { get; set; } = new(); public virtual Course? Course { get; set; }
private Dictionary<int, IProcedureModel>? _recipeProcedures = null; private Dictionary<int, IProcedureModel>? _recipeProcedures = null;
@ -37,7 +36,7 @@ namespace PolyclinicDatabaseImplement.Models
} }
} }
public static Recipe Create(PolyclinicDatabase database, RecipeBindingModel bindingModel) public static Recipe? Create(PolyclinicDatabase database, RecipeBindingModel bindingModel)
{ {
return new Recipe() return new Recipe()
{ {
@ -47,7 +46,7 @@ namespace PolyclinicDatabaseImplement.Models
CourseId = bindingModel.CourseId, CourseId = bindingModel.CourseId,
Procedures = bindingModel.RecipeProcedures.Select(x => new RecipeProcedure Procedures = bindingModel.RecipeProcedures.Select(x => new RecipeProcedure
{ {
Recipe = database.Recipes.First(y => y.Id == x.Key) Procedure = database.Procedures.First(y => y.Id == x.Key),
}).ToList() }).ToList()
}; };
} }
@ -64,17 +63,21 @@ namespace PolyclinicDatabaseImplement.Models
Id = Id, Id = Id,
ProceduresCount = ProceduresCount, ProceduresCount = ProceduresCount,
Comment = Comment, Comment = Comment,
CourseId = Course?.Id ?? null, CourseId = CourseId ?? null,
}; };
public void UpdateProcedures(PolyclinicDatabase database, RecipeBindingModel bindingModel) public void UpdateProcedures(PolyclinicDatabase database, RecipeBindingModel bindingModel)
{ {
if (database.Procedures.Count() == 0)
{
return;
}
var RecipeProcedures = database.RecipeProcedures.Where(x => x.ProcedureId == bindingModel.Id).ToList(); var RecipeProcedures = database.RecipeProcedures.Where(x => x.ProcedureId == bindingModel.Id).ToList();
if (RecipeProcedures != null) if (RecipeProcedures != null)
{ {
// удалили те, которых нет в модели // удалили те, которых нет в модели
database.RecipeProcedures.RemoveRange(RecipeProcedures.Where(rec => !bindingModel.RecipeProcedures.ContainsKey(rec.RecipeId))); database.RecipeProcedures.RemoveRange(RecipeProcedures);
database.SaveChanges(); database.SaveChanges();
} }
var Procedure = database.Procedures.First(x => x.Id == bindingModel.Id); var Procedure = database.Procedures.First(x => x.Id == bindingModel.Id);
@ -85,6 +88,7 @@ namespace PolyclinicDatabaseImplement.Models
Procedure = Procedure, Procedure = Procedure,
Recipe = database.Recipes.First(x => x.Id == pc.Key) Recipe = database.Recipes.First(x => x.Id == pc.Key)
}); });
database.SaveChanges();
} }
_recipeProcedures = null; _recipeProcedures = null;
} }

View File

@ -9,7 +9,7 @@ namespace PolyclinicDatabaseImplement.Models
public int ProcedureId { get; set; } public int ProcedureId { get; set; }
[Required] [Required]
public int RecipeId { get; set; } public int RecipeId { get; set; }
public virtual Procedure Procedure { get; set; } = new(); public virtual Procedure? Procedure { get; set; }
public virtual Recipe Recipe { get; set; } = new(); public virtual Recipe? Recipe { get; set; }
} }
} }

View File

@ -11,8 +11,7 @@ namespace PolyclinicDatabaseImplement.Models
{ {
[Required] [Required]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[Required] public string? Comment { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty;
[ForeignKey("SymptomId")] [ForeignKey("SymptomId")]
public virtual List<SymptomDiagnose> Diagnoses { get; set; } = new(); public virtual List<SymptomDiagnose> Diagnoses { get; set; } = new();
private Dictionary<int, IDiagnoseModel>? _symptomDiagnoses = null; private Dictionary<int, IDiagnoseModel>? _symptomDiagnoses = null;
@ -33,7 +32,7 @@ namespace PolyclinicDatabaseImplement.Models
} }
public int Id { get; set; } public int Id { get; set; }
public static Symptom Create(PolyclinicDatabase context, SymptomBindingModel model) public static Symptom? Create(PolyclinicDatabase context, SymptomBindingModel model)
{ {
return new Symptom() return new Symptom()
{ {
@ -64,19 +63,18 @@ namespace PolyclinicDatabaseImplement.Models
public void UpdateDiagnoses(PolyclinicDatabase context, SymptomBindingModel model) public void UpdateDiagnoses(PolyclinicDatabase context, SymptomBindingModel model)
{ {
var symptomDiagnoses = context.SymptomDiagnoses.Where(rec => rec.SymptomId == model.Id).ToList(); var symptomDiagnoses = context.SymptomDiagnoses.Where(rec => rec.SymptomId == model.Id).ToList();
if (symptomDiagnoses != null && symptomDiagnoses.Count > 0) if (symptomDiagnoses != null && symptomDiagnoses.Count > 0)
{ {
// удалили те, которых нет в модели context.SymptomDiagnoses.RemoveRange(symptomDiagnoses);
context.SymptomDiagnoses.RemoveRange(symptomDiagnoses
.Where(rec => !model.SymptomDiagnoses.ContainsKey(rec.DiagnoseId)));
context.SaveChanges(); context.SaveChanges();
} }
var course = context.Symptomes.First(x => x.Id == Id); var symptom = context.Symptomes.First(x => x.Id == model.Id);
foreach (var pc in model.SymptomDiagnoses) foreach (var pc in model.SymptomDiagnoses)
{ {
context.SymptomDiagnoses.Add(new SymptomDiagnose context.SymptomDiagnoses.Add(new SymptomDiagnose
{ {
Symptom = course, Symptom = symptom,
Diagnose = context.Diagnoses.First(x => x.Id == pc.Key), Diagnose = context.Diagnoses.First(x => x.Id == pc.Key),
}); });
context.SaveChanges(); context.SaveChanges();

View File

@ -9,7 +9,7 @@ namespace PolyclinicDatabaseImplement.Models
public int SymptomId { get; set; } public int SymptomId { get; set; }
[Required] [Required]
public int DiagnoseId { get; set; } public int DiagnoseId { get; set; }
public virtual Symptom Symptom { get; set; } = new(); public virtual Symptom? Symptom { get; set; }
public virtual Diagnose Diagnose { get; set; } = new(); public virtual Diagnose? Diagnose { get; set; }
} }
} }

View File

@ -9,7 +9,7 @@ namespace PolyclinicDatabaseImplement.Models
public int SymptomId { get; set; } public int SymptomId { get; set; }
[Required] [Required]
public int RecipeId { get; set; } public int RecipeId { get; set; }
public virtual Symptom Symptom { get; set; } = new(); public virtual Symptom? Symptom { get; set; }
public virtual Recipe Recipe { get; set; } = new(); public virtual Recipe? Recipe { get; set; }
} }
} }

View File

@ -43,8 +43,6 @@ namespace PolyclinicDatabaseImplement.Models
FIO = model.FIO; FIO = model.FIO;
Email = model.Email; Email = model.Email;
Password = model.Password; Password = model.Password;
Role = model.Role;
FIO = model.FIO;
} }
public UserViewModel GetViewModel => new() public UserViewModel GetViewModel => new()

View File

@ -0,0 +1,125 @@
using Microsoft.AspNetCore.Mvc;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
using PolyclinicWebAppImplementer.Models;
namespace PolyclinicWebAppImplementer.Controllers
{
public class CoursesController : Controller
{
private readonly IDiagnoseLogic _diagnoseLogic;
private readonly ICourseLogic _courseLogic;
public CoursesController(IDiagnoseLogic diagnoseLogic, ICourseLogic courseLogic)
{
_diagnoseLogic = diagnoseLogic;
_courseLogic = courseLogic;
}
[HttpGet]
public IActionResult Index()
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
List<CourseViewModel> courses = _courseLogic.ReadList();
ViewData["Title"] = "Список курсов";
return View("CoursesList", courses);
}
[HttpGet]
[HttpPost]
public IActionResult Add(CourseFormModel model, int[] selectedDiagnoses)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Новый курс";
model = new()
{
Diagnoses = _diagnoseLogic.ReadList().Select(x => (x, false)).ToList()
};
return View("CourseForm", model);
}
else
{
var allDiagnoses = _diagnoseLogic.ReadList();
CourseBindingModel course = new CourseBindingModel
{
Comment = model.CourseViewModel.Comment,
DaysCount = model.CourseViewModel.DaysCount,
PillsPerDay = model.CourseViewModel.PillsPerDay,
CourseDiagnoses = selectedDiagnoses
.ToDictionary(
x => x,
x => allDiagnoses.Where(y => y.Id == x) as IDiagnoseModel
)
};
_courseLogic.Create(course);
return RedirectToAction("Index");
}
}
[HttpGet]
[HttpPost]
public IActionResult Edit(int id, CourseFormModel model, int[] selectedDiagnoses)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
if (HttpContext.Request.Method == "GET")
{
var obj = _courseLogic.ReadElement(new CourseSearchModel { Id = id });
model = new()
{
CourseViewModel = obj,
Diagnoses = _diagnoseLogic.ReadList().Select(x => (x, obj.CourseDiagnoses.ContainsKey(x.Id))).ToList()
};
ViewData["Title"] = "Редактировать симптом";
return View("CourseForm", model);
}
else
{
var allDiagnoses = _diagnoseLogic.ReadList();
CourseBindingModel course = new CourseBindingModel
{
Id = id,
Comment = model.CourseViewModel.Comment,
DaysCount = model.CourseViewModel.DaysCount,
PillsPerDay = model.CourseViewModel.PillsPerDay,
CourseDiagnoses = selectedDiagnoses
.ToDictionary(
x => x,
x => allDiagnoses.Where(y => y.Id == x) as IDiagnoseModel
)
};
_courseLogic.Update(course);
return RedirectToAction("Index");
}
}
[HttpPost]
public IActionResult Delete(int id)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
var obj = _courseLogic.ReadElement(new CourseSearchModel { Id = id });
if (obj != null)
{
_courseLogic.Delete(new CourseBindingModel { Id = obj.Id });
}
return RedirectToAction("Index");
}
}
}

View File

@ -0,0 +1,118 @@
using Microsoft.AspNetCore.Mvc;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicContracts.ViewModels;
using PolyclinicWebAppImplementer.Models;
using System.Net;
namespace PolyclinicWebAppImplementer.Controllers
{
public class DiagnosesController : Controller
{
private readonly ILogger<DiagnosesController> _logger;
private readonly IDiagnoseLogic _diagnoseLogic;
public DiagnosesController(ILogger<DiagnosesController> logger, IDiagnoseLogic diagnoseLogic)
{
_logger = logger;
_diagnoseLogic = diagnoseLogic;
}
[HttpGet]
public IActionResult Index()
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
List<DiagnoseViewModel> diagnoses = _diagnoseLogic.ReadList(new DiagnoseSearchModel { UserId = currentUser.Id });
ViewData["Title"] = "Список диагнозов";
return View("DiagnosesList", diagnoses);
}
[HttpGet]
[HttpPost]
public IActionResult Add(DiagnoseViewModel model)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Новый диагноз";
return View("DiagnoseForm");
}
else
{
DiagnoseBindingModel diagnose = new DiagnoseBindingModel
{
UserId = currentUser.Id,
Name = model.Name,
Comment = model.Comment,
DateStartDiagnose = model.DateStartDiagnose,
DateStopDiagnose = model.DateStopDiagnose,
};
_diagnoseLogic.Create(diagnose);
return RedirectToAction("Index");
}
}
[HttpGet]
[HttpPost]
public IActionResult Edit(int id, DiagnoseViewModel model)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id });
if (obj.UserId != currentUser.Id)
{
return StatusCode(403, "Нельзя редактировать чужой диагноз");
}
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Редактировать диагноз";
return View("DiagnoseForm", obj);
}
else
{
DiagnoseBindingModel diagnose = new DiagnoseBindingModel
{
Id = model.Id,
Name = model.Name,
Comment = model.Comment,
DateStartDiagnose = model.DateStartDiagnose,
DateStopDiagnose = model.DateStopDiagnose,
};
_diagnoseLogic.Update(diagnose);
return RedirectToAction("Index");
}
}
[HttpPost]
public IActionResult Delete(int id)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
var obj = _diagnoseLogic.ReadElement(new DiagnoseSearchModel { Id = id });
if (obj.UserId != currentUser.Id)
{
return StatusCode(403, "Нельзя удалить чужой диагноз");
}
if (obj != null)
{
_diagnoseLogic.Delete(new DiagnoseBindingModel { Id = obj.Id });
}
return RedirectToAction("Index");
}
}
}

View File

@ -17,79 +17,12 @@ namespace PolyclinicWebAppImplementer.Controllers
{ {
return View(); return View();
} }
[HttpGet]
[HttpPost]
public IActionResult Course()
{
if (HttpContext.Request.Method == "POST")
{
return Redirect("~/Home/Courses");
}
else
{
return View();
}
}
public IActionResult Courses()
{
return View();
}
public IActionResult Diagnose()
{
if (HttpContext.Request.Method == "POST")
{
return Redirect("~/Home/Diagnoses");
}
else
{
return View();
}
}
public IActionResult Diagnoses()
{
return View();
}
public IActionResult Symptom()
{
if (HttpContext.Request.Method == "POST")
{
return Redirect("~/Home/Symptomes");
}
else
{
return View();
}
}
public IActionResult Symptomes()
{
return View();
}
public IActionResult Privacy() public IActionResult Privacy()
{ {
return View(); return View();
} }
[HttpGet]
[HttpPost]
public IActionResult Login()
{
if (HttpContext.Request.Method == "POST")
{
return Redirect("~/");
}
else
{
return View();
}
}
public IActionResult Register()
{
return View();
}
[HttpGet] [HttpGet]
[HttpPost] [HttpPost]
public IActionResult AddRecipeToCourse() public IActionResult AddRecipeToCourse()

View File

@ -0,0 +1,72 @@
using Microsoft.AspNetCore.Mvc;
using PolyclinicBusinessLogic.BusinessLogics;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicWebAppImplementer.Models;
namespace PolyclinicWebAppImplementer.Controllers
{
public class RecipeController : Controller
{
private readonly IRecipeLogic _recipeLogic;
private readonly ICourseLogic _courseLogic;
public RecipeController(IRecipeLogic recipeLogic, ICourseLogic courseLogic)
{
_recipeLogic = recipeLogic;
_courseLogic = courseLogic;
}
[HttpGet]
[HttpPost]
public IActionResult LinkCourse(RecipeLinkCourseModel model)
{
var recipes = _recipeLogic.ReadList();
var courses = _courseLogic.ReadList();
var linkedRecipes = recipes
.Where(x => x.CourseId != null)
.Select(x => (x, _courseLogic.ReadElement(new CourseSearchModel { Id = x.CourseId }))).ToList();
if (HttpContext.Request.Method == "GET")
{
model = new()
{
Recipes = recipes,
Courses = courses,
LinkedRecipes = linkedRecipes
};
return View(model);
}
else
{
var recipe = _recipeLogic.ReadElement(new RecipeSearchModel { Id = model.RecipeId });
var recipeBindingModel = new RecipeBindingModel
{
Id = recipe.Id,
ProceduresCount = recipe.ProceduresCount,
Comment = recipe.Comment,
RecipeProcedures = recipe.RecipeProcedures,
CourseId = model.CourseId
};
_recipeLogic.Update(recipeBindingModel);
return RedirectToAction("LinkCourse");
}
}
[HttpPost]
public IActionResult UnLinkCourse(int id)
{
var recipe = _recipeLogic.ReadElement(new RecipeSearchModel { Id = id });
var recipeBindingModel = new RecipeBindingModel
{
Id = recipe.Id,
ProceduresCount = recipe.ProceduresCount,
Comment = recipe.Comment,
RecipeProcedures = recipe.RecipeProcedures
};
_recipeLogic.Update(recipeBindingModel);
return RedirectToAction("LinkCourse");
}
}
}

View File

@ -0,0 +1,132 @@
using Microsoft.AspNetCore.Mvc;
using PolyclinicBusinessLogic.BusinessLogics;
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicContracts.ViewModels;
using PolyclinicWebAppImplementer.Models;
namespace PolyclinicWebAppImplementer.Controllers
{
public class ReportsController : Controller
{
private readonly IImplementerReportLogic _reportLogic;
private readonly IDiagnoseLogic _diagnoseLogic;
private readonly SendMailLogic _sendMailLogic;
public ReportsController(IImplementerReportLogic reportLogic, IDiagnoseLogic diagnoseLogic, SendMailLogic sendMailLogic)
{
_reportLogic = reportLogic;
_diagnoseLogic = diagnoseLogic;
_sendMailLogic = sendMailLogic;
}
[HttpGet]
[HttpPost]
public IActionResult DiagnosesByPeriod(DiagnosesByPeriodFormModel model)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
if (HttpContext.Request.Method == "GET")
{
return View(model);
}
else
{
var report = _reportLogic.GetReportDiagnosesByPeriod(model.DateStart, model.DateEnd);
if (model.ReportType == ReportType.Web)
{
model.Report = report;
}
else
{
ReportBindingModel reportInfo = new()
{
FileName = "diagnosesByPeriod.pdf",
DateFrom = model.DateStart,
DateTo = model.DateEnd
};
_reportLogic.SaveReportDiagnosesByPeriodToPdfFile(reportInfo, report);
var fileName = reportInfo.FileName;
var filePath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
if (System.IO.File.Exists(filePath))
{
try
{
string txt = reportInfo.GetPeriodString();
var userEmail = currentUser.Email;
_sendMailLogic.SendEmail(userEmail, $"Здравствуйте, {currentUser.FIO}! В приложении отчет по болезням {txt} от {DateTime.Now.ToString()}", filePath);
model.Message = $"Отчет в формате .pdf был отправлен на почту {currentUser.Email}";
return View(model);
}
catch (Exception)
{
model.Error = $"Произошла ошибка при отправке отчета";
}
}
else
{
model.Error = "Произошла ошибка при генерации отчета";
}
}
return View(model);
}
}
[HttpGet]
[HttpPost]
public IActionResult MedicamentsByDiagnoses(MedicamentsByDiagnosesFormModel model)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
var diagnoses = _diagnoseLogic.ReadList(new DiagnoseSearchModel { UserId = currentUser.Id });
if (model.SelectedDiagnoses != null)
{
model.Diagnoses = diagnoses.Select(x => (x, model.SelectedDiagnoses.Contains(x.Id))).ToList();
}
else
{
model.Diagnoses = diagnoses.Select(x => (x, false)).ToList();
}
if (HttpContext.Request.Method == "GET")
{
return View(model);
}
else
{
var reportInfo = new ReportBindingModel();
var reportModel = _reportLogic.GetReportMedicamentsByDiagnoses(model.SelectedDiagnoses);
if (model.ReportType == ReportType.Word)
{
reportInfo.FileName = model.FileName + ".docx";
_reportLogic.SaveReportMedicamentsByDiagnosesToWordFile(reportInfo, reportModel);
}
else
{
reportInfo.FileName = model.FileName + ".xlsx";
_reportLogic.SaveReportMedicamentsByDiagnosesToExcelFile(reportInfo, reportModel);
}
var filePath = Path.Combine(Directory.GetCurrentDirectory(), reportInfo.FileName);
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
string mimeType = model.ReportType == ReportType.Word ? "application/vnd.openxmlformats-officedocument.wordprocessingml.document" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
return File(fileBytes, mimeType, reportInfo.FileName);
}
}
}
}

View File

@ -0,0 +1,121 @@
using Microsoft.AspNetCore.Mvc;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
using PolyclinicWebAppImplementer.Models;
namespace PolyclinicWebAppImplementer.Controllers
{
public class SymptomesController : Controller
{
private readonly ISymptomLogic _symptomLogic;
private readonly IDiagnoseLogic _diagnoseLogic;
public SymptomesController(ISymptomLogic symptomLogic, IDiagnoseLogic diagnoseLogic)
{
_symptomLogic = symptomLogic;
_diagnoseLogic = diagnoseLogic;
}
[HttpGet]
public IActionResult Index()
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
List<SymptomViewModel> symptomes = _symptomLogic.ReadList();
ViewData["Title"] = "Список симптомов";
return View("SymptomesList", symptomes);
}
[HttpGet]
[HttpPost]
public IActionResult Add(SymptomFormModel model, int[] selectedDiagnoses)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Новый симптом";
model = new()
{
Diagnoses = _diagnoseLogic.ReadList().Select(x => (x, false)).ToList()
};
return View("SymptomForm", model);
}
else
{
var allDiagnoses = _diagnoseLogic.ReadList();
SymptomBindingModel symptom = new SymptomBindingModel
{
Name = model.SymptomViewModel.Name,
Comment = model.SymptomViewModel.Comment,
SymptomDiagnoses = selectedDiagnoses
.ToDictionary(
x => x,
x => allDiagnoses.Where(y => y.Id == x) as IDiagnoseModel
)
};
_symptomLogic.Create(symptom);
return RedirectToAction("Index");
}
}
[HttpGet]
[HttpPost]
public IActionResult Edit(int id, SymptomFormModel model, int[] selectedDiagnoses)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
if (HttpContext.Request.Method == "GET")
{
var obj = _symptomLogic.ReadElement(new SymptomSearchModel { Id = id });
model = new()
{
SymptomViewModel = obj,
Diagnoses = _diagnoseLogic.ReadList().Select(x => (x, obj.SymptomDiagnoses.ContainsKey(x.Id))).ToList()
};
ViewData["Title"] = "Редактировать симптом";
return View("SymptomForm", model);
}
else
{
var allDiagnoses = _diagnoseLogic.ReadList();
SymptomBindingModel symptom = new SymptomBindingModel
{
Id = id,
Name = model.SymptomViewModel.Name,
Comment = model.SymptomViewModel.Comment,
SymptomDiagnoses = selectedDiagnoses
.ToDictionary(
x => x,
x => allDiagnoses.Where(y => y.Id == x) as IDiagnoseModel
)
};
_symptomLogic.Update(symptom);
return RedirectToAction("Index");
}
}
[HttpPost]
public IActionResult Delete(int id)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login", "User");
}
var obj = _symptomLogic.ReadElement(new SymptomSearchModel { Id = id });
if (obj != null)
{
_symptomLogic.Delete(new SymptomBindingModel { Id = obj.Id });
}
return RedirectToAction("Index");
}
}
}

View File

@ -0,0 +1,151 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicDataModels.Enums;
using PolyclinicDataModels.Models;
using PolyclinicWebAppImplementer.Models;
namespace PolyclinicWebAppImplementer.Controllers
{
public class UserController : Controller
{
private readonly IUserLogic _userLogic;
public UserController(IUserLogic userLogic)
{
_userLogic = userLogic;
}
[HttpGet]
[HttpPost]
public IActionResult Login(LoginModel model)
{
var errors = new List<string>();
if (HttpContext.Request.Method == "POST")
{
var user = _userLogic.ReadElement(new UserSearchModel { Email = model.Email, Password = model.Password });
if (user == null)
{
errors.Add("Неверные логин или пароль");
}
else if (user.Role != UserRole.Исполнитель)
{
errors.Add("Пользователь имеет неразрешенную роль");
}
if (errors.Count > 0)
{
model = new LoginModel
{
Errors = errors
};
return View(model);
}
LoginManager.LogginedUser = user;
return RedirectToAction("", "Home");
}
else
{
model = new();
return View(model);
}
}
[HttpGet]
[HttpPost]
public IActionResult Register(RegisterModel model)
{
var errors = new List<string>();
if (HttpContext.Request.Method == "POST")
{
if (_userLogic.ReadElement(new UserSearchModel { Email = model.Email }) != null)
{
errors.Add("Пользователь с таким Email уже есть");
}
if (model.Password != model.ConfirmPassword)
{
errors.Add("Пароли не совпадают");
}
if (errors.Count > 0)
{
model.Errors = errors;
model.Password = string.Empty;
model.ConfirmPassword = string.Empty;
return View(model);
}
var user = new UserBindingModel
{
FIO = model.FIO,
Email = model.Email,
Password = model.Password,
Role = UserRole.Исполнитель
};
_userLogic.Create(user);
return RedirectToAction("Login");
}
else
{
return View(model);
}
}
[HttpPost]
public IActionResult Logout()
{
LoginManager.LogginedUser = null;
return RedirectToAction("Login");
}
[HttpGet]
[HttpPost]
public IActionResult Privacy(UserPrivacyModel model)
{
var currentUser = LoginManager.LogginedUser;
if (currentUser == null)
{
return RedirectToAction("Login");
}
if (HttpContext.Request.Method == "POST")
{
var errors = new List<string>();
var checkedUser = _userLogic.ReadElement(new UserSearchModel { Email = model.Email });
if (checkedUser != null && checkedUser.Id != LoginManager.LogginedUser.Id)
{
errors.Add("Пользователь с таким Email уже есть");
}
if (model.Password != model.ConfirmPassword)
{
errors.Add("Пароли не совпадают");
}
if (errors.Count > 0)
{
model.Errors = errors;
model.Password = string.Empty;
model.ConfirmPassword = string.Empty;
return View(model);
}
var user = new UserBindingModel
{
Id = currentUser.Id,
FIO = model.FIO,
Email = model.Email,
Password = model.Password.IsNullOrEmpty() ? LoginManager.LogginedUser.Password : model.Password,
};
_userLogic.Update(user);
LoginManager.LogginedUser = _userLogic.ReadElement(new UserSearchModel { Id = model.Id });
return RedirectToAction("Privacy");
}
else
{
model = new()
{
Id = currentUser.Id,
FIO = currentUser.FIO,
Email = currentUser.Email,
Role = currentUser.Role
};
return View(model);
}
}
}
}

View File

@ -0,0 +1,9 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicWebAppImplementer
{
public static class LoginManager
{
public static UserViewModel? LogginedUser { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using PolyclinicContracts.ViewModels;
namespace PolyclinicWebAppImplementer.Models
{
public class CourseFormModel
{
public CourseViewModel? CourseViewModel { get; set; }
public List<(DiagnoseViewModel Diagnose, bool IsChecked)> Diagnoses { get; set; } = new();
}
}

Some files were not shown because too many files have changed in this diff Show More