forked from ClearCanvas/ClearCanvas
/
ProtocolWorkflowTools.cs
241 lines (209 loc) · 8.04 KB
/
ProtocolWorkflowTools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#region License
// Copyright (c) 2013, ClearCanvas Inc.
// All rights reserved.
// http://www.clearcanvas.ca
//
// This file is part of the ClearCanvas RIS/PACS open source project.
//
// The ClearCanvas RIS/PACS open source project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// The ClearCanvas RIS/PACS open source project is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// the ClearCanvas RIS/PACS open source project. If not, see
// <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.ServiceModel;
using System.Threading;
using ClearCanvas.Common;
using ClearCanvas.Desktop;
using ClearCanvas.Desktop.Actions;
using ClearCanvas.Enterprise.Common;
using ClearCanvas.Ris.Application.Common;
using ClearCanvas.Ris.Application.Common.ProtocollingWorkflow;
using ClearCanvas.Ris.Application.Common.ReportingWorkflow;
namespace ClearCanvas.Ris.Client.Workflow
{
[MenuAction("apply", "folderexplorer-items-contextmenu/Verify Protocol", "Apply")]
[ButtonAction("apply", "folderexplorer-items-toolbar/Verify Protocol", "Apply")]
[IconSet("apply", IconScheme.Colour, "Icons.VerifyReportSmall.png", "Icons.VerifyReportMedium.png", "Icons.VerifyReportLarge.png")]
[EnabledStateObserver("apply", "Enabled", "EnabledChanged")]
[ExtensionOf(typeof(ProtocolWorkflowItemToolExtensionPoint))]
public class VerifyProtocolTool : ProtocolWorkflowItemTool
{
public VerifyProtocolTool()
: base("AcceptProtocol")
{
}
public override void Initialize()
{
this.Context.RegisterDropHandler(typeof(Folders.Reporting.CompletedProtocolFolder), this);
base.Initialize();
}
protected override bool Execute(ReportingWorklistItemSummary item)
{
try
{
ExecuteHelper(item.ProcedureStepRef, null);
}
catch (FaultException<SupervisorValidationException>)
{
ExecuteHelper(item.ProcedureStepRef, GetSupervisorRef());
}
this.Context.InvalidateFolders(typeof(Folders.Reporting.CompletedProtocolFolder));
return true;
}
private void ExecuteHelper(EntityRef procedureStepRef, EntityRef supervisorRef)
{
Platform.GetService<IProtocollingWorkflowService>(
delegate(IProtocollingWorkflowService service)
{
AcceptProtocolRequest request = new AcceptProtocolRequest(procedureStepRef, supervisorRef);
service.AcceptProtocol(request);
});
}
}
[MenuAction("apply", "folderexplorer-items-contextmenu/Reject Protocol", "Apply")]
[ButtonAction("apply", "folderexplorer-items-toolbar/Reject Protocol", "Apply")]
[IconSet("apply", IconScheme.Colour, "Icons.RejectProtocolSmall.png", "Icons.RejectProtocolMedium.png", "Icons.RejectProtocolLarge.png")]
[EnabledStateObserver("apply", "Enabled", "EnabledChanged")]
[ExtensionOf(typeof(ProtocolWorkflowItemToolExtensionPoint))]
public class RejectProtocolTool : ProtocolWorkflowItemTool
{
public RejectProtocolTool()
: base("RejectProtocol")
{
}
public override void Initialize()
{
this.Context.RegisterDropHandler(typeof(Folders.Reporting.RejectedProtocolFolder), this);
base.Initialize();
}
protected override bool Execute(ReportingWorklistItemSummary item)
{
ProtocolReasonComponent component = new ProtocolReasonComponent();
if (this.Context.DesktopWindow.ShowDialogBox(component, "Reason") == DialogBoxAction.Ok)
{
try
{
ExecuteHelper(item.ProcedureStepRef, component.Reason, component.OtherReason, null);
}
catch (FaultException<SupervisorValidationException>)
{
ExecuteHelper(item.ProcedureStepRef, component.Reason, component.OtherReason, GetSupervisorRef());
}
this.Context.InvalidateFolders(typeof (Folders.Reporting.RejectedProtocolFolder));
}
return true;
}
private void ExecuteHelper(EntityRef procedureStepRef, EnumValueInfo reason, string otherReason, EntityRef supervisorRef)
{
Platform.GetService<IProtocollingWorkflowService>(
delegate(IProtocollingWorkflowService service)
{
RejectProtocolRequest request = new RejectProtocolRequest(
procedureStepRef,
supervisorRef,
reason,
CreateAdditionalCommentsNote(otherReason));
service.RejectProtocol(request);
});
}
private static OrderNoteDetail CreateAdditionalCommentsNote(string additionalComments)
{
if (!string.IsNullOrEmpty(additionalComments))
return new OrderNoteDetail(OrderNoteCategory.Protocol.Key, additionalComments, null, false, null, null);
else
return null;
}
}
[MenuAction("apply", "folderexplorer-items-contextmenu/Submit for Review", "Apply")]
[ButtonAction("apply", "folderexplorer-items-toolbar/Submit for Review", "Apply")]
[IconSet("apply", IconScheme.Colour, "Icons.SubmitForReviewSmall.png", "Icons.SubmitForReviewMedium.png", "Icons.SubmitForReviewLarge.png")]
[EnabledStateObserver("apply", "Enabled", "EnabledChanged")]
[VisibleStateObserver("apply", "Visible", "VisibleChanged")]
[ExtensionOf(typeof(ProtocolWorkflowItemToolExtensionPoint))]
public class SubmitForReviewProtocolTool : ProtocolWorkflowItemTool
{
public SubmitForReviewProtocolTool()
: base("SubmitProtocolForApproval")
{
}
public bool Visible
{
get
{
return Thread.CurrentPrincipal.IsInRole(Application.Common.AuthorityTokens.Workflow.Protocol.SubmitForReview);
}
}
public event EventHandler VisibleChanged
{
add { }
remove { }
}
public override void Initialize()
{
this.Context.RegisterDropHandler(typeof(Folders.Reporting.AwaitingApprovalProtocolFolder), this);
base.Initialize();
}
protected override bool Execute(ReportingWorklistItemSummary item)
{
try
{
ExecuteHelper(item.ProcedureStepRef, null);
}
catch (FaultException<SupervisorValidationException>)
{
ExecuteHelper(item.ProcedureStepRef, GetSupervisorRef());
}
this.Context.InvalidateFolders(typeof(Folders.Reporting.AwaitingApprovalProtocolFolder));
return true;
}
private void ExecuteHelper(EntityRef procedureStepRef, EntityRef supervisorRef)
{
Platform.GetService<IProtocollingWorkflowService>(
delegate(IProtocollingWorkflowService service)
{
SubmitProtocolForApprovalRequest request = new SubmitProtocolForApprovalRequest(procedureStepRef, supervisorRef);
service.SubmitProtocolForApproval(request);
});
}
}
[MenuAction("apply", "folderexplorer-items-contextmenu/Discard Protocol", "Apply")]
[ButtonAction("apply", "folderexplorer-items-toolbar/Discard Protocol", "Apply")]
[IconSet("apply", IconScheme.Colour, "Icons.CancelReportSmall.png", "Icons.CancelReportMedium.png", "Icons.CancelReportLarge.png")]
[EnabledStateObserver("apply", "Enabled", "EnabledChanged")]
[ExtensionOf(typeof(ProtocolWorkflowItemToolExtensionPoint))]
[ExtensionOf(typeof(RadiologistAdminWorkflowItemToolExtensionPoint))]
public class DiscardProtocolTool : ProtocolWorkflowItemTool
{
public DiscardProtocolTool()
: base("DiscardProtocol")
{
}
public override void Initialize()
{
this.Context.RegisterDropHandler(typeof(Folders.Reporting.ToBeProtocolledFolder), this);
base.Initialize();
}
protected override bool Execute(ReportingWorklistItemSummary item)
{
if (this.Context.DesktopWindow.ShowMessageBox(SR.MessageConfirmDiscardSelectedProtocol, MessageBoxActions.OkCancel)
== DialogBoxAction.Cancel)
return false;
Platform.GetService<IProtocollingWorkflowService>(
delegate(IProtocollingWorkflowService service)
{
service.DiscardProtocol(new DiscardProtocolRequest(item.ProcedureStepRef));
});
return true;
}
}
}