void GetAllParticipants()
        {
            /*
             * var participantVMs = Array.ConvertAll(_repository.Participants.ToArray(),
             *  new Converter<Participant, ParticipantListItemViewModel>(p => new ParticipantListItemViewModel(Mapper.Map<ParticipantModel>(p))));
             * */
            var now       = DateTime.Now;
            int partCount = _repository.Participants.Count();
            List <ParticipantListItemViewModel> participantVMs = new List <ParticipantListItemViewModel>(partCount);

            foreach (var p in _repository.Participants//.Include("VaccinesAdministered").Include("ProtocolViolations").OrderByDescending(dp => dp.Id)
                     .Select(GetParticipantBaseMapExpression()))
            {
                p.StudyCentre = _repository.FindStudyCentre(p.CentreId);
                p.AgeDays     = (now - p.DateTimeBirth).Days;
                var newVm = new ParticipantListItemViewModel(p);
                participantVMs.Add(newVm);
            }

            _ageUpdater = AgeUpdatingMediator.GetService(participants: (from p in participantVMs
                                                                        where p.IsKnownDead != true && p.AgeDays <= ParticipantBaseModel.FollowToAge
                                                                        select(IBirthday) p),
                                                         capacity: partCount);
            _ageUpdater.OnAgeIncrement += OnNewAge;

            AllParticipants = new ListCollectionView(participantVMs)
            {
                CustomSort = new ParticipantIdSortDesc()
            };
            _groupByDataRequired  = true;
            _selectedDataRequired = (DataRequiredOption[])Enum.GetValues(typeof(DataRequiredOption));
            _selectedCentres      = _repository.GetCentresRequiringData();
            SetGrouping();
            //creating dispatchertimer so that screen is rendered before setting up the birthtime updating algorithms
        }
Example #2
0
 public DataSummaryViewModel(IRepository repository) : base(repository)
 {
     _participantData                          = _repository.GetParticipantSummary();
     ParticipantData                           = new ParticipantSummaryViewModel(_participantData);
     ScreenedPatientData                       = _repository.GetScreenedPatientSummary();
     _repository.ParticipantAdded             += _repository_ParticipantAdded;
     _repository.ParticipantUpdated           += _repository_ParticipantUpdated;
     _repository.ScreenedPatientAdded         += _repository_ScreenedPatientAdded;
     _repository.ProtocolViolationAddOrUpdate += _repository_ProtocolViolationAddOrUpdate;
     _ageService = AgeUpdatingMediator.GetService(repository);
     _ageService.OnAgeIncrement += OnNewAge;
 }
        void Cleanup()
        {
            if (_backupService != null)
            {
                _backupService.OnBackup -= OnBackupInterval;
                _backupService.Cleanup();
                _backupService = null;
            }
            AgeUpdatingMediator.Cleanup();
            var allPart = (AllParticipantsViewModel)Workspaces.FirstOrDefault(w => w is AllParticipantsViewModel); //should probably be with idisposable - I ahve a memory of this being problematic due to order of disposal

            if (allPart != null)
            {
                allPart.Dispose();
            }
            _transferLog = null;
        }