コード例 #1
0
 public bool AddPatient(ServicePatient.Patient user)
 {
     try
     {
         using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient())
         {
             return(client.AddPatient(user));
         }
     }
     catch
     {
         throw new TimeoutException();
     }
 }
コード例 #2
0
ファイル: Patient.cs プロジェクト: yoan-durand/MTIHospital
        public bool AddPatient(ServicePatient.Patient user)
        {
            try
            {

                using (ServicePatient.ServicePatientClient client = new ServicePatient.ServicePatientClient())
                {
                    return client.AddPatient(user);
                }
            }
            catch
            {
                throw new TimeoutException();
            }
        }
コード例 #3
0
        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)";
        }
コード例 #4
0
        /// <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;
            }
        }
コード例 #5
0
        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)";
        }