예제 #1
0
        private void patbtn_update_Click(object sender, RoutedEventArgs e)
        {
            if (patselected == null)
            {
                return;
            }



            String   fullname = patnametxt_update.Text;
            DateTime dob      = (DateTime)patdatepicker_update.SelectedDate;
            String   gender   = "male";

            if (((patrbfemale_update.IsChecked ?? false) || (patrbfemale_update.IsChecked ?? false)) &&
                !string.IsNullOrEmpty(patdatepicker_update.Text))
            {
                if (patrbfemale_update.IsChecked ?? false)
                {
                    gender = "female";
                }
            }

            patselected.pat_name   = fullname;
            patselected.pat_dob    = dob;
            patselected.pat_gender = gender;
            patselected.doc_id     = int.Parse(patcombobox_updatedoc.SelectedValue.ToString());
            var catid = doctorList.Where(x => x.doc_id == patselected.doc_id).Select(x => x.cat_id).FirstOrDefault();

            patselected.cat_id = catid;

            hmsfac.updatePatient(patselected);


            MessageBox.Show("Record updated success.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            dataGrid_Patient.Items.Refresh();
            this.patnametxt_update.Text       = "";
            this.patdatepicker_update.Text    = "";
            this.patcombobox_updatedoc.Text   = "";
            this.patbtn_update.IsEnabled      = false;
            this.patrbmale_update.IsChecked   = false;
            this.patrbfemale_update.IsChecked = false;
        }
        private void submit_presc_Click(object sender, RoutedEventArgs e)
        {
            if (patSelected == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(pattypecombo_doc.Text))
            {
                MessageBox.Show("Please select patient type.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }


            if (pattypecombo_doc.Text.Equals("Indoor"))
            {
                if (string.IsNullOrEmpty(patdisease_doc.Text))
                {
                    MessageBox.Show("Please enter a diease", "Reminder", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                IndoorPatient patIndoor = new IndoorPatient();
                DateTime      admitdate = DateTime.Today;
                patIndoor.indpat_disease = patdisease_doc.Text;
                patIndoor.Patient        = patSelected;
                patIndoor.admit_date     = admitdate;
                patIndoor.indpat_status  = "admitted";
                hmsfac.addIndoor(patIndoor);
                patSelected.pat_type = "indoor";
            }
            else
            {
                patSelected.pat_type = "outdoor";
            }


            if (!string.IsNullOrEmpty(patmed_doc.Text))
            {
                int mid1 = int.Parse(patmed_doc.SelectedValue.ToString());

                string dosage1 = patdosage_doc.Text;

                Prescription p1 = new Prescription();
                p1.med_id       = mid1;
                p1.presc_dosage = dosage1;
                p1.pat_id       = patSelected.pat_id;
                p1.doc_id       = docOwner.doc_id;
                hmsfac.addPrescription(p1);
                presList.Add(p1);


                if (!string.IsNullOrEmpty(patmed1_doc.Text))
                {
                    Prescription p2 = new Prescription();
                    p2.med_id       = int.Parse(patmed1_doc.SelectedValue.ToString());
                    p2.presc_dosage = patdosage1_doc.Text;
                    p2.pat_id       = patSelected.pat_id;
                    p2.doc_id       = docOwner.doc_id;
                    hmsfac.addPrescription(p2);
                    presList.Add(p2);
                }

                if (!string.IsNullOrEmpty(patmed2_doc.Text.ToString()))
                {
                    Prescription p3 = new Prescription();
                    p3.med_id       = int.Parse(patmed2_doc.SelectedValue.ToString());
                    p3.presc_dosage = patdosage2_doc.Text;
                    p3.pat_id       = patSelected.pat_id;
                    p3.doc_id       = docOwner.doc_id;
                    hmsfac.addPrescription(p3);
                    presList.Add(p3);
                }

                patSelected.doc_id = docOwner.doc_id;
                hmsfac.updatePatient(patSelected);
                NewPatientList.Remove(patSelected);
                dataGrid_NewPatient.Items.Refresh();
                dataGrid_MyPrescriptions.Items.Refresh();
                MessageBox.Show("Prescription submisson success.", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                dataGrid_OldPatient.ItemsSource = hmsfac.getMyOldPatients(docOwner);
                dataGrid_OldPatient.Items.Refresh();
                this.pattypecombo_doc.Text  = "";
                this.patmed_doc.Text        = "";
                this.patdisease_doc.Text    = "";
                this.patdosage_doc.Text     = "";
                this.patdosage1_doc.Text    = "";
                this.patdosage2_doc.Text    = "";
                this.patmed1_doc.Text       = "";
                this.patmed2_doc.Text       = "";
                this.submit_presc.IsEnabled = true;
            }
            else
            {
                MessageBox.Show("At least one medicine is required for prescription", "Reminder", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
        }