web stats
How to loop content with Component Seperators - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2020, 01:09 AM
itsaboutcode itsaboutcode is offline
What's HL7?
 
Join Date: Mar 2020
Posts: 1
itsaboutcode is on a distinguished road
Default How to loop content with Component Seperators

Code:
NTE|1|L|VERIFIED BY MICROSCOPIC EXAMINATION
NTE|1|L|H & H CHECK FAILED.SPECIMEN HAS BEEN PRE-WARMED.POSSIBLE COLD AGGLUTININ OR OTHER INTERFERING SUBSTANCES.
I got the above message today. One NTE have content with component seperator &.

Question is how I can know if one have it and other don't

Currently I am doing it like below and I did not like the way I did it.


Code:
if (val = NNil(params['NTE.3']['NTE.3.1']['NTE.3.1.1'])) {
	
  if (val = NNil(params['NTE.3']['NTE.3.1']['NTE.3.1.1'])) {
    NTE['Note'] = val;
  }

  if (val = NNil(params['NTE.3']['NTE.3.1']['NTE.3.1.2'])) {
	NTE['SubNote'] = val;
  }
				
} else {
  if (val = NNil(params['NTE.3']['NTE.3.1'])) {
	NTE['Note'] = val;
  }
}
Reply With Quote
  #2  
Old 04-03-2020, 01:32 PM
jkrebs jkrebs is offline
What's HL7?
 
Join Date: Feb 2015
Posts: 1
jkrebs is on a distinguished road
Default How to Loop with Component Separators

Quote:
Question is how I can know if one have it and other don't
Below traverses NTEs and does something with val based on the existence of comp and/or subcomp.

Code:
var val = '';

for (var i = 0;i < msg..NTE.length(); i++) {

    if (msg.NTE[i]['NTE.3']['NTE.3.1']['NTE.3.1.2'].toString().length != 0) {
        val = msg.NTE[i]['NTE.3']['NTE.3.1']['NTE.3.1.2'].toString()	
        logger.info(val)

    }  else {
            val = msg.NTE[i]['NTE.3']['NTE.3.1'].toString()
            logger.info(val)
    }

}
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


All times are GMT -8. The time now is 11:14 PM.


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