private static RoutineCheck buildRoutineCheck(MySqlCommand cmd)
        {
            var routineCheck = new RoutineCheck();

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                int nurseIDOrdinal = reader.GetOrdinal("nurseID");
                int fnameOrdinal   = reader.GetOrdinal("fname");
                int lnameOrdinal   = reader.GetOrdinal("lname");
                int bloodPressureSystolicOrdinal  = reader.GetOrdinal("bloodPressureSystolic");
                int bloodPressureDiastolicOrdinal = reader.GetOrdinal("bloodPressureDiastolic");
                int bodyTempOrdinal = reader.GetOrdinal("bodyTemp");
                int pulseOrdinal    = reader.GetOrdinal("pulse");
                int weightOrdinal   = reader.GetOrdinal("weight");
                int symptomsOrdinal = reader.GetOrdinal("symptoms");

                while (reader.Read())
                {
                    routineCheck.Nurse.ID               = DbDefault.GetInt(reader, nurseIDOrdinal);
                    routineCheck.Nurse.Bio.FirstName    = DbDefault.GetString(reader, fnameOrdinal);
                    routineCheck.Nurse.Bio.LastName     = DbDefault.GetString(reader, lnameOrdinal);
                    routineCheck.BloodPressureSystolic  = DbDefault.GetInt(reader, bloodPressureSystolicOrdinal);
                    routineCheck.BloodPressureDiastolic = DbDefault.GetInt(reader, bloodPressureDiastolicOrdinal);
                    routineCheck.BodyTemp               = DbDefault.GetDouble(reader, bodyTempOrdinal);
                    routineCheck.Pulse    = DbDefault.GetInt(reader, pulseOrdinal);
                    routineCheck.Weight   = DbDefault.GetDouble(reader, weightOrdinal);
                    routineCheck.Symptoms = DbDefault.GetString(reader, symptomsOrdinal);
                }

                return(routineCheck);
            }
        }
