Ejemplo n.º 1
0
        public IEnumerable <GeneralObservation> GetGerneralObservationList(int Mrn)
        {
            SqlDataReader reader = null;


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

            //Replace @Mrn with the requested patient's MRN

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

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

            query = query.Replace("@Mrn", Convert.ToString(Mrn));
            using (SqlCommand command = new SqlCommand(query, connection))
            {
                // Assign the SQL query and connection details to the reader
                reader = command.ExecuteReader();

                List <GeneralObservation> qresults = new List <GeneralObservation>();

                // Read the data from the server to the List of Falls Risk forms "qresults"
                // row by row
                while (reader.Read())
                {
                    GeneralObservation qr = new GeneralObservation();
                    qr.Mrn                       = reader["MRN"].ToString();
                    qr.DateOfScreening           = reader["DateAndTimeOfScreening"].ToString();
                    qr.O2Lpm                     = reader["O2Lpm"].ToString();
                    qr.oxygenDeviceMode          = reader["oxygenDeviceMode"].ToString();
                    qr.Sp02                      = Convert.ToInt32(reader["Sp02"].ToString());
                    qr.bloodPressureLow          = Convert.ToInt32(reader["bloodPressureLow"].ToString());
                    qr.bloodPressureHigh         = Convert.ToInt32(reader["bloodPressureHigh"].ToString());
                    qr.heartRate                 = Convert.ToInt32(reader["heartRate"].ToString());
                    qr.GeneralObservationNurseID = reader["NurseID"].ToString();
                    qresults.Add(qr);
                }

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

                return(qresults);
            }
        }
Ejemplo n.º 2
0
        public bool PostGeneralObservation(GeneralObservation 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 PatientGeneralObservation( MRN, DateAndTimeOfScreening , O2Lpm, oxygenDeviceMode, Sp02, bloodPressureLow, bloodPressureHigh, heartRate, GeneralObservationNurseID) VALUES (@Mrn, '@DateOfScreening',@O2Lpm,@oxygenDeviceMode,@Sp02,@bloodPressureLow,@bloodPressureHigh,@heartRate,@GeneralObservationNurseID);";

                //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("@O2Lpm", form.O2Lpm)
                        .Replace("@oxygenDeviceMode", form.oxygenDeviceMode)
                        .Replace("@Sp02", Convert.ToString(form.Sp02))
                        .Replace("@bloodPressureLow", Convert.ToString(form.bloodPressureLow))
                        .Replace("@bloodPressureHigh", Convert.ToString(form.bloodPressureHigh))
                        .Replace("@GeneralObservationNurseID", Convert.ToString(form.GeneralObservationNurseID));

                // 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);
                }
            }
        }
Ejemplo n.º 3
0
        public GeneralObservation 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 PatientGeneralObservation 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
                    GeneralObservation qresult = new GeneralObservation();



                    while (reader.Read())
                    {
                        qresult.Mrn              = reader["MRN"].ToString();
                        qresult.DateOfScreening  = reader["DateAndTimeOfScreening"].ToString();
                        qresult.O2Lpm            = reader["O2Lpm"].ToString();
                        qresult.oxygenDeviceMode = reader["oxygenDeviceMode"].ToString();

                        qresult.Sp02                      = Convert.ToInt32(reader["Sp02"].ToString());
                        qresult.bloodPressureLow          = Convert.ToInt32(reader["bloodPressureLow"].ToString());
                        qresult.bloodPressureHigh         = Convert.ToInt32(reader["bloodPressureHigh"].ToString());
                        qresult.heartRate                 = Convert.ToInt32(reader["heartRate"].ToString());
                        qresult.GeneralObservationNurseID = 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 PatientGeneralObservation 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
                    GeneralObservation qresult = new GeneralObservation();

                    // Read the data from the server to qresults
                    while (reader.Read())
                    {
                        qresult.Mrn                       = reader["MRN"].ToString();
                        qresult.DateOfScreening           = reader["DateAndTimeOfScreening"].ToString();
                        qresult.O2Lpm                     = reader["O2Lpm"].ToString();
                        qresult.oxygenDeviceMode          = reader["oxygenDeviceMode"].ToString();
                        qresult.Sp02                      = Convert.ToInt32(reader["Sp02"].ToString());
                        qresult.bloodPressureLow          = Convert.ToInt32(reader["bloodPressureLow"].ToString());
                        qresult.bloodPressureHigh         = Convert.ToInt32(reader["bloodPressureHigh"].ToString());
                        qresult.heartRate                 = Convert.ToInt32(reader["heartRate"].ToString());
                        qresult.GeneralObservationNurseID = reader["NurseID"].ToString();
                    }
                    connection.Close(); // Close the connection to the server

                    return(qresult);
                }
            }
        }