public List <PatientDTO> GetPatientStatus(string idP) { List <PatientDTO> patientStatus = new List <PatientDTO>(); using (ConnectionString connectionString = new ConnectionString()) { try { connectionString.sqlConnection.Open(); Microsoft.Data.SqlClient.SqlCommand cmd = new Microsoft.Data.SqlClient.SqlCommand("sp_Doctor_GetMeasurements", connectionString.sqlConnection); cmd.Parameters.AddWithValue("@idP", idP); cmd.CommandType = CommandType.StoredProcedure; using (Microsoft.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { PatientDTO patientDTO = new PatientDTO { statusDTO = new StatusDTO { Date = reader.GetDateTime(0), INR = reader.GetDecimal(1) } }; patientStatus.Add(patientDTO); } } } } catch (Exception exception) { if (exception is InvalidCastException || exception is Microsoft.Data.SqlClient.SqlException) { Console.WriteLine("Error source: " + exception); throw; } } } return(patientStatus); }
public PatientDTO GetPatientAdditionalInfo(string idP) { PatientDTO patientDTO = new PatientDTO(); using (ConnectionString connectionString = new ConnectionString()) { try { connectionString.sqlConnection.Open(); Microsoft.Data.SqlClient.SqlCommand cmd = new Microsoft.Data.SqlClient.SqlCommand("sp_Doctor_GetPatientInfo", connectionString.sqlConnection); cmd.Parameters.AddWithValue("@idP", idP); cmd.CommandType = CommandType.StoredProcedure; using (Microsoft.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { patientDTO = new PatientDTO { Firstname = reader.GetString(0), Lastname = reader.GetString(1), Phonenumber = reader.GetString(2), Email = reader.GetString(3), DateOfBirth = reader.GetDateTime(4).ToString("dd-MM-yyyy") }; } } } } catch (Exception exception) { if (exception is InvalidCastException || exception is Microsoft.Data.SqlClient.SqlException) { Console.WriteLine("Error source: " + exception); throw; } } } return(patientDTO); }