Compare commits

..

4 Commits

Author SHA1 Message Date
Alenka
fdd8bca511 mission completed 2024-05-01 16:44:54 +04:00
Alenka
cd27d7cff1 хочу шашлык 2024-05-01 15:32:43 +04:00
Alenka
f78f57706a Merge branch 'develop' of https://git.is.ulstu.ru/ValAnn/PIbd_23_Panina_A._D._Valova_A._D._Hospital into develop 2024-05-01 15:29:05 +04:00
Alenka
809d39a6e6 Хочу шашлык 2024-05-01 15:28:49 +04:00
135 changed files with 862 additions and 4823 deletions

View File

@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalView", "Hospital\HospitalView.csproj", "{C50859B7-7F2C-4308-B9F7-86119A83E155}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDataModels", "HospitalDataModels\HospitalDataModels.csproj", "{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalContracts", "HospitalContracts\HospitalContracts.csproj", "{78516D88-C507-42D8-B534-89BBB1D8E136}"
@ -23,6 +25,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C50859B7-7F2C-4308-B9F7-86119A83E155}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C50859B7-7F2C-4308-B9F7-86119A83E155}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C50859B7-7F2C-4308-B9F7-86119A83E155}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C50859B7-7F2C-4308-B9F7-86119A83E155}.Release|Any CPU.Build.0 = Release|Any CPU
{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CBB9321-2FA0-453A-970F-D8DCD6D4C654}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -17,12 +17,12 @@ namespace HospitalBusinessLogic.BusinessLogics
{
private readonly ILogger _logger;
private readonly IDescriptionProcedureStorage _descriptionProcedureStorage;
private readonly IDescriptionProcedureStorage _guidanceStorage;
public DescriptionProcedureLogic(ILogger<DescriptionProcedureLogic> logger, IDescriptionProcedureStorage descriptionProcedureStorage)
public DescriptionProcedureLogic(ILogger<DescriptionProcedureLogic> logger, IDescriptionProcedureStorage guidanceStorage)
{
_logger = logger;
_descriptionProcedureStorage = descriptionProcedureStorage;
_guidanceStorage = guidanceStorage;
}
public DescriptionProcedureViewModel? ReadElement(DescriptionProcedureSearchModel model)
@ -32,7 +32,7 @@ namespace HospitalBusinessLogic.BusinessLogics
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _descriptionProcedureStorage.GetElement(model);
var element = _guidanceStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
@ -45,8 +45,8 @@ namespace HospitalBusinessLogic.BusinessLogics
public List<DescriptionProcedureViewModel>? ReadList(DescriptionProcedureSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
var list = model == null ? _descriptionProcedureStorage.GetFullList() :
_descriptionProcedureStorage.GetFilteredList(model);
var list = model == null ? _guidanceStorage.GetFullList() :
_guidanceStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
@ -59,7 +59,7 @@ namespace HospitalBusinessLogic.BusinessLogics
public bool Create(DescriptionProcedureBindingModel model)
{
CheckModel(model);
if (_descriptionProcedureStorage.Insert(model) == null)
if (_guidanceStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
@ -69,7 +69,7 @@ namespace HospitalBusinessLogic.BusinessLogics
public bool Update(DescriptionProcedureBindingModel model)
{
CheckModel(model);
if (_descriptionProcedureStorage.Update(model) == null)
if (_guidanceStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
@ -80,7 +80,7 @@ namespace HospitalBusinessLogic.BusinessLogics
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_descriptionProcedureStorage.Delete(model) == null)
if (_guidanceStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
@ -104,7 +104,7 @@ namespace HospitalBusinessLogic.BusinessLogics
nameof(model.Description));
}
_logger.LogInformation("descriptionProcedure. Text:{Text}.", model.Description);
_logger.LogInformation("Guidance. Text:{Text}.", model.Description);
}
}
}

View File

@ -99,12 +99,12 @@ true)
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия лекарства",
throw new ArgumentNullException("Нет названия медикамента",
nameof(model.Name));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена лекарства должна быть больше 0", nameof(model.Price));
throw new ArgumentNullException("Цена медикамента должна быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Medicine. Medicine:{MedicineName}. Price:{ Price }. Id: { Id}", model.Name, model.Price, model.Id);
var element = _medicineStorage.GetElement(new MedicineSearchModel
@ -113,7 +113,7 @@ true)
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Лекарство с таким названием уже есть");
throw new InvalidOperationException("Медикамент с таким названием уже есть");
}
}
}

View File

