web stats
Parse a string - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2006, 05:28 AM
bobbie bobbie is offline
OBX.1 Kenobi
 
Join Date: Nov 2006
Posts: 47
bobbie
Default 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
Reply With Quote
  #2  
Old 12-08-2006, 06:10 AM
albertosaez albertosaez is offline
 
Join Date: Sep 2006
Location: Valladolid, Spain
Posts: 842
albertosaez is an unknown quantity at this point
Default 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') ;
var strFinal=strOriginal.replace( regEx, '');


Reply With Quote
  #3  
Old 12-08-2006, 06:15 AM
bobbie bobbie is offline
OBX.1 Kenobi
 
Join Date: Nov 2006
Posts: 47
bobbie
Default 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...
Reply With Quote
  #4  
Old 12-08-2006, 06:24 AM
nshaik nshaik is offline
Mirth Guru
 
Join Date: Sep 2006
Posts: 302
nshaik
Default 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);

http://www.mirthproject.org/index.ph...d=22&Itemid=63
Reply With Quote
  #5  
Old 12-08-2006, 06:52 AM
bobbie bobbie is offline
OBX.1 Kenobi
 
Join Date: Nov 2006
Posts: 47
bobbie
Default 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>
Reply With Quote
  #6  
Old 12-08-2006, 06:59 AM
bobbie bobbie is offline
OBX.1 Kenobi
 
Join Date: Nov 2006
Posts: 47
bobbie
Default Re: Parse a string

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

Sorry....
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
SOAP connector - cant't parse the WSDL quimicefa Support 1 04-24-2008 07:26 AM
Failed to parse conf ... mule-config.xml nate.teller Support 1 01-16-2008 04:28 AM
Can't parse message beginning nshaik Support 4 07-30-2007 12:43 PM
string replacement oakwood Support 3 04-20-2007 12:51 PM
Failed to parse tintinn Support 3 09-21-2006 11:20 PM


All times are GMT -8. The time now is 03:25 PM.


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