Solved

Mirth Connect  Read File - Javascript

Posted on 2014-12-16
1
1,409 Views
Last Modified: 2014-12-21
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
Comment
Question by:Jeff Darling
1 Comment
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 40512079
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Read about why website design really matters in today's demanding market.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now