private void UpdatePlanSetupsInScope(PlanningItemViewModel planSetupVm)
 {
     if (planSetupVm.IsChecked)
     {
         PlanSetupsInScope.Add(planSetupVm);
     }
     else
     {
         PlanSetupsInScope.Remove(planSetupVm);
     }
 }
        private void OpenPatientContext()
        {
            PatientId = SelectedPatientContext.PatientId;

            OpenPatient();

            foreach (var planningItem in SelectedPatientContext.PlanningItemsInScope)
            {
                var pi = PlanningItems
                         .FirstOrDefault(p => p.Id == planningItem.Id && p.CourseId == planningItem.CourseId);

                if (pi != null)
                {
                    pi.IsChecked = true;  // Will add it to PlanSetupsInScope
                }
            }

            if (SelectedPatientContext.ActivePlanSetup != null)
            {
                SelectedPlanSetup = PlanSetupsInScope
                                    .SingleOrDefault(p => p.Id == SelectedPatientContext.ActivePlanSetup.Id &&
                                                     p.CourseId == SelectedPatientContext.ActivePlanSetup.CourseId);
            }
        }
 private IEnumerable <PlanSetup> GetPlanSetupsInScope()
 {
     return(PlanSetupsInScope.Select(p => p.PlanningItem).Cast <PlanSetup>());
 }