Skip to content

Commit

Permalink
can now bring in plans which are not in the same course. Swapped & fo…
Browse files Browse the repository at this point in the history
…r | on joined structures
  • Loading branch information
rexcardan committed Sep 17, 2019
1 parent 1b63d88 commit 05cf574
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 43 deletions.
8 changes: 4 additions & 4 deletions ESAPIX/Common/Args/ArgContextSetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void Set(StandAloneContext sac, string[] commandLineArgs)
var plansInScope = ArgumentParser.GetPlansInScope(commandLineArgs);
if (plansInScope != null && plansInScope.Any())
{
var plans = sac.Course.PlanSetups.Where(p => plansInScope.Contains(p.UID));
var plans = sac.Patient.Courses.SelectMany(c=>c.PlanSetups).Where(p => plansInScope.Contains(p.UID));
sac.SetPlansInScope(plans);
}
}
Expand All @@ -70,15 +70,15 @@ public static void Set(StandAloneContext sac, string[] commandLineArgs)
var explansInScope = ArgumentParser.GetExternalPlansInScope(commandLineArgs);
if (explansInScope != null && explansInScope.Any())
{
var plans = sac.Course.ExternalPlanSetups.Where(p => explansInScope.Contains(p.UID));
var plans = sac.Patient.Courses.SelectMany(c => c.ExternalPlanSetups).Where(p => explansInScope.Contains(p.UID));
sac.SetExternalPlansInScope(plans);
}
}
{
var brachyInScope = ArgumentParser.GetBrachyPlansInScope(commandLineArgs);
if (brachyInScope != null && brachyInScope.Any())
{
var plans = sac.Course.BrachyPlanSetups.Where(p => brachyInScope.Contains(p.UID));
var plans = sac.Patient.Courses.SelectMany(c => c.BrachyPlanSetups).Where(p => brachyInScope.Contains(p.UID));
sac.SetBrachyPlansInScope(plans);
}
}
Expand All @@ -88,7 +88,7 @@ public static void Set(StandAloneContext sac, string[] commandLineArgs)
var ionPlansInScope = ArgumentParser.GetIonPlansInScope(commandLineArgs);
if (ionPlansInScope != null && ionPlansInScope.Any())
{
var plans = sac.Course.IonPlanSetups.Where(p => ionPlansInScope.Contains(p.UID));
var plans = sac.Patient.Courses.SelectMany(c => c.IonPlanSetups).Where(p => ionPlansInScope.Contains(p.UID));
sac.SetIonPlansInScope(plans);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ESAPIX/Constraints/DVH/ConstraintBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ESAPIX.Constraints.DVH
{
public class ConstraintBuilder
{
public static IConstraint Build(string structureName, string mayoConstraint, PriorityType priority = PriorityType.IDEAL)
public static IConstraint Build(string structureName, string mayoConstraint, PriorityType priority = PriorityType.PRIORITY_1)
{
var mayo = MayoConstraint.Read(mayoConstraint);
return mayo.ToDVHConstraint(structureName, priority);
Expand Down
9 changes: 5 additions & 4 deletions ESAPIX/Constraints/DVH/DoseStructureConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ESAPIX.Constraints.DVH
public abstract class DoseStructureConstraint : IPriorityConstraint
{
/// <summary>
/// The string structure name corresponding to the structure ID in Eclipse. Separate with '&' character for multiple
/// The string structure name corresponding to the structure ID in Eclipse. Separate with '|' character for multiple
/// structures
/// </summary>
public string StructureName { get; set; }
Expand Down Expand Up @@ -45,7 +45,7 @@ public DoseValue ConstraintDose
/// Splits structure names separated by & character
/// </summary>
[JsonIgnore]
public string[] StructureNames => StructureName.Split(new[] {"&"}, StringSplitOptions.RemoveEmptyEntries);
public string[] StructureNames => StructureName.Split(new[] {"|"}, StringSplitOptions.RemoveEmptyEntries);

public virtual string Name => ToString();
public string FullName => $"{StructureName} {Name}";
Expand All @@ -62,7 +62,7 @@ public ConstraintResult CanConstrain(PlanningItem pi)
if (!valid) return new ConstraintResult(this, ResultType.NOT_APPLICABLE, "Plan is null");

//Check structure exists
var structures = StructureName.Split('&');
var structures = StructureName.Split('|').Select(n=>n.Trim());
foreach (var s in structures)
{
valid = pi.ContainsStructure(s);
Expand All @@ -84,8 +84,9 @@ public ResultType GetFailedResultType()
{
switch (Priority)
{
case PriorityType.MAJOR_DEVIATION:
case PriorityType.PRIORITY_1: return ResultType.ACTION_LEVEL_3;
case PriorityType.PRIORITY_2: return ResultType.ACTION_LEVEL_2;
case PriorityType.PRIORITY_3: return ResultType.ACTION_LEVEL_1;
default: return ResultType.ACTION_LEVEL_1;
}
}
Expand Down
3 changes: 2 additions & 1 deletion ESAPIX/Constraints/NFractionConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ public ResultType GetFailedResultType()
{
switch (Priority)
{
case PriorityType.MAJOR_DEVIATION:
case PriorityType.PRIORITY_1: return ResultType.ACTION_LEVEL_3;
case PriorityType.PRIORITY_2: return ResultType.ACTION_LEVEL_2;
case PriorityType.PRIORITY_3: return ResultType.ACTION_LEVEL_1;
default: return ResultType.ACTION_LEVEL_1;
}
}
Expand Down
3 changes: 2 additions & 1 deletion ESAPIX/Constraints/PriorityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public static ResultType GetFailedResult(PriorityType priority)
{
switch (priority)
{
case PriorityType.MAJOR_DEVIATION:
case PriorityType.PRIORITY_1: return ResultType.ACTION_LEVEL_3;
case PriorityType.PRIORITY_2: return ResultType.ACTION_LEVEL_2;
case PriorityType.PRIORITY_3: return ResultType.ACTION_LEVEL_1;
default: return ResultType.ACTION_LEVEL_1;
}
}
Expand Down
13 changes: 4 additions & 9 deletions ESAPIX/Constraints/PriorityType.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#region

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

#endregion

namespace ESAPIX.Constraints
{
public enum PriorityType
{
[Description("Ideal")] IDEAL,
[Description("Acceptable")] ACCEPTABLE,
[Description("Minor Deviation")] MINOR_DEVIATION,
[Description("Major Deviation")] MAJOR_DEVIATION,
[Description("Goal")] GOAL,
[Description("Optional")] OPTIONAL,
[Description("Report")] REPORT,
[Description("Priority 1")] PRIORITY_1,
[Description("Priority 2")] PRIORITY_2
[Display(Name = "I")] PRIORITY_1,
[Display(Name = "II")] PRIORITY_2,
[Display(Name = "III")] PRIORITY_3,
}
}
7 changes: 4 additions & 3 deletions ESAPIX/ESAPIX.11.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<TargetFramework>net452</TargetFramework>
<Platforms>x64</Platforms>
<NeutralLanguage>en</NeutralLanguage>
<AssemblyVersion>1.5.3.0</AssemblyVersion>
<FileVersion>1.5.3.0</FileVersion>
<Version>1.5.3.0</Version>
<AssemblyVersion>1.5.3.1</AssemblyVersion>
<FileVersion>1.5.3.1</FileVersion>
<Version>1.5.3.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Rex Cardan © 2019</Copyright>
<RootNamespace>ESAPIX</RootNamespace>
Expand Down Expand Up @@ -69,6 +69,7 @@
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsBase" />
<Reference Include="VMS.TPS.Common.Model.API">
Expand Down
7 changes: 4 additions & 3 deletions ESAPIX/ESAPIX.13.6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<TargetFramework>net452</TargetFramework>
<Platforms>x64</Platforms>
<NeutralLanguage>en</NeutralLanguage>
<AssemblyVersion>1.5.3.0</AssemblyVersion>
<FileVersion>1.5.3.0</FileVersion>
<Version>1.5.3.0</Version>
<AssemblyVersion>1.5.3.1</AssemblyVersion>
<FileVersion>1.5.3.1</FileVersion>
<Version>1.5.3.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Rex Cardan © 2019</Copyright>
<RootNamespace>ESAPIX</RootNamespace>
Expand Down Expand Up @@ -69,6 +69,7 @@
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="PresentationFramework" />
<Reference Include="VMS.TPS.Common.Model.API">
<HintPath>lib\13.6\VMS.TPS.Common.Model.API.dll</HintPath>
Expand Down
7 changes: 4 additions & 3 deletions ESAPIX/ESAPIX.13.7.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<TargetFramework>net452</TargetFramework>
<Platforms>x64</Platforms>
<NeutralLanguage>en</NeutralLanguage>
<AssemblyVersion>1.5.3.0</AssemblyVersion>
<FileVersion>1.5.3.0</FileVersion>
<Version>1.5.3.0</Version>
<AssemblyVersion>1.5.3.1</AssemblyVersion>
<FileVersion>1.5.3.1</FileVersion>
<Version>1.5.3.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Rex Cardan © 2019</Copyright>
<RootNamespace>ESAPIX</RootNamespace>
Expand Down Expand Up @@ -69,6 +69,7 @@
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsBase" />
<Reference Include="VMS.TPS.Common.Model.API">
Expand Down
7 changes: 4 additions & 3 deletions ESAPIX/ESAPIX.15.0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<TargetFramework>net452</TargetFramework>
<Platforms>x64</Platforms>
<NeutralLanguage>en</NeutralLanguage>
<AssemblyVersion>1.5.3.0</AssemblyVersion>
<FileVersion>1.5.3.0</FileVersion>
<Version>1.5.3.0</Version>
<AssemblyVersion>1.5.3.1</AssemblyVersion>
<FileVersion>1.5.3.1</FileVersion>
<Version>1.5.3.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Rex Cardan © 2019</Copyright>
<RootNamespace>ESAPIX</RootNamespace>
Expand Down Expand Up @@ -69,6 +69,7 @@
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsBase" />
<Reference Include="VMS.TPS.Common.Model.API">
Expand Down
7 changes: 4 additions & 3 deletions ESAPIX/ESAPIX.15.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<TargetFramework>net452</TargetFramework>
<Platforms>x64</Platforms>
<NeutralLanguage>en</NeutralLanguage>
<AssemblyVersion>1.5.3.0</AssemblyVersion>
<FileVersion>1.5.3.0</FileVersion>
<Version>1.5.3.0</Version>
<AssemblyVersion>1.5.3.1</AssemblyVersion>
<FileVersion>1.5.3.1</FileVersion>
<Version>1.5.3.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Rex Cardan © 2019</Copyright>
<RootNamespace>ESAPIX</RootNamespace>
Expand Down Expand Up @@ -68,6 +68,7 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="WindowsBase" />
<Reference Include="VMS.TPS.Common.Model.API">
<HintPath>lib\15.1\VMS.TPS.Common.Model.API.dll</HintPath>
Expand Down
7 changes: 4 additions & 3 deletions ESAPIX/ESAPIX.15.5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<TargetFramework>net452</TargetFramework>
<Platforms>x64</Platforms>
<NeutralLanguage>en</NeutralLanguage>
<AssemblyVersion>1.5.3.0</AssemblyVersion>
<FileVersion>1.5.3.0</FileVersion>
<Version>1.5.3.0</Version>
<AssemblyVersion>1.5.3.7</AssemblyVersion>
<FileVersion>1.5.3.7</FileVersion>
<Version>1.5.3.7</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Rex Cardan © 2019</Copyright>
<RootNamespace>ESAPIX</RootNamespace>
Expand Down Expand Up @@ -71,6 +71,7 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="WindowsBase" />
<Reference Include="VMS.TPS.Common.Model.API">
<HintPath>lib\15.5\VMS.TPS.Common.Model.API.dll</HintPath>
Expand Down
9 changes: 9 additions & 0 deletions ESAPIX/Interfaces/IESAPIService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ESAPIX.Common;
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace ESAPIX.Interfaces
Expand All @@ -10,6 +11,14 @@ public interface IESAPIService

Task InvokeAsync(Action a);

void Execute(Action<StandAloneContext> sacFunc);

Task ExecuteAsync(Action<StandAloneContext> sacFunc);

Task<T> GetValueExpAsync<T>(Expression<Func<StandAloneContext, T>> func);

T GetValueExp<T>(Expression<Func<StandAloneContext, T>> func);

Task<T> GetValueAsync<T>(Func<StandAloneContext, T> func);

T GetValue<T>(Func<StandAloneContext, T> func);
Expand Down
27 changes: 22 additions & 5 deletions ESAPIX/Services/ESAPIService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using ESAPIX.Common;
using ESAPIX.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Threading.Tasks;
using VMS.TPS.Common.Model.API;

namespace ESAPIX.Services
{
Expand All @@ -29,14 +26,34 @@ public Task InvokeAsync(Action a)
return _thread.InvokeAsync(a);
}

public Task<T> GetValueAsync<T>(Func<StandAloneContext,T> func)
public void Execute(Action<StandAloneContext> sacFunc)
{
_thread.Execute(sacFunc);
}

public Task ExecuteAsync(Action<StandAloneContext> sacFunc)
{
return _thread.ExecuteAsync(sacFunc);
}

public Task<T> GetValueAsync<T>(Func<StandAloneContext, T> func)
{
return _thread.GetValueAsync(func);
}

public Task<T> GetValueExpAsync<T>(Expression<Func<StandAloneContext, T>> func)
{
return _thread.GetValueAsync(func.Compile());
}

public T GetValue<T>(Func<StandAloneContext, T> func)
{
return _thread.GetValue(func);
}

public T GetValueExp<T>(Expression<Func<StandAloneContext, T>> func)
{
return _thread.GetValue(func.Compile());
}
}
}

0 comments on commit 05cf574

Please sign in to comment.