Skip to content

Commit 2b5db41

Browse files
committed
changes around HL7 endpoints
Signed-off-by: Neil South <[email protected]>
1 parent daa5e85 commit 2b5db41

19 files changed

+621
-79
lines changed

src/Api/HL7DestinationEntity.cs

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace Monai.Deploy.InformaticsGateway.Api.Models
2525
/// {
2626
/// "name": "MYPACS",
2727
/// "hostIp": "10.20.100.200",
28-
/// "aeTitle": "MONAIPACS",
2928
/// "port": 1104
3029
/// }
3130
/// </code>
@@ -36,5 +35,10 @@ public class HL7DestinationEntity : BaseApplicationEntity
3635
/// Gets or sets the port to connect to.
3736
/// </summary>
3837
public int Port { get; set; }
38+
39+
public override string ToString()
40+
{
41+
return $"Name: {Name}/Host: {HostIp}/Port: {Port}";
42+
}
3943
}
4044
}

src/Api/Models/BaseApplicationEntity.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public class BaseApplicationEntity : MongoDBEntityBase
3535
/// </summary>
3636
public string Name { get; set; } = default!;
3737

38-
/// <summary>
39-
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
40-
/// </summary>
41-
public string AeTitle { get; set; } = default!;
4238

4339
/// <summary>
4440
/// Gets or set the host name or IP address of the AE Title.
@@ -65,10 +61,8 @@ public BaseApplicationEntity()
6561
SetDefaultValues();
6662
}
6763

68-
public void SetDefaultValues()
64+
public virtual void SetDefaultValues()
6965
{
70-
if (string.IsNullOrWhiteSpace(Name))
71-
Name = AeTitle;
7266
}
7367

7468
public void SetAuthor(ClaimsPrincipal user, EditMode editMode)
@@ -90,7 +84,7 @@ public void SetAuthor(ClaimsPrincipal user, EditMode editMode)
9084

9185
public override string ToString()
9286
{
93-
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";
87+
return $"Name: {Name} /Host: {HostIp}";
9488
}
9589
}
9690
}

src/Api/Models/DestinationApplicationEntity.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,21 @@ public class DestinationApplicationEntity : BaseApplicationEntity
3636
/// Gets or sets the port to connect to.
3737
/// </summary>
3838
public int Port { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
42+
/// </summary>
43+
public string AeTitle { get; set; } = default!;
44+
45+
public override void SetDefaultValues()
46+
{
47+
if (string.IsNullOrWhiteSpace(Name))
48+
Name = AeTitle;
49+
}
50+
51+
public override string ToString()
52+
{
53+
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}/Port: {Port}";
54+
}
3955
}
4056
}

src/Api/SourceApplicationEntity.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,20 @@ namespace Monai.Deploy.InformaticsGateway.Api
3333
/// </example>
3434
public class SourceApplicationEntity : BaseApplicationEntity
3535
{
36+
/// <summary>
37+
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
38+
/// </summary>
39+
public string AeTitle { get; set; } = default!;
40+
41+
public override void SetDefaultValues()
42+
{
43+
if (string.IsNullOrWhiteSpace(Name))
44+
Name = AeTitle;
45+
}
46+
47+
public override string ToString()
48+
{
49+
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";
50+
}
3651
}
3752
}

src/Api/Test/HL7DestinationEntityTest.cs

100644100755
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,23 @@ namespace Monai.Deploy.InformaticsGateway.Api.Test
2121
{
2222
public class HL7DestinationEntityTest
2323
{
24-
[Fact]
25-
public void GivenAMonaiApplicationEntity_WhenNameIsNotSet_ExepectSetDefaultValuesToBeUsed()
26-
{
27-
var entity = new HL7DestinationEntity
28-
{
29-
AeTitle = "AET",
30-
};
31-
32-
entity.SetDefaultValues();
3324

34-
Assert.Equal(entity.AeTitle, entity.Name);
35-
}
3625

3726
[Fact]
3827
public void GivenAMonaiApplicationEntity_WhenNameIsSet_ExepectSetDefaultValuesToNotOverwrite()
3928
{
4029
var entity = new HL7DestinationEntity
4130
{
42-
AeTitle = "AET",
31+
Port = 1104,
4332
HostIp = "IP",
4433
Name = "Name"
4534
};
4635

4736
entity.SetDefaultValues();
4837

49-
Assert.Equal("AET", entity.AeTitle);
5038
Assert.Equal("IP", entity.HostIp);
5139
Assert.Equal("Name", entity.Name);
40+
Assert.Equal(1104, entity.Port);
5241
}
5342
}
5443
}

src/Api/Test/BaseApplicationEntityTest.cs renamed to src/Api/Test/SourceBaseApplicationEntityTest.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
using Monai.Deploy.InformaticsGateway.Api.Models;
1817
using Xunit;
1918

2019
namespace Monai.Deploy.InformaticsGateway.Api.Test
2120
{
22-
public class BaseApplicationEntityTest
21+
public class SourceBaseApplicationEntityTest
2322
{
2423
[Fact]
2524
public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesToSetName()
2625
{
27-
var entity = new BaseApplicationEntity
26+
var entity = new SourceApplicationEntity
2827
{
2928
AeTitle = "AET",
3029
HostIp = "IP"
@@ -38,7 +37,7 @@ public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesT
3837
[Fact]
3938
public void GivenABaseApplicationEntity_WhenNameIsSet_ExpectSetDefaultValuesToNotSetName()
4039
{
41-
var entity = new BaseApplicationEntity
40+
var entity = new SourceApplicationEntity
4241
{
4342
AeTitle = "AET",
4443
HostIp = "IP",

src/Configuration/ValidationExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public static bool IsValid(this HL7DestinationEntity hl7destinationEntity, out I
6666

6767
var valid = true;
6868
valid &= !string.IsNullOrWhiteSpace(hl7destinationEntity.Name);
69-
valid &= IsAeTitleValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.AeTitle, validationErrors);
70-
valid &= IsValidHostNameIp(hl7destinationEntity.AeTitle, hl7destinationEntity.HostIp, validationErrors);
69+
valid &= IsValidHostNameIp(hl7destinationEntity.Name, hl7destinationEntity.HostIp, validationErrors);
7170
valid &= IsPortValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.Port, validationErrors);
7271

7372
return valid;

src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ internal class HL7DestinationEntityConfiguration : IEntityTypeConfiguration<HL7D
2626
public void Configure(EntityTypeBuilder<HL7DestinationEntity> builder)
2727
{
2828
builder.HasKey(j => j.Name);
29-
builder.Property(j => j.AeTitle).IsRequired();
3029
builder.Property(j => j.Port).IsRequired();
3130
builder.Property(j => j.HostIp).IsRequired();
3231
builder.Property(j => j.CreatedBy).IsRequired(false);
@@ -35,7 +34,7 @@ public void Configure(EntityTypeBuilder<HL7DestinationEntity> builder)
3534
builder.Property(j => j.DateTimeUpdated).IsRequired(false);
3635

3736
builder.HasIndex(p => p.Name, "idx_destination_name").IsUnique();
38-
builder.HasIndex(p => new { p.Name, p.AeTitle, p.HostIp, p.Port }, "idx_source_all").IsUnique();
37+
builder.HasIndex(p => new { p.Name, p.HostIp, p.Port }, "idx_source_all").IsUnique();
3938

4039
builder.Ignore(p => p.Id);
4140
}

0 commit comments

Comments
 (0)