Announcement

Collapse
No announcement yet.

XSLT Step - Unable to Deploy Channel

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

  • XSLT Step - Unable to Deploy Channel

    Hi,

    I'm having issues creating a channel that uses an XSLT step in the Transformer.

    I'm taking an HL7 v2 message, and transforming the IN1 segments to xml, below is the export of the transform step:

    Code:
    <transformer version="3.0.0">
      <steps>
        <step>
          <sequenceNumber>0</sequenceNumber>
          <name>Build Xml</name>
          <script>tFactory = Packages.javax.xml.transform.TransformerFactory.newInstance();xsltTemplate = new Packages.java.io.StringReader(&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    	&lt;xsl:template match=&quot;/&quot;&gt;
    		&lt;xsl:for-each select=&quot;HL7Message/IN1&quot;&gt;
    			&lt;Insurance&gt;
    			  &lt;PayorID&gt;&lt;xsl:value-of select=&quot;IN1.3/IN1.3.1&quot;/&gt;&lt;/PayorID&gt;
    			  &lt;PayorLevel&gt;&lt;/PayorLevel&gt;
    			  &lt;PlanName&gt;&lt;xsl:value-of select=&quot;IN1.2/IN1.2.1&quot;/&gt;&lt;/PlanName&gt;
    			  &lt;EffectiveDate&gt;&lt;xsl:value-of select=&quot;IN1.12/IN1.12.1&quot;/&gt;&lt;/EffectiveDate&gt;
    			  &lt;ExpirationDate&gt;&lt;xsl:value-of select=&quot;IN1.13/IN1.13.1&quot;/&gt;&lt;/ExpirationDate&gt;
    			  &lt;PolicyNumber&gt;&lt;xsl:value-of select=&quot;IN1.36/IN1.36.1&quot;/&gt;&lt;/PolicyNumber&gt;
    			  &lt;GroupNumber&gt;&lt;xsl:value-of select=&quot;IN1.8/IN1.8.1&quot;/&gt;&lt;/GroupNumber&gt;
    			  &lt;GroupName&gt;&lt;xsl:value-of select=&quot;IN1.9/IN1.9.1&quot;/&gt;&lt;/GroupName&gt;
    			  &lt;IsPolicyHolder&gt;&lt;/IsPolicyHolder&gt;
    			  &lt;Relationship&gt;&lt;xsl:value-of select=&quot;IN1.17/IN1.17.1&quot;/&gt;&lt;/Relationship&gt;
    			  &lt;FirstName&gt;&lt;xsl:value-of select=&quot;IN1.16/IN1.16.2&quot;/&gt;&lt;/FirstName&gt;
    			  &lt;LastName&gt;&lt;xsl:value-of select=&quot;IN1.16/IN1.16.1&quot;/&gt;&lt;/LastName&gt;
    			&lt;/Insurance&gt;
    		&lt;/xsl:for-each&gt;
    	&lt;/xsl:template&gt;
    &lt;/xsl:stylesheet&gt;);transformer = tFactory.newTransformer(new Packages.javax.xml.transform.stream.StreamSource(xsltTemplate));sourceVar = new Packages.java.io.StringReader(msg);resultVar = new Packages.java.io.StringWriter();transformer.transform(new Packages.javax.xml.transform.stream.StreamSource(sourceVar), new Packages.javax.xml.transform.stream.StreamResult(resultVar));channelMap.put(&apos;tmp[&apos;Insurances&apos;]&apos;, resultVar)</script>
          <type>XSLT Step</type>
          <data class="map">
            <entry>
              <string>Source</string>
              <string>msg</string>
            </entry>
            <entry>
              <string>Result</string>
              <string>tmp[&apos;Insurances&apos;]</string>
            </entry>
            <entry>
              <string>XsltTemplate</string>
              <string>&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    	&lt;xsl:template match=&quot;/&quot;&gt;
    		&lt;xsl:for-each select=&quot;HL7Message/IN1&quot;&gt;
    			&lt;Insurance&gt;
    			  &lt;PayorID&gt;&lt;xsl:value-of select=&quot;IN1.3/IN1.3.1&quot;/&gt;&lt;/PayorID&gt;
    			  &lt;PayorLevel&gt;&lt;/PayorLevel&gt;
    			  &lt;PlanName&gt;&lt;xsl:value-of select=&quot;IN1.2/IN1.2.1&quot;/&gt;&lt;/PlanName&gt;
    			  &lt;EffectiveDate&gt;&lt;xsl:value-of select=&quot;IN1.12/IN1.12.1&quot;/&gt;&lt;/EffectiveDate&gt;
    			  &lt;ExpirationDate&gt;&lt;xsl:value-of select=&quot;IN1.13/IN1.13.1&quot;/&gt;&lt;/ExpirationDate&gt;
    			  &lt;PolicyNumber&gt;&lt;xsl:value-of select=&quot;IN1.36/IN1.36.1&quot;/&gt;&lt;/PolicyNumber&gt;
    			  &lt;GroupNumber&gt;&lt;xsl:value-of select=&quot;IN1.8/IN1.8.1&quot;/&gt;&lt;/GroupNumber&gt;
    			  &lt;GroupName&gt;&lt;xsl:value-of select=&quot;IN1.9/IN1.9.1&quot;/&gt;&lt;/GroupName&gt;
    			  &lt;IsPolicyHolder&gt;&lt;/IsPolicyHolder&gt;
    			  &lt;Relationship&gt;&lt;xsl:value-of select=&quot;IN1.17/IN1.17.1&quot;/&gt;&lt;/Relationship&gt;
    			  &lt;FirstName&gt;&lt;xsl:value-of select=&quot;IN1.16/IN1.16.2&quot;/&gt;&lt;/FirstName&gt;
    			  &lt;LastName&gt;&lt;xsl:value-of select=&quot;IN1.16/IN1.16.1&quot;/&gt;&lt;/LastName&gt;
    			&lt;/Insurance&gt;
    		&lt;/xsl:for-each&gt;
    	&lt;/xsl:template&gt;
    &lt;/xsl:stylesheet&gt;</string>
            </entry>
          </data>
        </step>
      </steps>
      <inboundTemplate encoding="base64"></inboundTemplate>
      <outboundTemplate encoding="base64">PFBhdGllbnQ+CjxJbnN1cmFuY2VzPgo8L0luc3VyYW5jZXM+CjwvUGF0aWVudD4=</outboundTemplate>
      <inboundDataType>HL7V2</inboundDataType>
      <outboundDataType>XML</outboundDataType>
      <inboundProperties class="com.mirth.connect.plugins.datatypes.hl7v2.HL7v2DataTypeProperties" version="3.0.0">
        <serializationProperties class="com.mirth.connect.plugins.datatypes.hl7v2.HL7v2SerializationProperties" version="3.0.0">
          <handleRepetitions>true</handleRepetitions>
          <handleSubcomponents>true</handleSubcomponents>
          <useStrictParser>false</useStrictParser>
          <useStrictValidation>false</useStrictValidation>
          <stripNamespaces>true</stripNamespaces>
          <segmentDelimiter>\r</segmentDelimiter>
          <convertLineBreaks>true</convertLineBreaks>
        </serializationProperties>
        <deserializationProperties class="com.mirth.connect.plugins.datatypes.hl7v2.HL7v2DeserializationProperties" version="3.0.0">
          <useStrictParser>false</useStrictParser>
          <useStrictValidation>false</useStrictValidation>
          <segmentDelimiter>\r</segmentDelimiter>
        </deserializationProperties>
        <responseGenerationProperties class="com.mirth.connect.plugins.datatypes.hl7v2.HL7v2ResponseGenerationProperties" version="3.0.0">
          <segmentDelimiter>\r</segmentDelimiter>
          <successfulACKCode>AA</successfulACKCode>
          <successfulACKMessage></successfulACKMessage>
          <errorACKCode>AE</errorACKCode>
          <errorACKMessage>An Error Occured Processing Message.</errorACKMessage>
          <rejectedACKCode>AR</rejectedACKCode>
          <rejectedACKMessage>Message Rejected.</rejectedACKMessage>
          <msh15ACKAccept>false</msh15ACKAccept>
        </responseGenerationProperties>
        <responseValidationProperties class="com.mirth.connect.plugins.datatypes.hl7v2.HL7v2ResponseValidationProperties" version="3.0.0">
          <successfulACKCode>AA</successfulACKCode>
          <errorACKCode>AE</errorACKCode>
          <rejectedACKCode>AR</rejectedACKCode>
        </responseValidationProperties>
      </inboundProperties>
      <outboundProperties class="com.mirth.connect.plugins.datatypes.xml.XMLDataTypeProperties" version="3.0.0">
        <serializationProperties class="com.mirth.connect.plugins.datatypes.xml.XMLSerializationProperties" version="3.0.0">
          <stripNamespaces>true</stripNamespaces>
        </serializationProperties>
      </outboundProperties>
    </transformer>
    When I attempt to deploy this channel, It throws the below error (I'm using 3.0.0.6824)

    Code:
    9: </xsl:stylesheet>);transformer = tFactory.newTransformer(new Packages.javax.xml.transform.stream.StreamSource(xsltTemplate));sourceVar = new Packages.java.io.StringReader(msg);resultVar = new Packages.java.io.StringWriter();transformer.transform(new Packages.javax.xml.transform.stream.StreamSource(sourceVar), new Packages.javax.xml.transform.stream.StreamResult(resultVar));channelMap.put('tmp['Insurances']', resultVar)
    40: if ('xml' === typeof msg && msg.hasSimpleContent()) { msg = msg.toXMLString(); }if ('xml' === typeof tmp && tmp.hasSimpleContent()) { tmp = tmp.toXMLString(); }
    41: }
    42: if (doFilter() == true) { doTransform(); return true; } else { return false; } 
    43: }
    LINE NUMBER:
    	39
    LINE SOURCE:
    	</xsl:stylesheet>);transformer = tFactory.newTransformer(new Packages.javax.xml.transform.stream.StreamSource(xsltTemplate));sourceVar = new Packages.java.io.StringReader(msg);resultVar = new Packages.java.io.StringWriter();transformer.transform(new Packages.javax.xml.transform.stream.StreamSource(sourceVar), new Packages.javax.xml.transform.stream.StreamResult(resultVar));channelMap.put('tmp['Insurances']', resultVar)
    DETAILS:
    	missing ) after argument list
    
    
    	at com.mirth.connect.server.util.javascript.JavaScriptUtil.compileAndAddScript(JavaScriptUtil.java:585)
    
    	at com.mirth.connect.server.transformers.JavaScriptFilterTransformer.initialize(JavaScriptFilterTransformer.java:67)
    ...
    Is there something I am doing wrong?

    Thanks

  • #2
    Ok, so I got it working again - to a limited degree. Instead of having the result go to tmp['Insurances'], I had it go to a new variable (xmlOutput), and then added another step to map that variable to the location in my output message (Insurances).

    Now, it deploys and "works" - just not the way I want it to. It's doing two things that are undesired:

    - First, it's encoding the generated xml so that the <> signs are &gt; &lt;
    - Second, it's adding <?xml version="1.0" encoding="UTF-8"?> to the top of the variable.

    For information, I am creating an xml document containing all my information, and was intending to use the xslt step to build the Insurance portion of that Xml Document. The idea is that there is an "Insurances" node in the xml document, and I am generating the xml for each insurance and adding the entire collection under the Insurances node itself.

    Is there something I can do to fix the two issues above?

    Comment


    • #3
      Can you post the entire channel, and a sample inbound message?

      EDIT: Okay I think I see your issue. The XSLT Step requires a variable name for the result, because it places that result in the channel map. So what you want to do is create a subsequent step to pull it back out of the channel map and place it in tmp:

      Code:
      tmp.Insurances.appendChild(new XML($c('insurances')));
      Attached Files
      Last edited by narupley; 09-09-2013, 08:19 AM.
      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


      • #4
        Thanks Narupley, I'd arrived at around the same conclusion as you yesterday, although I was using

        Code:
        tmp['Insurances'] = new XML($('insuranceXml'));
        I think yours is neater (mine is replacing the entire insurances node), so I'll amend to yours.

        Thanks
        Fergal

        Comment

        Working...
        X