Example #1
0
        private void button_addPatient_Click(object sender, RoutedEventArgs e)
        {
            String id      = data_apatientid.Text;
            String first   = data_apfname.Text;
            String last    = data_aplname.Text;
            String age     = data_apage.Text;
            String maindoc = m.GetDoctorIDByName(data_apmaindoc.Text);
            char   gender  = (data_apgender.Text.Equals("Male") ? 'm' : 'f');

            if (!m.isLegalName(first) || !m.isLegalName(last) || !m.isLegalInt(age, 1) || !m.DoctorAlreadyExists(maindoc) || m.PatientAlreadyExists(id))
            {
                String error = "The following things need to be fixed:\n\n";
                if (m.PatientAlreadyExists(id))
                {
                    error += " Patient is already in the system.\n";
                }
                if (!m.isLegalName(first))
                {
                    error += " First name is not legal. Names must start with Captial letter.\n";
                }
                if (!m.isLegalName(last))
                {
                    error += " Last name is not legal. Names must start with Captial letter.\n";
                }
                if (!m.DoctorAlreadyExists(maindoc))
                {
                    error += " Doctor does not in the system.\n";
                }
                if (!m.isLegalInt(age, 1))
                {
                    error += " Age is not legal. Must be integer bigger than 0.\n";
                }
                MessageBoxResult err = MessageBox.Show(error);
            }
            else
            {
                BackEndLayer.Patient p = new BackEndLayer.Patient(id, first, last, maindoc, int.Parse(age), gender);
                m.AddPatient(p);
                data_apatientid.Text = "";
                data_apfname.Text    = "";
                data_aplname.Text    = "";
                data_apmaindoc.Text  = "";
                data_apage.Text      = "";
                data_apgender.Text   = "";
                MessageBoxResult done = MessageBox.Show("The patient is added successfully to the system database.");
            }
        }
Example #2
0
        private void button_loadPatient_Click(object sender, RoutedEventArgs e)
        {
            List <BackEndLayer.Patient> p = m.SearchPatientByID(data_patientid.Text);

            if (p.Count > 0)
            {
                BackEndLayer.Patient pat = p.First <BackEndLayer.Patient>();
                data_patientid.IsReadOnly = true;
                data_pfname.Text          = pat.firstName;
                data_plname.Text          = pat.lastName;
                data_pmaindoc.Text        = m.GetDoctorNameByID(pat.mainDoctor);
                data_page.Text            = pat.age + "";
                data_pgender.Text         = ((pat.gender == 'm') ? "Male" : "Female");
            }
            else
            {
                MessageBoxResult err = MessageBox.Show("The patient does not exists.");
            }
        }
Example #3
0
        private void go_Click(object sender, RoutedEventArgs e)
        {
            List <BackEndLayer.Patient> p = m.SearchPatientByID(this.data_patient.Text);

            if (p.Count > 0)
            {
                data_patient.IsReadOnly = true;
                BackEndLayer.Patient tPat = p.First <BackEndLayer.Patient>();
                this.data_presc.Clear();
                this.data_prog.Clear();
                this.dataBlock.Visibility = System.Windows.Visibility.Visible;
                this.data_name.Content    = tPat.getName();
                this.data_age.Content     = tPat.getAge();
                this.data_gender.Content  = tPat.getGender();
            }
            else
            {
                MessageBoxResult err = MessageBox.Show("The patient does not exists.");
            }
        }