Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
2fb5871f9d | |||
4d9cc77ab5 | |||
4881a7c7ca | |||
|
fea3859dbb | ||
|
6da19dcc84 | ||
9159f52f40 | |||
2efc894170 | |||
13b1baf5cb | |||
b5e9c5c194 | |||
6c1c337da5 | |||
|
07826a9fe0 | ||
|
49aa246bcf | ||
|
993cd30fde | ||
|
0dc935797e | ||
|
004c0381f5 | ||
|
ac470df39d | ||
|
9f29d4e15e | ||
|
935bb0b08b | ||
|
d864c43932 | ||
|
b3f954abd7 | ||
|
d6abaccf9b | ||
|
a0c3608ec9 | ||
85a4ee7940 | |||
5bd3381f7b | |||
ad043416d1 | |||
9eb8945bb7 | |||
c748d3328c | |||
57d2d06843 | |||
b6904e72fb |
@ -3,8 +3,6 @@ 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}"
|
||||
@ -13,11 +11,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalBusinessLogic", "Ho
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDatabaseImplement", "HospitalDatabaseImplement\HospitalDatabaseImplement.csproj", "{651AD7CE-7821-4BDF-9FA4-4F61DC5CF5C4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PharmacistApp", "PharmacistApp\PharmacistApp.csproj", "{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalPharmacistApp", "PharmacistApp\HospitalPharmacistApp.csproj", "{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalRestApi", "HospitalRestApi\HospitalRestApi.csproj", "{C524A697-427E-40BD-955C-334255D958B7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalRestApi", "HospitalRestApi\HospitalRestApi.csproj", "{C524A697-427E-40BD-955C-334255D958B7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalDoctorApp", "HospitalDoctorApp\HospitalDoctorApp.csproj", "{0E3C0346-E31B-401F-8047-CE157D984F33}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDoctorApp", "HospitalDoctorApp\HospitalDoctorApp.csproj", "{0E3C0346-E31B-401F-8047-CE157D984F33}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -25,10 +23,6 @@ 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
|
||||
@ -49,14 +43,14 @@ Global
|
||||
{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -17,12 +17,12 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
{
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDescriptionProcedureStorage _guidanceStorage;
|
||||
private readonly IDescriptionProcedureStorage _descriptionProcedureStorage;
|
||||
|
||||
public DescriptionProcedureLogic(ILogger<DescriptionProcedureLogic> logger, IDescriptionProcedureStorage guidanceStorage)
|
||||
public DescriptionProcedureLogic(ILogger<DescriptionProcedureLogic> logger, IDescriptionProcedureStorage descriptionProcedureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_guidanceStorage = guidanceStorage;
|
||||
_descriptionProcedureStorage = descriptionProcedureStorage;
|
||||
}
|
||||
|
||||
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 = _guidanceStorage.GetElement(model);
|
||||
var element = _descriptionProcedureStorage.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 ? _guidanceStorage.GetFullList() :
|
||||
_guidanceStorage.GetFilteredList(model);
|
||||
var list = model == null ? _descriptionProcedureStorage.GetFullList() :
|
||||
_descriptionProcedureStorage.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 (_guidanceStorage.Insert(model) == null)
|
||||
if (_descriptionProcedureStorage.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 (_guidanceStorage.Update(model) == null)
|
||||
if (_descriptionProcedureStorage.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 (_guidanceStorage.Delete(model) == null)
|
||||
if (_descriptionProcedureStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
@ -104,7 +104,7 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
nameof(model.Description));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Guidance. Text:{Text}.", model.Description);
|
||||
_logger.LogInformation("descriptionProcedure. Text:{Text}.", model.Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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("Лекарство с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -1,50 +1,70 @@
|
||||
using System;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.StoragesContracts;
|
||||
using HospitalContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 List<PharmacistViewModel>? ReadList(PharmacistSearchModel? model)
|
||||
|
||||
public bool Create(PharmacistBindingModel model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. FIO:{FIO}. Id:{ Id}", model?.FIO, model?.Id);
|
||||
var list = model == null ? _pharmacistStorage.GetFullList() :
|
||||
_pharmacistStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
CheckModel(model);
|
||||
if (_PharmacistStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
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. FIO:{FIO}.Id:{ Id}", model.FIO, model.Id);
|
||||
var element = _pharmacistStorage.GetElement(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");
|
||||
@ -53,39 +73,21 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(PharmacistBindingModel model)
|
||||
|
||||
public List<PharmacistViewModel>? ReadList(PharmacistSearchModel? model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_pharmacistStorage.Insert(model) == null)
|
||||
_logger.LogInformation("ReadList. PharmacistId:{Id}", model?.Id);
|
||||
var list = model == null ? _PharmacistStorage.GetFullList() : _PharmacistStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
return true;
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
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)
|
||||
|
||||
private void CheckModel(PharmacistBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -95,33 +97,28 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.FIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО клиента",
|
||||
nameof(model.FIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
throw new ArgumentNullException("Нет Email клиента",
|
||||
nameof(model.Login));
|
||||
throw new ArgumentNullException("Нет логина врача", nameof(model.Login));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера телефона врача", nameof(model.PhoneNumber));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля клиента",
|
||||
nameof(model.Password));
|
||||
throw new ArgumentNullException("Нет пароля врача", nameof(model.Password));
|
||||
}
|
||||
_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
|
||||
_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
|
||||
{
|
||||
Login = model.Login,
|
||||
Password = model.Password
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
||||
throw new InvalidOperationException("Врач с таким именем уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -16,18 +16,18 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
public class ProcedureLogic : IProcedureLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProcedureStorage _serviceStorage;
|
||||
public ProcedureLogic(ILogger<ProcedureLogic> logger, IProcedureStorage serviceStorage)
|
||||
private readonly IProcedureStorage _procedureStorage;
|
||||
public ProcedureLogic(ILogger<ProcedureLogic> logger, IProcedureStorage procedureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_serviceStorage = serviceStorage;
|
||||
_procedureStorage = procedureStorage;
|
||||
}
|
||||
|
||||
public List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ServiceName:{ServiceName}. Id:{ Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _serviceStorage.GetFullList() :
|
||||
_serviceStorage.GetFilteredList(model);
|
||||
_logger.LogInformation("ReadList. ProcedureName:{ProcedureName}. Id:{ Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _procedureStorage.GetFullList() :
|
||||
_procedureStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
@ -42,8 +42,8 @@ _serviceStorage.GetFilteredList(model);
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ServiceName:{ServiceName}.Id:{ Id}", model.Name, model.Id);
|
||||
var element = _serviceStorage.GetElement(model);
|
||||
_logger.LogInformation("ReadElement. ProcedureName:{ProcedureName}.Id:{ Id}", model.Name, model.Id);
|
||||
var element = _procedureStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
@ -56,7 +56,7 @@ _serviceStorage.GetFilteredList(model);
|
||||
public bool Create(ProcedureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_serviceStorage.Insert(model) == null)
|
||||
if (_procedureStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
@ -67,7 +67,7 @@ _serviceStorage.GetFilteredList(model);
|
||||
public bool Update(ProcedureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_serviceStorage.Update(model) == null)
|
||||
if (_procedureStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
@ -78,7 +78,7 @@ _serviceStorage.GetFilteredList(model);
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_serviceStorage.Delete(model) == null)
|
||||
if (_procedureStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
@ -99,21 +99,18 @@ 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));
|
||||
}
|
||||
_logger.LogInformation("Service. ServiceName:{ServiceName}. Id: { Id}", model.Name, model.Id);
|
||||
var element = _serviceStorage.GetElement(new ProcedureSearchModel
|
||||
|
||||
_logger.LogInformation("Procedure. ProcedureName:{ProcedureName}. Id: { Id}", model.Name, model.Id);
|
||||
var element = _procedureStorage.GetElement(new ProcedureSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Услуга с таким названием уже есть");
|
||||
throw new InvalidOperationException("Процедура с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,272 @@
|
||||
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)
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -7,7 +7,10 @@
|
||||
</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>
|
||||
|
@ -0,0 +1,64 @@
|
||||
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);
|
||||
}
|
||||
}
|
50
Hospital/HospitalBusinessLogic/MailWorker/MailWorker.cs
Normal file
50
Hospital/HospitalBusinessLogic/MailWorker/MailWorker.cs
Normal file
@ -0,0 +1,50 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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}";
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,335 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ namespace HospitalContracts.BindingModels
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public int PharmacistId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ namespace HospitalContracts.BindingModels
|
||||
public int DoctorId { get; set; }
|
||||
|
||||
public Dictionary<int, IProcedureModel> PatientProcedures { get; set; } = new();
|
||||
public Dictionary<int, IRecipeModel> PatientRecipes { get; set; } = new();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -9,11 +9,12 @@ namespace HospitalContracts.BindingModels
|
||||
{
|
||||
public class PharmacistBindingModel : IPharmacistModel
|
||||
{
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
public int Id { get; set; }
|
||||
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; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ 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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,6 @@ namespace HospitalContracts.SearchModels
|
||||
public string? Description { get; set; }
|
||||
|
||||
public int? DoctorId { get; set; }
|
||||
}
|
||||
public int? RecipeId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -13,5 +13,7 @@ namespace HospitalContracts.SearchModels
|
||||
public string? CountryOrigin { get; set; }
|
||||
public double? Price { get; set; }
|
||||
public int? PharmacistId { get; set; }
|
||||
}
|
||||
|
||||
public int? RecipeId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ 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; }
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ 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);
|
||||
|
@ -22,5 +22,8 @@ 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ 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);
|
||||
|
@ -22,6 +22,8 @@ namespace HospitalContracts.StoragesContracts
|
||||
RecipeViewModel? Update(RecipeBindingModel model);
|
||||
|
||||
RecipeViewModel? Delete(RecipeBindingModel model);
|
||||
List<Tuple<RecipeViewModel, List<Tuple<PatientViewModel, List<ProcedureViewModel>>>>> GetReportInfo(ListProceduresSearchModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
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();
|
||||
}
|
||||
}
|
15
Hospital/HospitalContracts/ViewModels/ListRecipeViewModel.cs
Normal file
15
Hospital/HospitalContracts/ViewModels/ListRecipeViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -19,23 +19,55 @@ namespace HospitalDatabaseImplement.Implements
|
||||
public List<MedicineViewModel> GetFullList()
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Medicines
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
return context.Medicines.Include(x => x.Pharmacist).Include(x => x.Recipes)
|
||||
.ThenInclude(x => x.Recipe)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<MedicineViewModel> GetFilteredList(MedicineSearchModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
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 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)
|
||||
{
|
||||
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)
|
||||
@ -45,8 +77,14 @@ namespace HospitalDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Medicines
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
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;
|
||||
}
|
||||
|
||||
public MedicineViewModel? Insert(MedicineBindingModel model)
|
||||
@ -68,14 +106,18 @@ namespace HospitalDatabaseImplement.Implements
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var medicine = context.Medicines
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var medicine = context.Medicines.Include(x => x.Pharmacist)
|
||||
.Include(x => x.Recipes)
|
||||
.ThenInclude(x => x.Recipe).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;
|
||||
}
|
||||
@ -84,13 +126,15 @@ namespace HospitalDatabaseImplement.Implements
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MedicineViewModel? Delete(MedicineBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var element = context.Medicines
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Medicines.Include(x => x.Pharmacist)
|
||||
.Include(x => x.Recipes).ThenInclude(x => x.Recipe)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Medicines.Remove(element);
|
||||
|
@ -17,17 +17,17 @@ namespace HospitalDatabaseImplement.Implements
|
||||
{
|
||||
public PharmacistViewModel? GetElement(PharmacistSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if ((string.IsNullOrEmpty(model.Login) && !model.Id.HasValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
|
||||
return context.Pharmacists
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Procedures)
|
||||
.Include(x => x.DescriptionProcedures)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
.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;
|
||||
}
|
||||
|
||||
public List<PharmacistViewModel> GetFilteredList(PharmacistSearchModel model)
|
||||
@ -59,19 +59,19 @@ namespace HospitalDatabaseImplement.Implements
|
||||
|
||||
public PharmacistViewModel? Insert(PharmacistBindingModel model)
|
||||
{
|
||||
var newDoctor = Pharmacist.Create(model);
|
||||
if (newDoctor == null)
|
||||
var newPharmacist = Pharmacist.Create(model);
|
||||
if (newPharmacist == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
context.Pharmacists.Add(newDoctor);
|
||||
context.Pharmacists.Add(newPharmacist);
|
||||
context.SaveChanges();
|
||||
return context.Pharmacists
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Procedures)
|
||||
.Include(x => x.DescriptionProcedures)
|
||||
.FirstOrDefault(x => x.Id == newDoctor.Id)
|
||||
.FirstOrDefault(x => x.Id == newPharmacist.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,6 @@ namespace HospitalDatabaseImplement.Models
|
||||
return new DescriptionProcedure()
|
||||
{
|
||||
Id = model.Id,
|
||||
|
||||
|
||||
Description = model.Description,
|
||||
PharmacistId = model.PharmacistId,
|
||||
Pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.PharmacistId)
|
||||
|
@ -12,4 +12,12 @@
|
||||
<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>
|
||||
|
@ -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)
|
||||
|
@ -118,5 +118,30 @@ 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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,17 +26,14 @@ namespace HospitalDatabaseImplement.Implements
|
||||
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
public ProcedureViewModel? GetElement(ProcedureSearchModel model)
|
||||
@ -46,10 +43,14 @@ namespace HospitalDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
public ProcedureViewModel? Insert(ProcedureBindingModel model)
|
||||
@ -64,6 +65,23 @@ 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)
|
||||
{
|
||||
@ -71,17 +89,18 @@ namespace HospitalDatabaseImplement.Implements
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var procedure = context.Procedures
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (procedure == null)
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -93,9 +112,10 @@ namespace HospitalDatabaseImplement.Implements
|
||||
public ProcedureViewModel? Delete(ProcedureBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var element = context.Procedures
|
||||
.Include(x => x.Medicines)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Procedures.Include(x => x.Pharmacist)
|
||||
.Include(x => x.Medicines)
|
||||
.ThenInclude(x => x.Medicine)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Procedures.Remove(element);
|
||||
|
@ -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,8 +58,10 @@ namespace HospitalDatabaseImplement.Implementss
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Recipes
|
||||
.Include(x => x.Doctor)
|
||||
.Include(x => x.Patients)
|
||||
.Include(x => x.Disease)
|
||||
.Include(x => x.Doctor)
|
||||
|
||||
.Include(x => x.Patients)
|
||||
.ThenInclude(x => x.Patient)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
@ -119,5 +121,22 @@ 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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ namespace HospitalDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
|
||||
{
|
||||
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
|
||||
.WithMany("Services")
|
||||
.WithMany("procedures")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -545,7 +545,7 @@ namespace HospitalDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("Recipes");
|
||||
|
||||
b.Navigation("Services");
|
||||
b.Navigation("procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
|
||||
|
@ -465,7 +465,7 @@ namespace HospitalDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
|
||||
{
|
||||
b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine")
|
||||
.WithMany("Services")
|
||||
.WithMany("procedures")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -542,7 +542,7 @@ namespace HospitalDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("Recipes");
|
||||
|
||||
b.Navigation("Services");
|
||||
b.Navigation("procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -51,7 +51,7 @@ namespace HospitalDatabaseImplement.Models
|
||||
[ForeignKey("MedicineId")]
|
||||
public virtual List<RecipeMedicine> Recipes { get; set; } = new();
|
||||
[ForeignKey("MedicineId")]
|
||||
public virtual List<ProcedureMedicine> Services { get; set; } = new();
|
||||
public virtual List<ProcedureMedicine> Procedures { get; set; } = new();
|
||||
public static Medicine Create(HospitalDatabase context,
|
||||
MedicineBindingModel model)
|
||||
{
|
||||
@ -60,6 +60,7 @@ namespace HospitalDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Price = model.Price,
|
||||
CountryOrigin = model.CountryOrigin,
|
||||
Recipes = model.MedicineRecipes.Select(x => new
|
||||
RecipeMedicine
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ namespace HospitalDatabaseImplement.Models
|
||||
{
|
||||
return new Patient()
|
||||
{
|
||||
// Id = model.Id,
|
||||
Id = model.Id,
|
||||
FIO = model.FIO,
|
||||
Address = model.Address,
|
||||
|
||||
@ -97,6 +97,7 @@ namespace HospitalDatabaseImplement.Models
|
||||
|
||||
public PatientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FIO = FIO,
|
||||
Address = Address,
|
||||
BirthDate = BirthDate,
|
||||
@ -106,14 +107,14 @@ namespace HospitalDatabaseImplement.Models
|
||||
|
||||
public void UpdateProcedures(HospitalDatabase context, PatientBindingModel model)
|
||||
{
|
||||
var servicePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList();
|
||||
if (servicePatients != null)
|
||||
var procedurePatients = context.PatientProcedures.Where(rec => rec.PatientId == model.Id).ToList();
|
||||
if (procedurePatients != null)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.PatientProcedures.RemoveRange(servicePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId)));
|
||||
context.PatientProcedures.RemoveRange(procedurePatients.Where(rec => !model.PatientProcedures.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
foreach (var service in servicePatients)
|
||||
foreach (var procedure in procedurePatients)
|
||||
{
|
||||
model.PatientProcedures.Remove(service.ProcedureId);
|
||||
model.PatientProcedures.Remove(procedure.ProcedureId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ namespace HospitalDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
Login = model.Login,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
FIO = model.FIO,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Password = model.Password
|
||||
};
|
||||
}
|
||||
|
@ -49,6 +49,11 @@ 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
|
||||
{
|
||||
@ -65,9 +70,12 @@ namespace HospitalDatabaseImplement.Models
|
||||
public ProcedureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
ProcedureMedicines = ProcedureMedicines
|
||||
};
|
||||
PharmacistId = PharmacistId,
|
||||
Name = Name,
|
||||
ProcedureMedicines = ProcedureMedicines,
|
||||
Date = Date,
|
||||
DescriptionProcedureId = DescriptionProcedureId
|
||||
};
|
||||
[Required]
|
||||
|
||||
public DateTime Date { get; set; }
|
||||
|
@ -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,13 +69,19 @@ namespace HospitalDatabaseImplement.Modelss
|
||||
{
|
||||
IssueDate = model.IssueDate;
|
||||
Description = model.Description;
|
||||
}
|
||||
DiseaseId = model.DiseaseId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public RecipeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
IssueDate = IssueDate,
|
||||
RecipePatients = RecipePatients
|
||||
Description = Description,
|
||||
RecipePatients = RecipePatients,
|
||||
DoctorId= DoctorId,
|
||||
DiseaseId = DiseaseId
|
||||
};
|
||||
|
||||
public void UpdatePatients(HospitalDatabase context, RecipeBindingModel model)
|
||||
|
@ -5,6 +5,9 @@ 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
|
||||
{
|
||||
@ -32,8 +35,7 @@ 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()
|
||||
@ -42,8 +44,7 @@ View(APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doct
|
||||
{
|
||||
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}"));
|
||||
|
||||
}
|
||||
|
||||
@ -152,11 +153,13 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
{
|
||||
return Redirect("~/Home/");
|
||||
}
|
||||
ViewBag.Procedures = APIClient.GetRequest<List<ProcedureViewModel>>($"api/procedure/getprocedures");
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateRecipe()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>("api/disease/getdiseases");
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/");
|
||||
}
|
||||
@ -164,32 +167,39 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
}
|
||||
public IActionResult CreateDisease()
|
||||
{
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>("api/recipe/getrecipelist");
|
||||
return View();
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreatePatient(string name, string address, DateTime patientdate)
|
||||
public void CreatePatient(string fio, string address, DateTime patientdate, List<int> procedures)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address))
|
||||
{
|
||||
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);
|
||||
}
|
||||
APIClient.PostRequest("api/patient/createpatient", new PatientBindingModel
|
||||
{
|
||||
FIO = name,
|
||||
FIO = fio,
|
||||
BirthDate = patientdate,
|
||||
Address = address,
|
||||
DoctorId = APIClient.Doctor.Id
|
||||
DoctorId = APIClient.Doctor.Id,
|
||||
PatientProcedures = produresDict
|
||||
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateRecipe(string description, DateTime issueDate)
|
||||
public void CreateRecipe(string description, DateTime date, int disease)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
@ -202,8 +212,9 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
APIClient.PostRequest("api/recipe/createrecipe", new RecipeBindingModel
|
||||
{
|
||||
Description = description,
|
||||
IssueDate = issueDate,
|
||||
DoctorId = APIClient.Doctor.Id
|
||||
IssueDate = date,
|
||||
DoctorId = APIClient.Doctor.Id,
|
||||
DiseaseId = disease
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
@ -225,9 +236,8 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
APIClient.PostRequest("api/disease/createdisease", new DiseaseBindingModel
|
||||
{
|
||||
Name = name,
|
||||
DoctorId = doctorId,
|
||||
|
||||
Description = description
|
||||
DoctorId = APIClient.Doctor.Id,
|
||||
Description = description
|
||||
});
|
||||
Response.Redirect("IndexDiseases");
|
||||
}
|
||||
@ -267,7 +277,24 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
|
||||
return View();
|
||||
}
|
||||
public IActionResult DeleteDisease()
|
||||
[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()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
@ -277,19 +304,6 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
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)
|
||||
{
|
||||
@ -343,11 +357,13 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipelist?doctorid={APIClient.Doctor.Id}");
|
||||
return View();
|
||||
ViewBag.Diseases = APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?diseaseId={APIClient.Doctor.Id}");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateRecipe(int recipe, string description, DateTime issuedate)
|
||||
public void UpdateRecipe(int recipe, string description, DateTime date, int disease)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
@ -362,8 +378,9 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
{
|
||||
Id = recipe,
|
||||
Description = description,
|
||||
IssueDate = issuedate
|
||||
|
||||
IssueDate = date,
|
||||
DiseaseId = disease
|
||||
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
@ -399,12 +416,12 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
|
||||
|
||||
});
|
||||
Response.Redirect("IndexDisease");
|
||||
Response.Redirect("IndexDiseases");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Промежуточные таблицы
|
||||
public IActionResult PatientRecipes()
|
||||
/*public IActionResult PatientRecipes()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
@ -441,7 +458,7 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
RecipePatients = v
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
}*/
|
||||
public IActionResult ProcedurePatients()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
@ -500,6 +517,7 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<RecipeViewModel, List<string>>? GetRecipe(int recipeId)
|
||||
{
|
||||
@ -530,6 +548,253 @@ View(APIClient.GetRequest<List<DiseaseViewModel>>($"api/disease/getdiseases?dise
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Chart.js" Version="3.7.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
using HospitalDoctorApp;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Add procedures to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
@ -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"
|
||||
|
@ -1,28 +1,30 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateDisease";
|
||||
ViewData["Title"] = "CreateDisease";
|
||||
}
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
|
||||
</head>
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание болезни</h2>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
</form>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<label class="u-label u-text-custom-color-1 u-label-2">Дата рождения</label>
|
||||
<input type="date"
|
||||
placeholder="Введите дату рождения"
|
||||
name="birthdate"
|
||||
name="patientdate"
|
||||
class="u-input u-input-rectangle" />
|
||||
</div>
|
||||
<div class="u-form-email u-form-group u-label-top">
|
||||
@ -28,6 +28,17 @@
|
||||
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>
|
||||
|
@ -18,11 +18,12 @@
|
||||
<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="datetime" name="date" />
|
||||
</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>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
@ -34,7 +35,7 @@
|
||||
</form>
|
||||
<script>
|
||||
$('#disease').on('change', function () {
|
||||
//check();
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
if (snack) {
|
||||
|
@ -1,28 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateDisease";
|
||||
ViewData["Title"] = "DeleteDisease";
|
||||
}
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
|
||||
</head>
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление болезни</h2>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
@ -1,28 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateDisease";
|
||||
ViewData["Title"] = "DeletePatient";
|
||||
}
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
|
||||
</head>
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление пациента</h2>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
@ -1,28 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateDisease";
|
||||
ViewData["Title"] = "DeleteRecipe";
|
||||
}
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="~/css/createdisease.css" asp-append-version="true" />
|
||||
</head>
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление Рецепта</h2>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
@ -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.Address)
|
||||
@Html.DisplayFor(modelItem => item.BirthDate)
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
@ -18,11 +18,11 @@
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="UpdateAnimal">Редактировать болезнь</a>
|
||||
<a asp-action="DeleteAnimal">Удалить болезнь</a>
|
||||
<a asp-action="UpdateDisease">Редактировать болезнь</a>
|
||||
<a asp-action="DeleteDisease">Удалить болезнь</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="CreateAnimal">Создать болезнь</a>
|
||||
<a asp-action="CreateDisease">Создать болезнь</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -18,12 +18,12 @@
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="Update">Редактировать рецепт</a>
|
||||
<a asp-action="Delete">Удалить рецепт</a>
|
||||
<a asp-action="ServiceVisits">Связать рецепт и пациента</a>
|
||||
<a asp-action="UpdateRecipe">Редактировать рецепт</a>
|
||||
<a asp-action="DeleteRecipe">Удалить рецепт</a>
|
||||
<a asp-action="PatientRecipes">Связать рецепт и пациента</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="Create">Создать рецепт</a>
|
||||
<a asp-action="CreateRecipe">Создать рецепт</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -1,28 +0,0 @@
|
||||
@{
|
||||
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>
|
72
Hospital/HospitalDoctorApp/Views/Home/PatientRecipes.cshtml
Normal file
72
Hospital/HospitalDoctorApp/Views/Home/PatientRecipes.cshtml
Normal file
@ -0,0 +1,72 @@
|
||||
@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>
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
@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>
|
65
Hospital/HospitalDoctorApp/Views/Home/Report.cshtml
Normal file
65
Hospital/HospitalDoctorApp/Views/Home/Report.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@{
|
||||
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>
|
||||
}
|
91
Hospital/HospitalDoctorApp/Views/Home/Statistics.cshtml
Normal file
91
Hospital/HospitalDoctorApp/Views/Home/Statistics.cshtml
Normal file
@ -0,0 +1,91 @@
|
||||
|
||||
|
||||
<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
Loading…
Reference in New Issue
Block a user