Announcement

Collapse
No announcement yet.

Custom ACK in the postprocessor script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?
    WD

  • #2
    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.

    Comment


    • #3
      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']);
      WD

      Comment


      • #4
        Can you post your logger results?

        Comment


        • #5
          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=
          WD

          Comment


          • #6
            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.

            Comment


            • #7
              oups, shame on me. Thanks guys!
              WD

              Comment

              Working...
              X