Sidebar

How do you take several fields from an HL7 message and add them as a row in a CSV file?

0 votes
720 views
asked Nov 5, 2014 by (290 points)
I would like to take HL7 messages and pull the values out of certain fields and insert them as a comma separated row in a csv file. Each HL7 message would be a single row that is appended to a file. Each row would have values from the HL7 message such as patient_id, last_name, first_name, referring_provider, and so on.

1 Answer

+1 vote
 
Best answer

The first step is to create a new message and set the format to CSV - Comma Separated Values.  In a CSV file each field is a node, so if you want the value in PID-3  to be the first field in the CSV file use the following:

var value = source.getNode("PID-3");
message.setNode("1", value);

The destination would be a file, with the Append to the file checkbox checked.  

answered Nov 5, 2014 by terrie-g-7436 (3,950 points)
selected Dec 26, 2014 by sam-s-1510
commented Nov 5, 2014 by (290 points)
Thank you. I see my error now.
...