/// <summary>
        /// Initializes a new instance of the PatientsListViewModel class.
        /// </summary>
        public PatientSheetViewModel()
        {
            ViewModelLocator vml = new ViewModelLocator();
             WindowContent = vml.PatientSheetView;
             WindowContent.DataContext = this;

            Selected = false;
            BackCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                Selected = false;
                SelectedObservation = null;
                vm.Window.DataContext = vm.PatientList;
            });

            AddCommand = new RelayCommand(() => {
                CanViewAdd = true;
            });

            TrashPatientCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                bool delete = BusinessManagement.Patient.DeletePatient(PatientId);
                vm.PatientList.PatientListUpdate();
                Selected = false;
                SelectedObservation = null;
                vm.Window.DataContext = vm.PatientList;
            });

            PatientBloodPressureSerie = new ObservableCollection<Serie>
            {
                new LineSerie
                {
                    Name = "BloodPressure",
                    PrimaryValues = new ObservableCollection<double> { 0}
                }
            };

            PatientTemperatureSerie = new ObservableCollection<Serie>
            {
                new LineSerie
                {
                    Name = "Temperature",
                    PrimaryValues = new ObservableCollection<double> { 38},
                    Color=Color.FromArgb(255,255,0,0)
                }
            };

            CanViewAdd = false;

            View.AddObservationView addObservationView = new View.AddObservationView();
            AddObservationContent = addObservationView;
            addObservationView.DataContext = vml.AddObservation;
            s = new ServiceLiveManager(this);
        }
示例#2
0
        private void Login_UserChangedEventHandler(object sender, ServiceUser.User e)
        {
            ViewModelLocator vm = new ViewModelLocator();

            vm.Account.UserConnectedChangedEventHandler(sender, e);
            vm.Home.UserConnectedChangedEventHandler(sender, e);
            vm.Sidebar.UserConnectedChangedEventHandler(sender, e);
            vm.StaffListView.UserConnectedChangedEventHandler(sender, e);
            vm.StaffSheet.UserConnectedChangedEventHandler(sender, e);
            vm.PatientList.UserConnectedChangedEventHandler(sender, e);
            vm.PatientSheet.UserConnectedChangedEventHandler(sender, e);
        }
示例#3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            ViewModelLocator vm = new ViewModelLocator();

            vm.Login.UserChangedEventHandler += Login_UserChangedEventHandler;

            LoginViewModel loginViewModel = vm.Login;

            vm.Window.sidebar.DataContext = vm.Sidebar;
            vm.Window.DataContext = loginViewModel;
            vm.Window.Show();
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the LoginViewModel class.
        /// </summary>
        public LoginViewModel()
        {
            Loading = false;
            LoginError = false;

            //Debug hack
            Login = "******";
            Password = "******";

            _connectionCommand = new RelayCommand(async () =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                Loading = true;
                try
                {
                    bool isConnected = await BusinessManagement.User.ConnectAsync(Login, Password);

                    if (isConnected)
                    {
                        // Set connected User
                        ServiceUser.User User = await BusinessManagement.User.GetUserAsync(Login);
                        await Application.Current.Dispatcher.InvokeAsync(() => { _userChangedEventHandler(this, User); });

                        // Reset error handling
                        LoginError = false;

                        // Switch view to home
                        vm.Window.DataContext = vm.Home;
                    }
                    else
                    {
                        // Wrong pass dude !
                        LoginError = true;
                    }
                }
                catch (Exception)
                {
                    // Server error
                }
                finally
                {
                    Loading = false;
                }
            }, () => !Loading && CanLogin);

            WindowContent = new View.LoginView();
            WindowContent.DataContext = this;
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the LoginViewModel class.
        /// </summary>
        public HomeViewModel()
        {
            WindowContent = new View.HomeView();
            WindowContent.DataContext = this;

            PatientConsult = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.PatientList;
            });

            StaffConsult = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.StaffListView;
            });
        }
        /// <summary>
        /// Initializes a new instance of the StaffSheetViewModel class.
        /// </summary>
        public StaffSheetViewModel()
        {
            WindowContent = new View.StaffSheetView();
             WindowContent.DataContext = this;

            BackCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.StaffListView;
            });

            TrashUserCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                bool delete = BusinessManagement.User.DeleteUser(SelectedLogin);
                vm.StaffListView.UserListUpdate();
                vm.Window.DataContext = vm.StaffListView;
            });
        }
        public SidebarViewModel()
        {
            Connected = false;

            AccountCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.Account;
            }, () => Connected);

            LogoutCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.Login;
                Connected = false;
            }, () => Connected);

            HomeCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.Home;
            }, () => Connected);
        }