@ -106,7 +106,7 @@ namespace HospitalBusinessLogic.BusinessLogics
{
throw new ArgumentNullException("Возраст пациента должен быть больше 0", nameof(model.FIO));
}*/ //TODO
//_logger.LogInformation("Patient. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. BirthDate:{BirthDate}. DoctorId:{DoctorId}. Id:{ Id}", model.FIO, model.BirthDate, model.DoctorId, model.Id);
_logger.LogInformation("Patient. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. BirthDate:{BirthDate}. DoctorId:{DoctorId}. Id:{ Id}", model.FIO, model.BirthDate, model.DoctorId, model.Id);
var element = _patientStorage.GetElement(new PatientSearchModel
{
FIO = model.FIO,

View File

@ -1,83 +1,34 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using HospitalDataModels.Models;
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.BusinessLogicContracts;
namespace HospitalBusinessLogic.BusinessLogics
{
public class PharmacistLogic : IPharmacistLogic
{
private readonly ILogger _logger;
private readonly IPharmacistStorage _PharmacistStorage;
public PharmacistLogic(ILogger<PharmacistLogic> logger, IPharmacistStorage PharmacistStorage)
private readonly IPharmacistStorage _pharmacistStorage;
public PharmacistLogic(ILogger<PharmacistLogic> logger, IPharmacistStorage
pharmacistStorage)
{
_logger = logger;
_PharmacistStorage = PharmacistStorage;
_pharmacistStorage = pharmacistStorage;
}
public bool Create(PharmacistBindingModel model)
{
CheckModel(model);
if (_PharmacistStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(PharmacistBindingModel model)
{
CheckModel(model);
if (_PharmacistStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PharmacistBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_PharmacistStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public PharmacistViewModel? ReadElement(PharmacistSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Login:{Login}. PhoneNumber:{PhoneNumber}. Id:{ Id}", model.Login, model.PhoneNumber, model.Id);
var element = _PharmacistStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<PharmacistViewModel>? ReadList(PharmacistSearchModel? model)
{
_logger.LogInformation("ReadList. PharmacistId:{Id}", model?.Id);
var list = model == null ? _PharmacistStorage.GetFullList() : _PharmacistStorage.GetFilteredList(model);
_logger.LogInformation("ReadList. FIO:{FIO}. Id:{ Id}", model?.FIO, model?.Id);
var list = model == null ? _pharmacistStorage.GetFullList() :
_pharmacistStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
@ -86,8 +37,55 @@ namespace HospitalBusinessLogic.BusinessLogics
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(PharmacistBindingModel model, bool withParams = true)
public PharmacistViewModel? ReadElement(PharmacistSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. FIO:{FIO}.Id:{ Id}", model.FIO, model.Id);
var element = _pharmacistStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(PharmacistBindingModel model)
{
CheckModel(model);
if (_pharmacistStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(PharmacistBindingModel model)
{
CheckModel(model);
if (_pharmacistStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PharmacistBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_pharmacistStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(PharmacistBindingModel model, bool withParams =
true)
{
if (model == null)
{
@ -97,28 +95,33 @@ namespace HospitalBusinessLogic.BusinessLogics
{
return;
}
if (string.IsNullOrEmpty(model.FIO))
{
throw new ArgumentNullException("Нет ФИО клиента",
nameof(model.FIO));
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет логина врача", nameof(model.Login));
}
if (string.IsNullOrEmpty(model.PhoneNumber))
{
throw new ArgumentNullException("Нет номера телефона врача", nameof(model.PhoneNumber));
throw new ArgumentNullException("Нет Email клиента",
nameof(model.Login));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля врача", nameof(model.Password));
throw new ArgumentNullException("Нет пароля клиента",
nameof(model.Password));
}
_logger.LogInformation("Pharmacist. Login:{Login}. PhoneNumber:{PhoneNumber}. Password:{Password}. Id:{ Id}", model.Login, model.PhoneNumber, model.Password, model.Id);
var element = _PharmacistStorage.GetElement(new PharmacistSearchModel
_logger.LogInformation("Pharmacist. FIO:{FIO}." +
"Email:{ Email}. Password:{ Password}. Id: { Id} ", model.FIO, model.Login, model.Password, model.Id);
var element = _pharmacistStorage.GetElement(new PharmacistSearchModel
{
Login = model.Login,
Password = model.Password
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Врач с таким именем уже есть");
throw new InvalidOperationException("Клиент с таким логином уже есть");
}
}
}
}

View File

@ -16,18 +16,18 @@ namespace HospitalBusinessLogic.BusinessLogics
public class ProcedureLogic : IProcedureLogic
{
private readonly ILogger _logger;
private readonly IProcedureStorage _procedureStorage;
public ProcedureLogic(ILogger<ProcedureLogic> logger, IProcedureStorage procedureStorage)
private readonly IProcedureStorage _serviceStorage;
public ProcedureLogic(ILogger<ProcedureLogic> logger, IProcedureStorage serviceStorage)
{
_logger = logger;
_procedureStorage = procedureStorage;
_serviceStorage = serviceStorage;
}
public List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model)
{
_logger.LogInformation("ReadList. ProcedureName:{ProcedureName}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _procedureStorage.GetFullList() :
_procedureStorage.GetFilteredList(model);
_logger.LogInformation("ReadList. ServiceName:{ServiceName}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _serviceStorage.GetFullList() :
_serviceStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
@ -42,8 +42,8 @@ _procedureStorage.GetFilteredList(model);
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ProcedureName:{ProcedureName}.Id:{ Id}", model.Name, model.Id);
var element = _procedureStorage.GetElement(model);
_logger.LogInformation("ReadElement. ServiceName:{ServiceName}.Id:{ Id}", model.Name, model.Id);
var element = _serviceStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
@ -56,7 +56,7 @@ _procedureStorage.GetFilteredList(model);
public bool Create(ProcedureBindingModel model)
{
CheckModel(model);
if (_procedureStorage.Insert(model) == null)
if (_serviceStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
@ -67,7 +67,7 @@ _procedureStorage.GetFilteredList(model);
public bool Update(ProcedureBindingModel model)
{
CheckModel(model);
if (_procedureStorage.Update(model) == null)
if (_serviceStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
@ -78,7 +78,7 @@ _procedureStorage.GetFilteredList(model);
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_procedureStorage.Delete(model) == null)
if (_serviceStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
@ -99,18 +99,21 @@ true)
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия процедуры",
throw new ArgumentNullException("Нет названия услуги",
nameof(model.Name));
}
_logger.LogInformation("Procedure. ProcedureName:{ProcedureName}. Id: { Id}", model.Name, model.Id);
var element = _procedureStorage.GetElement(new ProcedureSearchModel
//if (model.Price <= 0)
{
// throw new ArgumentNullException("Цена мороженного услуги быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Service. ServiceName:{ServiceName}. Id: { Id}", model.Name, model.Id);
var element = _serviceStorage.GetElement(new ProcedureSearchModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Процедура с таким названием уже есть");
throw new InvalidOperationException("Услуга с таким названием уже есть");
}
}
}

View File

@ -1,272 +0,0 @@
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using HospitalBusinessLogic.OfficePackage;
using HospitalBusinessLogic.OfficePackage.HelperModels;
namespace HospitalBusinessLogic.BusinessLogics
{
public class ReportLogicDoctor : IDoctorReportLogic
{
private readonly IPatientStorage _patientStorage;
private readonly IMedicineStorage _medicineStorage;
private readonly IProcedureStorage _procedureStorage;
private readonly IRecipeStorage _recipeStorage;
private readonly IDiseaseStorage _diseaseStorage;
private readonly AbstractSaveToExcelDoctor _saveToExcel;
private readonly AbstractSaveToWordDoctor _saveToWord;
private readonly AbstractSaveToPdfDoctor _saveToPdf;
public ReportLogicDoctor(IPatientStorage patientStorage, IMedicineStorage medicineStorage, IProcedureStorage procedureStorage, IRecipeStorage recipeStorage, IDiseaseStorage diseaseStorage,
AbstractSaveToExcelDoctor saveToExcel, AbstractSaveToWordDoctor saveToWord, AbstractSaveToPdfDoctor saveToPdf)
{
_patientStorage = patientStorage;
_medicineStorage = medicineStorage;
_procedureStorage = procedureStorage;
_recipeStorage = recipeStorage;
_diseaseStorage = diseaseStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
}
//отчет по лекарствам и болезням у пациента за период
/*public List<ReportPatientViewModel> GetPatientDiseases(ReportBindingModel model, PatientBindingModel patientModel)
{
var list = new List<ReportPatientViewModel>();
var patients = _patientStorage.GetFilteredList(new PatientSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo, Id = patientModel.Id });
foreach (var patient in patients)
{
var purchase = _patientStorage.GetElement(new() { Id = patient.Id })!;
List<string> diseaseList = new List<string>();
List<string> patientList = new List<string>();
foreach (var recipe in _recipeStorage.GetFilteredList(new RecipeSearchModel {PatientId = patient.Id}))
{
foreach (var patient in _patientStorage.GetFilteredList(new PatientSearchModel { RecipeId = recipe.Id }))
{
patientList.Add(new(patient.Name));
foreach (var disease in patient.PatientRecipes)
{
diseaseList.Add(disease.Value.Description);
}
}
}
var record = new ReportPatientViewModel
{
Id = purchase.Id,
FIO = patient.FIO,
Diseases = diseaseList,
Patients = patientList
};
list.Add(record);
}
return list;
}
public List<ReportPatientRecipeViewModel> GetPatients()
{
var list = new List<ReportPatientRecipeViewModel>();
var patients = _patientStorage.GetFullList();
foreach (var patient in patients)
{
var purchase = _patientStorage.GetElement(new() { Id = patient.Id })!;
List<string> diseaseList = new List<string>();
List<string> recipeList = new List<string>();
foreach (var recipe in _recipeStorage.GetFilteredList(new RecipeSearchModel { PatientId = patient.Id }))
{
recipeList.Add(recipe.IssueDate.ToString());
foreach (var disease in _diseaseStorage.GetFilteredList(new DiseaseSearchModel { RecipeId = recipe.Id }))
{
diseaseList.Add(disease.Name);
}
}
var record = new ReportPatientRecipeViewModel
{
Diseases = diseaseList,
Recipes = recipeList
};
list.Add(record);
}
return list;
}
public void SaveProcedureRecipesToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public List<ListProceduresViewModel> GetRecipeProcedures(List<int> recipes)
{
List<ListProceduresViewModel> ans = new();
List<Tuple<RecipeViewModel, List<Tuple<PatientViewModel, List<ProcedureViewModel>>>>> response =
_recipeStorage.GetReportInfo(new ListProceduresSearchModel { recipesIds = recipes });
foreach (var recipe in response)
{
Dictionary<int, (ProcedureViewModel, int)> counter = new();
foreach (var patient in recipe.Item2)
{
foreach (var procedure in patient.Item2)
{
if (!counter.ContainsKey(procedure.Id))
counter.Add(procedure.Id, (procedure, 1));
else
{
counter[procedure.Id] = (counter[procedure.Id].Item1, counter[procedure.Id].Item2 + 1);
}
}
}
List<ProcedureViewModel> res = new();
foreach (var cnt in counter)
{
if (cnt.Value.Item2 != recipe.Item2.Count)
continue;
res.Add(cnt.Value.Item1);
}
ans.Add(new ListProceduresViewModel
{
RecipeName = recipe.Item1.Description,
Procedures = res
});
}
return ans;
}
}*/
public List<ListProceduresViewModel> GetRecipeProcedures(List<int> recipes)
{
List<ListProceduresViewModel> ans = new();
List<Tuple<RecipeViewModel, List<Tuple<PatientViewModel, List<ProcedureViewModel>>>>> response =
_recipeStorage.GetReportInfo(new ListProceduresSearchModel { recipesIds = recipes });
foreach (var recipe in response)
{
Dictionary<int, (ProcedureViewModel, int)> counter = new();
foreach (var patient in recipe.Item2)
{
foreach (var procedure in patient.Item2)
{
if (!counter.ContainsKey(procedure.Id))
counter.Add(procedure.Id, (procedure, 1));
else
{
counter[procedure.Id] = (counter[procedure.Id].Item1, counter[procedure.Id].Item2 + 1);
}
}
}
List<ProcedureViewModel> res = new();
foreach (var cnt in counter)
{
if (cnt.Value.Item2 != recipe.Item2.Count)
continue;
res.Add(cnt.Value.Item1);
}
ans.Add(new ListProceduresViewModel
{
RecipeName = recipe.Item1.Description,
Procedures = res
});
}
return ans;
}
public void SaveProceduresToExcelFile(ListProceduresBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoDoctor
{
FileName = model.FileName,
Title = "Список процедур для рецептов",
RecipesProcedures = GetRecipeProcedures(model.Recipes)
});
}
public void SaveProceduresToWordFile(ListProceduresBindingModel model)
{
_saveToWord.CreateDoc(new WordInfoDoctor
{
FileName = model.FileName,
Title = "Список процедур для рецептов",
RecipesProcedures = GetRecipeProcedures(model.Recipes)
});
}
public List<MedicinesDiseasesViewModel> GetPatientMedicinesAndDiseases(MedicinesDiseasesBindingModel model)
{
List<MedicinesDiseasesViewModel> ans = new();
List<Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<DiseaseViewModel>>>>> responseDisease =
_patientStorage.GetDiseasesInfo(new MedicineDiseasesSearchModel { DateFrom = model.DateFrom!, DateTo = model.DateTo!, DoctorId = model.DoctorId! });
List<Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<MedicineViewModel>>>>> responseMedicines =
_patientStorage.GetMedicinesInfo(new MedicineDiseasesSearchModel { DateFrom = model.DateFrom!, DateTo = model.DateTo!, DoctorId = model.DoctorId! });
Dictionary<int, MedicinesDiseasesViewModel> dict = new();
foreach (var patient in responseDisease)
{
dict.Add(patient.Item1.Id, new());
dict[patient.Item1.Id].PatientFIO = patient.Item1.FIO;
dict[patient.Item1.Id].Date = patient.Item1.BirthDate;
foreach (var recipe in patient.Item2)
{
foreach (var guidance in recipe.Item2)
{
dict[patient.Item1.Id].Diseases.Add(guidance);
}
}
}
foreach (var patient in responseMedicines)
{
HashSet<int> used = new();
foreach (var recipe in patient.Item2)
{
foreach (var medicine in recipe.Item2)
{
if (used.Contains(medicine.Id))
continue;
dict[patient.Item1.Id].Medicines.Add(medicine);
}
}
ans.Add(dict[patient.Item1.Id]);
}
return ans;
}
public void SavePatientsToPdfFile(MedicinesDiseasesBindingModel model)
{
_saveToPdf.CreateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Список пациентов",
DateFrom = model.DateFrom!,
DateTo = model.DateTo!,
Patients = GetPatientMedicinesAndDiseases(model)
});
}
}
}

View File

@ -1,89 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalBusinessLogic.OfficePackage;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
namespace HospitalBusinessLogic.BusinessLogics
{
public class ReportLogicPharmacist : IReportLogicPharmacist
{
private readonly IProcedureStorage _procedureStorage;
private readonly IMedicineStorage _medicineStorage;
private readonly AbstractSaveToExcelPharmacist _saveToExcel;
private readonly AbstractSaveToWordPharmacist _saveToWord;
public ReportLogicPharmacist(IProcedureStorage procedureStorage, IMedicineStorage medicineStorage,
AbstractSaveToExcelPharmacist saveToExcel, AbstractSaveToWordPharmacist saveToWord)
{
_procedureStorage = procedureStorage;
_medicineStorage = medicineStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
}
public List<ListRecipesViewModel> GetProcedureRecipes(List<int> procedures)
{
List<ListRecipesViewModel> ans = new();
List<Tuple<ProcedureViewModel, List<Tuple<MedicineViewModel, List<RecipeViewModel>>>>> response =
_procedureStorage.GetReportInfo(new ListRecipesSearchModel { proceduresIds = procedures });
foreach (var procedure in response)
{
Dictionary<int, (RecipeViewModel, int)> counter = new();
foreach (var medicine in procedure.Item2)
{
foreach (var recipe in medicine.Item2)
{
if (!counter.ContainsKey(recipe.Id))
counter.Add(recipe.Id, (recipe, 1));
else
{
counter[recipe.Id] = (counter[recipe.Id].Item1, counter[recipe.Id].Item2 + 1);
}
}
}
List<RecipeViewModel> res = new();
foreach (var cnt in counter)
{
if (cnt.Value.Item2 != procedure.Item2.Count)
continue;
res.Add(cnt.Value.Item1);
}
ans.Add(new ListRecipesViewModel
{
ProcedureName = procedure.Item1.Name,
Recipes = res
});
}
return ans;
}
public void SaveRecipesToExcelFile(ListRecipesBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoPharmacist
{
FileName = model.FileName,
Title = "Список рецептов для процедур",
ProceduresRecipes = GetProcedureRecipes(model.Procedures)
});
}
public void SaveRecipesToWordFile(ListRecipesBindingModel model)
{
_saveToWord.CreateDoc(new WordInfoPharmacist
{
FileName = model.FileName,
Title = "Список рецептов для процедур",
ProceduresRecipes = GetProcedureRecipes(model.Procedures)
});
}
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -7,10 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.9" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.1.30" />
</ItemGroup>
<ItemGroup>

View File

@ -1,64 +0,0 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.MailWorker
{
public abstract class AbstractMailWorker
{
protected string _mailLogin = string.Empty;
protected string _mailPassword = string.Empty;
protected string _smtpClientHost = string.Empty;
protected int _smtpClientPort;
protected string _popHost = string.Empty;
protected int _popPort;
private readonly IPharmacistLogic _pharmacistLogic;
private readonly ILogger _logger;
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IPharmacistLogic pharmacistLogic)
{
_logger = logger;
_pharmacistLogic = pharmacistLogic;
}
public void MailConfig(MailConfigBindingModel config)
{
_mailLogin = config.MailLogin;
_mailPassword = config.MailPassword;
_smtpClientHost = config.SmtpClientHost;
_smtpClientPort = config.SmtpClientPort;
_popHost = config.PopHost;
_popPort = config.PopPort;
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
}
public async void MailSendAsync(MailSendInfoBindingModel info)
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
{
return;
}
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
{
return;
}
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
await SendMailAsync(info);
}
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
}
}

View File

@ -1,50 +0,0 @@
using HospitalContracts.BusinessLogicContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Net.Mime;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
namespace HospitalBusinessLogic.MailWorker
{
public class MailKitWorker : AbstractMailWorker
{
public MailKitWorker(ILogger<MailKitWorker> logger, IPharmacistLogic pharmacistLogic) : base(logger, pharmacistLogic) { }
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
{
using var objMailMessage = new MailMessage();
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
try
{
objMailMessage.From = new MailAddress(_mailLogin);
objMailMessage.To.Add(new MailAddress(info.MailAddress));
objMailMessage.Subject = info.Subject;
objMailMessage.Body = info.Text;
objMailMessage.SubjectEncoding = Encoding.UTF8;
objMailMessage.BodyEncoding = Encoding.UTF8;
Attachment attachment = new Attachment("C:\\ReportsCourseWork\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
objMailMessage.Attachments.Add(attachment);
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.EnableSsl = true;
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
await Task.Run(() => objSmtpClient.Send(objMailMessage));
}
catch (Exception)
{
throw;
}
}
}
}

View File

@ -1,73 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcelDoctor
{
public void CreateReport(ExcelInfoDoctor 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 rec in info.RecipesProcedures)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = rec.ProcedureName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var animal in rec.Procedures)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = animal.Name,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfoDoctor info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfoDoctor info);
}
}

View File

@ -1,72 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcelPharmacist
{
public void CreateReport(ExcelInfoPharmacist 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 rec in info.ProceduresRecipes)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = rec.ProcedureName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var animal in rec.Recipes)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = animal.Description,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfoPharmacist info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfoPharmacist info);
}
}

View File

@ -1,74 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfDoctor
{
public void CreateDoc(PdfInfo 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> { "4cm", "4cm", "4cm", "4cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Дата", "ФИО пациента", "Болезнь",
"Лекарство" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var patient in info.Patients)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { patient.Date.ToString(), patient.PatientFIO, "", "" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var disease in patient.Diseases)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", "", disease.Name.ToString(), "" },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
}
foreach (var medicine in patient.Medicines)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", "", "", medicine.Name.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
}
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfo info);
}
}

View File

@ -1,61 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWordDoctor
{
public void CreateDoc(WordInfoDoctor info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
foreach (var rec in info.RecipesProcedures)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (rec.ProcedureName, new WordTextProperties { Size = "24", Bold=true})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
foreach (var procedure in rec.Procedures)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (procedure.Name, new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
}
SaveWord(info);
}
protected abstract void CreateWord(WordInfoDoctor info);
protected abstract void CreateParagraph(WordParagraph paragraph);
protected abstract void SaveWord(WordInfoDoctor info);
}
}

View File

@ -1,61 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWordPharmacist
{
public void CreateDoc(WordInfoPharmacist info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
foreach (var rec in info.ProceduresRecipes)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (rec.ProcedureName, new WordTextProperties { Size = "24", Bold=true})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
foreach (var animal in rec.Recipes)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (animal.Description, new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
}
SaveWord(info);
}
protected abstract void CreateWord(WordInfoPharmacist info);
protected abstract void CreateParagraph(WordParagraph paragraph);
protected abstract void SaveWord(WordInfoPharmacist info);
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperEnums
{
public enum ExcelStyleInfoType
{
Title,
Text,
TextWithBroder
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperEnums
{
public enum PdfParagraphAlignmentType
{
Center,
Left,
Rigth
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperEnums
{
public enum WordJustificationType
{
Center,
Both
}
}

View File

@ -1,19 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
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

@ -1,20 +0,0 @@
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfoDoctor
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ListProceduresViewModel> RecipesProcedures
{
get;
set;
} = new();
}
}

View File

@ -1,21 +0,0 @@
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.ViewModels;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfoPharmacist
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ListRecipesViewModel> ProceduresRecipes
{
get;
set;
} = new();
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class ExcelMergeParameters
{
public string CellFromName { get; set; } = string.Empty;
public string CellToName { get; set; } = string.Empty;
public string Merge => $"{CellFromName}:{CellToName}";
}
}

View File

@ -1,18 +0,0 @@
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<MedicinesDiseasesViewModel> Patients { get; set; } = new();
}
}

View File

@ -1,17 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class PdfParagraph
{
public string Text { get; set; } = string.Empty;
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,17 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class PdfRowParameters
{
public List<string> Texts { get; set; } = new();
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,16 +0,0 @@
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class WordInfoDoctor
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ListProceduresViewModel> RecipesProcedures { get; set; } = new();
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.ViewModels;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class WordInfoPharmacist
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ListRecipesViewModel> ProceduresRecipes { get; set; } = new();
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class WordParagraph
{
public List<(string, WordTextProperties)> Texts { get; set; } = new();
public WordTextProperties? TextProperties { get; set; }
}
}

View File

@ -1,17 +0,0 @@
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
namespace HospitalBusinessLogic.OfficePackage.HelperModels
{
public class WordTextProperties
{
public string Size { get; set; } = string.Empty;
public bool Bold { get; set; }
public WordJustificationType JustificationType { get; set; }
}
}

View File

@ -1,333 +0,0 @@
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.Implements
{
public class SaveToExcelDoctor : AbstractSaveToExcelDoctor
{
private SpreadsheetDocument? _spreadsheetDocument;
private SharedStringTablePart? _shareStringPart;
private Worksheet? _worksheet;
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);
}
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
{
return styleInfo switch
{
ExcelStyleInfoType.Title => 2U,
ExcelStyleInfoType.TextWithBroder => 1U,
ExcelStyleInfoType.Text => 0U,
_ => 0U,
};
}
protected override void CreateExcel(ExcelInfoDoctor 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>();
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(ExcelInfoDoctor info)
{
if (_spreadsheetDocument == null)
{
return;
}
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
_spreadsheetDocument.Dispose();
}
}
}

View File

@ -1,335 +0,0 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using HospitalBusinessLogic.OfficePackage;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using Microsoft.Extensions.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetClinicBusinessLogic.OfficePackage.Implements
{
public class SaveToExcelPharmacist : AbstractSaveToExcelPharmacist
{
private SpreadsheetDocument? _spreadsheetDocument;
private SharedStringTablePart? _shareStringPart;
private Worksheet? _worksheet;
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);
}
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
{
return styleInfo switch
{
ExcelStyleInfoType.Title => 2U,
ExcelStyleInfoType.TextWithBroder => 1U,
ExcelStyleInfoType.Text => 0U,
_ => 0U,
};
}
protected override void CreateExcel(ExcelInfoPharmacist 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>();
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(ExcelInfoPharmacist info)
{
if (_spreadsheetDocument == null)
{
return;
}
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
_spreadsheetDocument.Dispose();
}
}
}

View File

@ -1,109 +0,0 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
namespace HospitalBusinessLogic.OfficePackage.Implements
{
public class SaveToPdfDoctor : AbstractSaveToPdfDoctor
{
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(PdfInfo 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(PdfInfo info)
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -1,117 +0,0 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.OfficePackage.Implements
{
public class SaveToWordDoctor : AbstractSaveToWordDoctor
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
private static JustificationValues
GetJustificationValues(WordJustificationType type)
{
return type switch
{
WordJustificationType.Both => JustificationValues.Both,
WordJustificationType.Center => JustificationValues.Center,
_ => JustificationValues.Left,
};
}
private static SectionProperties CreateSectionProperties()
{
var properties = new SectionProperties();
var pageSize = new PageSize
{
Orient = PageOrientationValues.Portrait
};
properties.AppendChild(pageSize);
return properties;
}
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(WordInfoDoctor 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(WordInfoDoctor info)
{
if (_docBody == null || _wordDocument == null)
{
return;
}
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Dispose();
}
}
}

View File

@ -1,118 +0,0 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalBusinessLogic.OfficePackage.HelperEnums;
using HospitalBusinessLogic.OfficePackage.HelperModels;
using HospitalBusinessLogic.OfficePackage;
namespace VetClinicBusinessLogic.OfficePackage.Implements
{
public class SaveToWordPharmacist : AbstractSaveToWordPharmacist
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
private static JustificationValues
GetJustificationValues(WordJustificationType type)
{
return type switch
{
WordJustificationType.Both => JustificationValues.Both,
WordJustificationType.Center => JustificationValues.Center,
_ => JustificationValues.Left,
};
}
private static SectionProperties CreateSectionProperties()
{
var properties = new SectionProperties();
var pageSize = new PageSize
{
Orient = PageOrientationValues.Portrait
};
properties.AppendChild(pageSize);
return properties;
}
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(WordInfoPharmacist 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(WordInfoPharmacist info)
{
if (_docBody == null || _wordDocument == null)
{
return;
}
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Dispose();
}
}
}

View File

@ -13,6 +13,7 @@ namespace HospitalContracts.BindingModels
public string Description { get; set; } = string.Empty;
public int PharmacistId { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class ListProceduresBindingModel
{
public string FileName { get; set; } = string.Empty;
public List<int> Recipes { get; set; } = new();
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class ListRecipesBindingModel
{
public string FileName { get; set; } = string.Empty;
public List<int> Procedures { get; set; } = new();
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class MailConfigBindingModel
{
public string MailLogin { get; set; } = string.Empty;
public string MailPassword { get; set; } = string.Empty;
public string SmtpClientHost { get; set; } = string.Empty;
public int SmtpClientPort { get; set; }
public string PopHost { get; set; } = string.Empty;
public int PopPort { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class MailSendInfoBindingModel
{
public string MailAddress { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;
public string Text { get; set; } = string.Empty;
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class MedicinesDiseasesBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime DateFrom { get; set; } = DateTime.Now;
public DateTime DateTo { get; set; } = DateTime.Now;
public int? DoctorId { get; set; }
public string? Email { get; set; }
}
}

View File

@ -20,7 +20,6 @@ namespace HospitalContracts.BindingModels
public int DoctorId { get; set; }
public Dictionary<int, IProcedureModel> PatientProcedures { get; set; } = new();
public Dictionary<int, IRecipeModel> PatientRecipes { get; set; } = new();
}
}
}

View File

@ -1,15 +0,0 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BindingModels
{
public class PatientsDescriptionProceduresBindingModel
{
public string FileName { get; set; } = string.Empty;
public List<int> Medicines { get; set; } = new();
}
}

View File

@ -9,12 +9,11 @@ namespace HospitalContracts.BindingModels
{
public class PharmacistBindingModel : IPharmacistModel
{
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
public string FIO { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public int Id { get; set; }
}
}

View File

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

View File

@ -1,21 +0,0 @@
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicContracts
{
public interface IDoctorReportLogic
{
// List<ReportPatientRecipeViewModel> GetPatients();
List<ListProceduresViewModel> GetRecipeProcedures(List<int> services);
//List<ReportPatientViewModel> GetMedicineDiseases(ReportBindingModel model, PatientBindingModel patientModel);
List<MedicinesDiseasesViewModel> GetPatientMedicinesAndDiseases(MedicinesDiseasesBindingModel services);
void SaveProceduresToWordFile(ListProceduresBindingModel model);
void SaveProceduresToExcelFile(ListProceduresBindingModel model);
void SavePatientsToPdfFile(MedicinesDiseasesBindingModel model);
}
}

View File

@ -1,18 +0,0 @@
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
namespace HospitalContracts.BusinessLogicsContracts
{
public interface IReportLogicPharmacist //В процессе
{
List<ListRecipesViewModel> GetProcedureRecipes(List<int> procedures);
void SaveRecipesToWordFile(ListRecipesBindingModel model);
void SaveRecipesToExcelFile(ListRecipesBindingModel model);
}
}

View File

@ -11,7 +11,6 @@ namespace HospitalContracts.SearchModels
public int? Id { get; set; }
public string? Description { get; set; } = string.Empty;
public int? PharmacistId { get; set; }
public int? ProcedureId { get; set; }
}
}

View File

@ -14,6 +14,5 @@ namespace HospitalContracts.SearchModels
public string? Description { get; set; }
public int? DoctorId { get; set; }
public int? RecipeId { get; set; }
}
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class ListProceduresSearchModel
{
public List<int>? recipesIds { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class ListRecipesSearchModel
{
public List<int>? proceduresIds { get; set; }
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class MedicineDiseasesSearchModel
{
public List<int>? patientsIds { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? DoctorId { get; set; }
}
}

View File

@ -13,7 +13,5 @@ namespace HospitalContracts.SearchModels
public string? CountryOrigin { get; set; }
public double? Price { get; set; }
public int? PharmacistId { get; set; }
public int? RecipeId { get; set; }
}
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.SearchModels
{
public class PatientDescriptionProceduresSearchModel
{
public List<int>? medicinesIds { get; set; }
}
}

View File

@ -11,8 +11,6 @@ namespace HospitalContracts.SearchModels
public int? Id { get; set; }
public int? DoctorId { get; set; }
public int? MedicineId { get; set; }
public int? PatientId { get; set; }
DateTime IssueDate { get; }
}
}

View File

@ -13,8 +13,6 @@ namespace HospitalContracts.StoragesContracts
{
List<MedicineViewModel> GetFullList();
List<MedicineViewModel> GetFilteredList(MedicineSearchModel model);
List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>>>> GetDescriptionProceduresInfo(PatientDescriptionProceduresSearchModel model);
List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<PatientViewModel>>>>> GetPatientsInfo(PatientDescriptionProceduresSearchModel model);
MedicineViewModel? GetElement(MedicineSearchModel model);
MedicineViewModel? Insert(MedicineBindingModel model);
MedicineViewModel? Update(MedicineBindingModel model);

View File

@ -22,8 +22,5 @@ namespace HospitalContracts.StoragesContracts
PatientViewModel? Update(PatientBindingModel model);
PatientViewModel? Delete(PatientBindingModel model);
List<Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<DiseaseViewModel>>>>> GetDiseasesInfo(MedicineDiseasesSearchModel model);
List<Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<MedicineViewModel>>>>> GetMedicinesInfo(MedicineDiseasesSearchModel model);
}
}

View File

@ -13,7 +13,6 @@ namespace HospitalContracts.StoragesContracts
{
List<ProcedureViewModel> GetFullList();
List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model);
List<Tuple<ProcedureViewModel, List<Tuple<MedicineViewModel, List<RecipeViewModel>>>>> GetReportInfo(ListRecipesSearchModel model);
ProcedureViewModel? GetElement(ProcedureSearchModel model);
ProcedureViewModel? Insert(ProcedureBindingModel model);
ProcedureViewModel? Update(ProcedureBindingModel model);

View File

@ -22,8 +22,6 @@ namespace HospitalContracts.StoragesContracts
RecipeViewModel? Update(RecipeBindingModel model);
RecipeViewModel? Delete(RecipeBindingModel model);
List<Tuple<RecipeViewModel, List<Tuple<PatientViewModel, List<ProcedureViewModel>>>>> GetReportInfo(ListProceduresSearchModel model);
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class ListProceduresViewModel
{
public string ProcedureName { get; set; } = string.Empty;
public string RecipeName { get; set; } = string.Empty;
public List<ProcedureViewModel> Procedures { get; set; } = new();
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class ListRecipesViewModel
{
public string ProcedureName { get; set; } = string.Empty;
public List<RecipeViewModel> Recipes { get; set; } = new();
public List<ProcedureViewModel> Procedures { get; set; } = new();
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class MedicinesDiseasesViewModel
{
public string PatientFIO { get; set; } = string.Empty;
public DateTime Date { get; set; } = new DateTime();
public List<MedicineViewModel> Medicines { get; set; } = new();
public List<DiseaseViewModel> Diseases { get; set; } = new();
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HospitalContracts.ViewModels;
namespace HospitalDataBaseImplement.Implements
{
public class PatientsDescriptionProceduresViewModel
{
public string PatientName { get; set; } = string.Empty;
public List<PatientViewModel> Patients { get; set; } = new();
public List<DescriptionProcedureViewModel> DescriptionProcedures { get; set; } = new();
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class ReportPatientRecipeViewModel
{
public List<string> Recipes { get; set; } = new();
public List<string> Diseases { get; set; } = new();
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.ViewModels
{
public class ReportPatientViewModel
{
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
public List<string> Medicines { get; set; } = new();
public List<string> Diseases { get; set; } = new();
}
}

View File

@ -19,55 +19,23 @@ namespace HospitalDatabaseImplement.Implements
public List<MedicineViewModel> GetFullList()
{
using var context = new HospitalDatabase();
return context.Medicines.Include(x => x.Pharmacist).Include(x => x.Recipes)
.ThenInclude(x => x.Recipe)
.Select(x => x.GetViewModel)
.ToList();
return context.Medicines
.Select(x => x.GetViewModel).ToList();
}
public List<MedicineViewModel> GetFilteredList(MedicineSearchModel model)
{
using var context = new HospitalDatabase();
return context.Medicines.Include(x => x.Pharmacist).Include(x => x.Recipes)
.ThenInclude(x => x.Recipe).Include(x => x.Procedures).ThenInclude(x => x.Procedure)
.Where(x => (string.IsNullOrEmpty(model.Name) || x.Name.Contains(model.Name))
&& (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId))
.Select(x => x.GetViewModel)
.ToList();
}
public List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>>>> GetDescriptionProceduresInfo(PatientDescriptionProceduresSearchModel model)
{
if (model.medicinesIds == null)
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Medicines
.Where(x => x.Name.Contains(model.Name)).ToList()
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
using var context = new HospitalDatabase();
return context.Medicines
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>>>(medicine.GetViewModel,
context.ProcedureMedicines.Include(procedure => procedure.Procedure)
.Include(procedure => procedure.Medicine).Where(procedure => medicine.Id == procedure.MedicineId).
Select(procedure => new Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>(procedure.Procedure.GetViewModel,
context.DescriptionProcedures.Include(x => x.Procedures).
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
}
public List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<PatientViewModel>>>>> GetPatientsInfo(PatientDescriptionProceduresSearchModel model)
{
if (model.medicinesIds == null)
{
return new();
}
using var context = new HospitalDatabase();
return context.Medicines
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<PatientViewModel>>>>(medicine.GetViewModel,
context.ProcedureMedicines.Include(procedure => procedure.Procedure)
.Include(procedure => procedure.Medicine).Where(procedure => medicine.Id == procedure.MedicineId).
Select(procedure => new Tuple<ProcedureViewModel, List<PatientViewModel>>(procedure.Procedure.GetViewModel,
context.PatientProcedures.Include(x => x.Patient).Where(x => x.ProcedureId == procedure.ProcedureId ).
Select(x => x.Patient.GetViewModel).ToList())).ToList())).ToList();
}
public MedicineViewModel? GetElement(MedicineSearchModel model)
@ -77,14 +45,8 @@ namespace HospitalDatabaseImplement.Implements
return null;
}
using var context = new HospitalDatabase();
return context.Medicines.Include(x => x.Pharmacist)
.Include(x => x.Recipes)
.ThenInclude(x => x.Recipe)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) &&
x.Name == model.Name) ||
(model.Id.HasValue && x.Id ==
model.Id))
?.GetViewModel;
return context.Medicines
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public MedicineViewModel? Insert(MedicineBindingModel model)
@ -106,18 +68,14 @@ namespace HospitalDatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
var medicine = context.Medicines.Include(x => x.Pharmacist)
.Include(x => x.Recipes)
.ThenInclude(x => x.Recipe).FirstOrDefault(rec =>
rec.Id == model.Id);
var medicine = context.Medicines
.FirstOrDefault(rec => rec.Id == model.Id);
if (medicine == null)
{
return null;
}
medicine.Update(model);
context.SaveChanges();
if (model.MedicineRecipes != null)
medicine.UpdateRecipes(context, model);
transaction.Commit();
return medicine.GetViewModel;
}
@ -126,15 +84,13 @@ namespace HospitalDatabaseImplement.Implements
transaction.Rollback();
throw;
}
}
public MedicineViewModel? Delete(MedicineBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Medicines.Include(x => x.Pharmacist)
.Include(x => x.Recipes).ThenInclude(x => x.Recipe)
.FirstOrDefault(rec => rec.Id == model.Id);
var element = context.Medicines
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Medicines.Remove(element);

View File

@ -17,17 +17,17 @@ namespace HospitalDatabaseImplement.Implements
{
public PharmacistViewModel? GetElement(PharmacistSearchModel model)
{
if ((string.IsNullOrEmpty(model.Login) && !model.Id.HasValue))
if (!model.Id.HasValue)
{
return null;
}
using var context = new HospitalDatabase();
return context.Pharmacists
.FirstOrDefault(x =>
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Login) || x.Login == model.Login) &&
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
?.GetViewModel;
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
public List<PharmacistViewModel> GetFilteredList(PharmacistSearchModel model)
@ -59,19 +59,19 @@ namespace HospitalDatabaseImplement.Implements
public PharmacistViewModel? Insert(PharmacistBindingModel model)
{
var newPharmacist = Pharmacist.Create(model);
if (newPharmacist == null)
var newDoctor = Pharmacist.Create(model);
if (newDoctor == null)
{
return null;
}
using var context = new HospitalDatabase();
context.Pharmacists.Add(newPharmacist);
context.Pharmacists.Add(newDoctor);
context.SaveChanges();
return context.Pharmacists
.Include(x => x.Medicines)
.Include(x => x.Procedures)
.Include(x => x.DescriptionProcedures)
.FirstOrDefault(x => x.Id == newPharmacist.Id)
.FirstOrDefault(x => x.Id == newDoctor.Id)
?.GetViewModel;
}

View File

@ -37,6 +37,8 @@ namespace HospitalDatabaseImplement.Models
return new DescriptionProcedure()
{
Id = model.Id,
Description = model.Description,
PharmacistId = model.PharmacistId,
Pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.PharmacistId)

View File

@ -12,12 +12,4 @@
<None Remove="Enums\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -31,7 +31,7 @@ namespace HospitalDatabaseImplement.Implementss
public List<DiseaseViewModel> GetFilteredList(DiseaseSearchModel model)
{
using var context = new HospitalDatabase();
if (string.IsNullOrEmpty(model.Name) && model.Id.HasValue)
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Diseases
.Include(x => x.Recipes)

View File

@ -118,30 +118,5 @@ namespace HospitalDatabaseImplement.Implementss
}
return null;
}
public List<Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<DiseaseViewModel>>>>> GetDiseasesInfo(MedicineDiseasesSearchModel model)
{
using var context = new HospitalDatabase();
return context.Patients.Where(patient => patient.DoctorId == model.DoctorId && patient.BirthDate >= model.DateFrom && patient.BirthDate <= model.DateTo)
.Select(patient => new Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<DiseaseViewModel>>>>(patient.GetViewModel,
context.PatientRecipes.Include(recipe => recipe.Recipe)
.Include(recipe => recipe.Patient).Where(recipe => patient.Id == recipe.PatientId).
Select(recipe => new Tuple<RecipeViewModel, List<DiseaseViewModel>>(recipe.Recipe.GetViewModel,
context.Diseases.Include(x => x.Recipes).Where(x => x.Id == recipe.RecipeId).
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
}
public List<Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<MedicineViewModel>>>>> GetMedicinesInfo(MedicineDiseasesSearchModel model)
{
using var context = new HospitalDatabase();
return context.Patients.Where(patient => patient.DoctorId == model.DoctorId && patient.BirthDate >= model.DateFrom && patient.BirthDate <= model.DateTo)
.Select(patient => new Tuple<PatientViewModel, List<Tuple<RecipeViewModel, List<MedicineViewModel>>>>(patient.GetViewModel,
context.PatientRecipes.Include(recipe => recipe.Recipe)
.Include(recipe => recipe.Patient).Where(recipe => patient.Id == recipe.PatientId).
Select(recipe => new Tuple<RecipeViewModel, List<MedicineViewModel>>(recipe.Recipe.GetViewModel,
context.RecipeMedicines.Include(x => x.Medicine).Where(x => x.RecipeId == recipe.RecipeId ).
Select(x => x.Medicine.GetViewModel).ToList())).ToList())).ToList();
}
}
}

View File

@ -26,14 +26,17 @@ namespace HospitalDatabaseImplement.Implements
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
{
using var context = new HospitalDatabase();
return context.Procedures.Include(x => x.Pharmacist)
.Include(x => x.Medicines)
.ThenInclude(x => x.Medicine)
.Where(x => (string.IsNullOrEmpty(model.Name) || x.Name.Contains(model.Name))
&& (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return context.Procedures
.Include(x => x.Medicines)
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel).ToList();
}
else
{
return new();
}
}
public ProcedureViewModel? GetElement(ProcedureSearchModel model)
@ -43,14 +46,10 @@ namespace HospitalDatabaseImplement.Implements
return null;
}
using var context = new HospitalDatabase();
return context.Procedures.Include(x => x.Pharmacist)
.Include(x => x.Medicines)
.ThenInclude(x => x.Medicine)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) &&
x.Name == model.Name) ||
(model.Id.HasValue && x.Id ==
model.Id))
?.GetViewModel;
return context.Procedures
.Include(x => x.Medicines)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ProcedureViewModel? Insert(ProcedureBindingModel model)
@ -65,23 +64,6 @@ namespace HospitalDatabaseImplement.Implements
context.SaveChanges();
return newProcedure.GetViewModel;
}
public List<Tuple<ProcedureViewModel, List<Tuple<MedicineViewModel, List<RecipeViewModel>>>>> GetReportInfo(ListRecipesSearchModel model)
{
if (model.proceduresIds == null)
{
return new();
}
using var context = new HospitalDatabase();
return context.Procedures
.Where(procedure => model.proceduresIds.Contains(procedure.Id))
.Select(procedure => new Tuple<ProcedureViewModel, List<Tuple<MedicineViewModel, List<RecipeViewModel>>>>(procedure.GetViewModel,
context.ProcedureMedicines.Include(medicine => medicine.Medicine)
.Include(medicine => medicine.Procedure).Where(medicine => procedure.Id == medicine.ProcedureId).
Select(medicine => new Tuple<MedicineViewModel, List<RecipeViewModel>>(medicine.Medicine.GetViewModel,
context.RecipeMedicines.Include(x => x.Recipe).Where(x => x.MedicineId == medicine.Medicine.Id).
Select(x => x.Recipe.GetViewModel).ToList())).ToList())).ToList();
}
public ProcedureViewModel? Update(ProcedureBindingModel model)
{
@ -89,18 +71,17 @@ namespace HospitalDatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
var Procedure = context.Procedures.Include(x => x.Pharmacist)
.Include(x => x.Medicines).ThenInclude(x => x.Medicine).FirstOrDefault(rec =>
rec.Id == model.Id);
if (Procedure == null)
var procedure = context.Procedures
.FirstOrDefault(rec => rec.Id == model.Id);
if (procedure == null)
{
return null;
}
Procedure.Update(model);
procedure.Update(model);
context.SaveChanges();
Procedure.UpdateMedicines(context, model);
procedure.UpdateMedicines(context, model);
transaction.Commit();
return Procedure.GetViewModel;
return procedure.GetViewModel;
}
catch
{
@ -112,10 +93,9 @@ namespace HospitalDatabaseImplement.Implements
public ProcedureViewModel? Delete(ProcedureBindingModel model)
{
using var context = new HospitalDatabase();
var element = context.Procedures.Include(x => x.Pharmacist)
.Include(x => x.Medicines)
.ThenInclude(x => x.Medicine)
.FirstOrDefault(rec => rec.Id == model.Id);
var element = context.Procedures
.Include(x => x.Medicines)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Procedures.Remove(element);

View File

@ -26,7 +26,7 @@ namespace HospitalDatabaseImplement.Implementss
public List<RecipeViewModel> GetFilteredList(RecipeSearchModel model)
{
using var context = new HospitalDatabase();
if (model.Id.HasValue)
if (!model.Id.HasValue)
{
return context.Recipes
.Include(x => x.Doctor)
@ -58,10 +58,8 @@ namespace HospitalDatabaseImplement.Implementss
}
using var context = new HospitalDatabase();
return context.Recipes
.Include(x => x.Disease)
.Include(x => x.Doctor)
.Include(x => x.Patients)
.Include(x => x.Doctor)
.Include(x => x.Patients)
.ThenInclude(x => x.Patient)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
@ -121,22 +119,5 @@ namespace HospitalDatabaseImplement.Implementss
}
return null;
}
public List<Tuple<RecipeViewModel, List<Tuple<PatientViewModel, List<ProcedureViewModel>>>>> GetReportInfo(ListProceduresSearchModel model)
{
if (model.recipesIds == null)
{
return new();
}
using var context = new HospitalDatabase();
return context.Recipes
.Where(recipe => model.recipesIds.Contains(recipe.Id))
.Select(recipe => new Tuple<RecipeViewModel, List<Tuple<PatientViewModel, List<ProcedureViewModel>>>>(recipe.GetViewModel,
context.PatientRecipes.Include(patient => patient.Patient)
.Include(patient => patient.Recipe).Where(patient => recipe.Id == patient.RecipeId).
Select(patient => new Tuple<PatientViewModel, List<ProcedureViewModel>>(patient.Patient.GetViewModel,
context.PatientProcedures.Include(x => x.Procedure).Where(x => x.PatientId == patient.Patient.Id).
Select(x => x.Procedure.GetViewModel).ToList())).ToList())).ToList();
}
}
}

View File

@ -468,7 +468,7 @@ namespace HospitalDatabaseImplement.Migrations
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("procedures")
.WithMany("Services")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -545,7 +545,7 @@ namespace HospitalDatabaseImplement.Migrations
{
b.Navigation("Recipes");
b.Navigation("procedures");
b.Navigation("Services");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>

View File

@ -465,7 +465,7 @@ namespace HospitalDatabaseImplement.Migrations
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
.WithMany("procedures")
.WithMany("Services")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -542,7 +542,7 @@ namespace HospitalDatabaseImplement.Migrations
{
b.Navigation("Recipes");
b.Navigation("procedures");
b.Navigation("Services");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>

View File

@ -40,7 +40,7 @@ namespace HospitalDatabaseImplement.Models
}
return new Disease()
{
Id = model.Id,
//Id = model.Id,
Name = model.Name,
Description = model.Description,
DoctorId = model.DoctorId

View File

@ -53,7 +53,7 @@ namespace HospitalDatabaseImplement.Models
}
return new Doctor()
{
Id = model.Id,
//Id = model.Id,
Login = model.Login,
PhoneNumber = model.PhoneNumber,
Password = model.Password,

View File

@ -51,7 +51,7 @@ namespace HospitalDatabaseImplement.Models
[ForeignKey("MedicineId")]
public virtual List<RecipeMedicine> Recipes { get; set; } = new();
[ForeignKey("MedicineId")]
public virtual List<ProcedureMedicine> Procedures { get; set; } = new();
public virtual List<ProcedureMedicine> Services { get; set; } = new();
public static Medicine Create(HospitalDatabase context,
MedicineBindingModel model)
{
@ -60,7 +60,6 @@ namespace HospitalDatabaseImplement.Models
Id = model.Id,
Name = model.Name,
Price = model.Price,
CountryOrigin = model.CountryOrigin,
Recipes = model.MedicineRecipes.Select(x => new
RecipeMedicine
{

View File

@ -72,7 +72,7 @@ namespace HospitalDatabaseImplement.Models
{
return new Patient()
{
Id = model.Id,
// Id = model.Id,
FIO = model.FIO,
Address = model.Address,
@ -97,7 +97,6 @@ namespace HospitalDatabaseImplement.Models
public PatientViewModel GetViewModel => new()
{
Id = Id,
FIO = FIO,
Address = Address,
BirthDate = BirthDate,
@ -107,14 +106,14 @@ namespace HospitalDatabaseImplement.Models
public void UpdateProcedures(HospitalDatabase context, PatientBindingModel model)
{
var procedurePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList();
if (procedurePatients != null)
var servicePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList();
if (servicePatients != null)
{ // удалили те, которых нет в модели
context.PatientProcedures.RemoveRange(procedurePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId)));
context.PatientProcedures.RemoveRange(servicePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId)));
context.SaveChanges();
foreach (var procedure in procedurePatients)
foreach (var service in servicePatients)
{
model.PatientProcedures.Remove(procedure.ProcedureId);
model.PatientProcedures.Remove(service.ProcedureId);
}
context.SaveChanges();
}

View File

@ -50,8 +50,7 @@ namespace HospitalDatabaseImplement.Models
{
Id = model.Id,
Login = model.Login,
FIO = model.FIO,
PhoneNumber = model.PhoneNumber,
PhoneNumber = model.PhoneNumber,
Password = model.Password
};
}

View File

@ -49,11 +49,6 @@ namespace HospitalDatabaseImplement.Models
return new Procedure()
{
Id = model.Id,
PharmacistId = model.PharmacistId,
Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId),
DescriptionProcedureId = model.DescriptionProcedureId,
DescriptionProcedure = context.DescriptionProcedures.First(x => x.Id == model.DescriptionProcedureId),
Date = model.Date,
Name = model.Name,
Medicines = model.ProcedureMedicines.Select(x => new ProcedureMedicine
{
@ -70,12 +65,9 @@ namespace HospitalDatabaseImplement.Models
public ProcedureViewModel GetViewModel => new()
{
Id = Id,
PharmacistId = PharmacistId,
Name = Name,
ProcedureMedicines = ProcedureMedicines,
Date = Date,
DescriptionProcedureId = DescriptionProcedureId
};
Name = Name,
ProcedureMedicines = ProcedureMedicines
};
[Required]
public DateTime Date { get; set; }

View File

@ -52,7 +52,7 @@ namespace HospitalDatabaseImplement.Modelss
{
return new Recipe()
{
Id = model.Id,
//Id = model.Id,
IssueDate = model.IssueDate,
Description = model.Description,
DiseaseId = model.DiseaseId,
@ -69,19 +69,13 @@ namespace HospitalDatabaseImplement.Modelss
{
IssueDate = model.IssueDate;
Description = model.Description;
DiseaseId = model.DiseaseId;
}
}
public RecipeViewModel GetViewModel => new()
{
Id = Id,
IssueDate = IssueDate,
Description = Description,
RecipePatients = RecipePatients,
DoctorId= DoctorId,
DiseaseId = DiseaseId
RecipePatients = RecipePatients
};
public void UpdatePatients(HospitalDatabase context, RecipeBindingModel model)

View File

@ -5,9 +5,6 @@ using HospitalDataModels.Models;
using HospitalDoctorApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Globalization;
using System.IO.Pipelines;
using System.Text;
namespace HospitalDoctorApp.Controllers
{
@ -35,7 +32,8 @@ namespace HospitalDoctorApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}"));
return
View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorId={APIClient.Doctor.Id}"));
}
public IActionResult IndexDiseases()
@ -44,7 +42,8 @@ namespace HospitalDoctorApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}"));
return
View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}"));
}
@ -153,13 +152,11 @@ namespace HospitalDoctorApp.Controllers
{
return Redirect("~/Home/");
}
ViewBag.Procedures = APIClient.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures");
return View();
}
public IActionResult CreateRecipe()
{
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>("api/disease/getdiseases");
if (APIClient.Doctor == null)
if (APIClient.Doctor == null)
{
return Redirect("~/Home/");
}
@ -167,39 +164,32 @@ namespace HospitalDoctorApp.Controllers
}
public IActionResult CreateDisease()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/");
}
return View();
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>("api/recipe/getrecipelist");
return View();
}
[HttpPost]
public void CreatePatient(string fio, string address, DateTime patientdate, List<int> procedures)
public void CreatePatient(string name, string address, DateTime patientdate)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
Dictionary<int, IProcedureModel> produresDict = new Dictionary<int, IProcedureModel>();
foreach (int procedure in procedures)
{
produresDict.Add(procedure, new ProcedureSearchModel { Id = procedure } as IProcedureModel);
}
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address))
{
throw new Exception("Ошибка в введенных данных");
}
APIClient.PostRequest("api/patient/createpatient", new PatientBindingModel
{
FIO = fio,
FIO = name,
BirthDate = patientdate,
Address = address,
DoctorId = APIClient.Doctor.Id,
PatientProcedures = produresDict
DoctorId = APIClient.Doctor.Id
});
Response.Redirect("Index");
}
[HttpPost]
public void CreateRecipe(string description, DateTime date, int disease)
public void CreateRecipe(string description, DateTime issueDate)
{
if (APIClient.Doctor == null)
{
@ -212,9 +202,8 @@ namespace HospitalDoctorApp.Controllers
APIClient.PostRequest("api/recipe/createrecipe", new RecipeBindingModel
{
Description = description,
IssueDate = date,
DoctorId = APIClient.Doctor.Id,
DiseaseId = disease
IssueDate = issueDate,
DoctorId = APIClient.Doctor.Id
});
Response.Redirect("IndexRecipes");
}
@ -236,8 +225,9 @@ namespace HospitalDoctorApp.Controllers
APIClient.PostRequest("api/disease/createdisease", new DiseaseBindingModel
{
Name = name,
DoctorId = APIClient.Doctor.Id,
Description = description
DoctorId = doctorId,
Description = description
});
Response.Redirect("IndexDiseases");
}
@ -277,24 +267,7 @@ namespace HospitalDoctorApp.Controllers
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
return View();
}
[HttpPost]
public void DeleteRecipe(int recipe)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/recipe/deleterecipe", new RecipeBindingModel
{
Id = recipe
});
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorid={APIClient.Doctor.Id}");
Response.Redirect("IndexRecipes");
}
public IActionResult DeleteDisease()
public IActionResult DeleteDisease()
{
if (APIClient.Doctor == null)
{
@ -304,6 +277,19 @@ namespace HospitalDoctorApp.Controllers
return View();
}
[HttpPost]
public void DeleteRecipe(int recipe)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/recipe/deleterecipe", new RecipeBindingModel
{
Id = recipe
});
Response.Redirect("IndexRecipes");
}
[HttpPost]
public void DeleteDisease(int disease)
{
@ -357,13 +343,11 @@ namespace HospitalDoctorApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}");
return View();
return View();
}
[HttpPost]
public void UpdateRecipe(int recipe, string description, DateTime date, int disease)
public void UpdateRecipe(int recipe, string description, DateTime issuedate)
{
if (APIClient.Doctor == null)
{
@ -378,9 +362,8 @@ namespace HospitalDoctorApp.Controllers
{
Id = recipe,
Description = description,
IssueDate = date,
DiseaseId = disease
IssueDate = issuedate
});
Response.Redirect("IndexRecipes");
}
@ -416,12 +399,12 @@ namespace HospitalDoctorApp.Controllers
});
Response.Redirect("IndexDiseases");
Response.Redirect("IndexDisease");
}
#endregion
#region Промежуточные таблицы
/*public IActionResult PatientRecipes()
public IActionResult PatientRecipes()
{
if (APIClient.Doctor == null)
{
@ -458,7 +441,7 @@ namespace HospitalDoctorApp.Controllers
RecipePatients = v
});
Response.Redirect("IndexRecipes");
}*/
}
public IActionResult ProcedurePatients()
{
if (APIClient.Doctor == null)
@ -517,7 +500,6 @@ namespace HospitalDoctorApp.Controllers
return result;
}
[HttpGet]
public Tuple<RecipeViewModel, List<string>>? GetRecipe(int recipeId)
{
@ -548,253 +530,6 @@ namespace HospitalDoctorApp.Controllers
return result;
}
#region Reports
[HttpGet]
public IActionResult ProcedureListReport()
{
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorid={APIClient.Doctor.Id}");
return View();
}
[HttpPost]
public void ProcedureListReport(List<int> recipes, string type)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (recipes.Count <= 0)
{
throw new Exception("Количество должно быть больше 0");
}
if (string.IsNullOrEmpty(type))
{
throw new Exception("Неверный тип отчета");
}
if (type == "docx")
{
APIClient.PostRequest("api/report/createprocedurelistwordfile", new ListProceduresBindingModel
{
Recipes = recipes,
FileName = "C:\\ReportsCourseWork\\wordfile.docx"
});
Response.Redirect("GetWordFile");
}
else
{
APIClient.PostRequest("api/report/createprocedurelistexcelfile", new ListProceduresBindingModel
{
Recipes = recipes,
FileName = "C:\\ReportsCourseWork\\excelfile.xlsx"
});
Response.Redirect("GetExcelFile");
}
}
[HttpGet]
public IActionResult GetWordFile()
{
return new PhysicalFileResult("C:\\ReportsCourseWork\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
}
public IActionResult GetExcelFile()
{
return new PhysicalFileResult("C:\\ReportsCourseWork\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
[HttpGet]
public IActionResult Report()
{
ViewBag.Report = new List<MedicinesDiseasesBindingModel>();
return View();
}
[HttpGet]
public string GetPatientsReport(DateTime dateFrom, DateTime dateTo)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
List<MedicinesDiseasesViewModel> result;
try
{
string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture);
string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture);
result = APIClient.GetRequest<List<MedicinesDiseasesViewModel>>
($"api/report/getmedicinesdiseasesreport?datefrom={dateFromS}&dateto={dateToS}&doctorid={APIClient.Doctor.Id}")!;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
string table = "";
table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
table += "<div class=\"table-responsive\">";
table += "<table class=\"table table-striped table-bordered table-hover\">";
table += "<thead class=\"table-dark\">";
table += "<tr>";
table += "<th scope=\"col\">Дата</th>";
table += "<th scope=\"col\">ФИО пациента</th>";
table += "<th scope=\"col\">Болезнь</th>";
table += "<th scope=\"col\">Лекарство</th>";
table += "</tr>";
table += "</thead>";
foreach (var patient in result)
{
table += "<tbody>";
table += "<tr>";
table += $"<td>{patient.Date}</td>";
table += $"<td>{patient.PatientFIO}</td>";
table += $"<td></td>";
table += $"<td></td>";
table += "</tr>";
foreach (var disease in patient.Diseases)
{
table += "<tr>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td>{disease.Name}</td>";
table += $"<td></td>";
table += "</tr>";
}
foreach (var medicine in patient.Medicines)
{
table += "<tr>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td>{medicine.Name}</td>";
table += "</tr>";
}
table += "</tbody>";
}
table += "</table>";
table += "</div>";
return table;
}
[HttpPost]
public void Report(DateTime dateFrom, DateTime dateTo)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest("api/report/sendmedicinesdiseasesreporttoemail", new MedicinesDiseasesBindingModel
{
FileName = "C:\\ReportsCourseWork\\pdffile.pdf",
DoctorId = APIClient.Doctor.Id,
DateFrom = dateFrom,
DateTo = dateTo,
Email = APIClient.Doctor.MailAddress
});
Response.Redirect("Report");
}
#endregion
public IActionResult PatientRecipes()
{
if (APIClient.Doctor == null)
{
return Redirect("~/Home/Enter");
}
/*ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
ViewBag.Animals = APIPharmacist.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist");*/
ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>("api/patient/getpatients");
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
return View();
}
[HttpPost]
public void PatientRecipes(int recipe, string description, int diseaseId,
List<int> patients)
{
if (APIClient.Doctor == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(description))
{
throw new Exception("Ошибка в введенных данных");
}
Dictionary<int, IPatientModel> a = new Dictionary<int, IPatientModel>();
foreach (int patient in patients)
{
a.Add(patient, new PatientSearchModel { Id = patient } as IPatientModel);
}
APIClient.PostRequest("api/recipe/updaterecipe?isconnection=true", new RecipeBindingModel
{
Id = recipe,
Description = description,
DoctorId = APIClient.Doctor.Id,
DiseaseId = diseaseId,
RecipePatients = a
});
Response.Redirect("Index");
}
public IActionResult Statistics()
{
//ViewBag.Patients = APIClient.GetRequest<List<PatientViewModel>>("api/patient/getpatients");
var patients = APIClient.GetRequest<List<PatientViewModel>>("api/patient/getpatients");
List<int> groups = new List<int> { 0, 0, 0, 0, 0 };
foreach ( var patient in patients)
{
groups[Convert.ToInt32(((DateTime.Now - patient.BirthDate).TotalDays / 365)) / 20] += 1;
}
ViewBag.PatientsGroups = groups;
var recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorid={APIClient.Doctor.Id}");
var diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?doctorid={APIClient.Doctor.Id}");
var diseaseLinkCounts = new Dictionary<int, int>(); // Словарь для подсчета количества рецептов
foreach (var recipe in recipes)
{
if ( diseaseLinkCounts.ContainsKey(recipe.DiseaseId))
{
diseaseLinkCounts[recipe.DiseaseId]++; // Увеличиваем счетчик для данной болезни
}
else
{
diseaseLinkCounts[recipe.DiseaseId] = 1; // Инициализируем счетчик для новой болезни
}
}
var diseaseIds = diseaseLinkCounts.Keys.Select(diseaseId => diseaseId);
List<string> diseaseNames = diseases
.Where(model => diseaseIds.Contains(model.Id))
.Select(model => model.Name)
.ToList();
var linkCounts = diseaseLinkCounts.Values;
ViewBag.DiseaseNames = diseaseNames;
ViewBag.LinkCounts = linkCounts;
ViewBag.ABC = new List<char> { 'A', 'B', 'C' };
return View();
}
}
}

