#1
|
|||
|
|||
![]()
Hi, I am very new to Mirth and have a lot to learn. I really appreciate how helpful the people on this forum have been thus far. Thank you all!
I am trying to create a channel that will receive HL7v2.* files from a laboratory and store the lab results into a MySQL table. Thus far, I've been able to create transformers for patientID, last name, first name, etc and store those in a table, no problem. However, I'm not sure how to store the actual lab values. There could be only one or two results - or there could be many. How do I create variables for each of an unknown number of fields (Sodium, Potassium, WBC, etc) and their corresponding values? Or can I create arrays of all of the field names and field values? If so, how would I store such an array into a db? |
#2
|
|||
|
|||
![]()
I think one of your first steps is to make sure you are allowing repeated fields. With Mirth Connect open, click Channels > Your channel, and make sure you are on the Summary page. Click Set Data Types and then Properties for (I think) your input. Make sure "Parse Field Repetitions" is checked.
This is something I had trouble with at one point, and without it checked I was getting all my repeated fields crammed into 1. Someone else should be able to further help you, but try using a template on the input that has everything in it, that way it will try and map the fields if they're there. Last edited by fonix; 07-18-2011 at 10:52 AM. Reason: spelling |
#3
|
|||
|
|||
![]()
This is more a db design question I think.
I've never worked with My SQL, only Oracle and SQL Server. I don't know how it handles cross-table relationships. If this were my project I'd have a patient table, a test table containing the various tests that would come across the interface, and a results table. The results table, naturally is where you store your results. It would need a many to one relationship with both the patient and the tests tables and would need at least 3 fields. Pt ID, Test ID, and Result You could then write as many or as few results per patient into the table as required. Hopefully this isn't too convoluted. If you need clarification feel free to ask, I'll try and be as helpful as I can. |
#4
|
|||
|
|||
![]()
Actually, I'm pretty confident about the design of the db - it looks a lot like what you laid out. My question was: how do I get at the values of the results in order to store them?
For example: In the transformer I have patientID mapped to msg['PID']['PID.3']['PID.3.1'].toString(). This works because there is only one instance of ['PID']. However, each result address looks like msg['OBX'][3]['OBX.7']['OBX.7.1'].toString(). The [3] signifies that this is the third result value. There will be some unknown number of results. Therefore I need to pull msg['OBX'][X]['OBX.7']['OBX.7.1'].toString() where X goes from 1 to whatever number or results there are. Right now I'm trying pull all the values as an array by mapping a variable to msg['OBX']['OBX.7']['OBX.7.1'].toString() (notice, no number). That may or may not work - I'm experimenting Last edited by DimitriA; 07-21-2011 at 09:31 AM. Reason: changed OBR's to OBX's |
#5
|
|||
|
|||
![]()
Oh! Sorry...I do that sometimes..
This should point you in the right direction.. Code:
for each(seg in msg.children()) { if(seg.name() == "OBR") { } } |
#6
|
|||
|
|||
![]()
Great!
Sorry for the newbie question but uh . . . where do I put that? It looks like JavaScript, so do I put it in Destinations? |
#7
|
|||
|
|||
![]()
Don't worry about sounding like a newbie....go back and read my original posts when I started with Mirth...you'll feel better
![]() You need to build a transformer on the destination you want this to work on. Copy a sample message to your clipboard. Go to the destination and click "Transformers" on the left hand side of your window. Click "Add New Step" When the new step comes up, double click on "Message Builder" and select Javascript from the pulldown Copy the code into the window and make the necessary modifications. Go to Templates and paste your message in the inbound template. Click on Message Tree and you'll see if you have access to it parsed into nodes. When you want to manipulate or read a node, all you have to do is drag it into your code. Remember that when you drag it, it will always be msg['SEG']['SEG.1']['SEG.1.1'].toString() .."SEG" being the segment. If you're using this in the for each loop, you need to replace msg['SEG'] with just seg (exactly those letter seg) |
#8
|
|||
|
|||
![]()
Bostad,
Thank you so much for the clear and thorough explanation! However I'm stumped on the last part: how do I get at the values in the 'for each' loop? I tried setting the name of a previous Step (resultValue) that was of type Mapper equal to the node like this: Code:
for each(seg in msg.children()) { if(seg.name() == "OBX") { $('resultValue') = seg['OBX.5']['OBX.5.1'].toString(); } } |
#9
|
|||
|
|||
![]()
Never mind I got it.
For anyone else: Code:
var resultVal = new Array(); var counter = 0; for each (mOBX in msg..OBX) { resultVal[counter] = mOBX['OBX.5']['OBX.5.1'].toString(); counter += 1; } channelMap.put("resultVal",resultVal); |
#10
|
|||
|
|||
![]()
Thanks for posting the answer.
|
![]() |
Tags |
database writer, mirth, transformer, transformer mapping |
Thread Tools | |
Display Modes | |
|
|