示例#8
0
        /// <summary>
        /// Initializes a new instance of the AddStaffViewModel class.
        /// </summary>
        public AddStaffViewModel()
        {
            CanSubmit = false;
            Validator.AddRequiredRule(() => Firstname, "Le prénom ne peut pas être vide");
            Validator.AddRequiredRule(() => Name, "Le prénom ne peut pas être vide");

            Validator.AddRequiredRule(() => Login, "Le login ne peut pas être vide");
            Validator.AddRule(() => Login,
                              () => RuleResult.Assert(Login != null && Login != "" && Login.Split(' ').Length == 1, "Le login doit être composé d'un seul mot"));


            Validator.AddRequiredRule(() => Role, "Le role ne peut pas être vide");

            Validator.AddRequiredRule(() => Password, "Le mot de passe ne peut pas être vide");
            Validator.AddRule(() => Password,
                              () => RuleResult.Assert(Password.Length >= 4, "Le mot de passe doit contenir au moins 4 caractères"));

            CancelCommand = new RelayCommand(() =>
            {
                CancelPopup();
            });

            ChoosePictureCommand = 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.StaffListView.DissmissPopup();
                if (openDialog.ShowDialog().Value)
                {
                    vml.StaffListView.CanViewAdd = true;
                    Image = new BitmapImage(new Uri(openDialog.FileName));
                }
                vml.StaffListView.CanViewAdd = true;
            });

            CreateCommand = new RelayCommand(() =>
            {
                User user      = new User();
                user.Firstname = Firstname;
                user.Name      = Name;
                user.Login     = Login;
                user.Role      = Role;
                user.Picture   = Tools.ConvertImage(Image);
                user.Pwd       = Password;
                try
                {
                    BusinessManagement.User.AddUser(user);
                    ViewModelLocator vml = new ViewModelLocator();
                    vml.StaffListView.UserListUpdate();
                    CancelPopup();
                }
                catch (Exception)
                {
                    // ErrorMessage = "La taille de l'image est trop grande";
                }
            });

            Image    = new BitmapImage(new Uri("/Assets/anonym.jpg", UriKind.Relative));
            ListRole = new ObservableCollection <string>()
            {
                "Infirmière", "Medecin", "Chirurgien", "Radiologue"
            };
        }
        public StaffListViewModel()
        {
            BackCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.Home;
            });

            StaffDetails = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.StaffSheet.UserSelectedEventHandler(SelectedRecord);
                vm.Window.DataContext = vm.StaffSheet;
            });

            AddCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                CanViewAdd = !CanViewAdd;
            });

            StaffList = null;
            CanAdd = true;

            ViewModelLocator vml = new ViewModelLocator();
            View.AddStaffView addStaffView = new View.AddStaffView();
            AddUserContent = addStaffView;
            addStaffView.DataContext = vml.AddStaff;

            WindowContent = new View.StaffListView();
            WindowContent.DataContext = this;
        }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the AddStaffViewModel class.
        /// </summary>
        public AddStaffViewModel()
        {
            CanSubmit = false;
            Validator.AddRequiredRule(() => Firstname, "Le prénom ne peut pas être vide");
            Validator.AddRequiredRule(() => Name, "Le prénom ne peut pas être vide");

            Validator.AddRequiredRule(() => Login, "Le login ne peut pas être vide");
            Validator.AddRule(() => Login,
                              () => RuleResult.Assert(Login != null && Login != "" && Login.Split(' ').Length == 1, "Le login doit être composé d'un seul mot"));

            Validator.AddRequiredRule(() => Role, "Le role ne peut pas être vide");

            Validator.AddRequiredRule(() => Password, "Le mot de passe ne peut pas être vide");
            Validator.AddRule(() => Password,
                              () => RuleResult.Assert(Password.Length >= 4, "Le mot de passe doit contenir au moins 4 caractères"));

            CancelCommand = new RelayCommand(() =>
            {
                CancelPopup();
            });

            ChoosePictureCommand = 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.StaffListView.DissmissPopup();
                if (openDialog.ShowDialog().Value)
                {
                    vml.StaffListView.CanViewAdd = true;
                    Image = new BitmapImage(new Uri(openDialog.FileName));
                }
                vml.StaffListView.CanViewAdd = true;
            });

            CreateCommand = new RelayCommand(() =>
            {
                User user = new User();
                user.Firstname = Firstname;
                user.Name = Name;
                user.Login = Login;
                user.Role = Role;
                user.Picture = Tools.ConvertImage(Image);
                user.Pwd = Password;
                try
                {
                    BusinessManagement.User.AddUser(user);
                    ViewModelLocator vml = new ViewModelLocator();
                    vml.StaffListView.UserListUpdate();
                    CancelPopup();
                }
                catch (Exception)
                {
                    // ErrorMessage = "La taille de l'image est trop grande";
                }
            });

            Image = new BitmapImage(new Uri("/Assets/anonym.jpg", UriKind.Relative));
            ListRole = new ObservableCollection<string>() { "Infirmière", "Medecin", "Chirurgien", "Radiologue" };
        }