Exemple #2
0
        public async Task AddCheckp(RoutineCheck checkup)
        {
            var qry =
                "insert into `routine_check`(aId, nId, date, systolicReading, diastolicBloodPressure, weight,  temp, pId, init_diagnosis) VALUES(@aid, @nid, @date, @systolicReading, @diastolicBloodPressure, @weight, @temp, @pId, @init); delete from `incomplete_appointments` where aId = @aID; insert into `complete_appointments` values(@aId);";
            var conn = DbConnection.GetConnection();
            await conn.OpenAsync();

            using (var command = new MySqlCommand(qry, conn))
            {
                var aId                    = checkup.Appointment.AppointmentId;
                var nId                    = checkup.Nurse.NurseId;
                var pId                    = checkup.Patient.Id;
                var date                   = checkup.Date;
                var systolicReading        = checkup.SystolicReading;
                var diastolicBloodPressure = checkup.DiastolicBloodPressure;
                var weight                 = checkup.Weight;
                var init                   = checkup.InitialDiagnosis;
                var temp                   = checkup.Temperature;

                command.Parameters.Add("@aid", (DbType)MySqlDbType.Int16).Value                     = aId;
                command.Parameters.Add("@nid", (DbType)MySqlDbType.Int16).Value                     = nId;
                command.Parameters.Add("@pId", (DbType)MySqlDbType.Int16).Value                     = pId;
                command.Parameters.Add("@date", (DbType)MySqlDbType.DateTime).Value                 = date;
                command.Parameters.Add("@systolicReading", (DbType)MySqlDbType.Double).Value        = systolicReading;
                command.Parameters.Add("@diastolicBloodPressure", (DbType)MySqlDbType.Double).Value =
                    diastolicBloodPressure;
                command.Parameters.Add("@weight", (DbType)MySqlDbType.Double).Value = weight;
                command.Parameters.Add("@init", (DbType)MySqlDbType.VarChar).Value  = init;
                command.Parameters.Add("@temp", (DbType)MySqlDbType.Double).Value   = temp;

                await command.ExecuteNonQueryAsync();
            }

            conn.Close();
        }
        private async void finishEdit(object sender, RoutedEventArgs e)
        {
            try
            {
                this.ring.IsActive = true;
                var patientDal = new PatientDAL();
                var nurseDal   = new NurseDAL();
                var appointDal = new AppointmentDAL();
                var vm         = new RoutineCheckupViewModel();
                var appnt      = await appointDal.GetAppointmentById(this.AppointmentID);

                var patient = await patientDal.GetPatientById(this.PatientId);

                var nurse = await nurseDal.GetNurseByNurseId(this.NurseId);

                var date = this.CheckupDate.Date.AddHours(this.CheckupTime.Hours).AddMinutes(this.CheckupTime.Minutes);
                var sys  = !string.IsNullOrWhiteSpace(this.SystolicReading.ToString())
                    ? this.SystolicReading
                    : throw new ArgumentException("The Systolic Reading cannot be empty.");
                var dbp = !string.IsNullOrWhiteSpace(this.DiastolicBloodPressure.ToString())
                    ? this.DiastolicBloodPressure
                    : throw new ArgumentException("The blood pressure cannot be empty.");
                var weght = !string.IsNullOrWhiteSpace(this.Weight.ToString())
                    ? this.Weight
                    : throw new ArgumentException("The weight cannot be empty");
                var tep = !string.IsNullOrWhiteSpace(this.Temperature.ToString())
                    ? this.Temperature
                    : throw new ArgumentException("The tmeperature cannot be empty");
                var diag = !string.IsNullOrWhiteSpace(this.InitialDiagnosis)
                    ? this.InitialDiagnosis
                    : throw new ArgumentException("The initial diaggnosis cannot be empty");
                var checkup = new RoutineCheck(appnt, nurse, patient, date, sys, dbp, weght, tep, diag);
                await vm.EditCheckup(checkup);

                this.Editing(false);
                this.ChangesMade = true;
            }
            catch (Exception ex)
            {
                this.ring.IsActive = false;
                this.error.Text    = ex.Message;
                await Task.Delay(4000);

                this.error.Text = "";
            }

            this.ring.IsActive = false;
        }
        public static List <RoutineCheck> GetPreviousReadings(int patientID)
        {
            List <RoutineCheck> checkResultList = new List <RoutineCheck>();
            string selectStatement = "SELECT visitTime, systolicBP, diastolicBP, bodyTemperature, pulse, symptomType "
                                     + "FROM visit LEFT JOIN Appointment ON visit.appointmentID = appointment.appointmentID "
                                     + "JOIN visit_symptom ON visit.visitID = visit_symptom.visitID "
                                     + "JOIN symptom ON visit_symptom.symptomID = symptom.symptomID "
                                     + "WHERE patientID = @patientID AND visitTime < GETDATE()";

            try
            {
                using (SqlConnection connection = DBConnection.GetConnection())
                {
                    connection.Open();
                    using (SqlCommand selectCommand = new SqlCommand(selectStatement, connection))
                    {
                        selectCommand.Parameters.AddWithValue("@patientID", patientID);
                        using (SqlDataReader reader = selectCommand.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                RoutineCheck checkResults = new RoutineCheck();
                                checkResults.VisitDate       = (DateTime)reader["visitTime"];
                                checkResults.SystolicBP      = (int)reader["systolicBP"];
                                checkResults.DiastolicBP     = (int)reader["diastolicBP"];
                                checkResults.BodyTemperature = (decimal)reader["bodyTemperature"];
                                checkResults.Pulse           = (int)reader["pulse"];
                                checkResults.Symptom         = reader["symptomType"].ToString();
                                checkResultList.Add(checkResults);
                            }
                            reader.Close();
                        }
                    }
                    connection.Close();
                }
            }

            catch (SqlException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(checkResultList);
        }
Exemple #5
0
        private RoutineCheck buildRoutineCheck()
        {
            var check = new RoutineCheck
            {
                Appointment = this.appointment
            };

            check.Nurse.ID = Settings.CurrentUser.ID;
            check.BloodPressureSystolic  = Convert.ToInt32(this.systolicNumberUpDown.Value);
            check.BloodPressureDiastolic = Convert.ToInt32(this.diastolicNumberUpDown.Value);
            check.Pulse    = Convert.ToInt32(this.pulseNumberUpDown.Value);
            check.BodyTemp = Convert.ToDouble(this.bodyTempNumberUpDown.Value);
            check.Weight   = Convert.ToDouble(this.weightNumberUpDown.Value);
            check.Symptoms = this.symptomsTextArea.Text.ToString();

            return(check);
        }
