Ejemplo n.º 1
0
        private void yesBtn_Click(object sender, RoutedEventArgs e)
        {
            Patient selectedPatient = (Patient)txtPatient.SelectedItem;
            Room    selectedRoom    = (Room)cmbNumberOfRoom.SelectedItem;

            if (selectedPatient == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati pacijenta!";
                okMbx.ShowDialog();
                return;
            }
            if (cmbTypeOfExamination.SelectedItem == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati vrstu pregleda!";
                okMbx.ShowDialog();
                return;
            }
            if (selectedRoom == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati sobu!";
                okMbx.ShowDialog();
                return;
            }
            TypeOfExamination    type;
            TypeOfExaminationDTO selectedType = (TypeOfExaminationDTO)cmbTypeOfExamination.SelectedItem;

            if (selectedType.Type.Equals("Opšti pregled"))
            {
                type = TypeOfExamination.Opsti;
            }
            else if (selectedType.Type.Equals("Specijalistički pregled"))
            {
                type = TypeOfExamination.Specijalisticki;
            }
            else
            {
                type = TypeOfExamination.Operacija;
            }
            DateTime date = Convert.ToDateTime(examination.Date + " " + examination.Time, CultureInfo.InvariantCulture);

            string[]    partsDoctor         = examination.Doctor.Split(' ');
            Doctor      selectedDoctor      = (Doctor)userDoctorController.ViewProfile(partsDoctor[partsDoctor.Length - 1]);
            PatientCard selectedPatientCard = patientCardController.ViewPatientCard(selectedPatient.Jmbg);

            if (examinationController.ScheduleExamination(new Examination(examination.Id, type, date, selectedDoctor, selectedRoom, selectedPatientCard)) == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Došlo je do greške, doktor/soba su već zauzeti u izabranom terminu!";
                okMbx.ShowDialog();
                return;
            }

            int    lastId  = notificationController.getLastId();
            string message = "Zakazan pregled\n" + "Doktor: " + selectedDoctor.Name + " " + selectedDoctor.Surname
                             + "\nBroj sobe: " + selectedRoom.Number + "\nDatum:" + date.ToShortDateString() + "\nVrijeme: " + date.ToShortTimeString();

            notificationController.SendNotification(new Notification(++lastId, TypeOfNotification.Pregled, message, selectedPatientCard.patient.Jmbg));


            var okMb = new OKMessageBox(this, 0);

            okMb.titleMsgBox.Text = "Obavještenje";
            okMb.textMsgBox.Text  = "Uspješno ste zakazali pregled.";
            okMb.ShowDialog();
            this.Close();

            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(MainWindow))
                {
                    (window as MainWindow).Main.Content = new ExaminationViewByDoctor(selectedDoctor.Jmbg);
                }
            }
        }
