Announcement

Collapse
No announcement yet.

RTF into ORU

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

  • RTF into ORU

    Hi All,

    I'm having some trouble trying to turn an RTF into a plain text message. I've got a javascript step that reads the file and turns it into a variable. Then in my template, I have:

    foo
    ${contents2}
    bar

    I'm new at this and it is probably something simple.

    NOTE: If I remove my transformer steps and use ${message.rawData} as the template, then the channel doesnt error out (but it doesnt make a change to the RTF).

    Any help would be appreciated. Thank you.

    I get the error:

    [2008-06-27 09:11:32,677] ERROR(org.mule.impl.DefaultComponentExceptionStrat egy:95): Caught exception in Exception Strategy for: 59206275-d023-4f0f-86a9-db3f64315142: org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.webreach.mirth.model.MessageObject
    org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.webreach.mirth.model.MessageObject



    Here is my channel:

    <com.webreach.mirth.model.Channel>
    <id>59206275-d023-4f0f-86a9-db3f64315142</id>
    <name>RTF to ORU</name>
    <description></description>
    <enabled>true</enabled>
    <version>1.7.1.3422</version>
    <lastModified>
    <time>1214572225864</time>
    <timezone>America/New_York</timezone>
    </lastModified>
    <revision>41</revision>
    <sourceConnector>
    <name>sourceConnector</name>
    <properties>
    <property name="sortAttribute">date</property>
    <property name="pollingType">interval</property>
    <property name="pollingFrequency">1000</property>
    <property name="binary">0</property>
    <property name="processBatchFiles">0</property>
    <property name="DataType">File Reader</property>
    <property name="moveToErrorDirectory">C:/Documents and Settings/Administrator/Desktop/Mirth/RTF ERROR</property>
    <property name="fileAge">0</property>
    <property name="moveToPattern">${SYSTIME} - ${ORIGINALNAME}</property>
    <property name="charsetEncoding">DEFAULT_ENCODING</property>
    <property name="checkFileAge">0</property>
    <property name="autoDelete">0</property>
    <property name="host">C:/Documents and Settings/Administrator/Desktop/Mirth/RTF IN</property>
    <property name="fileFilter">*.rtf</property>
    <property name="moveToDirectory">C:/Documents and Settings/Administrator/Desktop/Mirth/RTF OUT</property>
    </properties>
    <transformer>
    <steps/>
    <inboundTemplate></inboundTemplate>
    <outboundTemplate></outboundTemplate>
    <inboundProtocol>HL7V2</inboundProtocol>
    <outboundProtocol>HL7V2</outboundProtocol>
    <inboundProperties/>
    <outboundProperties/>
    </transformer>
    <filter>
    <rules/>
    </filter>
    <transportName>File Reader</transportName>
    <mode>SOURCE</mode>
    <enabled>true</enabled>
    </sourceConnector>
    <destinationConnectors>
    <com.webreach.mirth.model.Connector>
    <name>Destination 1</name>
    <properties>
    <property name="charsetEncoding">DEFAULT_ENCODING</property>
    <property name="outputAppend">0</property>
    <property name="DataType">File Writer</property>
    <property name="outputPattern">${ORIGINALNAME}</property>
    <property name="template">foo
    ${contents2}
    bar</property>
    <property name="host">C:/Documents and Settings/Administrator/Desktop/Mirth/ORU</property>
    <property name="binary">0</property>
    </properties>
    <transformer>
    <steps>
    <com.webreach.mirth.model.Step>
    <sequenceNumber>0</sequenceNumber>
    <name>New Step</name>
    <script>var contents = FileUtil.read(&apos;messageObject.getRawData()&apo s;
    //contents = contents & "hi";</script>
    <type>JavaScript</type>
    <data class="map">
    <entry>
    <string>Script</string>
    <string>var contents = FileUtil.read(&apos;messageObject.getRawData()&apo s;
    //contents = contents & "hi";</string>
    </entry>
    </data>
    </com.webreach.mirth.model.Step>
    <com.webreach.mirth.model.Step>
    <sequenceNumber>1</sequenceNumber>
    <name>contents2</name>
    <script>var mapping;try { mapping = contents; }catch (e) { logger.error(e); mapping = &apos;&apos;;}connectorMap.put(&apos;contents2&apo s;, validate( mapping , &apos;&apos;, new Array()));</script>
    <type>Mapper</type>
    <data class="map">
    <entry>
    <string>Variable</string>
    <string>contents2</string>
    </entry>
    <entry>
    <string>DefaultValue</string>
    <string></string>
    </entry>
    <entry>
    <string>Mapping</string>
    <string>contents</string>
    </entry>
    <entry>
    <string>RegularExpressions</string>
    <list/>
    </entry>
    <entry>
    <string>isGlobal</string>
    <string>connector</string>
    </entry>
    </data>
    </com.webreach.mirth.model.Step>
    </steps>
    <inboundTemplate></inboundTemplate>
    <outboundTemplate></outboundTemplate>
    <inboundProtocol>HL7V2</inboundProtocol>
    <outboundProtocol>HL7V2</outboundProtocol>
    <inboundProperties/>
    <outboundProperties>
    <property name="handleRepetitions">false</property>
    <property name="convertLFtoCR">true</property>
    <property name="useStrictValidation">false</property>
    <property name="useStrictParser">false</property>
    </outboundProperties>
    </transformer>
    <filter>
    <rules/>
    </filter>
    <transportName>File Writer</transportName>
    <mode>DESTINATION</mode>
    <enabled>true</enabled>
    </com.webreach.mirth.model.Connector>
    </destinationConnectors>
    <properties>
    <property name="synchronous">true</property>
    <property name="removeNamespace">true</property>
    <property name="transactional">false</property>
    <property name="initialState">started</property>
    <property name="dont_store_filtered">false</property>
    <property name="error_messages_only">false</property>
    <property name="max_message_age">-1</property>
    <property name="store_messages">true</property>
    <property name="encryptData">false</property>
    </properties>
    <preprocessingScript>// Modify the message variable below to pre process data
    return message;</preprocessingScript>
    <postprocessingScript>// This script executes once after a message has been processed
    return;</postprocessingScript>
    <deployScript>// This script executes once when the mule engine is started
    // You only have access to the globalMap here to persist data
    return;</deployScript>
    <shutdownScript>// This script executes once when the mule engine is stopped
    // You only have access to the globalMap here to persist data
    return;</shutdownScript>
    </com.webreach.mirth.model.Channel>

    Post edited by: JasonGriffith, at: 06/27/2008 07:18

  • #2
    Re:RTF into ORU

    Here is what I found on how to read an RTF into a file. This is probably pretty easy for most people, but I thought I would throw this out anyways.

    I wasn't able to read the RTF in with a file reader. I believe this has to do with the summary tab on the channel reader. It defines the type of incoming data and none of the items in the drop down menu matched with the RTF.

    That turned out to be OK, for me, because I get a .XML at the same time with the .RTF. I need to use the .XML anyways, so this really got me on the right track.

    So my channel reader 'summary tab' 'incoming data' is XML. 'source tab' 'filename pattern' is *.xml

    'Destination tab' 'template' is ${FileContents}

    add a transformer step and change the type to JavaScript:

    Code:
    //get .xml original file name
    var FileNameA = channelMap.get('originalFilename');
    //remove the .xml extension from original file name
    var FileNameB = FileNameA.substring(0,FileNameA.length()-4);
    //read contents of RTF into variable 
    var RTFcontents = FileUtil.read('C:/Documents and Settings/Administrator/Desktop/Mirth/RTF IN/' + FileNameB + '.RTF');
    var contents = RTFcontents
    At this point you can add more text before and after the RTF text if you are trying to create an ORU message. Just replace the last line.

    Code:
    var contents = stuffA + RTFcontents + stuffB
    Add another step, variable named RTFtext and is type 'mapper' and set 'add to' to 'connector map'
    Set mapping to: $c('FileContents', contents);

    Then save and deploy.

    Comment

    Working...
    X