예제 #1
0
        private bool GetPatientBool(string connectionString, string commandString, string facility, string patientId, double episodeNumber)
        {
            string stringResult = "";

            using (OdbcConnection connection = new OdbcConnection(connectionString))
            {
                OdbcCommand command = new OdbcCommand(commandString, connection);
                command.Parameters.Add(new OdbcParameter("FACILITY", facility));
                command.Parameters.Add(new OdbcParameter("PATID", patientId));
                command.Parameters.Add(new OdbcParameter("EPISODENUMBER", episodeNumber));

                try
                {
                    connection.Open();
                    object obj = command.ExecuteScalar();
                    if (obj != null && !DBNull.Value.Equals(obj))
                    {
                        stringResult = (string)obj;
                    }
                }
                catch (OdbcException ex)
                {
                    logger.Error(ex, "GetPatientBool: Could not connect to ODBC data source. See error message. Data Source: {systemDsn}. Error: {errorMessage}", connectionString, ex.Message);
                    throw;
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "GetPatientBool: An unexpected error occurred. Error Type: {errorType}. Error: {errorMessage}", ex.GetType(), ex.Message);
                    throw;
                }
            }

            return(RoseConvert.ToBool(stringResult));
        }
예제 #2
0
 private bool GetBoolValue(OdbcDataReader reader, int column)
 {
     try
     {
         if (reader.IsDBNull(column))
         {
             logger.Debug("Reader column {column} is DbNull. Returning default value.", column);
             return(false);
         }
         else
         {
             return(RoseConvert.ToBool(reader.GetString(column)));
         }
     }
     catch (Exception ex)
     {
         logger.Error("An unexpected error occurred while processing reader column {column}. Error: {errorMessage}", column, ex.Message);
         throw;
     }
 }
예제 #3
0
        private DateTime GetPatientDateTime(string connectionString, string commandString, string facility, string patientId)
        {
            string stringResult = "";

            using (OdbcConnection connection = new OdbcConnection(connectionString))
            {
                OdbcCommand command = new OdbcCommand(commandString, connection);
                command.Parameters.Add(new OdbcParameter("FACILITY", facility));
                command.Parameters.Add(new OdbcParameter("PATID", patientId));

                try
                {
                    connection.Open();
                    object obj = command.ExecuteScalar();
                    if (obj != null && !DBNull.Value.Equals(obj))
                    {
                        try
                        {
                            return((DateTime)obj);
                        }
                        catch (InvalidCastException)
                        {
                            stringResult = (string)obj;
                        }
                    }
                }
                catch (OdbcException ex)
                {
                    logger.Error(ex, "GetPatientDateTime: Could not connect to ODBC data source. See error message. Data Source: {systemDsn}. Error: {errorMessage}", connectionString, ex.Message);
                    throw;
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "GetPatientDateTime: An unexpected error occurred. Error Type: {errorType}. Error: {errorMessage}", ex.GetType(), ex.Message);
                    throw;
                }
            }
            logger.Debug("Retrieved date string {dateString} for Facility {facility} and Patient Id {patientId}", stringResult, facility, patientId);
            return(RoseConvert.ToDateTime(stringResult));
        }
예제 #4
0
        private int IMCANSGetRating(string fieldValue)
        {
            try
            {
                switch (fieldValue)
                {
                case "0":
                case "1":
                case "2":
                case "3":
                    return(RoseConvert.ToInt(fieldValue));

                default:
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error occurred getting IMCANS rating from Field Value {fieldValue}. Error: {errorMessage}.", fieldValue, ex.Message);
                throw;
            }
        }