1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
979 views
by ramaswamy-s-6353 (440 points)

My OBX-5 segment has RTF formatting which the EMR cannot digest. So use RTFEditor kit from one of the previous posts to remove the RTF format.

But HEX characters for line feed are left behind  - [x0A]. I am unable to replace them.

 var rtfEditorKit = new javax.swing.text.rtf.RTFEditorKit();

var rtfDocument = rtfEditorKit.createDefaultDocument();
rtfEditorKit.read(new java.io.ByteArrayInputStream(message.getBytes()), rtfDocument, 0);
message.setNode('OBX-5', rtfDocument.getText(0, rtfDocument.getLength()));

1 Answer

0 votes

Java converts the line feed into unicode in the bytes. To replace them you can use the following line.

myText = StringUtils.replace(myText, '\u000a', '~');

Here is a full test script

var myText = "Howdy\nMy text is here.";
 
myText = StringUtils.replace(myText, '\u000a', '~');
 
qie.debug(myText);
by brandon-w-8204 (34.1k points)
by ramaswamy-s-6353 (440 points)
that didnt work. After converting RTF to plain text using following code when I try to replace the line feeds I get an error stating Unknown segment.

var rtfEditorKit = new javax.swing.text.rtf.RTFEditorKit();
var rtfDocument = rtfEditorKit.createDefaultDocument();
rtfEditorKit.read(new java.io.ByteArrayInputStream(message.getBytes()), rtfDocument, 0);
message.setNode('OBX-5', rtfDocument.getText(0, rtfDocument.getLength()));

I am guessing  the output loses the HL7 format.

Thanks for helping me out.
...