web stats
Trouble with Batch Files - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-19-2020, 09:00 PM
XXMirthXX XXMirthXX is offline
Mirth Newb
 
Join Date: Mar 2020
Posts: 8
XXMirthXX is on a distinguished road
Default Trouble with Batch Files

I am using Mirth Connect (v.3.8.1) to replace another interface engine.
We have an integration where a trading partner sends hundreds of messages within a single batch file.
So it looks like
FHS
BHS
MSH
*rest of HL7 v2 message, e.g. PID, EVN
BTS
FTS

Currently I have it working pretty darn close to what I need, but I've run into a weird problem I'm not sure how to resolve.
The output from MC includes an FHS, BHS, BTS and FTS on each message, so where I expect 806 MSH segments in the output file and only one FHS segment, for example, I'm actually seeing 806 FHS segments (one per message).

Does anybody have any tips, or a sample channel for processing batch files that I could use as a reference?

Thank you very much.

**I updated this post to include attachments that are 1) the exported channel 2) sample input file - two messages in file 3) examples of what I'm getting as output.

Everything is processed through a single Javascript source transformer:

Code:
var dateTdy,strdate,strDt,strMn,strHr,strMin,strSec, mshCount = 0;

dateTdy = new Date();
strdate = dateTdy.getFullYear().toString();
if (dateTdy.getDate() < 10)
	strDt = "0"+dateTdy.getDate();
else
	strDt = dateTdy.getDate().toString();
if (dateTdy.getMonth() < 9)
	strMn = "0"+(dateTdy.getMonth()+1);
else
	strMn = (dateTdy.getMonth()+1).toString();
if (dateTdy.getHours() < 9)
	strHr = "0"+dateTdy.getHours();
else
	strHr = dateTdy.getHours();
if (dateTdy.getMinutes() < 9)
	strMin = "0"+dateTdy.getMinutes();
else
	strMin = dateTdy.getMinutes();
if (dateTdy.getSeconds() < 9)
	strSec = "0"+dateTdy.getSeconds();
else
	strSec = dateTdy.getSeconds();


msg.prependChild(<BHS/>);
msg['BHS']['BHS.7']['BHS.7.1'] = strdate+strMn+strDt+strHr+strMin+"."+strSec;
msg['BHS']['BHS.10']['BHS.10.1'] = "";

msg.prependChild(<FHS/>);
msg['FHS']['FHS.7']['FHS.7.1'] = strdate+strMn+strDt+strHr+strMin+"."+strSec;
msg['FHS']['FHS.9']['FHS.9.1'] = sourceMap.get('originalFilename');





//MSH Segment
msg['MSH']['MSH.3']['MSH.3.1'] = validate('prov', '', new Array());
msg['MSH']['MSH.4']['MSH.4.1'] = validate('', '', new Array());
msg['MSH']['MSH.5']['MSH.5.1'] = validate('RPM_PROV', '', new Array());
msg['MSH']['MSH.6']['MSH.6.1'] = validate('', '', new Array());
msg['MSH']['MSH.7']['MSH.7.1'] = msg['MSH']['MSH.7']['MSH.7.1'].toString();
msg['MSH']['MSH.8']['MSH.8.1'] = validate('', '', new Array());
//msg['MSH']['MSH.9'] =  this component doesn't need to be changed.
msg['MSH']['MSH.7']['MSH.7.1'] = msg['MSH']['MSH.7']['MSH.7.1'].toString();
msg['MSH']['MSH.10']['MSH.10.1'] = msg['MSH']['MSH.10']['MSH.10.1'].toString();
msg['MSH']['MSH.11']['MSH.11.1'] = validate('P', '', new Array());
msg['MSH']['MSH.12']['MSH.12.1'] = validate('2.3.1', '', new Array());

// EVN Segment - not present in source message. Creating it in outbound message here:
createSegmentAfter('EVN', msg['MSH']);
msg['EVN']['EVN.1']['EVN.1.1'] = msg['MSH']['MSH.9']['MSH.9.2'].toString();

//No Changes to PID segment.

//PV1 Segment
// Added PV1-45 because BizTalk was adding a "|" pipe - only to the PV1 segment (PV1-44) It's not on any other segments. 
//msg['PV1']['PV1.46']['PV1.46.1'] = msg['PV1']['PV1.46']['PV1.46.1'].toString();
if(msg['PV1']['PV1.45']['PV1.45.1'].toString().length == 0)
msg['PV1']['PV1.45']['PV1.45.1'] = ''; 


//PV1-7 added because carets were being sent in some messges so now they will be copied. 
if(msg['PV1']['PV1.7']['PV1.7.1'].toString().length == 0)
msg['PV1']['PV1.7']['PV1.7.1'] = '^^^^^^^^';



//No Changes to DG1 segment.

//IN1 Segment
for each (var in1 in msg.IN1) {
    in1['IN1.3']['IN1.3.1'] = '';   //Clear IN1-3.1
    in1['IN1.9']['IN1.9.1'] = '';   //Clear IN1-9.1
    in1['IN1.19']['IN1.19.7'] = ''; //Clear IN1-19.7 
    in1['IN1.19']['IN1.19.8'] = ''; //Clear IN1-19.8 
    in1['IN1.19']['IN1.19.9'] = ''; //Clear IN1-19.9 
    in1['IN1.35']['IN1.35.1'] = ''; //Clear IN1-35.1
    in1['IN1.36']['IN1.36.1'] = ''; //Clear IN1-36.1
    in1['IN1.42']['IN1.42.1'] = ''; //Clear IN1-42.1
    in1['IN1.44']['IN1.44.6'] = ''; //Clear IN1-44.6
    in1['IN1.47']['IN1.47.1'] = ''; //Clear IN1-47.1
   
}

// ZXA Segment - not present in source message.
//ZXA Segment
if(msg['PV1']['PV1.39']['PV1.39.1'].toString().length > 0) {
msg['ZXA']['ZXA.1']['ZXA.1.1'] = '1';
msg['ZXA']['ZXA.2']['ZXA.2.1'] = '50';         
msg['ZXA']['ZXA.2']['ZXA.2.2'] = msg['PV1']['PV1.39']['PV1.39.1'].toString();
}

//BTS segment
for each (segMSH in msg.MSH) {
	mshCount++;
}

msg['BTS']['BTS.1'] = "" + mshCount;
msg['BTS']['BTS.3'] = "";


//FTS Segment (end of message)
createSegmentAfter('FTS', msg['BTS']);
msg['FTS']['FTS.1']['FTS.1.1'] = '1';
Attached Files
File Type: xml ADT - Mirth Channel.xml (30.5 KB, 0 views)
File Type: doc Input and Output Messages.doc (25.5 KB, 0 views)

Last edited by XXMirthXX; 03-20-2020 at 02:56 PM.
Reply With Quote
Reply

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:26 PM.


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