private void calendar1_ItemDoubleClick(object sender, CalendarItemEventArgs e)
        {
            selectedAppointmentID = e.Item.AppointmentID;
            for (int i = Application.OpenForms.Count - 1; i >= 0; i--)
            {
                if (Application.OpenForms[i].Name != "ProviderMain" && Application.OpenForms[i].Name != "WelcomeHomePage")
                {
                    Application.OpenForms[i].Close();
                }
            }

            if (Application.OpenForms["PatientHomePage"] as PatientHomePage == null)
            {
                ISingleResult <getPatientByIDResult> result = doAction.getPatientByID(e.Item.PatientID);
                foreach (getPatientByIDResult r in result)
                {
                    string          name            = r.FirstName + " " + r.LastName;
                    PatientHomePage patientHomePage = new PatientHomePage(name, r.PhoneNumber, r.Gender,
                                                                          r.MaritalStatus, r.Age, r.DOB, e.Item.PatientID, this.providerMain, this, e.Item)
                    {
                        MdiParent = providerMain
                    };
                    patientHomePage.Show();
                }
            }
        }
Exemplo n.º 2
0
        private void AppointmentListView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var appointmentListGrid = (DataGridView)sender;

            selectedAppointmentID = (int)appointmentListGrid["appointmentID", e.RowIndex].Value;
            if (e.RowIndex >= 0 && appointmentListGrid[e.ColumnIndex, e.RowIndex] is DataGridViewButtonCell &&
                appointmentListGrid.CurrentCell.ColumnIndex == 7 && (String)appointmentListGrid.CurrentCell.Value == "Scheduled")
            {
                try
                {
                    DataGridViewTextBoxCell TextBoxCell = new DataGridViewTextBoxCell();
                    string checkedIn = "Checked in at: " + DateTime.Now.ToString("HH:mm");
                    appointmentListGrid[e.ColumnIndex, e.RowIndex].Value = checkedIn;
                    doAction.updateAppointment(checkedIn, selectedAppointmentID);
                    appointmentListGrid[e.ColumnIndex, e.RowIndex] = TextBoxCell;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            if (e.RowIndex >= 0 && appointmentListGrid[e.ColumnIndex, e.RowIndex] is DataGridViewButtonCell &&
                appointmentListGrid.CurrentCell.ColumnIndex == 0)
            {
                try
                {
                    if (Application.OpenForms["PatientHomePage"] as PatientHomePage == null)
                    {
                        int selectedPatientID = (int)AppointmentListView1["PatientID", e.RowIndex].Value;

                        Console.WriteLine("hello I passed");



                        string   firstName = null;
                        string   lastName  = null;
                        string   number    = null;
                        string   gender    = null;
                        DateTime?DOB       = null;
                        string   age       = null;

                        ISingleResult <getPatientByIDResult> result = doAction.getPatientByID(selectedPatientID);


                        foreach (getPatientByIDResult r in result)
                        {
                            firstName = r.FirstName;
                            lastName  = r.LastName;
                            number    = r.PhoneNumber;
                            gender    = r.Gender;
                            DOB       = r.DOB;
                            age       = r.Age;

                            Console.WriteLine(1);
                        }

                        string patientFullName = firstName + " " + lastName;

                        Console.WriteLine(patientFullName);


                        PatientHomePage newPatientHomePage = new PatientHomePage(patientFullName, number, gender, age, Convert.ToDateTime(DOB), selectedPatientID, thisProviderMain, this)
                        {
                            MdiParent = thisProviderMain
                        };


                        Center(newPatientHomePage);
                        newPatientHomePage.Show();
                    }
                }
                catch (Exception ex)
                {
                    //while (ex.InnerException != null) ex = ex.InnerException;
                    throw (ex);
                }
            }
        }
        private void PatientListView1_RowClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && PatientListView1[e.ColumnIndex, e.RowIndex] is DataGridViewButtonCell && e.ColumnIndex == 0)
            {
                this.PatientListView1.Rows[e.RowIndex].Selected = true;



                int selectedPatientID = (int)this.PatientListView1["PatientID", e.RowIndex].Value;


                EMRDatabaseDataSet.PatientDataTable selectedPatient = this.patientTableAdapter.GetDataByPatientID(selectedPatientID);

                string   name          = (String)selectedPatient[0]["FirstName"] + " " + (String)selectedPatient[0]["LastName"];
                string   phoneNumber   = (String)selectedPatient[0]["PhoneNumber"];
                string   gender        = (String)selectedPatient[0]["Gender"];
                string   age           = (String)selectedPatient[0]["Age"];
                string   maritalStatus = (String)selectedPatient[0]["MaritalStatus"];
                DateTime DOB           = (DateTime)selectedPatient[0]["DOB"];



                if (Application.OpenForms["PatientHomePage"] as PatientHomePage == null)
                {
                    PatientHomePage patientHome = new PatientHomePage(name, phoneNumber, gender, age, maritalStatus, DOB, selectedPatientID, this.providerMain)
                    {
                        MdiParent = (ProviderMain)this.MdiParent
                    };

                    for (int i = Application.OpenForms.Count - 1; i >= 0; i--)
                    {
                        if (Application.OpenForms[i].Name != "ProviderMain" && Application.OpenForms[i].Name != "WelcomeHomePage" &&
                            Application.OpenForms[i].Name != "SchedulerMain")
                        {
                            Application.OpenForms[i].Close();
                        }
                    }
                    patientHome.Show();
                }

                Console.WriteLine("clicked");
            }


            else if (e.RowIndex >= 0 && PatientListView1[e.ColumnIndex, e.RowIndex] is DataGridViewButtonCell)
            {
                this.PatientListView1.Rows[e.RowIndex].Selected = true;
                int selectedPatientID = (int)this.PatientListView1["PatientID", e.RowIndex].Value;
                EMRDatabaseDataSet.PatientDataTable selectedPatient = this.patientTableAdapter.GetDataByPatientID(selectedPatientID);

                string firstName   = (String)selectedPatient[0]["FirstName"];
                string lastName    = (String)selectedPatient[0]["LastName"];
                string phoneNumber = "";
                if (selectedPatient[0]["PhoneNumber"].GetType() != typeof(DBNull))
                {
                    phoneNumber = (String)selectedPatient[0]["PhoneNumber"];
                }
                string gender          = (String)selectedPatient[0]["Gender"];
                string age             = (String)selectedPatient[0]["Age"];
                string pregnancyStatus = "";
                if (selectedPatient[0]["PregnancyStatus"].GetType() != typeof(DBNull))
                {
                    pregnancyStatus = (String)selectedPatient[0]["PregnancyStatus"];
                }


                string   maritalStatus = (String)selectedPatient[0]["MaritalStatus"];
                string   height        = (String)selectedPatient[0]["Height"];
                string   weight        = (String)selectedPatient[0]["Weight"];
                string   nationality   = (String)selectedPatient[0]["Nationality"];
                DateTime DOB           = (DateTime)selectedPatient[0]["DOB"];

                for (int i = Application.OpenForms.Count - 1; i >= 0; i--)
                {
                    if (Application.OpenForms[i] != this && Application.OpenForms[i].Name != "WelcomeHomePage" &&
                        Application.OpenForms[i].Name != "ProviderMain" && Application.OpenForms[i].Name != "SchedulerMain")
                    {
                        Application.OpenForms[i].Close();
                    }
                }
                this.Hide();

                if (Application.OpenForms["NewPatient"] as NewPatient == null)
                {
                    if (parentType == "provider")
                    {
                        NewPatient update = new NewPatient(providerMain, selectedPatientID)
                        {
                            MdiParent = (ProviderMain)this.MdiParent,
                        };

                        update.FirstNameBox.Text   = firstName;
                        update.LastNameBox.Text    = lastName;
                        update.PhoneNumberBox.Text = phoneNumber;
                        if (gender == "Male")
                        {
                            update.MaleCheckBox.Checked = true;
                        }
                        else
                        {
                            update.FemaleCheckBox.Checked = true;
                            if (pregnancyStatus == "Pregnant")
                            {
                                update.PregnantBox.Checked = true;
                            }
                            else
                            {
                                update.NotPregnantBox.Checked = true;
                            }
                        }
                        if (maritalStatus == "Single")
                        {
                            update.SingleBox.Checked = true;
                        }
                        else
                        {
                            update.MarriedBox.Checked = true;
                        }
                        update.HeightBox.Text      = height;
                        update.WeightBox.Text      = weight;
                        update.NationalityBox.Text = nationality;
                        update.Focus();
                        this.Close();
                        this.Dispose();
                        update.Show();
                    }
                    if (parentType == "scheduler")
                    {
                        NewPatient update = new NewPatient(schedulerMain, selectedPatientID)
                        {
                            MdiParent = (ProviderMain)this.MdiParent,
                        };
                        this.Hide();
                        update.FirstNameBox.Text   = firstName;
                        update.LastNameBox.Text    = lastName;
                        update.PhoneNumberBox.Text = phoneNumber;
                        if (gender == "Male")
                        {
                            update.MaleCheckBox.Checked = true;
                        }
                        else
                        {
                            update.FemaleCheckBox.Checked = true;
                            if (pregnancyStatus == "Pregnant")
                            {
                                update.PregnantBox.Checked = true;
                            }
                            else
                            {
                                update.NotPregnantBox.Checked = true;
                            }
                        }
                        if (maritalStatus == "Single")
                        {
                            update.SingleBox.Checked = true;
                        }
                        else
                        {
                            update.MarriedBox.Checked = true;
                        }
                        update.HeightBox.Text      = height;
                        update.WeightBox.Text      = weight;
                        update.NationalityBox.Text = nationality;
                        update.Focus();
                        this.Close();
                        this.Dispose();
                        update.Show();
                    }
                }
            }
        }