Esempio n. 1
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "CT Sim";
            ResultDetails   = "";
            TestExplanation = "Checks that the correct CT is chosen for the image series based on what treatment unit is used for planning\nWarning: This will not correctly account for patients simmed at one facility and treated at another";

            string ct = plan.StructureSet.Image.Series.ImagingDeviceId;

            if (!DepartmentInfo.GetCTIDs(Department).Contains(ct))
            {
                Result         = "Warning";
                ResultDetails  = $"Patient is being treated on {MachineID}, but the {String.Join(" or ", DepartmentInfo.GetCTIDs(Department))} was not chosen as the imaging device for the series, please check";
                ResultDetails += $"\nSelected CT: {ct}\n";
                DisplayColor   = ResultColorChoices.Warn;
            }

            if (ResultDetails == "")
            {
                Result        = "";
                ResultDetails = ct;
                DisplayColor  = ResultColorChoices.Pass;
            }

            ResultDetails = ResultDetails.TrimEnd('\n');
        }
Esempio n. 2
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "DRRs";
            Result          = "Pass";
            ResultDetails   = "";
            DisplayColor    = ResultColorChoices.Pass;
            TestExplanation = "Checks that DRRs are created and attached as a reference for all fields";

            foreach (Beam field in plan.Beams)
            {
                if (field.ReferenceImage == null)
                {
                    Result         = "Warning";
                    ResultDetails += field.Id + " has no reference image\n";
                    DisplayColor   = ResultColorChoices.Warn;
                }
            }

            ResultDetails = ResultDetails.TrimEnd('\n');
        }
