Sidebar

Quickest way to create an HL7 file from XML content?

0 votes
388 views
asked May 1, 2018 by (220 points)
I am processing an XML format through a HTTP Listener, and the HL7 is in the XML content section.  What is the quickest way to create an HL7 file?

Currently, this is how I am processing it:

var out = new java.io.FileOutputStream(filename + '.hl7', false);

var hl7 = qie.parseHL7String(message.getNode('Request/Part/Content'));

var bytes = hl7.getBytes();
var i = 0;
while (i < bytes.length)
{
   out.write(bytes[i]);
   ++i;
}

out.close();

 

However, for larger attachments in the OBX section of the HL7, it takes a long time to process the file.  I was wondering if there is any faster way in creating HL7 files.

 

Thanks.

1 Answer

0 votes
 
Best answer

FileOutputStream can accept a byte or a byte array. The code above currently writes one byte at a time and will have overhead from the OS as it writes and acknowledges each request. Instead you can just call the write with the byte array which will be more efficient.

var out = new java.io.FileOutputStream(filename + '.hl7', false);

var hl7 = qie.parseHL7String(message.getNode('Request/Part/Content'));
out.write(hl7.getBytes());
out.close();

answered May 3, 2018 by brandon-w-8204 (33,270 points)
selected May 3, 2018 by
...