вэтс ол ай гес энд билив
This commit is contained in:
parent
4d9cc77ab5
commit
2fb5871f9d
@ -12,6 +12,8 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HospitalBusinessLogic.OfficePackage;
|
||||
using HospitalBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace HospitalBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -23,8 +25,12 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
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)
|
||||
public ReportLogicDoctor(IPatientStorage patientStorage, IMedicineStorage medicineStorage, IProcedureStorage procedureStorage, IRecipeStorage recipeStorage, IDiseaseStorage diseaseStorage,
|
||||
AbstractSaveToExcelDoctor saveToExcel, AbstractSaveToWordDoctor saveToWord, AbstractSaveToPdfDoctor saveToPdf)
|
||||
{
|
||||
|
||||
_patientStorage = patientStorage;
|
||||
@ -32,10 +38,14 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
_procedureStorage = procedureStorage;
|
||||
_recipeStorage = recipeStorage;
|
||||
_diseaseStorage = diseaseStorage;
|
||||
}
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
|
||||
}
|
||||
|
||||
//отчет по лекарствам и болезням у пациента за период
|
||||
public List<ReportPatientViewModel> GetMedicineDiseases(ReportBindingModel model, PatientBindingModel patientModel)
|
||||
/*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 });
|
||||
@ -44,15 +54,15 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
{
|
||||
var purchase = _patientStorage.GetElement(new() { Id = patient.Id })!;
|
||||
List<string> diseaseList = new List<string>();
|
||||
List<string> medicineList = new List<string>();
|
||||
List<string> patientList = new List<string>();
|
||||
foreach (var recipe in _recipeStorage.GetFilteredList(new RecipeSearchModel {PatientId = patient.Id}))
|
||||
{
|
||||
foreach (var medicine in _medicineStorage.GetFilteredList(new MedicineSearchModel { RecipeId = recipe.Id }))
|
||||
foreach (var patient in _patientStorage.GetFilteredList(new PatientSearchModel { RecipeId = recipe.Id }))
|
||||
{
|
||||
medicineList.Add(new(medicine.Name));
|
||||
patientList.Add(new(patient.Name));
|
||||
|
||||
|
||||
foreach (var disease in medicine.MedicineRecipes)
|
||||
foreach (var disease in patient.PatientRecipes)
|
||||
{
|
||||
diseaseList.Add(disease.Value.Description);
|
||||
}
|
||||
@ -64,7 +74,7 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
FIO = patient.FIO,
|
||||
|
||||
Diseases = diseaseList,
|
||||
Medicines = medicineList
|
||||
Patients = patientList
|
||||
};
|
||||
list.Add(record);
|
||||
}
|
||||
@ -102,19 +112,161 @@ namespace HospitalBusinessLogic.BusinessLogics
|
||||
|
||||
|
||||
|
||||
public void SavePatientsToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveProcedureRecipesToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
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)
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
<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>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -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,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,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,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,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,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,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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,12 @@ namespace HospitalContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IDoctorReportLogic
|
||||
{
|
||||
List<ReportPatientRecipeViewModel> GetPatients();
|
||||
List<ReportPatientViewModel> GetMedicineDiseases(ReportBindingModel model, PatientBindingModel patientModel);
|
||||
void SaveProcedureRecipesToWordFile(ReportBindingModel model);
|
||||
void SaveProcedureRecipesToExcelFile(ReportBindingModel model);
|
||||
void SavePatientsToPdfFile(ReportBindingModel model);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
|
||||
namespace HospitalContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportLogicDoctorcs
|
||||
{
|
||||
List<ListRecipesViewModel> GetProcedureRecipes(List<int> animals);
|
||||
void SaveServicesToWordFile(ListProceduresBindingModel model);
|
||||
void SaveServicesToExcelFile(ListProceduresBindingModel model);
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.SearchModels
|
||||
{
|
||||
public class ListProcedureSearchModel
|
||||
public class ListProceduresSearchModel
|
||||
{
|
||||
public List<int>? recipesIds { 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; }
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.ViewModels
|
||||
{
|
||||
public class ListProcedureViewModel
|
||||
public class ListProceduresViewModel
|
||||
{
|
||||
public string ProcedureName { get; set; } = string.Empty;
|
||||
public string RecipeName { get; set; } = string.Empty;
|
||||
public List<ProcedureViewModel> Procedures { get; set; } = new();
|
||||
}
|
||||
}
|
@ -10,5 +10,6 @@ namespace HospitalContracts.ViewModels
|
||||
{
|
||||
public string ProcedureName { get; set; } = string.Empty;
|
||||
public List<RecipeViewModel> Recipes { get; set; } = new();
|
||||
public List<ProcedureViewModel> Procedures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ 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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ namespace HospitalDatabaseImplement.Models
|
||||
|
||||
public PatientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FIO = FIO,
|
||||
Address = Address,
|
||||
BirthDate = BirthDate,
|
||||
|
@ -70,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; }
|
||||
|
@ -69,14 +69,19 @@ namespace HospitalDatabaseImplement.Modelss
|
||||
{
|
||||
IssueDate = model.IssueDate;
|
||||
Description = model.Description;
|
||||
}
|
||||
DiseaseId = model.DiseaseId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public RecipeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
IssueDate = IssueDate,
|
||||
Description = Description,
|
||||
RecipePatients = RecipePatients
|
||||
RecipePatients = RecipePatients,
|
||||
DoctorId= DoctorId,
|
||||
DiseaseId = DiseaseId
|
||||
};
|
||||
|
||||
public void UpdatePatients(HospitalDatabase context, RecipeBindingModel model)
|
||||
|
@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO.Pipelines;
|
||||
using System.Text;
|
||||
|
||||
namespace HospitalDoctorApp.Controllers
|
||||
{
|
||||
@ -420,7 +421,7 @@ namespace HospitalDoctorApp.Controllers
|
||||
#endregion
|
||||
|
||||
#region Промежуточные таблицы
|
||||
public IActionResult PatientRecipes()
|
||||
/*public IActionResult PatientRecipes()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
@ -457,7 +458,7 @@ namespace HospitalDoctorApp.Controllers
|
||||
RecipePatients = v
|
||||
});
|
||||
Response.Redirect("IndexRecipes");
|
||||
}
|
||||
}*/
|
||||
public IActionResult ProcedurePatients()
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
@ -553,7 +554,7 @@ namespace HospitalDoctorApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult ProcedureListReport()
|
||||
{
|
||||
ViewBag.Services = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorid={APIClient.Doctor.Id}");
|
||||
ViewBag.Recipes = APIClient.GetRequest<List<RecipeViewModel>>($"api/recipe/getrecipes?doctorid={APIClient.Doctor.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -597,6 +598,7 @@ namespace HospitalDoctorApp.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetWordFile()
|
||||
{
|
||||
@ -615,7 +617,7 @@ namespace HospitalDoctorApp.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetPacientsReport(DateTime dateFrom, DateTime dateTo)
|
||||
public string GetPatientsReport(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIClient.Doctor == null)
|
||||
{
|
||||
@ -651,7 +653,7 @@ namespace HospitalDoctorApp.Controllers
|
||||
{
|
||||
table += "<tbody>";
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{patient.Date}</td>";
|
||||
table += $"<td>{patient.PatientFIO}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
@ -659,7 +661,7 @@ namespace HospitalDoctorApp.Controllers
|
||||
foreach (var disease in patient.Diseases)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td>{disease.Description}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{disease.Name}</td>";
|
||||
table += $"<td></td>";
|
||||
@ -668,10 +670,10 @@ namespace HospitalDoctorApp.Controllers
|
||||
foreach (var medicine in patient.Medicines)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{medicine.Name}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{medicine.CountryOrigin}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
table += "</tbody>";
|
||||
@ -700,8 +702,99 @@ namespace HospitalDoctorApp.Controllers
|
||||
Response.Redirect("Report");
|
||||
|
||||
}
|
||||
#endregion
|
||||
#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>
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
<p>
|
||||
<a asp-action="UpdatePatient">Редактировать пациента</a>
|
||||
<a asp-action="DeletePatient">Удалить пациента</a>
|
||||
<a asp-action="AddProcedureToPatient">Связать пациента и процедуру</a>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="CreatePatient">Создать пациента</a>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<p>
|
||||
<a asp-action="UpdateRecipe">Редактировать рецепт</a>
|
||||
<a asp-action="DeleteRecipe">Удалить рецепт</a>
|
||||
<a asp-action="LinkPatientAndProcedure">Связать рецепт(процедуру?) и пациента</a>
|
||||
<a asp-action="PatientRecipes">Связать рецепт и пациента</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="CreateRecipe">Создать рецепт</a>
|
||||
|
@ -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>
|
||||
}
|
@ -17,14 +17,23 @@
|
||||
<select name="recipes" class="form-control" multiple size="5" id="recipes">
|
||||
@foreach (var recipe in ViewBag.Recipes)
|
||||
{
|
||||
<option value="@recipe.Id">@recipe.RecipeName</option>
|
||||
<option value="@recipe.Id">@recipe.Description</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Word" class="btn btn-primary" /></div>
|
||||
<div class="col-4"><input type="submit" value="Excel" class="btn btn-primary" /></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>
|
||||
|
@ -49,7 +49,7 @@
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetAnimalsReport",
|
||||
url: "/Home/GetPatientsReport",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
|
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>
|
@ -44,6 +44,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Report">Отчет</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Statistics">Статистика</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,7 +6,7 @@ using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
|
@ -6,7 +6,7 @@ using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
@ -54,7 +54,7 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка визитов");
|
||||
_logger.LogError(ex, "Ошибка получения списка пациентов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDatabaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
@ -38,6 +38,26 @@ namespace VetClinicRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<RecipeViewModel> GetRecipes(int? doctorId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<RecipeViewModel> res;
|
||||
if (!doctorId.HasValue)
|
||||
res = _recipe.ReadList(null);
|
||||
else
|
||||
res = _recipe.ReadList(new RecipeSearchModel { DoctorId = doctorId });
|
||||
foreach (var recipe in res)
|
||||
recipe.RecipePatients = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка услуг");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<RecipeViewModel>? GetRecipeList(int? doctorId = null)
|
||||
|
@ -1,5 +1,7 @@
|
||||
using HospitalBusinessLogic.BusinessLogics;
|
||||
using HospitalBusinessLogic.MailWorker;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.BusinessLogicsContracts;
|
||||
using HospitalContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -11,9 +13,9 @@ namespace HospitalRestApi.Controllers
|
||||
[ApiController]
|
||||
public class ReportController : Controller
|
||||
{
|
||||
private readonly IReportLogicDoctor _reportDoctor;
|
||||
private readonly IDoctorReportLogic _reportDoctor;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
public ReportController(ILogger<ReportController> logger, IReportLogicPharmacist reportPharmacist, AbstractMailWorker mailWorker)
|
||||
public ReportController(ILogger<ReportController> logger, IDoctorReportLogic reportPharmacist, AbstractMailWorker mailWorker)
|
||||
{
|
||||
_reportDoctor = reportPharmacist;
|
||||
_mailWorker = mailWorker;
|
||||
@ -36,7 +38,7 @@ namespace HospitalRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateProceddureListExcelFile(ListProceduresBindingModel model)
|
||||
public void CreateProcedureListExcelFile(ListProceduresBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -58,7 +60,7 @@ namespace HospitalRestApi.Controllers
|
||||
model.DateFrom = DateFrom;
|
||||
model.DateTo = DateTo;
|
||||
model.DoctorId = doctorId;
|
||||
return _reportDoctor.GetMedicinesDiseases(model);
|
||||
return _reportDoctor.GetPatientMedicinesAndDiseases(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,9 +1,14 @@
|
||||
using HospitalBusinessLogic.BusinessLogics;
|
||||
using HospitalBusinessLogic.MailWorker;
|
||||
using HospitalBusinessLogic.OfficePackage;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.BusinessLogicsContracts;
|
||||
using HospitalContracts.StoragesContracts;
|
||||
using HospitalDatabaseImplement.Implements;
|
||||
using HospitalDatabaseImplement.Implementss;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using HospitalBusinessLogic.OfficePackage.Implements;
|
||||
using HospitalContracts.BindingModels;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -31,6 +36,12 @@ builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
|
||||
builder.Services.AddTransient<IDescriptionProcedureLogic, DescriptionProcedureLogic>();
|
||||
|
||||
builder.Services.AddTransient<IDoctorReportLogic, ReportLogicDoctor>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelDoctor, SaveToExcelDoctor>();
|
||||
builder.Services.AddTransient<AbstractSaveToWordDoctor, SaveToWordDoctor>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfDoctor, SaveToPdfDoctor>();
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
@ -44,6 +55,24 @@ builder.Services.AddSwaggerGen(c =>
|
||||
});
|
||||
});
|
||||
var app = builder.Build();
|
||||
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString()
|
||||
?? string.Empty,
|
||||
MailPassword =
|
||||
builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ??
|
||||
string.Empty,
|
||||
SmtpClientHost =
|
||||
builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ??
|
||||
string.Empty,
|
||||
SmtpClientPort =
|
||||
Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
||||
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ??
|
||||
string.Empty,
|
||||
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
||||
});
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -5,5 +5,11 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"SmtpClientHost": "smtp.gmail.com",
|
||||
"SmtpClientPort": "587",
|
||||
"PopHost": "pop.gmail.com",
|
||||
"PopPort": "995",
|
||||
"MailLogin": "valanuni04@gmail.com",
|
||||
"MailPassword": "bpkm pnxf rbvi sroc"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user