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

adding new ArtifactsReceivedEvent #234

Merged
merged 11 commits into from
Oct 11, 2023
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,5 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

*/.idea/*
4 changes: 2 additions & 2 deletions src/Messaging/API/IMessageBrokerSubscriberService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface IMessageBrokerSubscriberService : IDisposable
string Name { get; }

/// <summary>
/// Subscribe to a message topic & queue and executes <c>messageReceivedCallback</c> asynchronously for every message that is received.
/// Subscribe to a message topic and queue and executes <c>messageReceivedCallback</c> asynchronously for every message that is received.
/// Either provide a topic, a queue or both.
/// A queue is generated if the name of the queue is not provided.
/// </summary>
Expand All @@ -43,7 +43,7 @@ public interface IMessageBrokerSubscriberService : IDisposable
void SubscribeAsync(string topic, string queue, Func<MessageReceivedEventArgs, Task> messageReceivedCallback, ushort prefetchCount = 0);

/// <summary>
/// Subscribe to a message topic & queue and executes <c>messageReceivedCallback</c> asynchronously for every message that is received.
/// Subscribe to a message topic and queue and executes <c>messageReceivedCallback</c> asynchronously for every message that is received.
/// Either provide a topic, a queue or both.
/// A queue is generated if the name of the queue is not provided.
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions src/Messaging/Common/Artifact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2022-2023 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Monai.Deploy.Messaging.Common
{
public class Artifact
{
public ArtifactType Type { get; set; } = ArtifactType.Unset;
public string Path { get; set; } = string.Empty;
}
}
85 changes: 85 additions & 0 deletions src/Messaging/Common/ArtifactType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2022-2023 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Monai.Deploy.Messaging.Common
{
public enum ArtifactType
{
Unset, //Unset
AR, //Autorefraction
ASMT, //Content Assessment Results
AU, //Audio
BDUS, //Bone Densitometry (ultrasound)
BI, //Biomagnetic imaging
BMD, //Bone Densitometry (X-Ray)
CR, //Computed Radiography
CT, //Computed Tomography
DG, //Diaphanography
DOC, //Document
DX, //Digital Radiography
ECG, //Electrocardiography
EPS, //Cardiac Electrophysiology
ES, //Endoscopy
FID, //Fiducials
GM, //General Microscopy
HC, //Hard Copy
HD, //Hemodynamic Waveform
IO, //Intra-Oral Radiography
IOL, //Intraocular Lens Data
IVOCT, //Intravascular Optical Coherence Tomography
IVUS, //Intravascular Ultrasound
KER, //Keratometry
KO, //Key Object Selection
LEN, //Lensometry
LS, //Laser surface scan
MG, //Mammography
MR, //Magnetic Resonance
NM, //Nuclear Medicine
OAM, //Ophthalmic Axial Measurements
OCT, //Optical Coherence Tomography (non-Ophthalmic)
OP, //Ophthalmic Photography
OPM, //Ophthalmic Mapping
OPT, //Ophthalmic Tomography
OPV, //Ophthalmic Visual Field
OSS, //Optical Surface Scan
OT, //Other
PLAN, //Plan
PR, //Presentation State
PT, //Positron emission tomography (PET)
PX, //Panoramic X-Ray
REG, //Registration
RESP, //Respiratory Waveform
RF, //Radio Fluoroscopy
RG, //Radiographic imaging (conventional film/screen)
RTDOSE, //Radiotherapy Dose
RTIMAGE, //Radiotherapy Image
RTPLAN, //Radiotherapy Plan
RTRECORD, //RT Treatment Record
RTSTRUCT, //Radiotherapy Structure Set
RWV, //Real World Value Map
SEG, //Segmentation
SM, //Slide Microscopy
SMR, //Stereometric Relationship
SR, //SR Document
SRF, //Subjective Refraction
STAIN, //Automated Slide Stainer
TG, //Thermography
US, //Ultrasound
VA, //Visual Acuity
XA, //X-Ray Angiography
XC, //External-camera Photography
};
}
95 changes: 95 additions & 0 deletions src/Messaging/Common/ArtifactTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright 2022-2023 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Monai.Deploy.Messaging.Common
{
public static class ArtifactTypes
{
private static readonly Dictionary<ArtifactType, string> ListOfModularity = new()
{
{ ArtifactType.Unset, "Unset" },
{ ArtifactType.AR, "Autorefract" },
{ ArtifactType.ASMT, "Content Assessment Results" },
{ ArtifactType.AU, "Audio" },
{ ArtifactType.BDUS, "Bone Densitometry (ultrasound)" },
{ ArtifactType.BI, "Biomagnetic imaging" },
{ ArtifactType.BMD, "Bone Densitometry (X-Ray)" },
{ ArtifactType.CR, "Computed Radiography" },
{ ArtifactType.CT, "Computed Tomography" },
{ ArtifactType.DG, "Diaphanography" },
{ ArtifactType.DOC, "Document" },
{ ArtifactType.DX, "Digital Radiography" },
{ ArtifactType.ECG, "Electrocardiography" },
{ ArtifactType.EPS, "Cardiac Electrophysiology" },
{ ArtifactType.ES, "Endoscopy" },
{ ArtifactType.FID, "Fiducials" },
{ ArtifactType.GM, "General Microscopy" },
{ ArtifactType.HC, "Hard Copy" },
{ ArtifactType.HD, "Hemodynamic Waveform" },
{ ArtifactType.IO, "Intra-Oral Radiography" },
{ ArtifactType.IOL, "Intraocular Lens Data" },
{ ArtifactType.IVOCT, "Intravascular Optical Coherence Tomography" },
{ ArtifactType.IVUS, "Intravascular Ultrasound" },
{ ArtifactType.KER, "Keratometry" },
{ ArtifactType.KO, "Key Object Selection" },
{ ArtifactType.LEN, "Lensometry" },
{ ArtifactType.LS, "Laser surface scan" },
{ ArtifactType.MG, "Mammography" },
{ ArtifactType.MR, "Magnetic Resonance" },
{ ArtifactType.NM, "Nuclear Medicine" },
{ ArtifactType.OAM, "Ophthalmic Axial Measurements" },
{ ArtifactType.OCT, "Optical Coherence Tomography (non-Ophthalmic)" },
{ ArtifactType.OP, "Ophthalmic Photography" },
{ ArtifactType.OPM, "Ophthalmic Mapping" },
{ ArtifactType.OPT, "Ophthalmic Tomography" },
{ ArtifactType.OPV, "Ophthalmic Visual Field" },
{ ArtifactType.OSS, "Optical Surface Scan" },
{ ArtifactType.OT, "Other" },
{ ArtifactType.PLAN, "Plan" },
{ ArtifactType.PR, "Presentation State" },
{ ArtifactType.PT, "Positron emission tomography (PET)" },
{ ArtifactType.PX, "Panoramic X-Ray" },
{ ArtifactType.REG, "Registration" },
{ ArtifactType.RESP, "Respiratory Waveform" },
{ ArtifactType.RF, "Radio Fluoroscopy" },
{ ArtifactType.RG, "Radiographic imaging (conventional film/screen)" },
{ ArtifactType.RTDOSE, "Radiotherapy Dose" },
{ ArtifactType.RTIMAGE, "Radiotherapy Image" },
{ ArtifactType.RTPLAN, "Radiotherapy Plan" },
{ ArtifactType.RTRECORD, "RT Treatment Record" },
{ ArtifactType.RTSTRUCT, "Radiotherapy Structure Set" },
{ ArtifactType.RWV, "Real World Value Map" },
{ ArtifactType.SEG, "Segmentation" },
{ ArtifactType.SM, "Slide Microscopy" },
{ ArtifactType.SMR, "Stereometric Relationship" },
{ ArtifactType.SR, "SR Document" },
{ ArtifactType.SRF, "Subjective Refraction" },
{ ArtifactType.STAIN, "Automated Slide Stainer" },
{ ArtifactType.TG, "Thermography" },
{ ArtifactType.US, "Ultrasound" },
{ ArtifactType.VA, "Visual Acuity" },
{ ArtifactType.XA, "X-Ray Angiography" },
{ ArtifactType.XC, "External-camera Photography" },
};

public static bool Validate(string artifactType)
{
return ListOfModularity.Any(x =>
Enum.TryParse<ArtifactType>(artifactType, out var artifact)
&& x.Key == artifact);
}
}
}
4 changes: 2 additions & 2 deletions src/Messaging/Configuration/MessageBrokerServiceConfiguration.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class MessageBrokerServiceConfiguration

/// <summary>
/// Gets or sets the a fully qualified type name of the message publisher service.
/// The spcified type must implement <typeparam name="Monai.Deploy.InformaticsGateway.Api.MessageBroker.IMessageBrokerPublisherService">IMessageBrokerPublisherService</typeparam> interface.
/// The spcified type must implement <see cref="Monai.Deploy.Messaging.API.IMessageBrokerPublisherService">IMessageBrokerPublisherService</see> interface.
/// The default message publisher service configured is RabbitMQ.
/// </summary>
[ConfigurationKeyName("publisherServiceAssemblyName")]
public string PublisherServiceAssemblyName { get; set; } = DefaultPublisherAssemblyName;

/// <summary>
/// Gets or sets the a fully qualified type name of the message subscriber service.
/// The spcified type must implement <typeparam name="Monai.Deploy.InformaticsGateway.Api.MessageBroker.IMessageBrokerSubscriberService">IMessageBrokerSubscriberService</typeparam> interface.
/// The spcified type must implement <see cref="Monai.Deploy.Messaging.API.IMessageBrokerSubscriberService">IMessageBrokerSubscriberService</see> interface.
/// The default message subscriber service configured is RabbitMQ.
/// </summary>
[ConfigurationKeyName("subscriberServiceAssemblyName")]
Expand Down
60 changes: 60 additions & 0 deletions src/Messaging/Events/ArtifactsReceivedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2022-2023 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Monai.Deploy.Messaging.Common;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace Monai.Deploy.Messaging.Events
{
public class ArtifactsReceivedEvent : EventBase
{
/// <summary>
/// Gets or sets the workflow instanceID generated by the Workflow Manager.
/// </summary>
[JsonProperty(PropertyName = "workflow_instance_id")]
[JsonPropertyName("workflow_instance_id")]
[Required]
public string WorkflowInstanceId { get; set; } = default!;

/// <summary>
/// Gets or sets the export task ID generated by the Workflow Manager.
/// </summary>
[JsonProperty(PropertyName = "task_id")]
[JsonPropertyName("task_id")]
[Required]
public string TaskId { get; set; } = default!;

/// <summary>
/// Gets or set the correlation ID.
/// For DIMSE, the correlation ID is the UUID associated with the first DICOM association received.
/// For ACR, use the Transaction ID in the original request.
/// </summary>
[JsonProperty(PropertyName = "correlation_id")]
[JsonPropertyName("correlation_id")]
[Required]
public string CorrelationId { get; set; } = default!;

/// <summary>
/// Gets or set the list of artifacts.
/// </summary>
[JsonProperty(PropertyName = "artifacts")]
[JsonPropertyName("artifacts")]
[Required]
public List<Artifact> Artifacts { get; set; } = new List<Artifact>();
}
}
4 changes: 4 additions & 0 deletions src/Messaging/Events/WorkflowRequestEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public class DataOrigin
[JsonPropertyName("destination")]
public string Destination { get; set; } = default!;

[JsonProperty(PropertyName = "fromExternalApp")]
[JsonPropertyName("fromExternalApp")]
public bool FromExternalApp { get; set; } = false;

public override int GetHashCode()
{
return HashCode.Combine(Source, Destination, DataService);
Expand Down
16 changes: 16 additions & 0 deletions src/Messaging/IServiceCollectionExtension.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
/// </summary>
/// <param name="services">Instance of <see cref="IServiceCollection"/>.</param>
/// <param name="fullyQualifiedTypeName">Fully qualified type name of the service to use.</param>
/// <param name="registerHealthCheck">bool as to if the healthcheck is be registered</param>
/// <param name="failureStatus"></param>
/// <param name="tags"></param>
/// <param name="timeout"></param>
/// <returns>Instance of <see cref="IServiceCollection"/>.</returns>
/// <exception cref="ConfigurationException"></exception>
public static IServiceCollection AddMonaiDeployMessageBrokerSubscriberService(
Expand All @@ -48,6 +52,10 @@
/// <param name="services">Instance of <see cref="IServiceCollection"/>.</param>
/// <param name="fullyQualifiedTypeName">Fully qualified type name of the service to use.</param>
/// <param name="fileSystem">Instance of <see cref="IFileSystem"/>.</param>
/// <param name="registerHealthCheck">bool as to if the healthcheck is be registered</param>
/// <param name="failureStatus"></param>
/// <param name="tags"></param>
/// <param name="timeout"></param>
/// <returns>Instance of <see cref="IServiceCollection"/>.</returns>
/// <exception cref="ConfigurationException"></exception>
public static IServiceCollection AddMonaiDeployMessageBrokerSubscriberService(
Expand All @@ -65,6 +73,10 @@
/// </summary>
/// <param name="services">Instance of <see cref="IServiceCollection"/>.</param>
/// <param name="fullyQualifiedTypeName">Fully qualified type name of the service to use.</param>
/// <param name="registerHealthCheck">bool as to if the healthcheck is be registered</param>
/// <param name="failureStatus"></param>
/// <param name="tags"></param>
/// <param name="timeout"></param>
/// <returns>Instance of <see cref="IServiceCollection"/>.</returns>
/// <exception cref="ConfigurationException"></exception>
public static IServiceCollection AddMonaiDeployMessageBrokerPublisherService(
Expand All @@ -82,6 +94,10 @@
/// <param name="services">Instance of <see cref="IServiceCollection"/>.</param>
/// <param name="fullyQualifiedTypeName">Fully qualified type name of the service to use.</param>
/// <param name="fileSystem">Instance of <see cref="IFileSystem"/>.</param>
/// <param name="registerHealthCheck">bool as to if the healthcheck is be registered</param>
/// <param name="failureStatus"></param>
/// <param name="tags"></param>
/// <param name="timeout"></param>
/// <returns>Instance of <see cref="IServiceCollection"/>.</returns>
/// <exception cref="ConfigurationException"></exception>
public static IServiceCollection AddMonaiDeployMessageBrokerPublisherService(
Expand Down Expand Up @@ -147,7 +163,7 @@
IEnumerable<string>? tags,
TimeSpan? timeout) where V : HealthCheckRegistrationBase
{
var healthCheckBaseType = serviceAssembly.GetTypes().FirstOrDefault(p => p.BaseType == typeof(V));

Check warning on line 166 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

Check warning on line 166 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

Check warning on line 166 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

Check warning on line 166 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

if (healthCheckBaseType is null || Activator.CreateInstance(healthCheckBaseType) is not V healthCheckBuilderBase)
{
Expand All @@ -163,7 +179,7 @@
string fullyQualifiedTypeName,
Assembly serviceAssembly) where U : ServiceRegistrationBase
{
var serviceRegistrationType = serviceAssembly.GetTypes().FirstOrDefault(p => p.BaseType == typeof(U));

Check warning on line 182 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

Check warning on line 182 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

Check warning on line 182 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

Check warning on line 182 in src/Messaging/IServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / unit-test

"Find" method should be used instead of the "FirstOrDefault" extension method.

if (serviceRegistrationType is null || Activator.CreateInstance(serviceRegistrationType) is not U serviceRegistrar)
{
Expand Down
Loading
Loading