Skip to content

Commit 5226ee8

Browse files
committed
Stores username & date of to AE create/update API calls
Signed-off-by: Victor Chang <[email protected]>
1 parent 30ad69e commit 5226ee8

File tree

97 files changed

+984
-205
lines changed

Some content is hidden

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

97 files changed

+984
-205
lines changed

src/Api/BaseApplicationEntity.cs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
using System;
19+
using System.Security.Claims;
20+
1821
namespace Monai.Deploy.InformaticsGateway.Api
1922
{
2023
/// <summary>
@@ -29,17 +32,32 @@ public class BaseApplicationEntity : MongoDBEntityBase
2932
/// Gets or sets the unique name used to identify a DICOM application entity.
3033
/// This value must be unique.
3134
/// </summary>
32-
public string Name { get; set; }
35+
public string Name { get; set; } = default!;
3336

3437
/// <summary>
3538
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
3639
/// </summary>
37-
public string AeTitle { get; set; }
40+
public string AeTitle { get; set; } = default!;
3841

3942
/// <summary>
4043
/// Gets or set the host name or IP address of the AE Title.
4144
/// </summary>
42-
public string HostIp { get; set; }
45+
public string HostIp { get; set; } = default!;
46+
47+
/// <summary>
48+
/// Gets or set the user who created the DICOM entity.
49+
/// </summary>
50+
public string? CreatedBy { get; set; }
51+
52+
/// <summary>
53+
/// Gets or set the most recent user who updated the DICOM entity.
54+
/// </summary>
55+
public string? UpdatedBy { get; set; }
56+
57+
/// <summary>
58+
/// Gets or set the most recent date time the DICOM entity was updated.
59+
/// </summary>
60+
public DateTime? DateTimeUpdated { get; set; }
4361

4462
public BaseApplicationEntity()
4563
{
@@ -52,6 +70,23 @@ public void SetDefaultValues()
5270
Name = AeTitle;
5371
}
5472

73+
public void SetAuthor(ClaimsPrincipal user, EditMode editMode)
74+
{
75+
if (editMode == EditMode.Update)
76+
{
77+
DateTimeUpdated = DateTime.UtcNow;
78+
}
79+
80+
if (editMode == EditMode.Create)
81+
{
82+
CreatedBy = user.Identity?.Name;
83+
}
84+
else if (editMode == EditMode.Update)
85+
{
86+
UpdatedBy = user.Identity?.Name;
87+
}
88+
}
89+
5590
public override string ToString()
5691
{
5792
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";

src/Api/DicomAssociationInfo.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ namespace Monai.Deploy.InformaticsGateway.Api
2020
{
2121
public class DicomAssociationInfo : MongoDBEntityBase
2222
{
23-
public DateTime DateTimeDisconnected { get; set; }
24-
public string CorrelationId { get; set; }
23+
public DateTime DateTimeDisconnected { get; set; } = default!;
24+
public string CorrelationId { get; set; } = default!;
2525
public int FileCount { get; private set; }
26-
public string CallingAeTitle { get; set; }
27-
public string CalledAeTitle { get; set; }
28-
public string RemoteHost { get; set; }
29-
public int RemotePort { get; set; }
30-
public string Errors { get; set; }
31-
public TimeSpan Duration { get; private set; }
26+
public string CallingAeTitle { get; set; } = default!;
27+
public string CalledAeTitle { get; set; } = default!;
28+
public string RemoteHost { get; set; } = default!;
29+
public int RemotePort { get; set; } = default!;
30+
public string Errors { get; set; } = string.Empty;
31+
public TimeSpan Duration { get; private set; } = default!;
3232

3333
public DicomAssociationInfo()
3434
{

src/Api/EditMode.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2021-2022 MONAI Consortium
3+
* Copyright 2019-2020 NVIDIA Corporation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace Monai.Deploy.InformaticsGateway.Api
19+
{
20+
public enum EditMode
21+
{
22+
Create,
23+
Update,
24+
}
25+
}

src/Api/LoggingDataDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace Monai.Deploy.InformaticsGateway.Api
2525
{
2626
[Serializable]
27-
public class LoggingDataDictionary<K, V> : Dictionary<K, V>
27+
public class LoggingDataDictionary<TKey, TValue> : Dictionary<TKey, TValue> where TKey : notnull
2828
{
2929
public LoggingDataDictionary()
3030
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<IsTrimmable>true</IsTrimmable>
2424
<CodeAnalysisRuleSet>..\.sonarlint\project-monai_monai-deploy-informatics-gatewaycsharp.ruleset</CodeAnalysisRuleSet>
2525
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
26+
<Nullable>enable</Nullable>
2627
</PropertyGroup>
2728

2829
<ItemGroup>

src/Api/MonaiApplicationEntity.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Collections.Generic;
2020
using System.ComponentModel.DataAnnotations;
2121
using System.ComponentModel.DataAnnotations.Schema;
22+
using System.Security.Claims;
2223

2324
namespace Monai.Deploy.InformaticsGateway.Api
2425
{
@@ -52,36 +53,36 @@ public class MonaiApplicationEntity : MongoDBEntityBase
5253
/// This value must be unique.
5354
/// </summary>
5455
[Key, Column(Order = 0)]
55-
public string Name { get; set; }
56+
public string Name { get; set; } = default!;
5657

5758
/// <summary>
5859
/// Gets or sets the AE TItle.
5960
/// </summary>
60-
public string AeTitle { get; set; }
61+
public string AeTitle { get; set; } = default!;
6162

6263
/// <summary>
6364
/// Gets or sets the DICOM tag used to group the instances.
6465
/// Defaults to 0020,000D (Study Instance UID).
6566
/// Valid DICOM Tags: > Study Instance UID (0020,000D) and Series Instance UID (0020,000E).
6667
/// </summary>
67-
public string Grouping { get; set; }
68+
public string Grouping { get; set; } = default!;
6869

6970
/// <summary>
7071
/// Optional field to map AE to one or more workflows.
7172
/// </summary>
72-
public List<string> Workflows { get; set; }
73+
public List<string> Workflows { get; set; } = default!;
7374

7475
/// <summary>
7576
/// Optional field to specify SOP Class UIDs to ignore.
7677
/// <see cref="IgnoredSopClasses"/> and <see cref="AllowedSopClasses"/> are mutually exclusive.
7778
/// </summary>
78-
public List<string> IgnoredSopClasses { get; set; }
79+
public List<string> IgnoredSopClasses { get; set; } = default!;
7980

8081
/// <summary>
8182
/// Optional field to specify accepted SOP Class UIDs.
8283
/// <see cref="IgnoredSopClasses"/> and <see cref="AllowedSopClasses"/> are mutually exclusive.
8384
/// </summary>
84-
public List<string> AllowedSopClasses { get; set; }
85+
public List<string> AllowedSopClasses { get; set; } = default!;
8586

8687
/// <summary>
8788
/// Timeout, in seconds, to wait for instances before notifying other subsystems of data arrival
@@ -90,6 +91,11 @@ public class MonaiApplicationEntity : MongoDBEntityBase
9091
/// </summary>
9192
public uint Timeout { get; set; } = 5;
9293

94+
/// <summary>
95+
/// Gets or set the user who created the DICOM entity.
96+
/// </summary>
97+
public string? CreatedBy { get; set; }
98+
9399
public MonaiApplicationEntity()
94100
{
95101
SetDefaultValues();
@@ -118,5 +124,10 @@ public override string ToString()
118124
{
119125
return $"Name: {Name}/AET: {AeTitle}";
120126
}
127+
128+
public void SetAuthor(ClaimsPrincipal user)
129+
{
130+
CreatedBy = user.Identity?.Name;
131+
}
121132
}
122133
}

src/Api/Rest/DicomWebConnectionDetails.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ public class DicomWebConnectionDetails
2929
/// Gets or sets a list of permitted operations for the connection.
3030
/// </summary>
3131
[JsonPropertyName("operations")]
32-
public IList<InputInterfaceOperations> Operations { get; set; }
32+
public IList<InputInterfaceOperations>? Operations { get; set; }
3333

3434
/// <summary>
3535
/// Gets or sets the resource URI (Uniform Resource Identifier) of the connection.
3636
/// </summary>
3737
[JsonPropertyName("uri")]
38-
public string Uri { get; set; }
38+
public string? Uri { get; set; }
3939

4040
/// <summary>
4141
/// Gets or sets the authentication/authorization token of the connection.
4242
/// For HTTP basic access authentication, the value must be encoded in based 64 using "{username}:{password}" format.
4343
/// </summary>
4444
[JsonPropertyName("authID")]
45-
public string AuthId { get; set; }
45+
public string? AuthId { get; set; }
4646

4747
/// <summary>
4848
/// Gets or sets the type of the authentication token used for the connection.

src/Api/Rest/Enums.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
using System;
1819
using System.Runtime.Serialization;
1920
using System.Text.Json.Serialization;
2021

src/Api/Rest/FhirResources.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ public class FhirResource
8181
/// E.g. Pateitn, Observation.
8282
/// </summary>
8383
[JsonPropertyName("resourceType")]
84-
public string Type { get; set; }
84+
public string Type { get; set; } = default!;
8585

8686
/// <summary>
8787
/// Gets or sets the ID of the resource to be retrieved.
8888
/// </summary>
8989
/// <value></value>
9090
[JsonPropertyName("id")]
91-
public string Id { get; set; }
91+
public string Id { get; set; } = default!;
9292

9393
/// <summary>
9494
/// Internal use only!
9595
/// Gets or sets whether or not resource has been retrieved or not.
9696
/// </summary>
9797
/// <value></value>
9898
[JsonPropertyName("isRetrieved")]
99-
public bool IsRetrieved { get; set; }
99+
public bool IsRetrieved { get; set; } = default!;
100100
}
101101
}

src/Api/Rest/InferenceRequest.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using System.Collections.Generic;
2020
using System.Linq;
2121
using System.Text.Json.Serialization;
22-
using System.Xml.Linq;
2322
using Ardalis.GuardClauses;
2423
using Monai.Deploy.InformaticsGateway.Common;
2524

@@ -83,7 +82,7 @@ public class InferenceRequest
8382
/// Gets or set the transaction ID of a request.
8483
/// </summary>
8584
[JsonPropertyName("transactionID")]
86-
public string TransactionId { get; set; }
85+
public string TransactionId { get; set; } = default!;
8786

8887
/// <summary>
8988
/// Gets or sets the priority of a request.
@@ -101,15 +100,15 @@ public class InferenceRequest
101100
/// Gets or sets the details of the data associated with the inference request.
102101
/// </summary>
103102
[JsonPropertyName("inputMetadata")]
104-
public InferenceRequestMetadata InputMetadata { get; set; }
103+
public InferenceRequestMetadata? InputMetadata { get; set; }
105104

106105
/// <summary>
107106
/// Gets or set a list of data sources to query/retrieve data from.
108107
/// When multiple data sources are specified, the system will query based on
109108
/// the order the list was received.
110109
/// </summary>
111110
[JsonPropertyName("inputResources")]
112-
public IList<RequestInputDataResource> InputResources { get; set; }
111+
public IList<RequestInputDataResource>? InputResources { get; set; }
113112

114113
/// <summary>
115114
/// Gets or set a list of data sources to export results to.
@@ -118,7 +117,17 @@ public class InferenceRequest
118117
/// Followed by registering the results using the MONAI App SDK.
119118
/// </summary>
120119
[JsonPropertyName("outputResources")]
121-
public IList<RequestOutputDataResource> OutputResources { get; set; }
120+
public IList<RequestOutputDataResource>? OutputResources { get; set; }
121+
122+
/// <summary>
123+
/// Gets or set the user who created the DICOM entity.
124+
/// </summary>
125+
public string? CreatedBy { get; set; }
126+
127+
/// <summary>
128+
/// Gets or set the date and time the objects first created.
129+
/// </summary>
130+
public DateTime? DateTimeCreated { get; set; }
122131

123132
#region Internal Use Only
124133

@@ -155,7 +164,7 @@ public class InferenceRequest
155164
public int TryCount { get; set; } = 0;
156165

157166
[JsonIgnore]
158-
public InputConnectionDetails Application
167+
public InputConnectionDetails? Application
159168
{
160169
get
161170
{
@@ -169,6 +178,7 @@ public InferenceRequest()
169178
{
170179
InputResources = new List<RequestInputDataResource>();
171180
OutputResources = new List<RequestOutputDataResource>();
181+
DateTimeCreated = DateTime.UtcNow;
172182
}
173183

174184
public bool IsValid(out string details)
@@ -192,7 +202,7 @@ private void Preprocess()
192202
if (InputMetadata.Details is not null)
193203
{
194204
InputMetadata.Inputs.Add(InputMetadata.Details);
195-
InputMetadata.Details = null;
205+
InputMetadata.Details = default!;
196206
}
197207
}
198208

src/Api/Rest/InferenceRequestDetails.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ namespace Monai.Deploy.InformaticsGateway.Api.Rest
7171
/// </remarks>
7272
public class InferenceRequestDetails
7373
{
74-
private string _fhirAcceptHeader;
74+
private string _fhirAcceptHeader = default!;
7575

7676
/// <summary>
7777
/// Gets or sets the type of the inference request.
7878
/// </summary>
79-
[JsonConverter(typeof(JsonStringEnumConverter))]
79+
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
8080
[JsonPropertyName("type")]
8181
public InferenceRequestType Type { get; set; }
8282

@@ -85,27 +85,27 @@ public class InferenceRequestDetails
8585
/// Used when <c>Type</c> is <see cref="T:Monai.Deploy.InformaticsGateway.Api.Rest.InferenceRequestType.DicomUid" />.
8686
/// </summary>
8787
[JsonPropertyName("studies")]
88-
public IList<RequestedStudy> Studies { get; set; }
88+
public IList<RequestedStudy>? Studies { get; set; }
8989

9090
/// <summary>
9191
/// Gets or sets Patient ID that is used to query the data source.
9292
/// Used when <c>Type</c> is <see cref="T:Monai.Deploy.InformaticsGateway.Api.Rest.InferenceRequestType.DicomPatientId" />.
9393
/// </summary>
9494
[JsonPropertyName("PatientID")]
95-
public string PatientId { get; set; }
95+
public string? PatientId { get; set; }
9696

9797
/// <summary>
9898
/// Gets or sets Access Number that is used to query the data source.
9999
/// Used when <c>Type</c> is <see cref="T:Monai.Deploy.InformaticsGateway.Api.Rest.InferenceRequestType.AccessionNumber" />.
100100
/// </summary>
101101
[JsonPropertyName("accessionNumber")]
102-
public IList<string> AccessionNumber { get; set; }
102+
public IList<string>? AccessionNumber { get; set; }
103103

104104
/// <summary>
105105
/// Gets or sets a list of FHIR resources to be retrived.
106106
/// </summary>
107107
[JsonPropertyName("resources")]
108-
public IList<FhirResource> Resources { get; set; }
108+
public IList<FhirResource>? Resources { get; set; }
109109

110110
/// <summary>
111111
/// Gets or set the data format used when storing FHIR resources.

0 commit comments

Comments
 (0)