Skip to content

Commit

Permalink
changes around HL7 endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Neil South <[email protected]>
  • Loading branch information
neildsouth committed Jan 15, 2024
1 parent daa5e85 commit 2b5db41
Show file tree
Hide file tree
Showing 19 changed files with 621 additions and 79 deletions.
6 changes: 5 additions & 1 deletion src/Api/HL7DestinationEntity.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace Monai.Deploy.InformaticsGateway.Api.Models
/// {
/// "name": "MYPACS",
/// "hostIp": "10.20.100.200",
/// "aeTitle": "MONAIPACS",
/// "port": 1104
/// }
/// </code>
Expand All @@ -36,5 +35,10 @@ public class HL7DestinationEntity : BaseApplicationEntity
/// Gets or sets the port to connect to.
/// </summary>
public int Port { get; set; }

public override string ToString()
{
return $"Name: {Name}/Host: {HostIp}/Port: {Port}";
}
}
}
10 changes: 2 additions & 8 deletions src/Api/Models/BaseApplicationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public class BaseApplicationEntity : MongoDBEntityBase
/// </summary>
public string Name { get; set; } = default!;

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

/// <summary>
/// Gets or set the host name or IP address of the AE Title.
Expand All @@ -65,10 +61,8 @@ public BaseApplicationEntity()
SetDefaultValues();

Check warning on line 61 in src/Api/Models/BaseApplicationEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Remove this call from a constructor to the overridable 'SetDefaultValues' method.

Check warning on line 61 in src/Api/Models/BaseApplicationEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Remove this call from a constructor to the overridable 'SetDefaultValues' method.
}

public void SetDefaultValues()
public virtual void SetDefaultValues()
{
if (string.IsNullOrWhiteSpace(Name))
Name = AeTitle;
}

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

public override string ToString()
{
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";
return $"Name: {Name} /Host: {HostIp}";
}
}
}
16 changes: 16 additions & 0 deletions src/Api/Models/DestinationApplicationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,21 @@ public class DestinationApplicationEntity : BaseApplicationEntity
/// Gets or sets the port to connect to.
/// </summary>
public int Port { get; set; }

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

public override void SetDefaultValues()
{
if (string.IsNullOrWhiteSpace(Name))
Name = AeTitle;
}

public override string ToString()
{
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}/Port: {Port}";
}
}
}
15 changes: 15 additions & 0 deletions src/Api/SourceApplicationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,20 @@ namespace Monai.Deploy.InformaticsGateway.Api
/// </example>
public class SourceApplicationEntity : BaseApplicationEntity
{
/// <summary>
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
/// </summary>
public string AeTitle { get; set; } = default!;

public override void SetDefaultValues()
{
if (string.IsNullOrWhiteSpace(Name))
Name = AeTitle;
}

public override string ToString()
{
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";
}
}
}
15 changes: 2 additions & 13 deletions src/Api/Test/HL7DestinationEntityTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,23 @@ namespace Monai.Deploy.InformaticsGateway.Api.Test
{
public class HL7DestinationEntityTest
{
[Fact]
public void GivenAMonaiApplicationEntity_WhenNameIsNotSet_ExepectSetDefaultValuesToBeUsed()
{
var entity = new HL7DestinationEntity
{
AeTitle = "AET",
};

entity.SetDefaultValues();

Assert.Equal(entity.AeTitle, entity.Name);
}

[Fact]
public void GivenAMonaiApplicationEntity_WhenNameIsSet_ExepectSetDefaultValuesToNotOverwrite()
{
var entity = new HL7DestinationEntity
{
AeTitle = "AET",
Port = 1104,
HostIp = "IP",
Name = "Name"
};

entity.SetDefaultValues();

Assert.Equal("AET", entity.AeTitle);
Assert.Equal("IP", entity.HostIp);
Assert.Equal("Name", entity.Name);
Assert.Equal(1104, entity.Port);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
* limitations under the License.
*/

using Monai.Deploy.InformaticsGateway.Api.Models;
using Xunit;

namespace Monai.Deploy.InformaticsGateway.Api.Test
{
public class BaseApplicationEntityTest
public class SourceBaseApplicationEntityTest
{
[Fact]
public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesToSetName()
{
var entity = new BaseApplicationEntity
var entity = new SourceApplicationEntity
{
AeTitle = "AET",
HostIp = "IP"
Expand All @@ -38,7 +37,7 @@ public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesT
[Fact]
public void GivenABaseApplicationEntity_WhenNameIsSet_ExpectSetDefaultValuesToNotSetName()
{
var entity = new BaseApplicationEntity
var entity = new SourceApplicationEntity
{
AeTitle = "AET",
HostIp = "IP",
Expand Down
3 changes: 1 addition & 2 deletions src/Configuration/ValidationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public static bool IsValid(this HL7DestinationEntity hl7destinationEntity, out I

var valid = true;
valid &= !string.IsNullOrWhiteSpace(hl7destinationEntity.Name);
valid &= IsAeTitleValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.AeTitle, validationErrors);
valid &= IsValidHostNameIp(hl7destinationEntity.AeTitle, hl7destinationEntity.HostIp, validationErrors);
valid &= IsValidHostNameIp(hl7destinationEntity.Name, hl7destinationEntity.HostIp, validationErrors);
valid &= IsPortValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.Port, validationErrors);

return valid;
Expand Down
3 changes: 1 addition & 2 deletions src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal class HL7DestinationEntityConfiguration : IEntityTypeConfiguration<HL7D
public void Configure(EntityTypeBuilder<HL7DestinationEntity> builder)
{
builder.HasKey(j => j.Name);
builder.Property(j => j.AeTitle).IsRequired();
builder.Property(j => j.Port).IsRequired();
builder.Property(j => j.HostIp).IsRequired();
builder.Property(j => j.CreatedBy).IsRequired(false);
Expand All @@ -35,7 +34,7 @@ public void Configure(EntityTypeBuilder<HL7DestinationEntity> builder)
builder.Property(j => j.DateTimeUpdated).IsRequired(false);

builder.HasIndex(p => p.Name, "idx_destination_name").IsUnique();
builder.HasIndex(p => new { p.Name, p.AeTitle, p.HostIp, p.Port }, "idx_source_all").IsUnique();
builder.HasIndex(p => new { p.Name, p.HostIp, p.Port }, "idx_source_all").IsUnique();

builder.Ignore(p => p.Id);
}
Expand Down
Loading

0 comments on commit 2b5db41

Please sign in to comment.