Skip to content

Commit 1ce9fbb

Browse files
committed
adding hl7Plugins
Signed-off-by: Neil South <[email protected]>
1 parent 313415a commit 1ce9fbb

27 files changed

+3642
-3521
lines changed

src/Api/Hl7ApplicationConfigEntity.cs

Lines changed: 130 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* Copyright 2022 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 System;
18-
using System.Collections.Generic;
19-
using System.ComponentModel.DataAnnotations;
20-
using System.ComponentModel.DataAnnotations.Schema;
21-
using System.Linq;
22-
using FellowOakDicom;
1+
/*
2+
* Copyright 2022 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 System;
18+
using System.Collections.Generic;
19+
using System.ComponentModel.DataAnnotations;
20+
using System.ComponentModel.DataAnnotations.Schema;
21+
using System.Linq;
22+
using FellowOakDicom;
2323
using Monai.Deploy.InformaticsGateway.Api.Storage;
2424
using Monai.Deploy.InformaticsGateway.Common;
2525
using Newtonsoft.Json;
@@ -60,109 +60,111 @@ public class Hl7ApplicationConfigEntity : MongoDBEntityBase
6060
/// </summary>
6161
public List<string> PlugInAssemblies { get; set; } = default!;
6262

63-
public IEnumerable<string> Validate()
64-
{
65-
var errors = new List<string>();
66-
if (string.IsNullOrWhiteSpace(SendingId.Key))
67-
errors.Add($"{nameof(SendingId.Key)} is missing.");
68-
if (string.IsNullOrWhiteSpace(SendingId.Value))
69-
errors.Add($"{nameof(SendingId.Value)} is missing.");
70-
71-
if (string.IsNullOrWhiteSpace(DataLink.Key))
72-
errors.Add($"{nameof(DataLink.Key)} is missing.");
73-
74-
if (DataMapping.IsNullOrEmpty())
75-
errors.Add($"{nameof(DataMapping)} is missing values.");
76-
77-
ValidateDataMapping(errors);
78-
79-
return errors;
80-
}
81-
82-
private void ValidateDataMapping(List<string> errors)
83-
{
84-
for (var idx = 0; idx < DataMapping.Count; idx++)
85-
{
86-
var dataMapKvp = DataMapping[idx];
87-
88-
if (string.IsNullOrWhiteSpace(dataMapKvp.Key) || dataMapKvp.Value.Length < 8)
89-
{
90-
if (string.IsNullOrWhiteSpace(dataMapKvp.Key))
91-
errors.Add($"{nameof(DataMapping)} is missing a name at index {idx}.");
92-
93-
if (string.IsNullOrWhiteSpace(dataMapKvp.Value) || dataMapKvp.Value.Length < 8)
94-
errors.Add($"{nameof(DataMapping)} ({dataMapKvp.Key}) @ index {idx} is not a valid DICOM Tag.");
95-
96-
continue;
97-
}
98-
99-
try
100-
{
101-
DicomTag.Parse(dataMapKvp.Value);
102-
}
103-
catch (Exception e)
104-
{
105-
errors.Add($"DataMapping.Value is not a valid DICOM Tag. {e.Message}");
106-
}
107-
}
108-
}
109-
110-
public override string ToString()
111-
{
112-
return JsonConvert.SerializeObject(this);
113-
}
114-
}
115-
116-
//string key, string value
117-
public class StringKeyValuePair : IKeyValuePair<string, string>
118-
{
119-
[Key]
120-
public string Key { get; set; } = string.Empty;
121-
public string Value { get; set; } = string.Empty;
122-
123-
public static implicit operator StringKeyValuePair(KeyValuePair<string, string> kvp)
124-
{
125-
return new StringKeyValuePair { Key = kvp.Key, Value = kvp.Value };
126-
}
127-
128-
public static List<StringKeyValuePair> FromDictionary(Dictionary<string, string> dictionary) =>
129-
dictionary.Select(kvp => new StringKeyValuePair { Key = kvp.Key, Value = kvp.Value }).ToList();
130-
131-
public override bool Equals(object? obj) => Equals(obj as StringKeyValuePair);
132-
133-
public bool Equals(StringKeyValuePair? other) => other != null && Key == other.Key && Value == other.Value;
134-
135-
public override int GetHashCode() => HashCode.Combine(Key, Value);
136-
137-
}
138-
139-
public class DataKeyValuePair : IKeyValuePair<string, DataLinkType>
140-
{
141-
[Key]
142-
public string Key { get; set; } = string.Empty;
143-
public DataLinkType Value { get; set; }
144-
145-
public static implicit operator DataKeyValuePair(KeyValuePair<string, DataLinkType> kvp)
146-
{
147-
return new DataKeyValuePair { Key = kvp.Key, Value = kvp.Value };
148-
}
149-
150-
public override bool Equals(object? obj) => Equals(obj as DataKeyValuePair);
151-
152-
public bool Equals(DataKeyValuePair? other) => other != null && Key == other.Key && Value == other.Value;
153-
154-
public override int GetHashCode() => HashCode.Combine(Key, Value);
155-
}
156-
157-
public interface IKeyValuePair<TKey, TValue>
158-
{
159-
public TKey Key { get; set; }
160-
public TValue Value { get; set; }
161-
}
162-
163-
public enum DataLinkType
164-
{
165-
PatientId,
166-
StudyInstanceUid
167-
}
168-
}
63+
public DateTime LastModified { get; set; } = DateTime.UtcNow;
64+
65+
public IEnumerable<string> Validate()
66+
{
67+
var errors = new List<string>();
68+
if (string.IsNullOrWhiteSpace(SendingId.Key))
69+
errors.Add($"{nameof(SendingId.Key)} is missing.");
70+
if (string.IsNullOrWhiteSpace(SendingId.Value))
71+
errors.Add($"{nameof(SendingId.Value)} is missing.");
72+
73+
if (string.IsNullOrWhiteSpace(DataLink.Key))
74+
errors.Add($"{nameof(DataLink.Key)} is missing.");
75+
76+
if (DataMapping.IsNullOrEmpty())
77+
errors.Add($"{nameof(DataMapping)} is missing values.");
78+
79+
ValidateDataMapping(errors);
80+
81+
return errors;
82+
}
83+
84+
private void ValidateDataMapping(List<string> errors)
85+
{
86+
for (var idx = 0; idx < DataMapping.Count; idx++)
87+
{
88+
var dataMapKvp = DataMapping[idx];
89+
90+
if (string.IsNullOrWhiteSpace(dataMapKvp.Key) || dataMapKvp.Value.Length < 8)
91+
{
92+
if (string.IsNullOrWhiteSpace(dataMapKvp.Key))
93+
errors.Add($"{nameof(DataMapping)} is missing a name at index {idx}.");
94+
95+
if (string.IsNullOrWhiteSpace(dataMapKvp.Value) || dataMapKvp.Value.Length < 8)
96+
errors.Add($"{nameof(DataMapping)} ({dataMapKvp.Key}) @ index {idx} is not a valid DICOM Tag.");
97+
98+
continue;
99+
}
100+
101+
try
102+
{
103+
DicomTag.Parse(dataMapKvp.Value);
104+
}
105+
catch (Exception e)
106+
{
107+
errors.Add($"DataMapping.Value is not a valid DICOM Tag. {e.Message}");
108+
}
109+
}
110+
}
111+
112+
public override string ToString()
113+
{
114+
return JsonConvert.SerializeObject(this);
115+
}
116+
}
117+
118+
//string key, string value
119+
public class StringKeyValuePair : IKeyValuePair<string, string>
120+
{
121+
[Key]
122+
public string Key { get; set; } = string.Empty;
123+
public string Value { get; set; } = string.Empty;
124+
125+
public static implicit operator StringKeyValuePair(KeyValuePair<string, string> kvp)
126+
{
127+
return new StringKeyValuePair { Key = kvp.Key, Value = kvp.Value };
128+
}
129+
130+
public static List<StringKeyValuePair> FromDictionary(Dictionary<string, string> dictionary) =>
131+
dictionary.Select(kvp => new StringKeyValuePair { Key = kvp.Key, Value = kvp.Value }).ToList();
132+
133+
public override bool Equals(object? obj) => Equals(obj as StringKeyValuePair);
134+
135+
public bool Equals(StringKeyValuePair? other) => other != null && Key == other.Key && Value == other.Value;
136+
137+
public override int GetHashCode() => HashCode.Combine(Key, Value);
138+
139+
}
140+
141+
public class DataKeyValuePair : IKeyValuePair<string, DataLinkType>
142+
{
143+
[Key]
144+
public string Key { get; set; } = string.Empty;
145+
public DataLinkType Value { get; set; }
146+
147+
public static implicit operator DataKeyValuePair(KeyValuePair<string, DataLinkType> kvp)
148+
{
149+
return new DataKeyValuePair { Key = kvp.Key, Value = kvp.Value };
150+
}
151+
152+
public override bool Equals(object? obj) => Equals(obj as DataKeyValuePair);
153+
154+
public bool Equals(DataKeyValuePair? other) => other != null && Key == other.Key && Value == other.Value;
155+
156+
public override int GetHashCode() => HashCode.Combine(Key, Value);
157+
}
158+
159+
public interface IKeyValuePair<TKey, TValue>
160+
{
161+
public TKey Key { get; set; }
162+
public TValue Value { get; set; }
163+
}
164+
165+
public enum DataLinkType
166+
{
167+
PatientId,
168+
StudyInstanceUid
169+
}
170+
}
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
/*
2-
* Copyright 2022-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 System;
18-
using System.Threading;
19-
using System.Threading.Tasks;
20-
21-
namespace Monai.Deploy.InformaticsGateway.Services.HealthLevel7
22-
{
23-
internal interface IMllpClient : IDisposable
24-
{
25-
Guid ClientId { get; }
26-
27-
string ClientIp { get; }
28-
29-
Task Start(Func<IMllpClient, MllpClientResult, Task> onDisconnect, CancellationToken cancellationToken);
30-
}
31-
}
1+
/*
2+
* Copyright 2022-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 System;
18+
using System.Threading;
19+
using System.Threading.Tasks;
20+
21+
namespace Monai.Deploy.InformaticsGateway.Api.Mllp
22+
{
23+
public interface IMllpClient : IDisposable
24+
{
25+
Guid ClientId { get; }
26+
27+
string ClientIp { get; }
28+
29+
Task Start(Func<IMllpClient, MllpClientResult, Task> onDisconnect, CancellationToken cancellationToken);
30+
}
31+
}
Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
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-
18-
using System.Threading.Tasks;
19-
using HL7.Dotnetcore;
20-
using Monai.Deploy.InformaticsGateway.Api.Storage;
21-
22-
namespace Monai.Deploy.InformaticsGateway.Services.HealthLevel7
23-
{
24-
internal interface IMllpExtract
25-
{
26-
Task<Message> ExtractInfo(Hl7FileStorageMetadata meta, Message message);
27-
}
28-
}
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+
18+
using System.Threading.Tasks;
19+
using HL7.Dotnetcore;
20+
using Monai.Deploy.InformaticsGateway.Api.Storage;
21+
22+
namespace Monai.Deploy.InformaticsGateway.Api.Mllp
23+
{
24+
public interface IMllpExtract
25+
{
26+
Task<Message> ExtractInfo(Hl7FileStorageMetadata meta, Message message, Hl7ApplicationConfigEntity configItem);
27+
28+
Task<Hl7ApplicationConfigEntity?> GetConfigItem(Message message);
29+
}
30+
}

0 commit comments

Comments
 (0)