web stats
Custom ACK in the postprocessor script - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-06-2012, 02:55 AM
wello007 wello007 is offline
OBX.3 Kenobi
 
Join Date: Dec 2007
Posts: 160
wello007 is an unknown quantity at this point
Default Custom ACK in the postprocessor script

I created a custom ACK/NACK but instead I want to pull the value of the MSA.3.1 instead of inserting the whole NACK.
he is a piece of the postprocessor script:
Code:
if (response.getStatus() == 'FAILURE'){
	var rawResponse = response.getMessage();
    var mshind = rawResponse.search('MSH');
	var hl7Response = rawResponse.substring(mshind,rawResponse.length());
	logger.error( "ACK ="+ hl7Response);
	var nack_resp_mess = SerializerFactory.getHL7Serializer().toXML(hl7Response);
	logger.error("ack au format XML="+nack_resp_mess);
	var libelle = nack_resp_mess['MSA']['MSA.3']['MSA.3.1'].toString();
	logger.error("erreur="+libelle);
	var xml_resp_mess= '<FindPatientsResponse xmlns="http://tempuri.org/">'+
	'<Erreur><Code>'+response.getStatus()+'</Code>'+'<Libelle><![CDATA['+nack_resp_mess+']]></Libelle></Erreur>'+
	'</FindPatientsResponse>';
}
but i am getting this error
Code:
[2012-08-06 12:53:50,648]  ERROR (com.mirth.connect.server.util.JavaScriptUtil:264): Error executing Postprocessor script from channel: 835aa760-ba57-40d4-9753-ceb8168cae76
com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE:
	20: 
	var hl7Response = rawResponse.substring(mshind,rawResponse.length());21: 
	logger.error( "ACK ="+ hl7Response);22: 
	var nack_resp_mess = SerializerFactory.getHL7Serializer().toXML(hl7Response);23: 
	logger.error("ack au format XML="+nack_resp_mess);24: 
	var libelle = nack_resp_mess['MSA']['MSA.3']['MSA.3.1'].toString();25: 
	logger.error("erreur="+libelle);26: 
	var xml_resp_mess= '<FindPatientsResponse xmlns="http://tempuri.org/">'+27: 
	'<Erreur><Code>'+response.getStatus()+'</Code>'+'<Libelle><![CDATA['+nack_resp_mess+']]></Libelle></Erreur>'+28: 
	'</FindPatientsResponse>';29: }LINE NUMBER:
	25DETAILS:
	TypeError: Cannot read property "MSA.3" from undefined
Why i am not able to access to the value of the MSA.3.1?
Reply With Quote
  #2  
Old 08-06-2012, 04:17 AM
jgarcia jgarcia is offline
Mirth Newb
 
Join Date: Apr 2009
Posts: 11
jgarcia is on a distinguished road
Default

You will probably need to work with an XML Object:
var nack_resp_mess = new XML(SerializerFactory.getHL7Serializer().toXML(hl7Res ponse));

I think that should be enough to work.
Reply With Quote
  #3  
Old 08-06-2012, 07:39 AM
wello007 wello007 is offline
OBX.3 Kenobi
 
Join Date: Dec 2007
Posts: 160
wello007 is an unknown quantity at this point
Default

did it but still getting nothing

Code:
	var nack_resp_mess = new XML(SerializerFactory.getHL7Serializer().toXML(hl7Response));
	logger.error("ack au format XML="+nack_resp_mess);
	logger.error("erreur="+nack_resp_mess['MSA']['MSA.1']['MSA.3.1']);
Reply With Quote
  #4  
Old 08-06-2012, 07:46 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,213
cory_cole is on a distinguished road
Default

Can you post your logger results?
Reply With Quote
  #5  
Old 08-06-2012, 07:58 AM
wello007 wello007 is offline
OBX.3 Kenobi
 
Join Date: Dec 2007
Posts: 160
wello007 is an unknown quantity at this point
Default

Code:
[2012-08-06 17:38:55,395]  ERROR (postprocessor:?): ack au format XML=<HL7Message><MSH><MSH.1>|</MSH.1><MSH.2>^~\&amp;</MSH.2><MSH.3/><MSH.4/><MSH.5/><MSH.6/><MSH.7><MSH.7.1>20120806173841</MSH.7.1></MSH.7><MSH.8/><MSH.9><MSH.9.1>FWS</MSH.9.1><MSH.9.2>FindPatients</MSH.9.2></MSH.9><MSH.10><MSH.10.1>3FC19543-7552-4DC9-AF65-BA0B46B42619</MSH.10.1></MSH.10><MSH.11/><MSH.12/><MSH.13/><MSH.14/><MSH.15/><MSH.16/><MSH.17/></MSH><MSA><MSA.1><MSA.1.1>AE</MSA.1.1></MSA.1><MSA.2><MSA.2.1>3FC19543-7552-4DC9-AF65-BA0B46B42619</MSA.2.1></MSA.2><MSA.3><MSA.3.1>Error Parsing ZPR:3</MSA.3.1></MSA.3></MSA></HL7Message>

[2012-08-06 17:38:55,395]  ERROR (postprocessor:?): erreur=
Reply With Quote
  #6  
Old 08-06-2012, 08:03 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,099
narupley is on a distinguished road
Default

Quote:
Originally Posted by wello007 View Post
did it but still getting nothing

Code:
	var nack_resp_mess = new XML(SerializerFactory.getHL7Serializer().toXML(hl7Response));
	logger.error("ack au format XML="+nack_resp_mess);
	logger.error("erreur="+nack_resp_mess['MSA']['MSA.1']['MSA.3.1']);
That should be "nack_resp_mess['MSA']['MSA.3']['MSA.3.1']" instead of "nack_resp_mess['MSA']['MSA.1']['MSA.3.1']".
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

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
  #7  
Old 08-06-2012, 11:32 PM
wello007 wello007 is offline
OBX.3 Kenobi
 
Join Date: Dec 2007
Posts: 160
wello007 is an unknown quantity at this point
Default

oups, shame on me. Thanks guys!
Reply With Quote
Reply

Tags
custom ack, postprocessor

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 04:31 AM.


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