//View Refill Request button click event
        private void viewRefillRequestsButton_Click(object sender, EventArgs e)
        {
            if (!(newRefillRequestsListView.SelectedIndices.Count == 0))
            {
                selectedRefillRequest = (RefillRequest)RefillRequest.displayRefillRequests()[newRefillRequestsListView.SelectedIndices[0]];    //get the selected refill request
                listView1.Items.Clear();
                listView2.Items.Clear();

                selectedRefillRequest.Prescription.retrieveMedicines();                        //retrieve all medicines of the requested prescription
                Patient patient = selectedRefillRequest.Prescription.retrievePatientDetails(); //retrieve the details of the patient who requested the refill

                int i = 0;
                foreach (Medicine medicine in patient.MedicineHistory)
                {
                    listView1.Items.Add(medicine.Date);
                    listView1.Items[i].SubItems.Add(medicine.Name);
                    listView1.Items[i].SubItems.Add("" + medicine.Quantity);
                    listView1.Items[i].SubItems.Add(medicine.Dosage);
                    i++;
                }
                i = 0;
                foreach (Medicine medicine in selectedRefillRequest.Prescription.Medicines)
                {
                    listView2.Items.Add(medicine.Name);
                    listView2.Items[i].SubItems.Add("" + medicine.Quantity);
                    listView2.Items[i].SubItems.Add(medicine.Dosage);
                    listView2.Items[i].SubItems.Add(medicine.Route);
                    listView2.Items[i].SubItems.Add(medicine.Instructions);
                    i++;
                }

                //Display patient information
                generalListView.Items.Clear();
                generalListView.Items.Add("Name: " + patient.Name);
                generalListView.Items.Add("Date of Birth: " + patient.BirthDate);
                generalListView.Items.Add("Height: " + patient.Height);
                generalListView.Items.Add("Weight: " + patient.Weight);
                generalListView.Items.Add("Body Mass Index: " + patient.BodyMassIndex);
                dateLabel.Text      = selectedRefillRequest.Date;
                statusLabel.Text    = selectedRefillRequest.Status;
                refillsLabel.Text   = "" + selectedRefillRequest.Prescription.Refills;
                remainingLabel.Text = "" + selectedRefillRequest.Prescription.RemainingRefills;
                allergyTextBox.Text = patient.Allergies;

                //Disable or enable Accept and Deny buttons depending on RefillRequest status
                if (selectedRefillRequest.Status.ToLower().Equals("new"))
                {
                    acceptButton.Enabled = true;
                    rejectButton.Enabled = true;
                }
                else
                {
                    acceptButton.Enabled = false;
                    rejectButton.Enabled = false;
                }

                newRefillRequestsPanel.Hide();
                prescriptionDetailPanel.Show();
            }
        }
 //return to the new refill requests panel
 private void backButton_Click(object sender, EventArgs e)
 {
     RefillRequest.retrieveRefillRequests();
     populateList();
     prescriptionDetailPanel.Hide();
     newRefillRequestsPanel.Show();
 }
 /// <summary>
 /// Update notices, prescriptions, and refill requests from the database and display the number of each with status New
 /// </summary>
 private void showUnread()
 {
     Notice.retrieveNotices();
     Prescription.retrieveNewPrescriptions();
     RefillRequest.retrieveRefillRequests();
     newNoticesButton.Text        = "Notices  (" + Notice.unread + ")";
     newPrescriptionsButton.Text  = "Prescriptions  (" + Prescription.NewPrescriptionCount + ")";
     newRefillRequestsButton.Text = "Refill Requests  (" + RefillRequest.NewRefillRequestCount + ")";
 }
        /// <summary>
        /// Retrieve all new refill requests for the pharmacy of the pharmacist user.
        /// </summary>
        public static void retrieveRefillRequests()
        {
            refillRequests.Clear();
            DataTable       table   = new DataTable();
            string          connStr = "server=csdatabase.eku.edu;user=stu_csc340;database=csc340_db;port=3306;password=Colonels18;SSLMode=None";
            MySqlConnection conn    = new MySqlConnection(connStr);

            try
            {
                Console.WriteLine("Connecting to MySQL...");
                conn.Open();
                string sql = @"SELECT DATE_FORMAT(re.dateRequested, ""%m-%d-%Y"") AS dateRequested, re.refillRequestStatus, 
                        re.id, pa.name AS patientName, pa.patientID, DATE_FORMAT(pa.birthDate, ""%Y-%m-%d"") AS birthDate, 
                        doc.name, pr.refills, pr.remainingRefills, pr.id AS 'pid'
                        FROM DixonRefillRequest re JOIN DixonPrescription pr ON re.prescriptionID = pr.id 
                        JOIN DixonPatient pa ON re.patientID = pa.patientID JOIN DixonDoctor doc ON pr.doctorID = doc.id 
                        WHERE pr.pharmacyID = @id AND re.refillRequestStatus = 'New'
                        ORDER BY re.refillRequestStatus DESC, dateRequested DESC;";

                MySqlCommand cmd = new MySqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@id", User.Id);
                MySqlDataAdapter myAdapter = new MySqlDataAdapter(cmd);
                myAdapter.Fill(table);
                Console.WriteLine("Table is ready.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            conn.Close();

            int newCount = 0;

            foreach (DataRow row in table.Rows)
            {
                RefillRequest request = new RefillRequest();
                request.Prescription                  = new Prescription();
                request.Date                          = row["dateRequested"].ToString();
                request.Status                        = row["refillRequestStatus"].ToString();
                request.Id                            = row["id"].ToString();
                request.Prescription.PatientName      = row["patientName"].ToString();
                request.Prescription.PatientBirthDate = row["birthDate"].ToString();
                request.Prescription.PrescriberName   = row["name"].ToString();
                request.Prescription.Refills          = (int)row["refills"];
                request.Prescription.RemainingRefills = (int)row["remainingRefills"];
                request.Prescription.Id               = (int)row["pid"];
                request.Prescription.PatientId        = (int)row["patientID"];
                if (request.Status.Equals("New"))
                {
                    newCount++;
                }
                refillRequests.Add(request);
            }
            newRefillRequestCount = newCount;
        }
        //display refill requests in the refill requests listview
        public void populateList()
        {
            newRefillRequestsListView.Items.Clear();
            int i = 0;

            foreach (RefillRequest request in RefillRequest.displayRefillRequests())
            {
                newRefillRequestsListView.Items.Add(request.Status);
                newRefillRequestsListView.Items[i].SubItems.Add(request.Date);
                newRefillRequestsListView.Items[i].SubItems.Add(request.Prescription.PatientName);
                newRefillRequestsListView.Items[i].SubItems.Add(request.Prescription.PrescriberName);
                newRefillRequestsListView.Items[i].SubItems.Add(request.Prescription.Refills.ToString());
                newRefillRequestsListView.Items[i].SubItems.Add(request.Prescription.RemainingRefills.ToString());
                i++;
            }
        }
Exemple #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Login());

            //check if authentication is successful
            if (Login.loginSuccess)
            {
                //retrieve information from database
                Notice.retrieveNotices();
                Prescription.retrieveNewPrescriptions();
                RefillRequest.retrieveRefillRequests();
                //launch main menu
                Application.Run(new MainMenu());
            }
        }