web stats
Need assistance with transformer - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2018, 10:15 AM
KBanks KBanks is offline
OBX.1 Kenobi
 
Join Date: Sep 2010
Posts: 38
KBanks is on a distinguished road
Default Need assistance with transformer

This message is for diet orders and our vendor pulls information out of an ODS segment. Someone, prior to me, set up the code to build a new ODS segment and information is currently being populated in the ODS.5.1 segment. I need to add information to the ODS.1.1, ODS.2.1, and ODS.3.3 segments but each time I try to set up JavaScript coding to do so, I get error messages about things not being defined. The information I need to populate into the ODS segments are coming from the OBR.13 segment, which is tilde separated, and direct each value to one of the new ODS segments that was created.

Currently, I have the "Parse Field Repetitions" and "Parse Subcomponents" turned on so the system has broken out my OBR.13 segment into separate segments. I have tried to take each of these and direct them to their respective ODS segment but again, I only get error messages and I know it has to do with my JavaScript coding.


Here is a copy of my message I am using:
MSH|^~\&|CPSI_IF_FEED_OUT|Wayne Hospital|||20180808132116||ORM^O01|201808081321162 8|P|2.3|||
PID|1||000414|000414|TEST CPSI^BROWN^ROBERT||19801010|M||W|10 WAYNE DRIVE^^GREENVILLE^OH^45331|014|1234567894^^^amanda .cpsi@gmail.com^^0000000000|9372284101|Southern Altai|?||CPSI5060|000000000|||Not Hispanic or Latino||||||W||N
PV1|1|2^O/P^21|^^||||999999^WAYNE^HEALTHCARE^|999999^WAYNE^H EALTHCARE^|999999^WAYNE^HEALTHCARE^|Z||||||||||P|| ||||||||||||||||||||||||| .00|||00131662
PV2|1||CPSI TEST PATIENT FOR NURSING EDUCATION|||||20150930000000|||||||||||||||||||
OBX|1|ST|1010.3^Height||079|Inches
OBX|2|ST|1010.1^Body Weight||167.00|pounds
AL1|1|BRANDNAME|00006659^DEMEROL HYDROCHLORIDE||Rash
AL1|2|FOOD|00025602^SHRIMP||Hives
AL1|3|ENVIRONMENTAL|00037793^DUST||Sneezing
GT1|1||CPSI^BROWN^ROBERT||10 WAYNE DRIVE^^GREENVILLE^OH^45331|1234567894^^^amanda.cps i@gmail.com^^0000000000|7659351507|19801010|M|||00 0000000||||KOHLS RICHMOND|3722 NATIONAL ROAD EAST^^RICHMOND^IN^47374|7659351507|||||||||||KH4
ORC|NW|908841620180808|||IP||||201808081320|KAG||9 99999^WAYNE^HEALTHCARE^|090|||
OBR|1|908841620180808||9000100^REGULAR DIET||201808081320|||||L||REGULAR DIET~{LIQUID SPECIFIC:~START DATE (MMDDYY): 073018~{START MEAL BREAKFAST||^^^|999999^WAYNE^HEALTHCARE^||||||||DIE T|P||001^1X^^20180808132000^^R|999999~926400||||^^ ^|^^^|||||||||||
ZRV|N^|Y^20120627000000|^||
ODS|||||1


Any help someone could give me would be greatly appreciated. I have been working on this and playing with different JavaScript coding for over a week now and I give up.

Last edited by KBanks; 08-09-2018 at 10:31 AM. Reason: Need to add more information
Reply With Quote
  #2  
Old 08-09-2018, 11:20 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 530
agermano is on a distinguished road
Default

It's usually helpful to post both your original message and your expected output. Also if you post some of your coding attempts you can get some feedback on why it didn't work and what you might need to adjust.
Reply With Quote
  #3  
Old 08-10-2018, 04:26 AM
KBanks KBanks is offline
OBX.1 Kenobi
 
Join Date: Sep 2010
Posts: 38
KBanks is on a distinguished road
Default

Here is my original message:
MSH|^~\&|CPSI_IF_FEED_OUT|Wayne Hospital|||20180808132116||ORM^O01|201808081321162 8|P|2.3|||
PID|1||000414|000414|TEST CPSI^BROWN^ROBERT||19801010|M||W|10 WAYNE DRIVE^^GREENVILLE^OH^45331|014|1234567894^^^amanda .cpsi@gmail.com^^0000000000|9372284101|Southern Altai|?||CPSI5060|000000000|||Not Hispanic or Latino||||||W||N
PV1|1|2^O/P^21|^^||||999999^WAYNE^HEALTHCARE^|999999^WAYNE^H EALTHCARE^|999999^WAYNE^HEALTHCARE^|Z||||||||||P|| ||||||||||||||||||||||||| .00|||00131662
PV2|1||CPSI TEST PATIENT FOR NURSING EDUCATION|||||20150930000000|||||||||||||||||||
OBX|1|ST|1010.3^Height||079|Inches
OBX|2|ST|1010.1^Body Weight||167.00|pounds
AL1|1|BRANDNAME|00006659^DEMEROL HYDROCHLORIDE||Rash
AL1|2|FOOD|00025602^SHRIMP||Hives
AL1|3|ENVIRONMENTAL|00037793^DUST||Sneezing
GT1|1||CPSI^BROWN^ROBERT||10 WAYNE DRIVE^^GREENVILLE^OH^45331|1234567894^^^amanda.cps i@gmail.com^^0000000000|7659351507|19801010|M|||00 0000000||||KOHLS RICHMOND|3722 NATIONAL ROAD EAST^^RICHMOND^IN^47374|7659351507|||||||||||KH4
ORC|NW|908841620180808|||IP||||201808081320|KAG||9 99999^WAYNE^HEALTHCARE^|090|||
OBR|1|908841620180808||9000100^REGULAR DIET||201808081320|||||L||REGULAR DIET~{LIQUID SPECIFIC:~START DATE (MMDDYY): 073018~{START MEAL BREAKFAST||^^^|999999^WAYNE^HEALTHCARE^||||||||DIE T|P||001^1X^^20180808132000^^R|999999~926400||||^^ ^|^^^|||||||||||
ZRV|N^|Y^20120627000000|^||


This is the current transformer in place that builds the ODS segment.
/*
This transformer finds what level of assistance (if any) patients need to place
a meal request.

1 = select (or allowed to order without restriction)
2 = non select (or must recieve the default tray)
3 = select with assiatance (patient needs help to select their food items)

The clues are provided in OBR 13-1
*/

// Set up some variables

var level2 = 'SEND DEFAULT TRAY D/T PATIENT CONDITION';
var level3 = 'PT NEEDS ASSISTANCE W/ROOM SERVICE ORDERS';

var instructions = 0;
var result = -1;
var MatchFound = 0;

// Find what those instructions are and set the variable "instructions" accordingly

var SearchString = msg['OBR']['OBR.13']['OBR.13.1'].toString();

result = SearchString.indexOf(level2);
if (result != -1)
{
instructions = 2;
MatchFound = 1;
}
if (MatchFound ==0)
{
var result = SearchString.indexOf(level3);
if (result != -1)
{
instructions = 3;
MatchFound = 1;
}
}
if (MatchFound == 0)
{
instructions = 1;
}

// set segment ODS-5 with the value
createSegment ('ODS', msg);
msg['ODS']['ODS.5'] = instructions;


Here is my latest attempt at the code. I thought since the ODS segment was already built from the previous transformer step, all I would need to do is direct each of the OBR.13.1 to their respective ODS segments but obviously I am wrong.

msg['OBR'][0]['OBR.13']['OBR.13.1'] = msg['ODS']['ODS.1'] ['ODS.1.1'].toString();
msg['OBR'][1]['OBR.13']['OBR.13.1'] = msg['ODS']['ODS.3'] ['ODS.3.3'].toString();
msg['OBR'][2]['OBR.13']['OBR.13.1'] = msg['ORC']['ORC.7'] ['ORC.7.1'].toString();
msg['OBR'][3]['OBR.13']['OBR.13.1'] = msg['ODS']['ODS.2'] ['ODS.2.1'].toString();
Reply With Quote
  #4  
Old 08-14-2018, 05:47 AM
KBanks KBanks is offline
OBX.1 Kenobi
 
Join Date: Sep 2010
Posts: 38
KBanks is on a distinguished road
Default

Is there anyone at all who may be able to assist me with this?
Reply With Quote
  #5  
Old 08-14-2018, 09:54 AM
KBanks KBanks is offline
OBX.1 Kenobi
 
Join Date: Sep 2010
Posts: 38
KBanks is on a distinguished road
Default

I figured out what I was doing wrong. I now have it set up and it is working.
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


All times are GMT -8. The time now is 04:46 AM.


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