Beispiel #1
0
        public MainViewModel(User user, Patient patient, string scriptVersion, ObservableCollection <PlanningItemViewModel> planningItemList, PlanningItemViewModel planningItem)
        {
            ActivePlanningItem = planningItem;
            Patient            = patient;
            Image        = ActivePlanningItem.PlanningItemImage;
            StructureSet = ActivePlanningItem.PlanningItemStructureSet;
            DirectoryInfo constraintDir = new DirectoryInfo(Path.Combine(AssemblyHelper.GetAssemblyDirectory(), "ConstraintTemplates"));
            //DirectoryInfo constraintDir = new DirectoryInfo(Path.Combine(AssemblyHelper.GetAssemblyDirectory(), "ConstraintTemplates"));
            string firstFileName           = constraintDir.GetFiles().FirstOrDefault().ToString();
            string firstConstraintFilePath = Path.Combine(constraintDir.ToString(), firstFileName);

            ActiveConstraintPath   = new ConstraintViewModel(firstConstraintFilePath);
            PlanningItemList       = planningItemList;
            StructureList          = StructureSetListViewModel.GetStructureList(StructureSet);;
            ConstraintComboBoxList = ConstraintListViewModel.GetConstraintList(constraintDir.ToString());
            //GetPQMSummaries(ActiveConstraintPath, ActivePlanningItem, Patient);
            //PqmSummaries = new ObservableCollection<PQMSummaryViewModel>();
            ErrorGrid             = GetErrors(ActivePlanningItem);
            Title                 = GetTitle(patient, scriptVersion);
            ModelGroup            = new Model3DGroup();
            SliderValue           = 0;
            upDir                 = new Vector3D(0, -1, 0);
            lookDir               = new Vector3D(0, 0, 1);
            isoctr                = new Point3D(0, 0, 0); //just to initalize
            cameraPosition        = new Point3D(0, 0, -3500);
            PlanningItemSummaries = GetPlanningItemSummary(ActivePlanningItem, PlanningItemList);
            //NotifyPropertyChanged("Structure");
        }
Beispiel #2
0
        public List <ErrorViewModel> GetErrors(PlanningItemViewModel planningItem)
        {
            var calculator = new ErrorCalculator();

            ErrorGrid = calculator.Calculate(planningItem.PlanningItemObject);
            ErrorGrid = ErrorGrid.OrderBy(x => x.Status).ToList();
            return(ErrorGrid);
        }
Beispiel #3
0
        static public ObservableCollection <PlanningItemViewModel> GetPlanningItemList(IEnumerable <PlanSetup> planSetupsInScope, IEnumerable <PlanSum> planSumsInScope)
        {
            var PlanningItemComboBoxList = new ObservableCollection <PlanningItemViewModel>();

            foreach (PlanSetup planSetup in planSetupsInScope)
            {
                var planningItemViewModel = new PlanningItemViewModel(planSetup);
                PlanningItemComboBoxList.Add(planningItemViewModel);
            }

            foreach (PlanSum planSum in planSumsInScope)
            {
                var planningItemViewModel = new PlanningItemViewModel(planSum);
                PlanningItemComboBoxList.Add(planningItemViewModel);
            }
            return(PlanningItemComboBoxList);
        }
Beispiel #4
0
        public string CalculateMetricDose(Patient patient, string courseId, string planId, string structureId, string structureCode, string dvhObjective)
        {
            var       plan   = Extensions.GetPlanningItem(patient, courseId, planId);
            var       planVM = new PlanningItemViewModel(plan);
            Structure structure;

            if (structureCode == null)
            {
                structure = Extensions.GetStructureFromId(plan, structureId);
            }
            else
            {
                structure = Extensions.GetStructureFromCode(plan, structureCode);
            }
            var    structureVM = new StructureViewModel(structure);
            string metric      = dvhObjective;
            string result      = _metricCalc.CalculateMetric(planVM.PlanningItemStructureSet, structureVM, planVM, metric);

            return(result);
        }
Beispiel #5
0
        public PQMSummaryViewModel CalculatePQM(PQMSummaryViewModel objective, PlanningItemViewModel planningItemVM, StructureSet structureSet, StructureViewModel evalStructure)
        {
            objective.ActivePlanningItem = planningItemVM;
            PlanningItem planningItem = planningItemVM.PlanningItemObject;

            if (evalStructure == null)
            {
                objective.Achieved      = "Structure not found or empty.";
                objective.isCalculated  = false;
                objective.StructureList = StructureSetListViewModel.GetStructureList(structureSet);
                return(objective);
            }
            else
            {
                objective.isCalculated          = true;
                objective.Structure             = evalStructure;
                objective.StructureName         = evalStructure.StructureName;
                objective.StructVolume          = evalStructure.VolumeValue;
                objective.StructureNameWithCode = evalStructure.StructureNameWithCode;
                objective.StructureList         = StructureSetListViewModel.GetStructureList(structureSet);
                return(objective);
            }
        }
Beispiel #6
0
        public string CalculateMetric(StructureSet structureSet, StructureViewModel evalStructure, PlanningItemViewModel planningItem, string DVHObjective)
        {
            //start with a general regex that pulls out the metric type and the @ (evalunit) part.
            string pattern            = @"^(?<type>[^\[\]]+)(\[(?<evalunit>[^\[\]]+)\])$";
            string minmaxmean_Pattern = @"^(M(in|ax|ean)|Volume)$";                          //check for Max or Min or Mean or Volume
            string d_at_v_pattern     = @"^D(?<evalpt>\d+\p{P}\d+|\d+)(?<unit>(%|cc))$";     // matches D95%, D2cc
            string dc_at_v_pattern    = @"^DC(?<evalpt>\d+)(?<unit>(%|cc))$";                // matches DC95%, DC700cc
            string v_at_d_pattern     = @"^V(?<evalpt>\d+\p{P}\d+|\d+)(?<unit>(%|Gy|cGy))$"; // matches V98%, V40Gy
            string cv_at_d_pattern    = @"^CV(?<evalpt>\d+)(?<unit>(%|Gy|cGy))$";            // matches CV98%, CV40Gy
                                                                                             // Max[Gy] D95%[%] V98%[%] CV98%[%] D2cc[Gy] V40Gy[%]
            string cn_pattern = @"^CN(?<evalpt>\d+\p{P}\d+|\d+)(?<unit>(%|Gy|cGy))$";        //matches CN50%
            string gi_pattern = @"^GI(?<evalpt>\d+\p{P}\d+|\d+)(?<unit>(%|Gy|cGy))$";        //matches GI50%

            //Structure evalStructure = ;
            if (evalStructure == null)
            {
                return("Structure not found");
            }

            //start with a general regex that pulls out the metric type and the [evalunit] part.
            var matches = Regex.Matches(DVHObjective, pattern);

            if (matches.Count != 1)
            {
                return(string.Format("DVH Objective expression \"{0}\" is not a recognized expression type.", DVHObjective));
            }
            Match m        = matches[0];
            Group type     = m.Groups["type"];
            Group evalunit = m.Groups["evalunit"];

            Console.WriteLine("expression {0} => type = {1}, unit = {2}", DVHObjective, type.Value, evalunit.Value);

            // further decompose <type>
            var testMatch = Regex.Matches(type.Value, minmaxmean_Pattern);

            if (testMatch.Count != 1)
            {
                testMatch = Regex.Matches(type.Value, v_at_d_pattern);
                if (testMatch.Count != 1)
                {
                    testMatch = Regex.Matches(type.Value, d_at_v_pattern);
                    if (testMatch.Count != 1)
                    {
                        testMatch = Regex.Matches(type.Value, cv_at_d_pattern);
                        if (testMatch.Count != 1)
                        {
                            testMatch = Regex.Matches(type.Value, dc_at_v_pattern);
                            if (testMatch.Count != 1)
                            {
                                testMatch = Regex.Matches(type.Value, cn_pattern);
                                if (testMatch.Count != 1)
                                {
                                    testMatch = Regex.Matches(type.Value, gi_pattern);
                                    if (testMatch.Count != 1)
                                    {
                                        return(string.Format("DVH Objective expression \"{0}\" is not a recognized expression type.", DVHObjective));
                                    }
                                    else
                                    {
                                        // we have Gradient Index pattern
                                        return(PQMGradientIndex.GetGradientIndex(structureSet, planningItem, evalStructure, testMatch, evalunit));
                                    }
                                }
                                else
                                {
                                    // we have Conformation Number pattern
                                    return(PQMConformationNumber.GetConformationNumber(structureSet, planningItem, evalStructure, testMatch, evalunit));
                                }
                            }
                            else
                            {
                                // we have Covered Dose at Volume pattern
                                return(PQMCoveredDoseAtVolume.GetCoveredDoseAtVolume(structureSet, planningItem, evalStructure, testMatch, evalunit));
                            }
                        }
                        else
                        {
                            // we have Covered Volume at Dose pattern
                            return(PQMCoveredVolumeAtDose.GetCoveredVolumeAtDose(structureSet, planningItem, evalStructure, testMatch, evalunit));
                        }
                    }
                    else
                    {
                        // we have Dose at Volume pattern
                        return(PQMDoseAtVolume.GetDoseAtVolume(structureSet, planningItem, evalStructure, testMatch, evalunit));
                    }
                }
                else
                {
                    // we have Volume at Dose pattern
                    return(PQMVolumeAtDose.GetVolumeAtDose(structureSet, planningItem, evalStructure, testMatch, evalunit));
                }
            }
            else
            {
                // we have Min, Max, Mean, or Volume
                return(PQMMinMaxMean.GetMinMaxMean(structureSet, planningItem, evalStructure, testMatch, evalunit, type));
            }
        }
        public ObservableCollection <PlanningItemDetailsViewModel> Calculate(PlanningItemViewModel activePlanningItem, ObservableCollection <PlanningItemViewModel> planningItemComboBoxList, ObservableCollection <PQMViewModel> PqmSummaries, List <CollisionCheckViewModel> CollisionSummaries, List <ErrorViewModel> ErrorGrid)
        {
            var  PlanningItemSummaries = new ObservableCollection <PlanningItemDetailsViewModel>();
            var  PlanSummary           = new ObservableCollection <PlanningItemDetailsViewModel>();
            bool planIsBold            = false;
            bool isCCEnabled           = false;

            foreach (PlanningItemViewModel planningItem in planningItemComboBoxList)
            {
                string pqmResult = "";
                string ccResult  = "";
                string pcResult  = "";
                string rpiResult = "";
                if (planningItem.PlanningItemIdWithCourse == activePlanningItem.PlanningItemIdWithCourse)
                {
                    int pqmsPassing = 0;
                    int pqmsTotal   = 0;
                    if (PqmSummaries != null)
                    {
                        pqmsTotal = PqmSummaries.Count;
                        foreach (var row in PqmSummaries)
                        {
                            if (row.Met == "Goal" || row.Met == "Variation")
                            {
                                pqmsPassing += 1;
                            }
                        }
                    }
                    pqmResult = pqmsPassing.ToString() + "/" + pqmsTotal.ToString();
                    int    beamCollisionChecksClearing = 0;
                    int    beamsTotal       = 0;
                    string beamsTotalString = " - ";
                    if (planningItem.PlanningItemObject is PlanSetup)
                    {
                        PlanSetup planSetup = (PlanSetup)planningItem.PlanningItemObject;

                        foreach (Beam b in planSetup.Beams)
                        {
                            if (b.IsSetupField != true)
                            {
                                beamsTotal += 1;
                            }
                        }
                        beamsTotalString = beamsTotal.ToString();
                    }
                    if (CollisionSummaries != null)
                    {
                        foreach (var row in CollisionSummaries)
                        {
                            if (row.Status == "Clear" || row.Status == " - ")
                            {
                                beamCollisionChecksClearing += 1;
                            }
                        }
                    }
                    ccResult = beamCollisionChecksClearing.ToString() + "/" + beamsTotal;
                    int errorChecksPassing = 0;
                    int errorChecksTotal   = ErrorGrid.Count();
                    foreach (var row in ErrorGrid)
                    {
                        if (row.Status == "3 - OK" || row.Status == "2 - Variation")
                        {
                            errorChecksPassing += 1;
                        }
                    }
                    pcResult = errorChecksPassing.ToString() + "/" + errorChecksTotal.ToString();
                }

                if (planningItem.PlanningItemObject is PlanSum)
                {
                    PlanSum planSum             = (PlanSum)planningItem.PlanningItemObject;
                    int     sumOfFractions      = 0;
                    double  sumOfPlanSetupDoses = 0;
                    isCCEnabled = false;
                    if (planSum == activePlanningItem.PlanningItemObject)
                    {
                        planIsBold = true;
                    }
                    else
                    {
                        planIsBold = false;
                    }

                    foreach (PlanSetup planSetup in planSum.PlanSetups.OrderBy(x => x.CreationDateTime))
                    {
                        string planTarget;
                        sumOfFractions      += planSetup.NumberOfFractions.Value;
                        sumOfPlanSetupDoses += planSetup.TotalDose.Dose;
                        if (planSetup.TargetVolumeID != null)
                        {
                            planTarget = planSetup.TargetVolumeID;
                        }
                        else
                        {
                            planTarget = "No target selected";
                        }
                    }
                    var PlanSumSummary = new PlanningItemDetailsViewModel
                    {
                        IsBold = planIsBold,
                        CC     = isCCEnabled,
                        PlanningItemIdWithCourse = planSum.Course + "/" + planSum.Id,
                        ApprovalStatus           = "PlanSum",
                        PlanningItemObject       = planningItem.PlanningItemObject,
                        PlanName      = planSum.Course + "/" + planSum.Id,
                        PlanCreated   = planSum.CreationDateTime.ToString(),
                        PlanFractions = sumOfFractions.ToString(),
                        PlanTotalDose = sumOfPlanSetupDoses.ToString(),
                        PQMResult     = pqmResult,
                        CCResult      = ccResult,
                        PCResult      = pcResult,
                        RPIResult     = rpiResult,
                    };
                    PlanningItemSummaries.Add(PlanSumSummary);
                }
                else  //planningitem is plansetup
                {
                    PlanSetup planSetup = (PlanSetup)planningItem.PlanningItemObject;
                    if (planSetup == activePlanningItem.PlanningItemObject)
                    {
                        planIsBold  = true;
                        isCCEnabled = true;
                    }
                    else
                    {
                        planIsBold  = false;
                        isCCEnabled = false;
                    }
                    var approvalStatus = "";
                    if (planSetup.PlanIntent == "VERIFICATION")
                    {
                        approvalStatus = "VerificationPlan";
                    }
                    else
                    {
                        approvalStatus = planSetup.ApprovalStatus.ToString();
                    }

                    string planTarget;
                    if (planSetup.TargetVolumeID != null)
                    {
                        planTarget = planSetup.TargetVolumeID;
                    }
                    else
                    {
                        planTarget = "No target selected";
                    }
                    var PlanningItemSummary = new PlanningItemDetailsViewModel
                    {
                        IsBold = planIsBold,
                        CC     = isCCEnabled,
                        PlanningItemIdWithCourse = planSetup.Course + "/" + planSetup.Id,
                        ApprovalStatus           = approvalStatus,
                        PlanName           = planSetup.Course + "/" + planSetup.Id,
                        PlanningItemObject = planningItem.PlanningItemObject,
                        PlanCreated        = planSetup.CreationDateTime.ToString(),
                        PlanFxDose         = planSetup.DosePerFraction.Dose.ToString(),
                        PlanFractions      = planSetup.NumberOfFractions.ToString(),
                        PlanTotalDose      = planSetup.TotalDose.Dose.ToString(),
                        PlanTarget         = planTarget,
                        PQMResult          = pqmResult,
                        CCResult           = ccResult,
                        PCResult           = pcResult,
                        RPIResult          = rpiResult,
                    };
                    PlanningItemSummaries.Add(PlanningItemSummary);
                }
            }
            return(PlanningItemSummaries);
        }
