Skip to content

Commit

Permalink
Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jaime-olivares committed Jul 31, 2024
1 parent 2b85950 commit 9a11985
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/HL7-V2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>Lightweight HL7 V2 library</Description>
<Copyright>(c) Efferent Health, LLC</Copyright>
<VersionPrefix>3.0.1</VersionPrefix>
<VersionPrefix>3.0.2</VersionPrefix>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<AssemblyName>HL7-V2</AssemblyName>
<PackageId>HL7-V2</PackageId>
Expand Down
1 change: 1 addition & 0 deletions src/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public bool ParseMessage(bool bypassValidation = false)

if (!string.IsNullOrEmpty(strSerializedMessage))
{
this.Encoding.EvaluateSegmentDelimiter(this.HL7Message);
if (this.Equals(strSerializedMessage))
isParsed = true;
}
Expand Down
2 changes: 1 addition & 1 deletion test/HL7test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Copyright>(c) Efferent Health, LLC</Copyright>
<VersionPrefix>3.0.1</VersionPrefix>
<VersionPrefix>3.0.2</VersionPrefix>
<TargetFramework>net7.0</TargetFramework>
<AssemblyName>HL7Test</AssemblyName>
<PackageId>HL7Test</PackageId>
Expand Down
27 changes: 26 additions & 1 deletion test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,31 @@ public void ParseBrokenCharMessage()

var isParsed = message.ParseMessage();
Assert.IsTrue(isParsed);
}
}

[TestMethod]
public void BypassValidationParseMessage_ShouldReturnTrue()
{
string sampleMessage = @"MSH|^~\&|SCA|SCA|LIS|LIS|202107300000||ORU^R01||P|2.4|||||||
PID|1|1234|1234||JOHN^DOE||19000101||||||||||||||
OBR|1|1234|1234||||20210708|||||||||||||||20210708||||||||||
OBX|1|TX|SCADOCTOR||^||||||F";

try
{
var msg = new Message(sampleMessage);
Assert.IsTrue(msg.ParseMessage(true));

Assert.IsNull(msg.MessageControlID, "MessageControlID should be null");

//just to make sure we have actually parsed the invalid MSH
string messageType = msg.GetValue("MSH.9");
Assert.AreEqual("ORU^R01", messageType, "Unexpected Message Type");
}
catch (Exception ex)
{
Assert.Fail("Unexpected exception", ex);
}
}
}
}

0 comments on commit 9a11985

Please sign in to comment.