осталось редактирование
This commit is contained in:
parent
dc5910e324
commit
22eecccf08
@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalBusinessLogic.BusinessLogics
|
||||
@ -107,6 +108,15 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password));
|
||||
}
|
||||
if (!Regex.IsMatch(model.Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$", RegexOptions.IgnoreCase))
|
||||
{
|
||||
throw new ArgumentException("Неправильно введенный email", nameof(model.Email));
|
||||
}
|
||||
|
||||
if (!Regex.IsMatch(model.Password, @"^^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$", RegexOptions.IgnoreCase))
|
||||
{
|
||||
throw new ArgumentException("Неправильно введенный пароль", nameof(model.Password));
|
||||
}
|
||||
_logger.LogInformation("Client. ClientFIO: {ClientFIO}. Email: {Email}. Id: {Id}", model.ClientFIO, model.Email, model.Id);
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using HospitalContracts.BusinessLogicsContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.StoragesContracts;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -21,6 +22,38 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
_logger = logger;
|
||||
_proceduresStorage = proceduresStorage;
|
||||
}
|
||||
|
||||
public bool AddMedicines(ProceduresSearchModel model, IMedicinesModel medicine)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddMedicine.Id:{ Id}", model.Id);
|
||||
var element = _proceduresStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddMedicine element not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddMedicine find. Id:{Id}", element.Id);
|
||||
|
||||
element.ProcedureMedicine[medicine.Id] = medicine;
|
||||
|
||||
_proceduresStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
ProceduresName = element.ProceduresName,
|
||||
Type = element.Type,
|
||||
ClientId = element.ClientId,
|
||||
ProcedureMedicine = element.ProcedureMedicine
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
public bool Create(ProceduresBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
@ -130,6 +130,10 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.SymptomsId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор симптома", nameof(model.SymptomsId));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Dose))
|
||||
{
|
||||
throw new ArgumentNullException("В рецепте нет дозировки", nameof(model.Dose));
|
||||
@ -138,7 +142,7 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет способа приема", nameof(model.ModeOfApplication));
|
||||
}
|
||||
_logger.LogInformation("Recipes.RecipesId:{Id}.Dose:{ Dose}.ModeOfApplication:{ ModeOfApplication}", model.Id, model.Dose, model.ModeOfApplication);
|
||||
_logger.LogInformation("Recipes.RecipesId:{Id}.Dose:{ Dose}.ModeOfApplication:{ ModeOfApplication}. MedicineId: { MedicineId}", model.Id, model.Dose, model.ModeOfApplication, model.SymptomsId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace HospitalClientApp.Controllers
|
||||
@ -123,23 +124,23 @@ namespace HospitalClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Medicines = APIClient.GetRequest<List<MedicinesViewModel>>("api/main/getmedicineslist");
|
||||
if (!id.HasValue)
|
||||
{
|
||||
return View();
|
||||
return View(new ProceduresViewModel());
|
||||
}
|
||||
var model = APIClient.GetRequest<ProceduresViewModel?>($"api/main/getprocedure?id={id}");
|
||||
return View(model);
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateProcedure(int? id, string procedurename, string proceduretype )
|
||||
public void CreateProcedure(ProceduresBindingModel model, int? id, string procedurename, string proceduretype )
|
||||
{
|
||||
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (id.HasValue)
|
||||
if (model.Id != 0)
|
||||
{
|
||||
APIClient.PostRequest("api/main/updateprocedure", new ProceduresBindingModel
|
||||
{
|
||||
@ -199,6 +200,29 @@ namespace HospitalClientApp.Controllers
|
||||
ViewBag.Procedures = APIClient.GetRequest<List<ProceduresViewModel>>($"api/main/getprocedurelist?clientId={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
//[HttpGet]
|
||||
//public IActionResult AddDrugCourse()
|
||||
//{
|
||||
// if (APIClient.Client == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIClient.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines");
|
||||
// ViewBag.DrugCourses = APIClient.GetRequest<List<DrugCourseViewModel>>($"api/drugcourse/getdrugcourses");
|
||||
// return View();
|
||||
//}
|
||||
|
||||
//[HttpPost]
|
||||
//public void AddMedicineDrugCourse(int medicine, int drugcourse)
|
||||
//{
|
||||
// if (APIClient.Client == null)
|
||||
// {
|
||||
// throw new Exception("Доступно только авторизованным пользователям");
|
||||
// }
|
||||
// APIClient.PostRequest($"api/medicine/addmedicinedrugcourse", (new DrugCourseBindingModel { Id = drugcourse }, new MedicineBindingModel { Id = medicine }));
|
||||
// Response.Redirect("ListDrugCourses");
|
||||
//}
|
||||
/// <summary>
|
||||
/// ЛЕКАРСТВА
|
||||
/// </summary>
|
||||
@ -310,19 +334,20 @@ namespace HospitalClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Medicines = APIClient.GetRequest<List<MedicinesViewModel>>("api/main/getmedicineslist");
|
||||
ViewBag.Symptomses = APIClient.GetRequest<List<SymptomsViewModel>>("api/main/getsymptoms");
|
||||
ViewBag.Procedures = APIClient.GetRequest<List<ProceduresViewModel>>("api/main/getprocedurelist");
|
||||
if (!id.HasValue)
|
||||
{
|
||||
return View(new RecipesViewModel());
|
||||
}
|
||||
var model = APIClient.GetRequest<RecipesViewModel?>($"api/main/getrecipe?id={id}");
|
||||
|
||||
var model = APIClient.GetRequest<ProceduresViewModel?>($"api/main/getprocedure?id={id}");
|
||||
return View(model);
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateRecipe(RecipesBindingModel model)
|
||||
public void CreateRecipe(RecipesBindingModel model, int? id, int symptoms, string dose, string modeofapplication)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
@ -335,7 +360,13 @@ namespace HospitalClientApp.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
APIClient.PostRequest("api/main/createrecipe", model);
|
||||
APIClient.PostRequest("api/main/createrecipe", new RecipesBindingModel
|
||||
{
|
||||
ClientId = APIClient.Client.Id,
|
||||
Dose = dose,
|
||||
SymptomsId = symptoms,
|
||||
ModeOfApplication = modeofapplication
|
||||
});
|
||||
}
|
||||
Response.Redirect("ListRecipes");
|
||||
}
|
||||
@ -364,6 +395,27 @@ namespace HospitalClientApp.Controllers
|
||||
}
|
||||
return Tuple.Create(result.Item1, table);
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteRecipe(int recipe)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
|
||||
APIClient.PostRequest($"api/main/DeleteRecipe", new RecipesBindingModel { Id = recipe });
|
||||
Response.Redirect("ListRecipes");
|
||||
}
|
||||
|
||||
public IActionResult DeleteRecipe()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipesViewModel>>($"api/main/GetRecipesList?clientId={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
|
@ -18,14 +18,80 @@ if (Model != null)
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название процедуры:</div>
|
||||
<div class="col-8"><input type="text" name="procedurename" id="procedurename" value="@Model?.MedicinesName" /></div>
|
||||
<div class="col-8"><input type="text" name="procedurename" id="procedurename"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Тип:</div>
|
||||
<div class="col-8"><input type="text" id="proceduretype" name="proceduretype" value="@Model?.Type" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Добавление лекарств</div>
|
||||
<div class="col-8">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<select id="medicines" name="medicines" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines,"Id", "MedicinesName"))"></select>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-success" onclick="addMedicine()">Добавить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p class="text-center"><strong>Лекарства</strong></p>
|
||||
<table id="medicinesTable" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var medicine in Model.ProcedureMedicine)
|
||||
{
|
||||
<tr>
|
||||
<td>@medicine.Value.MedicinesName</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-danger" data-id="@medicine.Key" onclick="removeMedicine('@medicine.Key')">Удалить</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</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>
|
||||
var procedureMedicine = @Json.Serialize(Model.ProcedureMedicine);
|
||||
function addMedicine() {
|
||||
var medicineId = $('#medicines').val();
|
||||
var medicinesName = $('#medicines option:selected').text();
|
||||
if (procedureMedicine.hasOwnProperty(medicineId)) {
|
||||
alert('This medicine is already added.');
|
||||
return;
|
||||
}
|
||||
procedureMedicine[medicineId] = { Id: medicineId, MedicinesName: medicinesName };
|
||||
var row = $('<tr>').append($('<td>').text(medicinesName));
|
||||
var removeButton = $('<button>').text('Удалить').attr('data-id', medicineId).attr('class', 'btn btn-danger').click((function (id) {
|
||||
return function () {
|
||||
removeMedicine(id);
|
||||
};
|
||||
})(medicineId));
|
||||
row.append($('<td>').append(removeButton));
|
||||
|
||||
$('#medicinesTable tbody').append(row);
|
||||
var input = $('<input>').attr('type', 'hidden').attr('name', 'ProcedureMedicine[' + medicineId + ']').val(medicineId);
|
||||
$('#procedures-form').append(input);
|
||||
}
|
||||
function removeMedicine(medicineId) {
|
||||
delete procedureMedicine[medicineId];
|
||||
$('#medicinesTable button[data-id="' + medicineId + '"]').closest('tr').remove();
|
||||
$('#procedures-form input[name="ProcedureMedicine[' + medicineId + ']"]').remove();
|
||||
}
|
||||
</script>
|
||||
}
|
@ -17,26 +17,28 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Лекарство:</div>
|
||||
<div class="col-4">Привязка симптома:</div>
|
||||
<div class="col-8">
|
||||
<select id="medicines" name="medicines" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines,"Id", "MedicinesName"))"></select>
|
||||
<select id="symptoms" name="symptoms" class="form-control" asp-items="@(new SelectList(@ViewBag.Symptomses,"Id", "SymptomName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Добавление процедур:</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<select id="procedures" name="procedures" class="form-control" asp-items="@(new SelectList(@ViewBag.Procedures,"Id", "ProceduresName"))"></select>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-success bg-dark" onclick="addProcedures()">Добавить</button>
|
||||
<div class="col-4">Добавление процедур</div>
|
||||
<div class="col-8">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<select id="procedures" name="procedures" class="form-control" asp-items="@(new SelectList(@ViewBag.Procedures,"Id", "ProceduresName"))"></select>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-success" onclick="addProcedures()">Добавить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p class="text-center"><strong>Процедуры</strong></p>
|
||||
<table id="prodedureTable" class="table table-bordered table-striped">
|
||||
<table id="procedureTable" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
@ -56,7 +58,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br />
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
@ -65,16 +66,16 @@
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
var recipesProcedures = @Json.Serialize(Model.RecipeProcedures);
|
||||
var recipeProcedures = @Json.Serialize(Model.RecipeProcedures);
|
||||
function addProcedures() {
|
||||
var procedureId = $('#procedures').val();
|
||||
var proceduresName = $('#procedures option:selected').text();
|
||||
if (recipesProcedures.hasOwnProperty(procedureId)) {
|
||||
var procedureName = $('#procedures option:selected').text();
|
||||
if (recipeProcedures.hasOwnProperty(procedureId)) {
|
||||
alert('This procedure is already added.');
|
||||
return;
|
||||
}
|
||||
recipesProcedures[procedureId] = { Id: procedureId, Name: proceduresName };
|
||||
var row = $('<tr>').append($('<td>').text(proceduresName));
|
||||
recipeProcedures[procedureId] = { Id: procedureId, ProceduresName: procedureName };
|
||||
var row = $('<tr>').append($('<td>').text(procedureName));
|
||||
var removeButton = $('<button>').text('Удалить').attr('data-id', procedureId).attr('class', 'btn btn-danger').click((function (id) {
|
||||
return function () {
|
||||
removeProcedure(id);
|
||||
@ -83,13 +84,13 @@
|
||||
row.append($('<td>').append(removeButton));
|
||||
|
||||
$('#procedureTable tbody').append(row);
|
||||
var input = $('<input>').attr('type', 'hidden').attr('name', 'RecipesProcedures[' + procedureId + ']').val(procedureId);
|
||||
var input = $('<input>').attr('type', 'hidden').attr('name', 'RecipeProcedures[' + procedureId + ']').val(procedureId);
|
||||
$('#recipe-form').append(input);
|
||||
}
|
||||
function removeProcedure(procedureId) {
|
||||
delete recipesProcedures[procedureId];
|
||||
delete recipeProcedures[procedureId];
|
||||
$('#procedureTable button[data-id="' + procedureId + '"]').closest('tr').remove();
|
||||
$('#recipe-form input[name="RecipesProcedures[' + procedureId + ']"]').remove();
|
||||
$('#recipe-form input[name="RecipeProcedures[' + procedureId + ']"]').remove();
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
16
Hospital/HospitalClientApp/Views/Home/DeleteRecipe.cshtml
Normal file
16
Hospital/HospitalClientApp/Views/Home/DeleteRecipe.cshtml
Normal file
@ -0,0 +1,16 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteRecipe";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<label class="lable">Рецепт: </label>
|
||||
<div>
|
||||
<select id="recipe" name="recipe" class="form-control" asp-items="@(new SelectList(@ViewBag.Recipes, "Id", "Id"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Удалить"/></div>
|
||||
</div>
|
||||
</form>
|
@ -21,8 +21,6 @@
|
||||
<p>
|
||||
<a class="btn btn-warning" asp-action="CreateRecipe">Создать рецепт</a>
|
||||
<a class="btn btn-warning" asp-action="DeleteRecipe">Удалить</a>
|
||||
<a class="btn btn-warning" asp-action="AddProcedures">Добавить процедуры</a>
|
||||
<a class="btn btn-warning" asp-action="AddSymptoms">Добавить симптомы</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
@ -58,7 +56,7 @@
|
||||
@Html.DisplayFor(modelItem => item.Dose)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.MedicinesName)
|
||||
@Html.DisplayFor(modelItem => item.SymptomsId)
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-warning" asp-action="CreateRecipe" asp-route-id="@item.Id">Редактировать</a>
|
||||
|
@ -105,7 +105,7 @@ namespace HospitalRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
_procedure.Update(model);
|
||||
_procedure.Update(GetModelWithMedicines(model));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -114,6 +114,17 @@ namespace HospitalRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
private ProceduresBindingModel GetModelWithMedicines(ProceduresBindingModel model)
|
||||
{
|
||||
var medicines = _medicine.ReadList(new MedicinesSearchModel { Ids = model.ProcedureMedicine.Keys.ToArray() });
|
||||
if (medicines != null)
|
||||
{
|
||||
model.ProcedureMedicine = medicines.Where(m => model.ProcedureMedicine.Keys.Contains(m.Id))
|
||||
.ToDictionary(m => m.Id, m => m as IMedicinesModel);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteProcedure(ProceduresBindingModel model)
|
||||
{
|
||||
@ -248,7 +259,7 @@ namespace HospitalRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
_recipe.Create(GetModelWithProcedures(model));
|
||||
_recipe.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -309,11 +320,23 @@ namespace HospitalRestApi.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка добавления участника в план питания.");
|
||||
_logger.LogError(ex, "Ошибка добавления процедуры в рецепт.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void AddMedicines(Tuple<ProceduresSearchModel, MedicinesViewModel> model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_procedure.AddMedicines(model.Item1, model.Item2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка добавления лекарства в процедуру.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private RecipesBindingModel GetModelWithProcedures( RecipesBindingModel model)
|
||||
{
|
||||
var medicines = _procedure.ReadList(new ProceduresSearchModel { Ids = model.RecipeProcedures.Keys.ToArray() });
|
||||
@ -324,6 +347,32 @@ namespace HospitalRestApi.Controllers
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteRecipe(RecipesBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_recipe.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления рецепта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<SymptomsViewModel>? GetSymptoms()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _symptom.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using HospitalBusinessLogic.BusinessLogics;
|
||||
using HospitalContracts.BusinessLogicsContracts;
|
||||
using HospitalContracts.StoragesContracts;
|
||||
using HospitalDataBaseImplements;
|
||||
using HospitalDataBaseImplements.Implements;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
@ -42,6 +43,7 @@ builder.Services.AddSwaggerGen(c =>
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
LoaderFromXML.LoadSymptoms();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
|
@ -1,8 +1,10 @@
|
||||
using HospitalDataModels.Models;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.BindingModels
|
||||
@ -13,5 +15,13 @@ namespace HospitalContracts.BindingModels
|
||||
public string ProceduresName { get; set; } = string.Empty;
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public Dictionary<int, IMedicinesModel> ProcedureMedicine
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,18 +14,12 @@ namespace HospitalContracts.BindingModels
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public string ModeOfApplication { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
public int MedicinesId { get; set; }
|
||||
//public Dictionary<int, ISymptomsModel> RecipeSymptoms
|
||||
//{
|
||||
// get;
|
||||
// set;
|
||||
//} = new();
|
||||
|
||||
public Dictionary<int, IProceduresModel> RecipeProcedures
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
public int SymptomsId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -13,6 +14,7 @@ namespace HospitalContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<ProceduresViewModel>? ReadList(ProceduresSearchModel? model);
|
||||
ProceduresViewModel? ReadElement(ProceduresSearchModel model);
|
||||
bool AddMedicines(ProceduresSearchModel model, IMedicinesModel member);
|
||||
bool Create(ProceduresBindingModel model);
|
||||
bool Update(ProceduresBindingModel model);
|
||||
bool Delete(ProceduresBindingModel model);
|
||||
|
@ -14,7 +14,7 @@ namespace HospitalContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<RecipesViewModel>? ReadList(RecipesSearchModel? model);
|
||||
RecipesViewModel? ReadElement(RecipesSearchModel model);
|
||||
bool AddProcedures(RecipesSearchModel model, IProceduresModel member);
|
||||
bool AddProcedures(RecipesSearchModel model, IProceduresModel procedure);
|
||||
bool Create(RecipesBindingModel model);
|
||||
bool Update(RecipesBindingModel model);
|
||||
bool Delete(RecipesBindingModel model);
|
||||
|
@ -11,5 +11,7 @@ namespace HospitalContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? MedicinesName { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public int[]? Ids { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace HospitalContracts.ViewModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название лекарства")]
|
||||
public string MedicinesName { get; set; } = string.Empty;
|
||||
public string MedicinesName { get; set; }
|
||||
[DisplayName("Группа")]
|
||||
public string Group { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.ViewModels
|
||||
@ -16,5 +17,17 @@ namespace HospitalContracts.ViewModels
|
||||
[DisplayName("Тип процедуры")]
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
public Dictionary<int, IMedicinesModel> ProcedureMedicine
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
public ProceduresViewModel() { }
|
||||
[JsonConstructor]
|
||||
public ProceduresViewModel(Dictionary<int, MedicinesViewModel> ProcedureMedicine)
|
||||
{
|
||||
this.ProcedureMedicine = ProcedureMedicine.ToDictionary(x => x.Key, x => x.Value as IMedicinesModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.ViewModels
|
||||
@ -20,20 +21,22 @@ namespace HospitalContracts.ViewModels
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Способ приготовления")]
|
||||
public string ModeOfApplication { get; set; } = string.Empty;
|
||||
[DisplayName("Лекарство")]
|
||||
public string MedicinesName { get; set; } = string.Empty;
|
||||
public int MedicinesId { get; set; }
|
||||
//[DisplayName("Симптом")]
|
||||
//public Dictionary<int, ISymptomsModel> RecipeSymptoms
|
||||
//{
|
||||
// get;
|
||||
// set;
|
||||
//} = new();
|
||||
|
||||
[DisplayName("Процедура")]
|
||||
public Dictionary<int, IProceduresModel> RecipeProcedures
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
[DisplayName("Симптом")]
|
||||
public int SymptomsId { get; set; }
|
||||
|
||||
public RecipesViewModel() { }
|
||||
|
||||
[JsonConstructor]
|
||||
public RecipesViewModel(Dictionary<int, ProceduresViewModel> RecipeProcedures)
|
||||
{
|
||||
this.RecipeProcedures = RecipeProcedures.ToDictionary(x => x.Key, x => x.Value as IProceduresModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace HospitalContracts.ViewModels
|
||||
[DisplayName("Симптом")]
|
||||
public string SymptomName { get; set; } = string.Empty;
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ namespace HospitalDataBaseImplements
|
||||
public virtual DbSet<Illness> Illnesses { set; get; }
|
||||
public virtual DbSet<IllnessKurse> IllnessKurse { set; get; }
|
||||
public virtual DbSet<IllnessSymptoms> IllnessSymptomses { set; get; }
|
||||
public virtual DbSet<RecipesSymptoms> RecipesSymptoms { set; get; }
|
||||
public virtual DbSet<RecipesProcedures> RecipesProcedures { set; get; }
|
||||
public virtual DbSet<ProcedureMedicine> ProcedureMedicine { set; get; }
|
||||
public virtual DbSet<Symptoms> Symptomses { set; get; }
|
||||
public virtual DbSet<Recipes> Recipes { set; get; }
|
||||
public virtual DbSet<Medicines> Medicines { set; get; }
|
||||
|
@ -42,7 +42,7 @@ namespace HospitalDataBaseImplements.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Medicines
|
||||
return context.Medicines.Include(x => x.Client)
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.MedicinesName) && x.MedicinesName ==
|
||||
model.MedicinesName) ||
|
||||
@ -51,20 +51,24 @@ namespace HospitalDataBaseImplements.Implements
|
||||
}
|
||||
public MedicinesViewModel? Insert(MedicinesBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var newMedicine = Medicines.Create(model);
|
||||
if (newMedicine == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
context.Medicines.Add(newMedicine);
|
||||
context.SaveChanges();
|
||||
return newMedicine.GetViewModel;
|
||||
return context.Medicines.Include(x => x.Client).FirstOrDefault(x => x.Id == newMedicine.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public MedicinesViewModel? Update(MedicinesBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var medicine = context.Medicines.FirstOrDefault(x => x.Id == model.Id);
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var medicine = context.Medicines.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (medicine == null)
|
||||
{
|
||||
return null;
|
||||
@ -72,6 +76,12 @@ namespace HospitalDataBaseImplements.Implements
|
||||
medicine.Update(model);
|
||||
context.SaveChanges();
|
||||
return medicine.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public MedicinesViewModel? Delete(MedicinesBindingModel model)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace HospitalDataBaseImplements.Implements
|
||||
{
|
||||
@ -17,7 +18,8 @@ namespace HospitalDataBaseImplements.Implements
|
||||
public List<ProceduresViewModel> GetFullList()
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Procedures.Include(x => x.Client)
|
||||
return context.Procedures.Include(x => x.Client).Include(x => x.Medicines)
|
||||
.ThenInclude(x => x.Medicine)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -41,7 +43,7 @@ namespace HospitalDataBaseImplements.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Procedures
|
||||
return context.Procedures.Include(x => x.Client)
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ProceduresName) && x.ProceduresName ==
|
||||
model.ProceduresName) ||
|
||||
@ -58,24 +60,40 @@ namespace HospitalDataBaseImplements.Implements
|
||||
using var context = new HospitalDatabase();
|
||||
context.Procedures.Add(newProcedures);
|
||||
context.SaveChanges();
|
||||
return newProcedures.GetViewModel;
|
||||
return context.Procedures.Include(x => x.Client)
|
||||
.Include(x => x.Medicines)
|
||||
.ThenInclude(x => x.Medicine).FirstOrDefault(x => x.Id == newProcedures.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ProceduresViewModel? Update(ProceduresBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var procedure = context.Procedures.FirstOrDefault(x => x.Id == model.Id);
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var procedure = context.Procedures.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (procedure == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
procedure.Update(model);
|
||||
context.SaveChanges();
|
||||
return procedure.GetViewModel;
|
||||
procedure.UpdateMedicines(context, model);
|
||||
transaction.Commit();
|
||||
return procedure.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public ProceduresViewModel? Delete(ProceduresBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var element = context.Procedures.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Procedures.Include(x => x.Medicines)
|
||||
.ThenInclude(x => x.Medicine)
|
||||
.Include(x => x.Client).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Procedures.Remove(element);
|
||||
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace HospitalDataBaseImplements.Implements
|
||||
{
|
||||
@ -17,7 +18,8 @@ namespace HospitalDataBaseImplements.Implements
|
||||
public RecipesViewModel? Delete(RecipesBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var element = context.Recipes.Include(x => x.Procedures).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Recipes.Include(x => x.Procedures).Include(x => x.Symptoms)
|
||||
.Include(x => x.Client).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Recipes.Remove(element);
|
||||
@ -38,11 +40,11 @@ namespace HospitalDataBaseImplements.Implements
|
||||
Include(x => x.Client).
|
||||
Include(x => x.Procedures).
|
||||
ThenInclude(x => x.Procedure).
|
||||
Include(x => x.Medicines).
|
||||
Include(x => x.Symptoms).
|
||||
FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
//НУЖЕН ТУТ ЕЩЕ ОДИН ТУ ЛИСТ???
|
||||
public List<RecipesViewModel> GetFilteredList(RecipesSearchModel model)
|
||||
{
|
||||
if (model is null)
|
||||
@ -54,9 +56,9 @@ namespace HospitalDataBaseImplements.Implements
|
||||
return context.Recipes.
|
||||
Include(x => x.Procedures).
|
||||
ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Symptoms)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Where(x => x.ClientId == model.ClientId).ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -66,8 +68,9 @@ namespace HospitalDataBaseImplements.Implements
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Recipes.Include(x => x.Procedures).
|
||||
ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Symptoms)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -75,33 +78,44 @@ namespace HospitalDataBaseImplements.Implements
|
||||
public RecipesViewModel? Insert(RecipesBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var newDrugCourse = Recipes.Create(model);
|
||||
if (newDrugCourse == null)
|
||||
var newRecipe = Recipes.Create(model);
|
||||
if (newRecipe == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Recipes.Add(newDrugCourse);
|
||||
context.Recipes.Add(newRecipe);
|
||||
context.SaveChanges();
|
||||
return context.Recipes
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Medicines)
|
||||
.Include(x => x.Symptoms)
|
||||
.Include(x => x.Client)
|
||||
.FirstOrDefault(x => x.Id == newDrugCourse.Id)
|
||||
.FirstOrDefault(x => x.Id == newRecipe.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public RecipesViewModel? Update(RecipesBindingModel model)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
var recipe = context.Recipes.FirstOrDefault(x => x.Id == model.Id);
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var recipe = context.Recipes.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (recipe == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
recipe.Update(model);
|
||||
context.SaveChanges();
|
||||
return recipe.GetViewModel;
|
||||
recipe.UpdateProcedures(context, model);
|
||||
transaction.Commit();
|
||||
return recipe.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ namespace HospitalDataBaseImplements
|
||||
{
|
||||
public class LoaderFromXML
|
||||
{
|
||||
private static readonly string IllnessFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLData\\Illness.xml");
|
||||
// private static readonly string IllnessFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLData\\Illness.xml");
|
||||
private static readonly string SymptomsFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLData\\Symptoms.xml");
|
||||
private static readonly string KursesFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLData\\Kurses.xml");
|
||||
// private static readonly string KursesFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLData\\Kurses.xml");
|
||||
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
@ -26,35 +26,35 @@ namespace HospitalDataBaseImplements
|
||||
/// Чтение пациентов из XML-файла
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static void LoadIllness() // (запуск после загрузки курсов)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
if (context.Illnesses.ToList().Count > 0)
|
||||
return;
|
||||
var list = LoadData(IllnessFileName, "Illness", x => Illness.Create(x)!)!;
|
||||
list.ForEach(x =>
|
||||
{
|
||||
context.Illnesses.Add(x);
|
||||
});
|
||||
context.SaveChanges();
|
||||
//public static void LoadIllness() // (запуск после загрузки курсов)
|
||||
//{
|
||||
// using var context = new HospitalDatabase();
|
||||
// if (context.Illnesses.ToList().Count > 0)
|
||||
// return;
|
||||
// var list = LoadData(IllnessFileName, "Illness", x => Illness.Create(x)!)!;
|
||||
// list.ForEach(x =>
|
||||
// {
|
||||
// context.Illnesses.Add(x);
|
||||
// });
|
||||
// context.SaveChanges();
|
||||
|
||||
}
|
||||
//}
|
||||
/// <summary>
|
||||
/// Чтение лечений из XML-файла
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static void LoadKurses() // (запуск после загрузки симптомов)
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
if (context.Kurse.ToList().Count > 0)
|
||||
return;
|
||||
//var list = LoadData(KursesFileName, "Kurses", x => Kurses.Create(context, x)!)!;
|
||||
//list.ForEach(x =>
|
||||
//{
|
||||
// context.Kurse.Add(x);
|
||||
//});
|
||||
//context.SaveChanges();
|
||||
}
|
||||
//public static void LoadKurses() // (запуск после загрузки симптомов)
|
||||
//{
|
||||
// using var context = new HospitalDatabase();
|
||||
// if (context.Kurse.ToList().Count > 0)
|
||||
// return;
|
||||
// //var list = LoadData(KursesFileName, "Kurses", x => Kurses.Create(context, x)!)!;
|
||||
// //list.ForEach(x =>
|
||||
// //{
|
||||
// // context.Kurse.Add(x);
|
||||
// //});
|
||||
// //context.SaveChanges();
|
||||
//}
|
||||
/// <summary>
|
||||
/// Чтение поцедур из XML-файла
|
||||
/// </summary>
|
||||
@ -64,12 +64,12 @@ namespace HospitalDataBaseImplements
|
||||
using var context = new HospitalDatabase();
|
||||
if (context.Symptomses.ToList().Count > 0)
|
||||
return;
|
||||
//var list = LoadData(SymptomsFileName, "Symptoms", x => Symptoms.Create(x)!)!;
|
||||
//list.ForEach(x =>
|
||||
//{
|
||||
// context.Symptomses.Add(x);
|
||||
//});
|
||||
//context.SaveChanges();
|
||||
var list = LoadData(SymptomsFileName, "Symptoms", x => Symptoms.Create(x)!)!;
|
||||
list.ForEach(x =>
|
||||
{
|
||||
context.Symptomses.Add(x);
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace HospitalDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(HospitalDatabase))]
|
||||
[Migration("20230520015950_InitialCreate")]
|
||||
[Migration("20230525103233_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -172,6 +172,29 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.ProcedureMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.ToTable("ProcedureMedicine");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -216,18 +239,18 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MedicinesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ModeOfApplication")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MedicinesId");
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("Recipes");
|
||||
});
|
||||
@ -255,29 +278,6 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.ToTable("RecipesProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("RecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RecipesId");
|
||||
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("RecipesSymptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Symptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -358,6 +358,25 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.ProcedureMedicine", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicine")
|
||||
.WithMany("Procedures")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Procedures", "Procedure")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medicine");
|
||||
|
||||
b.Navigation("Procedure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Client", "Client")
|
||||
@ -377,15 +396,15 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicines")
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicinesId")
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Medicines");
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesProcedures", b =>
|
||||
@ -407,25 +426,6 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.Navigation("Recipe");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Recipes", "Recipe")
|
||||
.WithMany()
|
||||
.HasForeignKey("RecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany()
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Recipe");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Illness", b =>
|
||||
{
|
||||
b.Navigation("Kurses");
|
||||
@ -438,6 +438,16 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.Navigation("IllnessKurses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Medicines", b =>
|
||||
{
|
||||
b.Navigation("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.Navigation("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.Navigation("Procedures");
|
@ -122,6 +122,35 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Recipes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Dose = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
ModeOfApplication = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
SymptomsId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Recipes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Recipes_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Recipes_Symptomses_SymptomsId",
|
||||
column: x => x.SymptomsId,
|
||||
principalTable: "Symptomses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Kurse",
|
||||
columns: table => new
|
||||
@ -145,60 +174,31 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Recipes",
|
||||
name: "ProcedureMedicine",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Dose = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
MedicinesId = table.Column<int>(type: "int", nullable: false),
|
||||
ModeOfApplication = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
MedicineId = table.Column<int>(type: "int", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Recipes", x => x.Id);
|
||||
table.PrimaryKey("PK_ProcedureMedicine", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Recipes_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Recipes_Medicines_MedicinesId",
|
||||
column: x => x.MedicinesId,
|
||||
name: "FK_ProcedureMedicine_Medicines_MedicineId",
|
||||
column: x => x.MedicineId,
|
||||
principalTable: "Medicines",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProcedureMedicine_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "IllnessKurse",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
IllnessId = table.Column<int>(type: "int", nullable: false),
|
||||
KurseId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_IllnessKurse", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_IllnessKurse_Illnesses_IllnessId",
|
||||
column: x => x.IllnessId,
|
||||
principalTable: "Illnesses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_IllnessKurse_Kurse_KurseId",
|
||||
column: x => x.KurseId,
|
||||
principalTable: "Kurse",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RecipesProcedures",
|
||||
columns: table => new
|
||||
@ -226,27 +226,27 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RecipesSymptoms",
|
||||
name: "IllnessKurse",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RecipesId = table.Column<int>(type: "int", nullable: false),
|
||||
SymptomsId = table.Column<int>(type: "int", nullable: false)
|
||||
IllnessId = table.Column<int>(type: "int", nullable: false),
|
||||
KurseId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RecipesSymptoms", x => x.Id);
|
||||
table.PrimaryKey("PK_IllnessKurse", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecipesSymptoms_Recipes_RecipesId",
|
||||
column: x => x.RecipesId,
|
||||
principalTable: "Recipes",
|
||||
name: "FK_IllnessKurse_Illnesses_IllnessId",
|
||||
column: x => x.IllnessId,
|
||||
principalTable: "Illnesses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecipesSymptoms_Symptomses_SymptomsId",
|
||||
column: x => x.SymptomsId,
|
||||
principalTable: "Symptomses",
|
||||
name: "FK_IllnessKurse_Kurse_KurseId",
|
||||
column: x => x.KurseId,
|
||||
principalTable: "Kurse",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -281,6 +281,16 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
table: "Medicines",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureMedicine_MedicineId",
|
||||
table: "ProcedureMedicine",
|
||||
column: "MedicineId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProcedureMedicine_ProcedureId",
|
||||
table: "ProcedureMedicine",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Procedures_ClientId",
|
||||
table: "Procedures",
|
||||
@ -292,9 +302,9 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Recipes_MedicinesId",
|
||||
name: "IX_Recipes_SymptomsId",
|
||||
table: "Recipes",
|
||||
column: "MedicinesId");
|
||||
column: "SymptomsId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecipesProcedures_ProcedureId",
|
||||
@ -305,16 +315,6 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
name: "IX_RecipesProcedures_RecipesId",
|
||||
table: "RecipesProcedures",
|
||||
column: "RecipesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecipesSymptoms_RecipesId",
|
||||
table: "RecipesSymptoms",
|
||||
column: "RecipesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecipesSymptoms_SymptomsId",
|
||||
table: "RecipesSymptoms",
|
||||
column: "SymptomsId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -327,10 +327,10 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
name: "IllnessSymptomses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RecipesProcedures");
|
||||
name: "ProcedureMedicine");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RecipesSymptoms");
|
||||
name: "RecipesProcedures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Kurse");
|
||||
@ -345,10 +345,10 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
name: "Recipes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Symptomses");
|
||||
name: "Medicines");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Medicines");
|
||||
name: "Symptomses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
@ -169,6 +169,29 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.ProcedureMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.ToTable("ProcedureMedicine");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -213,18 +236,18 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MedicinesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ModeOfApplication")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MedicinesId");
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("Recipes");
|
||||
});
|
||||
@ -252,29 +275,6 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.ToTable("RecipesProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("RecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RecipesId");
|
||||
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("RecipesSymptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Symptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -355,6 +355,25 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.ProcedureMedicine", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicine")
|
||||
.WithMany("Procedures")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Procedures", "Procedure")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medicine");
|
||||
|
||||
b.Navigation("Procedure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Client", "Client")
|
||||
@ -374,15 +393,15 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicines")
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicinesId")
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Medicines");
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesProcedures", b =>
|
||||
@ -404,25 +423,6 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.Navigation("Recipe");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Recipes", "Recipe")
|
||||
.WithMany()
|
||||
.HasForeignKey("RecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany()
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Recipe");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Illness", b =>
|
||||
{
|
||||
b.Navigation("Kurses");
|
||||
@ -435,6 +435,16 @@ namespace HospitalDataBaseImplements.Migrations
|
||||
b.Navigation("IllnessKurses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Medicines", b =>
|
||||
{
|
||||
b.Navigation("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.Navigation("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.Navigation("Procedures");
|
||||
|
@ -14,12 +14,15 @@ namespace HospitalDataBaseImplements.Models
|
||||
public class Medicines : IMedicinesModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public virtual Client Client { get; set; }
|
||||
[Required]
|
||||
public string MedicinesName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Group { get; private set; } = string.Empty;
|
||||
public virtual Client Client { get; set; }
|
||||
[ForeignKey("MedicineId")]
|
||||
public virtual List<ProcedureMedicine> Procedures { get; set; } = new();
|
||||
public static Medicines? Create(MedicinesBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -7,14 +7,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalDataBaseImplements.Models
|
||||
{
|
||||
public class RecipesSymptoms
|
||||
public class ProcedureMedicine
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int RecipesId { get; set; }
|
||||
public int MedicineId { get; set; }
|
||||
[Required]
|
||||
public int SymptomsId { get; set; }
|
||||
public virtual Recipes Recipe { get; set; } = new();
|
||||
public virtual Symptoms Symptoms { get; set; } = new();
|
||||
public int ProcedureId { get; set; }
|
||||
public virtual Medicines Medicine { get; set; } = new();
|
||||
public virtual Procedures Procedure { get; set; } = new();
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ using HospitalDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -15,11 +16,29 @@ namespace HospitalDataBaseImplements.Models
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public virtual Client Client { get; set; }
|
||||
[Required]
|
||||
public string ProceduresName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Type { get; private set; } = string.Empty;
|
||||
public virtual Client Client { get; set; }
|
||||
private Dictionary<int, IMedicinesModel>? _procedureMedicine = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IMedicinesModel> ProcedureMedicine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_procedureMedicine == null)
|
||||
{
|
||||
_procedureMedicine = Medicines
|
||||
.ToDictionary(rec => rec.MedicineId, rec =>
|
||||
rec.Medicine as IMedicinesModel);
|
||||
}
|
||||
return _procedureMedicine;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ProcedureId")]
|
||||
public virtual List<ProcedureMedicine> Medicines { get; set; } = new();
|
||||
public static Procedures? Create(ProceduresBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -60,5 +79,32 @@ namespace HospitalDataBaseImplements.Models
|
||||
ProceduresName = ProceduresName,
|
||||
Type = Type
|
||||
};
|
||||
|
||||
public void UpdateMedicines(HospitalDatabase context, ProceduresBindingModel model)
|
||||
{
|
||||
var procedureMedicine = context.ProcedureMedicine.Where(rec => rec.ProcedureId == model.Id).ToList();
|
||||
if (procedureMedicine != null && procedureMedicine.Count > 0)
|
||||
{
|
||||
context.ProcedureMedicine.RemoveRange(procedureMedicine.Where(rec
|
||||
=> !model.ProcedureMedicine.ContainsKey(rec.MedicineId)));
|
||||
context.SaveChanges();
|
||||
}
|
||||
var procedure = context.Procedures.First(x => x.Id == Id);
|
||||
var existingMedicineIds = procedureMedicine?.Select(x => x.MedicineId).ToList();
|
||||
foreach (var rec in model.ProcedureMedicine)
|
||||
{
|
||||
|
||||
if (existingMedicineIds != null && !existingMedicineIds.Contains(rec.Key))
|
||||
{
|
||||
context.ProcedureMedicine.Add(new ProcedureMedicine
|
||||
{
|
||||
Procedure = procedure,
|
||||
Medicine = context.Medicines.First(x => x.Id == rec.Key),
|
||||
});
|
||||
}
|
||||
}
|
||||
context.SaveChanges();
|
||||
_procedureMedicine = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,13 @@ namespace HospitalDataBaseImplements.Models
|
||||
public string Dose { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime Date { get; private set; } = DateTime.Now;
|
||||
[Required]
|
||||
public int ClientId { get; set; }
|
||||
public virtual Medicines Medicines { get; set; } = new();
|
||||
public int MedicinesId { get; private set; }
|
||||
[Required]
|
||||
public string ModeOfApplication { get; private set; } = string.Empty;
|
||||
public Client Client { get; set; }
|
||||
[Required]
|
||||
public int SymptomsId { get; private set; }
|
||||
|
||||
private Dictionary<int, IProceduresModel>? _recipeProcedures = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IProceduresModel> RecipeProcedures
|
||||
@ -43,59 +44,49 @@ namespace HospitalDataBaseImplements.Models
|
||||
}
|
||||
[ForeignKey("RecipesId")]
|
||||
public virtual List<RecipesProcedures> Procedures { get; set; } = new();
|
||||
|
||||
//private Dictionary<int, ISymptomsModel>? _recipeSymptoms = null;
|
||||
//[NotMapped]
|
||||
//public Dictionary<int, ISymptomsModel> RecipeSymptoms
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (_recipeSymptoms == null)
|
||||
// {
|
||||
// _recipeSymptoms = Symptoms.ToDictionary(recPC => recPC.SymptomsId, recPC => (recPC.Symptoms as ISymptomsModel));
|
||||
// }
|
||||
// return _recipeSymptoms;
|
||||
// }
|
||||
//}
|
||||
//public virtual List<RecipesSymptoms> Symptoms { get; set; } = new();
|
||||
|
||||
public Client Client { get; set; }
|
||||
public Symptoms Symptoms { get; set; }
|
||||
public static Recipes? Create(RecipesBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Recipes()
|
||||
{
|
||||
Id = model.Id,
|
||||
SymptomsId = model.SymptomsId,
|
||||
Dose = model.Dose,
|
||||
Date = model.Date,
|
||||
ModeOfApplication = model.ModeOfApplication,
|
||||
ClientId = model.ClientId
|
||||
//Symptoms = model.RecipeSymptoms.Select(x => new RecipesSymptoms
|
||||
//{
|
||||
// Symptoms = context.Symptomses.First(y => y.Id == x.Key),
|
||||
//}).ToList()
|
||||
ClientId = model.ClientId,
|
||||
ModeOfApplication = model.ModeOfApplication
|
||||
};
|
||||
}
|
||||
public static Recipes Create(RecipesViewModel model)
|
||||
{
|
||||
return new Recipes()
|
||||
{
|
||||
Id = model.Id,
|
||||
SymptomsId = model.SymptomsId,
|
||||
Dose = model.Dose,
|
||||
ClientId = model.ClientId,
|
||||
ModeOfApplication = model.ModeOfApplication
|
||||
};
|
||||
}
|
||||
public void Update(RecipesBindingModel model)
|
||||
{
|
||||
Date = model.Date;
|
||||
MedicinesId = model.MedicinesId;
|
||||
Dose = model.Dose;
|
||||
ModeOfApplication = model.ModeOfApplication;
|
||||
}
|
||||
public RecipesViewModel GetViewModel
|
||||
public RecipesViewModel GetViewModel => new()
|
||||
{
|
||||
get
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
return new RecipesViewModel
|
||||
{
|
||||
Id = Id,
|
||||
Date = Date,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
||||
MedicinesId = MedicinesId,
|
||||
RecipeProcedures = RecipeProcedures,
|
||||
//RecipeSymptoms = RecipeSymptoms
|
||||
};
|
||||
}
|
||||
}
|
||||
Id = Id,
|
||||
Date = Date,
|
||||
ClientId = ClientId,
|
||||
ModeOfApplication = ModeOfApplication,
|
||||
Dose = Dose,
|
||||
SymptomsId = SymptomsId
|
||||
};
|
||||
public void UpdateProcedures(HospitalDatabase context, RecipesBindingModel model)
|
||||
{
|
||||
var recipeProcedures = context.RecipesProcedures.Where(rec => rec.RecipesId == model.Id).ToList();
|
||||
@ -117,26 +108,5 @@ namespace HospitalDataBaseImplements.Models
|
||||
}
|
||||
_recipeProcedures = null;
|
||||
}
|
||||
//public void UpdateSymptomses(HospitalDatabase context, RecipesBindingModel model)
|
||||
//{
|
||||
// var recipeSymptomses = context.RecipesSymptoms.Where(rec => rec.RecipesId == model.Id).ToList();
|
||||
// if (recipeSymptomses != null && recipeSymptomses.Count > 0)
|
||||
// { // удалили те, которых нет в модели
|
||||
// context.RecipesSymptoms.RemoveRange(recipeSymptomses.Where(rec
|
||||
// => !model.RecipeSymptoms.ContainsKey(rec.SymptomsId)));
|
||||
// context.SaveChanges();
|
||||
// }
|
||||
// var recipe = context.Recipes.First(x => x.Id == Id);
|
||||
// foreach (var pc in model.RecipeSymptoms)
|
||||
// {
|
||||
// context.RecipesSymptoms.Add(new RecipesSymptoms
|
||||
// {
|
||||
// Recipe = recipe,
|
||||
// Symptoms = context.Symptomses.First(x => x.Id == pc.Key)
|
||||
// });
|
||||
// context.SaveChanges();
|
||||
// }
|
||||
// _recipeSymptoms = null;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace HospitalDataBaseImplements.Models
|
||||
{
|
||||
@ -40,6 +41,18 @@ namespace HospitalDataBaseImplements.Models
|
||||
Description = model.Description
|
||||
};
|
||||
}
|
||||
public static Symptoms? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Symptoms()
|
||||
{
|
||||
SymptomName = element.Element("SymptomName")!.Value,
|
||||
Description = element.Element("Description")!.Value
|
||||
};
|
||||
}
|
||||
public void Update(SymptomsBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Illness>
|
||||
<Illness Id="1">
|
||||
<IllnessName>Ветрянка</IllnessName>
|
||||
<Form>Тяжелая</Form>
|
||||
<Symptoms>
|
||||
<SymptomId >1</SymptomId>
|
||||
<SymptomId >2</SymptomId>
|
||||
<SymptomId >3</SymptomId>
|
||||
</Symptoms>
|
||||
<Kurses>
|
||||
<KurseId >1</KurseId>
|
||||
<KurseId >2</KurseId>
|
||||
</Kurses>
|
||||
</Illness>
|
||||
<Illness Id="2">
|
||||
<IllnessName>Воспаление аппендицита</IllnessName>
|
||||
<Form>Легкая</Form>
|
||||
<Symptoms>
|
||||
<SymptomId >1</SymptomId>
|
||||
</Symptoms>
|
||||
<Kurses>
|
||||
<KurseId >1</KurseId>
|
||||
</Kurses>
|
||||
</Illness>
|
||||
<Illness Id="3">
|
||||
<IllnessName>ОРВИ</IllnessName>
|
||||
<Form>Средняя</Form>
|
||||
<Symptoms>
|
||||
<SymptomId >1</SymptomId>
|
||||
<SymptomId >2</SymptomId>
|
||||
</Symptoms>
|
||||
<Kurses>
|
||||
<KurseId >1</KurseId>
|
||||
<KurseId >3</KurseId>
|
||||
</Kurses>
|
||||
</Illness>
|
||||
<Illness Id="4">
|
||||
<IllnessName>Отравление</IllnessName>
|
||||
<Form>Тяжелая</Form>
|
||||
<Symptoms>
|
||||
<SymptomId >1</SymptomId>
|
||||
<SymptomId >2</SymptomId>
|
||||
<SymptomId >3</SymptomId>
|
||||
<SymptomId >4</SymptomId>
|
||||
<SymptomId >5</SymptomId>
|
||||
<SymptomId >6</SymptomId>
|
||||
</Symptoms>
|
||||
<Kurses>
|
||||
<KurseId >1</KurseId>
|
||||
<KurseId >2</KurseId>
|
||||
<KurseId >3</KurseId>
|
||||
<KurseId >4</KurseId>
|
||||
</Kurses>
|
||||
</Illness>
|
||||
<Illness Id="5">
|
||||
<IllnessName>Перелом</IllnessName>
|
||||
<Form>Средняя</Form>
|
||||
<Symptoms>
|
||||
<SymptomId >3</SymptomId>
|
||||
</Symptoms>
|
||||
<Kurses>
|
||||
<KurseId >1</KurseId>
|
||||
<KurseId >2</KurseId>
|
||||
</Kurses>
|
||||
</Illness>
|
||||
<Illness Id="6">
|
||||
<IllnessName>Мигрень</IllnessName>
|
||||
<Form>Тяжелая</Form>
|
||||
<Symptoms>
|
||||
<SymptomId >1</SymptomId>
|
||||
<SymptomId >3</SymptomId>
|
||||
<SymptomId >4</SymptomId>
|
||||
</Symptoms>
|
||||
<Kurses>
|
||||
<KurseId >1</KurseId>
|
||||
<KurseId >3</KurseId>
|
||||
<KurseId >4</KurseId>
|
||||
</Kurses>
|
||||
</Illness>
|
||||
<Illness Id="7">
|
||||
<IllnessName>Астма</IllnessName>
|
||||
<Form>Легкая</Form>
|
||||
<Symptoms>
|
||||
<SymptomId >5</SymptomId>
|
||||
</Symptoms>
|
||||
<Kurses>
|
||||
<KurseId >5</KurseId>
|
||||
</Kurses>
|
||||
</Illness>
|
||||
</Illness>
|
@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Kurses>
|
||||
<Kurses Id="1">
|
||||
<CountInDay>4</CountInDay>
|
||||
<Duration>1 месяц</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
<Kurses Id="2">
|
||||
<CountInDay>3</CountInDay>
|
||||
<Duration>1 месяц</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
<Kurses Id="3">
|
||||
<CountInDay>1</CountInDay>
|
||||
<Duration>2 месяца</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
<Kurses Id="4">
|
||||
<CountInDay>7</CountInDay>
|
||||
<Duration>1 неделя</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
<Kurses Id="5">
|
||||
<CountInDay>2</CountInDay>
|
||||
<Duration>10 дней</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
<Kurses Id="6">
|
||||
<CountInDay>5</CountInDay>
|
||||
<Duration>3 недели</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
<Kurses Id="7">
|
||||
<CountInDay>3</CountInDay>
|
||||
<Duration>20 дней</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
<Kurses Id="8">
|
||||
<CountInDay>2</CountInDay>
|
||||
<Duration>1,5 недели</Duration>
|
||||
<MedicinesId>1</MedicinesId>
|
||||
</Kurses>
|
||||
</Kurses>
|
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Symptoms>
|
||||
<Symptoms Id="1">
|
||||
<SymptomName>Кашель</SymptomName>
|
||||
<Description>Сухой</Description>
|
||||
</Symptoms>
|
||||
<Symptoms Id="2">
|
||||
<SymptomName>Отечность</SymptomName>
|
||||
<Description>Ноги</Description>
|
||||
</Symptoms>
|
||||
<Symptoms Id="3">
|
||||
<SymptomName>Заложенность носа</SymptomName>
|
||||
<Description>2 ноздри</Description>
|
||||
</Symptoms>
|
||||
<Symptoms Id="4">
|
||||
<SymptomName>Тошнота</SymptomName>
|
||||
<Description>Прозрачные выделения</Description>
|
||||
</Symptoms>
|
||||
<Symptoms Id="5">
|
||||
<SymptomName>Боль в сердце</SymptomName>
|
||||
<Description>Постоянная</Description>
|
||||
</Symptoms>
|
||||
<Symptoms Id="6">
|
||||
<SymptomName>Боль в животе</SymptomName>
|
||||
<Description>Умеренная</Description>
|
||||
</Symptoms>
|
||||
<Symptoms Id="7">
|
||||
<SymptomName>Боль</SymptomName>
|
||||
<Description>Тяжелая</Description>
|
||||
</Symptoms>
|
||||
<Symptoms Id="8">
|
||||
<SymptomName>Головокружение</SymptomName>
|
||||
<Description>При нагрузках</Description>
|
||||
</Symptoms>
|
||||
</Symptoms>
|
@ -12,6 +12,5 @@ namespace HospitalDataModels.Models
|
||||
string Form { get; }
|
||||
Dictionary<int, ISymptomsModel> IllnessSymptoms { get; }
|
||||
Dictionary<int, IKurseModel> IllnessKurse { get; }
|
||||
//int ClientId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,5 @@ namespace HospitalDataModels.Models
|
||||
int CountInDay { get; }
|
||||
int MedicinesId { get; }
|
||||
string MedicinesName { get; }
|
||||
//int ClientId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ namespace HospitalDataModels.Models
|
||||
string ProceduresName { get; }
|
||||
string Type { get; }
|
||||
int ClientId { get; }
|
||||
Dictionary<int, IMedicinesModel> ProcedureMedicine { get; }
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalDataModels.Models
|
||||
@ -11,9 +12,9 @@ namespace HospitalDataModels.Models
|
||||
string Dose { get; }
|
||||
DateTime Date { get; }
|
||||
string ModeOfApplication { get; }
|
||||
int MedicinesId { get; }
|
||||
int ClientId { get; }
|
||||
int SymptomsId { get; }
|
||||
Dictionary<int, IProceduresModel> RecipeProcedures { get; }
|
||||
//Dictionary<int, ISymptomsModel> RecipeSymptoms { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace HospitalDataModels.Models
|
||||
public interface ISymptomsModel: IId
|
||||
{
|
||||
string SymptomName { get; }
|
||||
string Description { get; }
|
||||
//int ClientId { get; }
|
||||
string? Description { get; }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user