web stats
Setting Transformer Variables using Javascript - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 12-07-2009, 07:37 AM
cmarchione cmarchione is offline
Mirth Newb
Join Date: Apr 2008
Posts: 8
Question Setting Transformer Variables using Javascript

I need to extract information from a Patient Identifier List (array) and I am not sure how to set a variable in a transformer to update a database table.
Basically my code loops thru repeating PID segments in a transformer step. Most of the steps are Mappers (i.e.: variable name, msg[blah])

This is what I have: the transformer step is called "pid_3_patient_id" (javascript type)

var msg = channelMap.get('msg');
var type_code = "";

for each (pid in msg..PID)
var type_code = pid['PID.3']['CX.5'].toString();
if (type_code == "MR")
pid_3_patient_id = pid['PID.3']['CX.1'].toString();

but this errors out...i am unable to save it.
Any assistance would be greatly appreciated!
Reply With Quote
Old 12-07-2009, 03:06 PM
jim jim is offline
OBX.1 Kenobi
Join Date: Sep 2009
Posts: 35
jim is on a distinguished road

Carol, there may be a simpler way to get the information using javascript. Normally an HL7 message has only one PID segment:

var type_code=msg['PID']['PID.3']['PID.3.5'].toString()
if (type_code == "MR"){
var pid_3_patient_id=msg['PID']['PID.3']['PID.3.1'].toString();

If there are multiple PID segments in the HL7 message being sent into the Transformer then you would have to apply a sequence number to each PID segment like so:

for (pidSeq in msg['PID']){
var type_code=msg['PID'][pidSeq]['PID.3']['PID.3.5'].toString()
if (type_code == "MR"){
var pid_3_patient_id=msg['PID'][pidSeq]['PID.3']['PID.3.1'].toString();

Reply With Quote

repeating, transformer, variables

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 08:05 AM.

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