Exemplo n.º 1
0
        private void DetermineColumnVisibilities()
        {
            //see if there are any nodes in the protocol that have a "variation-constraint" or "variation-limit" attribute
            if ((from el in ConstraintList.GetProtocol(SelectedProtocol).Descendants("constraint")
                 where el.Attribute("variation-constraint") != null
                 select el).Count() > 0)
            {
                VariationConstraintColumnVisibility = Visibility.Visible;
            }
            else
            {
                VariationConstraintColumnVisibility = Visibility.Collapsed;
            }


            if ((from el in ConstraintList.GetProtocol(SelectedProtocol).Descendants("constraint")
                 where el.Attribute("variation-limit") != null
                 select el).Count() > 0)
            {
                VariationLimitColumnVisibility = Visibility.Visible;
            }
            else
            {
                VariationLimitColumnVisibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 2
0
        private ReportData CreateReportData()
        {
            ReportData reportData = new ReportData();

            reportData.Patient = new SimplePdfReport.Reporting.Patient
            {
                Id   = _vm.PatientID,
                Name = _vm.PatientName
            };

            reportData.User = new SimplePdfReport.Reporting.User
            {
                Username = _vm.CurrentUser
            };

            reportData.Plans = new SimplePdfReport.Reporting.Plans
            {
                Id       = _vm.PlanID,
                Course   = _vm.CourseID == "" ? "" : $" ({_vm.CourseID})",
                Protocol = ConstraintList.GetProtocolName(_vm.SelectedProtocol),
                PlanList = new List <Plan>()
            };

            foreach (PlanInformation plan in _vm.Plans)
            {
                SimplePdfReport.Reporting.Plan newPlan = new SimplePdfReport.Reporting.Plan
                {
                    Id        = plan.PlanID,
                    TotalDose = plan.TotalPlannedDose,
                    DosePerFx = plan.DosePerFraction,
                    Fractions = plan.NumberOfFractions
                };

                reportData.Plans.PlanList.Add(newPlan);
            }

            reportData.DvhTable = new DVHTable
            {
                Title = "DVH Analysis Report"
            };

            foreach (DVHTableRow row in _vm.DVHTable)
            {
                SimplePdfReport.Reporting.DVHTableRow newRow = new SimplePdfReport.Reporting.DVHTableRow();

                newRow.StructureId         = row.Structure ?? "";
                newRow.PlanStructureId     = row.SelectedStructure != null ? row.SelectedStructure.Id : "";
                newRow.Constraint          = row.ConstraintText ?? "";
                newRow.VariationConstraint = row.VariationConstraintText ?? "";
                newRow.Limit           = row.LimitText ?? "";
                newRow.VariationLimit  = row.VariationLimitText ?? "";
                newRow.PlanValue       = row.PlanValueText ?? "";
                newRow.PlanResult      = row.PlanResult ?? "";
                newRow.PlanResultColor = row.PlanResultColor;

                reportData.DvhTable.Rows.Add(newRow);
            }

            return(reportData);
        }
Exemplo n.º 3
0
        public DVHViewModel(Patient pat, PlanningItem pItem, Course course, StructureSet ss, User user)
        {
            //patient information
            _contextInfo = new ContextInformation
            {
                SelectedPatient      = pat,
                SelectedPlanningItem = pItem,
                SelectedCourse       = course,
                SelectedStructureSet = pItem is PlanSetup ? ss : (pItem as PlanSum).StructureSet,
                CurrentUser          = user
            };

            _plans = new ObservableCollection <PlanInformation>();

            //add plans to be displayed
            if (pItem is PlanSetup)
            {
                PlanSumDoseVisibility = Visibility.Hidden;
                _plans.Add(new PlanInformation(pItem as PlanSetup));
            }
            else             //plan sum, so add all plans in it
            {
                PlanSumDoseVisibility = Visibility.Visible;
                DoseValue tempPlanSumTotalDose = new DoseValue(0, SelectedPlanningItem.Dose.DoseMax3D.Unit);

                foreach (PlanSetup plan in (pItem as PlanSum).PlanSetups)
                {
                    _plans.Add(new PlanInformation(plan));
                    tempPlanSumTotalDose = DvhExtensions.AddDoseValues(tempPlanSumTotalDose, plan.TotalDose);
                }

                _planSumTotalDose     = tempPlanSumTotalDose;
                _planSumTotalDoseText = tempPlanSumTotalDose.Dose.ToString();
            }

            //protocol selection dropdowns
            _categories       = ConstraintList.GetCategories();
            _protocols        = ConstraintList.GetProtocols();
            _selectedCategory = _categories.First();

            //DVH
            PlotModel     = CreatePlotModel();
            DVHStructures = GetContouredStructures();

            //constraints table
            DVHTable = new ObservableCollection <DVHTableRow>();

            //misc
            Username = _contextInfo.CurrentUser.Id;
        }
Exemplo n.º 4
0
        public void CreateNewDVHTable()
        {
            _initialTableLoad = true;
            DVHTable.Clear();

            //add new row for each constraint found in the new protocol
            foreach (XElement constr in ConstraintList.GetProtocol(SelectedProtocol).Descendants("constraint"))
            {
                DVHTableRow newRow = new DVHTableRow(constr, this);

                DVHTable.Add(newRow);
            }

            DetermineColumnVisibilities();

            _initialTableLoad = false;
        }
Exemplo n.º 5
0
        public DVHTableRow(XElement constraint, DVHViewModel viewModel)
        {
            _viewModel = viewModel;

            //set structures
            Structure         = constraint.Parent.Attribute("name").Value;
            SelectedStructure = GetBestStructureMatch(Structure);

            //get info from xml
            ConstraintText          = constraint.Attribute("constraint").Value;
            VariationConstraintText = constraint.Attribute("variation-constraint") == null ? "" : constraint.Attribute("variation-constraint").Value;
            LimitText           = constraint.Attribute("goal").Value == "greater" ? "> " + constraint.Attribute("limit").Value : "< " + constraint.Attribute("limit").Value;
            VariationLimitText  = constraint.Attribute("variation-limit") == null ? "" : constraint.Attribute("goal").Value == "greater" ? "> " + constraint.Attribute("variation-limit").Value : "< " + constraint.Attribute("variation-limit").Value;
            ConstraintType      = GetConstraintType(constraint);
            Constraint          = (ConstraintType == ConstraintType.Dose || ConstraintType == ConstraintType.Volume || ConstraintType == ConstraintType.ColdVolume || ConstraintType == ConstraintType.CI) ? ConstraintParsing.ExtractNumber(constraint.Attribute("constraint").Value) : -1;
            VariationConstraint = constraint.Attribute("variation-constraint") == null ? -1 : ConstraintParsing.ExtractNumber(constraint.Attribute("variation-constraint").Value);
            ConstraintUnits     = (ConstraintType == ConstraintType.Dose || ConstraintType == ConstraintType.Volume || ConstraintType == ConstraintType.ColdVolume || ConstraintType == ConstraintType.CI) ? ConstraintParsing.ExtractUnits(constraint.Attribute("constraint").Value) : "";
            GoalGreaterThan     = ConstraintList.GetConstraintGoal(constraint);
            Limit          = ConstraintParsing.ExtractNumber(constraint.Attribute("limit").Value);
            VariationLimit = constraint.Attribute("variation-limit") == null ? -1 : ConstraintParsing.ExtractNumber(constraint.Attribute("variation-limit").Value);
            LimitUnits     = ConstraintParsing.ExtractUnits(constraint.Attribute("limit").Value);
            Endpoint       = constraint.Attribute("endpoint") == null ? "" : "Endpoint: " + constraint.Attribute("endpoint").Value;
            Reference      = constraint.Attribute("reference") == null ? "" : "Reference: " + constraint.Attribute("reference").Value;

            if (Endpoint != "" && Reference != "")
            {
                Reference += "\n";
            }

            try
            {
                //compute results
                ComputePlanValues();
                ComputePlanResult();
            }
            catch { }

            //only show the selected structure dropdown if it's the first time that it's being listed so far in the table
            StructureVisibility = viewModel.DVHTable.Where(s => s.Structure == Structure).Count() > 0 ? Visibility.Hidden : Visibility.Visible;
        }