No announcement yet.

Guidance on sending to csv file with repeating OBX per OBR

  • Filter
  • Time
  • Show
Clear All
new posts

  • Guidance on sending to csv file with repeating OBX per OBR

    Hello. I have scoured this forum and found tons of useful info however now find myself needing expert guidance on what i am trying to achieve. Some of this is javascript related, and some of this is not knowing how to extract the information. Any help appreciated.

    Mirth Connect version:

    I am trying to build a compendium file or a channel that writes to a .csv file that will continually append the csv file where each line would look like this:


    I have found that i am probably going to need to iterate since I could have an unknown amount of OBXs for each OBR, and will also have the chance for multi-obr messges. I have found some other methods such as getSegmentsAfter and various other ways people have done something similar. But I am getting stuck due to just not knowing enough. I am assuming this should be a JavaScript Source Transform, but whether or not to use msg.OBX or msg..OBX as well as letting the Javascript write to the file or doing a channel map for a destination template is my confusion.

    I haven't yet accounted for the OBRs, just literally trying to see this code work but it isn't. Any help appreciated:

    var csv="";
    for each(var seg in msg..OBX)
    csv=csv+=seg['OBX.3']['OBX.3.1'].toString()+','+ seg['OBX.3']['OBX.3.2'].toString() + "\n";
    //FileUtil.write("C:\Desktop", true, csv);

  • #2
    This should get you started.

    PHP Code:
    var csv="";
    each(obx in msg.OBX
    obx obx['OBX.3']['OBX.3.1'].toString()+','obx['OBX.3']['OBX.3.2'].toString() + "\n";
    csv += obx;    


    • #3
      Thank you mcalKno, that did the trick. I also had to remove strict parsing. Can you explain why you used msg.OBX rather than msg..OBX?