Skip to content

Commit

Permalink
Add unit test for #72
Browse files Browse the repository at this point in the history
  • Loading branch information
milkshakeuk committed Apr 15, 2021
1 parent cf47b92 commit 0f4bf3f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/NHapi.Base/Model/AbstractGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public virtual void RemoveRepetition(string name, int rep)
{
throw new HL7Exception(
$"The structure {name} does not have {rep} repetitions. ",
ErrorCode.APPLICATION_INTERNAL_ERROR);
ErrorCode.APPLICATION_INTERNAL_ERROR);
}

item.Structures.RemoveAt(rep);
Expand Down
29 changes: 29 additions & 0 deletions tests/NHapi.NUnit/Parser/PipeParserUnexpectedSegmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,35 @@ public class PipeParserUnexpectedSegmentTests
{
#region v23

/// <summary>
/// Fixes https://github.com/nHapiNET/nHapi/issues/72.
/// </summary>
[Test]
public void Parse_V23_ADT_A01()
{
var message =
"MSH|^~\\&|V500|01010|TEST|TEST|20170130125848||ADT^A01|12345||2.3||||||8859/1\r"
+ "EVN|A01|20170130125600|||12345|20170130125600\r"
+ "PID|1|12345^^^PATIENT MASTER^MRN^|12345^^^PATIENT MASTER^MRN^||TEST||20101114|F||4|16 Bothar Na Tra^^Ireland^^^1101^home^^||||2303|1||12345^^^EPISODE NUMBER^FIN NBR^|12312312310||||||0|Not Known / Not Stated||1101||\r"
+ "PV1|1|I|TEST^08^011^A207^^Bed(s)^A207|01||^^^^^^|0121212J^Stephen^Peter^J^^Dr^^^Doctor Provider Number^Personnel^^^DOCUPIN^|||ONC|||1|01|||0121212J^Stephen^Peter^J^^Dr^^^Doctor Provider Number^Personnel^^^DOCUPIN^|8|12345^0^^^Visit Id|5M^20170130125600|||||||||||||||||||B2021||Active|||20170130125600\r"
+ "NK1|1||||0404111111^^^[email protected]||Proxy\r"
+ "NK1|2||||0404111112^^^[email protected]||Proxy 2";

var parser = new PipeParser();

var adtA01 = (NHapi.Model.V23.Message.ADT_A01)parser.Parse(message);
var allNextOfKin = adtA01.GetAll("NK12");

Assert.IsNotNull(allNextOfKin);
Assert.IsNotEmpty(allNextOfKin);
Assert.AreEqual(
"[email protected]",
((Model.V23.Segment.NK1)allNextOfKin[0]).GetPhoneNumber(0).EmailAddress.Value);
Assert.AreEqual(
"[email protected]",
((Model.V23.Segment.NK1)allNextOfKin[1]).GetPhoneNumber(0).EmailAddress.Value);
}

[Test]
public void Parse_V23_ORM_O01()
{
Expand Down

0 comments on commit 0f4bf3f

Please sign in to comment.