From 86f949cc30546c45cb86959e3e0ddf20bd4335ea Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Fri, 7 Apr 2023 16:42:04 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5:=20=D0=B3=D0=B4=D0=B5-=D1=82=D0=BE=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D1=8B,=20=D0=B3=D0=B4=D0=B5-?= =?UTF-8?q?=D1=82=D0=BE=20=D1=83=D0=B1=D1=80=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hospital/HospitalBusinessLogic/PatientLogic.cs | 2 +- .../Implements/ProcedureStorage.cs | 3 +-- .../HospitalDatabaseImplement/LoaderFromXML.cs | 17 +++++++++++++---- .../Models/Procedure.cs | 14 +++++++------- .../XMLData/Procedure.xml | 14 ++++++-------- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Hospital/HospitalBusinessLogic/PatientLogic.cs b/Hospital/HospitalBusinessLogic/PatientLogic.cs index cbd7c37..bea9da4 100644 --- a/Hospital/HospitalBusinessLogic/PatientLogic.cs +++ b/Hospital/HospitalBusinessLogic/PatientLogic.cs @@ -103,7 +103,7 @@ namespace HospitalBusinessLogic throw new ArgumentNullException("Нет имени пациента", nameof(model.Name)); } - // TODO: проверка на наличие даты рождения и фамилии в модели? + _logger.LogInformation("Patient. Surname:{ Date}. Name: {Name}. Patronymic: {Patronymic}. BirthDate: {BirthDate}. Id: { Id}", model.Surname, model.Name, model.Patronymic, model.BirthDate, model.Id); } diff --git a/Hospital/HospitalDatabaseImplement/Implements/ProcedureStorage.cs b/Hospital/HospitalDatabaseImplement/Implements/ProcedureStorage.cs index 34d3c1d..663970a 100644 --- a/Hospital/HospitalDatabaseImplement/Implements/ProcedureStorage.cs +++ b/Hospital/HospitalDatabaseImplement/Implements/ProcedureStorage.cs @@ -19,8 +19,7 @@ namespace HospitalDatabaseImplement.Implements return context.Procedures.Include(x => x.Medicines).ThenInclude(x => x.Medicine).FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) ?.GetViewModel; - } - // TODO: подумать над параметрами фильтрации + } public List GetFilteredList(ProcedureSearchModel model) { if (string.IsNullOrEmpty(model.Name)) diff --git a/Hospital/HospitalDatabaseImplement/LoaderFromXML.cs b/Hospital/HospitalDatabaseImplement/LoaderFromXML.cs index aee986a..4986cbc 100644 --- a/Hospital/HospitalDatabaseImplement/LoaderFromXML.cs +++ b/Hospital/HospitalDatabaseImplement/LoaderFromXML.cs @@ -17,7 +17,10 @@ namespace HospitalDatabaseImplement } return new List(); } - + /// + /// Чтение пациентов из XML-файла + /// + /// public static void LoadPatients() { using var context = new HospitalDatabase(); @@ -31,7 +34,10 @@ namespace HospitalDatabaseImplement context.SaveChanges(); } - + /// + /// Чтение лечений из XML-файла + /// + /// public static void LoadTreatments() { using var context = new HospitalDatabase(); @@ -44,13 +50,16 @@ namespace HospitalDatabaseImplement }); context.SaveChanges(); } - + /// + /// Чтение поцедур из XML-файла + /// + /// public static void LoadProcedures() { using var context = new HospitalDatabase(); if (context.Procedures.ToList().Count > 0) return; - var list = LoadData(ProcedureFileName, "Procedure", x => Procedure.Create(context, x)!)!; + var list = LoadData(ProcedureFileName, "Procedure", x => Procedure.Create(x)!)!; list.ForEach(x => { context.Procedures.Add(x); diff --git a/Hospital/HospitalDatabaseImplement/Models/Procedure.cs b/Hospital/HospitalDatabaseImplement/Models/Procedure.cs index dde50e8..8d79577 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Procedure.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Procedure.cs @@ -53,19 +53,19 @@ namespace HospitalDatabaseImplement.Models }; } - public static Procedure? Create(HospitalDatabase context, XElement element) + public static Procedure? Create(XElement element) { if (element == null) { return null; } return new Procedure() - { - Name = element.Element("Name")!.Value, - /* Medicines = element.Element("Medicines")!.Elements("MedicineId").Select(x => new ProcedureMedicine - { - Medicine = context.Medicines?.First(y => y.Id == Convert.ToInt32(x.Value)) - }).ToList()*/ + { + Name = element.Element("Name")!.Value, + // при чтении из файла мы не можем загрузить сведения о лекарствах в процедуре (Medicines), + // так как на данном этапе нет созданных записей о лекарствах + // привязка будет осуществляться позднее - на клиенте будет данная возможность на дополнительной формочке + // Medicines = new() }; } diff --git a/Hospital/HospitalDatabaseImplement/XMLData/Procedure.xml b/Hospital/HospitalDatabaseImplement/XMLData/Procedure.xml index a046158..6623594 100644 --- a/Hospital/HospitalDatabaseImplement/XMLData/Procedure.xml +++ b/Hospital/HospitalDatabaseImplement/XMLData/Procedure.xml @@ -3,28 +3,26 @@ Процедура 1 - 1 - 2 - 3 Процедура 2 - - 1 + Процедура 3 - - 2 - 3 + Процедура 4 + + Процедура 5 + + \ No newline at end of file