Ejemplo n.º 2
0
        private void yesBtn_Click(object sender, RoutedEventArgs e)
        {
            Regex regexJmbg  = new Regex(@"^[0-9]{13}$");
            Match match      = regexJmbg.Match(txtJmbg.Text);
            Regex regexPhone = new Regex(@"^[0-9]+$");
            Match match1     = regexPhone.Match(txtPhone.Text);
            Regex regexLbo   = new Regex(@"^[a-z]{2}[0-9]{3}$");
            Match match2     = regexLbo.Match(txtLbo.Text);
            Regex regexEmail = new Regex(@"^[a-z0-9\.\-_]{4,20}[@]{1}[a-z.]{4,10}");
            Match match3     = regexEmail.Match(txtEmail.Text);

            if (txtName.Text.Equals("") || txtSurname.Text.Equals("") || txtJmbg.Text.Equals(""))
            {
                var okMbx = new OKMessageBox(this, 1);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Unos imena, prezimena i jmbg-a je obavezan!";
                okMbx.ShowDialog();
            }
            else if (!match.Success)
            {
                var okMbx = new OKMessageBox(this, 2);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "JMBG mora da sadrži 13 cifara!";
                okMbx.ShowDialog();
            }
            else if (!txtPhone.Text.Equals("") && !match1.Success)
            {
                var okMbx = new OKMessageBox(this, 2);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Telefon može da sadrži samo cifre!";
                okMbx.ShowDialog();
            }
            else if (!txtLbo.Text.Equals("") && !match2.Success)
            {
                var okMbx = new OKMessageBox(this, 2);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Lbo mora da bude u formatu xx000!";
                okMbx.ShowDialog();
            }
            else if (!txtEmail.Text.Equals("") && !match3.Success)
            {
                var okMbx = new OKMessageBox(this, 2);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Pogrešan format za email!";
                okMbx.ShowDialog();
            }
            else
            {
                bool hi = false;
                if ((bool)yesCheckBtn.IsChecked)
                {
                    hi = true;
                }
                BloodType    blood = BloodType.O;
                RhFactorType rh    = RhFactorType.Negativna;
                DateTime     date  = DateTime.Today;
                GenderType   gen   = GenderType.Z;

                if (cmbBloodType.Text.Equals("A"))
                {
                    blood = BloodType.A;
                }
                else if (cmbBloodType.Text.Equals("B"))
                {
                    blood = BloodType.B;
                }
                else if (cmbBloodType.Text.Equals("AB"))
                {
                    blood = BloodType.AB;
                }

                if (cmbRh.Text.Equals("+"))
                {
                    rh = RhFactorType.Pozitivna;
                }
                if (dpDateOfBirth.SelectedDate != null)
                {
                    date = (DateTime)dpDateOfBirth.SelectedDate;
                }
                if (cmbGender.Text.Equals("M"))
                {
                    gen = GenderType.M;
                }

                City city = (City)txtCity.SelectedItem;

                bool guest = false;
                if (txtUsername.Text.Equals("") || txtUsername.Text == null)
                {
                    guest = true;
                }


                Patient p = new Patient(txtJmbg.Text, txtName.Text, txtSurname.Text, date, gen, city, txtStreet.Text, txtPhone.Text, txtEmail.Text, txtUsername.Text, txtPassword.Password, DateTime.Today, guest);

                string   medicalHistory = "";
                string[] partsDate      = txtDate.Text.Split('\n');
                string[] partsDesc      = txtDesc.Text.Split('\n');
                string[] partsTherapy   = txtTherapy.Text.Split('\n');

                if (!txtDate.Text.Equals(dates) || !txtTherapy.Text.Equals(therapy) || !txtDesc.Text.Equals(desc))
                {
                    if (partsDate.Length != partsDesc.Length || partsDate.Length != partsTherapy.Length || partsDate.Length != partsTherapy.Length)
                    {
                        var okMbx = new OKMessageBox(this, 2);
                        okMbx.titleMsgBox.Text = "Greška";
                        okMbx.textMsgBox.Text  = "Niste dobro unijeli istoriju bolesti!";
                        okMbx.ShowDialog();
                        return;
                    }
                    if (!txtDate.Text.Equals("") || !txtDesc.Text.Equals("") || !txtTherapy.Text.Equals(""))
                    {
                        for (int i = 0; i < partsDate.Length; i++)
                        {
                            if (partsDate[i].Equals("") || partsDesc[i].Equals("") || partsTherapy[i].Equals(""))
                            {
                                var okMbx = new OKMessageBox(this, 2);
                                okMbx.titleMsgBox.Text = "Greška";
                                okMbx.textMsgBox.Text  = "Niste dobro unijeli istoriju bolesti!";
                                okMbx.ShowDialog();
                                return;
                            }
                            medicalHistory += partsDate[i] + ":" + partsDesc[i] + ":" + partsTherapy[i] + ";";
                        }
                    }
                }
                else
                {
                    medicalHistory = dates + desc + therapy;
                    medicalHistory = medicalHistory.Replace('\n', ':');
                    if (medicalHistory.Length > 0)
                    {
                        medicalHistory  = medicalHistory.Substring(0, medicalHistory.Length - 1);
                        medicalHistory += ";";
                    }
                }

                PatientCard pc = new PatientCard(p, blood, rh, txtAllergy.Text, medicalHistory, hi, txtLbo.Text);

                if (patientController.EditProfile(p) != null && patientCardController.EditPatientCard(pc) != null)
                {
                    List <Examination> examinations = examinationController.ViewExaminationsByPatient(p.Jmbg);
                    foreach (Examination exm in examinations)
                    {
                        exm.patientCard = pc;
                        examinationController.EditExamination(exm);
                    }
                    List <Therapy> therapies = therapyController.ViewAllTherapyByPatient(p.Jmbg);
                    foreach (Therapy t in therapies)
                    {
                        t.patientCard = pc;
                        therapyController.EditTherapy(t);
                    }
                    List <PlacemetnInARoom> placemetnInARooms = placementInSickRoomController.ViewPatientPlacements(p.Jmbg);
                    foreach (PlacemetnInARoom pr in placemetnInARooms)
                    {
                        pr.patientCard = pc;
                        placementInSickRoomController.EditPlacement(pr);
                    }

                    var okMb = new OKMessageBox(this, 3);
                    okMb.titleMsgBox.Text = "Obavještenje";
                    okMb.textMsgBox.Text  = "Uspješno ste izmijenili informacije o pacijentu.";
                    okMb.ShowDialog();
                }
                else
                {
                    var okMbx = new OKMessageBox(this, 2);
                    okMbx.titleMsgBox.Text = "Greška";
                    okMbx.textMsgBox.Text  = "Došlo je do greške prilikom izmjene informacija! Provjerite da li su korisničko ime/lozinka validni.";
                    okMbx.ShowDialog();
                }
            }
        }