web stats
ACK response - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2018, 06:07 AM
CardosoDSI CardosoDSI is offline
What's HL7?
 
Join Date: Jun 2018
Posts: 3
CardosoDSI is on a distinguished road
Default ACK response

Hi all,

I am trying to create an ACK response for an HL7 request.

I already read the Thread http://www.mirthproject.org/communit...ead.php?t=6626

and I created a code template based on what narupley said, the problem is that whenever I get an hl7 request the ack is always the same:

MSH|^~\&|test|test|test|test|20180612142202.640||A CK^O23^ACK|20180612142202.640|P|2.5
MSA|AR|20180612135152.337|Message Rejected.

Can someone tell me what I'm doing wrong?


**************** code template:
Quote:
function buildAckMsg(sourceMsg,responseCode,responseMsg,res ponseStatus) {
importPackage(com.mirth.connect.model);

if (!responseStatus)
responseStatus = {'AA':Status.RECEIVED,'AR':Status.FILTERED,'AE':St atus.ERROR}[responseCode] || Status.UNKNOWN;

var ack = <HL7Message/>;
ack.MSH['MSH.1'] = sourceMsg.MSH['MSH.1'].toString();
ack.MSH['MSH.2'] = sourceMsg.MSH['MSH.2'].toString();
ack.MSH['MSH.3'] = sourceMsg['MSH']['MSH.5']['MSH.5.1'].toString();
ack.MSH['MSH.4'] = sourceMsg['MSH']['MSH.6']['MSH.6.1'].toString();
ack.MSH['MSH.5'] = sourceMsg['MSH']['MSH.3']['MSH.3.1'].toString();
ack.MSH['MSH.6'] = sourceMsg['MSH']['MSH.4']['MSH.4.1'].toString();
ack.MSH['MSH.7']['MSH.7.1'] = DateUtil.getCurrentDate('yyyyMMddHHmmss');
ack.MSH['MSH.9']['MSH.9.1'] = 'ACK';
ack.MSH['MSH.9']['MSH.9.2'] = sourceMsg.MSH['MSH.9']['MSH.9.2'].toString();
ack.MSH['MSH.9']['MSH.9.3'] = 'ACK';
ack.MSH['MSH.10'] = DateUtil.getCurrentDate('yyyyMMddHHmmssSSS');
ack.MSH['MSH.11'] = sourceMsg.MSH['MSH.11'].copy();
ack.MSH['MSH.12'] = sourceMsg.MSH['MSH.12'].copy();
ack.MSA['MSA.1']['MSA.1.1'] = responseCode;
ack.MSA['MSA.2']['MSA.2.1'] = sourceMsg.MSH['MSH.10']['MSH.10.1'].toString();
ack.MSA['MSA.3']['MSA.3.1'] = responseMsg;

var res_hl7=SerializerFactory.getSerializer('HL7V2').f romXML(ack);
logger.info(res_hl7);

responseMap.put('ACK',new Response(responseStatus,res_hl7));
}
mirth version: 3.5.2
Reply With Quote
  #2  
Old 06-12-2018, 06:38 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,002
narupley is on a distinguished road
Default

Where are you using that code template? Can you share the channel code that is actually calling the code template?

On the Source tab, have you chosen the "ACK" variable as your response?
__________________
Step 1: JAVA CACHE...DID YOU CLEAR

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 06-12-2018, 08:25 AM
CardosoDSI CardosoDSI is offline
What's HL7?
 
Join Date: Jun 2018
Posts: 3
CardosoDSI is on a distinguished road
Default

I'm using the template in the "edit filter" option of my source tab but I already know what the problem is.

Quote:
On the Source tab, have you chosen the "ACK" variable as your response?
The problem was here, I did not change the response variable. Thank you.


Just a question .... do you think the ACKGenerator.generateAckResponse function is a better solution? or is it the same?
Reply With Quote
  #4  
Old 06-12-2018, 09:36 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,002
narupley is on a distinguished road
Default

Indeed, the ACKGenerator utility class is an easier method! The thread you're referencing is from 6 years ago...
__________________
Step 1: JAVA CACHE...DID YOU CLEAR

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #5  
Old 06-14-2018, 02:11 AM
CardosoDSI CardosoDSI is offline
What's HL7?
 
Join Date: Jun 2018
Posts: 3
CardosoDSI is on a distinguished road
Default

Thanks for the reply
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 03:29 AM.


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