View File

@ -7,7 +7,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Chart.js" Version="3.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

View File

@ -1,7 +1,7 @@
using HospitalDoctorApp;
var builder = WebApplication.CreateBuilder(args);
// Add procedures to the container.
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();

View File

@ -8,7 +8,7 @@
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название болезни</label>
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"

View File

@ -1,30 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
ViewData["Title"] = "CreateDisease";
}
<div class="text-center">
<h2 class="display-4">Создание болезни</h2>
</div>
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8">
<input type="text" name="name" />
</div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8">
<input type="text" name="description" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -18,7 +18,7 @@
<label class="u-label u-text-custom-color-1 u-label-2">Дата рождения</label>
<input type="date"
placeholder="Введите дату рождения"
name="patientdate"
name="birthdate"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
@ -28,17 +28,6 @@
name="address"
class="u-input u-input-rectangle" />
</div>
<div class="row">
<div class="col-4">Процедуры:</div>
<div class="col-8">
<select name="procedures" class="form-control" multiple size="6" id="procedures">
@foreach (var procedure in ViewBag.Procedures)
{
<option value="@procedure.Id">@procedure.Name</option>
}
</select>
</div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>

View File

@ -18,12 +18,11 @@
<select id="disease" name="disease" class="form-control" asp-items="@(new SelectList(@ViewBag.Diseases, "Id", "Name"))"></select>
</div>
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Дата создания</label>
<input type="date"
placeholder="Введите дату рождения"
name="date"
class="u-input u-input-rectangle" />
<div class="row">
<div class="col-4">Дата назначения:</div>
<div class="col-8">
<input type="datetime" name="date" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
@ -35,7 +34,7 @@
</form>
<script>
$('#disease').on('change', function () {
check();
//check();
});
function check() {
if (snack) {

View File

@ -1,18 +1,28 @@
@{
ViewData["Title"] = "DeleteDisease";
ViewData["Title"] = "CreateDisease";
}
<div class="text-center">
<h2 class="display-4">Удаление болезни</h2>
</div>
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="row">
<div class="col-4">Болезни:</div>
<div class="col-8">
<select id="disease" name="disease" class="form-control" asp-items="@(new SelectList(@ViewBag.Diseases, "Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
</div>
</form>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -1,18 +1,28 @@
@{
ViewData["Title"] = "DeletePatient";
ViewData["Title"] = "CreateDisease";
}
<div class="text-center">
<h2 class="display-4">Удаление пациента</h2>
</div>
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="row">
<div class="col-4">Пациенты:</div>
<div class="col-8">
<select id="patient" name="patient" class="form-control" asp-items="@(new SelectList(@ViewBag.Patients, "Id", "FIO"))"></select>
</div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
</div>
</form>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -1,18 +1,28 @@
@{
ViewData["Title"] = "DeleteRecipe";
ViewData["Title"] = "CreateDisease";
}
<div class="text-center">
<h2 class="display-4">Удаление Рецепта</h2>
</div>
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="row">
<div class="col-4">Рецепт:</div>
<div class="col-8">
<select id="recipe" name="recipe" class="form-control" asp-items="@(new SelectList(@ViewBag.Recipes, "Id", "Description"))"></select>
</div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
</div>
</form>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -20,7 +20,7 @@
<p>
<a asp-action="UpdatePatient">Редактировать пациента</a>
<a asp-action="DeletePatient">Удалить пациента</a>
<a asp-action="ServiceVisits">Связать пацииента и процедуру</a>
</p>
<p>
<a asp-action="CreatePatient">Создать пациента</a>
@ -32,10 +32,10 @@
Номер
</th>
<th>
ФИО
Название
</th>
<th>
Дата рождения
Дата
</th>
</tr>
@ -52,7 +52,7 @@
@Html.DisplayFor(modelItem => item.FIO)
</td>
<td>
@Html.DisplayFor(modelItem => item.BirthDate)
@Html.DisplayFor(modelItem => item.Address)
</td>
</tr>

View File

@ -18,11 +18,11 @@
return;
}
<p>
<a asp-action="UpdateDisease">Редактировать болезнь</a>
<a asp-action="DeleteDisease">Удалить болезнь</a>
<a asp-action="UpdateAnimal">Редактировать болезнь</a>
<a asp-action="DeleteAnimal">Удалить болезнь</a>
</p>
<p>
<a asp-action="CreateDisease">Создать болезнь</a>
<a asp-action="CreateAnimal">Создать болезнь</a>
</p>
<table class="table">
<thead>

View File

@ -18,12 +18,12 @@
return;
}
<p>
<a asp-action="UpdateRecipe">Редактировать рецепт</a>
<a asp-action="DeleteRecipe">Удалить рецепт</a>
<a asp-action="PatientRecipes">Связать рецепт и пациента</a>
<a asp-action="Update">Редактировать рецепт</a>
<a asp-action="Delete">Удалить рецепт</a>
<a asp-action="ServiceVisits">Связать рецепт и пациента</a>
</p>
<p>
<a asp-action="CreateRecipe">Создать рецепт</a>
<a asp-action="Create">Создать рецепт</a>
</p>
<table class="table">
<thead>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "CreateDisease";
}
<head>
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
</head>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название конференции</label>
<input type="text"
placeholder="Введите название болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-email u-form-group u-label-top">
<label class="u-label u-text-custom-color-1 u-label-2">Начало</label>
<input type="text"
placeholder="Введите описание болезни"
name="conferenceName"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -1,72 +0,0 @@
@using HospitalContracts.ViewModels;
@{
ViewData["Title"] = "PatientRecipes";
}
<div class="text-center">
<h2 class="display-4">Связывание пациента и рецептов</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Рецепт:</div>
<div class="col-8">
<select id="recipe" name="recipe" class="form-control" asp-items="@(new SelectList(@ViewBag.Recipes, "Id", "Description"))"></select>
</div>
</div>
<input style="visibility: hidden" type="text" name="diseaseId" id="diseaseId" class="form-control" />
<input style="visibility: hidden" type="text" id="description" name="description" class="form-control" />
<input style="visibility: hidden" type="date" id="issueDate" name="issueDate" class="form-control" />
<div class="row">
<div class="col-4">Пациент:</div>
<div class="col-8">
<select name="patients" class="form-control" multiple size="5" id="patients">
@foreach (var patient in ViewBag.Patients)
{
<option value="@patient.Id" data-name="@patient.FIO">@patient.FIO</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var recipe = $('#recipe').val();
$("#patients option:selected").removeAttr("selected");
if (recipe) {
$.ajax({
method: "GET",
url: "/Home/GetRecipe",
data: { recipeId: recipe },
success: function (result) {
console.log(result.item1);
console.log(patients);
$('#description').val(result.item1.description);
$('#diseaseId').val(result.item1.diseaseId);
$('#issueDate').val(result.item1.issueDate);
$.map(result.item2, function (n) {
console.log("#" + n);
$(`option[data-name=${n}]`).attr("selected", "selected")
});
}
});
};
}
check();
$('#recipe').on('change', function () {
console.log("change");
check();
});
</script>
}

