public void FromMessage_EncodingCharactersInMessage_ReturnsExpectedResult(char fieldSeperator, string encodingCharacters) { // Arrange var input = "MSH|{0}|sys1|sys1|sys2|sys2|20180503174921||ORM^O01|1234567890|P|2.3\r" + "PID|||1^^^XXX~2^^^YYY||LastName^FirstName||19660429|F\r" + "PV1||I|3906||||||||||||||||100001\r" + "ORC|CA|1410|3121||CA\r" + "OBR|1|1410|3121|RX50^ADDOME SUPINO"; input = input.Replace('|', fieldSeperator) .Replace('^', encodingCharacters[0]); input = string.Format(input, encodingCharacters); var parser = new PipeParser(); var message = parser.Parse(input); var expected = new EncodingCharacters(fieldSeperator, encodingCharacters); // Act var actual = EncodingCharacters.FromMessage(message); // Assert Assert.AreEqual(expected, actual); }
public void TestParseNull() { // Arrange var input = "MSH|^~\\&|LABGL1||DMCRES||19951002185200||ADT^A01|LABGL1199510021852632|P|2.2\r" + "PID|||T12345||TEST^PATIENT^P||19601002|M||||||||||123456\r" + "PV1|||NER|||||||GSU||||||||E||||||||||||||||||||||||||19951002174900|19951006\r"; var parser = new PipeParser(); var a01 = new ADT_A01(); parser.Parse(a01, input); // Act / Assert Assert.Throws <ArgumentNullException>( () => parser.Parse(a01.PID, null, EncodingCharacters.FromMessage(a01))); }
public void FromMessage_NoFieldSeperatorCharacterInMessage_ThrowsHl7Exception() { // Arrange var input = "MSH|^~\\&|sys1|sys1|sys2|sys2|20180503174921||ORM^O01|1234567890|P|2.3\r" + "PID|||1^^^XXX~2^^^YYY||LastName^FirstName||19660429|F\r" + "PV1||I|3906||||||||||||||||100001\r" + "ORC|CA|1410|3121||CA\r" + "OBR|1|1410|3121|RX50^ADDOME SUPINO"; var parser = new PipeParser(); var message = parser.Parse(input); var terser = new Terser(message); terser.Set("MSH-1", null); // Action / Assert Assert.Throws <HL7Exception>( () => EncodingCharacters.FromMessage(message)); }
public void TestParseEmpty() { // Arrange var input = "MSH|^~\\&|LABGL1||DMCRES||19951002185200||ADT^A01|LABGL1199510021852632|P|2.2\r" + "PID|||T12345||TEST^PATIENT^P||19601002|M||||||||||123456\r" + "PV1|||NER|||||||GSU||||||||E||||||||||||||||||||||||||19951002174900|19951006\r"; var expected = "MSH|^~\\&|LABGL1||DMCRES||19951002185200||ADT^A01|LABGL1199510021852632|P|2.2\r" + "PV1|||NER|||||||GSU||||||||E||||||||||||||||||||||||||19951002174900|19951006\r"; var parser = new PipeParser(); var a01 = new ADT_A01(); parser.Parse(a01, input); Assert.AreEqual(input, parser.Encode(a01)); // Act parser.Parse(a01.PID, "PID", EncodingCharacters.FromMessage(a01)); // Assert Assert.AreEqual(expected, parser.Encode(a01)); }
public void TestRemoveRepetition() { // Arrange var input = "MSH|^~\\&|ULTRA|TML|OLIS|OLIS|200905011130||ORU^R01|20169838|T|2.5\r" + "PID|||7005728^^^TML^MR||TEST^RACHEL^DIAMOND||19310313|F|||200 ANYWHERE ST^^TORONTO^ON^M6G 2T9||(416)888-8888||||||1014071185^KR\r" + "PV1|1||OLIS||||OLIST^BLAKE^DONALD^THOR^^^^^921379^^^^OLIST\r" + "ORC|RE||T09-100442-RET-0^^OLIS_Site_ID^ISO|||||||||OLIST^BLAKE^DONALD^THOR^^^^L^921379\r" + "OBR|0||T09-100442-RET-0^^OLIS_Site_ID^ISO|RET^RETICULOCYTE COUNT^HL79901 literal|||200905011106|||||||200905011106||OLIST^BLAKE^DONALD^THOR^^^^L^921379||7870279|7870279|T09-100442|MOHLTC|200905011130||B7|F||1^^^200905011106^^R\r" + "OBX|1\r" + "OBX|2\r" + "OBX|3\r"; var expected = "MSH|^~\\&|ULTRA|TML|OLIS|OLIS|200905011130||ORU^R01|20169838|T|2.5\r" + "PID|||7005728^^^TML^MR||TEST^RACHEL^DIAMOND||19310313|F|||200 ANYWHERE ST^^TORONTO^ON^M6G 2T9||(416)888-8888||||||1014071185^KR\r" + "PV1|1||OLIS||||OLIST^BLAKE^DONALD^THOR^^^^^921379^^^^OLIST\r" + "ORC|RE||T09-100442-RET-0^^OLIS_Site_ID^ISO|||||||||OLIST^BLAKE^DONALD^THOR^^^^L^921379\r" + "OBR|0||T09-100442-RET-0^^OLIS_Site_ID^ISO|RET^RETICULOCYTE COUNT^HL79901 literal|||200905011106|||||||200905011106||OLIST^BLAKE^DONALD^THOR^^^^L^921379||7870279|7870279|T09-100442|MOHLTC|200905011130||B7|F||1^^^200905011106^^R\r" + "OBX|1\r" + "OBX|3\r"; var oruR01 = new ORU_R01(); var parser = new PipeParser(); parser.Parse(oruR01, input); // Action var obx = oruR01.GetPATIENT_RESULT().GetORDER_OBSERVATION().GetOBSERVATION(1); oruR01.GetPATIENT_RESULT().GetORDER_OBSERVATION().RemoveOBSERVATIONAt(1); var result = parser.Encode(oruR01); // Assert Assert.AreEqual("OBX|2", PipeParser.Encode(obx.OBX, EncodingCharacters.FromMessage(oruR01))); Assert.AreEqual(expected, result); }