Announcement

Collapse
No announcement yet.

Translating escape sequences

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

  • Translating escape sequences

    Has anyone got some code they can share to translate all the \.sk[N]\ escape sequences into spaces?

    Code:
    OBX|1|TX||17|\.sk+1\\.sk+1\astraia\.sk+1\\.sk+1\software for women's health\.sk+1\\.sk+1\obstetric and gynaecological database application\.sk+1\astraia software gmbh\.sk+1\\.sk+1\\.sk+49\\.sk+1\\.br\\.sk+1\\.sk+1\\.sk+49\\.sk+1\Occamstr. 20\.sk+1\\.sk+1\\.sk+49\\.sk+1\80802 Munich\.sk+1\\.sk+1\\.sk+49\\.sk+1\Germany\.sk+1\\.sk+1\\.sk+49\\.sk+1\\.br\\.sk+1\\.sk+1\\.sk+49\\.sk+1\Tel   +49 (0)89 1271147-0\.sk+1\\.sk+1\\.sk+49\\.sk+1\Fax  +49 (0)89 1271147-17\.sk+1\\.sk+1\\.sk+49\\.sk+1\Email: [email protected]\.sk+1\\.sk+1\\.sk+49\\.sk+1\Web:   www.astraia.com\.br\\.br\Patient Data\.br\--------------------\.br\\.sk+4\\.sk+4\Other \.sk+4\\.sk+4\Date of birth\.sk+1\13/05/\.sk+4\\.sk+4\\.sk+4\\.sk+4\1 Albert \.sk+4\\.sk+4\\.sk+4\\.sk+4\EC1 \.sk+4\Ethnic \.sk+4\white (European, Middle Eastern, North African, Hispanic)\.sk+56\\.br\\.sk+13\\.sk+1\White and Black \.sk+4\Hospital no. \.sk+1\\.sk+4\\.sk+4\Dr. A Patel , Royal Docks Medical Practice, Royal Docks Medical Ctre, 21 East Ham Manor Way, Beckton020 \.sk+4\\.br\Present Pregnancy\.br\--------------------\.br\\.sk+4\last period: 01/06/2014\.br\EDD by dates\.sk+1\08/03/\.sk+4\\.br\Examination\.br\--------------------\.br\Date\.sk+1\21/07/2014\.br\Time\.sk+1\10:\.sk+4\\.br\Ultrasound\.br\--------------------\.br\Operator\.sk+1\Dr. Test\.br\\.br\||||||A|||20140724143345

  • #2
    This is based off of my replaceAllInXML function:

    Code:
    function replaceEscapedSpaces(parent) {
    	for each (child in parent.children()) {
    		if (child.hasComplexContent()) {
    			replaceEscapedSpaces(child);
    		} else {
    			var value = child.toString();
    			for each (match in value.match(/\\\.sk\+\d+\\/g)) {
    				value = value.replace(match, org.apache.commons.lang3.StringUtils.repeat(' ', parseInt(match.replace(/[^\d]/g,''),10)));
    			}
    			parent.children()[child.childIndex()] = value.replace(/\\\.br\\/g,'\n');
    		}
    	}
    }
    You can use it on the entire message if there are multiple places it could happen:

    Code:
    replaceEscapedSpaces(msg);
    Or you could do it only on the OBXs:

    Code:
    replaceEscapedSpaces(msg.OBX);
    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


    • #3
      Wow Nick, I'm so very grateful as have been struggling with this. I was trying to get the number of spaces using capturing groups, and never thought about parseInt

      Comment

      Working...
      X