Solved

Mirth Connect  Read File - Javascript

Posted on 2014-12-16
1
2,120 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Introduction to Processes

622 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