web stats
Using Create Segment Functions - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2008, 12:02 PM
jpiascik jpiascik is offline
Mirth Newb
 
Join Date: Oct 2006
Location: Connecticut
Posts: 22
jpiascik
Default Using Create Segment Functions

Hi.

I'm trying to write a transfomer script to modify the CON segments in a message, deleting all those except a specific Type, and adding an additional copy with modifications. This is all working fairly well except that when I try to create the new segment, it is inserted to the end of the message, instead of following the current CON segment that I am iterating over.

---------------------------------------------------------
My Source Message:
---------------------------------------------------------
MSH|^~\&|EPIC|IFH|NYCLIX|NYCLIX|20080415132906|704 888|ADT^A31|139|D|2.5|||
EVN|A31|200804151329|||704888^PIASCIK^JONAH^TEST^^ ^^^IUH^^^^^MHHC|
PID|||1241204^^^^EPI||ZZ TEST^PARIS^HILTON^^MS.^||19850823|F|||TWIN TOWERS LOS ANGELES COUNTY DETENTION CENTER^^LOS ANGELES^CA^00000^^^^||(123)456-7890^^7|(000)000-0000^^8|DEAF/MUTE|||156234|999-99-9999|||WHITE||||||||N
PD1||||199^ZZTEST^MD^^^^||||||||||
ROL||||199^ZZTEST^MD^^^^|20070717|||
CON|1|CLINICAL UNK|face sheet/ insurance card/notification 10/02/07||||||||||||
CON|2|CLINICAL UNK|face sheets/ insurance card notification 10/02/07||||||||||||
CON|3|CONSENT|RHIO CONSENT FORM||||||||100002||20080415||
NK1|1|King^Larry^^^^|Friend||(000)000-0000||1|||||||||||||||||||||||||||
PV1|||^^^^^^^^|||||||||||||||5|||||||||||||||||||| ||||||||||||
PV2||||||||||||||||||||||N|||||||||||||||||||||||| |||

---------------------------------------------------------
My transmform:
---------------------------------------------------------
var count = 0;
var setID = 1;

for each (con in msg..CON)
{
// Find a RHIO Consent - Type 'CONSENT'
if (con['CON.2']['CON.2.1'].toString() == "CONSENT")
{
// Set first CON segment for Disclosure
msg['CON'][count]['CON.1']['CON.1.1'] = setID.toString();
msg['CON'][count]['CON.2']['CON.2.1'] = "001";
msg['CON'][count]['CON.5']['CON.5.1'] = "Disclosure Consent";
count++;
setID++;
// Create a second CON segment for Access Consent
createSegmentAfter('CON', msg['CON'][count-1])
msg['CON'][count] = msg['CON'][count-1];
msg['CON'][count]['CON.1']['CON.1.1'] = setID.toString();
msg['CON'][count]['CON.2']['CON.2.1'] = "110";
msg['CON'][count]['CON.5']['CON.5.1'] = "Access Consent";
count++;
setID++;
}
else
{
delete msg['CON'][count];
};
}

---------------------------------------------------------
My Result Message
---------------------------------------------------------
MSH|^~\&|EPIC|IFH|NYCLIX|NYCLIX|20080415132906|704 888|ADT^A31|139|D|2.5|||
EVN|A31|200804151329|||704888^PIASCIK^JONAH^TEST^^ ^^^IUH^^^^^MHHC|
PID|||1241204^^^^EPI||ZZ TEST^PARIS^HILTON^^MS.^||19850823|F|||TWIN TOWERS LOS ANGELES COUNTY DETENTION CENTER^^LOS ANGELES^CA^00000^^^^||(123)456-7890^^7|(000)000-0000^^8|DEAF/MUTE|||156234|999-99-9999|||WHITE||||||||N
PD1||||199^ZZTEST^MD^^^^||||||||||
ROL||||199^ZZTEST^MD^^^^|20070717|||
CON|1|001|RHIO CONSENT FORM||Disclosure Consent||||||100002||20080415||
NK1|1|King^Larry^^^^|Friend||(000)000-0000||1|||||||||||||||||||||||||||
PV1|||^^^^^^^^|||||||||||||||5|||||||||||||||||||| ||||||||||||
PV2||||||||||||||||||||||N|||||||||||||||||||||||| |||
CON|2|110|RHIO CONSENT FORM||Access Consent||||||100002||20080415||

---------------------------------------------------------

Any ideas/recommendations/solutions?

Thanks in advance!

Jonah Piascik
The Institute for Family Health
jpiascik@institute2000.org
212.404.7697
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
how to use inbuilt functions (filters) in Mirth manish1982 Support 1 03-26-2008 03:53 PM
Using Java Script to Create/Duplicate HL7 Segment jpiascik Development 0 03-18-2008 12:02 PM
Global functions - how to do it? Bleupomme Support 1 06-04-2007 12:29 PM
Complete REference FUnctions shifting_18 Support 4 05-29-2007 06:13 PM
wanted to know about functions deepaganu Support 1 04-23-2007 11:40 PM


All times are GMT -7. The time now is 02:18 PM.


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