Улучшайзинги1
This commit is contained in:
parent
e8d4571560
commit
2fc3852943
@ -1,6 +1,7 @@
|
||||
using RegistrationPatientsPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,11 +11,15 @@ namespace RegistrationPatientsPolyclinic.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 => $"{Last_Name} {First_Name}";
|
||||
|
||||
[DisplayName("Должность")]
|
||||
public DoctorPost DoctorPost { get; private set; } // объявляется свойство DoctorPost, которое имеет тип DoctorPost
|
||||
|
||||
public static Doctor CreateEntity(int id, string first_Name, string last_Name, DoctorPost doctorPost)
|
||||
|
@ -1,23 +1,32 @@
|
||||
using RegistrationPatientsPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RegistrationPatientsPolyclinic.Entities;
|
||||
|
||||
public class DoctorPayments // Проверка класса
|
||||
public class DoctorPayments
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int IdDoctor { get; private set; }
|
||||
|
||||
[DisplayName("Доктор")]
|
||||
public string DoctorName { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Месяц")]
|
||||
public string Month { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Количество пациентов")]
|
||||
public int Count_Patient { get; private set; }
|
||||
|
||||
|
||||
[DisplayName("Дата оплаты")]
|
||||
public DateTime DoctorPaymentData { get; private set; }
|
||||
[DisplayName("Оплата")]
|
||||
public int Payment { get; private set; }
|
||||
|
||||
public static DoctorPayments CreateElement(int id, int idDoctor, string month, int count_patient, int payment)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using RegistrationPatientsPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -11,10 +12,13 @@ public class Drug // Наподобие Feed
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Название лекарства")]
|
||||
public DrugName DrugName { get; private set; }
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Grams { get; private set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
|
||||
public static Drug CreateElement(int id, DrugName name, int grams, string description)
|
||||
|
@ -13,6 +13,7 @@ public class DrugMedicalHistory // Тоже самое что FeedFeedRepleshme
|
||||
|
||||
public int DrugId { get; private set; }
|
||||
|
||||
public string DrugName { get; private set; } = string.Empty;
|
||||
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using RegistrationPatientsPolyclinic.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -11,14 +12,28 @@ public class MedicalHistory // сущность пополнения, напо
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int PatientId { get; private set; }
|
||||
|
||||
[DisplayName("Имя пациента")]
|
||||
public string PatientName { get; private set; } = string.Empty;
|
||||
|
||||
[Browsable(false)]
|
||||
public int DoctorId { get; private set; }
|
||||
|
||||
[DisplayName("Имя доктора")]
|
||||
public string DoctorName { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата приема")]
|
||||
public DateTime VisitDate { get; private set; }
|
||||
|
||||
[DisplayName("Таблетки")]
|
||||
public string Drug => DrugMedicalHistory != null ?
|
||||
string.Join(", ", DrugMedicalHistory.Select(x => $"{x.Id} {x.Description}")) :
|
||||
string.Empty;
|
||||
|
||||
|
||||
[Browsable(false)]
|
||||
public IEnumerable<DrugMedicalHistory> DrugMedicalHistory { get; set; } = [];
|
||||
|
||||
public static MedicalHistory CreateEntity(int id, int patientId, int doctorId,
|
||||
@ -33,7 +48,7 @@ public class MedicalHistory // сущность пополнения, напо
|
||||
DrugMedicalHistory = drugMedicalHistory
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
public static MedicalHistory CreateOpeartion(TempDrugMedicalHistory tempDrugMedicalHistory, IEnumerable<DrugMedicalHistory> drugMedicalHistories)
|
||||
{
|
||||
return new MedicalHistory
|
||||
@ -45,4 +60,12 @@ public class MedicalHistory // сущность пополнения, напо
|
||||
DrugMedicalHistory = drugMedicalHistories
|
||||
};
|
||||
}
|
||||
*/
|
||||
public void SetProductMaterial(IEnumerable<DrugMedicalHistory> drugMedicalHistory)
|
||||
{
|
||||
if (drugMedicalHistory != null && drugMedicalHistory.Any())
|
||||
{
|
||||
DrugMedicalHistory = drugMedicalHistory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,15 +11,17 @@ public class Patient
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string First_Name { get; private set; } = string .Empty; // string.Empty - означает, что по умолчанию это свойство будет содержать пустую строку, а не null(то же самое "")
|
||||
[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; }
|
||||
|
||||
|
||||
// ТУТ СДЕЛАЕМ СТАТИСТИЧЕСКИЙ МЕТОД, который будет отвечать за создание объекта
|
||||
|
||||
public static Patient CreateEntity(int id, string first_Name, string last_Name, string contactNumber)
|
||||
{
|
||||
return new Patient
|
||||
|
@ -23,7 +23,7 @@ namespace RegistrationPatientsPolyclinic.Forms
|
||||
throw new ArgumentNullException(nameof(doctorPaymentsRepository));
|
||||
|
||||
comboBoxDoctor.DataSource = doctorRepository.ReadDoctors();
|
||||
comboBoxDoctor.DisplayMember = "Firts_Name";
|
||||
comboBoxDoctor.DisplayMember = "FullName";
|
||||
comboBoxDoctor.ValueMember = "Id";
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,12 @@ namespace RegistrationPatientsPolyclinic.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _doctorPaymentsRepository.ReadDoctorPayments();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _doctorPaymentsRepository.ReadDoctorPayments();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Month"].DefaultCellStyle.Format = "yyyy-dd";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,12 @@ namespace RegistrationPatientsPolyclinic.Forms
|
||||
}
|
||||
// отдельный метод который будет загружать в GridView
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _doctorRepository.ReadDoctors();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _doctorRepository.ReadDoctors();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["FullName"].Visible = false;
|
||||
}
|
||||
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id) // возвращает смог н извлечь или нет
|
||||
|
@ -29,7 +29,11 @@ namespace RegistrationPatientsPolyclinic.Forms
|
||||
}
|
||||
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _dragRepository.ReadDrug();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _dragRepository.ReadDrug();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
}
|
||||
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
|
@ -52,7 +52,12 @@ namespace RegistrationPatientsPolyclinic.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _medicalHistoryRepository.ReadMedicalHistory();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _medicalHistoryRepository.ReadMedicalHistory();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["VisitDate"].DefaultCellStyle.Format = "dd.MM.yyyy";
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -32,12 +32,12 @@ namespace RegistrationPatientsPolyclinic.Forms
|
||||
throw new ArgumentNullException(nameof(medicalHistoryRepository));
|
||||
|
||||
comboBoxPacient.DataSource = patientRepository.ReadPatient(); // передает набор всех пациентов
|
||||
comboBoxPacient.DisplayMember = "First_Name"; // отображение в combobox
|
||||
comboBoxPacient.DisplayMember = "FullName"; // отображение в combobox
|
||||
comboBoxPacient.ValueMember = "Id";
|
||||
|
||||
|
||||
comboBoxDoctor.DataSource = doctorRepository.ReadDoctors();
|
||||
comboBoxDoctor.DisplayMember = "First_Name";
|
||||
comboBoxDoctor.DisplayMember = "FullName";
|
||||
comboBoxDoctor.ValueMember = "Id";
|
||||
|
||||
ColumnDrug.DataSource = drugRepository.ReadDrug();
|
||||
|
@ -99,7 +99,12 @@ namespace RegistrationPatientsPolyclinic.Forms
|
||||
|
||||
// отдельный метод который будет загружать в GridView
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _pacientRepository.ReadPatient();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _pacientRepository.ReadPatient();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["FullName"].Visible = false;
|
||||
}
|
||||
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id) // возвращает смог н извлечь или нет
|
||||
|
@ -47,7 +47,9 @@ VALUES (@IdDoctor, @Month, @Count_Patient, @Payment)";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public IEnumerable<DoctorPayments> ReadDoctorPayments()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
@ -55,7 +57,10 @@ VALUES (@IdDoctor, @Month, @Count_Patient, @Payment)";
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM DoctorPayments";
|
||||
var querySelect = @"SELECT fa.*,
|
||||
CONCAT(e.Last_Name, ' ', e.First_Name) AS DoctorName
|
||||
FROM DoctorPayments fa
|
||||
LEFT JOIN Doctor e ON e.Id = fa.IdDoctor";
|
||||
var doctorPayments =
|
||||
connection.Query<DoctorPayments>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
@ -70,6 +75,7 @@ VALUES (@IdDoctor, @Month, @Count_Patient, @Payment)";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@ WHERE Id=@id";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public IEnumerable<MedicalHistory> ReadMedicalHistory(DateTime? dateForm = null, DateTime? dateTo = null, int? PatientId = null, int? DoctorId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
@ -111,8 +111,8 @@ WHERE Id=@id";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
public IEnumerable<MedicalHistory> ReadMedicalHistory(DateTime? dateForm = null, DateTime? dateTo = null, int? PatientId = null, int? DoctorId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
@ -120,44 +120,61 @@ WHERE Id=@id";
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM MedicalHistory";
|
||||
var medicalHistory =
|
||||
connection.Query<MedicalHistory>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(medicalHistory));
|
||||
return medicalHistory;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
//var querySelect = @"SELECT * FROM MedicalHistory";
|
||||
/* var querySelect = @"SELECT mh.*,
|
||||
CONCAT(p.LastName, ' ', p.FirstName) as PatientName,
|
||||
CONCAT(d.LastName, ' ', d.FirstName) as DoctorName,
|
||||
dmh.DrugId,
|
||||
dmh.Description
|
||||
dr.DrugName AS drugName
|
||||
FROM MedicalHistory mh
|
||||
LEFT JOIN Patient p on p.Id = mh.PatientId
|
||||
LEFT JOIN Doctor d on d.Id = mh.DoctorId
|
||||
INNER JOIN DrugMedicalHistory dmh ON dmh.MedicalHistoryId = mh.Id
|
||||
LEFT JOIN Drug dr on dr.Id = dmh.DrugId";*/
|
||||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public IEnumerable<TempDrugMedicalHistory> ReadMedicalHistory(DateTime? dateForm = null, DateTime? dateTo = null, int? PatientId = null, int? DoctorId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT mh.*, dmh.DrugId, dmh.Description
|
||||
var querySelect = @"SELECT mh.*,
|
||||
CONCAT(p.Last_Name, ' ', p.First_Name) as PatientName,
|
||||
CONCAT(d.Last_Name, ' ', d.First_Name) as DoctorName,
|
||||
dmh.Id AS Id, dmh.DrugId AS drugId, dmh.Description AS Description
|
||||
FROM MedicalHistory mh
|
||||
INNER JOIN DrugMedicalHistory dmh ON dmh.MedicalHistoryId = mh.Id";
|
||||
LEFT JOIN DrugMedicalHistory dmh ON dmh.MedicalHistoryId = mh.Id
|
||||
LEFT JOIN Patient p ON p.Id = mh.PatientId
|
||||
LEFT JOIN doctor d ON d.Id = mh.DoctorId
|
||||
";
|
||||
|
||||
var historyDict = new Dictionary<int, List<DrugMedicalHistory>>();
|
||||
var medicalHistory =
|
||||
connection.Query<TempDrugMedicalHistory>(querySelect);
|
||||
connection.Query<MedicalHistory, DrugMedicalHistory, MedicalHistory>(querySelect,
|
||||
(history, drugMedicalHistory) =>
|
||||
{
|
||||
if (!historyDict.TryGetValue(history.Id, out var drugs))
|
||||
{
|
||||
drugs = new List<DrugMedicalHistory>();
|
||||
historyDict.Add(history.Id, drugs);
|
||||
}
|
||||
if (drugMedicalHistory != null && drugMedicalHistory.Id > 0)
|
||||
{
|
||||
drugs.Add(DrugMedicalHistory.CreateEntity(drugMedicalHistory.Id, drugMedicalHistory.DrugId, drugMedicalHistory.Description));
|
||||
}
|
||||
return history;
|
||||
}, splitOn: "Id");//, param: new { dateForm, dateTo, DoctorId, PatientId});
|
||||
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(medicalHistory));
|
||||
return medicalHistory;
|
||||
return historyDict.Select(x =>
|
||||
{
|
||||
var mh = medicalHistory.First(y => y.Id == x.Key);
|
||||
mh.SetProductMaterial(x.Value);
|
||||
return mh;
|
||||
}).ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user