Skip to content

Commit fc5e3f2

Browse files
authored
Merge pull request #494 from Project-MONAI/AI-300
Ai 300
2 parents a7df6ff + 8d5fc9b commit fc5e3f2

File tree

162 files changed

+3894
-831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+3894
-831
lines changed

doc/dependency_decisions.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,16 @@
774774
- :who: neilsouth
775775
:why: Apache-2.0 (https://github.com/Project-MONAI/monai-deploy-messaging/raw/main/LICENSE)
776776
:versions:
777-
- 1.0.3
778-
- 1.0.4
777+
- 1.0.5-rc0006
778+
- 1.0.5
779779
:when: 2023-10-13 18:06:21.511789690 Z
780780
- - :approve
781781
- Monai.Deploy.Messaging.RabbitMQ
782782
- :who: neilsouth
783783
:why: Apache-2.0 (https://github.com/Project-MONAI/monai-deploy-messaging/raw/main/LICENSE)
784784
:versions:
785-
- 1.0.3
786-
- 1.0.4
785+
- 1.0.5-rc0006
786+
- 1.0.5
787787
:when: 2023-10-13 18:06:21.511789690 Z
788788
- - :approve
789789
- Monai.Deploy.Storage

src/Api/Hl7ApplicationConfigEntity.cs

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.ComponentModel.DataAnnotations;
2121
using System.Linq;
2222
using FellowOakDicom;
23+
using Monai.Deploy.InformaticsGateway.Api.Storage;
2324
using Monai.Deploy.InformaticsGateway.Common;
2425
using Newtonsoft.Json;
2526

src/Api/BaseApplicationEntity.cs renamed to src/Api/Models/BaseApplicationEntity.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
using System;
1919
using System.Security.Claims;
20+
using Monai.Deploy.InformaticsGateway.Api.Storage;
2021

21-
namespace Monai.Deploy.InformaticsGateway.Api
22+
namespace Monai.Deploy.InformaticsGateway.Api.Models
2223
{
2324
/// <summary>
2425
/// DICOM Application Entity or AE.

src/Api/DestinationApplicationEntity.cs renamed to src/Api/Models/DestinationApplicationEntity.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace Monai.Deploy.InformaticsGateway.Api
18+
namespace Monai.Deploy.InformaticsGateway.Api.Models
1919
{
2020
/// <summary>
2121
/// Destination Application Entity

src/Api/DicomAssociationInfo.cs renamed to src/Api/Models/DicomAssociationInfo.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
using System;
1818
using System.Collections.Generic;
19+
using Monai.Deploy.InformaticsGateway.Api.Storage;
1920

20-
namespace Monai.Deploy.InformaticsGateway.Api
21+
namespace Monai.Deploy.InformaticsGateway.Api.Models
2122
{
2223
public class DicomAssociationInfo : MongoDBEntityBase
2324
{

src/Api/ExportRequestDataMessage.cs renamed to src/Api/Models/ExportRequestDataMessage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using Monai.Deploy.InformaticsGateway.Api.PlugIns;
2121
using Monai.Deploy.Messaging.Events;
2222

23-
namespace Monai.Deploy.InformaticsGateway.Api
23+
namespace Monai.Deploy.InformaticsGateway.Api.Models
2424
{
2525
public class ExportRequestDataMessage
2626
{

src/Api/Models/ExternalAppDetails.cs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2023 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using Monai.Deploy.InformaticsGateway.Api.Storage;
18+
19+
namespace Monai.Deploy.InformaticsGateway.Api.Models
20+
{
21+
public class ExternalAppDetails : MongoDBEntityBase
22+
{
23+
public string StudyInstanceUid { get; set; } = string.Empty;
24+
25+
public string StudyInstanceUidOutBound { get; set; } = string.Empty;
26+
27+
public string WorkflowInstanceId { get; set; } = string.Empty;
28+
29+
public string ExportTaskID { get; set; } = string.Empty;
30+
31+
public string CorrelationId { get; set; } = string.Empty;
32+
33+
public string? DestinationFolder { get; set; }
34+
35+
public string PatientId { get; set; } = string.Empty;
36+
37+
public string PatientIdOutBound { get; set; } = string.Empty;
38+
}
39+
}

src/Api/MonaiApplicationEntity.cs renamed to src/Api/Models/MonaiApplicationEntity.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
using System.ComponentModel.DataAnnotations.Schema;
2222
using System.Security.Claims;
2323
using Monai.Deploy.InformaticsGateway.Api.PlugIns;
24+
using Monai.Deploy.InformaticsGateway.Api.Storage;
2425

25-
namespace Monai.Deploy.InformaticsGateway.Api
26+
namespace Monai.Deploy.InformaticsGateway.Api.Models
2627
{
2728
/// <summary>
2829
/// MONAI Application Entity

src/Api/Monai.Deploy.InformaticsGateway.Api.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
<PackageReference Include="fo-dicom" Version="5.1.1" />
5656
<PackageReference Include="Macross.Json.Extensions" Version="3.0.0" />
5757
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="6.0.22" />
58-
<PackageReference Include="Monai.Deploy.Messaging" Version="1.0.4" />
59-
<PackageReference Include="Monai.Deploy.Messaging.RabbitMQ" Version="1.0.4" />
58+
<PackageReference Include="Monai.Deploy.Messaging" Version="1.0.5-rc0006" />
59+
<PackageReference Include="Monai.Deploy.Messaging.RabbitMQ" Version="1.0.5-rc0006" />
6060
<PackageReference Include="Monai.Deploy.Storage" Version="0.2.18" />
6161
</ItemGroup>
6262

src/Api/PlugIns/IOutputDataPlugin.cs

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using System.Threading.Tasks;
1818
using FellowOakDicom;
19+
using Monai.Deploy.InformaticsGateway.Api.Models;
1920

2021
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
2122
{

src/Api/PlugIns/IOutputDataPluginEngine.cs

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using System.Collections.Generic;
1818
using System.Threading.Tasks;
19+
using Monai.Deploy.InformaticsGateway.Api.Models;
1920

2021
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
2122
{

src/Api/SourceApplicationEntity.cs

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
using Monai.Deploy.InformaticsGateway.Api.Models;
19+
1820
namespace Monai.Deploy.InformaticsGateway.Api
1921
{
2022
/// <summary>

src/Api/Storage/DicomFileStorageMetadata.cs

100644100755
+43-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public sealed record DicomFileStorageMetadata : FileStorageMetadata
3636
/// Gets or set the Study Instance UID of the DICOM instance.
3737
/// </summary>
3838
[JsonPropertyName("studyInstanceUid")]
39-
public string StudyInstanceUid { get; init; } = default!;
39+
public string StudyInstanceUid { get; set; } = default!;
4040

4141
/// <summary>
4242
/// Gets or set the Series Instance UID of the DICOM instance.
@@ -93,6 +93,15 @@ public DicomFileStorageMetadata(string associationId, string identifier, string
9393
StudyInstanceUid = studyInstanceUid;
9494
SeriesInstanceUid = seriesInstanceUid;
9595
SopInstanceUid = sopInstanceUid;
96+
SetupFilePaths(associationId);
97+
98+
DataOrigin.DataService = dataService;
99+
DataOrigin.Source = callingAeTitle;
100+
DataOrigin.Destination = calledAeTitle;
101+
}
102+
103+
private void SetupFilePaths(string associationId)
104+
{
96105
File = new StorageObjectMetadata(FileExtension)
97106
{
98107
TemporaryPath = string.Join(PathSeparator, associationId, DataTypeDirectoryName, $"{Guid.NewGuid()}{FileExtension}"),
@@ -106,16 +115,45 @@ public DicomFileStorageMetadata(string associationId, string identifier, string
106115
UploadPath = $"{File.UploadPath}{DicomJsonFileExtension}",
107116
ContentType = DicomJsonContentType,
108117
};
118+
}
109119

110-
DataOrigin.DataService = dataService;
111-
DataOrigin.Source = callingAeTitle;
112-
DataOrigin.Destination = calledAeTitle;
120+
public void SetupGivenFilePaths(string? DestinationFolder)
121+
{
122+
if (DestinationFolder is null)
123+
{
124+
return;
125+
}
126+
127+
if (DestinationFolder.EndsWith('/'))
128+
{
129+
DestinationFolder = DestinationFolder.Remove(DestinationFolder.Length - 1);
130+
}
131+
132+
File = new StorageObjectMetadata(FileExtension)
133+
{
134+
TemporaryPath = string.Join(PathSeparator, DestinationFolder, $"Temp{PathSeparator}{Guid.NewGuid()}{FileExtension}"),
135+
UploadPath = string.Join(PathSeparator, DestinationFolder, $"{SopInstanceUid}{FileExtension}"),
136+
ContentType = DicomContentType,
137+
DestinationFolderOverride = true,
138+
};
139+
140+
JsonFile = new StorageObjectMetadata(DicomJsonFileExtension)
141+
{
142+
TemporaryPath = $"{File.TemporaryPath}{DicomJsonFileExtension}",
143+
UploadPath = $"{File.UploadPath}{DicomJsonFileExtension}",
144+
ContentType = DicomJsonContentType,
145+
DestinationFolderOverride = true,
146+
};
147+
148+
//DestinationFolderNeil = DestinationFolder;
113149
}
114150

151+
public void SetStudyInstanceUid(string newStudyInstanceUid) => StudyInstanceUid = newStudyInstanceUid;
152+
115153
public override void SetFailed()
116154
{
117155
base.SetFailed();
118156
JsonFile.SetFailed();
119157
}
120158
}
121-
}
159+
}

src/Api/Storage/FileStorageMetadata.cs

100644100755
+4-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public abstract record FileStorageMetadata
104104
[JsonPropertyName("payloadId")]
105105
public string? PayloadId { get; set; }
106106

107+
// [JsonPropertyName("destinationFolder")]
108+
//public string? DestinationFolderNeil { get; set; }
109+
107110
/// <summary>
108111
/// DO NOT USE
109112
/// This constructor is intended for JSON serializer.
@@ -162,4 +165,4 @@ public static string IpAddress()
162165
return "127.0.0.1";
163166
}
164167
}
165-
}
168+
}

src/Api/MongoDBEntityBase.cs renamed to src/Api/Storage/MongoDBEntityBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
using System;
1818

19-
namespace Monai.Deploy.InformaticsGateway.Api
19+
namespace Monai.Deploy.InformaticsGateway.Api.Storage
2020
{
2121
public abstract class MongoDBEntityBase
2222
{

src/Api/Storage/Payload.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public TimeSpan Elapsed
8686

8787
public int FilesFailedToUpload { get => Files.Count(p => p.IsUploadFailed); }
8888

89+
public string DestinationFolder { get; set; } = string.Empty;
90+
8991
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout)
9092
{
9193
Guard.Against.NullOrWhiteSpace(key, nameof(key));
@@ -106,7 +108,7 @@ public Payload(string key, string correlationId, string? workflowInstanceId, str
106108
DataTrigger = dataTrigger;
107109
}
108110

109-
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout, string? payloadId = null) :
111+
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout, string? payloadId = null, string? DestinationFolder = null) :
110112
this(key, correlationId, workflowInstanceId, taskId, dataTrigger, timeout)
111113
{
112114
Guard.Against.NullOrWhiteSpace(key, nameof(key));
@@ -119,6 +121,7 @@ public Payload(string key, string correlationId, string? workflowInstanceId, str
119121
{
120122
PayloadId = Guid.Parse(payloadId);
121123
}
124+
DestinationFolder ??= string.Empty;
122125
}
123126

124127
public void Add(FileStorageMetadata value)
@@ -132,6 +135,11 @@ public void Add(FileStorageMetadata value)
132135
DataOrigins.Add(value.DataOrigin);
133136
}
134137

138+
//if (string.IsNullOrWhiteSpace(value.DestinationFolderNeil) is false)
139+
//{
140+
// DestinationFolder = value.DestinationFolderNeil;
141+
//}
142+
135143
_lastReceived.Reset();
136144
_lastReceived.Start();
137145
}

src/Api/Storage/StorageObjectMetadata.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public class StorageObjectMetadata
8888
[JsonPropertyName("isMoveCompleted"), JsonInclude]
8989
public bool IsMoveCompleted { get; private set; } = default!;
9090

91+
[JsonPropertyName("destinationFolderOverride")]
92+
public bool DestinationFolderOverride { get; set; } = false;
93+
9194
public StorageObjectMetadata(string fileExtension)
9295
{
9396
Guard.Against.NullOrWhiteSpace(fileExtension, nameof(fileExtension));
@@ -111,7 +114,11 @@ public string GetPayloadPath(Guid payloadId)
111114
{
112115
Guard.Against.Null(payloadId, nameof(payloadId));
113116

114-
return $"{payloadId}{FileStorageMetadata.PathSeparator}{UploadPath}";
117+
if (DestinationFolderOverride is false)
118+
{
119+
return $"{payloadId}{FileStorageMetadata.PathSeparator}{UploadPath}";
120+
}
121+
return $"{UploadPath}";
115122
}
116123

117124
public void SetUploaded(string bucketName)

src/Api/Test/BaseApplicationEntityTest.cs

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
using Monai.Deploy.InformaticsGateway.Api.Models;
1718
using Xunit;
1819

1920
namespace Monai.Deploy.InformaticsGateway.Api.Test

src/Api/Test/DestinationApplicationEntityTest.cs

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
using Monai.Deploy.InformaticsGateway.Api.Models;
1718
using Xunit;
1819

1920
namespace Monai.Deploy.InformaticsGateway.Api.Test

src/Api/Test/MonaiApplicationEntityTest.cs

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
using Monai.Deploy.InformaticsGateway.Api.Models;
1718
using Xunit;
1819

1920
namespace Monai.Deploy.InformaticsGateway.Api.Test

src/Api/Test/Storage/DicomFileStorageMetadataTest.cs

100644100755
+36-1
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,40 @@ public void GivenDicomFileStorageMetadata_WhenGetPayloadPathIsCalled_APayyloadPa
8989
Assert.Equal($"{payloadId}/{metadata.File.UploadPath}", metadata.File.GetPayloadPath(payloadId));
9090
Assert.Equal($"{payloadId}/{metadata.JsonFile.UploadPath}", metadata.JsonFile.GetPayloadPath(payloadId));
9191
}
92+
93+
94+
[Fact]
95+
public void StudyInstanceUid_Set_ValidValue()
96+
{
97+
// Arrange
98+
var metadata = new DicomFileStorageMetadata();
99+
100+
// Act
101+
metadata.StudyInstanceUid = "12345";
102+
103+
// Assert
104+
Assert.Equal("12345", metadata.StudyInstanceUid);
105+
}
106+
107+
[Fact]
108+
public void SeriesInstanceUid_Set_ValidValue()
109+
{
110+
// Arrange
111+
var metadata = new DicomFileStorageMetadata { SeriesInstanceUid = "67890" };
112+
113+
// Assert
114+
Assert.Equal("67890", metadata.SeriesInstanceUid);
115+
}
116+
117+
[Fact]
118+
public void SopInstanceUid_Set_ValidValue()
119+
{
120+
// Arrange
121+
var metadata = new DicomFileStorageMetadata { SopInstanceUid = "ABCDE" };
122+
123+
// Assert
124+
Assert.Equal("ABCDE", metadata.SopInstanceUid);
125+
}
126+
92127
}
93-
}
128+
}

0 commit comments

Comments
 (0)