Announcement

Collapse
No announcement yet.

OBX Segment parsing

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

  • OBX Segment parsing

    I have these OBX Segements and I'm using Mirth 3.5.1

    OBX|1|ST|||John Doe was admitted to Hospital , Event Type: In-Patient
    OBX|2|ST|||Company Name^
    OBX|3|CE|R52^Pain, unspecified^I10||diagnosis^R52^Stuff in here^I10^^F
    OBX|4|CE|S90.811A^Abrasion, right foot, initial encounter^I10||diagnosis^S90.811^Stuff in Here^I10^^F

    And I have run this code but for some reason it doesn't run the if statement when it equals CE can someone see what I'm doing wrong here in this javascript transformer step?

    var obxText = '';

    try{
    for each (seg in msg.children()) {
    if (seg.name().toString() == "OBX") {
    if(msg['OBX']['OBX.2']['OBX.2.1'].toString() == 'CE'){
    logger.info('CE');
    obxText = obxText + 'Diagnosis Code: ' + msg['OBX']['OBX.3']['OBX.3.1'].toString() + 'Diagnosis: ' + msg['OBX']['OBX.3']['OBX.3.2'].toString();

    }
    else{
    obxText = obxText + seg['OBX.5']['OBX.5.1'].toString();
    }

    }
    }
    }
    catch(e){
    logger.error(e);
    }

    globalChannelMap.put('OBXValues', obxText);

  • #2
    msg['OBX'] will give you the list of msg.children() where name == 'OBX'. You have to make sure you're using your loop variable consistently. You did it correctly in the else clause.

    Also, not sure what your purpose is for storing the value in the globalChannelMap, but that is not thread safe, won't survive a server reboot, and won't be visible in the message viewer. If you're just keeping it to use later in the same message (e.g. in another transformer step, your destination connector properties, another destination, or the post-processor,) use the channelMap instead.

    Code:
    var obxText = '';
    
    try{
    	for each (seg in msg['OBX']) {
    		if(seg['OBX.2']['OBX.2.1'].toString() == 'CE'){
    			logger.info('CE');
    			obxText = obxText + 'Diagnosis Code: ' + seg['OBX.3']['OBX.3.1'].toString() + 'Diagnosis: ' + seg['OBX.3']['OBX.3.2'].toString();
    		}
    		else{
    			obxText = obxText + seg['OBX.5']['OBX.5.1'].toString();
    		}
    	}
    }
    catch(e){
    	logger.error(e);
    }
    
    globalChannelMap.put('OBXValues', obxText);
    Last edited by agermano; 03-16-2018, 09:22 AM. Reason: fix typo

    Comment


    • #3
      Thank you this worked great the only comment is that there is no period msg.['OBX']) it should be just msg['OBX'])

      Comment


      • #4
        Originally posted by tkurian View Post
        Thank you this worked great the only comment is that there is no period msg.['OBX']) it should be just msg['OBX'])
        Oops I fixed it. I had it right in the comment, just not in the code.

        Comment

        Working...
        X