Exemple #6
0
        public async Task UpdateCheckup(RoutineCheck checkup)
        {
            var qry =
                "update routine_check set date = @date, systolicReading = @systolicReading, diastolicBloodPressure = @diastolicBloodPressure, weight = @weight, temp = @temp, init_diagnosis = @init_diagnosis where aId = @aID";
            var conn = DbConnection.GetConnection();
            await conn.OpenAsync();

            using (var command = new MySqlCommand(qry, conn))
            {
                command.Parameters.AddWithValue("@date", checkup.Date);
                command.Parameters.AddWithValue("@systolicReading", checkup.SystolicReading);
                command.Parameters.AddWithValue("@diastolicBloodPressure", checkup.DiastolicBloodPressure);
                command.Parameters.AddWithValue("@weight", checkup.Weight);
                command.Parameters.AddWithValue("@temp", checkup.Temperature);
                command.Parameters.AddWithValue("@aID", checkup.Appointment.AppointmentId);
                command.Parameters.AddWithValue("@init_diagnosis", checkup.InitialDiagnosis);
                await command.ExecuteNonQueryAsync();
            }

            conn.Close();
        }
        /// <summary>
        /// Updates a routine check with the same ID as the passed in check
        /// </summary>
        /// <param name="check">The routine check to be updated</param>
        public static void UpdateRoutineCheck(RoutineCheck check)
        {
            var connection = DbConnection.GetConnection();

            using (connection)
            {
                connection.Open();

                using (var cmd = new MySqlCommand(UpdateRoutineCheckup, connection))
                {
                    cmd.Parameters.AddWithValue("@apptID", check.Appointment.ID);
                    cmd.Parameters.AddWithValue("@nurseID", check.Nurse.ID);
                    cmd.Parameters.AddWithValue("@bloodPressureSystolic", check.BloodPressureSystolic);
                    cmd.Parameters.AddWithValue("@bloodPressureDiastolic", check.BloodPressureDiastolic);
                    cmd.Parameters.AddWithValue("@bodyTemp", check.BodyTemp);
                    cmd.Parameters.AddWithValue("@pulse", check.Pulse);
                    cmd.Parameters.AddWithValue("@weight", check.Weight);
                    cmd.Parameters.AddWithValue("@symptoms", check.Symptoms);

                    cmd.ExecuteNonQuery();
                }
            }
        }
        private async void addCheckup(object sender, RoutedEventArgs e)
        {
            this.ring.IsActive = true;
            try
            {
                var aId            = int.Parse(this.aID.Text);
                var nId            = int.Parse(this.nID.Text);
                var time           = this.timeicker.Time;
                var date           = this.datePicker.Date.Date.AddHours(time.Hours).AddMinutes(time.Minutes);
                var sys            = int.Parse(this.sysReadind.Text);
                var bPr            = int.Parse(this.bPressure.Text);
                var _weight        = double.Parse(this.weight.Text);
                var temp           = double.Parse(this.temp.Text);
                var ini            = this.summaryTextBox.Text;
                var appointmentdal = new AppointmentDAL();
                var appointment    = await appointmentdal.GetAppointmentById(aId);

                var nursedal = new NurseDAL();
                var nurse    = await nursedal.GetNurseByNurseId(nId);

                var checkup = new RoutineCheck(appointment, nurse, appointment.Patient, date, sys, bPr, _weight, temp,
                                               ini);
                await this.viewModel.AddCheckup(checkup);

                await this.viewModel.LoadAllAppointments();

                var confirmBox = new MessageDialog($"CheckUp completed  {date.ToShortDateString()}");
                this.ring.IsActive = false;
                await confirmBox.ShowAsync();
            }
            catch (Exception ex)
            {
                this.ring.IsActive = false;
                var messageDialog = new MessageDialog(ex.Message);
                await messageDialog.ShowAsync();
            }
        }
Exemple #9
0
        private void showRoutineCheckSavedMessage(RoutineCheck check)
        {
            var msg = $"The routine check has been saved.";

            MessageBox.Show(msg, "Routine Check Saved", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
        }