Esempio n. 1
0
 public HomeVisitHistory GetHomeVisitHistoryById(int homeVisitHistoryId)
 {
     try
     {
         var query      = "SELECT * FROM \"HomeVisitHistoryTable\" WHERE \"HomeVisitHistoryId\" = @HomeVisitHistoryId";
         var parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@HomeVisitHistoryId", homeVisitHistoryId)
         };
         var res = PostgreSQLHelper_OnlineSystem.ExecuteParamerizedSelectCommand(query, CommandType.Text,
                                                                                 parameters.ToArray());
         if (res.Rows.Count == 0)
         {
             return(null);
         }
         return(new HomeVisitHistory()
         {
             Policlinic = GetPoliclinicById(res.Rows[0].Field <int>("PoliclinicId")),
             Date = res.Rows[0].Field <DateTime>("Date"),
             Patient = GetPatientById(res.Rows[0].Field <int>("PatientId")),
             HomeVisitHistoryId = res.Rows[0].Field <int>("HomeVisitHistoryId")
         });
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 2
0
 public VisitHistory GetVisitHistoryById(int visitHistoryId)
 {
     try
     {
         var query      = "SELECT * FROM \"VisitHistoryTable\" WHERE \"VisitHistoryId\" = @VisitHistoryId";
         var parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@VisitHistoryId", visitHistoryId)
         };
         var results = PostgreSQLHelper_OnlineSystem.ExecuteParamerizedSelectCommand(query, CommandType.Text,
                                                                                     parameters.ToArray());
         if (results.Rows.Count == 0)
         {
             return(null);
         }
         return(new VisitHistory()
         {
             AvailableTime = GetAvailableTimeById(results.Rows[0].Field <int>("AvailableTimeId")),
             Doctor = GetDoctorById(results.Rows[0].Field <int>("DoctorId")),
             Patient = GetPatientById(results.Rows[0].Field <int>("PatientId")),
             VisitHistoryId = results.Rows[0].Field <int>("VisitHistoryId")
         });
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 3
0
 public List <HomeVisitHistory> GetAllHomeVisitHistoriesByPatientId(int patientId)
 {
     try
     {
         var query      = "SELECT * FROM \"HomeVisitHistoryTable\" WHERE \"PatientId\" = @PatientId";
         var parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@PatientId", patientId)
         };
         var results = PostgreSQLHelper_OnlineSystem.ExecuteParamerizedSelectCommand(query, CommandType.Text,
                                                                                     parameters.ToArray());
         var toReturn = new List <HomeVisitHistory>();
         for (var i = 0; i < results.Rows.Count; i++)
         {
             toReturn.Add(new HomeVisitHistory()
             {
                 Policlinic         = GetPoliclinicById(results.Rows[i].Field <int>("PoliclinicId")),
                 Date               = results.Rows[i].Field <DateTime>("Date"),
                 Patient            = GetPatientById(results.Rows[i].Field <int>("PatientId")),
                 HomeVisitHistoryId = results.Rows[i].Field <int>("HomeVisitHistoryId")
             });
         }
         return(toReturn);
     }
     catch (Exception)
     {
         return(new List <HomeVisitHistory>());
     }
 }
Esempio n. 4
0
 public int AddHomeVisitHistory(HomeVisitHistory history)
 {
     try
     {
         var query      = "INSERT INTO \"HomeVisitHistoryTable\" VALUES(default, @PatientId, @Date, @PoliclinicId) RETURNING \"HomeVisitHistoryId\"";
         var parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@PatientId", IsPatientExists(history.Patient)),
             new NpgsqlParameter("@Date", history.Date),
             new NpgsqlParameter("@PoliclinicId", history.Policlinic.PoliclinicId)
         };
         var res = PostgreSQLHelper_OnlineSystem.ExecuteParamerizedSelectCommand(query, CommandType.Text, parameters.ToArray());
         return(res.Rows.Count == 0 ? -1 : res.Rows[0].Field <int>("HomeVisitHistoryId"));
     }
     catch (Exception exception)
     {
         return(-1);
     }
 }
Esempio n. 5
0
 public int AddOrder(int patientId, int doctorId, int availableTimeId)
 {
     try
     {
         const string query      = "INSERT INTO \"VisitHistoryTable\" VALUES(default, @PatientId, @DoctorId, @AvailableTimeId) RETURNING \"VisitHistoryId\"";
         var          parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@PatientId", patientId),
             new NpgsqlParameter("@DoctorId", doctorId),
             new NpgsqlParameter("@AvailableTimeId", availableTimeId),
         };
         var res = PostgreSQLHelper_OnlineSystem.ExecuteParamerizedSelectCommand(query, CommandType.Text,
                                                                                 parameters.ToArray());
         return(res.Rows.Count != 0 ? res.Rows[0].Field <int>("VisitHistoryId") : -1);
     }
     catch (Exception exception)
     {
         return(-1);
     }
 }