private IEnumerable <PlanSum> GetPlanSumsInScope()
 {
     return(PlanningItems
            .Where(p => p.PlanningItem is PlanSum && p.IsChecked)
            .Select(p => p.PlanningItem)
            .Cast <PlanSum>());
 }
        private void UpdateRecentPatientContexts()
        {
            var patientContext = new PatientContext();

            patientContext.PatientId       = _patientId;
            patientContext.ActivePlanSetup = MapPlanningItemViewModelToData(SelectedPlanSetup);

            foreach (var planningItemsInScope in PlanningItems.Where(p => p.IsChecked))
            {
                patientContext.PlanningItemsInScope
                .Add(MapPlanningItemViewModelToData(planningItemsInScope));
            }

            if (RecentPatientContexts.Contains(patientContext))
            {
                var index = RecentPatientContexts.IndexOf(patientContext);
                RecentPatientContexts.Move(index, 0);
            }
            else
            {
                RecentPatientContexts.Insert(0, patientContext);

                if (RecentPatientContexts.Count > MaximumNumberOfRecentPatientContexts)
                {
                    RecentPatientContexts.Remove(RecentPatientContexts.Last());
                }
            }
        }
 private void UpdatePlanSetupsInScopeWhenPlanSetupVmIsCheckedChanged()
 {
     // Each planSetupVm is a PlanningItemViewModel that contains a PlanSetup
     foreach (var planSetupVm in PlanningItems.Where(p => p.PlanningItem is PlanSetup))
     {
         planSetupVm.PropertyChanged += (o, e) =>
         {
             if (e.PropertyName == "IsChecked")
             {
                 UpdatePlanSetupsInScope((PlanningItemViewModel)o);
             }
         };
     }
 }