Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow Request Event to support multiple sources/modalities #215

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 57 additions & 9 deletions src/Messaging/Events/WorkflowRequestEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,56 @@

namespace Monai.Deploy.Messaging.Events
{
public class DataOrigin
{
[JsonProperty(PropertyName = "type")]
public DataType DataType { get; set; }

/// <summary>
/// Gets or sets the source of the data:
/// <list type="bullet">
/// <item>DIMSE: the sender or calling AE Title of the DICOM dataset.</item>
/// <item>ACR inference request: the transaction ID.</item>
/// <item>FHIR/HL7: host name or IP address.</item>
/// <item>DICOMWeb: host name or IP address.</item>
/// </list>
/// </summary>
[JsonProperty(PropertyName = "source")]
[Required]
public string Source { get; set; } = default!;

/// <summary>
/// Gets or set the receiving service.
/// <list type="bullet">
/// <item>DIMSE: the MONAI Deploy AE Title that received the DICOM dataset.</item>
/// <item>ACR inference request: IP address of the receiving service.</item>
/// <item>FHIR/HL7: IP address of the receiving service.</item>
/// <item>DICOMWeb: IP address of the receiving service or the named virtual AE Title.</item>
/// </list>
/// </summary>
[JsonProperty(PropertyName = "destination")]
public string Destination { get; set; } = default!;
}
public enum DataType
{
/// <summary>
/// Data received via DIMSE services
/// </summary>
DIMSE,
/// <summary>
/// Data received via DICOMWeb services
/// </summary>
DICOMWEB,
/// <summary>
/// Data received via FHIR services
/// </summary>
FHIR,
/// <summary>
/// Data received via HL7 services
/// </summary>
HL7,
}

public class WorkflowRequestEvent : EventBase
{
private readonly List<BlockStorageInfo> _payload;
Expand Down Expand Up @@ -60,19 +110,16 @@ public class WorkflowRequestEvent : EventBase
public string Bucket { get; set; } = default!;

/// <summary>
/// For DIMSE, the sender or calling AE Title of the DICOM dataset.
/// For an ACR inference request, the transaction ID.
/// Gets or sets the service that received the original request.
/// </summary>
[JsonProperty(PropertyName = "calling_aetitle")]
[Required]
public string CallingAeTitle { get; set; } = default!;
[JsonProperty(PropertyName = "trigger")]
public DataOrigin DataTrigger { get; set; } = default!;

/// <summary>
/// For DIMSE, the MONAI Deploy AE Title received the DICOM dataset.
/// For an ACR inference request, this field is empty.
/// Gets or sets the data origins that were involved in triggering this workflow request.
/// </summary>
[JsonProperty(PropertyName = "called_aetitle")]
public string CalledAeTitle { get; set; } = default!;
[JsonProperty(PropertyName = "data_origins")]
public List<DataOrigin> DataOrigins { get; private set; }

/// <summary>
/// Gets or sets the time the data was received.
Expand Down Expand Up @@ -108,6 +155,7 @@ public WorkflowRequestEvent()
{
_payload = new List<BlockStorageInfo>();
Workflows = new List<string>();
DataOrigins = new List<DataOrigin>();
}

public void AddFiles(IEnumerable<BlockStorageInfo> files)
Expand Down
36 changes: 34 additions & 2 deletions src/Messaging/Tests/WorkflowRequestMessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public void ConvertsJsonMessageToMessage()
var input = new WorkflowRequestEvent()
{
Bucket = Guid.NewGuid().ToString(),
CalledAeTitle = Guid.NewGuid().ToString(),
CallingAeTitle = Guid.NewGuid().ToString(),
DataTrigger = new DataOrigin
{
DataType = DataType.DIMSE,
Source = Guid.NewGuid().ToString(),
Destination = Guid.NewGuid().ToString(),
},
CorrelationId = Guid.NewGuid().ToString(),
FileCount = 10,
PayloadId = Guid.NewGuid(),
Expand All @@ -40,6 +44,34 @@ public void ConvertsJsonMessageToMessage()
WorkflowInstanceId = Guid.NewGuid().ToString(),
TaskId = Guid.NewGuid().ToString(),
};
input.DataOrigins.Add(new DataOrigin
{
DataType = DataType.DICOMWEB,
Source = Guid.NewGuid().ToString(),
Destination = Guid.NewGuid().ToString(),

});
input.DataOrigins.Add(new DataOrigin
{
DataType = DataType.FHIR,
Source = Guid.NewGuid().ToString(),
Destination = Guid.NewGuid().ToString(),

});
input.DataOrigins.Add(new DataOrigin
{
DataType = DataType.DIMSE,
Source = Guid.NewGuid().ToString(),
Destination = Guid.NewGuid().ToString(),

});
input.DataOrigins.Add(new DataOrigin
{
DataType = DataType.HL7,
Source = Guid.NewGuid().ToString(),
Destination = Guid.NewGuid().ToString(),

});

var files = new List<BlockStorageInfo>()
{
Expand Down
Loading