web stats
Mirth Community - View Single Post - Extract data from a single OBX segment based on word separators
View Single Post
  #7  
Old 11-08-2013, 07:05 AM
sandersmr sandersmr is offline
OBX.2 Kenobi
 
Join Date: Feb 2013
Posts: 71
sandersmr is on a distinguished road
Default

Do you simply need to have access to the data, and not necessarily parse it out into the HL7 messages? If so, you could probably get away with using an array or a Java ArrayList. Just for each item, add it to the array/arraylist, and after collecting everything, iterate over the array/arraylist.

Code:
var examList = new Packages.java.util.ArrayList();
for each (obx in msg.OBX) {
	var obsVal = new java.lang.String(obx['OBX.5']['OBX.5.1'].toString());
	if (obsVal.startsWith('EXAM:')) {
		for each (exam in obsVal.substring(5).split('and|\\\\T\\\\')) {
			examList.add(exam.trim());
		}
	}
}

for (var i = 0; i < examList.size(); i++) {
	//do something with examList.get(i);
}
Reply With Quote