Пример #1
0
 private PlanningItem FindPlanningItem(PlanOrPlanSum planOrPlanSum, IEnumerable <PlanningItem> planningItems) =>
 planningItems?.FirstOrDefault(p => p.GetCourse().Id == planOrPlanSum?.CourseId && p.Id == planOrPlanSum?.Id);
Пример #2
0
        private void SaveRecent(string patientId, IEnumerable <PlanOrPlanSum> plansAndPlanSumsInScope, PlanOrPlanSum activePlan)
        {
            var data = _dataRepository.Load();

            var recent = new RecentEntry
            {
                PatientId = patientId,
                PlansAndPlanSumsInScope = plansAndPlanSumsInScope?.ToList(),
                ActivePlan = activePlan
            };

            if (!data.Recents.Contains(recent))
            {
                data.Recents.Add(recent);
                _dataRepository.Save(data);
            }
        }
Пример #3
0
        private PluginScriptContext CreateScriptContext(Patient patient, IEnumerable <PlanOrPlanSum> plansAndPlanSumsInScope, PlanOrPlanSum activePlan)
        {
            var planningItems        = patient?.GetPlanningItems().ToArray();
            var planningItemsInScope = FindPlanningItems(plansAndPlanSumsInScope, planningItems);
            var planSetup            = FindPlanningItem(activePlan, planningItems) as PlanSetup;

            return(new PluginScriptContext
            {
                CurrentUser = _esapiApp.CurrentUser,
                Course = planSetup?.Course,
                Image = planSetup?.StructureSet?.Image,
                StructureSet = planSetup?.StructureSet,
                Patient = patient,
                PlanSetup = planSetup,
                ExternalPlanSetup = planSetup as ExternalPlanSetup,
                BrachyPlanSetup = planSetup as BrachyPlanSetup,
                PlansInScope = planningItemsInScope?.Where(p => p is PlanSetup).Cast <PlanSetup>(),
                ExternalPlansInScope = planningItemsInScope?.Where(p => p is ExternalPlanSetup).Cast <ExternalPlanSetup>(),
                BrachyPlansInScope = planningItemsInScope?.Where(p => p is BrachyPlanSetup).Cast <BrachyPlanSetup>(),
                PlanSumsInScope = planningItemsInScope?.Where(p => p is PlanSum).Cast <PlanSum>(),
                ApplicationName = ApplicationName,
                VersionInfo = VersionInfo
            });
        }
Пример #4
0
        public void RunScript(string patientId, IEnumerable <PlanOrPlanSum> plansAndPlanSumsInScope, PlanOrPlanSum activePlan)
        {
            try
            {
                SaveRecent(patientId, plansAndPlanSumsInScope, activePlan);

                var patient = _esapiApp.OpenPatientById(patientId);
                var context = CreateScriptContext(patient, plansAndPlanSumsInScope, activePlan);

                if (_scriptWithWindow != null)
                {
                    var window = new Window();
                    _scriptWithWindow.Execute(context, window);
                    window.ShowDialog();
                }
                else if (_script != null)
                {
                    _script.Run(context);
                }
            }
            catch (Exception e)
            {
                // Mimic Eclipse by showing a message box when an exception is thrown
                MessageBox.Show(e.Message, ApplicationName, MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            finally
            {
                _esapiApp.ClosePatient();
            }
        }