Solved

Mirth Connect  Read File - Javascript

Posted on 2014-12-16
1
1,900 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

751 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