Skip to content

Commit

Permalink
adding HL7 plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Neil South <neil.south@answerdigital.com>
  • Loading branch information
neildsouth committed Dec 8, 2023
1 parent 076cc86 commit af4c416
Show file tree
Hide file tree
Showing 232 changed files with 10,240 additions and 1,403 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ jobs:
ports:
- 27017:27017
steps:
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: '11'
java-version: '17'

- uses: actions/setup-dotnet@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,4 @@ FodyWeavers.xsd
# Additional files built by Visual Studio

# End of https://www.toptal.com/developers/gitignore/api/aspnetcore,dotnetcore,visualstudio,visualstudiocode
/src/InformaticsGateway/Properties/launchSettings.json
46 changes: 32 additions & 14 deletions doc/dependency_decisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,62 +314,77 @@
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
:when: 2022-08-16 23:05:49.698463427 Z
- 6.0.25
- :when: 2022-08-16 23:05:49.698463427 Z
- - :approve
- Microsoft.EntityFrameworkCore
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
- 6.0.25
:when: 2022-08-16 23:05:50.137694970 Z
- - :approve
- Microsoft.EntityFrameworkCore.Abstractions
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
:when: 2022-08-16 23:05:51.008105271 Z
- 6.0.25
- :when: 2022-08-16 23:05:51.008105271 Z
- - :approve
- Microsoft.EntityFrameworkCore.Analyzers
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
:when: 2022-08-16 23:05:51.445711308 Z
- 6.0.25
- :when: 2022-08-16 23:05:51.445711308 Z
- - :approve
- Microsoft.EntityFrameworkCore.Design
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
:when: 2022-08-16 23:05:51.922790944 Z
- 6.0.25
- :when: 2022-08-16 23:05:51.922790944 Z
- - :approve
- Microsoft.EntityFrameworkCore.InMemory
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
:when: 2022-08-16 23:05:52.375150938 Z
- 6.0.25
- :when: 2022-08-16 23:05:52.375150938 Z
- - :approve
- Microsoft.EntityFrameworkCore.Relational
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
:when: 2022-08-16 23:05:52.828879230 Z
- 6.0.25
- :when: 2022-08-16 23:05:52.828879230 Z
- - :approve
- Microsoft.EntityFrameworkCore.Tools
- :who: ndsouth
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.25
- :when: 2022-08-16 23:05:52.828879230 Z
- - :approve
- Microsoft.EntityFrameworkCore.Sqlite
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
- 6.0.25
:when: 2022-08-16 23:05:53.270526921 Z
- - :approve
- Microsoft.EntityFrameworkCore.Sqlite.Core
- :who: mocsharp
:why: MIT (https://raw.githubusercontent.com/dotnet/efcore/release/6.0/LICENSE.txt)
:versions:
- 6.0.22
- 6.0.25
:when: 2022-08-16 23:05:53.706997823 Z
- - :approve
- Microsoft.Extensions.ApiDescription.Server
Expand Down Expand Up @@ -512,22 +527,25 @@
:versions:
- 6.0.21
- 6.0.22
:when: 2022-08-29 18:11:22.090772006 Z
- 6.0.25
- :when: 2022-08-29 18:11:22.090772006 Z
- - :approve
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions
- :who: mocsharp
:why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt)
:versions:
- 6.0.21
- 6.0.22
:when: 2022-08-29 18:11:22.090772006 Z
- 6.0.25
- :when: 2022-08-29 18:11:22.090772006 Z
- - :approve
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore
- :who: mocsharp
:why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt)
:versions:
- 6.0.22
:when: 2022-08-29 18:11:22.090772006 Z
- 6.0.25
- :when: 2022-08-29 18:11:22.090772006 Z
- - :approve
- Microsoft.Extensions.FileProviders.Abstractions
- :who: mocsharp
Expand Down Expand Up @@ -774,16 +792,16 @@
- :who: neilsouth
:why: Apache-2.0 (https://github.com/Project-MONAI/monai-deploy-messaging/raw/main/LICENSE)
:versions:
- 1.0.3
- 1.0.4
- 1.0.5-rc0006
- 1.0.5
:when: 2023-10-13 18:06:21.511789690 Z
- - :approve
- Monai.Deploy.Messaging.RabbitMQ
- :who: neilsouth
:why: Apache-2.0 (https://github.com/Project-MONAI/monai-deploy-messaging/raw/main/LICENSE)
:versions:
- 1.0.3
- 1.0.4
- 1.0.5-rc0006
- 1.0.5
:when: 2023-10-13 18:06:21.511789690 Z
- - :approve
- Monai.Deploy.Storage
Expand Down
40 changes: 40 additions & 0 deletions src/Api/HL7DestinationEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2021-2022 MONAI Consortium
* Copyright 2019-2020 NVIDIA Corporation
*
* 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.InformaticsGateway.Api.Models
{
/// <summary>
/// HL7 Destination Entity
/// </summary>
/// <example>
/// <code>
/// {
/// "name": "MYPACS",
/// "hostIp": "10.20.100.200",
/// "aeTitle": "MONAIPACS",
/// "port": 1104
/// }
/// </code>
/// </example>
public class HL7DestinationEntity : BaseApplicationEntity
{
/// <summary>
/// Gets or sets the port to connect to.
/// </summary>
public int Port { get; set; }
}
}
170 changes: 170 additions & 0 deletions src/Api/Hl7ApplicationConfigEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* Copyright 2022 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 System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using FellowOakDicom;
using Monai.Deploy.InformaticsGateway.Api.Storage;
using Monai.Deploy.InformaticsGateway.Common;
using Newtonsoft.Json;

namespace Monai.Deploy.InformaticsGateway.Api
{
public class Hl7ApplicationConfigEntity : MongoDBEntityBase
{
/// <summary>
/// Gets or sets the name of a Hl7 application entity.
/// This value must be unique.
/// </summary>
[Key, Column(Order = 0)]
public string Name { get; set; } = default!;

/// <summary>
/// Gets or sets the sending identifier.
/// </summary>
[JsonProperty("sending_identifier")]
public StringKeyValuePair SendingId { get; set; } = new();

/// <summary>
/// Gets or sets the data link.
/// Value is either PatientId or StudyInstanceUid
/// </summary>
[JsonProperty("data_link")]
public DataKeyValuePair DataLink { get; set; } = new();

/// <summary>
/// Gets or sets the data mapping.
/// Value is a DICOM Tag
/// </summary>
[JsonProperty("data_mapping")]
public List<StringKeyValuePair> DataMapping { get; set; } = new();

/// <summary>
/// Optional list of data input plug-in type names to be executed by the <see cref="IInputHL7DataPlugInEngine"/>.
/// </summary>
public List<string> PlugInAssemblies { get; set; } = default!;

public DateTime LastModified { get; set; } = DateTime.UtcNow;

public IEnumerable<string> Validate()
{
var errors = new List<string>();
if (string.IsNullOrWhiteSpace(SendingId.Key))
errors.Add($"{nameof(SendingId.Key)} is missing.");
if (string.IsNullOrWhiteSpace(SendingId.Value))
errors.Add($"{nameof(SendingId.Value)} is missing.");

if (string.IsNullOrWhiteSpace(DataLink.Key))
errors.Add($"{nameof(DataLink.Key)} is missing.");

if (DataMapping.IsNullOrEmpty())
errors.Add($"{nameof(DataMapping)} is missing values.");

ValidateDataMapping(errors);

return errors;
}

private void ValidateDataMapping(List<string> errors)
{
for (var idx = 0; idx < DataMapping.Count; idx++)
{
var dataMapKvp = DataMapping[idx];

if (string.IsNullOrWhiteSpace(dataMapKvp.Key) || dataMapKvp.Value.Length < 8)
{
if (string.IsNullOrWhiteSpace(dataMapKvp.Key))
errors.Add($"{nameof(DataMapping)} is missing a name at index {idx}.");

if (string.IsNullOrWhiteSpace(dataMapKvp.Value) || dataMapKvp.Value.Length < 8)
errors.Add($"{nameof(DataMapping)} ({dataMapKvp.Key}) @ index {idx} is not a valid DICOM Tag.");

continue;
}

try
{
DicomTag.Parse(dataMapKvp.Value);
}
catch (Exception e)
{
errors.Add($"DataMapping.Value is not a valid DICOM Tag. {e.Message}");
}
}
}

public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}

//string key, string value
public class StringKeyValuePair : IKeyValuePair<string, string>

Check warning on line 119 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Implement 'IEquatable<StringKeyValuePair>'.

Check warning on line 119 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Seal class 'StringKeyValuePair' or implement 'IEqualityComparer<T>' instead.

Check warning on line 119 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Implement 'IEquatable<StringKeyValuePair>'.

Check warning on line 119 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Seal class 'StringKeyValuePair' or implement 'IEqualityComparer<T>' instead.
{
[Key]
public string Key { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;

public static implicit operator StringKeyValuePair(KeyValuePair<string, string> kvp)
{
return new StringKeyValuePair { Key = kvp.Key, Value = kvp.Value };
}

public static List<StringKeyValuePair> FromDictionary(Dictionary<string, string> dictionary) =>
dictionary.Select(kvp => new StringKeyValuePair { Key = kvp.Key, Value = kvp.Value }).ToList();

public override bool Equals(object? obj) => Equals(obj as StringKeyValuePair);

public bool Equals(StringKeyValuePair? other) => other != null && Key == other.Key && Value == other.Value;

public override int GetHashCode() => HashCode.Combine(Key, Value);

}

public class DataKeyValuePair : IKeyValuePair<string, DataLinkType>

Check warning on line 141 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Implement 'IEquatable<DataKeyValuePair>'.

Check warning on line 141 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Seal class 'DataKeyValuePair' or implement 'IEqualityComparer<T>' instead.

Check warning on line 141 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Implement 'IEquatable<DataKeyValuePair>'.

Check warning on line 141 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Seal class 'DataKeyValuePair' or implement 'IEqualityComparer<T>' instead.
{
[Key]
public string Key { get; set; } = string.Empty;
public DataLinkType Value { get; set; }

public static implicit operator DataKeyValuePair(KeyValuePair<string, DataLinkType> kvp)
{
return new DataKeyValuePair { Key = kvp.Key, Value = kvp.Value };
}

public override bool Equals(object? obj) => Equals(obj as DataKeyValuePair);

public bool Equals(DataKeyValuePair? other) => other != null && Key == other.Key && Value == other.Value;

public override int GetHashCode() => HashCode.Combine(Key, Value);
}

public interface IKeyValuePair<TKey, TValue>
{
public TKey Key { get; set; }
public TValue Value { get; set; }
}

public enum DataLinkType
{
PatientId,
StudyInstanceUid
}
}
6 changes: 3 additions & 3 deletions ...eway/Services/HealthLevel7/IMllpClient.cs → src/Api/Mllp/IMllpClient.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
using System.Threading;
using System.Threading.Tasks;

namespace Monai.Deploy.InformaticsGateway.Services.HealthLevel7
namespace Monai.Deploy.InformaticsGateway.Api.Mllp
{
internal interface IMllpClient : IDisposable
public interface IMllpClient : IDisposable
{
Guid ClientId { get; }

string ClientIp { get; }

Task Start(Func<IMllpClient, MllpClientResult, Task> onDisconnect, CancellationToken cancellationToken);
}
}
}
Loading

0 comments on commit af4c416

Please sign in to comment.