Announcement

Collapse

Mirth Connect 4.1.0 Released!

Mirth Connect 4.1.0 is now available as an appliance update and on our GitHub page. Mirth Connect 4.1.0 includes new features such as new event log messages, additional fields to the Welcome to Mirth Connect screen, new information included in alerts as well as many smaller changes, updates, and improvements. This release also contains several improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Import CSV file with quotes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Import CSV file with quotes

    Forgive me if this is in the wrong area of the forum. I am trying to create a simple import of a CSV file with quotes. I am running the script belown in the preprocessor and have just one problem: If the field contains a comma, it tries to make it into two fields.

    Example "AAA111111","XX-01-87(06)","SMITH, JOE P",07/XX/07,

    I get the fields:
    AAA111111
    XX-01-87(06)
    SMITH
    JOE P
    07/XX/07

    I am new to JS, but I am pretty sure that there should be a way to ignore a comma inside of a set of quotes. Any help would be appreciated.

    John

    Code:

    // Modify the message variable below to pre process data
    message = message.replace(/[\r\n]/g, "\n");

    var columnnames = new Array("Chart","XRay","PatientName","DateScheduled" ,"DOB","Sex","ReferenceCode","Doctor","ReferenceNo ","Recall","Reason");
    var nofcolumns = 11;
    var lines = new Array();
    var newmessage = new String();
    newmessage = "<!-- Generated using Mirth PreProc -->\n";
    newmessage += "<Root>\n";
    rawData = message;
    lines = rawData.split("\n");
    for (var i=0;i<lines.length;i++) {
    currline = lines[i];

    newmessage += "<Patient>\n";
    var data = new Array();
    data = currline.split(Chr()",");
    for (var j = 0; j < nofcolumns; j++){
    newmessage += "<" + columnnames[j] + ">" + data[j] + "</" + columnnames[j] + ">\n";
    }
    newmessage += "</Patient>\n";
    }
    newmessage += "</Root>\n";
    return newmessage


    return message;

  • #2
    Were you able to resolve this issue?

    Comment

    Working...
    X