Beispiel #8
0
        public Tuple <List <CollisionCheckViewModel>, Model3DGroup> GetCollisionSummary(PlanningItemViewModel planningItem)
        {
            var waitWindowCollision = new WaitWindowCollision();

            waitWindowCollision.Show();

            var calculator           = new CollisionSummariesCalculator();
            var collimatorModelGroup = new Model3DGroup();
            var isoModelGroup        = new Model3DGroup();
            var modelGroup           = new Model3DGroup();

            upDir          = new Vector3D(0, -1, 0);
            lookDir        = new Vector3D(0, 0, 1);
            isoctr         = new Point3D(0, 0, 0); //just to initalize
            cameraPosition = new Point3D(0, 0, -3500);
            var CollisionSummaries = new List <CollisionCheckViewModel>();

            // Create some materials
            var redMaterial        = new DiffuseMaterial(new SolidColorBrush(Colors.Red));
            var darkblueMaterial   = new DiffuseMaterial(new SolidColorBrush(Colors.DarkBlue));
            var collimatorMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Green));

            Structure      bodyStruct;
            var            iso3DMesh = calculator.CalculateIsoMesh(isoctr);
            MeshGeometry3D bodyMesh  = null;
            MeshGeometry3D couchMesh = null;

            if (planningItem.PlanningItemObject is PlanSetup)
            {
                PlanSetup planSetup = (PlanSetup)planningItem.PlanningItemObject;
                bodyStruct = planSetup.StructureSet.Structures.Where(x => x.Id.Contains("BODY")).First();
                bodyMesh   = bodyStruct.MeshGeometry;
                foreach (Structure structure in planSetup.StructureSet.Structures)
                {
                    if (structure.StructureCodeInfos.FirstOrDefault().Code != null)
                    {
                        if (structure.StructureCodeInfos.FirstOrDefault().Code == "Support")
                        {
                            Structure couchStruct = structure;
                            couchMesh = couchStruct.MeshGeometry;
                        }
                    }
                }
                foreach (Beam beam in planSetup.Beams)
                {
                    isoctr    = calculator.GetIsocenter(beam);
                    iso3DMesh = calculator.CalculateIsoMesh(calculator.GetIsocenter(beam));
                    bool view = true;
                    if (planSetup.TreatmentOrientation.ToString() == "HeadFirstProne")
                    {
                        upDir = new Vector3D(0, 1, 0);
                    }
                    bool isArc      = false;
                    bool isElectron = false;
                    bool isSRSCone  = false;
                    collimatorMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Green));
                    if (beam.IsSetupField == true)
                    {
                        continue;
                    }
                    if (beam.Name.Contains("Subfield 2") || beam.Name.Contains("Subfield 3"))
                    {
                        continue;
                    }
                    if (beam.EnergyModeDisplayName.Contains("E"))
                    {
                        isElectron = true;
                    }
                    if (beam.EnergyModeDisplayName.Contains("SRS"))
                    {
                        isSRSCone = true;
                    }
                    if (beam.Technique.Id.Contains("ARC"))
                    {
                        isArc = true;
                        collimatorMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.GreenYellow));
                    }

                    foreach (Structure structure in planSetup.StructureSet.Structures)
                    {
                        if (structure.Id.Contains("CouchSurface") == true)
                        {
                            Structure couchStruct = planSetup.StructureSet.Structures.Where(x => x.Id.Contains("CouchSurface")).First();
                            couchMesh = couchStruct.MeshGeometry;
                        }
                    }
                    MeshGeometry3D collimatorMesh        = calculator.CalculateCollimatorMesh(planSetup, beam, isoctr, isArc, isElectron, isSRSCone);
                    string         shortestDistanceBody  = "2000000";
                    string         shortestDistanceTable = "2000000";
                    string         status = "Clear";
                    shortestDistanceBody = calculator.ShortestDistance(collimatorMesh, bodyMesh);
                    if (couchMesh != null)
                    {
                        shortestDistanceTable = calculator.ShortestDistance(collimatorMesh, couchMesh);
                    }
                    else
                    {
                        shortestDistanceTable = " - ";
                        status = " - ";
                    }
                    Console.WriteLine(beam.Id + " - gantry to body is " + shortestDistanceBody + " cm");
                    Console.WriteLine(beam.Id + " - gantry to table is " + shortestDistanceTable + " cm");
                    if (shortestDistanceTable != " - ")
                    {
                        if ((Convert.ToDouble(shortestDistanceBody) < 3.0) || (Convert.ToDouble(shortestDistanceTable) < 3.0))
                        {
                            collimatorMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Red));
                            status             = "Collision";
                        }
                    }
                    collimatorModelGroup.Children.Add(new GeometryModel3D {
                        Geometry = collimatorMesh, Material = collimatorMaterial, BackMaterial = darkblueMaterial
                    });
                    isoModelGroup.Children.Add(new GeometryModel3D {
                        Geometry = iso3DMesh, Material = redMaterial, BackMaterial = redMaterial
                    });
                    var collisionSummary = calculator.GetFieldCollisionSummary(beam, view, shortestDistanceBody, shortestDistanceTable, status);
                    CollisionSummaries.Add(collisionSummary);
                }
            }
            modelGroup = CreateModel(bodyMesh, couchMesh, isoModelGroup, collimatorModelGroup, collimatorMaterial);
            waitWindowCollision.Close();
            return(Tuple.Create(CollisionSummaries, modelGroup));
        }
