Announcement

Collapse
No announcement yet.

Parse a string

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

  • Parse a string

    I want to know if there is a way in a transformer to take a SSN that is being send in ###-##-#### this format to this format #########?

    Thanks

  • #2
    Re: Parse a string

    You hava all JavaScript power.

    You can use the split function:

    EJ:
    var strOriginal="###-##-####";
    var splitArray=strOriginal.split("-");
    var strFinal=''+splitArray[0]+splitArray[1]+splitArray[2];

    Or you can use the replace method for string

    var strOriginal="###-##-####";
    var regEx = new RegExp ('-', 'gi&#039 ;
    var strFinal=strOriginal.replace( regEx, ''


    Comment


    • #3
      Re: Parse a string

      I can do that in Destinations/Edit Transformer/ in the mapping box? Is that the correct place? Sorry new to this...

      Comment


      • #4
        Re: Parse a string

        Transformer / JavaScript step:

        var originalSSN = msg['PID']['PID.19'].text()[0].toString();
        var modifiedSSN = originalSSN.replace(/-/g, "");
        localMap.put('patSSN', modifiedSSN);


        Comment


        • #5
          Re: Parse a string

          I get a syntax error when I try that here is my exported transformer...

          <com.webreach.mirth.model.Transformer>
          <steps>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>0</sequenceNumber>
          <name>Identifier</name>
          <script>localMap.put(&apos;Identifier&apos;, var originalSSN = msg[&apos;PID&apos;][&apos;PID.19&apos;].text()[0].toString();
          var modifiedSSN = originalSSN.replace(/-/g, &quot;&quot;
          localMap.put(&apos;patSSN&apos;, modifiedSSN);</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>var originalSSN = msg[&apos;PID&apos;][&apos;PID.19&apos;].text()[0].toString();
          var modifiedSSN = originalSSN.replace(/-/g, &quot;&quot;
          localMap.put(&apos;patSSN&apos;, modifiedSSN);</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>Identifier</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>1</sequenceNumber>
          <name>FirstName</name>
          <script>localMap.put(&apos;FirstName&apos;, msg[&apos;PID&apos;][&apos;PID.5&apos;][&apos;XPN.2&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.5&apos;][&apos;XPN.2&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>FirstName</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>2</sequenceNumber>
          <name>MiddleName</name>
          <script>localMap.put(&apos;MiddleName&apos;, msg[&apos;PID&apos;][&apos;PID.5&apos;][&apos;XPN.3&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.5&apos;][&apos;XPN.3&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>MiddleName</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>3</sequenceNumber>
          <name>LastName</name>
          <script>localMap.put(&apos;LastName&apos;, msg[&apos;PID&apos;][&apos;PID.5&apos;][&apos;XPN.1&apos;][&apos;FN.1&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.5&apos;][&apos;XPN.1&apos;][&apos;FN.1&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>LastName</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>4</sequenceNumber>
          <name>Address1</name>
          <script>localMap.put(&apos;Address1&apos;, msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.1&apos;][&apos;SAD.1&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.1&apos;][&apos;SAD.1&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>Address1</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>5</sequenceNumber>
          <name>City</name>
          <script>localMap.put(&apos;City&apos;, msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.3&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.3&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>City</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>6</sequenceNumber>
          <name>PostalCode</name>
          <script>localMap.put(&apos;PostalCode&apos;, msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.5&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.5&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>PostalCode</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>7</sequenceNumber>
          <name>PhoneNumber</name>
          <script>localMap.put(&apos;PhoneNumber&apos;, msg[&apos;PID&apos;][&apos;PID.13&apos;][&apos;XTN.1&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.13&apos;][&apos;XTN.1&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>PhoneNumber</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>8</sequenceNumber>
          <name>StateCd</name>
          <script>localMap.put(&apos;StateCd&apos;, msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.4&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.4&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>StateCd</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>9</sequenceNumber>
          <name>Sex</name>
          <script>localMap.put(&apos;Sex&apos;, msg[&apos;PID&apos;][&apos;PID.8&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.8&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>Sex</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>10</sequenceNumber>
          <name>Ethnic</name>
          <script>localMap.put(&apos;Ethnic&apos;, msg[&apos;PID&apos;][&apos;PID.10&apos;][&apos;CE.1&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.10&apos;][&apos;CE.1&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>Ethnic</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>11</sequenceNumber>
          <name>Address2</name>
          <script>localMap.put(&apos;Address2&apos;, msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.2&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.11&apos;][&apos;XAD.2&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>Address2</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          <com.webreach.mirth.model.Step>
          <sequenceNumber>12</sequenceNumber>
          <name>MaritalStatus</name>
          <script>localMap.put(&apos;MaritalStatus&apos;, msg[&apos;PID&apos;][&apos;PID.16&apos;][&apos;CE.1&apos;].toString());</script>
          <type>Mapper</type>
          <data class="map">
          <entry>
          <string>Mapping</string>
          <string>msg[&apos;PID&apos;][&apos;PID.16&apos;][&apos;CE.1&apos;]</string>
          </entry>
          <entry>
          <string>Variable</string>
          <string>MaritalStatus</string>
          </entry>
          <entry>
          <string>isGlobal</string>
          <string>0</string>
          </entry>
          </data>
          </com.webreach.mirth.model.Step>
          </steps>
          <template>MSH|^~\&amp;|Encore Clinical|HomeHealth|REMOTE|REMOTE|20061127105209|| ADT^A08|HomeHealth000000002020061127105209|P|2.4|| |AL|||&#x0D;EVN|A08|20061127105210.0130|&#x0D;PID| 1|67001408^^^HOSP^EK|2000^^^HOSP^MR||Bartlyn^Shery l^J||19340714000000.0000|F||AA|2530 Sandpiper way^XXX^Altoona^PA^16601||(705)555-4367|||M|||001-00-7291|&#x0D;NK1|1|Smith^Ann|C^Daughter||(705)555-0000||&#x0D;PV1|1|R|||||9001^Quarles^Kambe Leon^|9001^Quarles^Kambe Leon^||||||||||||||||||||||||||||||||||||200601030 00000.0000||||||2000^^^HOSP^EP|&#x0D;DG1|1|ICD9|17 27|Malig melanoma leg|20051227000000.0000|&#x0D;DG1|2|ICD9|4281|Left heart failure|20060101000000.0000|&#x0D;IN1|1|||Medicare Hospice|123 Pansey LAne^^Holldaysburg^PA^16648|^^||||||20060103|&#x0D ;ZOR|1|24680|Amiodarone HCl TABS|20050101|200 mg every pm PO||&#x0D;ZOR|2|11843|Lasix TABS|20060101|180 mg bid PO||&#x0D;ZOR|3|11261|K-Dur TBCR|20060101|80 meq q am PO||&#x0D;ZOR|4|70227|Zithromax Z-Pak TABS|20051228|1 tab every am PO|20060106|&#x0D;ZOR|5|6648|Dilaudid TABS|20060101|2 mg 4hr prn PO|| &#x0D;</template>
          </com.webreach.mirth.model.Transformer>

          Comment


          • #6
            Re: Parse a string

            Nevermind I did not realize that you could change the step type from mapper to javascript.....

            Sorry....

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