web stats
ACK Problem - Cloverleaf - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-30-2010, 12:56 AM
Klaus Klaus is offline
Mirth Newb
 
Join Date: Dec 2009
Posts: 13
Klaus is on a distinguished road
Default ACK Problem - Cloverleaf

Hello,

i have a problem ... :P

this is my Situation:

i have a Mirth Channel TCP Listener and i have a Cloverleaf.

The Cloverleaf sends messages to a ip+port.

my TCP Listener listen to this port and get the message.

the problem is that Cloverleaf needs a ACK. So i had Creat via JavaScript a ACK
(i got this Script from this forum)
Code:
// This script executes once after a message has been processed

var ack = "";

var dateFormat = "yyyyMMddHHmmss";

var textMessage = "";
var ackCode = "";
var errorMessage = "";

var statusMsg = "";

var processedDestination = "";
var acknowledgementCode = "";

var statusMsg = responseMap.get('Destination 1').getStatus().toString();

//The status will be "SUCCESS","FAILURE","FILTERED". If it is "SUCCESS" then the -- Added by Jared Quick
//web service was called correctly.
//var responseVal = responseMap.get('output').getMessage();
		if (statusMsg.toString() == "FILTERED" ) {
			textMessage = "Message Failed Validation";
			//errorMessage = "Message failed validation for one of the following reasons:- / One of the required fields was not populated // The wrong version of HL7 has been sent // The receiving / sending application's values were incorrect /";
			acknowledgementCode = "AR"
			////logger.info('FILTERED Status');
		} 
else if (statusMsg.toString() == "ERROR") 
{
			textMessage = "An error occurred updating the database";
			acknowledgementCode = "AE";
		} else if (statusMsg.toString() == "FAILURE") {

			textMessage = "A processing failure occurred";
			//errorMessage = responseMap.get(processedDestination).getMessage();
			acknowledgementCode = "AE";
		} else if (statusMsg.toString() == "UNKNOWN") {
			textMessage = "Message Status Unknown";
			acknowledgementCode = "AE";
		}else {
			textMessage = "Message Processed Sucessfully";
			errorMessage = "";
			acknowledgementCode = "AA";
		}

var segmentDelim = "\r";
var fieldDelim = "|"; // Usually |
var componentDelim = "^"; // Usually ^
var repetitionSeparator = "~"; // Usually ~
var escapeCharacter = "\\"; // Usually \
var subcomponentDelim = "&"; // Usually &
	
//Default message Delimiters
var sendingApplication = ""; // MSH.3.1
var sendingFacility = ""; // MSH.4.1
var receivingApplication = ""; // MSH.5.1
var receivingFacility = ""; // MSH.6.1
var securityValue = ""; //MSH 7.1 - Added by Richard Haine
var triggerEvent = ""; //MSH 9.2 - Added by Richard Haine
var originalid = ""; // MSH.10.1
var newMessageId = ""; // Added by Richard Haine
var procid = ""; // MSH.11.1
var procidmode = ""; // // MSH.11.2
var version_number = ""; // MSH.12.1
var acceptAcknowledgmentType = ""; //MSH.15.1
var applicationAcknowledgmentType = ""; //MSH.16.1

var encodeChrs = ""; // MSH.2



