I am using HL7-dotnetcore package which seems to be really nice. Unfortunately I'm struggling while creating new HL7 message.
I am trying to create new MDM_T02 message as explained in the guide (docs) with following code:
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. 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
messageTypeasMDM_T02. This is invalid value. TheMDMis message andT02is an event. 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".Refer to following code on github:
Observe that the exception being thrown in above code is same that you mentioned in question. Also observe the first line; the
SplitStringis done onComponentDelimiter.