/// <summary> /// constructeur /// </summary> public PatientBrowserViewModel(Page lkView) { _linkedView = lkView; _imageCommand = new RelayCommand(param => ImageAccess(param), param => true); _createObservationCommand = new RelayCommand(param => NavigateToCreateObservation(param), param => IsButtonAvailable()); _addPatientCommand = new RelayCommand(param => ClickAddPatient(), param => true); _navigateToHomeCommand = new RelayCommand(param => NavigateToHome(), param => true); _deletePatientCommand = new RelayCommand(param => NavigateToDeletePatient(param), param => IsButtonAvailable()); /// Definit si les bouton de creation/suppression est disponible ou non if (NavigationMessenger.GetInstance().IsRWAccount) { IsAvailableRW = Visibility.Visible; } else { IsAvailableRW = Visibility.Hidden; } _listPatient = new ObservableCollection<ServicePatient.Patient>(); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { Debug.WriteLine("DEBUT"); ServicePatient.ServicePatientClient patientService = new ServicePatient.ServicePatientClient(); e.Result = patientService.GetListPatient(); }); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { Debug.WriteLine("FIN"); if (e.Cancelled) { } if (e.Error != null) { } if (e.Result == null) { } else { ServicePatient.Patient[] res = e.Result as ServicePatient.Patient[]; if (res != null) { foreach (ServicePatient.Patient item in res) { _listPatient.Add(item); } } else { } } }); worker.RunWorkerAsync(); }
public void FillListPatient() { ServicePatient.ServicePatientClient service = new ServicePatient.ServicePatientClient(); try { ServicePatient.Patient[] listPatient = service.GetListPatient(); this._allPatient = new List <Model.Patient>(); List <Model.Observation> listObs = new List <Model.Observation>(); foreach (ServicePatient.Patient pat in listPatient) { Model.Patient patient = new Model.Patient { Birth = pat.Birthday, Firstname = pat.Firstname, Name = pat.Name, Id = pat.Id }; if (pat.Observations != null) { foreach (ServicePatient.Observation obs in pat.Observations) { Model.Observation observation = new Model.Observation { Comments = obs.Comment, Date = obs.Date, Pic = obs.Pictures ?? new List <byte[]>().ToArray(), Prescriptions = obs.Prescription.ToList() ?? new List <string>(), Pressure = obs.BloodPressure, Weight = obs.Weight }; listObs.Add(observation); } patient.Obs = listObs; } patient.Name = FirstUpper(patient.Name); patient.Firstname = FirstUpper(patient.Firstname); patient.Birthday = pat.Birthday.ToString("dd/MM/yyyy"); this._allPatient.Add(patient); } ListPatient = new ObservableCollection <Model.Patient>(this._allPatient); } catch { MainWindow main = new MainWindow(); View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow; View.Patients view = new colle_tMedecine.View.Patients(); ViewModel.PatientsViewModel vm = new colle_tMedecine.ViewModel.PatientsViewModel(); view.DataContext = vm; main.navigate((UserControl)mainwindow.contentcontrol.Content, view); } }
public bool AddPatient(ServicePatient.Patient user) { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { return(client.AddPatient(user)); } } catch { throw new TimeoutException(); } }
public List<ServicePatient.Patient> GetListPatient() { List<ServicePatient.Patient> serviceListPatient = new List<ServicePatient.Patient>(); try { serviceListPatient = new ServicePatient.ServicePatientClient().GetListPatient().ToList(); } catch (Exception ex) { //traitement exception ... Debug.WriteLine(ex.Message); } return serviceListPatient; }
public bool DeletePatient(int id) { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { return(client.DeletePatient(id)); } } catch { throw new TimeoutException(); } }
public bool DeletePatient(int id) { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { return client.DeletePatient(id); } } catch { throw new TimeoutException(); } }
public bool AddPatient(ServicePatient.Patient user) { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { return client.AddPatient(user); } } catch { throw new TimeoutException(); } }
/// <summary> /// constructeur /// </summary> public PatientDeleteViewModel(Page lkView, int idpatient) { _linkedView = lkView; _deleteCommand = new RelayCommand(param => Delete(), param => IsDeleting()); _id = idpatient; ServicePatient.ServicePatientClient servicePatient = new ServicePatient.ServicePatientClient(); ServicePatient.Patient selectedpatient = servicePatient.GetPatient(_id); _name = selectedpatient.Name; _firstname = selectedpatient.Firstname; _birthday = selectedpatient.Birthday; }
/// <summary> /// constructeur /// </summary> public PatientDeleteViewModel(Page lkView, int idpatient) { _linkedView = lkView; _deleteCommand = new RelayCommand(param => Delete(), param => IsDeleting()); _id = idpatient; ServicePatient.ServicePatientClient servicePatient = new ServicePatient.ServicePatientClient(); ServicePatient.Patient selectedpatient = servicePatient.GetPatient(_id); _name = selectedpatient.Name; _firstname = selectedpatient.Firstname; _birthday = selectedpatient.Birthday; }
public void DeletePatient(object param) { Model.Patient patient = (Model.Patient)param; ServicePatient.ServicePatientClient service = new ServicePatient.ServicePatientClient(); try { service.DeletePatient(patient.Id); this._allPatient.Remove(patient); ListPatient = new ObservableCollection <Model.Patient>(_allPatient); } catch { ListPatient = new ObservableCollection <Model.Patient>(_allPatient); } }
public static void UpdatePatient(int id) { try { var spc = new ServicePatient.ServicePatientClient(); Patient = spc.GetPatient(id); _basicInformation = StringHelper.FullName(Patient.Firstname, Patient.Name) + " - " + String.Format("{0:dd/MM/yyyy}", Patient.Birthday); (App.ViewModels["PatientDetails"] as PatientDetailsViewModel).UpdateChart(); } catch (Exception) { } }
public ServicePatient.Patient[] GetListPatient() { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { ServicePatient.Patient[] listPatient = client.GetListPatient(); if (listPatient == null || listPatient.Count() == 0) throw new ArgumentNullException(); else return listPatient; } } catch { throw new TimeoutException(); } }
public ServicePatient.Patient GetPatient(int id) { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { ServicePatient.Patient patient = client.GetPatient(id); if (patient == null) throw new ArgumentNullException(); else return patient; } } catch { throw new TimeoutException(); } }
public void RefreshPatientList() { try { var spc = new ServicePatient.ServicePatientClient(); _patientList = spc.GetListPatient(); this._items.Clear(); foreach (ServicePatient.Patient p in _patientList) { this._items.Add(new Link { DisplayName = p.Name, Source = new Uri("Patient/" + p.Id, UriKind.Relative), }); } } catch (Exception) { } }
public ServicePatient.Patient[] GetListPatient() { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { ServicePatient.Patient[] listPatient = client.GetListPatient(); if (listPatient == null || listPatient.Count() == 0) { throw new ArgumentNullException(); } else { return(listPatient); } } } catch { throw new TimeoutException(); } }
public ServicePatient.Patient GetPatient(int id) { try { using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient()) { ServicePatient.Patient patient = client.GetPatient(id); if (patient == null) { throw new ArgumentNullException(); } else { return(patient); } } } catch { throw new TimeoutException(); } }
private void CreatePatient() { BackgroundWorker worker = new BackgroundWorker(); ServicePatient.Patient newPatient = new ServicePatient.Patient(); newPatient.Name = _name; newPatient.Firstname = _firstname; int d = 0; int m = 0; int y = 0; if (int.TryParse(_birthday, out d) && int.TryParse(_birthmonth, out m) && int.TryParse(_birthyear, out y)) { newPatient.Birthday = new DateTime(y, m, d); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { ServicePatient.ServicePatientClient servicePatient = new ServicePatient.ServicePatientClient(); Debug.WriteLine("DEBUT"); _iscreatingpatient = true; BackgroundWorker bg = s as BackgroundWorker; e.Result = servicePatient.AddPatient(newPatient); }); // TODO penser a mettre un comportement en fonction des differents cas notamment en cas de fail worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { Debug.WriteLine("FIN"); _iscreatingpatient = false; WaitingMessage = ""; if (e.Cancelled) { Debug.WriteLine("CANCELLED"); WaitingMessage = "L'opération a été annulée."; } if (e.Error != null) { Debug.WriteLine("ERROR"); WaitingMessage = "Erreur lors de la création : " + e.Error.Message; } bool? res = e.Result as bool?; if (res == null) { Debug.WriteLine("ERREUR COTE SERVEUR"); WaitingMessage = "Erreur côté serveur lors de la création. Veuillez recommencer"; } if (res == true) { WaitingMessage = "Création réussie"; View.PatientBrowserView window = new View.PatientBrowserView(); ViewModel.PatientBrowserViewModel vm = new PatientBrowserViewModel(window); window.DataContext = vm; _ns = NavigationService.GetNavigationService(_linkedView); _ns.Navigate(window); WaitingMessage = ""; } else { Debug.WriteLine("ECHEC DE LA CREATION"); WaitingMessage = "La création a échoué. Veuillez recommencer."; } }); worker.RunWorkerAsync(); WaitingMessage = "Création du patient"; } WaitingMessage = "Veuillez indiquer des dates valides (ex : 26 07 1989)"; }
/// <summary> /// constructeur /// </summary> public PatientBrowserViewModel(Page lkView) { _linkedView = lkView; _imageCommand = new RelayCommand(param => ImageAccess(param), param => true); _createObservationCommand = new RelayCommand(param => NavigateToCreateObservation(param), param => IsButtonAvailable()); _addPatientCommand = new RelayCommand(param => ClickAddPatient(), param => true); _navigateToHomeCommand = new RelayCommand(param => NavigateToHome(), param => true); _deletePatientCommand = new RelayCommand(param => NavigateToDeletePatient(param), param => IsButtonAvailable()); /// Definit si les bouton de creation/suppression est disponible ou non if (NavigationMessenger.GetInstance().IsRWAccount) { IsAvailableRW = Visibility.Visible; } else { IsAvailableRW = Visibility.Hidden; } _listPatient = new ObservableCollection <ServicePatient.Patient>(); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { Debug.WriteLine("DEBUT"); ServicePatient.ServicePatientClient patientService = new ServicePatient.ServicePatientClient(); e.Result = patientService.GetListPatient(); }); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { Debug.WriteLine("FIN"); if (e.Cancelled) { } if (e.Error != null) { } if (e.Result == null) { } else { ServicePatient.Patient[] res = e.Result as ServicePatient.Patient[]; if (res != null) { foreach (ServicePatient.Patient item in res) { _listPatient.Add(item); } } else { } } }); worker.RunWorkerAsync(); }
/// <summary> /// action permettant de supprimer un patient /// </summary> private void DeletePatient() { try { var spc = new ServicePatient.ServicePatientClient(); spc.DeletePatient(PatientViewModel.Patient.Id); Sb.Begin(); // Refresh patient list (App.ViewModels["PatientList"] as PatientListViewModel).RefreshPatientList(); } catch (Exception) { } }
/// <summary> /// Le clic sur le bouton permet de supprimer le patient /// </summary> private void Delete() { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { ServicePatient.ServicePatientClient servicePatient = new ServicePatient.ServicePatientClient(); Debug.WriteLine("DEBUT"); _isdeleting = true; BackgroundWorker bg = s as BackgroundWorker; e.Result = servicePatient.DeletePatient(_id); }); // TODO penser a mettre un comportement en fonction des differents cas notamment en cas de fail worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { Debug.WriteLine("FIN"); _isdeleting = false; WaitingMessage = ""; if (e.Cancelled) { Debug.WriteLine("CANCELLED"); WaitingMessage = "L'opération a été annulée."; } if (e.Error != null) { Debug.WriteLine("ERROR"); WaitingMessage = "Erreur lors de la suppression : " + e.Error.Message; } bool? res = e.Result as bool?; if (res == null) { Debug.WriteLine("ERREUR COTE SERVEUR"); WaitingMessage = "Erreur côté serveur lors de la suppression. Veuillez recommencer"; } if (res == true) { WaitingMessage = "Suppression réussie"; View.PatientBrowserView window = new View.PatientBrowserView(); ViewModel.PatientBrowserViewModel vm = new PatientBrowserViewModel(window); window.DataContext = vm; _ns = NavigationService.GetNavigationService(_linkedView); _ns.Navigate(window); WaitingMessage = ""; } else { Debug.WriteLine("ECHEC DE LA SUPPRESSION"); WaitingMessage = "La suppression a échoué. Veuillez recommencer."; } }); worker.RunWorkerAsync(); WaitingMessage = "Suppression du patient"; }
/// <summary> /// action permettant de créer un patient /// </summary> private void CreatePatient() { try { Error = ""; Success = ""; // We check that all fields are filled CheckFields(); // Check that patient didn't already exist foreach(var patient in (App.ViewModels["PatientList"] as PatientListViewModel).PatientList) { if (patient.Firstname.Equals(_patient.Firstname) && patient.Name.Equals(_patient.Name) && patient.Birthday.Equals(_patient.Birthday)) { throw new Exception("Ce patient existe déjà !"); } } _patient.Observations = new List<Observation>().ToArray(); var spc = new ServicePatient.ServicePatientClient(); spc.AddPatient(_patient); Success = "Le patient \"" + StringHelper.FullName(_patient.Firstname, _patient.Name) + "\" a été bien été ajouté !"; // Reset fields ResetFields(); // Refresh patient list (App.ViewModels["PatientList"] as PatientListViewModel).RefreshPatientList(); } catch (Exception ex) { Error = ex.Message; } }
private void CreatePatient() { BackgroundWorker worker = new BackgroundWorker(); ServicePatient.Patient newPatient = new ServicePatient.Patient(); newPatient.Name = _name; newPatient.Firstname = _firstname; int d = 0; int m = 0; int y = 0; if (int.TryParse(_birthday, out d) && int.TryParse(_birthmonth, out m) && int.TryParse(_birthyear, out y)) { newPatient.Birthday = new DateTime(y, m, d); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { ServicePatient.ServicePatientClient servicePatient = new ServicePatient.ServicePatientClient(); Debug.WriteLine("DEBUT"); _iscreatingpatient = true; BackgroundWorker bg = s as BackgroundWorker; e.Result = servicePatient.AddPatient(newPatient); }); // TODO penser a mettre un comportement en fonction des differents cas notamment en cas de fail worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { Debug.WriteLine("FIN"); _iscreatingpatient = false; WaitingMessage = ""; if (e.Cancelled) { Debug.WriteLine("CANCELLED"); WaitingMessage = "L'opération a été annulée."; } if (e.Error != null) { Debug.WriteLine("ERROR"); WaitingMessage = "Erreur lors de la création : " + e.Error.Message; } bool?res = e.Result as bool?; if (res == null) { Debug.WriteLine("ERREUR COTE SERVEUR"); WaitingMessage = "Erreur côté serveur lors de la création. Veuillez recommencer"; } if (res == true) { WaitingMessage = "Création réussie"; View.PatientBrowserView window = new View.PatientBrowserView(); ViewModel.PatientBrowserViewModel vm = new PatientBrowserViewModel(window); window.DataContext = vm; _ns = NavigationService.GetNavigationService(_linkedView); _ns.Navigate(window); WaitingMessage = ""; } else { Debug.WriteLine("ECHEC DE LA CREATION"); WaitingMessage = "La création a échoué. Veuillez recommencer."; } }); worker.RunWorkerAsync(); WaitingMessage = "Création du patient"; } WaitingMessage = "Veuillez indiquer des dates valides (ex : 26 07 1989)"; }
public void FillListPatient() { ServicePatient.ServicePatientClient service = new ServicePatient.ServicePatientClient(); try { ServicePatient.Patient[] listPatient = service.GetListPatient(); this._allPatient = new List<Model.Patient>(); List<Model.Observation> listObs = new List<Model.Observation>(); foreach (ServicePatient.Patient pat in listPatient) { Model.Patient patient = new Model.Patient { Birth = pat.Birthday, Firstname = pat.Firstname, Name = pat.Name, Id = pat.Id }; if (pat.Observations != null) { foreach (ServicePatient.Observation obs in pat.Observations) { Model.Observation observation = new Model.Observation { Comments = obs.Comment, Date = obs.Date, Pic = obs.Pictures ?? new List<byte[]>().ToArray(), Prescriptions = obs.Prescription.ToList() ?? new List<string>(), Pressure = obs.BloodPressure, Weight = obs.Weight }; listObs.Add(observation); } patient.Obs = listObs; } patient.Name = FirstUpper(patient.Name); patient.Firstname = FirstUpper(patient.Firstname); patient.Birthday = pat.Birthday.ToString("dd/MM/yyyy"); this._allPatient.Add(patient); } ListPatient = new ObservableCollection<Model.Patient>(this._allPatient); } catch { MainWindow main = new MainWindow(); View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow; View.Patients view = new colle_tMedecine.View.Patients(); ViewModel.PatientsViewModel vm = new colle_tMedecine.ViewModel.PatientsViewModel(); view.DataContext = vm; main.navigate((UserControl)mainwindow.contentcontrol.Content, view); } }
/// <summary> /// Le clic sur le bouton permet de supprimer le patient /// </summary> private void Delete() { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { ServicePatient.ServicePatientClient servicePatient = new ServicePatient.ServicePatientClient(); Debug.WriteLine("DEBUT"); _isdeleting = true; BackgroundWorker bg = s as BackgroundWorker; e.Result = servicePatient.DeletePatient(_id); }); // TODO penser a mettre un comportement en fonction des differents cas notamment en cas de fail worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { Debug.WriteLine("FIN"); _isdeleting = false; WaitingMessage = ""; if (e.Cancelled) { Debug.WriteLine("CANCELLED"); WaitingMessage = "L'opération a été annulée."; } if (e.Error != null) { Debug.WriteLine("ERROR"); WaitingMessage = "Erreur lors de la suppression : " + e.Error.Message; } bool?res = e.Result as bool?; if (res == null) { Debug.WriteLine("ERREUR COTE SERVEUR"); WaitingMessage = "Erreur côté serveur lors de la suppression. Veuillez recommencer"; } if (res == true) { WaitingMessage = "Suppression réussie"; View.PatientBrowserView window = new View.PatientBrowserView(); ViewModel.PatientBrowserViewModel vm = new PatientBrowserViewModel(window); window.DataContext = vm; _ns = NavigationService.GetNavigationService(_linkedView); _ns.Navigate(window); WaitingMessage = ""; } else { Debug.WriteLine("ECHEC DE LA SUPPRESSION"); WaitingMessage = "La suppression a échoué. Veuillez recommencer."; } }); worker.RunWorkerAsync(); WaitingMessage = "Suppression du patient"; }
public void DeletePatient(object param) { Model.Patient patient = (Model.Patient)param; ServicePatient.ServicePatientClient service = new ServicePatient.ServicePatientClient(); try { service.DeletePatient(patient.Id); this._allPatient.Remove(patient); ListPatient = new ObservableCollection<Model.Patient>(_allPatient); } catch { ListPatient = new ObservableCollection<Model.Patient>(_allPatient); } }