rightNow = java.util.Calendar.getInstance();
var dateString = DateUtil.getCurrentDate(dateFormat);
dateString = dateString.toString() + rightNow.get(java.util.Calendar.MILLISECOND);
newMessageId = dateString.toString();
		//logger.error('12');			
			//fieldDelim = channelMap.get('messageHeader_fieldSeparator');
			fieldDelim = channelMap.get('messageHeader_fieldSeparator');
			encodeChrs = channelMap.get('messageHeader_encodingCharacters');
			sendingApplication = channelMap.get('messageHeader_sendingApplication_entityIdentifier'); //componentPattern.split(mshFields[2])[0]; // MSH.3.1
			sendingFacility = channelMap.get('messageHeader_sendingFacility_entityIdentifier'); //componentPattern.split(mshFields[3])[0]; // MSH.4.1
			receivingApplication = channelMap.get('messageHeader_receivingApplication_entityIdentifier'); //componentPattern.split(mshFields[4])[0]; // MSH.5.1
			receivingFacility = channelMap.get('messageHeader_receivingFacility_entityIdentifier'); //componentPattern.split(mshFields[5])[0]; // MSH.6.1
			securityValue = channelMap.get('messageHeader_security_value'); //componentPattern.split(mshFields[7])[0]; // MSH.8.1
			triggerEvent = channelMap.get('messageHeader_messageType_event'); //componentPattern.split(mshFields[8])[1]; // MSH.9.2
			originalid = channelMap.get('messageHeader_messageControlId_value'); //componentPattern.split(mshFields[9])[0]; // MSH.10.1
			procid = channelMap.get('messageHeader_processingId_processingId');
			version_number = channelMap.get('messageHeader_versionId_versionId');
			acceptAcknowledgmentType = channelMap.get('messageHeader_acceptAcknowledgmentType_value');
			applicationAcknowledgmentType = channelMap.get('messageHeader_applicationAcknowledgmentType_value');
			
		if (textMessage != null && java.lang.String(textMessage).length() > 0) 
		{
			textMessage = fieldDelim.toString() + textMessage.toString();

		} 
		else 
		{
			textMessage = "";

		}

		if (errorMessage != null && java.lang.String(errorMessage).length() > 0) 
		{
			errorMessage = segmentDelim.toString() + "ERR" + fieldDelim.toString() + errorMessage.toString();

		} 
		else 
		{
			errorMessage = "";
			logger.info("I reset the error!");
		}
		

		// Set defaults to important fields if they're blank.
		if (version_number == null || java.lang.String(version_number).length() == 0) {
			version_number = "2.3";
		}
		if (procid == null || java.lang.String(procid).length() == 0) {
			procid = "P";
		}
		if (originalid == null || java.lang.String(originalid).length() == 0) {
			originalid = ""; // we should reject in this case
		}
		
		if (triggerEvent == null) {
			triggerEvent=""; // this is not a valid entry but should never happen!
		}
		if (newMessageId == null || java.lang.String(newMessageId).length() == 0) {
			newMessageId=dateString;
		}
		if (acceptAcknowledgmentType == null) {
			acceptAcknowledgmentType="";
		}
		if (applicationAcknowledgmentType == null) {
			applicationAcknowledgmentType="";
		}
		if (acknowledgementCode == null) {
			acknowledgementCode="AE"; // default to reject if no value has been provided
		}
		timestamp = DateUtil.getCurrentDate(dateFormat);
		ackBuilder = new java.lang.StringBuilder();
		ackBuilder.append(message.substring(0, 9));
		ackBuilder.append("MSH" + fieldDelim + componentDelim + repetitionSeparator + escapeCharacter + subcomponentDelim + fieldDelim);
