Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2503
  • Last Modified:

Mirth Connect Read File - Javascript

I'm looking for a sample script using Mirth Connect to read a ASCII Text.  The text file is formatted like a proprietary transaction file.  Each line is a delimited record, but there are multiple record types within the file,  just like a transaction file would have.

Example

GG1,John,Smith
GG2,"207 Main Street",Springfield,MA,02134
GG3,ITM001,"Red Pencil Sharpener"
GG3,ITM005,"Shoe Laces"
GG3,ITM014,"Bicycle pump"
GG4,400.02
GG5,"Repeat Customer Award",102.44

Open in new window


I need the records to go into 3 different MSSQL database tables

GG1 and GG2 records go into the customer table.
GG3  records go into the items table.
GG4 and GG5  records go into the benefits table.

Since noone is answering this question,   I have decided to simplify the question, and also add more detail.

I need help getting the Javascript and more specifically, how to use Javascript within the mirth application as part of the channel setup.

For the sake of simplicity, lets just say only the GG1 and GG2 lines to extract the info (using Mirth)

GG1,John,Smith
GG2,"207 Main Street",Springfield,MA,02134

Open in new window


more details

I have made some progress and have a code snippet that works, but definitely depends on good clean data.

var msg = connectorMessage.getRawData()

//Convert from Java string to Javascript 
var msgTemp = String(new java.lang.String(msg));

// verify msg is populated with the message
logger.info('msg='+msg);
logger.info('msgTemp='+msgTemp);

// get rid of crlf
msg = msgTemp.replace(/[\n\r]+/g, ',');

// verify msg is populated with the message
logger.info('msg='+msg);

// split the string into res array
var res = msg.split(",");

// Sample String
// GG1,John,Smith

// firstname element should be populated with John
tmp['firstname'] = res[1];
// lastname element should be populated with Smith
tmp['lastname'] = res[2];

Open in new window


This code is under the source Transformer Step.

mirth01.jpg
at this point, my question needs to be revised to - Is there a better way to do this using the Mirth Connect Tool?
0
Jeff Darling
Asked:
Jeff Darling
1 Solution
 
COBOLdinosaurCommented:
Jeff,

As Mirth is an HL7 interface, you are asking about a product that is very narrowly focused as HL7 is designed for use in health care and patient information applications.  I t may be that this has gone without a response because no one on the site is using or familar with Mirth.  

Even though I have worked with HL7 I am not familiar with Mirth and I have no idea how the connect tool works.  Sorry I can be of any real help.  You might be able to find what you need in the community forum for mirth connect:

http://www.mirthcorp.com/community/forums/forumdisplay.php?s=0fe6a152b77642251dda660b0a3e59ed&f=3

Cd&
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now