Esempio n. 3
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Tolerance Table";
            Result          = "";
            ResultDetails   = "";
            TestExplanation = "Checks that all fields use the correct tolerance table based on department standards";

            #region Port Huron
            // SRS/SRT for plans with "_5"
            // SBRT for plans with "_4"
            // Electron for electron plans
            // TB Photon for all other plans
            if (Department == Department.MPH)
            {
                string tolTable;
                string badFields = "";

                if (plan.Id.Contains("_5") || plan.StructureSet.Image.ZRes == 1)                 // Plan is single fraction (SRS) or has 1 mm slices (likely a brain SRS or SRT)
                {
                    tolTable = "SRS/SRT";
                }
                else if (plan.Id.Contains("_4"))
                {
                    tolTable = "SBRT";
                }
                else if (plan.Beams.Where(x => !x.IsSetupField).Where(x => x.EnergyModeDisplayName.Contains("E", StringComparison.CurrentCultureIgnoreCase)).Count() > 0)
                {
                    tolTable = "Electron";
                }
                else
                {
                    tolTable = "TB Photon";
                }

                //Check each field to make sure they're the same
                foreach (Beam field in plan.Beams)
                {
                    if (ResultDetails == "")
                    {
                        ResultDetails = field.ToleranceTableLabel;
                    }

                    //wrong tolerance table
                    if (field.ToleranceTableLabel != tolTable)
                    {
                        Result        = "Warning";
                        ResultDetails = $"Not all fields use the {tolTable} tolerance table: ";
                        badFields    += field.Id + ", ";
                        DisplayColor  = ResultColorChoices.Warn;
                    }
                }

                ResultDetails += badFields;
                ResultDetails  = ResultDetails.TrimEnd(' ');
                ResultDetails  = ResultDetails.TrimEnd(',');

                //no issues found
                if (Result == "")
                {
                    Result       = "";
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            #region Macomb / Clarkston / Central / Northern
            // Same tolerance table selected for all fields
            else if (Department == Department.CLA ||
                     Department == Department.MAC ||
                     Department == Department.CEN ||
                     Department == Department.NOR)
            {
                //Check each field to make sure they're the same
                foreach (Beam field in plan.Beams)
                {
                    if (ResultDetails == "")
                    {
                        ResultDetails = field.ToleranceTableLabel;
                    }
                    else if (ResultDetails != field.ToleranceTableLabel)
                    {
                        Result        = "Warning";
                        ResultDetails = "Not all fields have the same tolerance table";
                        DisplayColor  = ResultColorChoices.Warn;
                    }
                }

                //no issues found
                if (Result == "")
                {
                    Result       = "";
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            #region Flint

            // TrueBeam for all plans

            else if (Department == Department.FLT)
            {
                string tolTable;
                string txFieldsResult    = "";
                string badTxFields       = "";
                string setupFieldsResult = "";
                string badSetupFields    = "";

                if (plan.Id.Contains("_5"))                 // SRS Plan
                {
                    tolTable = "TrueBeam";
                }
                else if (plan.Id.Contains("_4"))                 // SBRT Plan
                {
                    tolTable = "TrueBeam";
                }
                else
                {
                    tolTable = "TrueBeam";
                }

                //Check each field to make sure they're the same
                foreach (Beam field in plan.Beams)
                {
                    if (field.IsSetupField)
                    {
                        if (!field.ToleranceTableLabel.Contains("TrueBeam"))
                        {
                            Result            = "Warning";
                            setupFieldsResult = "OBI tolerance table not chosen for setup field: ";
                            badSetupFields   += $"{field.Id}, ";
                            DisplayColor      = ResultColorChoices.Warn;
                        }
                    }
                    else                      // not a setup field
                    {
                        if (ResultDetails == "")
                        {
                            ResultDetails = field.ToleranceTableLabel;
                        }

                        //wrong tolerance table
                        if (field.ToleranceTableLabel != tolTable)
                        {
                            Result         = "Warning";
                            txFieldsResult = $"Not all fields use the {tolTable} tolerance table: ";
                            badTxFields   += $"{field.Id}, ";
                            DisplayColor   = ResultColorChoices.Warn;
                        }
                    }
                }

                if (setupFieldsResult != "" || txFieldsResult != "")
                {
                    ResultDetails += "\n";
                }
                ResultDetails += $"{setupFieldsResult}{badSetupFields}";
                ResultDetails  = ResultDetails.TrimEnd(' ');
                ResultDetails  = ResultDetails.TrimEnd(',');
                if (setupFieldsResult != "")
                {
                    ResultDetails += "\n";
                }
                ResultDetails += $"{txFieldsResult}{badTxFields}";
                ResultDetails  = ResultDetails.TrimEnd(' ');
                ResultDetails  = ResultDetails.TrimEnd(',');

                //no issues found
                if (Result == "")
                {
                    Result       = "";
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            #region Lapeer/Owosso
            // OBI for setup fields
            // Same tolerance table selected for all treatment fields
            else if (Department == Department.LAP ||
                     Department == Department.OWO)
            {
                string tolTable  = "";
                string badFields = "";

                //Check each field to make sure they're the same
                foreach (Beam field in plan.Beams)
                {
                    //if (field.IsSetupField)
                    //{
                    //	if (!field.ToleranceTableLabel.Contains("OBI"))
                    //	{
                    //		Result = "Warning";
                    //		ResultDetails = "OBI tolerance table chosen for setup field of 21iX machine\n";
                    //		DisplayColor = ResultColorChoices.Warn;
                    //		break;
                    //	}
                    //}
                    //else
                    {
                        if (tolTable == "")
                        {
                            tolTable = field.ToleranceTableLabel;
                        }

                        //wrong tolerance table
                        if (field.ToleranceTableLabel != tolTable)
                        {
                            Result        = "Warning";
                            ResultDetails = $"Not all fields use the {tolTable} tolerance table: ";
                            badFields    += field.Id + ", ";
                            DisplayColor  = ResultColorChoices.Warn;
                        }
                    }
                }

                ResultDetails += badFields;
                ResultDetails  = ResultDetails.TrimEnd(' ');
                ResultDetails  = ResultDetails.TrimEnd(',');
                if (ResultDetails != "")
                {
                    ResultDetails += '\n';
                }
                ResultDetails += tolTable;

                //no issues found
                if (Result == "")
                {
                    Result       = "";
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            #region Detroit Group/Lansing
            // 01 SRS for plans with "_5"
            // 02 SBRT for plans with "_4"
            // Same tolerance table selected for all treatment fields otherwise
            else if (Department == Department.DET ||
                     Department == Department.FAR ||
                     Department == Department.LAN)
            {
                string tolTable  = "";
                string badFields = "";

                if (plan.Id.Contains("_5"))
                {
                    tolTable = "01 SRS";
                }
                else if (plan.Id.Contains("_4"))
                {
                    tolTable = "02 SBRT";
                }

                //Check each field to make sure they're the same
                foreach (Beam field in plan.Beams)
                {
                    if (tolTable == "")
                    {
                        tolTable = field.ToleranceTableLabel;
                    }

                    //wrong tolerance table
                    if (field.ToleranceTableLabel != tolTable)
                    {
                        Result        = "Warning";
                        ResultDetails = $"Not all fields use the {tolTable} tolerance table: ";
                        badFields    += field.Id + ", ";
                        DisplayColor  = ResultColorChoices.Warn;
                    }
                }

                ResultDetails += badFields;
                ResultDetails  = ResultDetails.TrimEnd(' ');
                ResultDetails  = ResultDetails.TrimEnd(',');
                if (ResultDetails == "")
                {
                    ResultDetails = tolTable;
                }

                //no issues found
                if (Result == "")
                {
                    Result       = "";
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            else
            {
                TestNotImplemented();
            }
        }
Esempio n. 4
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Naming Conventions";
            TestExplanation = "Checks Course, Plan, and Reference Point naming against OneAria conventions";
            Result          = "";
            ResultDetails   = "";
            DisplayColor    = ResultColorChoices.Pass;

            var courseIdRegexStrings = Properties.Resources.CourseSiteNames.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => $@"^\d{{1,2}} (?:[RL] )?{x}$");
            var planIdRegexStrings   = Properties.Resources.PlanSiteNames.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => $@"^(?:[RL] )?{x}(?: (?:LN|Bst))?_\d[a-z]?\.?$");
            var refPointRegexStrings = Properties.Resources.PlanSiteNames.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => $@"^(?:[RL] )?{x}(?: (?:LN|Bst))?$");

            // Plan ID suffix vs Treatment Type
            if (plan.RTPrescription != null)
            {
                var planSuffixTxTypeDict = new Dictionary <string, string>
                {
                    { "[Clinical Setup]", "0" },
                    { "(2D)", "2" },
                    { "(3D)", "3" },
                    { "(IMRT)", "1" },
                    { "(SBRT)", "4" },
                    { "(SRS)", "5" },
                    { "(TBI)", "2" },
                    { "(VMAT)", "1" },
                    { "{HDR-interstitial", "6" },
                    { "{HDR-intracavitary", "6" },
                    { "{HDR-intraluminal", "6" },
                    { "|MFO|", "7" },
                    { "|SFO|", "7" }
                };
                var fullSuffix = plan.Id.Split('_').Last();
                var suffix     = fullSuffix[0];
                var txType     = plan.RTPrescription.Technique;

                if (planSuffixTxTypeDict.ContainsKey(txType))
                {
                    if (planSuffixTxTypeDict[txType] != suffix.ToString())
                    {
                        ResultDetails += $"Prescribed Technique is {txType} but the plan ID suffix is _{suffix}";
                        DisplayColor   = ResultColorChoices.Warn;
                    }
                }
                else
                {
                    ResultDetails += $"Prescribed Technique {txType} is not supported";
                    DisplayColor   = ResultColorChoices.Warn;
                }
            }

            // Course ID
            bool match = false;

            foreach (var allowedCourseIdString in courseIdRegexStrings)
            {
                Regex courseRegex = new Regex(allowedCourseIdString);
                if (courseRegex.IsMatch(plan.Course.Id))
                {
                    match = true;
                    continue;
                }
            }

            if (!match)
            {
                ResultDetails += $"Course ID: {plan.Course.Id} doesn't match OneAria naming conventions\n";
                DisplayColor   = ResultColorChoices.Warn;
            }

            // Plan ID
            match = false;
            foreach (var allowedPlanIdString in planIdRegexStrings)
            {
                Regex planRegex = new Regex(allowedPlanIdString);
                if (planRegex.IsMatch(plan.Id))
                {
                    match = true;
                    continue;
                }
            }

            if (!match)
            {
                ResultDetails += $"Plan ID: {plan.Id} doesn't match OneAria naming conventions\n";
                DisplayColor   = ResultColorChoices.Warn;
            }

            // Reference Point ID
            match = false;
            foreach (var allowedRefPointString in refPointRegexStrings)
            {
                Regex refPointRegex = new Regex(allowedRefPointString);
                if (refPointRegex.IsMatch(plan.PrimaryReferencePoint.Id))
                {
                    match = true;
                    continue;
                }
            }

            if (!match)
            {
                ResultDetails += $"Reference Point: {plan.PrimaryReferencePoint.Id} doesn't match OneAria naming conventions\n";
                DisplayColor   = ResultColorChoices.Warn;
            }

            // Plan Name
            match = false;
            foreach (var planNameString in refPointRegexStrings)
            {
                Regex planNameRegex = new Regex(planNameString);
                if (planNameRegex.IsMatch(plan.Name))
                {
                    match = true;
                    continue;
                }
            }

            if (!match)
            {
                ResultDetails += $"Plan Name: {(plan.Name == "" ? "Blank name" : plan.Name)} doesn't match OneAria naming conventions\n";
                DisplayColor   = ResultColorChoices.Warn;
            }

            ResultDetails = ResultDetails.TrimEnd('\n');

            if (ResultDetails == "")
            {
                Result = "Pass";
            }
        }
Esempio n. 5
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Couch Values";
            ResultDetails   = "";
            TestExplanation = "Checks that couch values are entered for each field based on department standards";

            #region Macomb/Detroit Groups, Central, and Northern
            // Any couch values entered
            if (Department == Department.CLA ||
                Department == Department.MAC ||
                Department == Department.MPH ||
                Department == Department.DET ||
                Department == Department.FAR ||
                Department == Department.CEN ||
                Department == Department.NOR)
            {
                //Check each field to see if couch values are NaN
                foreach (Beam field in plan.Beams)
                {
                    if (field.ControlPoints.First().TableTopLateralPosition.ToString() == "NaN" || field.ControlPoints.First().TableTopLongitudinalPosition.ToString() == "NaN" || field.ControlPoints.First().TableTopVerticalPosition.ToString() == "NaN")
                    {
                        Result         = "Warning";
                        ResultDetails += "No couch values for " + field.Id.ToString() + ": ";
                        DisplayColor   = ResultColorChoices.Warn;

                        if (field.ControlPoints.First().TableTopLateralPosition.ToString() == "NaN")
                        {
                            ResultDetails += "lat, ";
                        }
                        if (field.ControlPoints.First().TableTopLongitudinalPosition.ToString() == "NaN")
                        {
                            ResultDetails += "long, ";
                        }
                        if (field.ControlPoints.First().TableTopVerticalPosition.ToString() == "NaN")
                        {
                            ResultDetails += "vert, ";
                        }

                        ResultDetails  = ResultDetails.TrimEnd(' ');
                        ResultDetails  = ResultDetails.TrimEnd(',');
                        ResultDetails += '\n';
                    }
                }

                ResultDetails = ResultDetails.TrimEnd('\n');

                //no issues found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = $"Lat: {(ConvertCouchLatToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\n" +
                                    $"Long: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\n" +
                                    $"Vert: {(ConvertCouchVertToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm";
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            #region Flint Group
            // Vert = 0
            // Long = 100
            // Lat = 0
            else if (Department == Department.LAP ||
                     Department == Department.FLT ||
                     Department == Department.OWO)
            {
                //Check each field to see if couch values are NaN
                foreach (Beam field in plan.Beams)
                {
                    if (field.ControlPoints.FirstOrDefault().TableTopLateralPosition != 0 || field.ControlPoints.FirstOrDefault().TableTopLongitudinalPosition != 1000 || field.ControlPoints.FirstOrDefault().TableTopVerticalPosition != 0)
                    {
                        Result         = "Warning";
                        ResultDetails += "Couch value incorrect for " + field.Id.ToString() + ": ";
                        DisplayColor   = ResultColorChoices.Warn;

                        if (field.ControlPoints.First().TableTopLateralPosition != 0)
                        {
                            ResultDetails += "lat, ";
                        }
                        if (field.ControlPoints.First().TableTopLongitudinalPosition != 1000)
                        {
                            ResultDetails += "long, ";
                        }
                        if (field.ControlPoints.First().TableTopVerticalPosition != 0)
                        {
                            ResultDetails += "vert, ";
                        }

                        ResultDetails  = ResultDetails.TrimEnd(' ');
                        ResultDetails  = ResultDetails.TrimEnd(',');
                        ResultDetails += '\n';
                    }
                }

                ResultDetails = ResultDetails.TrimEnd('\n');

                //no issues found
                if (ResultDetails == "")
                {
                    Result = "";
                    if (Department == Department.LAP ||
                        Department == Department.OWO)
                    {
                        ResultDetails = $"Lat: {(ConvertCouchLatToVarianStandardScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\nLong: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\nVert: {(ConvertCouchVertToVarianStandardScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm";
                    }
                    else
                    {
                        ResultDetails = $"Lat: {(ConvertCouchLatToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\n" +
                                        $"Long: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\n" +
                                        $"Vert: {(ConvertCouchVertToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm";
                    }
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            #region Lansing
            // Vert <= 50
            // Long = 50
            // Lat = 0
            else if (Department == Department.LAN)
            {
                //Check each field to see if couch values are NaN
                foreach (Beam field in plan.Beams)
                {
                    if (field.ControlPoints.First().TableTopLateralPosition != 0 || field.ControlPoints.First().TableTopLongitudinalPosition != 500 || field.ControlPoints.First().TableTopVerticalPosition < -500)
                    {
                        Result         = "Warning";
                        ResultDetails += "Couch value incorrect for " + field.Id.ToString() + ": ";
                        DisplayColor   = ResultColorChoices.Warn;

                        if (field.ControlPoints.First().TableTopLateralPosition != 0)
                        {
                            ResultDetails += "lat, ";
                        }
                        if (field.ControlPoints.First().TableTopLongitudinalPosition != 500)
                        {
                            ResultDetails += "long, ";
                        }
                        if (field.ControlPoints.First().TableTopVerticalPosition < -500)
                        {
                            ResultDetails += "vert, ";
                        }

                        ResultDetails  = ResultDetails.TrimEnd(' ');
                        ResultDetails  = ResultDetails.TrimEnd(',');
                        ResultDetails += '\n';
                    }
                }

                ResultDetails = ResultDetails.TrimEnd('\n');

                //no issues found
                if (ResultDetails == "")
                {
                    ResultDetails = $"Lat: {(ConvertCouchLatToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\n" +
                                    $"Long: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\n" +
                                    $"Vert: {(ConvertCouchVertToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm";
                    DisplayColor = ResultColorChoices.Pass;
                }
            }
            #endregion

            else
            {
                TestNotImplemented();
            }
        }
Esempio n. 6
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Bolus";
            Result          = "";
            ResultDetails   = "";
            TestExplanation = "Checks that each field has a linked bolus if a bolus exists";

            string bolus            = "";
            bool   containsBolus    = false;
            bool   containsMultiple = false;
            string resultDetailsMultiPerFieldLine = "";
            string resultDetailsMultiPerPlanLine  = "";

            //Check to see if plan contains a bolus
            foreach (Structure struc in plan.StructureSet.Structures)
            {
                if (struc.DicomType == "BOLUS")
                {
                    //if it's already found one bolus, then there are multiple
                    if (containsBolus)
                    {
                        containsMultiple = true;
                    }

                    containsBolus = true;
                }
            }

            //Check each field to make sure it has a bolus attached
            foreach (Beam field in plan.Beams)
            {
                if (!containsBolus)
                {
                    break;
                }
                if (!field.IsSetupField)
                {
                    //no bolus
                    if (field.Boluses.Count() == 0)
                    {
                        //Set up "no bolus linked" string
                        if (ResultDetails == "")
                        {
                            Result        = "Warning";
                            ResultDetails = "Some fields do not have a linked bolus: ";
                            DisplayColor  = ResultColorChoices.Warn;
                        }
                        ResultDetails += field.Id + ", ";
                    }
                    //more than 1 bolus
                    else if (field.Boluses.Count() > 1)
                    {
                        //set up "multiple boluses" string
                        if (resultDetailsMultiPerFieldLine == "")
                        {
                            Result = "Warning";
                            resultDetailsMultiPerFieldLine = "Some fields have more than one bolus linked: ";
                            DisplayColor = ResultColorChoices.Warn;
                        }
                        resultDetailsMultiPerFieldLine += field.Id + ", ";
                    }
                    //just one bolus
                    else
                    {
                        //if this is the first bolus found, save it
                        if (bolus == "")
                        {
                            bolus = field.Boluses.First().Id;
                        }
                        //if not make sure it's the same bolus used on other fields
                        else if (field.Boluses.First().Id != bolus)
                        {
                            //set up "multiple boluses" string
                            if (resultDetailsMultiPerPlanLine == "")
                            {
                                Result = "Warning";
                                resultDetailsMultiPerPlanLine = $"Multiple bolus structures linked in plan: {bolus}, ";
                                DisplayColor = ResultColorChoices.Warn;
                            }
                            resultDetailsMultiPerPlanLine += field.Boluses.First().Id + ", ";
                        }
                    }
                }
            }

            //no bolus in plan so it's good
            if (!containsBolus)
            {
                Result        = "";
                ResultDetails = "No bolus in structure set";
                DisplayColor  = ResultColorChoices.Pass;
            }
            //no issues found
            else if (Result == "")
            {
                Result        = "";
                ResultDetails = $"{bolus} attached to all fields";
                DisplayColor  = ResultColorChoices.Pass;
            }

            //clean up strings
            ResultDetails = ResultDetails.TrimEnd(' ');
            ResultDetails = ResultDetails.TrimEnd(',');
            resultDetailsMultiPerFieldLine = resultDetailsMultiPerFieldLine.TrimEnd(' ');
            resultDetailsMultiPerFieldLine = resultDetailsMultiPerFieldLine.TrimEnd(',');
            resultDetailsMultiPerPlanLine  = resultDetailsMultiPerPlanLine.TrimEnd(' ');
            resultDetailsMultiPerPlanLine  = resultDetailsMultiPerPlanLine.TrimEnd(',');
            if (resultDetailsMultiPerFieldLine != "")
            {
                ResultDetails += '\n' + resultDetailsMultiPerFieldLine;
            }
            if (resultDetailsMultiPerPlanLine != "")
            {
                ResultDetails += '\n' + resultDetailsMultiPerPlanLine;
            }
            ResultDetails = ResultDetails.TrimStart('\n');
            ResultDetails = ResultDetails.TrimStart('\n');

            //multiple boluses in structure set, so put a warning at the end
            if (containsMultiple)
            {
                Result         = "Warning";
                ResultDetails += "\nMultiple bolus structures in the structure set, please ensure that the correct one is used";
                DisplayColor   = ResultColorChoices.Warn;
            }
        }
Esempio n. 7
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Dose Rate";
            ResultDetails   = "";
            TestExplanation = "Checks that all dose rates are set to maximum allowed per department standards";

            #region Macomb Group and Northern TrueBeam
            // Flattened - 600
            // 6FFF      - 1400
            // 10FFF     - 2400
            // Electron  - 1000
            if (Department == Department.CLA ||
                Department == Department.MAC ||
                Department == Department.MPH ||
                (Department == Department.NOR && MachineID == DepartmentInfo.MachineNames.NOR_TB))
            {
                foreach (Beam field in plan.Beams)
                {
                    //ignore setup fields
                    if (!field.IsSetupField)
                    {
                        string energy = field.EnergyModeDisplayName;

                        if (energy == "6X" || energy == "10X" || energy == "15X" || energy == "16X" || energy == "18X" || energy == "23X")
                        {
                            if (field.DoseRate < 600)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy == "6X-FFF")
                        {
                            if (field.DoseRate < 1400)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy == "10X-FFF")
                        {
                            if (field.DoseRate < 2400)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy.Contains("E", StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (field.DoseRate < 1000)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                    }
                }

                //no problems found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = plan.Beams.Where(x => !x.IsSetupField).First().DoseRate.ToString();
                    DisplayColor  = ResultColorChoices.Pass;
                }

                ResultDetails = ResultDetails.TrimEnd('\n');
            }
            #endregion

            #region Flint TrueBeams
            // Flattened - 600
            // 6FFF      - 1400
            // 10FFF     - 2400
            // Electron  - 600
            else if (Department == Department.FLT)
            {
                foreach (Beam field in plan.Beams)
                {
                    //ignore setup fields
                    if (!field.IsSetupField)
                    {
                        string energy = field.EnergyModeDisplayName;

                        if (energy == "6X" || energy == "10X" || energy == "15X" || energy == "16X" || energy == "18X" || energy == "23X")
                        {
                            if (field.DoseRate < 600)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy == "6X-FFF")
                        {
                            if (field.DoseRate < 1400)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy == "10X-FFF")
                        {
                            if (field.DoseRate < 2400)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy.Contains("E", StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (field.DoseRate < 600)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                    }
                }

                //no problems found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = plan.Beams.Where(x => !x.IsSetupField).First().DoseRate.ToString();
                    DisplayColor  = ResultColorChoices.Pass;
                }

                ResultDetails = ResultDetails.TrimEnd('\n');
            }
            #endregion

            #region Lapeer / Owosso
            // Photon   - 600
            // Electron - 400
            else if (Department == Department.LAP ||
                     Department == Department.OWO)
            {
                foreach (Beam field in plan.Beams)
                {
                    //ignore setup fields
                    if (!field.IsSetupField)
                    {
                        string energy = field.EnergyModeDisplayName;

                        if (energy == "6X" || energy == "10X" || energy == "15X" || energy == "16X" || energy == "18X" || energy == "23X")
                        {
                            if (field.DoseRate < 600)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy.Contains("E", StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (field.DoseRate < 400)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                    }
                }

                //no problems found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = plan.Beams.Where(x => !x.IsSetupField).First().DoseRate.ToString();
                    DisplayColor  = ResultColorChoices.Pass;
                }

                ResultDetails = ResultDetails.TrimEnd('\n');
            }
            #endregion

            #region Lansing
            // IMRT     - 500
            // 3D       - 600
            // Electron - 400
            else if (Department == Department.LAN)
            {
                foreach (Beam field in plan.Beams)
                {
                    //ignore setup fields
                    if (!field.IsSetupField)
                    {
                        string energy = field.EnergyModeDisplayName;

                        if (energy == "6X" || energy == "10X" || energy == "15X" || energy == "16X" || energy == "18X" || energy == "23X")
                        {
                            //for IMRT fields that have more control points than step and shoot, dose rate should be 500
                            if (field.MLCPlanType == MLCPlanType.DoseDynamic && field.ControlPoints.Count > 18)
                            {
                                if (field.DoseRate != 500)
                                {
                                    Result         = "Warning";
                                    ResultDetails += field.Id + " (IMRT) dose rate set at " + field.DoseRate + "\n";
                                    DisplayColor   = ResultColorChoices.Warn;
                                }
                            }
                            //3D dose rate should be 600
                            else
                            {
                                if (field.DoseRate < 600)
                                {
                                    Result         = "Warning";
                                    ResultDetails += field.Id + " (3D) dose rate set at " + field.DoseRate + "\n";
                                    DisplayColor   = ResultColorChoices.Warn;
                                }
                            }
                        }
                        else if (energy.Contains("E", StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (field.DoseRate != 400)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " (electron) dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                    }
                }

                //no problems found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = plan.Beams.Where(x => !x.IsSetupField).First().DoseRate.ToString();
                    DisplayColor  = ResultColorChoices.Pass;
                }

                ResultDetails = ResultDetails.TrimEnd('\n');
            }
            #endregion

            #region Detroit group
            // IMRT & 3D - 400
            // VMAT      - 600
            // 10FFF     - 1600
            // Electron  - 1000
            else if (Department == Department.DET ||
                     Department == Department.FAR)
            {
                foreach (Beam field in plan.Beams)
                {
                    //ignore setup fields
                    if (!field.IsSetupField)
                    {
                        string energy     = field.EnergyModeDisplayName;
                        string field_type = field.Technique.ToString();

                        if (energy == "6X" || energy == "10X" || energy == "15X")
                        {
                            if ((field.DoseRate < 600) && (field_type.Contains("ARC", StringComparison.CurrentCultureIgnoreCase)))
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                            else if (field.DoseRate != 400 && field_type.Contains("STATIC", StringComparison.CurrentCultureIgnoreCase))
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy == "10X-FFF")
                        {
                            if (field.DoseRate < 1600)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (energy.Contains("E", StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (field.DoseRate < 1000)
                            {
                                Result         = "Warning";
                                ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                    }
                }

                //no problems found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = plan.Beams.Where(x => !x.IsSetupField).First().DoseRate.ToString();
                    DisplayColor  = ResultColorChoices.Pass;
                }

                ResultDetails = ResultDetails.TrimEnd('\n');
            }
            #endregion

            #region Northern Trilogy
            // 600 for everything
            else if (Department == Department.NOR)
            {
                foreach (Beam field in plan.Beams)
                {
                    //ignore setup fields
                    if (!field.IsSetupField)
                    {
                        if (field.DoseRate < 600)
                        {
                            Result         = "Warning";
                            ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                            DisplayColor   = ResultColorChoices.Warn;
                        }
                    }
                }

                //no problems found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = plan.Beams.Where(x => !x.IsSetupField).First().DoseRate.ToString();
                    DisplayColor  = ResultColorChoices.Pass;
                }

                ResultDetails = ResultDetails.TrimEnd('\n');
            }
            #endregion

            #region Central
            // 400 or 600 for everything
            else if (Department == Department.CEN)
            {
                foreach (Beam field in plan.Beams)
                {
                    //ignore setup fields
                    if (!field.IsSetupField)
                    {
                        if (field.DoseRate != 600 && field.DoseRate != 400)
                        {
                            Result         = "Warning";
                            ResultDetails += field.Id + " dose rate set at " + field.DoseRate + "\n";
                            DisplayColor   = ResultColorChoices.Warn;
                        }
                    }
                }

                //no problems found
                if (ResultDetails == "")
                {
                    Result        = "";
                    ResultDetails = plan.Beams.Where(x => !x.IsSetupField).First().DoseRate.ToString();
                    DisplayColor  = ResultColorChoices.Pass;
                }

                ResultDetails = ResultDetails.TrimEnd('\n');
            }
            #endregion

            else
            {
                TestNotImplemented();
            }
        }
Esempio n. 8
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Field Names";
            ResultDetails   = "";
            TestExplanation = "Checks that field names follow OneAria naming conventions";

            foreach (Beam field in plan.Beams)
            {
                //ignore setup fields
                if (!field.IsSetupField)
                {
                    #region Static Gantry Angles
                    //for static fields, check that the gantry angle is contained in the field name
                    if (field.Technique.ToString() == "STATIC" || field.Technique.ToString() == "SRS STATIC")
                    {
                        //field name matching pattern: g125 with or without a space or "_" between
                        string fieldNameGantry = "(?i)g_? ?" + Math.Round(field.GantryAngleToUser(field.ControlPoints.First().GantryAngle), 0).ToString();

                        if (!Regex.IsMatch(field.Id, fieldNameGantry))
                        {
                            Result         = "Warning";
                            ResultDetails += "Field name mismatch  —  Field: " + field.Id + "  Gantry Angle: " + field.GantryAngleToUser(field.ControlPoints.FirstOrDefault().GantryAngle).ToString() + "\n";
                            DisplayColor   = ResultColorChoices.Warn;
                        }
                    }
                    #endregion

                    #region Arcs
                    //for arc fields, check that cw vs ccw matches rotation direction
                    else if (field.Technique.ToString() == "ARC" || field.Technique.ToString() == "SRS ARC")
                    {
                        if (field.GantryDirection == GantryDirection.Clockwise)
                        {
                            if (field.Id.Contains("ccw", StringComparison.CurrentCultureIgnoreCase) || !field.Id.Contains("cw", StringComparison.CurrentCultureIgnoreCase))
                            {
                                Result         = "Warning";
                                ResultDetails += "Field name mismatch  —  Field: " + field.Id + "  Gantry Direction: " + field.GantryDirection + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                        else if (field.GantryDirection == GantryDirection.CounterClockwise)
                        {
                            if (!field.Id.Contains("ccw", StringComparison.CurrentCultureIgnoreCase))
                            {
                                Result         = "Warning";
                                ResultDetails += "Field name mismatch  —  Field: " + field.Id + "  Gantry Direction: " + field.GantryDirection + "\n";
                                DisplayColor   = ResultColorChoices.Warn;
                            }
                        }
                    }
                    #endregion

                    #region Couch Kicks
                    //check for pedestal kicks
                    if (field.ControlPoints.First().PatientSupportAngle != 0)
                    {
                        //field name matching pattern: g125 with or without a space or "_" between
                        string fieldNamePedestal = "(?i)(p|t)_? ?" + Math.Round(field.PatientSupportAngleToUser(field.ControlPoints.First().PatientSupportAngle), 0).ToString();

                        if (!Regex.IsMatch(field.Id, fieldNamePedestal))
                        {
                            Result         = "Warning";
                            ResultDetails += "Field name mismatch  —  Field: " + field.Id + "  Pedestal Angle: " + field.PatientSupportAngleToUser(field.ControlPoints.First().PatientSupportAngle).ToString() + "\n";
                            DisplayColor   = ResultColorChoices.Warn;
                        }
                    }
                    #endregion
                }
            }

            ResultDetails = ResultDetails.TrimEnd('\n');

            //no problems found
            if (ResultDetails == "")
            {
                Result       = "Pass";
                DisplayColor = ResultColorChoices.Pass;
            }
        }
Esempio n. 9
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Patient Shifts";
            TestExplanation = "Displays shifts from Marker Structure or User Origin";
            Result          = "";
            ResultDetails   = "";
            DisplayColor    = ResultColorChoices.Pass;

            PatientOrientation orientation = plan.TreatmentOrientation;

            // get location of user origin and plan isocenter
            VVector tattoos   = plan.StructureSet.Image.UserOrigin;
            VVector isocenter = plan.Beams.First().IsocenterPosition;

            // calculated shift distance from user origin
            VVector shift     = isocenter - tattoos;
            string  shiftFrom = "User Origin";

            // these sites set iso at sim and import in a "MARKER" structure that shifts will be based off (also they don't use gold markers, so there's no need to worry about those "MARKER" structures)
            if (Department == Department.MPH ||
                Department == Department.FLT ||
                Department == Department.LAP ||
                Department == Department.OWO ||
                Department == Department.DET ||
                Department == Department.FAR)
            {
                // loop through each patient marker and see if it's closer to the iso than the user origin and if it is use that for the calculated shift
                foreach (Structure point in plan.StructureSet.Structures.Where(x => x.DicomType == "MARKER"))
                {
                    if (Math.Round((isocenter - point.CenterPoint).Length, 2) <= Math.Round(shift.Length, 2))
                    {
                        shift     = isocenter - point.CenterPoint;
                        shiftFrom = point.Id;
                    }
                }
            }

            //round it off to prevent very small numbers from appearing and convert to cm for shifts
            shift.x = Math.Round(shift.x / 10, 1);
            shift.y = Math.Round(shift.y / 10, 1);
            shift.z = Math.Round(shift.z / 10, 1);

            if (shift.Length == 0)
            {
                ResultDetails = $"No shifts from {shiftFrom}";
            }
            else
            {
                // Set shift verbiage based on department
                string pat, sup, inf, ant, post;
                if (Department == Department.NOR)
                {
                    pat  = "Table";
                    sup  = "out";
                    inf  = "in";
                    ant  = "down";
                    post = "up";
                }
                else
                {
                    pat  = "Patient";
                    sup  = "superior";
                    inf  = "inferior";
                    ant  = "anterior";
                    post = "posterior";
                }

                //x-axis
                if (shift.x > 0)
                {
                    ResultDetails += $"{pat} left: {shift.x:0.0} cm\n";
                }
                else if (shift.x < 0)
                {
                    ResultDetails += $"{pat} right: {-shift.x:0.0} cm\n";
                }

                //z-axis
                if (shift.z > 0)
                {
                    ResultDetails += $"{pat} {sup}: {shift.z:0.0} cm\n";
                }
                else if (shift.z < 0)
                {
                    ResultDetails += $"{pat} {inf}: {-shift.z:0.0} cm\n";
                }

                //y-axis
                if (shift.y > 0)
                {
                    ResultDetails += $"{pat} {post}: {shift.y:0.0} cm\n";
                }
                else if (shift.y < 0)
                {
                    ResultDetails += $"{pat}  {ant}: {-shift.y:0.0} cm\n";
                }


                //remove negatives
                ResultDetails.Replace("-", string.Empty);

                ResultDetails = $"Shifts from {shiftFrom}\n" + ResultDetails;
            }

            ResultDetails = ResultDetails.TrimEnd('\n');
        }
Esempio n. 10
0
        protected override void RunTest(PlanSetup plan)
        {
            DisplayName     = "Isocenter";
            ResultDetails   = "";
            TestExplanation = "Checks that only a single isocenter exists in the plan\nAlso suggests using G180E if the isocenter is shifted >2cm to patient's right";

            int isocenters = 1;


            VVector firstIso = plan.Beams.FirstOrDefault().IsocenterPosition;

            foreach (Beam field in plan.Beams)
            {
                //check for multiple isocenters
                if (field != plan.Beams.First())
                {
                    //if there's no distance between the two, they are equal
                    if (VVector.Distance(field.IsocenterPosition, firstIso) != 0)
                    {
                        isocenters++;
                    }
                }

                //check if 180E might be necessary
                if (!field.IsSetupField && field.ControlPoints.First().GantryAngle == 180)
                {
                    try
                    {
                        Structure body = (from s in plan.StructureSet.Structures where (s.DicomType == "BODY" || s.DicomType == "EXTERNAL") select s).First();

                        //Looks for the isocenter position to be 20 mm to the left when facing the linac. Positions are in mm
                        if (field.IsocenterPosition.x - body.CenterPoint.x < -20 && (plan.TreatmentOrientation == PatientOrientation.HeadFirstSupine || plan.TreatmentOrientation == PatientOrientation.FeetFirstProne))
                        {
                            Result         = "Warning";
                            ResultDetails += $"Isocenter is shifted to patients right, do you want to use {field.GantryAngleToUser(180)}E?\n";
                            DisplayColor   = ResultColorChoices.Warn;
                        }
                        if (field.IsocenterPosition.x - body.CenterPoint.x > 20 && (plan.TreatmentOrientation == PatientOrientation.HeadFirstProne || plan.TreatmentOrientation == PatientOrientation.FeetFirstSupine))
                        {
                            Result         = "Warning";
                            ResultDetails += $"Isocenter is shifted to patients left, do you want to use {field.GantryAngleToUser(180)}E?\n";
                            DisplayColor   = ResultColorChoices.Warn;
                        }
                    }
                    catch
                    {
                        TestCouldNotComplete("CheckIsocenterPosition - No structure with type \"BODY\" or \"EXTERNAL\" found");
                    }
                }
            }

            if (isocenters > 1)
            {
                Result         = "Warning";
                ResultDetails += $"{isocenters} isocenters detected, please check plan\n";
                DisplayColor   = ResultColorChoices.Warn;
            }

            ResultDetails = ResultDetails.TrimEnd('\n');

            //no problems found
            if (ResultDetails == "")
            {
                Result       = "Pass";
                DisplayColor = ResultColorChoices.Pass;
            }
        }