示例#11
0
 public void CancelPopup()
 {
     _firstname = "";
     RaisePropertyChanged("Firstname");
     _name = "";
     RaisePropertyChanged("Name");
     _login = "";
     RaisePropertyChanged("Login");
     _role = "";
     RaisePropertyChanged("Role");
     _password = "";
     RaisePropertyChanged("Password");
     CanSubmit = false;
     Image = new BitmapImage(new Uri("/Assets/anonym.jpg", UriKind.Relative));
     ViewModelLocator vml = new ViewModelLocator();
     vml.StaffListView.DissmissPopup();
 }
        public void CancelPopup()
        {
            ViewModelLocator vml = new ViewModelLocator();
            _addfirstname = "";
            RaisePropertyChanged("AddFirstname");
            _addname = "";
            RaisePropertyChanged("AddName");
            _addBirthday = DateTime.Now;
            RaisePropertyChanged("AddBirthday");
            CanSubmit = false;
            RaisePropertyChanged("CanSubmit");

            vml.PatientList.DissmissPopup();
        }
示例#13
0
        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;
        }
 public void PatientListUpdate()
 {
     ViewModelLocator vml = new ViewModelLocator();
     vml.PatientList.PatientListUpdate();
 }
 public void CancelPopup()
 {
     Prescriptions = new ObservableCollection<string>();
     Pictures = new ObservableCollection<BitmapImage>();
     ViewModelLocator vml = new ViewModelLocator();
     vml.PatientSheet.DissmissPopup();
     _poids = "";
     RaisePropertyChanged("Poids");
     _date = DateTime.Now;
     RaisePropertyChanged("Date");
     _bloodpressure = "";
     RaisePropertyChanged("BloodPressure");
     _comment = "";
     RaisePropertyChanged("Comment");
     AddPrescription = "";
     CanSubmit = false;
     RaisePropertyChanged("CanSubmit");
 }
        public PatientListViewModel()
        {


            BackCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.Window.DataContext = vm.Home;
            });

            PatientDetails = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();
                vm.PatientSheet.PatientSelectedEventHandler(SelectedRecord);
                vm.Window.DataContext = vm.PatientSheet;
            });

            AddPatientCommand = new RelayCommand(() =>
            {
                ViewModelLocator vm = new ViewModelLocator();

                CanViewAdd = !CanViewAdd;
            });           

            PatientsList = null;
            CanAdd = true;
            CanViewAdd = false;

            ViewModelLocator vml = new ViewModelLocator();
            View.AddPatientView addPatientView = new View.AddPatientView();
            AddPatientContent = addPatientView;
            addPatientView.DataContext = vml.AddPatient;

            WindowContent = new View.PatientListView();
            WindowContent.DataContext = this;
        }
示例#18
0
        public void PatientListUpdate()
        {
            ViewModelLocator vml = new ViewModelLocator();

            vml.PatientList.PatientListUpdate();
        }