View File

@ -1,39 +0,0 @@
@using HospitalContracts.ViewModels;
@{
ViewData["Title"] = "ProcedureListReport";
}
<div class="text-center">
<h2 class="display-4">Создать списки процедур для рецептов</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Рецепты:</div>
<div class="col-8">
<select name="recipes" class="form-control" multiple size="5" id="recipes">
@foreach (var recipe in ViewBag.Recipes)
{
<option value="@recipe.Id">@recipe.Description</option>
}
</select>
</div>
</div>
<div class="file-format">
<label class="form-label">Выберите формат файла:</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" value="docx" id="docx">
<label class="form-check-label" for="docx">Word-файл</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx" checked>
<label class="form-check-label" for="xlsx">Excel-файл</label>
</div>
</div>
<div class="d-flex justify-content-center">
<button type="submit" class="btn btn-block btn-outline-dark w-100">Создать</button>
</div>
</form>

View File

@ -1,65 +0,0 @@
@{
ViewData["Title"] = "Report";
}
<div class="container">
<div class="text-center mb-4">
<h2 class="text-custom-color-1">Список пациентов с расшифровкой по лекарствам и болезням за период</h2>
</div>
<form method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="dateFrom" class="form-label text-custom-color-1">Начало периода:</label>
<input type="datetime-local" id="dateFrom" name="dateFrom" class="form-control" placeholder="Выберите дату начала периода">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="dateTo" class="form-label text-custom-color-1">Окончание периода:</label>
<input type="datetime-local" id="dateTo" name="dateTo" class="form-control" placeholder="Выберите дату окончания периода">
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-md-8"></div>
<div class="col-md-4">
<button type="submit" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Отправить на почту</button>
</div>
</div>
<div class="row mb-4">
<div class="col-md-8"></div>
<div class="col-md-4">
<button type="button" id="demonstrate" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Продемонстрировать</button>
</div>
</div>
<div id="report"></div>
</form>
</div>
@section Scripts {
<script>
function check() {
var dateFrom = $('#dateFrom').val();
var dateTo = $('#dateTo').val();
if (dateFrom && dateTo) {
$.ajax({
method: "GET",
url: "/Home/GetPatientsReport",
data: { dateFrom: dateFrom, dateTo: dateTo },
success: function (result) {
if (result != null) {
$('#report').html(result);
}
}
});
};
}
check();
$('#demonstrate').on('click', (e) => check());
</script>
}

