Skip to content

Commit

Permalink
fixing around message ack
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 Jan 9, 2024
1 parent 6b47b7f commit fecb72f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/InformaticsGateway/Logging/Log.800.Hl7Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@ public static partial class Log
[LoggerMessage(EventId = 829, Level = LogLevel.Trace, Message = "HL7 config Not matching message Id {senderId} configId {configID}")]
public static partial void Hl7NotMatchingConfig(this ILogger logger, string senderId, string configID);

[LoggerMessage(EventId = 830, Level = LogLevel.Error, Message = "Error generating HL7 acknowledgment. for message {message}")]
public static partial void ErrorGeneratingHl7Acknowledgment(this ILogger logger, Exception ex, string message);

}
}
7 changes: 6 additions & 1 deletion src/InformaticsGateway/Services/HealthLevel7/MllpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ private async Task SendAcknowledgment(INetworkStream clientStream, Message messa

if (ShouldSendAcknowledgment(message))
{
var ackMessage = message.GetACK();
var ackMessage = message.GetACK(true);
if (ackMessage is null)
{
_logger.ErrorGeneratingHl7Acknowledgment(new Exception(), message.HL7Message);
return;

Check warning on line 166 in src/InformaticsGateway/Services/HealthLevel7/MllpClient.cs

View check run for this annotation

Codecov / codecov/patch

src/InformaticsGateway/Services/HealthLevel7/MllpClient.cs#L165-L166

Added lines #L165 - L166 were not covered by tests
}
var ackData = new ReadOnlyMemory<byte>(ackMessage.GetMLLP());
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/InformaticsGateway/Services/HealthLevel7/MllpExtract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private Message RepopulateMessage(Hl7ApplicationConfigEntity config, ExternalApp
{
var newMess = message.HL7Message.Replace(oldvalue, details.PatientId);
message = new Message(newMess);
message.ParseMessage(false);
message.ParseMessage(true);
}
}
else if (tag == DicomTag.StudyInstanceUID)
Expand All @@ -162,7 +162,7 @@ private Message RepopulateMessage(Hl7ApplicationConfigEntity config, ExternalApp
{
var newMess = message.HL7Message.Replace(oldvalue, details.StudyInstanceUid);
message = new Message(newMess);
message.ParseMessage(false);
message.ParseMessage(true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private async Task EnsureAck(NetworkStream networkStream)
foreach (var message in _rawHl7Messages)
{
var hl7Message = new Message(message);
hl7Message.ParseMessage(false);
hl7Message.ParseMessage(true);

Check warning on line 343 in src/InformaticsGateway/Services/HealthLevel7/MllpService.cs

View check run for this annotation

Codecov / codecov/patch

src/InformaticsGateway/Services/HealthLevel7/MllpService.cs#L343

Added line #L343 was not covered by tests
if (hl7Message.MessageStructure == "ACK")
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task GivenAnInputHL7DataPlugInEngine_WhenExecutePlugInsIsCalledWith
"called");

var message = new HL7.Dotnetcore.Message(SampleMessage);
message.ParseMessage(false);
message.ParseMessage(true);

await Assert.ThrowsAsync<PlugInInitializationException>(async () => await pluginEngine.ExecutePlugInsAsync(message, dicomInfo, config));
}
Expand Down Expand Up @@ -152,7 +152,7 @@ public async Task GivenAnInputHL7DataPlugInEngine_WhenExecutePlugInsIsCalled_Exp
"called");

var message = new HL7.Dotnetcore.Message(SampleMessage);
message.ParseMessage(false);
message.ParseMessage(true);

var (Hl7Message, resultDicomInfo) = await pluginEngine.ExecutePlugInsAsync(message, dicomInfo, config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Monai.Deploy.InformaticsGateway.Test.Services.HealthLevel7
{
public class MllpClientTest
{
private const string SampleMessage = "MSH|^~\\&|MD|MD HOSPITAL|MD Test|MONAI Deploy|202207130000|SECURITY|MD^A01^ADT_A01|MSG00001|P|2.8|||<ACK>|\r\n";
private const string SampleMessage = "MSH|^~\\&|MD|MD HOSPITAL|MD Test|MONAI Deploy|202207130000|SECURITY|MD^A01^ADT_A01|MSG00001|P|2.8|||<ACK>|\r";

private readonly Mock<ITcpClientAdapter> _tcpClient;
private readonly Hl7Configuration _config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public async Task ThenEnsureThatExportcompleteMessagesAreSentWithSuscess(string
private async Task SendAcknowledgment(NetworkStream networkStream, HL7.Dotnetcore.Message message, CancellationToken cancellationToken)
{
if (message == null) { return; }
var ackMessage = message.GetACK();
var ackMessage = message.GetACK(true);
var ackData = new ReadOnlyMemory<byte>(ackMessage.GetMLLP());
{
try
Expand Down

0 comments on commit fecb72f

Please sign in to comment.