private void AddObservation() { ServiceObservation.ServiceObservationClient client = new ServiceObservation.ServiceObservationClient(); ServiceObservation.Observation obs = new ServiceObservation.Observation(); obs.BloodPressure = BloodPressure; obs.Comment = Comment; obs.Prescription = Prescriptions.ToArray(); obs.Weight = Weight; obs.Pictures = ConverttobyteArray().ToArray(); obs.Date = Date; try { client.AddObservation(Patient.Id, obs); View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow; View.NewObservation view = new colle_tMedecine.View.NewObservation(); ViewModel.NewObservationViewModel vm = new colle_tMedecine.ViewModel.NewObservationViewModel(Patient); view.DataContext = vm; mainwindow.contentcontrol.Content = view; } catch { View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow; View.NewObservation view = new colle_tMedecine.View.NewObservation(); ViewModel.NewObservationViewModel vm = new colle_tMedecine.ViewModel.NewObservationViewModel(Patient); view.DataContext = vm; mainwindow.contentcontrol.Content = view; } }
public ObservationSheetViewModel(Patient patientToDisplay, ServiceObservation.Observation observationToDisplay, MainWindowViewModel mainView = null) { this._patientToDisplay = patientToDisplay; this._observationToDisplay = observationToDisplay; this._mainView = mainView; base.DisplayName = $"Udokotela - {Firstname} {Name}"; this.BackCommand = new RelayCommand(param => DismissBack(), param => this._mainView != null && this._mainView.HasBackgroundContent()); }
public static bool AddObservation(int idPatient, ServiceObservation.Observation o) { try { ServiceObservation.ServiceObservationClient c = new ServiceObservation.ServiceObservationClient(); return(c.AddObservation(idPatient, o)); } catch (EndpointNotFoundException) { MessageBox.Show("Le serveur ne répond pas.", "Erreur"); return(false); } }
public bool AddObservation(int idPatient, ServiceObservation.Observation obs) { using (ServiceObservation.ServiceObservationClient client = new ServiceObservation.ServiceObservationClient()) { try { return(client.AddObservation(idPatient, obs)); } catch { throw new TimeoutException(); } } }
private void ShowObservation(Observation observation) { ServiceObservation.Observation serviceObservation = new ServiceObservation.Observation() { BloodPressure = observation.BloodPressure, Comment = observation.Comment, Date = observation.Date, ExtensionData = observation.ExtensionData, Pictures = observation.Pictures, Prescription = observation.Prescription, Weight = observation.Weight }; UserControl observationView = new ObservationSheetView(this._patientToDisplay, serviceObservation, this._mainView); this._mainView.OverlayContent(observationView); }
public ObservationSheetView(Patient patient, ServiceObservation.Observation observation, MainWindowViewModel mainView) { InitializeComponent(); this.DataContext = new ObservationSheetViewModel(patient, observation, mainView); }
private void CreateObservation() { ServiceObservation.Observation newObs = new ServiceObservation.Observation(); int tmp = 0; if (Int32.TryParse(_weight, out tmp)) { newObs.Weight = tmp; } if (Int32.TryParse(_bloodPressure, out tmp)) { newObs.BloodPressure = tmp; } if (_comment != null) { newObs.Comment = _comment; } if (_arrayPrescription != null) { newObs.Prescription = _arrayPrescription.ToArray(); } if (_listDisplayedImages != null && _listDisplayedImages.Count != 0) { /// Le nombre d'images voulues utile pour creer le tableau statique int finalSize = _listDisplayedImages.Count; /// Le tableau d'images final byte[][] finalArrayImages = new byte[finalSize][]; ///Pour convertir nos images en byte[] ByteArrayConverter cv = new ByteArrayConverter(); for (int i = 0; i < finalSize; i++) { byte[] convertedImg = (byte[])cv.ConvertBack(_listDisplayedImages.ElementAt(i), null, null, null); finalArrayImages[i] = convertedImg; } newObs.Pictures = finalArrayImages; newObs.Date = DateTime.Now; } BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { ServiceObservation.ServiceObservationClient observService = new ServiceObservation.ServiceObservationClient(); e.Result = observService.AddObservation(_idPatient, newObs); }); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { WaitingMessage = ""; if (e.Cancelled) { WaitingMessage = "L'opération a été annulée."; } if (e.Error != null) { WaitingMessage = "Erreur lors de la création : " + e.Error.Message; } bool? resWebService = e.Result as bool?; if (resWebService.HasValue && resWebService.Value) { View.PatientBrowserView window = new View.PatientBrowserView(); ViewModel.PatientBrowserViewModel vm = new PatientBrowserViewModel(window); window.DataContext = vm; _ns = NavigationService.GetNavigationService(_linkedView); _ns.Navigate(window); } else { WaitingMessage = "Erreur côté serveur lors de la création. Veuillez recommencer"; } }); worker.RunWorkerAsync(); WaitingMessage = "Ajout de l'observation en cours"; }
private void CreateObservation() { ServiceObservation.Observation newObs = new ServiceObservation.Observation(); int tmp = 0; if (Int32.TryParse(_weight, out tmp)) { newObs.Weight = tmp; } if (Int32.TryParse(_bloodPressure, out tmp)) { newObs.BloodPressure = tmp; } if (_comment != null) { newObs.Comment = _comment; } if (_arrayPrescription != null) { newObs.Prescription = _arrayPrescription.ToArray(); } if (_listDisplayedImages != null && _listDisplayedImages.Count != 0) { /// Le nombre d'images voulues utile pour creer le tableau statique int finalSize = _listDisplayedImages.Count; /// Le tableau d'images final byte[][] finalArrayImages = new byte[finalSize][]; ///Pour convertir nos images en byte[] ByteArrayConverter cv = new ByteArrayConverter(); for (int i = 0; i < finalSize; i++) { byte[] convertedImg = (byte[])cv.ConvertBack(_listDisplayedImages.ElementAt(i), null, null, null); finalArrayImages[i] = convertedImg; } newObs.Pictures = finalArrayImages; newObs.Date = DateTime.Now; } BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler((object s, DoWorkEventArgs e) => { ServiceObservation.ServiceObservationClient observService = new ServiceObservation.ServiceObservationClient(); e.Result = observService.AddObservation(_idPatient, newObs); }); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s, RunWorkerCompletedEventArgs e) => { WaitingMessage = ""; if (e.Cancelled) { WaitingMessage = "L'opération a été annulée."; } if (e.Error != null) { WaitingMessage = "Erreur lors de la création : " + e.Error.Message; } bool?resWebService = e.Result as bool?; if (resWebService.HasValue && resWebService.Value) { View.PatientBrowserView window = new View.PatientBrowserView(); ViewModel.PatientBrowserViewModel vm = new PatientBrowserViewModel(window); window.DataContext = vm; _ns = NavigationService.GetNavigationService(_linkedView); _ns.Navigate(window); } else { WaitingMessage = "Erreur côté serveur lors de la création. Veuillez recommencer"; } }); worker.RunWorkerAsync(); WaitingMessage = "Ajout de l'observation en cours"; }
public AddObservationViewModel() { int parse = 0; Prescriptions = new ObservableCollection <string>(); Pictures = new ObservableCollection <BitmapImage>(); _date = DateTime.Now; RaisePropertyChanged("Date"); CanAddPrescription = false; Validator.AddRequiredRule(() => Date, "La date ne peut pas être vide"); Validator.AddRequiredRule(() => BloodPressure, "La pression sanguine ne peut pas être vide"); Validator.AddRule(() => BloodPressure, () => RuleResult.Assert(int.TryParse(BloodPressure, out parse), "La pression sanguine doit être un nombre")); Validator.AddRequiredRule(() => Poids, "Le poids ne peut pas être vide"); Validator.AddRule(() => Poids, () => RuleResult.Assert(int.TryParse(Poids, out parse), "Le poids doit être un nombre")); Validator.AddRule(() => Prescriptions, () => RuleResult.Assert(Prescriptions.Count > 0, "Il doit y avoir au moins une prescription")); CancelCommand = new RelayCommand(() => { CancelPopup(); }); ValidateAddCommand = new RelayCommand(() => { try { ViewModelLocator vml = new ViewModelLocator(); ServiceObservation.Observation o = new ServiceObservation.Observation(); o.BloodPressure = int.Parse(BloodPressure); o.Weight = int.Parse(Poids); o.Comment = Comment; o.Date = Date; o.Prescription = new List <string>(Prescriptions).ToArray(); List <byte[]> images = new List <byte[]>(); foreach (BitmapImage arr in Pictures) { images.Add(Tools.ConvertImage(arr)); } o.Pictures = images.ToArray(); BusinessManagement.Observation.AddObservation(vml.PatientSheet.PatientId, o); vml.PatientSheet.PatientUpdate(); vml.PatientList.PatientListUpdate(); CancelPopup(); } catch (Exception) {} }); AddPrescriptionCommand = new RelayCommand(() => { if (CanAddPrescription) { Prescriptions.Add(AddPrescription); AddPrescription = ""; UpdateSubmitButton(); } }); ReinitCommand = new RelayCommand(() => { Prescriptions = new ObservableCollection <string>(); }); AddObservationPicture = new RelayCommand(() => { OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "All Images|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.TIF;*.TIFF;*.PNG|BMP Files: (*.BMP; *.DIB; *.RLE) | *.BMP; *.DIB; *.RLE |" + "JPEG Files: (*.JPG; *.JPEG; *.JPE; *.JFIF)| *.JPG; *.JPEG; *.JPE; *.JFIF |GIF Files: (*.GIF) | *.GIF | " + "TIFF Files: (*.TIF; *.TIFF)| *.TIF; *.TIFF |" + "PNG Files: (*.PNG) | *.PNG |" + "All Files | *.* "; ViewModelLocator vml = new ViewModelLocator(); vml.PatientSheet.DissmissPopup(); if (openDialog.ShowDialog().Value) { vml.PatientSheet.CanViewAdd = true; Pictures.Add(new BitmapImage(new Uri(openDialog.FileName))); } vml.PatientSheet.CanViewAdd = true; }); DeletePictures = new RelayCommand(() => { Pictures = new ObservableCollection <BitmapImage>(); }); CanSubmit = false; }
public AddObservationViewModel() { int parse = 0; Prescriptions = new ObservableCollection<string>(); Pictures = new ObservableCollection<BitmapImage>(); _date = DateTime.Now; RaisePropertyChanged("Date"); CanAddPrescription = false; Validator.AddRequiredRule(() => Date, "La date ne peut pas être vide"); Validator.AddRequiredRule(() => BloodPressure, "La pression sanguine ne peut pas être vide"); Validator.AddRule(() => BloodPressure, () => RuleResult.Assert(int.TryParse(BloodPressure, out parse), "La pression sanguine doit être un nombre")); Validator.AddRequiredRule(() => Poids, "Le poids ne peut pas être vide"); Validator.AddRule(() => Poids, () => RuleResult.Assert(int.TryParse(Poids, out parse), "Le poids doit être un nombre")); Validator.AddRule(() => Prescriptions, () => RuleResult.Assert(Prescriptions.Count > 0, "Il doit y avoir au moins une prescription")); CancelCommand = new RelayCommand(() => { CancelPopup(); }); ValidateAddCommand = new RelayCommand(() => { try { ViewModelLocator vml = new ViewModelLocator(); ServiceObservation.Observation o = new ServiceObservation.Observation(); o.BloodPressure = int.Parse(BloodPressure); o.Weight = int.Parse(Poids); o.Comment = Comment; o.Date = Date; o.Prescription = new List<string>(Prescriptions).ToArray(); List<byte[]> images = new List<byte[]>(); foreach (BitmapImage arr in Pictures) images.Add(Tools.ConvertImage(arr)); o.Pictures = images.ToArray(); BusinessManagement.Observation.AddObservation(vml.PatientSheet.PatientId, o); vml.PatientSheet.PatientUpdate(); vml.PatientList.PatientListUpdate(); CancelPopup(); } catch (Exception){} }); AddPrescriptionCommand = new RelayCommand(() => { if (CanAddPrescription) { Prescriptions.Add(AddPrescription); AddPrescription = ""; UpdateSubmitButton(); } }); ReinitCommand = new RelayCommand(() => { Prescriptions = new ObservableCollection<string>(); }); AddObservationPicture = new RelayCommand(() => { OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "All Images|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.TIF;*.TIFF;*.PNG|BMP Files: (*.BMP; *.DIB; *.RLE) | *.BMP; *.DIB; *.RLE |" + "JPEG Files: (*.JPG; *.JPEG; *.JPE; *.JFIF)| *.JPG; *.JPEG; *.JPE; *.JFIF |GIF Files: (*.GIF) | *.GIF | " + "TIFF Files: (*.TIF; *.TIFF)| *.TIF; *.TIFF |" + "PNG Files: (*.PNG) | *.PNG |" + "All Files | *.* "; ViewModelLocator vml = new ViewModelLocator(); vml.PatientSheet.DissmissPopup(); if (openDialog.ShowDialog().Value) { vml.PatientSheet.CanViewAdd = true; Pictures.Add(new BitmapImage(new Uri(openDialog.FileName))); } vml.PatientSheet.CanViewAdd = true; }); DeletePictures = new RelayCommand(() => { Pictures = new ObservableCollection<BitmapImage>(); }); CanSubmit = false; }