Example #1
0
        //send request
        private void sendRequestButton_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                Patient patID = (Patient)listView1.SelectedItems[0].Tag;

                //get textbox field
                string additional = additionCommentsText.Text.ToString();

                //get doctor ID
                string docID = docObj.calculateID(docObj.getUserName());

                //create our notice, and use return value of 1 or 0 to check if successful or not
                int check = notObj.createMedicalRequestNotice(patID.ID, docID, additional);

                //check if success or fail
                if (check == 1)
                {
                    MessageBox.Show("Medical Records Permission Request Sent Successfully!");
                }
                else
                {
                    MessageBox.Show("Something went wrong :( Try again.");
                }

                //clear additional textbox
                additionCommentsText.Clear();
                listView1.Items.Clear();
            }
            else
            {
                MessageBox.Show("Please select a patient!");
            }
        }
        public DoctorNotification()
        {
            InitializeComponent();

            notificationListView.View = View.Details;
            notificationListView.Columns.Add("Notification");
            notificationListView.Columns[0].Width = -2;
            notificationListView.GridLines        = true;
            notificationListView.HeaderStyle      = System.Windows.Forms.ColumnHeaderStyle.None;

            List <Notice> displayAllNotices = new List <Notice>();

            string docID = docObj.calculateID(docObj.getUserName());

            displayAllNotices = notObj.getAllDoctorNotices(docID);

            //display all list objects as strings
            for (int i = 0; i < displayAllNotices.Count; i++)
            {
                CreateListViewItem(notificationListView, displayAllNotices[i]);
            }
        }
        //grant 'R'
        private void buttonMakeAppointment_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                //get patient tag tied with object
                Patient patID = (Patient)listView1.SelectedItems[0].Tag;
                //get textbox field
                string additional = textBox1.Text.ToString();

                //get our doctor ID
                string docID = docObj.calculateID(docObj.getUserName());

                //to show response in notice
                string response = "1";

                //create the notice, which returns a 1 if successful, 0 if a fail
                int check = notObj.createGrantNotice(patID.ID, docID, additional, response);

                //check if success or fail
                if (check == 1)
                {
                    MessageBox.Show("Notice sent successfully! Permit has been granted!");
                }
                else
                {
                    MessageBox.Show("Something went wrong :( Try again.");
                }

                //clear additional textbox
                textBox1.Clear();
                listView1.Items.Clear();
            }
            else
            {
                MessageBox.Show("Please Select a Patient!");
            }
        }
        //end of create
        //
        //
        //
        //

        //-------ADD------------
        //
        //
        //
        //
        //
        private void button1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                Patient patID = (Patient)listView1.SelectedItems[0].Tag;
                name = patID.getName();
                string id = patID.getID();

                string docID = docObj.calculateID(docObj.getUserName());

                int checkFam = docObj.checkFamily(docID, id);

                if (checkFam == 0)
                {
                    MessageBox.Show("You do not have permission to access this Patient's records!");
                    return;
                }

                //check if gender is on default value
                if (genderDrop.SelectedItem == null)
                {
                    gender = "";
                }
                else
                {
                    gender = genderDrop.SelectedItem.ToString();
                }

                //calculate age
                DateTime tempDate = dobTimePicker.Value.Date;
                var      today    = DateTime.Today;
                var      tempAge  = today.Year - tempDate.Year;

                //format date, convert age
                DOB = tempDate.ToString("yyyy/MM/d");
                age = tempAge.ToString();


                phone    = phoneText.Text.ToString();
                address1 = address1Text.Text.ToString();
                address2 = address2Text.Text.ToString();
                city     = cityText.Text.ToString();
                state    = stateTextBox.Text.ToString();

                //check country base value
                if (countryDrop.SelectedItem == null)
                {
                    country = "";
                }
                else
                {
                    country = countryDrop.SelectedItem.ToString();
                }

                accepted      = acceptedTimePicker.Value.Date.ToString("yyyy/M/d");
                prescriptions = prescriptionsText.Text.ToString();
                sickness      = sicknessText.Text.ToString();
                allergies     = allergiesText.Text.ToString();
                other         = specialText.Text.ToString();

                //check all fields have data

                //check that prescription is a number
                if (prescriptionsText.Text.ToString() != "")
                {
                    int parsedValue;
                    if (!int.TryParse(prescriptionsText.Text, out parsedValue))
                    {
                        MessageBox.Show("Prescription must be a number!");
                        prescriptionsText.Clear();
                        return;
                    }
                    else
                    {
                        prescriptions = prescriptionsText.Text.ToString();
                    }
                }

                //check that phone is entered correct
                if (phoneText.Text.ToString() != "")
                {
                    int parsedValue2;
                    if (!int.TryParse(phoneText.Text, out parsedValue2))
                    {
                        MessageBox.Show("Phone must be a number!");
                        phoneText.Clear();
                        return;
                    }
                    else
                    {
                        phone = phoneText.Text.ToString();
                    }
                }

                //calculate username to pass
                string user  = "";
                var    split = name.Split(' ');
                if (split.Length < 2)
                {
                    user = name;
                }
                else
                {
                    user = name[0] + split[1];
                }

                //MessageBox.Show(" | "+name+ " | " +gender+ " | " +DOB+" | "+age+ " | " +phone+ " | " +address1+ " | " +city + " | " +state + " | " +country + " | " +accepted + " | " +prescriptions + " | " +allergies+" | "+other);

                //call our database method, and check if it succeeded
                Patient passPatObj = new Patient();

                passPatObj = patID.getPatientObject(patID.getID());

                int check = notObj.addMedicalRecord(name, gender, DOB, age, phone, address1, address2, city, state, country, accepted, sickness, prescriptions, allergies, other, user, passPatObj);

                //display message accordingly
                if (check == 1)
                {
                    MessageBox.Show("Entered information has been modified/updated!");
                    nameText.Clear();
                    phoneText.Clear();
                    address1Text.Clear();
                    address2Text.Clear();
                    cityText.Clear();
                    stateTextBox.Clear();
                    sicknessText.Clear();
                    prescriptionsText.Clear();
                    allergiesText.Clear();
                    sicknessText.Clear();
                    specialText.Clear();
                }
                else
                {
                    MessageBox.Show("Something went wrong :( Try again.");
                }
            }
            else
            {
                MessageBox.Show("Please select a patient!");
            }
        }