1 часть
This commit is contained in:
parent
441b9a1443
commit
7707c90032
@ -1,6 +1,7 @@
|
||||
using ProjectPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,8 +11,13 @@ namespace ProjectPolyclinic.Entities;
|
||||
public class Doctor
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[DisplayName("Имя доктора")]
|
||||
public string First_Name { get; private set; } = string.Empty;
|
||||
[DisplayName("Фамилия доктора")]
|
||||
public string Last_Name { get; private set; } = string.Empty;
|
||||
public string FullName => $"{First_Name} {Last_Name}";
|
||||
|
||||
[DisplayName("Специализация")]
|
||||
public Specialization Specialization { get; private set; }
|
||||
public static Doctor CreateEntity(int id, string first_Name, string last_Name, Specialization specialization)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using ProjectPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,8 +11,12 @@ namespace ProjectPolyclinic.Entities;
|
||||
public class Medication
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Вид таблетки")]
|
||||
public MedicinesType MedicinesType { get; private set; }
|
||||
[DisplayName("Доза")]
|
||||
public string Dosing { get; private set; } = string.Empty;
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
public static Medication CreateEntity(int id,MedicinesType medicinesType,string dosing, string description)
|
||||
{
|
||||
@ -23,4 +28,5 @@ public class Medication
|
||||
Description = description ?? string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ProjectPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -9,6 +10,7 @@ namespace ProjectPolyclinic.Entities;
|
||||
public class Medicines_Visiting
|
||||
{
|
||||
public int MedicinesId { get; private set; }
|
||||
public MedicinesType MedicinesType { get; private set; }
|
||||
public int VisitingId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public static Medicines_Visiting CreateElement(int medicinesId, int visitingId, int count)
|
||||
@ -20,5 +22,6 @@ public class Medicines_Visiting
|
||||
Count = count
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -9,8 +10,13 @@ namespace ProjectPolyclinic.Entities
|
||||
public class Patient
|
||||
{
|
||||
public int Id { get;private set; }
|
||||
[DisplayName("Имя пациента")]
|
||||
public string First_Name { get; private set; } = string.Empty;
|
||||
[DisplayName("Фамилия пациента")]
|
||||
public string Last_Name { get; private set; } = string.Empty;
|
||||
public string FullName => $"{First_Name} {Last_Name}";
|
||||
|
||||
[DisplayName("Контактный номер")]
|
||||
public string ContactNumber { get; private set; } = string.Empty;
|
||||
public static Patient CreateEntity(int id, string first_Name, string last_Name, string contactNumber)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -9,7 +10,11 @@ namespace ProjectPolyclinic.Entities
|
||||
public class ProfessionalDevelopment
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Browsable(false)]
|
||||
public int DoctorId { get; private set; }
|
||||
[DisplayName("Доктор")]
|
||||
public string DoctorName { get; private set; } = string.Empty;
|
||||
[DisplayName("Дата повышения квалификации")]
|
||||
public DateTime ProfessionalDevelopmentTime { get; private set; }
|
||||
//public string Description { get; private set; } = string.Empty;
|
||||
public static ProfessionalDevelopment CreateOperation(int id, int doctorId, DateTime professionalDevelopmentTime)
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectPolyclinic.Entities;
|
||||
|
||||
public class TempMedicines_Visiting
|
||||
/*public class TempMedicines_Visiting
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int DoctorId { get; private set; }
|
||||
@ -17,4 +17,6 @@ public class TempMedicines_Visiting
|
||||
public int VisitingId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public int MedicinesId { get; private set; }
|
||||
}
|
||||
public string DoctorName { get; private set; }
|
||||
public string PatientName { get; private set; }
|
||||
}*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
using ProjectPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,10 +11,32 @@ namespace ProjectPolyclinic.Entities;
|
||||
public class Visiting
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int DoctorId { get; private set; }
|
||||
[Browsable(false)]
|
||||
public int PatientId { get; private set; }
|
||||
[DisplayName("Доктор")]
|
||||
public string DoctorName { get; private set; } = string.Empty;
|
||||
[DisplayName("Пациент")]
|
||||
public string PatientName { get; private set; } = string.Empty;
|
||||
[DisplayName("Название диагноза")]
|
||||
public DiagnosisName DiagnosisName { get; private set; }
|
||||
[DisplayName("Дата визита")]
|
||||
|
||||
public DateTime VisitingTime { get; private set; }
|
||||
/*public string Medication => Medicines != null ?
|
||||
string.Join(", ", Medicines
|
||||
.Where(x => x != null) // Добавляем проверку на null
|
||||
.Select(x =>
|
||||
x.Count > 0 ? $"{x.MedicinesType} {x.Count}" : $"{x.MedicinesType} (нет в наличии)")) :
|
||||
string.Empty;*/
|
||||
[DisplayName("Медикаменты")]
|
||||
public string Medication => Medicines != null ?
|
||||
string.Join(", ", Medicines.Select(x => $"{x.MedicinesType} {x.Count}")) :
|
||||
string.Empty;
|
||||
|
||||
[Browsable(false)]
|
||||
public IEnumerable<Medicines_Visiting> Medicines
|
||||
{
|
||||
get;
|
||||
@ -31,7 +54,7 @@ public class Visiting
|
||||
Medicines = medicines
|
||||
};
|
||||
}
|
||||
public static Visiting CreateOperation(TempMedicines_Visiting tempMedicines_Visiting, IEnumerable<Medicines_Visiting> medicines)
|
||||
/*public static Visiting CreateOperation(TempMedicines_Visiting tempMedicines_Visiting, IEnumerable<Medicines_Visiting> medicines)
|
||||
{
|
||||
return new Visiting
|
||||
{
|
||||
@ -40,7 +63,17 @@ public class Visiting
|
||||
PatientId = tempMedicines_Visiting.PatientId,
|
||||
DiagnosisName = tempMedicines_Visiting.DiagnosisName,
|
||||
VisitingTime = tempMedicines_Visiting.VisitingTime,
|
||||
DoctorName = tempMedicines_Visiting.DoctorName,
|
||||
PatientName = tempMedicines_Visiting.PatientName,
|
||||
Medicines = medicines
|
||||
};
|
||||
}*/
|
||||
public void SetMedicines_Visiting(IEnumerable<Medicines_Visiting> medicines_Visitings)
|
||||
{
|
||||
if (medicines_Visitings != null && medicines_Visitings.Any())
|
||||
{
|
||||
Medicines = medicines_Visitings;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -96,7 +96,13 @@ namespace ProjectPolyclinic.Forms
|
||||
}
|
||||
|
||||
}
|
||||
private void LoadList() => dataGridViewData.DataSource =_doctorRepository.ReadDoctors();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridViewData.DataSource = _doctorRepository.ReadDoctors();
|
||||
dataGridViewData.Columns["Id"].Visible = false;
|
||||
dataGridViewData.Columns["FullName"].Visible = false;
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
|
@ -95,7 +95,12 @@ namespace ProjectPolyclinic.Forms
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridViewData.DataSource = _medicationRepository.ReadMedicines();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridViewData.DataSource = _medicationRepository.ReadMedicines();
|
||||
dataGridViewData.Columns["Id"].Visible = false;
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
|
@ -96,7 +96,12 @@ namespace ProjectPolyclinic.Forms
|
||||
}
|
||||
|
||||
}
|
||||
private void LoadList() => dataGridViewData.DataSource = _patientRepository.ReadPatients();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridViewData.DataSource = _patientRepository.ReadPatients();
|
||||
dataGridViewData.Columns["Id"].Visible = false;
|
||||
dataGridViewData.Columns["FullName"].Visible = false;
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace ProjectPolyclinic.Forms
|
||||
_professionalDevelopmentRepository = professionalDevelopmentRepository ??
|
||||
throw new ArgumentNullException(nameof(professionalDevelopmentRepository));
|
||||
comboBoxDoctor.DataSource = doctorRepository.ReadDoctors();
|
||||
comboBoxDoctor.DisplayMember = "FirstName";
|
||||
comboBoxDoctor.DisplayMember = "FullName";
|
||||
comboBoxDoctor.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,13 @@ namespace ProjectPolyclinic.Forms
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridViewData.DataSource = _professionalDevelopmentRepository.ReadProfessionalDevelopment();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridViewData.DataSource = _professionalDevelopmentRepository.ReadProfessionalDevelopment();
|
||||
dataGridViewData.Columns["Id"].Visible = false;
|
||||
dataGridViewData.Columns["ProfessionalDevelopmentTime"].DefaultCellStyle.Format =
|
||||
"dd.MM.yyyy";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using ProjectPolyclinic.Entities;
|
||||
using ProjectPolyclinic.Entities.Enums;
|
||||
using ProjectPolyclinic.Repositories;
|
||||
using ProjectPolyclinic.Repositories.Implementations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -22,10 +23,10 @@ namespace ProjectPolyclinic.Forms
|
||||
_visitingRepository = visitingRepository ?? throw new ArgumentNullException(nameof(visitingRepository));
|
||||
comboBoxDoctor.DataSource =
|
||||
doctorRepository.ReadDoctors();
|
||||
comboBoxDoctor.DisplayMember = "FirstName";
|
||||
comboBoxDoctor.DisplayMember = "FullName";
|
||||
comboBoxDoctor.ValueMember = "Id";
|
||||
comboBoxPatient.DataSource = patientRepository.ReadPatients();
|
||||
comboBoxPatient.DisplayMember = "FirstName";
|
||||
comboBoxPatient.DisplayMember = "FullName";
|
||||
comboBoxPatient.ValueMember = "Id";
|
||||
foreach (var elem in Enum.GetValues(typeof(DiagnosisName)))
|
||||
{
|
||||
@ -34,6 +35,7 @@ namespace ProjectPolyclinic.Forms
|
||||
ColumnMedicines.DataSource = medicationRepository.ReadMedicines();
|
||||
ColumnMedicines.DisplayMember = "MedicinesType";
|
||||
ColumnMedicines.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
@ -81,8 +83,9 @@ namespace ProjectPolyclinic.Forms
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(Medicines_Visiting.CreateElement(0,
|
||||
Convert.ToInt32(row.Cells["ColumnMedicines"].Value),
|
||||
|
||||
list.Add(Medicines_Visiting.CreateElement(Convert.ToInt32(row.Cells["ColumnMedicines"].Value),
|
||||
0,
|
||||
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||
}
|
||||
return list;
|
||||
|
@ -22,7 +22,7 @@ namespace ProjectPolyclinic.Forms
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
comboBoxDoctor.DataSource = doctorRepository.ReadDoctors();
|
||||
comboBoxDoctor.DisplayMember = "FirstName";
|
||||
comboBoxDoctor.DisplayMember = "FullName";
|
||||
comboBoxDoctor.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
@ -76,7 +76,14 @@ MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private void LoadList() => dataGridViewData.DataSource = _visitingRepository.ReadVisiting();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridViewData.DataSource = _visitingRepository.ReadVisiting();
|
||||
dataGridViewData.Columns["Id"].Visible = false;
|
||||
dataGridViewData.Columns["VisitingTime"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
|
@ -12,11 +12,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectPolyclinic.Repositories.Implementations
|
||||
{
|
||||
public class ProfessionalDevelopmentRepository:IProfessionalDevelopmentRepository
|
||||
public class ProfessionalDevelopmentRepository : IProfessionalDevelopmentRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<ProfessionalDevelopmentRepository> _logger;
|
||||
public ProfessionalDevelopmentRepository(IConnectionString connectionString,ILogger<ProfessionalDevelopmentRepository> logger)
|
||||
public ProfessionalDevelopmentRepository(IConnectionString connectionString, ILogger<ProfessionalDevelopmentRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
@ -45,7 +45,7 @@ VALUES (@DoctorId, @ProfessionalDevelopmentTime)";
|
||||
|
||||
public IEnumerable<ProfessionalDevelopment> ReadProfessionalDevelopment(DateTime? dateForm = null, DateTime? dateTo = null, int? doctorId = null, int? Id = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
/*_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
@ -58,10 +58,29 @@ VALUES (@DoctorId, @ProfessionalDevelopmentTime)";
|
||||
return professionalDevelopments;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}*/
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT pd.*, CONCAT(d.First_Name, ' ', d.Last_Name) as DoctorName
|
||||
FROM ProfessionalDevelopments pd
|
||||
LEFT JOIN Doctors d ON d.Id = pd.DoctorId";
|
||||
var professionalDevelopments =
|
||||
connection.Query<ProfessionalDevelopment>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(professionalDevelopments));
|
||||
return professionalDevelopments;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Dapper;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
@ -81,7 +82,7 @@ WHERE Id=@id";
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Visiting> ReadVisiting(DateTime? dateForm = null, DateTime? dateTo = null, int? patientId = null, int? doctorId = null,int ? visitingId = null)
|
||||
/*public IEnumerable<Visiting> ReadVisiting(DateTime? dateForm = null, DateTime? dateTo = null, int? patientId = null, int? doctorId = null,int ? visitingId = null)
|
||||
{
|
||||
/*_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
@ -99,7 +100,7 @@ WHERE Id=@id";
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}*/
|
||||
}
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
@ -121,6 +122,95 @@ WHERE Id=@id";
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}*/
|
||||
|
||||
//работает но не выводит список медикаментов
|
||||
/*public IEnumerable<Visiting> ReadVisiting(DateTime? dateForm = null, DateTime? dateTo = null, int? patientId = null, int? doctorId = null, int? visitingId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT v.*,
|
||||
CONCAT(d.First_Name, ' ', d.Last_Name) as DoctorName,
|
||||
CONCAT(p.First_Name, ' ', p.Last_Name) as PatientName,
|
||||
mv.MedicinesId,
|
||||
mv.Count
|
||||
FROM Visitings v
|
||||
LEFT JOIN Doctors d ON d.Id = v.DoctorId
|
||||
LEFT JOIN Patients p ON p.Id = v.PatientId
|
||||
LEFT JOIN Medicines_Visiting mv ON v.Id = mv.VisitingId";
|
||||
|
||||
var visitings = connection.Query<TempMedicines_Visiting>(querySelect);
|
||||
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(visitings));
|
||||
|
||||
return visitings.GroupBy(x => x.Id, y => y,
|
||||
(key, value) => Visiting.CreateOperation(value.First(),
|
||||
value.Select(z => Medicines_Visiting.CreateElement(z.MedicinesId, z.VisitingId, z.Count)))).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}*/
|
||||
//постоянно выводит none в названии таблеток
|
||||
public IEnumerable<Visiting> ReadVisiting(DateTime? dateForm = null, DateTime? dateTo = null, int? patientId = null, int? doctorId = null, int? visitingId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT v.*,
|
||||
CONCAT(d.First_Name, ' ', d.Last_Name) as DoctorName,
|
||||
CONCAT(p.First_Name, ' ', p.Last_Name) as PatientName,
|
||||
mv.MedicinesId,
|
||||
mv.Count,
|
||||
m.MedicinesType as MedicinesType
|
||||
FROM Visitings v
|
||||
LEFT JOIN Doctors d ON d.Id = v.DoctorId
|
||||
LEFT JOIN Patients p ON p.Id = v.PatientId
|
||||
LEFT JOIN Medicines_Visiting mv ON v.Id = mv.VisitingId
|
||||
LEFT JOIN Medicines m ON m.Id = mv.MedicinesId ";
|
||||
|
||||
|
||||
var visitingDict = new Dictionary<int, List<Medicines_Visiting>>();
|
||||
var visitings = connection.Query<Visiting, Medicines_Visiting, Visiting>(querySelect,
|
||||
(visiting, medicine) =>
|
||||
{
|
||||
if (!visitingDict.TryGetValue(visiting.Id, out var medicines))
|
||||
{
|
||||
medicines = [];
|
||||
visitingDict.Add(visiting.Id, medicines);
|
||||
}
|
||||
|
||||
medicines.Add(medicine);
|
||||
|
||||
return visiting;
|
||||
}, splitOn: "MedicinesId");//, param: new { dateForm, dateTo, patientId, doctorId, visitingId } зачем-то убрали
|
||||
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(visitings));
|
||||
|
||||
|
||||
return visitingDict.Select(x =>
|
||||
{
|
||||
var v = visitings.First(y => y.Id == x.Key);
|
||||
v.SetMedicines_Visiting(x.Value);
|
||||
return v;
|
||||
|
||||
|
||||
}).ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user