View File

@ -1,91 +0,0 @@

<style>
.container {
display: flex;
flex-direction: column;
align-items: center;
}
.row {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
</style>
<div class="container">
<div class="row">
<div style="width: 500px">
<canvas id="myChart" width="50" height="50"></canvas>
</div>
<div style="width: 500px">
<canvas id="myPieChart" width="100" height="100"></canvas>
</div>
</div>
@* <div style="width: 400px">
<canvas id="myDoughnutChart" width="300" height="300"></canvas>
</div> *@
</div>
<div style="height: 100px"></div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['0-20', '20-40', '40-60', '60-80', '80+'],
datasets: [{
label: 'Возраст пациентов',
data: @Html.Raw(Json.Serialize(ViewBag.PatientsGroups)),
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
<script>
var ctxPie = document.getElementById('myPieChart').getContext('2d');
var myPieChart = new Chart(ctxPie, {
type: 'pie',
data: {
labels: @Html.Raw(Json.Serialize(ViewBag.DiseaseNames)),
datasets: [{
data: @Html.Raw(Json.Serialize(ViewBag.LinkCounts)),
}]
}
});
</script>
<script>
var ctxDoughnut = document.getElementById('myDoughnutChart').getContext('2d');
var myDoughnutChart = new Chart(ctxDoughnut, {
type: 'doughnut',
data: {
labels: ViewBag.ABC,
datasets: [{
data: [30, 40, 30],
backgroundColor: ['green', 'orange', 'purple']
}]
}
});
</script>

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