-
Notifications
You must be signed in to change notification settings - Fork 163
Decoding a message
Jake Aitchison edited this page Jun 28, 2021
·
10 revisions
var message = @"MSH|^~\&|CohieCentral|COHIE|Clinical Data Provider|TCH|20060228155525||QRY^R02^QRY_R02|1|P|2.3|QRD|20060228155525|R|I||||10^RD&Records&0126|38923^^^^^^^^&TCH|||";
var parser = new PipeParser();
var parsed = parser.Parse(message);
var qryR02 = parsed as QRY_R02;
Assert.IsNotNull(qryR02);
Assert.AreEqual("38923", qryR02.QRD.GetWhoSubjectFilter(0).IDNumber.Value);
Some message types are not mapped to their exact same event type and this can cause some confusion when you first encounter it.
For example ADT^A01, ADT^A04, ADT^A08 and ADT^A13 event types will all be parsed into the ADT^01 structure.
The following unit test illustrates this behaviour:
[Test]
public void TestADTA04IsMappedAsA01()
{
var hl7Data = @"MSH|^~\&|CohieCentral|COHIE|Clinical Data Provider|TCH|20060228155525||ADT^A04|1|P|2.5.1|
EVN|
PID|1|12345
PV1|1";
var parser = new PipeParser();
var msg = parser.Parse(hl7Data);
Assert.IsNotNull(msg, "Message should not be null");
var a04 = (ADT_A01)msg;
Assert.AreEqual("A04", a04.MSH.MessageType.TriggerEvent.Value);
Assert.AreEqual("1", a04.PID.SetIDPID.Value);
}
The Event to Structure Map for each version of HL7 supported can be found below: