public ZakazivanjePregleda() { InitializeComponent(); DoctorController DoctorContr = new DoctorController(); List <DoctorUser> lista = new List <DoctorUser>(); lista = DoctorContr.GetAll(); List <DoctorUser> doktori = new List <DoctorUser>(); CurrentDateTime = new DateTime(2020, 6, 20, 14, 9, 22); TimeText = String.Format("{0:t}", CurrentDateTime); EndDateTime = new DateTime(2020, 6, 20, 14, 9, 22); TimeText1 = String.Format("{0:t}", EndDateTime); this.DataContext = this; foreach (DoctorUser lekar in lista) { ListaLekara.Items.Add(lekar.firstName + " " + lekar.secondName + " " + lekar.speciality + " " + lekar.email + " " + lekar.ordination); } ListaLekara.SelectedIndex = 0; PatientController guestContr = new PatientController(); List <PatientUser> pacijenti = new List <PatientUser>(); pacijenti = guestContr.GetAll(); List <PatientUser> lista1 = new List <PatientUser>(); ListaPacijenata.SelectedIndex = 0; foreach (PatientUser ee in lista1) { pacijenti.Add(new PatientUser { id = ee.id, firstName = ee.firstName, secondName = ee.secondName, uniqueCitizensidentityNumber = ee.uniqueCitizensidentityNumber, dateOfBirth = ee.dateOfBirth, phoneNumber = ee.phoneNumber, medicalIdNumber = ee.medicalIdNumber, isRegisteredBySecretary = ee.isRegisteredBySecretary }); } foreach (PatientUser regP in pacijenti) { ListaPacijenata.Items.Add(regP.firstName + " " + regP.secondName + " " + regP.medicalIdNumber); } foreach (PatientUser ee in lista1) { if (ListaPacijenata.SelectedItem.Equals(ee.firstName + " " + ee.secondName + " " + ee.medicalIdNumber)) { KnjizicaBox.Text = ee.medicalIdNumber; } } }
private void InitializeRecipients() { Recipients = new List <String>(); Recipients.Add("Svi korisnici"); Recipients.Add("Zaposleni"); Recipients.Add("Svi pacijenti"); foreach (Patient patient in _patientController.GetAll()) { if (!patient.IsDeleted) { Recipients.Add(patient.Name + " " + patient.Surname + " - " + patient.Username); } } RecipientsListBox.SelectedIndex = 0; }
public void UpdateTable() { PatientsDataGrid.Items.Clear(); List <Patient> patients = new List <Patient>(); foreach (Patient patient in _patientController.GetAll()) { if (!patient.IsDeleted) { patients.Add(patient); } } patients = _patientController.FilterPatients(patients, TableFilter.Text, PatientFilter); FillDataGrid(patients); }
private void InitializeComboBoxes() { DoctorComboBox.ItemsSource = _doctorControler.GetAll(); PatientComboBox.ItemsSource = _patientController.GetAll(); RoomComboBox.ItemsSource = _roomController.GetAllRooms(); date.BlackoutDates.Add(new CalendarDateRange(DateTime.MinValue, DateTime.Today.AddDays(-1))); date.SelectedDate = selected.AppointmentDate; time.SelectedValue = selected.AppointmentDate.ToString("HH:mm"); TypeComboBox.SelectedIndex = (int)selected.Type; DoctorComboBox.SelectedItem = selected.Doctor; PatientComboBox.SelectedItem = selected.Patient; RoomComboBox.SelectedItem = selected.Room; }
private int getNextid() { PatientController rp = new PatientController(); List <PatientUser> lista = rp.GetAll(); int number = 0; foreach (PatientUser r in lista) { if (r.id > number) { number = r.id; } } number += 1; return(number); }
private void InitializeComponentValues() { _confirmed = false; _doctors = _doctorController.GetAll(); DoctorComboBox.ItemsSource = _doctors; _rooms = _roomController.GetAllRooms(); RoomComboBox.ItemsSource = _rooms; _patients = new List <Patient>(); foreach (Patient patient in _patientController.GetAll()) { if (!patient.IsDeleted) { _patients.Add(patient); } } PatientComboBox.ItemsSource = _patients; PatientComboBox.SelectedItem = _selectedAppointment.Patient; foreach (global::Doctor doctors in _doctors) { if (doctors.Equals(_selectedAppointment.Doctor)) { DoctorComboBox.SelectedItem = doctors; } } UpdateAvailableTimes(); DatePicker.SelectedDate = _selectedAppointment.AppointmentDate; AppointmentTime.SelectedValue = _selectedAppointment.AppointmentDate.ToString("HH:mm"); AppointmentDuration.Text = _selectedAppointment.DurationInMinutes.ToString(); AppointmentTypeComboBox.SelectedIndex = (int)_selectedAppointment.Type; foreach (Room room in _rooms) { if (room.RoomId == _selectedAppointment.Room.RoomId) { RoomComboBox.SelectedItem = room; } } _done = true; }
public IzmenaPodatakaPacijent() { InitializeComponent(); this.DataContext = this; PatientController guestContr = new PatientController(); List <PatientUser> pacijenti = guestContr.GetAll(); ListaPacijenata.SelectedIndex = 0; foreach (PatientUser regP in pacijenti) { if (regP.isRegisteredBySecretary == true) { ListaPacijenata.Items.Add(regP.firstName + " " + regP.secondName + " " + regP.id.ToString()); } } pacijent = new PatientUser(); foreach (PatientUser s in pacijenti) { if (s.id.ToString().Equals(idPacijenta.Text)) { pacijent = s; ImeBox.Text = s.firstName.ToString(); Prezime = s.secondName.ToString(); DatumRodjenja = s.dateOfBirth.ToString(); Jmbg = s.uniqueCitizensidentityNumber.ToString(); BrKnjizice = s.medicalIdNumber.ToString(); Email = s.email.ToString(); Lozinka = s.password.ToString(); Lozinka2 = s.password.ToString(); AdresaBox.Text = s.city.ToString(); brojTelefona = s.phoneNumber.ToString(); } } }
public ObavestenjaPacijenata() { InitializeComponent(); lekar = new DoctorUser(); cont = new PatientController(); lista = new List <PatientUser>(); lista = cont.GetAll(); Question q = new Question(); DoctorController doctorController = new DoctorController(); List <DoctorUser> listaDoktora = doctorController.GetAll(); foreach (DoctorUser s in listaDoktora) { if (s.email.Equals(svojstvo)) { lekar = s; } } if (pitanja == null) { pitanja = new List <Question>(); } List <DoctorNotification> mojaObavestenja = lekar.specialNotifications; idSvihpacijenta = new List <int>(); foreach (PatientUser pacijent in lista) { idSvihpacijenta.Add(pacijent.id); } Obavestenja.ItemsSource = mojaObavestenja; pacijentid.ItemsSource = idSvihpacijenta; }
private void Confirm_Click(object sender, RoutedEventArgs e) { string name = NameText.Text; string surname = SurnameText.Text; string username = "******" + _patientController.GetAll().Count.ToString(); if (!Int64.TryParse(JMBG, out var JMBGRes) || JMBG.Length != 13) { MessageBox.Show("JMBG se mora sastojati iz 13 cifara", "Nedostatak informacija", MessageBoxButton.OK); return; } Patient = new Patient(name, surname, JMBG, ' ', "", "", new DateTime(), username, "", new ResidentialAddress("", new City("", "", new Country(""))), true, "", new MedicalRecord("")); bool retVal = _patientController.Register(Patient); if (retVal) { _parent.InitializePatients(); _parent.PatientsList.SelectedItem = Patient.Name + " " + Patient.Surname + " - " + Patient.JMBG; Close(); } }
private void Confirm_Click() { UInt64 JMBGRes; char genderRes; if (!char.TryParse(Gender, out genderRes)) { MessageBox.Show("Morate uneti pol", "Nedostatak informacija", MessageBoxButton.OK); return; } if (!UInt64.TryParse(JMBG, out JMBGRes) || JMBG.Length != 13) { MessageBox.Show("JMBG se mora sastojati iz 13 cifara", "Nedostatak informacija", MessageBoxButton.OK); return; } if (Username == null || Username.Length == 0) { MessageBox.Show("Korisničko ime ne sme biti prazno", "Nevalidan unos", MessageBoxButton.OK); return; } ResidentialAddress residentialAddress = new ResidentialAddress(ResidentialAddress, new City(City, PostalCode, new Country(Country))); Patient patient = new Patient(LegalName, Surname, JMBG, char.Parse(Gender), TelephoneNumber, EmailAddress, DateOfBirth, Username, Password, residentialAddress, Guest, SocialSecurityNumber, new MedicalRecord(_patientController.GetAll().Count.ToString()), false); patient.MedicalRecord.patient = patient; bool retVal = _patientController.Register(patient); if (retVal) { MessageBox.Show("Pacijent je uspešno registrovan!", "Uspešno dodat korisnik", MessageBoxButton.OK); _parent.Close(); } }
private void Zakazi_click(object sender, RoutedEventArgs e) { String b = bingPathToAppDir(@"JsonFiles\appointments.json"); String c = bingPathToAppDir(@"JsonFiles\refferal.json"); String d = bingPathToAppDir(@"JsonFiles\patients.json"); String m = bingPathToAppDir(@"JsonFiles\doctors.json"); PatientsRepository patientRepo = new PatientsRepository(d); List <PatientUser> patientLista = patientRepo.GetAll(); PatientUser ovajPacijent = new PatientUser(); foreach (PatientUser r1 in patientLista) { if (r1.medicalIdNumber.Equals(KnjizicaBox.Text.ToString())) { ovajPacijent = r1; KnjizicaBox.Text = r1.medicalIdNumber; } } DoctorRepository docRepo = new DoctorRepository(m); List <DoctorUser> doktori = docRepo.GetAll(); DoctorUser drOvaj = new DoctorUser(); foreach (DoctorUser d1 in doktori) { if (d1.email.Equals(emailLekarBox.Text.ToString())) { drOvaj = d1; } } if (!Regex.Match(Time1Box.Text, "^[0-9]{2}:[0-9]{2}$").Success || !Regex.Match(Time2Box.Text, "^[0-9]{2}:[0-9]{2}$").Success) { MessageBox.Show("Vreme mora biti u formatu 00:00", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } String[] startParts = Time1Box.Text.Split(':'); String[] endParts = Time2Box.Text.Split(':'); int startIntPart1 = int.Parse(startParts[0]); int startIntPart2 = int.Parse(startParts[1]); int ensIntPart1 = int.Parse(endParts[0]); int endtIntPart2 = int.Parse(endParts[1]); if (startIntPart1 > 23 || startIntPart2 > 60 || ensIntPart1 > 23 || endtIntPart2 > 60 || startIntPart1 > ensIntPart1) { MessageBox.Show("Najveca vrednost za vreme je 23:59", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } TimeSpan vremee = new TimeSpan(startIntPart1, startIntPart2, 00); TimeSpan vremee2 = new TimeSpan(ensIntPart1, endtIntPart2, 00); int broj = getNextid(); DoctorAppointment drap = new DoctorAppointment(broj, vremee, DatumBox.Text.ToString(), ovajPacijent, drOvaj, null, ordinacijaBox.Text); AppointmentRepository arepo = new AppointmentRepository(b); List <DoctorAppointment> lista2 = new List <DoctorAppointment>(); PatientController regPat = new PatientController(); List <PatientUser> pac = new List <PatientUser>(); pac = regPat.GetAll(); if (arepo.GetAll() != null) { lista2 = arepo.GetAll(); } String o = bingPathToAppDir(@"JsonFiles\operations.json"); int broj1 = getNextid1(); Operation op = new Operation(broj1, ovajPacijent, DatumBox.Text.ToString(), vremee, vremee2, drOvaj, ordinacijaBox.Text, null); OperationRepository opRep = new OperationRepository(o); List <Operation> lista3 = new List <Operation>(); if (opRep.GetAll() != null) { lista3 = opRep.GetAll(); } if (pregled == true) { String datum = DatumBox.Text; String[] delovi2 = datum.Split('/'); int mesec = int.Parse(delovi2[1]); int dan = int.Parse(delovi2[0]); int godina = int.Parse(delovi2[2]); DateTime dt1 = new DateTime(godina, mesec, dan, 0, 0, 0); DateTime dt2 = DateTime.Now; if (dt1 < dt2) { MessageBox.Show("Molimo vas da unesete datum koji tek predstoji", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } String x = bingPathToAppDir(@"JsonFiles\appointments.json"); AppointmentRepository apc = new AppointmentRepository(x); List <DoctorAppointment> listaPregleda = apc.GetAll(); /* foreach (DoctorAppointment dd in listaPregleda) * { * DoctorUser dr = dd.doctor; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * TimeSpan krajPr = dd.Time + new TimeSpan(0, 15, 0); * int result = TimeSpan.Compare(vremee, dd.Time); * int result1 = TimeSpan.Compare(vremee, krajPr); * if ((result == 1 && result1 == -1) || result == 0) * { * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * } * * * * * } * }*/ /* String pre = bingPathToAppDir(@"JsonFiles\operations.json"); * OperationRepository apc1 = new OperationRepository(pre); * List<Operation> listaPregleda1 = apc1.GetAll(); * foreach (Operation dd in listaPregleda1) * { * DoctorUser dr = dd.isResponiable; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * int result = TimeSpan.Compare(vremee, dd.Start); * int result1 = TimeSpan.Compare(vremee, dd.End); * if ((result == 1 && result1 == -1)||result==0 ||result1==0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * * } * * * * * } * }*/ EmployeesScheduleController schCon = new EmployeesScheduleController(); List <Schedule> listaRasporeda = schCon.GetAll(); Shift smena = schCon.getShiftForDoctorForSpecificDay(DatumBox.Text, drOvaj); if (smena == null || smena.startTime == null || smena.endTime == null) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi tog dana.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } AppointmentController appointmentController = new AppointmentController(); Boolean notAvaible = appointmentController.isTermNotAvailable(drOvaj, vremee, DatumBox.Text, ovajPacijent); if (notAvaible == true) { MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* foreach (Schedule s in listaRasporeda) * { * * if (s.employeeid.Equals(drOvaj.id.ToString())) * { * if (s.Date.Equals(DatumBox.Text)) * { * smena = s.shift; * } * } * } * if(smena.StartTime==null || smena.EndTime == null) * { * * }*/ bool slobodan = schCon.isDoctorWorkingAtSpecifiedTime(DatumBox.Text, drOvaj, vremee); if (slobodan == false) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* String pocetak = smena.StartTime; * String kraj = smena.EndTime; * String[] deloviPocetak = pocetak.Split(':'); * String[] deloviKraj = kraj.Split(':'); * * TimeSpan pocetakTime = new TimeSpan(int.Parse(deloviPocetak[0]), int.Parse(deloviPocetak[1]), 0); * TimeSpan krajTime = new TimeSpan(int.Parse(deloviKraj[0]), int.Parse(deloviKraj[1]), 0); * int result3 = TimeSpan.Compare(vremee, pocetakTime); * int result4 = TimeSpan.Compare(krajTime, vremee); * * if (result3 != 1 || result4 != 1) * { * MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * * return; * * }*/ AppointmentController apCon = new AppointmentController(); apCon.New(drap, null); int id1 = 0; String ime = ""; String prezime = ""; String jmbg = ""; String datumRodj = ""; String brojTel = ""; String brKnj = ""; List <Question> pitanja = new List <Question>(); String alergije = ""; String grad = ""; Boolean guest = false; String email = ""; String password = ""; Boolean sekr = false; // foreach (PatientUser pat in lista) // { // if (pat.id.Equals(d.patient.id)) // { id1 = drap.patient.id; ime = drap.patient.firstName; prezime = drap.patient.secondName; jmbg = drap.patient.uniqueCitizensidentityNumber; datumRodj = drap.patient.dateOfBirth; brKnj = drap.patient.medicalIdNumber; brojTel = drap.patient.phoneNumber; alergije = drap.patient.allergie; grad = drap.patient.city; email = drap.patient.email; guest = drap.patient.guest; password = drap.patient.password; sekr = drap.patient.isRegisteredBySecretary; if (drap.patient.notifications == null) { drap.patient.notifications = new List <ModelNotification>(); } List <ModelNotification> notifications = drap.patient.notifications; // } notifications.Add(new ModelNotification("Postovani, zakazana vam je novi pregled datuma : " + drap.date + " u " + drap.time + " h kod lekara " + drap.doctor.firstName + " " + drap.doctor.secondName + ". Ordinacija: " + drap.roomid)); drap.patient.notifications = notifications; // PatientUser rp = new PatientUser(id1, ime, prezime, jmbg, datumRodj, brojTel, brKnj, pitanja, alergije, grad, guest, email, password, sekr, notifications); PatientController pCon = new PatientController(); pCon.Update(drap.patient); Panel.Children.Clear(); UserControl usc = new RezervisaniiTermini(); Panel.Children.Add(usc); } else if (operacija == true) { String datum = DatumBox.Text; String[] delovi2 = datum.Split('/'); int mesec = int.Parse(delovi2[1]); int dan = int.Parse(delovi2[0]); int godina = int.Parse(delovi2[2]); DateTime dt1 = new DateTime(godina, mesec, dan, 0, 0, 0); DateTime dt2 = DateTime.Now; if (dt2 > dt1) { MessageBox.Show("Molimo vas da unesete termin koji tek predstoji", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } String x = bingPathToAppDir(@"JsonFiles\appointments.json"); AppointmentRepository apc = new AppointmentRepository(x); /* List<DoctorAppointment> listaPregleda = apc.GetAll(); * foreach (DoctorAppointment dd in listaPregleda) * { * DoctorUser dr = dd.doctor; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * TimeSpan krajPr = dd.Time + new TimeSpan(0, 15, 0); * int result = TimeSpan.Compare(vremee, dd.Time); * int result1 = TimeSpan.Compare(vremee, krajPr); * if ((result == 1 && result1 == -1) || result == 0) * { * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * int rezultat = TimeSpan.Compare(vremee2, dd.Time); * int rezultat1 = TimeSpan.Compare(vremee2, krajPr); * if ((rezultat == 1 && rezultat1 == -1) || rezultat == 0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * } * * * * * } * }*/ /*String pre = bingPathToAppDir(@"JsonFiles\operations.json"); * OperationRepository apc1 = new OperationRepository(pre); * List<Operation> listaPregleda1 = apc1.GetAll(); * foreach (Operation dd in listaPregleda1) * { * DoctorUser dr = dd.isResponiable; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * int result = TimeSpan.Compare(vremee, dd.Start); * int result1 = TimeSpan.Compare(vremee, dd.End); * if ((result == 1 && result1 == -1) || result == 0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * int rezultat = TimeSpan.Compare(vremee2, dd.Start); * int rezultat1 = TimeSpan.Compare(vremee2, dd.End); * if ((rezultat == 1 && rezultat1 == -1) || rezultat == 0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * } * * * * * } * }*/ OperationController opCon = new OperationController(); bool zauzetTermin = opCon.isTermNotAvailable(drOvaj, vremee, vremee2, DatumBox.Text, ovajPacijent); if (zauzetTermin == true) { MessageBox.Show("Trazeni termin nije dostupan.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } EmployeesScheduleController schCon = new EmployeesScheduleController(); List <Schedule> listaRasporeda = schCon.GetAll(); Shift smena = schCon.getShiftForDoctorForSpecificDay(DatumBox.Text, drOvaj); if (smena == null || smena.startTime == null || smena.endTime == null) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi tog dana.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } bool slobodan = schCon.isDoctorWorkingAtSpecifiedTime(DatumBox.Text, drOvaj, vremee); if (slobodan == false) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } String pocetak = smena.startTime; String kraj = smena.endTime; String[] deloviPocetak = pocetak.Split(':'); String[] deloviKraj = kraj.Split(':'); TimeSpan pocetakTime = new TimeSpan(int.Parse(deloviPocetak[0]), int.Parse(deloviPocetak[1]), int.Parse("00")); TimeSpan krajTime = new TimeSpan(int.Parse(deloviKraj[0]), int.Parse(deloviKraj[1]), int.Parse("00")); int result3 = TimeSpan.Compare(vremee2, pocetakTime); int result4 = TimeSpan.Compare(krajTime, vremee2); if (result3 != 1 || result4 != 1) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* EmployeesScheduleController schCon = new EmployeesScheduleController(); * List<Schedule> listaRasporeda = schCon.GetAll(); * Shift smena = new Shift(); * foreach (Schedule s in listaRasporeda) * { * * if (s.employeeid.Equals(drOvaj.id.ToString())) * { * if (s.Date.Equals(DatumBox.Text)) * { * smena = s.shift; * } * } * } * if (smena.StartTime == null || smena.EndTime == null) * { * MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi tog dana.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * * return; * }*/ /* String pocetak = smena.StartTime; * String kraj = smena.EndTime; * String[] deloviPocetak = pocetak.Split(':'); * String[] deloviKraj = kraj.Split(':'); * * TimeSpan pocetakTime = new TimeSpan(int.Parse(deloviPocetak[0]), int.Parse(deloviPocetak[1]), int.Parse("00")); * TimeSpan krajTime = new TimeSpan(int.Parse(deloviKraj[0]), int.Parse(deloviKraj[1]), int.Parse("00")); * int result3 = TimeSpan.Compare(vremee, pocetakTime); * int result4 = TimeSpan.Compare(krajTime, vremee); * * if (result3 != 1 || result4 != 1) * { * MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * * return; * * }*/ opCon.New(null, op); PatientController pCon = new PatientController(); List <PatientUser> pacijenti = pCon.GetAll(); int id1 = 0; String ime = ""; String prezime = ""; String jmbg = ""; String datumRodj = ""; String brojTel = ""; String brKnj = ""; List <Question> pitanja = new List <Question>(); String alergije = ""; String grad = ""; Boolean guest = false; String email = ""; String password = ""; Boolean sekr = false; List <ModelNotification> notifications = new List <ModelNotification>(); // foreach (PatientUser pat in lista) // { // if (pat.id.Equals(d.patient.id)) // { id1 = op.patient.id; ime = op.patient.firstName; prezime = op.patient.secondName; jmbg = op.patient.uniqueCitizensidentityNumber; datumRodj = op.patient.dateOfBirth; brojTel = op.patient.phoneNumber; alergije = op.patient.allergie; grad = op.patient.city; email = op.patient.email; guest = op.patient.guest; password = op.patient.password; sekr = op.patient.isRegisteredBySecretary; notifications = op.patient.notifications; // } if (notifications == null) { notifications = new List <ModelNotification>(); } notifications.Add(new ModelNotification("Postovani, zakazana Vam je nova operacija datuma : " + op.date + " u " + op.start + " h, kod lekara " + op.isResponiable.firstName + " " + op.isResponiable.secondName + " Sala " + op.idRoom)); PatientUser rp = new PatientUser(id1, ime, prezime, jmbg, datumRodj, brojTel, brKnj, alergije, grad, guest, email, password, sekr, notifications); pCon.Update(rp); Panel.Children.Clear(); UserControl usc = new RezervisaniiTermini(); Panel.Children.Add(usc); } }
private void Zakazi_click(object sender, RoutedEventArgs e) { String b = bingPathToAppDir(@"JsonFiles\appointments.json"); String c = bingPathToAppDir(@"JsonFiles\refferal.json"); String d = bingPathToAppDir(@"JsonFiles\patients.json"); String m = bingPathToAppDir(@"JsonFiles\doctors.json"); PatientsRepository patientRepo = new PatientsRepository(d); List <PatientUser> patientLista = patientRepo.GetAll(); PatientUser ovajPacijent = new PatientUser(); foreach (PatientUser r1 in patientLista) { if (r1.medicalIdNumber.Equals(KnjizicaBox.Text.ToString())) { ovajPacijent = r1; KnjizicaBox.Text = r1.medicalIdNumber; } } DoctorRepository docRepo = new DoctorRepository(m); List <DoctorUser> doktori = docRepo.GetAll(); DoctorUser drOvaj = new DoctorUser(); foreach (DoctorUser d1 in doktori) { if (d1.email.Equals(emailLekarBox.Text.ToString())) { drOvaj = d1; } } String konacnoVreme = ""; String vreme = TimeText; Console.WriteLine(vreme); String[] deliciVreme = vreme.Split(' '); String[] satIminut = deliciVreme[0].Split(':'); String sat = satIminut[0]; String minut = satIminut[1]; String kada = deliciVreme[1]; StringBuilder sb = new StringBuilder(); if (kada.Equals("AM")) { sb.Append(deliciVreme[0]); sb.Append(":00"); } else { if (sat.Equals("1")) { sb.Append("13:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("2")) { sb.Append("14:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("3")) { sb.Append("15:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("4")) { sb.Append("16:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("5")) { sb.Append("17:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("6")) { sb.Append("18:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("7")) { sb.Append("19:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("8")) { sb.Append("20:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("9")) { sb.Append("21:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("10")) { sb.Append("22:"); sb.Append(minut); sb.Append(":00"); } else if (sat.Equals("11")) { sb.Append("23:"); sb.Append(minut); sb.Append(":00"); } else { sb.Append("00:"); sb.Append(minut); sb.Append(":00"); } } konacnoVreme = sb.ToString(); Console.WriteLine(konacnoVreme); String[] zaTs = konacnoVreme.Split(':'); int minutiVreme = int.Parse(zaTs[1]); TimeSpan ts = new TimeSpan(int.Parse(zaTs[0]), minutiVreme, int.Parse(zaTs[2])); String konacnoVreme1 = ""; String vreme1 = TimeText1; Console.WriteLine(vreme); String[] deliciVreme1 = vreme1.Split(' '); String[] satIminut1 = deliciVreme1[0].Split(':'); String sat1 = satIminut1[0]; String minut1 = satIminut1[1]; String kada1 = deliciVreme1[1]; StringBuilder sb1 = new StringBuilder(); if (kada1.Equals("AM")) { sb1.Append(deliciVreme1[0]); sb1.Append(":00"); } else { if (sat1.Equals("1")) { sb1.Append("13:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("2")) { sb1.Append("14:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("3")) { sb1.Append("15:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("4")) { sb1.Append("16:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("5")) { sb1.Append("17:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("6")) { sb1.Append("18:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("7")) { sb1.Append("19:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("8")) { sb1.Append("20:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("9")) { sb1.Append("21:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("10")) { sb1.Append("22:"); sb1.Append(minut1); sb1.Append(":00"); } else if (sat1.Equals("11")) { sb1.Append("23:"); sb1.Append(minut1); sb1.Append(":00"); } else { sb1.Append("00:"); sb1.Append(minut1); sb1.Append(":00"); } } konacnoVreme1 = sb1.ToString(); Console.WriteLine(konacnoVreme); Console.WriteLine(konacnoVreme1); String[] zaTs1 = konacnoVreme1.Split(':'); int minutiVreme1 = int.Parse(zaTs1[1]); TimeSpan ts1 = new TimeSpan(int.Parse(zaTs1[0]), minutiVreme1, int.Parse(zaTs1[2])); String[] deloviVreme = vreme.Split(':'); //String[] deloviVreme2 = vreme2.Split(':'); // TimeSpan vremee = new TimeSpan(int.Parse(deloviVreme[0]), int.Parse(deloviVreme[1]), 0); // TimeSpan vremee2 = new TimeSpan(int.Parse(deloviVreme2[0]), int.Parse(deloviVreme2[1]), 0); int broj = getNextid(); DoctorAppointment drap = new DoctorAppointment(0, ts, DatumBox.Text.ToString(), ovajPacijent, drOvaj, null, ordinacijaBox.Text); AppointmentRepository arepo = new AppointmentRepository(b); List <DoctorAppointment> lista2 = new List <DoctorAppointment>(); PatientController regPat = new PatientController(); List <PatientUser> pac = new List <PatientUser>(); pac = regPat.GetAll(); if (arepo.GetAll() != null) { lista2 = arepo.GetAll(); } String o = bingPathToAppDir(@"JsonFiles\operations.json"); int broj1 = getNextid1(); Operation op = new Operation(0, ovajPacijent, DatumBox.Text.ToString(), ts, ts1, drOvaj, ordinacijaBox.Text, null); OperationRepository opRep = new OperationRepository(o); List <Operation> lista3 = new List <Operation>(); if (opRep.GetAll() != null) { lista3 = opRep.GetAll(); } if (pregled == true) { String datum = DatumBox.Text; String[] delovi2 = datum.Split('/'); int mesec = int.Parse(delovi2[1]); int dan = int.Parse(delovi2[0]); int godina = int.Parse(delovi2[2]); DateTime dt1 = new DateTime(godina, mesec, dan, 0, 0, 0); DateTime dt2 = DateTime.Now; if (dt1 < dt2) { MessageBox.Show("Molimo vas da unesete datum koji tek predstoji", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } String x = bingPathToAppDir(@"JsonFiles\appointments.json"); AppointmentRepository apc = new AppointmentRepository(x); List <DoctorAppointment> listaPregleda = apc.GetAll(); /* foreach (DoctorAppointment dd in listaPregleda) * { * DoctorUser dr = dd.doctor; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * TimeSpan krajPr = dd.Time + new TimeSpan(0, 15, 0); * int result = TimeSpan.Compare(vremee, dd.Time); * int result1 = TimeSpan.Compare(vremee, krajPr); * if ((result == 1 && result1 == -1) || result == 0) * { * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * } * * * * * } * }*/ /* String pre = bingPathToAppDir(@"JsonFiles\operations.json"); * OperationRepository apc1 = new OperationRepository(pre); * List<Operation> listaPregleda1 = apc1.GetAll(); * foreach (Operation dd in listaPregleda1) * { * DoctorUser dr = dd.isResponiable; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * int result = TimeSpan.Compare(vremee, dd.Start); * int result1 = TimeSpan.Compare(vremee, dd.End); * if ((result == 1 && result1 == -1)||result==0 ||result1==0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * * } * * * * * } * }*/ EmployeesScheduleController schCon = new EmployeesScheduleController(); List <Schedule> listaRasporeda = schCon.GetAll(); Shift smena = schCon.getShiftForDoctorForSpecificDay(DatumBox.Text, drOvaj); if (smena == null || smena.startTime == null || smena.endTime == null) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi tog dana.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } AppointmentController appointmentController = new AppointmentController(); Boolean notAvaible = appointmentController.isTermNotAvailable(drOvaj, ts, DatumBox.Text, ovajPacijent); if (notAvaible == true) { MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* foreach (Schedule s in listaRasporeda) * { * * if (s.employeeid.Equals(drOvaj.id.ToString())) * { * if (s.Date.Equals(DatumBox.Text)) * { * smena = s.shift; * } * } * } * if(smena.StartTime==null || smena.EndTime == null) * { * * }*/ bool slobodan = schCon.isDoctorWorkingAtSpecifiedTime(DatumBox.Text, drOvaj, ts); if (slobodan == false) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* String pocetak = smena.StartTime; * String kraj = smena.EndTime; * String[] deloviPocetak = pocetak.Split(':'); * String[] deloviKraj = kraj.Split(':'); * * TimeSpan pocetakTime = new TimeSpan(int.Parse(deloviPocetak[0]), int.Parse(deloviPocetak[1]), 0); * TimeSpan krajTime = new TimeSpan(int.Parse(deloviKraj[0]), int.Parse(deloviKraj[1]), 0); * int result3 = TimeSpan.Compare(vremee, pocetakTime); * int result4 = TimeSpan.Compare(krajTime, vremee); * * if (result3 != 1 || result4 != 1) * { * MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * * return; * * }*/ AppointmentController apCon = new AppointmentController(); apCon.New(drap, null); int id1 = 0; String ime = ""; String prezime = ""; String jmbg = ""; String datumRodj = ""; String brojTel = ""; String brKnj = ""; List <Question> pitanja = new List <Question>(); String alergije = ""; String grad = ""; Boolean guest = false; String email = ""; String password = ""; Boolean sekr = false; // foreach (PatientUser pat in lista) // { // if (pat.id.Equals(d.patient.id)) // { id1 = drap.patient.id; ime = drap.patient.firstName; prezime = drap.patient.secondName; jmbg = drap.patient.uniqueCitizensidentityNumber; datumRodj = drap.patient.dateOfBirth; brKnj = drap.patient.medicalIdNumber; brojTel = drap.patient.phoneNumber; alergije = drap.patient.allergie; grad = drap.patient.city; email = drap.patient.email; guest = drap.patient.guest; password = drap.patient.password; sekr = drap.patient.isRegisteredBySecretary; if (drap.patient.notifications == null) { drap.patient.notifications = new List <ModelNotification>(); } List <ModelNotification> notifications = drap.patient.notifications; // } notifications.Add(new ModelNotification("Postovani, zakazana vam je novi pregled datuma : " + drap.date + " u " + drap.time + " h kod lekara " + drap.doctor.firstName + " " + drap.doctor.secondName + ". Ordinacija: " + drap.roomid)); drap.patient.notifications = notifications; // PatientUser rp = new PatientUser(id1, ime, prezime, jmbg, datumRodj, brojTel, brKnj, pitanja, alergije, grad, guest, email, password, sekr, notifications); PatientController pCon = new PatientController(); pCon.Update(drap.patient); Panel.Children.Clear(); UserControl usc = new PopunjeniTermini(); Panel.Children.Add(usc); } else if (operacija == true) { String datum = DatumBox.Text; String[] delovi2 = datum.Split('/'); int mesec = int.Parse(delovi2[1]); int dan = int.Parse(delovi2[0]); int godina = int.Parse(delovi2[2]); DateTime dt1 = new DateTime(godina, mesec, dan, 0, 0, 0); DateTime dt2 = DateTime.Now; if (dt2 > dt1) { MessageBox.Show("Molimo vas da unesete termin koji tek predstoji", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } String x = bingPathToAppDir(@"JsonFiles\appointments.json"); AppointmentRepository apc = new AppointmentRepository(x); /* List<DoctorAppointment> listaPregleda = apc.GetAll(); * foreach (DoctorAppointment dd in listaPregleda) * { * DoctorUser dr = dd.doctor; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * TimeSpan krajPr = dd.Time + new TimeSpan(0, 15, 0); * int result = TimeSpan.Compare(vremee, dd.Time); * int result1 = TimeSpan.Compare(vremee, krajPr); * if ((result == 1 && result1 == -1) || result == 0) * { * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * int rezultat = TimeSpan.Compare(vremee2, dd.Time); * int rezultat1 = TimeSpan.Compare(vremee2, krajPr); * if ((rezultat == 1 && rezultat1 == -1) || rezultat == 0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * } * * * * * } * }*/ /*String pre = bingPathToAppDir(@"JsonFiles\operations.json"); * OperationRepository apc1 = new OperationRepository(pre); * List<Operation> listaPregleda1 = apc1.GetAll(); * foreach (Operation dd in listaPregleda1) * { * DoctorUser dr = dd.isResponiable; * if (dr.id == drOvaj.id) * { * if (dd.Date.Equals(DatumBox.Text)) * { * int result = TimeSpan.Compare(vremee, dd.Start); * int result1 = TimeSpan.Compare(vremee, dd.End); * if ((result == 1 && result1 == -1) || result == 0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * int rezultat = TimeSpan.Compare(vremee2, dd.Start); * int rezultat1 = TimeSpan.Compare(vremee2, dd.End); * if ((rezultat == 1 && rezultat1 == -1) || rezultat == 0) * { * * MessageBox.Show("Izvinjavamo se! Trazeni termin je vec zauzet!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * return; * } * } * * * * * } * }*/ OperationController opCon = new OperationController(); bool zauzetTermin = opCon.isTermNotAvailable(drOvaj, ts, ts1, DatumBox.Text, ovajPacijent); if (zauzetTermin == true) { MessageBox.Show("Trazeni termin nije dostupan.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } EmployeesScheduleController schCon = new EmployeesScheduleController(); List <Schedule> listaRasporeda = schCon.GetAll(); Shift smena = schCon.getShiftForDoctorForSpecificDay(DatumBox.Text, drOvaj); if (smena == null || smena.startTime == null || smena.endTime == null) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi tog dana.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } bool slobodan = schCon.isDoctorWorkingAtSpecifiedTime(DatumBox.Text, drOvaj, ts); if (slobodan == false) { MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); return; } int ispravno = TimeSpan.Compare(ts1, ts); if (ispravno == -1 || ispravno == 0) { MessageBox.Show("Operacija mora imati trajanje!", "Greska", MessageBoxButton.OK); return; } /* String pocetak = smena.StartTime; * String kraj = smena.EndTime; * String[] deloviPocetak = pocetak.Split(':'); * String[] deloviKraj = kraj.Split(':'); * * TimeSpan pocetakTime = new TimeSpan(int.Parse(deloviPocetak[0]), int.Parse(deloviPocetak[1]), int.Parse("00")); * TimeSpan krajTime = new TimeSpan(int.Parse(deloviKraj[0]), int.Parse(deloviKraj[1]), int.Parse("00")); * int result3 = TimeSpan.Compare(vremee2, pocetakTime); * int result4 = TimeSpan.Compare(krajTime, vremee2); * * if (result3 != 1 || result4 != 1) * { * MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * * return; * * }*/ /* EmployeesScheduleController schCon = new EmployeesScheduleController(); * List<Schedule> listaRasporeda = schCon.GetAll(); * Shift smena = new Shift(); * foreach (Schedule s in listaRasporeda) * { * * if (s.employeeid.Equals(drOvaj.id.ToString())) * { * if (s.Date.Equals(DatumBox.Text)) * { * smena = s.shift; * } * } * } * if (smena.StartTime == null || smena.EndTime == null) * { * MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi tog dana.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * * return; * }*/ /* String pocetak = smena.StartTime; * String kraj = smena.EndTime; * String[] deloviPocetak = pocetak.Split(':'); * String[] deloviKraj = kraj.Split(':'); * * TimeSpan pocetakTime = new TimeSpan(int.Parse(deloviPocetak[0]), int.Parse(deloviPocetak[1]), int.Parse("00")); * TimeSpan krajTime = new TimeSpan(int.Parse(deloviKraj[0]), int.Parse(deloviKraj[1]), int.Parse("00")); * int result3 = TimeSpan.Compare(vremee, pocetakTime); * int result4 = TimeSpan.Compare(krajTime, vremee); * * if (result3 != 1 || result4 != 1) * { * MessageBox.Show("Trazeni termin nije dostupan.Lekar ne radi u to vreme.", "Greska", MessageBoxButton.OK, MessageBoxImage.Error); * * return; * * }*/ opCon.New(null, op); PatientController pCon = new PatientController(); List <PatientUser> pacijenti = pCon.GetAll(); int id1 = 0; String ime = ""; String prezime = ""; String jmbg = ""; String datumRodj = ""; String brojTel = ""; String brKnj = ""; List <Question> pitanja = new List <Question>(); String alergije = ""; String grad = ""; Boolean guest = false; String email = ""; String password = ""; Boolean sekr = false; // List<String> notifications = new List<String>(); // foreach (PatientUser pat in lista) // { // if (pat.id.Equals(d.patient.id)) // { id1 = op.patient.id; ime = op.patient.firstName; prezime = op.patient.secondName; jmbg = op.patient.uniqueCitizensidentityNumber; datumRodj = op.patient.dateOfBirth; brojTel = op.patient.phoneNumber; alergije = op.patient.allergie; grad = op.patient.city; email = op.patient.email; guest = op.patient.guest; password = op.patient.password; sekr = op.patient.isRegisteredBySecretary; // } // PatientUser rp = new PatientUser(id1, ime, prezime, jmbg, datumRodj, brojTel, brKnj, pitanja, alergije, grad, guest, email, password, sekr, notifications); if (op.patient.notifications == null) { op.patient.notifications = new List <ModelNotification>(); } List <ModelNotification> notifications = drap.patient.notifications; // } notifications.Add(new ModelNotification("Postovani, zakazana Vam je nova operacija datuma : " + op.date + " u " + op.start + " h, kod lekara " + op.isResponiable.firstName + " " + op.isResponiable.secondName + " Sala " + op.idRoom)); op.patient.notifications = notifications; pCon.Update(op.patient); Panel.Children.Clear(); UserControl usc = new PopunjeniTermini(); Panel.Children.Add(usc); } }
private void Confirm_Click(object sender, RoutedEventArgs e) { UInt64 JMBGRes; char genderRes; if (!UInt64.TryParse(JMBG, out JMBGRes) || JMBG.Length != 13) { MessageBox.Show("JMBG se mora sastojati iz 13 cifara", "Nedostatak informacija", MessageBoxButton.OK); return; } if (Username == null || Username.Length == 0) { MessageBox.Show("Korisničko ime ne sme biti prazno", "Nevalidan unos", MessageBoxButton.OK); return; } ResidentialAddress residentialAddress = new ResidentialAddress(ResidentialAddress, new City(City, PostalCode, new Country(Country))); Patient patient = new Patient(LegalName, Surname, JMBG, char.Parse(Gender), TelephoneNumber, EmailAddress, DateOfBirth, Username, Password, residentialAddress, Guest, SocialSecurityNumber, new MedicalRecord(_patientController.GetAll().Count.ToString()), false); patient.MedicalRecord = _initialPatient.MedicalRecord; _initialPatient.MedicalRecord.patient = patient; _patientController.Update(_initialPatient.Username, patient); _parent.UpdateTable(); this.Close(); }