//ackBuilder.append("."+"MSH" + fieldDelim.toString() + encodeChrs.toString() + fieldDelim.toString());		

		ackBuilder.append(receivingApplication);
		ackBuilder.append(fieldDelim);
		ackBuilder.append(receivingFacility);
		ackBuilder.append(fieldDelim);
		ackBuilder.append(sendingApplication);
		ackBuilder.append(fieldDelim);
		ackBuilder.append(sendingFacility);
		ackBuilder.append(fieldDelim);
		ackBuilder.append(timestamp);
		ackBuilder.append(fieldDelim);
		ackBuilder.append(fieldDelim);
		ackBuilder.append("ACK");
		//ackBuilder.append(componentDelim); //Added by R.Haine
		//ackBuilder.append(triggerEvent); //Added by R.Haine
		ackBuilder.append(fieldDelim);
		ackBuilder.append(newMessageId); //modified by R.Haine - was timestamp
		ackBuilder.append(fieldDelim);
		ackBuilder.append(procid);
		ackBuilder.append(fieldDelim);
		ackBuilder.append(version_number);
		ackBuilder.append(fieldDelim);
		//ackBuilder.append(fieldDelim);
		//ackBuilder.append(fieldDelim);
		//ackBuilder.append(acceptAcknowledgmentType);
		//ackBuilder.append(fieldDelim);
		//ackBuilder.append(applicationAcknowledgmentType);
		ackBuilder.append(segmentDelim);
		ackBuilder.append("MSA");
		ackBuilder.append(fieldDelim);
		ackBuilder.append(acknowledgementCode);
		ackBuilder.append(fieldDelim);
		ackBuilder.append(originalid);
		//ackBuilder.append(fieldDelim);
		//ackBuilder.append(textMessage);
	//	ackBuilder.append(errorMessage);

		//ackBuilder.append(".");
	
		

		//ackBuilder = new java.lang.StringBuilder();

		ack = ackBuilder.toString();

var s = ack.substring(9);
		


//s.substring(0,pos)+s.substring(pos+1);



	
	logger.info(s);
		if(acknowledgementCode == "AA") 
		{
logger.info('INFO: ACK was send Successfully');
			responseMap.put('Post_Process_ACK', ResponseFactory.getSuccessResponse(s));
		} 
		else if (acknowledgementCode == "AR") 
		{
logger.info('INFO: ACK was filtered');
			responseMap.put('Post_Process_ACK', ResponseFactory.getFilteredResponse(s));
		} 
		else 
		{
logger.info('INFO: ACK was Failure');
			responseMap.put('Post_Process_ACK', ResponseFactory.getFailureResponse(s));
		}

return;
So the Result is this.

MSH|^~\&|MEDOS|MEDOS|SAP-ISH|034|20100430085458||ACK^A03|20100430085458903| P|2.3||||
MSA|AA|27783214||Message Processed Sucessfully


My problem is, that the Cloverleaf dont get or dont accept the ACK ....
when we turn off the ACK on Cloverleaf side its working but Cloverleaf sends more than 1 HL7-msg in 1 receiving Message and i get an Error that the Message not well-formed or something...

when Cloverleaf dont get the ACK when its turned on, the Cloverleaf sends the same Message every time....
the Mirth turn after receiving the Connection off


Cloverleaf -> MSG -> MIRTH
MIRTH -> ACK -> Cloverleaf
Cloverleaf -> NEXT MSG -> MIRTH
...
...

Question
is my ACK-Syntax right? what could be the problem?

best regards

Klaus


ps: sorry for my english its not the best
Reply With Quote
  #2  
Old 04-30-2010, 01:42 AM
nicovn nicovn is offline
OBX.2 Kenobi
 
Join Date: Oct 2006
Location: Belgium
Posts: 64
nicovn
Default

Hi Klaus,


You should have chosen "LLP Listener" instead of "TCP Listener" on the Source tab.


The LLP listener takes care of the underlying HL7 lower layer protocol.

If you use LLP listener you don't have to construct your own HL7 ack message.


Hope this helps.


Best Regards

Nico
__________________
Nico Vannieuwenhuyze

Amaron.be
Reply With Quote
  #3  
Old 04-30-2010, 02:09 AM
Klaus Klaus is offline
Mirth Newb
 
Join Date: Dec 2009
Posts: 13
Klaus is on a distinguished road
Default

Quote:
Originally Posted by nicovn View Post
Hi Klaus,


You should have chosen "LLP Listener" instead of "TCP Listener" on the Source tab.


The LLP listener takes care of the underlying HL7 lower layer protocol.

If you use LLP listener you don't have to construct your own HL7 ack message.


Hope this helps.


Best Regards

Nico
Hello Nico,

thank´s for your Answer...

its working now ... =D

Klaus
Reply With Quote
Reply

Tags
ack, adr, cloverleaf, response, tcp listener

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 03:23 AM.


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