示例#1
0
        public bool PostFallsRisk(FallsRisk form)
        {
            string query = "";

            if (form == null) //Check if the form contains any data
            {
                return(false);
            }
            else
            {
                // The SQL query to be sent to the server
                query = "INSERT INTO PatientFallsRisk( MRN, DateAndTimeOfScreening , HistoryOfFalls, " +
                        "MentalStatus, Vision, ToiletingScore, TransferScore, MobilityScore, TotalTSMS, TotalScore, " +
                        "NurseID) VALUES (@Mrn, '@DateOfScreening', @HistoryOfFalls, @MentalStatus, @Vision, " +
                        "@ToiletingScore, @TransferScore, @MobilityScore, @TotalTSMS, @TotalScore, @FallsRiskNurseID);";

                //Replace the values in the SQL query string with the data to be added to the server
                query = query.Replace("@Mrn", form.Mrn)
                        .Replace("@DateOfScreening", form.DateOfScreening)
                        .Replace("@HistoryOfFalls", Convert.ToString(form.HistoryOfFalls))
                        .Replace("@MentalStatus", Convert.ToString(form.MentalStatus))
                        .Replace("@Vision", Convert.ToString(form.Vision))
                        .Replace("@ToiletingScore", Convert.ToString(form.ToiletingScore))
                        .Replace("@TransferScore", Convert.ToString(form.TransferScore))
                        .Replace("@MobilityScore", Convert.ToString(form.MobilityScore))
                        .Replace("@TotalTSMS", Convert.ToString(form.TotalTSMS))
                        .Replace("@TotalScore", Convert.ToString(form.TotalScore))
                        .Replace("@FallsRiskNurseID", form.FallsRiskNurseID);

                // Establish connection with the SQL server
                SqlConnection connection = new SqlConnection(ConnectionString);

                try {
                    connection.Open();  // Open the connection to the server

                    // Create the command to be sent to the server with the query and connection info
                    SqlCommand command = new SqlCommand(query, connection);
                    command.ExecuteNonQuery(); // Execute the command on the server
                    command.Dispose();
                    connection.Close();        // Close the connection to the server
                    return(true);
                } catch (Exception) {
                    // If the command fails return false
                    return(false);
                }
            }
        }
示例#2
0
        public IEnumerable <FallsRisk> GetFallsRiskList(int Mrn)
        {
            SqlDataReader reader = null;

            // The SQL query to be sent to the server
            string query = "SELECT * FROM PatientFallsRisk WHERE MRN = '@Mrn'";

            //Replace @Mrn with the requested patient's MRN
            query = query.Replace("@Mrn", Convert.ToString(Mrn));

            // Establish connection with the SQL server
            SqlConnection connection = new SqlConnection(ConnectionString);

            connection.Open();  // Open the connection to the server

            using (SqlCommand command = new SqlCommand(query, connection)) {
                // Assign the SQL query and connection details to the reader
                reader = command.ExecuteReader();

                // Create a new list of Falls Risk forms that will contain data from server
                List <FallsRisk> qresults = new List <FallsRisk> ();

                // Read the data from the server to the List of Falls Risk forms "qresults"
                // row by row
                while (reader.Read())
                {
                    FallsRisk qr = new FallsRisk();
                    qr.Mrn              = reader["MRN"].ToString();
                    qr.DateOfScreening  = reader["DateAndTimeOfScreening"].ToString();
                    qr.HistoryOfFalls   = Convert.ToInt32(reader["HistoryOfFalls"].ToString());
                    qr.MentalStatus     = Convert.ToInt32(reader["MentalStatus"].ToString());
                    qr.Vision           = Convert.ToInt32(reader["Vision"].ToString());
                    qr.ToiletingScore   = Convert.ToInt32(reader["ToiletingScore"].ToString());
                    qr.TransferScore    = Convert.ToInt32(reader["TransferScore"].ToString());
                    qr.MobilityScore    = Convert.ToInt32(reader["MobilityScore"].ToString());
                    qr.TotalTSMS        = Convert.ToInt32(reader["TotalTSMS"].ToString());
                    qr.TotalScore       = Convert.ToInt32(reader["TotalScore"].ToString());
                    qr.FallsRiskNurseID = reader["NurseID"].ToString();
                    qresults.Add(qr);
                }
                connection.Close();  // Close the connection to the server

                return(qresults);
            }
        }