Beispiel #9
0
        public ObservableCollection <PlanningItemDetailsViewModel> GetPlanningItemSummary(PlanningItemViewModel activePlanningItem, ObservableCollection <PlanningItemViewModel> planningItemList)
        {
            var calculator = new PlanningItemDetailsCalculator();

            PlanningItemSummaries = calculator.Calculate(activePlanningItem, planningItemList, PqmSummaries, CollisionSummaries, ErrorGrid);
            return(PlanningItemSummaries);
        }
Beispiel #10
0
        public ObservableCollection <PQMSummaryViewModel> AddPQMSummary(ObservableCollection <PQMSummaryViewModel> PqmSummaries, ConstraintViewModel constraintPath, PlanningItemViewModel planningItem, Patient patient)
        {
            StructureSet structureSet = planningItem.PlanningItemStructureSet;
            Structure    evalStructure;
            //ObservableCollection<PQMSummaryViewModel> pqmSummaries = new ObservableCollection<PQMSummaryViewModel>();
            //ObservableCollection<StructureViewModel> foundStructureList = new ObservableCollection<StructureViewModel>();
            var calculator = new PQMSummaryCalculator();

            //var numCol = PqmSummaries[0]
            //Objectives = calculator.GetObjectives(constraintPath);
            if (planningItem.PlanningItemObject is PlanSum)
            {
                var     waitWindowPQM = new WaitWindowPQM();
                PlanSum plansum       = (PlanSum)planningItem.PlanningItemObject;
                if (plansum.IsDoseValid() == true)
                {
                    waitWindowPQM.Show();
                    foreach (PQMSummaryViewModel pqm in PqmSummaries)
                    {
                        evalStructure = calculator.FindStructureFromAlias(structureSet, pqm.TemplateId, pqm.TemplateAliases, pqm.TemplateCodes);
                        if (evalStructure != null)
                        {
                            var pqmSummary = calculator.GetObjectiveProperties(pqm, planningItem, structureSet, new StructureViewModel(evalStructure));
                            pqm.Achieved_Comparison                 = pqmSummary.Achieved;
                            pqm.AchievedColor_Comparison            = pqmSummary.AchievedColor;
                            pqm.AchievedPercentageOfGoal_Comparison = pqmSummary.AchievedPercentageOfGoal;
                            pqm.Met_Comparison = pqmSummary.Met;
                            //pqmSummaries.Add(pqmSummary);
                            //foundStructureList.Add(new StructureViewModel(evalStructure));
                        }
                    }
                    //FoundStructureList = foundStructureList;
                    waitWindowPQM.Close();
                }
                //PqmSummaries = pqmSummaries;
            }
            else //is plansetup
            {
                var waitWindowPQM = new WaitWindowPQM();

                PlanSetup planSetup = (PlanSetup)planningItem.PlanningItemObject;
                if (planSetup.IsDoseValid() == true)
                {
                    waitWindowPQM.Show();
                    foreach (PQMSummaryViewModel pqm in PqmSummaries)
                    {
                        evalStructure = calculator.FindStructureFromAlias(structureSet, pqm.TemplateId, pqm.TemplateAliases, pqm.TemplateCodes);
                        if (evalStructure != null)
                        {
                            if (evalStructure.Id.Contains("PTV") == true)
                            {
                                foreach (Structure s in structureSet.Structures)
                                {
                                    if (s.Id == planSetup.TargetVolumeID)
                                    {
                                        evalStructure = s;
                                    }
                                }
                            }
                            var pqmSummary = calculator.GetObjectiveProperties(pqm, planningItem, structureSet, new StructureViewModel(evalStructure));
                            pqm.Achieved_Comparison = pqmSummary.Achieved;
                            //foundStructureList.Add(new StructureViewModel(evalStructure));
                        }
                    }
                    //FoundStructureList = foundStructureList;
                    waitWindowPQM.Close();
                }
                //PqmSummaries = pqmSummaries;
            }
            return(PqmSummaries);
        }
