private bool abortActionOnPendingSelectedPatientEdit()
        {
            ViewModelPatient selectedPatient = patientsListView.SelectedItem as ViewModelPatient;
            bool             retValue        = abortActionOnPendingPatientEdit(selectedPatient);

            return(retValue);
        }
 bool patientVM_CheckDuplicateId(ViewModelPatient patient)
 {
     try
     {
         string id = patient.Id;
         foreach (ViewModelPatient existingPatient in _patients)
         {
             if (existingPatient == patient)
             {
                 continue;
             }
             if (existingPatient.Id == id)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         // MSOTService.IMSOTLog.HandleError(DisplayName, "Exception checking patient id: " + ex.Message);
         System.Windows.MessageBox.Show("Exception checking  patient id : " + ex.Message);
         return(false);
     }
 }
 private void selectAndScrollToPatientListViewItem(ViewModelPatient patient)
 {
     if (patient != null)
     {
         patientsListView.SetCurrentValue(ListView.SelectedItemProperty, patient);
         patientsListView.ScrollIntoView(patient);
     }
 }
 protected void AfterInitialize()
 {
     _patients         = new ObservableCollection <ViewModelPatient>();
     _selectedPatient  = null;
     _activePatient    = null;
     _operator         = Environment.UserName;
     _previousOperator = "";
     //           base.AfterInitialize();
     System.Windows.MessageBox.Show("Now dafterinitialize is called");
 }
Example #5
0
        bool OnCheckDuplicateId(ViewModelPatient patient)
        {
            CheckDuplicateIdEventHandler handler = CheckDuplicateId;

            if (handler != null)
            {
                return(handler(patient));
            }
            else
            {
                return(false);
            }
        }
        private bool abortActionOnPendingPatientEdit(ViewModelPatient patient)
        {
            bool retValue = false;

            if (patient != null)
            {
                {
                    FocusLastInputElement();
                }
            }

            return(true);
        }
        void patientVM_NewPatientSaved(object sender, EventArgs e)
        {
            try
            {
                ViewModelPatient patient = sender as ViewModelPatient;
                string           message = "Patient " + patient.FullName + " created.";
                string           caption = "Notice";

                DateTime existingPatientBirthDate;
                DateTime newPatientBirthDate;

                if (patient.BirthDate == null)
                {
                    return;
                }

                newPatientBirthDate = (DateTime)patient.BirthDate;

                foreach (ViewModelPatient existingPatient in _patients)
                {
                    if (existingPatient == patient)
                    {
                        continue;
                    }

                    if (existingPatient.BirthDate == null)
                    {
                        continue;
                    }

                    existingPatientBirthDate = (DateTime)existingPatient.BirthDate;

                    if (existingPatientBirthDate.Date == newPatientBirthDate.Date &&
                        existingPatient.FirstName == patient.FirstName &&
                        existingPatient.LastName == patient.LastName)
                    {
                        message += "\r\n\r\nPatient with same last name, first name and birth date already exists. Please modify patient information if necessary.";
                        caption  = "Warning";
                        break;
                    }
                }

                //MSOTService.NotifyUserOnAction(message, caption, UserNotificationType.Warning, false);
                System.Windows.MessageBox.Show("Warning: " + message);
            }
            catch (Exception ex)
            {
                //MSOTService.IMSOTLog.HandleError(DisplayName, "Exception checking for duplicate patient entries: " + ex.Message);
                System.Windows.MessageBox.Show("Exception checking for duplicate patient entries: " + ex.Message);
            }
        }
 void patientVM_DiscardNewPatient(object sender, EventArgs e)
 {
     try
     {
         ViewModelPatient patient = sender as ViewModelPatient;
         bool             deleted = true;//MSOTService.IProjectManager.DeletePatientStudy(patient.PatientFilePath);
         if (deleted)
         {
             Patients.Remove(patient);
         }
     }
     catch (Exception ex)
     {
         //MSOTService.IMSOTLog.HandleError(DisplayName, "Exception deleting patient: " + ex.Message);
         System.Windows.MessageBox.Show("Exception checking if patient id exists: " + ex.Message);
     }
 }
        public void NewPatient()
        {
            try
            {
                string newPatientStudyFilePath;
                newPatientStudyFilePath = CreateNewPatientStudy();

                if (string.IsNullOrWhiteSpace(newPatientStudyFilePath))
                {
                    return;
                }

                string newPatientStudyName = Path.GetFileNameWithoutExtension(newPatientStudyFilePath);
                string studyPath           = Path.GetDirectoryName(newPatientStudyFilePath);

                string           patientFilePath = Path.Combine(studyPath, newPatientStudyName + _patientFileNameExtension);
                DataModelPatient patientDM       = new DataModelPatient(patientFilePath);
                patientDM.Id = getNextAvailablePatientId();
                //DataModelSerialization.SaveToPath(patientDM, patientDM.PatientFilePath, Log);
                System.Windows.MessageBox.Show("Hier sollte gesaved werden");
                ViewModelPatient patientVM = new ViewModelPatient();
                //patientVM.InitializePlugin(patientDM.FriendlyName, new DataModelCatalogItem(patientDM), this);
                //patientVM.CommandLoad.Execute(null);
                patientVM.IsNewPatient       = true;
                patientVM.DiscardNewPatient += patientVM_DiscardNewPatient;
                patientVM.CheckDuplicateId  += patientVM_CheckDuplicateId;
                patientVM.NewPatientSaved   += patientVM_NewPatientSaved;
                _patients.Insert(0, patientVM);
                SelectedPatient = _patients[0];
                SelectedPatient.RefreshIsDuplicateId();
            }
            catch (Exception ex)
            {
                //MSOTService.IMSOTLog.HandleError(DisplayName, "Exception creating new patient: " + ex.Message);
                System.Windows.MessageBox.Show("Exception creating new patient: " + ex.Message);
            }
        }
Example #10
0
        private void gridViewColumnHeaderClickedHandler(object sender, MouseButtonEventArgs e)
        {
            try
            {
                GridViewColumnHeader headerClicked = sender as GridViewColumnHeader;
                ListSortDirection    direction;
                if (headerClicked != null)
                {
                    if (headerClicked != _lastHeaderClicked)
                    {
                        direction = ListSortDirection.Ascending;
                    }
                    else
                    {
                        if (_lastDirection == ListSortDirection.Ascending)
                        {
                            direction = ListSortDirection.Descending;
                        }
                        else
                        {
                            direction = ListSortDirection.Ascending;
                        }
                    }

                    if (_lastHeaderClicked != null)
                    {
                        _lastHeaderClicked.Column.HeaderTemplate = null;
                    }

                    if (direction == ListSortDirection.Ascending)
                    {
                        headerClicked.Column.HeaderTemplate =
                            Resources["HeaderTemplateArrowUp"] as DataTemplate;
                    }
                    else
                    {
                        headerClicked.Column.HeaderTemplate =
                            Resources["HeaderTemplateArrowDown"] as DataTemplate;
                    }

                    List <string> sortingParamNames = new List <string>();
                    sortingParamNames.Add(headerClicked.Tag.ToString());

                    if (headerClicked == lastNameGridViewColumnHeader)
                    {
                        sortingParamNames.Add(firstNameGridViewColumnHeader.Tag.ToString());
                    }
                    else if (headerClicked == firstNameGridViewColumnHeader)
                    {
                        sortingParamNames.Add(lastNameGridViewColumnHeader.Tag.ToString());
                    }

                    if (headerClicked != lastExamGridViewColumnHeader)
                    {
                        sortingParamNames.Add(lastExamGridViewColumnHeader.Tag.ToString());
                    }

                    clearRefreshPatientListViewSorting(sortingParamNames, direction);

                    _lastHeaderClicked = headerClicked;
                    _lastDirection     = direction;

                    ViewModelPatient selected = patientsListView.SelectedItem as ViewModelPatient;
                    selectAndScrollToPatientListViewItem(selected);
                }
            }
            catch { }
        }
        public void Initiate(string rootDirectory)
        {
            try
            {
                if (!Directory.Exists(rootDirectory))
                {
                    System.Windows.MessageBox.Show("Couldn't load patient list.", "Directory doesn't exist: " + rootDirectory);
                    return;
                }

                string[] patientsPaths = Directory.GetDirectories(rootDirectory);

                string           patientMetaXMLPath;
                string           patientStudyName;
                string           studyNodePath;
                DataModelPatient patientDM;
                foreach (string path in patientsPaths)
                {
                    patientStudyName   = Path.GetFileName(path);
                    patientMetaXMLPath = Path.Combine(path, patientStudyName + _patientFileNameExtension);

                    studyNodePath = Path.Combine(path, patientStudyName + studyParameters.StudyFileExtension);
                    if (!File.Exists(studyNodePath))
                    {
                        continue;
                    }

                    if (File.Exists(patientMetaXMLPath))
                    {
                        //patientDM = DataModelSerialization.LoadFromPath<DataModelPatient>(patientMetaXMLPath, Log);
                        //TODO Remove PatientSex.O enum
                        //                       if (patientDM.Sex == PatientSex.O)
                        //                       {
                        //                           patientDM.Sex = PatientSex.M;
                        ////                           DataModelSerialization.SaveToPath(patientDM, patientMetaXMLPath, Log);
                        //                       }
                        //                       patientDM.PatientFilePath = patientMetaXMLPath;
                        ViewModelPatient patientVM = new ViewModelPatient();
                        //patientVM.InitializePlugin(patientDM.FriendlyName, new DataModelCatalogItem(patientDM), this);
                        //patientVM.CommandLoad.Execute(null);
                        patientVM.CheckDuplicateId += patientVM_CheckDuplicateId;
                        _patients.Add(patientVM);
                    }

                    //added for testing, will create a default patient file .ptm for every study found in RootDirectory
                    //else
                    //{
                    //    random rg = new random();
                    //    datamodelpatient mockpatientdm = new datamodelpatient()
                    //    {
                    //        birthdate = datetime.now,
                    //        comment = "automatically created patient meta file.",
                    //        creationtime = datetime.now,
                    //        firstname = "first " + patientstudyname,
                    //        lastname = "last " + patientstudyname,
                    //        friendlyname = "friendly " + patientstudyname,
                    //        sex = (patientsex)(rg.next(3)),
                    //        lastexam = datetime.minvalue,
                    //        id = patientstudyname,
                    //        patientfilepath = patientmetaxmlpath
                    //    };
                    //    datamodelserialization.savetopath(mockpatientdm, patientmetaxmlpath, log);
                    //    viewmodelpatient patientvm = new viewmodelpatient();
                    //    patientvm.initializeplugin(mockpatientdm.friendlyname, new datamodelcatalogitem(mockpatientdm), this);
                    //    patientvm.commandload.execute(null);
                    //    _patients.add(patientvm);
                    //}
                }
            }
            catch (Exception ex)
            {
                //MSOTService.IMSOTLog.HandleError(EnumLogType.Warning, DisplayName, "Exception initiating patients manager: " + ex.Message);
                System.Windows.MessageBox.Show("Exception initiating patients manager: " + ex.Message);
            }
        }