Skip to content

Commit

Permalink
Added check for structure number of parts
Browse files Browse the repository at this point in the history
  • Loading branch information
LDClark committed Aug 12, 2020
1 parent d8d451c commit eca35be
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 8 deletions.
9 changes: 8 additions & 1 deletion PlanCheck.Script/Calculators/ErrorCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public ObservableCollection<ErrorViewModel> GetStructureSetErrors(StructureSet s
AddNewRow(description, status, severity, errorGrid);
}
}

if (structure.GetNumberOfSeparateParts() > 1)
{
var description = string.Format("Structure {0} has {1} separate parts.", structure.Id, structure.GetNumberOfSeparateParts());
var severity = 1;
var status = "1 - Warning";
AddNewRow(description, status, severity, errorGrid);
}
}
catch
{
Expand Down Expand Up @@ -213,7 +221,6 @@ public ObservableCollection<ErrorViewModel> GetPlanSetupErrors(PlanSetup planSet
}
}

Console.WriteLine(DateTime.Now + " now , plan" + planSetup.StructureSet.Image.CreationDateTime.Value);
if ((planSetup.CreationDateTime.Value - planSetup.StructureSet.Image.CreationDateTime.Value).TotalDays > 21)
{
error = string.Format("CT and structure data ({0}) is {1} days older than plan creation date ({2}) and outside of 21 days.", planSetup.StructureSet.Image.CreationDateTime.Value, (planSetup.CreationDateTime.Value - planSetup.StructureSet.Image.CreationDateTime.Value).TotalDays.ToString("0"), planSetup.CreationDateTime.Value);
Expand Down
6 changes: 3 additions & 3 deletions PlanCheck.Script/Esapi/EsapiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public Task<Plan[]> GetPlansAsync() =>
CourseId = x.GetCourse().Id,
PlanType = Extensions.GetPlanType(x),
PlanCreation = Extensions.GetCreationDateTime(x),
PlanStructureSetId = x.StructureSet.Id,
PlanImageId = x.StructureSet.Image.Id,
PlanImageCreation = (DateTime)x.StructureSet.Image.CreationDateTime,
PlanStructureSetId = Extensions.GetStructureSetId(x),
PlanImageId = Extensions.GetPlanImageId(x),
PlanImageCreation = Extensions.GetPlanImageCreation(x),
PlanIdWithFractionation = x.Id + Extensions.GetFractionation(x)
})
.ToArray());
Expand Down
55 changes: 54 additions & 1 deletion PlanCheck.Script/Esapi/Extensionscs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,59 @@ public static Course GetCourse(this PlanningItem plan)
throw new InvalidOperationException("Unknown PlanningItem type.");
}

public static string GetStructureSetId(this PlanningItem plan)
{
try
{
switch (plan)
{
case PlanSetup planSetup: return planSetup.StructureSet.Id;
case PlanSum planSum: return planSum.StructureSet.Id;
}

throw new InvalidOperationException("Unknown PlanningItem type.");
}
catch
{
return "";
}
}

public static string GetPlanImageId(this PlanningItem plan)
{
try
{
switch (plan)
{
case PlanSetup planSetup: return planSetup.StructureSet.Image.Id;
case PlanSum planSum: return planSum.StructureSet.Image.Id;
}

throw new InvalidOperationException("Unknown PlanningItem type.");
}
catch
{
return "";
}
}
public static DateTime GetPlanImageCreation(this PlanningItem plan)
{
try
{
switch (plan)
{
case PlanSetup planSetup: return (DateTime) planSetup.StructureSet.Image.CreationDateTime;
case PlanSum planSum: return (DateTime) planSum.StructureSet.Image.CreationDateTime;
}

throw new InvalidOperationException("Unknown PlanningItem type.");
}
catch
{
return DateTime.Now;
}
}

public static PlanningItem GetPlanningItem(Patient patient, string courseId, string planId)
{
var course = GetCourse(patient, courseId);
Expand Down Expand Up @@ -64,7 +117,7 @@ public static string GetFractionation(this PlanningItem plan)
{
switch (plan)
{
case PlanSetup planSetup: return " - " + planSetup.TotalDose.ValueAsString + " " + planSetup.TotalDose.UnitAsString + " x " + planSetup.NumberOfFractions;
case PlanSetup planSetup: return " - " + planSetup.DosePerFraction.ValueAsString + " " + planSetup.DosePerFraction.UnitAsString + " x " + planSetup.NumberOfFractions + " to " + planSetup.TotalDose.ValueAsString + " " + planSetup.TotalDose.UnitAsString;
case PlanSum planSum: return "";
}
throw new InvalidOperationException("Unknown PlanningItem type.");
Expand Down
6 changes: 3 additions & 3 deletions PlanCheck.Script/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public async void AnalyzePlan()
return;

var structures = await _esapiService.GetStructuresAsync(courseId, planId);
if (structures == null)
return;

CollimatorModel = null;
CouchBodyModel = null;
Expand All @@ -204,7 +206,7 @@ public async void AnalyzePlan()
}
PQMViewModel[] pqms = Objectives.GetObjectives(SelectedConstraint);

_dialogService.ShowProgressDialog("Calculating dose metrics", structures.Count(),
_dialogService.ShowProgressDialog("Calculating dose metrics...", structures.Count(),
async progress =>
{
PQMs = new ObservableCollection<PQMViewModel>();
Expand All @@ -225,8 +227,6 @@ public async void AnalyzePlan()
{
if (code == structure.StructureCode)
{
if (code == "9680")
goal = "";
result = "";
resultCompare1 = "";
resultCompare2 = "";
Expand Down
1 change: 1 addition & 0 deletions PlanCheck.Script/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
<Style TargetType="ComboBoxItem">
<Setter Property="Background" Value="#FF2B2B2B" />
<Setter Property="Foreground" Value="LightGray" />
<Setter Property="BorderBrush" Value="Black" />
</Style>
</ComboBox.Resources>
</ComboBox>
Expand Down

0 comments on commit eca35be

Please sign in to comment.