Skip to content

Commit 1a9818e

Browse files
lillie-daeJoeBatt1989
authored andcommitted
updated workflow request event process
Signed-off-by: Lillie Dae <[email protected]>
1 parent 534e8e9 commit 1a9818e

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

src/WorkflowManager/Database/Interfaces/IWorkflowRepository.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System;
1818
using System.Collections.Generic;
1919
using System.Threading.Tasks;
20+
using Monai.Deploy.Messaging.Events;
2021
using Monai.Deploy.WorkflowManager.Contracts.Models;
2122

2223
namespace Monai.Deploy.WorkflowManager.Database.Interfaces
@@ -67,6 +68,23 @@ public interface IWorkflowRepository
6768
/// <param name="aeTitle">An aeTitle to retrieve workflows for.</param>
6869
Task<IList<WorkflowRevision>> GetWorkflowsByAeTitleAsync(List<string> aeTitles);
6970

71+
/// <summary>
72+
/// Retrieves a list of workflows based..<br/>
73+
/// if clinical workflow has AET no data origin. => WorkflowRequestEvents received with CalledAET with that AET this workflow (regardless of what the CallingAET is)<br/>
74+
/// if clinical workflow has AET and data_orgins => only WorkflowRequestEvents with CalledAET with that AET and CallingAET trigger this workflow.<br/>
75+
/// </summary>
76+
/// <example>
77+
/// If clinical workflow (workflow revision) exists with AET “MONAI” but no data_origins set
78+
/// Any inbound WorkflowRequestEvents with CalledAET = “MONAI” trigger this workflow (regardless of what the CallingAET is)
79+
///
80+
/// If clinical workflow (workflow revision) exists with AET “MONAI” and data_origins set as “PACS”
81+
/// Only inbound WorkflowRequestEvents with CalledAET = “MONAI” and CallingAET = “PACS” trigger this workflow
82+
/// </example>
83+
/// <param name="calledAeTitle"></param>
84+
/// <param name="sallingAeTitle"></param>
85+
/// <returns></returns>
86+
Task<IList<WorkflowRevision>> GetWorkflowsForWorkflowRequestAsync(string calledAeTitle, string callingAeTitle);
87+
7088
/// <summary>
7189
/// Creates a workflow object.
7290
/// </summary>

src/WorkflowManager/Database/Repositories/WorkflowRepository.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,25 @@ public async Task<IList<WorkflowRevision>> GetWorkflowsByAeTitleAsync(List<strin
199199
return workflows;
200200
}
201201

202+
public async Task<IList<WorkflowRevision>> GetWorkflowsForWorkflowRequestAsync(string calledAeTitle, string callingAeTitle)
203+
{
204+
Guard.Against.NullOrEmpty(calledAeTitle);
205+
Guard.Against.NullOrEmpty(callingAeTitle);
206+
207+
var wfs = await _workflowCollection
208+
.Find(x =>
209+
x.Deleted == null &&
210+
x.Workflow != null &&
211+
x.Workflow.InformaticsGateway != null &&
212+
(x.Workflow.InformaticsGateway.AeTitle == calledAeTitle && x.Workflow.InformaticsGateway.DataOrigins.Length == 0 ||
213+
x.Workflow.InformaticsGateway.AeTitle == calledAeTitle && x.Workflow.InformaticsGateway.DataOrigins.Contains(callingAeTitle)))
214+
.ToListAsync();
215+
return wfs;
216+
}
217+
202218
public async Task<string> CreateAsync(Workflow workflow)
203219
{
204-
Guard.Against.Null(workflow, nameof(workflow));
220+
Guard.Against.Null(workflow);
205221

206222
var workflowRevision = new WorkflowRevision
207223
{

src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,8 @@ public async Task<bool> ProcessPayload(WorkflowRequestEvent message, Payload pay
117117
}
118118
else
119119
{
120-
var aeTitles = new List<string>
121-
{
122-
message.CalledAeTitle,
123-
message.CallingAeTitle
124-
};
125-
126-
workflows = await _workflowRepository.GetWorkflowsByAeTitleAsync(aeTitles) as List<WorkflowRevision>;
120+
var result = await _workflowRepository.GetWorkflowsForWorkflowRequestAsync(message.CalledAeTitle, message.CallingAeTitle);
121+
workflows = new List<WorkflowRevision>(result);
127122
}
128123

129124
if (workflows is null || workflows.Any() is false)

0 commit comments

Comments
 (0)