web stats
Group Multiple ORU Messages - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-03-2010, 08:42 PM
jmendezzz jmendezzz is offline
OBX.2 Kenobi
 
Join Date: Nov 2009
Posts: 85
jmendezzz is on a distinguished road
Default Group Multiple ORU Messages

Hi Everyone,

I have a LLP Listener channel(HL7 2.X) that receives multiples ORU messages for the same ORDER #...So say for instance: you have a CHOLESTEROL, GLUCOSE, CBC, for an order.

The channel will receive a message every time one of the three test is completed. At the end, the channel will have 3 messages. What i am trying to do is write a javascript or transformer that will group those three messages into one.

The only thing i need out of the three messages is OBR/OBX. Now I am thinking in order for me to do this i have to set a criteria like if OBR-2(PLACER ID) and also the application sending the message to my LLP Listener has to flag each message stating if order is "COMPLETED" Since I don't use OBR-22(FILLER 2) I am thinking of having flag here. So the logic will go like this:

Last message comes into my LLP Listener:

If OBR-22 == "Completed" then
check for every message in the log that equals to OBR-2
read OBR/OBX
Group all OBR/OBX.
end if

Any help on how I can start or if anyone can point me to the right direction. Please help.

Thanks in advance.

Logic is the opposite of the "Deli-Slicer"
================================
http://www.mirthcorp.com/community/f...ht=deli-slicer
Reply With Quote
  #2  
Old 05-04-2010, 05:51 AM
rts rts is offline
Mirth Guru
 
Join Date: Feb 2008
Posts: 215
rts is an unknown quantity at this point
Default

I'm not sure how you are receiving these. All at once ? or as each test is completed. If you are receiving these as each test is completed then I am assuming that they are received at different times (Typically the case with Lab Results). If that is the case I would manage these in a seperate DB table. Once order/results are completed set an flag on the rows that indicates that all results are complete. Then use a DB reader channel that polls the DB table for "Completed" results.
Reply With Quote
  #3  
Old 05-04-2010, 08:37 AM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

Hello,

How about this suggestion:
You strip off all the segments you don't need
Then you write the remaining segments to a file , using the order id as filename (You can additionally combine the name with patient id, admit number or whatever useful).
As long as you have messages coming for that order, they will concatenate to the same file
__________________
JJ Mouris
FFE Luxembourg
IT-Department
Reply With Quote
  #4  
Old 05-05-2010, 08:23 PM
jmendezzz jmendezzz is offline
OBX.2 Kenobi
 
Join Date: Nov 2009
Posts: 85
jmendezzz is on a distinguished road
Default

First of all, thank you for your reply. I like your idea of striping the segments that i do not need and only add the segments that i will require to a file and continue accumulating. The only issue i am having is that this messages will not come in sequence. I'll explain.

Say you order a CBC and GLUCOSE:
CBC result message gets completed at 12:00pm, message get sent to Mirth LLP Listener. At this moment Mirth will write the message to a file.

GLUCOSE oru message gets completed at 4pm,
message sent to Mirth LLP Listener. I only want to get the OBR/OBX segment. But keep in mind because the message are not in sequence i don't know how to go about writing logic that it will find say the file name that first message was sent to.

can you provide me an example or snippet of how I can create logic in a channel to write the segments that i require from those 2 messages.
Reply With Quote
  #5  
Old 05-06-2010, 06:13 AM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

Hello,

I stunbled into more question about what you are trying to do and the solution I suggested.
- Do you really not need message headers or other segments? If you need them, my solution won't work.
- My solution only works if you want files as an output result
- I don't know if there is a way to flag a message as completed. Perhaps it is possible to rename a file in a postprocessor script once you have received your "completed" flag, but i have never done this before.

For your other questions:
- There is a built-in function in the transformer to delete segments. It's very easy:
Code:
delete msg['MSH'];
and your MSH segment will have gone

- To have all your remaning segments be gathered in one file (on per placer_id or whatever):
* put the placer-id (or other unique ID) in a channel map variable
* use this channel variable as or as part of the filename
* make sure to select the "Append to file" option in the destination.

We use this to gather all the items of a pharmacy order in one delivery report, as the robot delivering the items sends one file per item. This works without problems.

If you need further or more complex processing of your data, I think the database-solution would be the better way, as suggested by rts
__________________
JJ Mouris
FFE Luxembourg
IT-Department

Last edited by mourisj; 05-06-2010 at 06:15 AM.
Reply With Quote
  #6  
Old 05-06-2010, 12:59 PM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

Hello again,

I worked a bit to find a solution for the unanswered question of renaming the file when all data are completed.

You have to define your output-filename in a variable and put it to channelMap during procesing.
You use the channel variable as output filename in your destination.

Also do so for completion flag in your OBR-22.

Then you do the following in postprocessor-script:

Code:
var path = "/path/for/outputfiles/" + channelMap.get('fn') ;
var oldfile = java.io.File(path);
var newpath = "/path/for/outputfiles/completed_" + channelMap.get('fn') ;
oldfile.renameTo(java.io.File(newpath));
You execute this piece of code only if your completed-flag is set.
Thus, your filename will usually be (e.g.) placer-id.hl7; on completion it will turn to completed_placer-id.hl7

Hope this helps
__________________
JJ Mouris
FFE Luxembourg
IT-Department
Reply With Quote
  #7  
Old 05-06-2010, 09:15 PM
jmendezzz jmendezzz is offline
OBX.2 Kenobi
 
Join Date: Nov 2009
Posts: 85
jmendezzz is on a distinguished road
Default

Thanks So much, I took your advise and in no time i have the basic logic that i am looking for. Now to answer your question; - Do you really not need message headers or other segments? If you need them, my solution won't work.

Yes i will need them but i will obtain those segments from the first message written to the file: so the logic will be. If placer-id(filename) exist then, delete ['MSH'],['PID'], etc until OBR/OBX and append to the file with the same filename. OBR-21(FLAG to determine if last message)

1st Message

MSH|^~\&|HM|HM|AAA|4954|20100422113320||ORU^R01|Q6 31118441T1211841256|P|2.3
PID|1|4954000001|27688638^^^^LESID~49540000000067^ ^^^VISIT|27688638~4954000001~29170226~4954000001|T EST^ONE||19651125|F|||1313 Mockingbird Lane^^NOWHERE^NOWHERE^12345||(612)719-1100|||||^^^^^CD:472|||||||0
PV1|1||||||^^^^^^^^^^^OTHER||||||||||^^^^^^^^^^^OT HER|Lab Outreach||-Medicare|||||||||||||||||||4954||Active|||20100422 111800
ORC|RE|000992010112071119|000992010112071119||CM|| ||20100422113323|||
OBR|1|000992010112071119|000992010112071119|550029 4^CBC|||20100422112800|||||||20100422112955|WB/Coll list&WB/Coll list|^^^^^^^^^^OTHER||||000992010112071119|P|20100 422113318||General Lab|F||1^^^20100422112800^^RT~^^^^^RT|||||||||2010 0422112800
NTE|1||Visit Number: 49540000000067
OBX|9|NM|5500015^WBC||10.1|K/uL|3.8-10.5||||F|||20100422113300
OBX|10|NM|5500020^RBC||5.10|M/uL|3.80-5.20||||F|||20100422113300
OBX|11|NM|5500025^HGB||14.2|g/dL|11.5-15.5||||F|||20100422113300
OBX|12|NM|5500030^HCT||41.1|%|34.5-45.0||||F|||20100422113300
OBX|13|NM|5500035^MCV||85.1|fl|80.0-100.0||||F|||20100422113300
OBX|14|NM|5500040^MCH||33.5|pg|27.0-34.0||||F|||20100422113300
OBX|15|NM|5500045^MCHC||33.2|gm/dL|32.0-36.0||||F|||20100422113300
OBX|18|NM|5500050^PLT||305|K/uL|150-400||||F|||20100422113300

2nd Message - Will only contain OBR/OBX and any segment associated to OBX

OBR|1|000992010112071119|000992010112071119|230200 0^METABOLIC|||20100422112800|||||||20100422112955| WB/Coll list|^^^^^^^^^^OTHER||||000992010112071119|P|20100 422113414||General Lab|F||1^^^20100422112800^^RT~^^^^^RT|||||||||2010 0422112800
NTE|1||Visit Number: 49540000000067
OBX|10|NM|5300035^Sodium||141|mmol/L|132-145||||F|||20100422113400
OBX|11|NM|5300040^Potassium||4.0|mmol/L|3.5-5.1||||F|||20100422113400
OBX|12|NM|5300045^Chloride||102|mmol/L|96-108||||F|||20100422113400
OBX|13|NM|5300050^CO2||28|mmol/L|22-31||||F|||20100422113400
OBX|14|NM|5300055^Anion Gap||9|mmol/L|5-17||||F|||20100422113400
OBX|15|NM|5300010^Glucose||155|mg/dL|70-99|H|||F|||20100422113400
OBX|16|NM|5300025^BUN||8|mg/dL|7-23||||F|||20100422113400
OBX|17|NM|5300030^Creatinine||1.17|mg/dL|0.50-1.30||||F|||20100422113400
OBX|18|NM|5300060^Calcium, Serum||8.8|mg/dL|8.4-10.5||||F|||20100422113400

================================================== ==============
Your logic definitely works, i just have to write logic for the first message to check if file with placer-id exist, however i am running into an obstacle, i am searching online and since Javascript by nature is client side, it does NOT have built functions to search for existing files. Any clues...

Last edited by jmendezzz; 05-06-2010 at 09:19 PM.
Reply With Quote
  #8  
Old 05-07-2010, 04:54 AM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

Once you have computed your filename (in the channel var. fn), you can check with this code:

Code:
var test = java.io.File(fn);
if ( (test.exists()) ){
<your code to strip headers>
}
else {
<don't strip headers>
}
Of course, in this place, fn has to be with the full path.

I'm not a Java or JavaScript programmer, so I don't know if this is the best way to do, but it works.
__________________
JJ Mouris
FFE Luxembourg
IT-Department
Reply With Quote
  #9  
Old 05-07-2010, 08:22 AM
jmendezzz jmendezzz is offline
OBX.2 Kenobi
 
Join Date: Nov 2009
Posts: 85
jmendezzz is on a distinguished road
Default

Thanks, after further investigation...I realized when i append the 2nd message with OBR/OBX segments, don't know why but it removes the field separator of each field. If i do NOT delete msg['MSH'] then is fine. any clues...
Reply With Quote
  #10  
Old 05-08-2010, 07:03 PM
jmendezzz jmendezzz is offline
OBX.2 Kenobi
 
Join Date: Nov 2009
Posts: 85
jmendezzz is on a distinguished road
Default

Hi mourisj, I figured out the issue with the 2nd message adding with NO field separator. I would like to thank you, because of you i was able to get this going. I found all the issues and now my channels are accumulating all ORU that are part of the same order. Once again, thanks for all your help.
Reply With Quote
Reply

Tags
message queuing, segment

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:10 AM.


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