Skip to content

Commit eca35be

Browse files
committed
Added check for structure number of parts
1 parent d8d451c commit eca35be

5 files changed

Lines changed: 69 additions & 8 deletions

File tree

PlanCheck.Script/Calculators/ErrorCalculator.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ public ObservableCollection<ErrorViewModel> GetStructureSetErrors(StructureSet s
6969
AddNewRow(description, status, severity, errorGrid);
7070
}
7171
}
72+
73+
if (structure.GetNumberOfSeparateParts() > 1)
74+
{
75+
var description = string.Format("Structure {0} has {1} separate parts.", structure.Id, structure.GetNumberOfSeparateParts());
76+
var severity = 1;
77+
var status = "1 - Warning";
78+
AddNewRow(description, status, severity, errorGrid);
79+
}
7280
}
7381
catch
7482
{
@@ -213,7 +221,6 @@ public ObservableCollection<ErrorViewModel> GetPlanSetupErrors(PlanSetup planSet
213221
}
214222
}
215223

216-
Console.WriteLine(DateTime.Now + " now , plan" + planSetup.StructureSet.Image.CreationDateTime.Value);
217224
if ((planSetup.CreationDateTime.Value - planSetup.StructureSet.Image.CreationDateTime.Value).TotalDays > 21)
218225
{
219226
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);

PlanCheck.Script/Esapi/EsapiService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public Task<Plan[]> GetPlansAsync() =>
3030
CourseId = x.GetCourse().Id,
3131
PlanType = Extensions.GetPlanType(x),
3232
PlanCreation = Extensions.GetCreationDateTime(x),
33-
PlanStructureSetId = x.StructureSet.Id,
34-
PlanImageId = x.StructureSet.Image.Id,
35-
PlanImageCreation = (DateTime)x.StructureSet.Image.CreationDateTime,
33+
PlanStructureSetId = Extensions.GetStructureSetId(x),
34+
PlanImageId = Extensions.GetPlanImageId(x),
35+
PlanImageCreation = Extensions.GetPlanImageCreation(x),
3636
PlanIdWithFractionation = x.Id + Extensions.GetFractionation(x)
3737
})
3838
.ToArray());

PlanCheck.Script/Esapi/Extensionscs.cs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,59 @@ public static Course GetCourse(this PlanningItem plan)
2929
throw new InvalidOperationException("Unknown PlanningItem type.");
3030
}
3131

32+
public static string GetStructureSetId(this PlanningItem plan)
33+
{
34+
try
35+
{
36+
switch (plan)
37+
{
38+
case PlanSetup planSetup: return planSetup.StructureSet.Id;
39+
case PlanSum planSum: return planSum.StructureSet.Id;
40+
}
41+
42+
throw new InvalidOperationException("Unknown PlanningItem type.");
43+
}
44+
catch
45+
{
46+
return "";
47+
}
48+
}
49+
50+
public static string GetPlanImageId(this PlanningItem plan)
51+
{
52+
try
53+
{
54+
switch (plan)
55+
{
56+
case PlanSetup planSetup: return planSetup.StructureSet.Image.Id;
57+
case PlanSum planSum: return planSum.StructureSet.Image.Id;
58+
}
59+
60+
throw new InvalidOperationException("Unknown PlanningItem type.");
61+
}
62+
catch
63+
{
64+
return "";
65+
}
66+
}
67+
public static DateTime GetPlanImageCreation(this PlanningItem plan)
68+
{
69+
try
70+
{
71+
switch (plan)
72+
{
73+
case PlanSetup planSetup: return (DateTime) planSetup.StructureSet.Image.CreationDateTime;
74+
case PlanSum planSum: return (DateTime) planSum.StructureSet.Image.CreationDateTime;
75+
}
76+
77+
throw new InvalidOperationException("Unknown PlanningItem type.");
78+
}
79+
catch
80+
{
81+
return DateTime.Now;
82+
}
83+
}
84+
3285
public static PlanningItem GetPlanningItem(Patient patient, string courseId, string planId)
3386
{
3487
var course = GetCourse(patient, courseId);
@@ -64,7 +117,7 @@ public static string GetFractionation(this PlanningItem plan)
64117
{
65118
switch (plan)
66119
{
67-
case PlanSetup planSetup: return " - " + planSetup.TotalDose.ValueAsString + " " + planSetup.TotalDose.UnitAsString + " x " + planSetup.NumberOfFractions;
120+
case PlanSetup planSetup: return " - " + planSetup.DosePerFraction.ValueAsString + " " + planSetup.DosePerFraction.UnitAsString + " x " + planSetup.NumberOfFractions + " to " + planSetup.TotalDose.ValueAsString + " " + planSetup.TotalDose.UnitAsString;
68121
case PlanSum planSum: return "";
69122
}
70123
throw new InvalidOperationException("Unknown PlanningItem type.");

PlanCheck.Script/ViewModels/MainViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ public async void AnalyzePlan()
193193
return;
194194

195195
var structures = await _esapiService.GetStructuresAsync(courseId, planId);
196+
if (structures == null)
197+
return;
196198

197199
CollimatorModel = null;
198200
CouchBodyModel = null;
@@ -204,7 +206,7 @@ public async void AnalyzePlan()
204206
}
205207
PQMViewModel[] pqms = Objectives.GetObjectives(SelectedConstraint);
206208

207-
_dialogService.ShowProgressDialog("Calculating dose metrics", structures.Count(),
209+
_dialogService.ShowProgressDialog("Calculating dose metrics...", structures.Count(),
208210
async progress =>
209211
{
210212
PQMs = new ObservableCollection<PQMViewModel>();
@@ -225,8 +227,6 @@ public async void AnalyzePlan()
225227
{
226228
if (code == structure.StructureCode)
227229
{
228-
if (code == "9680")
229-
goal = "";
230230
result = "";
231231
resultCompare1 = "";
232232
resultCompare2 = "";

PlanCheck.Script/Views/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@
245245
<Style TargetType="ComboBoxItem">
246246
<Setter Property="Background" Value="#FF2B2B2B" />
247247
<Setter Property="Foreground" Value="LightGray" />
248+
<Setter Property="BorderBrush" Value="Black" />
248249
</Style>
249250
</ComboBox.Resources>
250251
</ComboBox>

0 commit comments

Comments
 (0)