Пример #1
0
        private bool createPlan()
        {
            //look for a course name VMAT TBI. If it does not exit, create it, otherwise load it into memory
            if (!selectedSS.Patient.Courses.Where(x => x.Id == "VMAT TBI").Any())
            {
                if (selectedSS.Patient.CanAddCourse())
                {
                    tbi    = selectedSS.Patient.AddCourse();
                    tbi.Id = "VMAT TBI";
                }
                else
                {
                    MessageBox.Show("Error! \nCan't add a treatment course to the patient!");
                    return(true);
                }
            }
            else
            {
                tbi = selectedSS.Patient.Courses.FirstOrDefault(x => x.Id == "VMAT TBI");
            }

            //6-10-2020 EAS, research system only!
            //if (tbi.ExternalPlanSetups.Where(x => x.Id == "_VMAT TBI").Any()) if (tbi.CanRemovePlanSetup((tbi.ExternalPlanSetups.First(x => x.Id == "_VMAT TBI")))) tbi.RemovePlanSetup(tbi.ExternalPlanSetups.First(x => x.Id == "_VMAT TBI"));
            if (tbi.ExternalPlanSetups.Where(x => x.Id == "_VMAT TBI").Any())
            {
                MessageBox.Show("A plan named '_VMAT TBI' Already exists! \nESAPI can't remove plans in the clinical environment! \nPlease manually remove this plan and try again.");
                return(true);
            }
            plan = tbi.AddExternalPlanSetup(selectedSS);
            //100% dose prescribed in plan and plan ID is _VMAT TBI
            plan.SetPrescription(prescription.Item1, prescription.Item2, 1.0);
            plan.Id = "_VMAT TBI";
            //ask the user to set the calculation model if not calculation model was set in UI.xaml.cs (up near the top with the global parameters)
            if (calculationModel == "")
            {
                IEnumerable <string> models = plan.GetModelsForCalculationType(CalculationType.PhotonVolumeDose);
                selectItem           SUI    = new VMATTBIautoPlan.selectItem();
                SUI.title.Text = "No calculation model set!" + Environment.NewLine + "Please select a calculation model!";
                foreach (string s in plan.GetModelsForCalculationType(CalculationType.PhotonVolumeDose))
                {
                    SUI.itemCombo.Items.Add(s);
                }
                SUI.ShowDialog();
                if (!SUI.confirm)
                {
                    return(true);
                }
                //get the plan the user chose from the combobox
                calculationModel = SUI.itemCombo.SelectedItem.ToString();

                //just an FYI that the calculation will likely run out of memory and crash the optimization when Acuros is used
                if (calculationModel.ToLower().Contains("acuros"))
                {
                    confirmUI CUI = new VMATTBIautoPlan.confirmUI();
                    CUI.message.Text = "Warning!" + Environment.NewLine + "The optimization will likely crash (i.e., run out of memory) if Acuros is used!" + Environment.NewLine + "Continue?!";
                    CUI.ShowDialog();
                    if (!CUI.confirm)
                    {
                        return(true);
                    }
                }
            }
            plan.SetCalculationModel(CalculationType.PhotonVolumeDose, calculationModel);

            //reference point can only be added for a plan that IS CURRENTLY OPEN
            //plan.AddReferencePoint(selectedSS.Structures.First(x => x.Id == "TS_PTV_VMAT"), null, "VMAT TBI", "VMAT TBI");

            //6-10-2020 EAS, research system only!
            if ((numIsos > numVMATIsos) && tbi.ExternalPlanSetups.Where(x => x.Id.ToLower().Contains("legs")).Any())
            {
                MessageBox.Show("Plan(s) with the string 'legs' already exists! \nESAPI can't remove plans in the clinical environment! \nPlease manually remove this plan and try again.");
                return(true);
            }

            //these needs to be fixed
            //v16 of Eclipse allows for the creation of a plan with a named target structure and named primary reference point. Neither of these options are available in v15
            //plan.TargetVolumeID = selectedSS.Structures.First(x => x.Id == "TS_PTV_VMAT");
            //plan.PrimaryReferencePoint = plan.ReferencePoints.Fisrt(x => x.Id == "VMAT TBI");

            return(false);
        }