Beispiel #11
0
        public void GetPQMSummaries(ConstraintViewModel constraintPath, PlanningItemViewModel planningItem, Patient patient)
        {
            PqmSummaries = new ObservableCollection <PQMSummaryViewModel>();
            StructureSet structureSet = planningItem.PlanningItemStructureSet;
            Structure    evalStructure;
            ObservableCollection <PQMSummaryViewModel> pqmSummaries       = new ObservableCollection <PQMSummaryViewModel>();
            ObservableCollection <StructureViewModel>  foundStructureList = new ObservableCollection <StructureViewModel>();
            var calculator = new PQMSummaryCalculator();

            Objectives = calculator.GetObjectives(constraintPath);
            if (planningItem.PlanningItemObject is PlanSum)
            {
                var     waitWindowPQM = new WaitWindowPQM();
                PlanSum plansum       = (PlanSum)planningItem.PlanningItemObject;
                if (plansum.IsDoseValid() == true)
                {
                    waitWindowPQM.Show();
                    foreach (PQMSummaryViewModel objective in Objectives)
                    {
                        evalStructure = calculator.FindStructureFromAlias(structureSet, objective.TemplateId, objective.TemplateAliases, objective.TemplateCodes);
                        if (evalStructure != null)
                        {
                            var evalStructureVM = new StructureViewModel(evalStructure);
                            var obj             = calculator.GetObjectiveProperties(objective, planningItem, structureSet, evalStructureVM);
                            PqmSummaries.Add(obj);
                            NotifyPropertyChanged("Structure");
                        }
                    }
                    waitWindowPQM.Close();
                }
            }
            if (planningItem.PlanningItemObject is PlanSetup) //is plansetup
            {
                var waitWindowPQM = new WaitWindowPQM();

                PlanSetup planSetup = (PlanSetup)planningItem.PlanningItemObject;
                if (planSetup.IsDoseValid() == true)
                {
                    waitWindowPQM.Show();
                    foreach (PQMSummaryViewModel objective in Objectives)
                    {
                        evalStructure = calculator.FindStructureFromAlias(structureSet, objective.TemplateId, objective.TemplateAliases, objective.TemplateCodes);
                        if (evalStructure != null)
                        {
                            if (evalStructure.Id.Contains("PTV") == true)
                            {
                                foreach (Structure s in structureSet.Structures)
                                {
                                    if (s.Id == planSetup.TargetVolumeID)
                                    {
                                        evalStructure = s;
                                    }
                                }
                            }

                            var evalStructureVM = new StructureViewModel(evalStructure);
                            var obj             = calculator.GetObjectiveProperties(objective, planningItem, structureSet, evalStructureVM);
                            PqmSummaries.Add(obj);
                            NotifyPropertyChanged("Structure");
                        }
                    }
                    waitWindowPQM.Close();
                }
            }
        }