Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HL7 TX type, obx.5 leading space being trimmed PipeParser #103

Closed
slartibartfast3000 opened this issue May 29, 2018 · 5 comments · Fixed by #185
Closed

HL7 TX type, obx.5 leading space being trimmed PipeParser #103

slartibartfast3000 opened this issue May 29, 2018 · 5 comments · Fixed by #185
Assignees
Labels
bug The result of a coding Error

Comments

@slartibartfast3000
Copy link

slartibartfast3000 commented May 29, 2018

2.4 standard states:
"2.9.48 TX - text data
String data meant for user display (on a terminal or printer). Such data would not necessarily be left jus-tified since leading spaces may contribute greatly to the clarity of the presentation to the user. "

Unless I've missed a config option or rule, escape() function in Escape.cs always trims leading and trailing spaces for type TX i.e. return result.ToString().Trim();

Perhaps it should be changed to only TrimEnd?

Example OBX...

Before...
OBX|23|TX|^Report Line 23|| Sample stored as serological investigations on samples taken within||||||C|||201607270920

After...
OBX|23|TX|^Report Line 23||Sample stored as serological investigations on samples taken within||||||C|||201607270920

The XMLParser works fine as it has KeepAsOriginalNodes property which the PipeParser does not have

@JeremyOne
Copy link

We also would like to use leading spaces to indent report sections and lists. In our tests with longer reports this increases readability significantly.

@Usualdosage
Copy link
Collaborator

All primitives (FT, ST, etc) are escaped by default. Are there any other primitives that have this requirement? I'd prefer not to have to put in a one-off just for TX.

@slartibartfast3000
Copy link
Author

slartibartfast3000 commented Oct 22, 2020 via email

@Usualdosage
Copy link
Collaborator

Not sure what you mean by escaped, this isn’t an escape problem. The library is trimming leading spaces.

You previously said:

Unless I've missed a config option or rule, escape() function in Escape.cs always trims leading and trailing spaces for type TX i.e. return result.ToString().Trim();

And you are correct, escape() IS trimming leading and trailing spaces (Escape.cs line 187) for all primitive types, including TX. My question was regarding the other primitive types. Should they also ignore trimming, or is TX "special"?

@Usualdosage Usualdosage self-assigned this Oct 23, 2020
@milkshakeuk milkshakeuk added the bug The result of a coding Error label Oct 30, 2020
@milkshakeuk milkshakeuk added this to To Do in NHapi Kanban via automation Oct 30, 2020
@milkshakeuk
Copy link
Member

@slartibartfast3000 FYI in case you are interested.
I copied an Escape unit test from hapi (though technically it's not really a unit test since its testing multiple layers).
This unit test show that some whitespace at the end of the string is preserved, but when I copied it into nHapi the whitespace is not preserved

[Test]
public void TestPreserveFormattingChars()
{
    var msg = new ORU_R01();

    var ft = new FT(msg);
    msg.GetRESPONSE().GetORDER_OBSERVATION().GetOBSERVATION().OBX.ValueType.Value = "FT";
    msg.GetRESPONSE().GetORDER_OBSERVATION().GetOBSERVATION().OBX.GetObservationValue(0).Data = ft;

    ft.Value = "H \\H\\ N \\N\\ ";

    Assert.AreEqual("H \\H\\ N \\N\\ ", ft.Value);
    Assert.AreEqual("H \\H\\ N \\N\\ ", PipeParser.Encode(ft, _encodingCharacters));

    ft.Value = "H \\C00FF\\ N";
    Assert.AreEqual("H \\C00FF\\ N", ft.Value);
    Assert.AreEqual("H \\C00FF\\ N", PipeParser.Encode(ft, _encodingCharacters));
}

Unit test result below

Expected string length 12 but was 11. Strings differ at index 11.
Expected: "H \\H\\ N \\N\\ "
But was:  "H \\H\\ N \\N\\"
--------------------------^

at NHapi.NUnit.Parser.EscapeTests.TestPreserveFormattingChars() in C:\DEV\nHapi\tests\NHapi.NUnit\Parser\EscapeTests.cs:line 111

this is caused by Escape.cs Line 261.
Hapi does not do any trimming inside Escape.java so its highly likely nHapi shouldn't be either.

milkshakeuk added a commit that referenced this issue Feb 27, 2021
Changed behaviour of Escape to (mostly) match hapi implamentation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
milkshakeuk added a commit that referenced this issue Feb 27, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
milkshakeuk added a commit that referenced this issue Feb 28, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
milkshakeuk added a commit that referenced this issue Mar 1, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
milkshakeuk added a commit that referenced this issue Mar 1, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
milkshakeuk added a commit that referenced this issue Mar 6, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
Make line feed / carriage return hexadecimal escape sequences configurable
milkshakeuk added a commit that referenced this issue Mar 6, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
Make line feed / carriage return hexadecimal escape sequences configurable
milkshakeuk added a commit that referenced this issue Mar 7, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
Make line feed / carriage return hexadecimal escape sequences configurable
Add .gitattributes to prevent the line endings of txt files being changed on checkout (was breaking tests)
milkshakeuk added a commit that referenced this issue Mar 7, 2021
Changed behaviour of Escape to (mostly) match hapi implementation
Also added unit test to ensure Escape behaves correctly (some borrowed from hapi)
Make line feed / carriage return hexadecimal escape sequences configurable
Add .gitattributes to prevent the line endings of txt files being changed on checkout (was breaking tests)
NHapi Kanban automation moved this from To Do to Development Done Mar 8, 2021
@milkshakeuk milkshakeuk moved this from Development Done to In Pre-Release in NHapi Kanban Jun 2, 2021
@milkshakeuk milkshakeuk moved this from In Pre-Release to Released in NHapi Kanban Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The result of a coding Error
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants