web stats
processing multiple OBR message segments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Development

Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2006, 10:56 PM
mnowlin mnowlin is offline
OBX.3 Kenobi
 
Join Date: Sep 2006
Posts: 142
mnowlin is an unknown quantity at this point
Default processing multiple OBR message segments

Need to get a grasp on how to do this...

I have an incoming chanel that receives laboratory reports - these messages have one or more OBR records. I need to figure out how to count how many OBR (child of ORC) records are in the message, and create a loop that looks at OBR.25 for each one. (OBR.25 indicates "F" for final or "P" for pending for each test.) Need to return a variable that shows if all results are final or not - if any OBR.25 is "P", return "P"; else return "F". This variable will be inserted into a PGSQL DB row to indicate if the entire accession is complete or not.


Here's a sanitized sample:

ORC|RE||A0203809||IP|||||||

OBR|1|A0203809|A0203809|400090^Complete Blood Count|||200609240000|||||||200609240847||deleted^^ ^^MD^^^^^^||||||200609241055|||P

OBX|1|ST|40010^White Blood Count (WBC) (x1000)||PENDING||||||P

OBX|2|ST|40020^Red Blood Count (RBC)||PENDING||||||P

ORC|RE||A0203809||CM|||||||

OBR|2|A0203809|A0203809|650300^Depakene (Valproic Acid)
Level|||200609240000|||||||200609240847||^deleted^ ^^^MD^^^^^^||||||200609241055|||F

OBX|1|NM|65030^Depakene (Valproic Acid) Level||76.8|ug/ml|50-100||||F|||200609241054||


Any suggestions?

thanks - mike
Reply With Quote
  #2  
Old 09-25-2006, 02:42 AM
chrisl chrisl is offline
Mirth Employee
 
Join Date: Aug 2006
Posts: 967
chrisl is an unknown quantity at this point
Default Re: processing multiple OBR message segments

Since the incoming message is encoded as XML, you can use E4X queries and processing. (A good tutorial is here: http://weblog.infoworld.com/udell/2004/09/29.html)

The code below should handle what you want to do
Code:
var testResult = "F";
var count = 0;
//msg..OBR returns every segment that matches OBR
for each (obr in msg..OBR){
	count++;
	if (obr['OBR.25'].text() == 'P'){
		testResult = "P";
	}
}
logger.info('Count is: ' + count); 
//note that the logger might not show in 1.1.0. 
//Use logger.error instead.
logger.info('Result is: ' + testResult);
localMap.put('testResult', testResult);
localMap.put('count', count);
__________________
Chris Lang
Reply With Quote
  #3  
Old 09-25-2006, 02:45 AM
chrisl chrisl is offline
Mirth Employee
 
Join Date: Aug 2006
Posts: 967
chrisl is an unknown quantity at this point
Default Re: processing multiple OBR message segments

Now that you have the testResult in your localMap, you can reference in the db endpoint like this:

INSERT INTO laboratory_reports (test_result) VALUES (${testResult});

${testResult} will automatically be replaced with the value from the localMap.

I tested this with your sample message and it appears to work. Let me know if you have issues!
__________________
Chris Lang
Reply With Quote
  #4  
Old 09-25-2006, 08:21 PM
mnowlin mnowlin is offline
OBX.3 Kenobi
 
Join Date: Sep 2006
Posts: 142
mnowlin is an unknown quantity at this point
Default Re: processing multiple OBR message segments

Looks simple enough... I'll give it a shot and let you know if anything goes boom.

Thanks for the quick reply.

mike
Reply With Quote
  #5  
Old 09-26-2006, 11:38 AM
chrisl chrisl is offline
Mirth Employee
 
Join Date: Aug 2006
Posts: 967
chrisl is an unknown quantity at this point
Default Re: processing multiple OBR message segments

Yes - please let me know if this works. We're doing some work over here with complex E4X and want to verify that the tests work outside of our environment.

-Chris
__________________
Chris Lang
Reply With Quote
  #6  
Old 09-27-2006, 10:35 PM
mnowlin mnowlin is offline
OBX.3 Kenobi
 
Join Date: Sep 2006
Posts: 142
mnowlin is an unknown quantity at this point
Default Re: processing multiple OBR message segments

Have this implemented on a test server - the live system (1.0.3) sends copies of results via LLP to my test server (1.1.0), where I'm using your code sample and dropping the results into postgres.

Sent a few tests through, and it looks like it's working so far. I'll give you an update tomorrow after the busy period winds down.

Mike
Reply With Quote
  #7  
Old 09-27-2006, 10:37 PM
mnowlin mnowlin is offline
OBX.3 Kenobi
 
Join Date: Sep 2006
Posts: 142
mnowlin is an unknown quantity at this point
Default Re: processing multiple OBR message segments

BTW - if this does end up working the way I hope, I'll probably be able to do some serious E4X experimentation. Our clients are constantly asking for custom reports that would require convoluted parsing of the HL7. "Page Dr. Smith if there's a critical CBC", "Only post partial reports that have a protime result available" - that sort of thing.

mike
Reply With Quote
  #8  
Old 09-28-2006, 09:48 PM
mnowlin mnowlin is offline
OBX.3 Kenobi
 
Join Date: Sep 2006
Posts: 142
mnowlin is an unknown quantity at this point
Default Re: processing multiple OBR message segments

Just examined what was stored on my test server and compared against production - everything seems to be working correctly. (Correct number of tests per accession and correct final/partial status for each accession I looked at - about 20 out of 900+).

I'll move the new bits to the production server tomorrow and continue monitoring. If all is well, I'm going to try some craftier E4X things and let you know the results. (And whatever bits of code might seem useful.)

Thanks again for the support (and this really cool piece of software!)

mike
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple XML segments from HL7 dugjohnson Support 1 01-04-2017 05:37 AM
Mapping from FF to Multiple Segments aht75 Support 3 11-26-2008 09:18 AM
Multiple IN1 Segments with Optional IN2 Segments bdilworth Support 4 07-29-2008 10:24 AM
HL7 2.2 - Multiple Message Segments jason.irwin Support 4 02-07-2008 04:32 PM
Modify multiple OBX segments in a message gturrill Support 0 09-27-2007 09:50 PM


All times are GMT -8. The time now is 12:37 AM.


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