web stats
Extract data from a single OBX segment based on word separators - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-29-2013, 12:56 PM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 31
Jaypell22 is on a distinguished road
Default Extract data from a single OBX segment based on word separators

I am trying to figure out how to extract exam descriptions from an ORU message that will sometimes be separated by "and" or "\T\". The field will not always be on the same OBX line however will always follow "EXAM:" in OBX.5.1. There can be as many as 3 exam descriptions. I need to insert them into a MySQL database after separated. If it's easy to move them each into separate OBR fields I can then easily move them to the MySQL database.

Any assistance would be greatly appreciated.

For the examples below I am looking to get 3 separate entries
CT abdomen without contrast
CT pelvis without contrast
CT chest without contrast

Examples:


OBX|7|ST|||EXAM: CT abdomen without contrast and CT pelvis without contrast and CT chest without contrast||||||P||||||
OBX|8|ST|||||||||P||||||

OBX|7|ST|||EXAM: CT abdomen without contrast \T\ and CT pelvis without contrast \T\ CT Chest without contrast||||||P||||||
OBX|8|ST|||||||||P||||||
Reply With Quote
  #2  
Old 10-29-2013, 02:03 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,099
narupley is on a distinguished road
Default

You can do this:

Code:
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\\\\')) {
			// Do something with exam.trim()
		}
	}
}
__________________
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.
Reply With Quote
  #3  
Old 11-07-2013, 06:50 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 31
Jaypell22 is on a distinguished road
Default

Thanks for that info! I am trying to figure out how to separate those 2 or 3 results from the split into separate OBR fields. I was looking to use some random OBR fields to throw them into then I can pull them into the DB. Thoughts anyone?
Thanks!
Reply With Quote
  #4  
Old 11-07-2013, 06:54 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,099
narupley is on a distinguished road
Default

Quote:
Originally Posted by Jaypell22 View Post
Thanks for that info! I am trying to figure out how to separate those 2 or 3 results from the split into separate OBR fields. I was looking to use some random OBR fields to throw them into then I can pull them into the DB. Thoughts anyone?
Thanks!
One common thing to do there is to convert each "line" into a discrete NTE segment in the observation group. So this:

Code:
OBX|7|ST|||EXAM: CT abdomen without contrast \T\ and CT pelvis without contrast \T\ CT Chest without contrast||||||P||||||
Would become this:

Code:
OBX|7|ST|||SEE NOTE||||||P||||||
NTE|1|ST|CT abdomen without contrast
NTE|2|ST|CT pelvis without contrast
NTE|3|ST|CT Chest without contrast
__________________
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.
Reply With Quote
  #5  
Old 11-08-2013, 06:47 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 31
Jaypell22 is on a distinguished road
Default

Thanks for the reply Nick.

Is there a way to bypass adding the split descriptions into NTE lines since I am going to be inserting them into a MySQL DB or is that a necessity? I wonder if there is a more direct way. If there was just one result I would not have a problem with the code but since there is 2 or 3 I don't quite see how to separate them out even If i wanted to put them into NTE lines. I have been digging around in the forums and this seems somewhat unique, or I am not looking in the right places.

Thanks for your help as always.

Jay
Reply With Quote
  #6  
Old 11-08-2013, 06:53 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,099
narupley is on a distinguished road
Default

Quote:
Originally Posted by Jaypell22 View Post
Thanks for the reply Nick.

Is there a way to bypass adding the split descriptions into NTE lines since I am going to be inserting them into a MySQL DB or is that a necessity? I wonder if there is a more direct way. If there was just one result I would not have a problem with the code but since there is 2 or 3 I don't quite see how to separate them out even If i wanted to put them into NTE lines. I have been digging around in the forums and this seems somewhat unique, or I am not looking in the right places.

Thanks for your help as always.

Jay
I'm not understanding the question... can you rephrase that with some clear examples?
__________________
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.
Reply With Quote
  #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
  #8  
Old 11-08-2013, 08:17 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 31
Jaypell22 is on a distinguished road
Default

Thanks Sandersmr, I will give that a shot as I don't need the info in the actual HL7 message however I am used to pulling info from HL7 messages to put into my DB.

Nick, Sorry for the confusion.

If I stick with the idea of putting everything into new NTE lines as you recommended I don't know how to do that when it comes to the code. I guess that is the short of it. If it were one item I can code it.

Specifically I need to be able to separate each of the below "split" 3 pieces of data into separate MySQL columns. I am looking for the easiest way to do so and possibly bypass having to put it into NTE lines.

CT abdomen without contrast
CT pelvis without contrast
CT Chest without contrast

Hope that didn't make it muddier.
Reply With Quote
  #9  
Old 11-08-2013, 08:27 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,099
narupley is on a distinguished road
Default

In each of these code examples posted here so far, there's a section of the code where we direct you to "do something with" the specific exam. That's where you need to inject your own code to perform a database update. There are templates in the References tab which will help to get connected to a database and execute a statement.
__________________
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.
Reply With Quote
  #10  
Old 11-20-2013, 07:12 AM
aquillen aquillen is offline
OBX.1 Kenobi
 
Join Date: Dec 2010
Posts: 30
aquillen is on a distinguished road
Default

narupley - I sent J off line help on manipulating the results. Your code example above does work of course.
Question

if (obsVal.startsWith('EXAM:'))

startsWith ... is this prototyped into javascript as part of the Mirth build or part of current javascript release? Looking on WEB at W3Schools for example it doesn't come up in the standard section on javascript string functions.

Where in Mirth info can I find this and all the rest of implemented/available language constructs & syntax that are at our fingertips with just a bit of reading?

Thank you!
Reply With Quote
Reply

Tags
extract, obx, segment, separate

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 06:39 AM.


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