web stats
Use multiple Text files to create HL7 messages - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2016, 02:02 PM
softengg softengg is offline
Mirth Newb
 
Join Date: Nov 2006
Posts: 8
softengg
Default Use multiple Text files to create HL7 messages

I have a facility that is sending multiple flat text files (each for Patient Data, Insurance Information, Transactions, Notes etc) with multiple patient records in them. Now I need to create HL7 messages by combining the information contained in these files for each patient.

Is there a way to consume these files directly using a javascript and gather the data from these multiple files for generation of HL7 messages or will it be easier to dump these files into a DB and create the messages from there using the DB reader?

Thanks

Last edited by softengg; 06-23-2016 at 02:10 PM.
Reply With Quote
  #2  
Old 06-24-2016, 04:29 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 567
kirbykn2 is on a distinguished road
Default

I had a similar situation and thought using a DB was overkill for what we needed.

We did something similar by using one channel to combine the two files into one and another channel to parse the combined file.

A better solution would be to use a file reader in Javascript to read the contents of both files at the same time.

If you search the forum, I think I've seen posts on how to do this.
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.11.2
Mirth Connect Version 3.6.1
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_151-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.6.3
Reply With Quote
  #3  
Old 06-24-2016, 08:06 AM
softengg softengg is offline
Mirth Newb
 
Join Date: Nov 2006
Posts: 8
softengg
Default

That's our thought too that using DB would be overkill.

Would you mind sharing your channel you used for combining and parsing multiple files and/or can you point me to the posts you are referring to?

Thanks
Reply With Quote
  #4  
Old 06-24-2016, 08:55 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 567
kirbykn2 is on a distinguished road
Default

I can't post the channel because of a lot of embedded stuff (users, passwords, server information, etc.)

I can tell you
1. We had two files in a folder.
2. We had source file reader pickup the files and move them to and archive directory after reading.
3. We had two transformer steps, one for each file (if($('originalFilename') == "nodeDataArray.txt")). This steps look for the data we need and puts it in an array. You could just as easily pass the whole contents into a variable.

channel 1 channelMap.put('nodeArray',nodeArrayString);
Channel 2 channelMap.put('linkArray',linkArray);
4. On the destination in the template section we write both arrays to the same file.

${nodeArray}

${linkArray}
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.11.2
Mirth Connect Version 3.6.1
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_151-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.6.3
Reply With Quote
  #5  
Old 06-24-2016, 09:45 AM
softengg softengg is offline
Mirth Newb
 
Join Date: Nov 2006
Posts: 8
softengg
Default

Thanks for a quick reply Kirby.

This is really helpful but how do you recommend combining the arrays or the data from 2 files based upon certain fields?
For example:

File 1 contains:

PatLastName, PatFirstName, dob, SSN, MRN, Inv#

File 2 contains

Inv#, MRN, Type, InsuranceCo, Address
Reply With Quote
  #6  
Old 06-27-2016, 03:48 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

Its easy. You can use below code.
I would suggest creating JSON objects as an additional step and then map JSON to HL7

Code:
var patient = new Object();
var filePath = * absolutePathOfFile * ;
var fileOps = org.apache.commons.io.FileUtils();
var thisFile = new File(filePath);
var fileContents = fileOps.readFileToString(thisFile);
var fileContentsLines = fileContents.split("\n"); //This will put every row in the CSV as an array element.
for (i = 0; i < fileContentsLines.length; i++) { // This works as a lineIterator and moves to next line/row in the CSV
  var fileContentsColumn = fileContentsLines[i].split(","); //Now we split using comma and put inside an array

  patient.patLastName = fileContentsColumn[0];
  patient.patFirstName = fileContentsColumn[1];
  patient.dob = fileContentsColumn[2]; // and so on
}
Similarly, read the insurance file, and create insurance object.

Last edited by siddharth; 06-27-2016 at 03:49 AM. Reason: Additional
Reply With Quote
Reply

Tags
file reader, multiple text files

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:07 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation