39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using MedicalDatabaseContracts;
|
|
using MedicalDatabaseContracts.Models;
|
|
using Microsoft.Extensions.Logging;
|
|
using Npgsql;
|
|
using System.Data;
|
|
|
|
namespace MedicalPostgresqlDatabase
|
|
{
|
|
public class VisitStorage : AbstractPostgresqlStorage<Visit>
|
|
{
|
|
public VisitStorage(ILogger<IStorage<Visit>> logger) : base(logger, "visits", "visit_id", "visits_id_seq") { }
|
|
|
|
protected override Visit CreateEntityFromReader(NpgsqlDataReader reader)
|
|
{
|
|
return new Visit
|
|
{
|
|
Id = Convert.ToInt32(reader.GetValue(PRIMARY_KEY_COLUMN_NAME)),
|
|
PatientId = Convert.ToInt32(reader.GetValue("patient_id")),
|
|
DoctorId = Convert.ToInt32(reader.GetValue("doctor_id")),
|
|
DiagnoseId = Convert.ToInt32(reader.GetValue("diagnose_id")),
|
|
Comment = Convert.ToString(reader.GetValue("comment")),
|
|
};
|
|
}
|
|
|
|
protected override Dictionary<string, string> GetEntityAttributesDictionary(Visit item)
|
|
{
|
|
var dict = new Dictionary<string, string>
|
|
{
|
|
{ PRIMARY_KEY_COLUMN_NAME, item.Id.ToString() },
|
|
{ "patient_id", item.PatientId.ToString() },
|
|
{ "doctor_id", item.DoctorId.ToString() },
|
|
{ "diagnose_id", item.DiagnoseId.ToString() },
|
|
{ "comment", item.Comment },
|
|
};
|
|
return dict;
|
|
}
|
|
}
|
|
}
|