简体   繁体   English

HL7-dotnetcore:为什么 HL7 消息验证失败并显示错误“消息类型和触发事件值未在消息中找到”?

[英]HL7-dotnetcore: Why the HL7 message validation fail with error "Message Type & Trigger Event value not found in message"?

I am using HL7-dotnetcore package which seems to be really nice.我正在使用HL7-dotnetcore 包,这似乎非常好。 Unfortunately I'm struggling while creating new HL7 message.不幸的是,我在创建新的 HL7 消息时遇到了困难。

I am trying to create new MDM_T02 message as explained in the guide (docs) with following code:我正在尝试使用以下代码创建新的MDM_T02消息,如指南(文档)中所述:

Message mdmMessage = new Message();

mdmMessage.AddSegmentMSH(
    "sendingApplication",
    "sendingFacility",
    "receivingApplication",
    "receivingFacility",
    string.Empty,
    "MDM_T02",
    $"Id{DateTime.Now.Ticks}",
    "P",
    "2.6");

But, I get following exception message:但是,我收到以下异常消息:

Failed to validate the message with error - Message Type & Trigger Event value not found in message无法验证消息并出现错误 - 在消息中找不到消息类型和触发事件值

The AddSegmentMSH method expects the messageType as a parameter. AddSegmentMSH方法需要messageType作为参数。 But I don't know about the trigger event.但我不知道触发事件。 I think the exception comes from here .我认为例外来自这里 Does someone know how to fix it?有人知道如何解决吗?

The problem is because you are sending messageType as MDM_T02 .问题是因为您将messageType作为MDM_T02发送。 This is invalid value.这是无效值。 The MDM is message and T02 is an event. MDM是消息, T02是事件。 Those should be separated by component separator;那些应该用成分分离器分开; default CAPS ( ^ ) symbol.默认大写 ( ^ ) 符号。 Observe that you are separating those with underscore ( _ ) symbol.请注意,您正在用下划线 ( _ ) 符号分隔那些。

Due to this, toolkit is not able to validate your message type.因此,工具包无法验证您的消息类型。 You should change "MDM_T02" to "MDM^T02" .您应该将"MDM_T02"更改为"MDM^T02"

Refer to following code on github :参考github上的以下代码:

var MSH_9_comps = MessageHelper.SplitString(MSH_9, this.Encoding.ComponentDelimiter);

if (MSH_9_comps.Count >= 3)
{
    this.MessageStructure = MSH_9_comps[2];
}
else if (MSH_9_comps.Count > 0 && MSH_9_comps[0] != null && MSH_9_comps[0].Equals("ACK"))
{
    this.MessageStructure = "ACK";
}
else if (MSH_9_comps.Count == 2)
{
    this.MessageStructure = MSH_9_comps[0] + "_" + MSH_9_comps[1];
}
else
{
    throw new HL7Exception("Message Type & Trigger Event value not found in message", HL7Exception.UNSUPPORTED_MESSAGE_TYPE);
}

Observe that the exception being thrown in above code is same that you mentioned in question.观察上面代码中抛出的异常与您提到的相同。 Also observe the first line;还要注意第一行; the SplitString is done on ComponentDelimiter . SplitStringComponentDelimiter上完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM