void HandleUpdateViolation(object sender, ProtocolViolationEventArgs e)
        {
            var assdVM = ((List <ParticipantListItemViewModel>)AllParticipants.SourceCollection)
                         .First(p => p.Id == e.Violation.ParticipantId);

            AllParticipants.EditItem(assdVM);
            assdVM.RecalculateDataRequired();
            AllParticipants.CommitEdit();
        }
        void HandleAddOrUpdateViolation(object sender, ProtocolViolationEventArgs e)
        {
            var assdVM = ((List <ParticipantListItemViewModel>)AllParticipants.SourceCollection)
                         .First(p => p.Id == e.Violation.ParticipantId);

            AllParticipants.EditItem(assdVM);
            if (e.EventType == CRUD.Updated)
            {
                assdVM.ProtocolViolations.Remove(assdVM.ProtocolViolations.First(v => v.Id == e.Violation.Id));
            }
            assdVM.ProtocolViolations.Add(e.Violation);
            assdVM.RecalculateDataRequired();
            AllParticipants.CommitEdit();
        }
 void OnNewAge(object sender, AgeIncrementingEventArgs e)
 {
     if (!(e.Participant is ParticipantListItemViewModel participant))
     {
         participant         = ((List <ParticipantListItemViewModel>)AllParticipants.SourceCollection).First(p => p.Id == e.Participant.Id);
         participant.AgeDays = e.Participant.AgeDays;
     }
     AllParticipants.EditItem(participant);
     if (participant.IsKnownDead == true || participant.AgeDays > 28)
     {
         e.Remove = true;
     }
     AllParticipants.CommitEdit();
 }
        void HandleParticipantUpdate(object sender, ParticipantEventArgs e)
        {
            var assdVM = ((List <ParticipantListItemViewModel>)AllParticipants.SourceCollection)
                         .First(p => p.Id == e.Participant.Id);

            AllParticipants.EditItem(assdVM);
            UpdateDemographics(e.Participant, assdVM);
            assdVM.VaccinesAdministered       = e.Participant.VaccinesAdministered;
            assdVM.UnsuccessfulFollowUps      = e.Participant.UnsuccessfulFollowUps;
            assdVM.OutcomeAt28Days            = e.Participant.OutcomeAt28Days;
            assdVM.DischargeDateTime          = e.Participant.DischargeDateTime;
            assdVM.DeathOrLastContactDateTime = e.Participant.DeathOrLastContactDateTime;
            assdVM.CauseOfDeath             = e.Participant.CauseOfDeath;
            assdVM.FollowUpBabyBCGReaction  = e.Participant.FollowUpBabyBCGReaction;
            assdVM.PermanentlyUncontactable = e.Participant.PermanentlyUncontactable;
            assdVM.MaternalBCGScar          = e.Participant.MaternalBCGScar;

            if (_updateWindow != null && ((ParticipantProgressViewModel)_updateWindow.DataContext).Id == assdVM.Id)
            {
                //this is here for data oversite, when update comes without having entered the data. For data collection sites, values should be the same and so updates will not be notified
                ParticipantProgressViewModel sp = (ParticipantProgressViewModel)_updateWindow.DataContext;
                UpdateDemographics(e.Participant, sp);
                sp.OutcomeAt28Days            = e.Participant.OutcomeAt28Days;
                sp.CauseOfDeath               = e.Participant.CauseOfDeath;
                sp.DeathOrLastContactDateTime = e.Participant.DeathOrLastContactDateTime;
                sp.DischargeDateTime          = e.Participant.DischargeDateTime;
                sp.LastContactWeight          = e.Participant.LastContactWeight;
                sp.LastWeightDate             = e.Participant.LastWeightDate;
                sp.OtherCauseOfDeathDetail    = e.Participant.OtherCauseOfDeathDetail;
                sp.BcgAdverse                = e.Participant.BcgAdverse;
                sp.BcgAdverseDetail          = e.Participant.BcgAdverseDetail;
                sp.BcgPapuleAtDischarge      = e.Participant.BcgPapuleAtDischarge;
                sp.IsParticipantModelChanged = false;
                sp.IsVaccineAdminChanged     = false; //ensure save changes is not enabled
                //assdVM.ParticipantModel = sp.ParticipantModel;
            }
            AllParticipants.CommitEdit();
        }