示例#3
0
        public FallsRisk Get(int Mrn, string date)
        {
            string        query  = "";
            SqlDataReader reader = null;

            // Establish connection with the SQL server
            SqlConnection connection = new SqlConnection(ConnectionString);

            connection.Open();  // Open the connection to the server

            // Return single Falls Risk form for specific date and time
            if (date != "latest")
            {
                // The SQL query to be sent to the server
                query = "SELECT * FROM PatientFallsRisk WHERE MRN = '@Mrn' AND DateAndTimeOfScreening = '@date'";

                //Replace @Mrn with the requested patient's MRN
                query = query.Replace("@Mrn", Convert.ToString(Mrn));

                //Replace @date with the requested Falls Risk Screening Date
                query = query.Replace("@date", Convert.ToString(date));

                using (SqlCommand command = new SqlCommand(query, connection)) {
                    // Assign the SQL query and connection details to the reader
                    reader = command.ExecuteReader();

                    // Create a new patient that will contain data from server
                    FallsRisk qresult = new FallsRisk();

                    // Read the data from the server to qresults
                    while (reader.Read())
                    {
                        qresult.Mrn              = reader["MRN"].ToString();
                        qresult.DateOfScreening  = reader["DateAndTimeOfScreening"].ToString();
                        qresult.HistoryOfFalls   = Convert.ToInt32(reader["HistoryOfFalls"].ToString());
                        qresult.MentalStatus     = Convert.ToInt32(reader["MentalStatus"].ToString());
                        qresult.Vision           = Convert.ToInt32(reader["Vision"].ToString());
                        qresult.ToiletingScore   = Convert.ToInt32(reader["ToiletingScore"].ToString());
                        qresult.TransferScore    = Convert.ToInt32(reader["TransferScore"].ToString());
                        qresult.MobilityScore    = Convert.ToInt32(reader["MobilityScore"].ToString());
                        qresult.TotalTSMS        = Convert.ToInt32(reader["TotalTSMS"].ToString());
                        qresult.TotalScore       = Convert.ToInt32(reader["TotalScore"].ToString());
                        qresult.FallsRiskNurseID = reader["NurseID"].ToString();
                    }
                    connection.Close();  // Close the connection to the server

                    return(qresult);
                }
            }
            else
            {
                // The SQL query to be sent to the server
                query = "SELECT * FROM PatientFallsRisk WHERE DateAndTimeOfScreening = (SELECT MAX(DateAndTimeOfScreening) " +
                        "FROM PatientFallsRisk WHERE MRN = '@Mrn')";

                //Replace @Mrn with the requested patient's MRN
                query = query.Replace("@Mrn", Convert.ToString(Mrn));

                //Replace @date with the requested Falls Risk Screening Date
                query = query.Replace("@date", Convert.ToString(date));

                using (SqlCommand command = new SqlCommand(query, connection)) {
                    // Assign the SQL query and connection details to the reader
                    reader = command.ExecuteReader();

                    // Create a new patient that will contain data from server
                    FallsRisk qresult = new FallsRisk();

                    // Read the data from the server to qresults
                    while (reader.Read())
                    {
                        qresult.Mrn              = reader["MRN"].ToString();
                        qresult.DateOfScreening  = reader["DateAndTimeOfScreening"].ToString();
                        qresult.HistoryOfFalls   = Convert.ToInt32(reader["HistoryOfFalls"].ToString());
                        qresult.MentalStatus     = Convert.ToInt32(reader["MentalStatus"].ToString());
                        qresult.Vision           = Convert.ToInt32(reader["Vision"].ToString());
                        qresult.ToiletingScore   = Convert.ToInt32(reader["ToiletingScore"].ToString());
                        qresult.TransferScore    = Convert.ToInt32(reader["TransferScore"].ToString());
                        qresult.MobilityScore    = Convert.ToInt32(reader["MobilityScore"].ToString());
                        qresult.TotalTSMS        = Convert.ToInt32(reader["TotalTSMS"].ToString());
                        qresult.TotalScore       = Convert.ToInt32(reader["TotalScore"].ToString());
                        qresult.FallsRiskNurseID = reader["NurseID"].ToString();
                    }
                    connection.Close();  // Close the connection to the server

                    return(qresult);
                }
            }
        }