web stats
Creating New Segments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-07-2013, 01:34 PM
atibbits atibbits is offline
Mirth Guru
 
Join Date: May 2012
Location: Salina, KS
Posts: 381
atibbits is on a distinguished road
Cool Creating New Segments

I am thinking that I need to use the create segments after or before for this, but I am trying to figure out how to do that exactly. I am iterating through the OBX and saving the OBX's I need to a variable. I then need to make those become OBX|1| and OBX|2|. Well, I am doing this, but it is placing my new OBX's at the bottom. They should be placed after PV2 and before AL1. Can someone help me with that part??

Here is what I have so far:

Code:
for each(obx in msg..OBX)
{
if(obx['OBX.3']['OBX.3.2'].toString()=="WEIGHT")
{
var obxA= msg.children()[obx.childIndex()];
}
}

for each(obx in msg..OBX)
{
if(obx['OBX.3']['OBX.3.2'].toString()=="HEIGHT")
{
var obxB=msg.children()[obx.childIndex()];
}
}

delete msg['OBX'];


msg['OBX'][0]=obxA;
msg['OBX'][1]=obxB;
Reply With Quote
  #2  
Old 06-07-2013, 02:18 PM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,125
narupley is on a distinguished road
Default

The createSegmentAfter function (in the References tab) should accomplish what you're looking for. Also, I created similar functions: createSegmentBefore, insertSegmentBefore, and insertSegmentAfter. Between the four of those you'll be able to create/insert wherever you want.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 07-19-2017, 06:39 AM
rkMC rkMC is offline
OBX.1 Kenobi
 
Join Date: May 2017
Posts: 48
rkMC is on a distinguished road
Default

Quote:
Originally Posted by narupley View Post
The createSegmentAfter function (in the References tab) should accomplish what you're looking for. Also, I created similar functions: createSegmentBefore, insertSegmentBefore, and insertSegmentAfter. Between the four of those you'll be able to create/insert wherever you want.
I know this is an old post, but Mr Rupley, you mentioned (in the References Tab) in response. Can you explain? I'm new to Mirth and I cannot find the Reference Tab you have mentioned. The createSegmentAfter function is the only function of yours I have not been able to find the code for. I see many references to this function, but not the actual coded function. If you could help, I would greatly appreciate it.
thanks
Reply With Quote
  #4  
Old 07-20-2017, 12:47 AM
amble amble is offline
OBX.2 Kenobi
 
Join Date: Nov 2015
Posts: 94
amble is on a distinguished road
Default

Quote:
Originally Posted by rkMC View Post
I know this is an old post, but Mr Rupley, you mentioned (in the References Tab) in response. Can you explain? I'm new to Mirth and I cannot find the Reference Tab you have mentioned. The createSegmentAfter function is the only function of yours I have not been able to find the code for. I see many references to this function, but not the actual coded function. If you could help, I would greatly appreciate it.
thanks
It's on the left of the message tree part. In the transformer/filters
Attached Images
File Type: png Untitled.png (5.3 KB, 20 views)
Reply With Quote
  #5  
Old 07-20-2017, 05:23 AM
rkMC rkMC is offline
OBX.1 Kenobi
 
Join Date: May 2017
Posts: 48
rkMC is on a distinguished road
Default

Those are the commands. I need the code for the function itself. I assume these are not built into Mirth Connect. When I have ran a message thru my channel with this command included, it comes back and says the command is undefined. Thanks again for your help.
Mirth 3.5.0.8232
Reply With Quote
  #6  
Old 07-21-2017, 12:48 AM
Thoughts_Shared Thoughts_Shared is offline
OBX.2 Kenobi
 
Join Date: Dec 2016
Posts: 58
Thoughts_Shared is on a distinguished road
Default

Quote:
Originally Posted by rkMC View Post
I know this is an old post, but Mr Rupley, you mentioned (in the References Tab) in response. Can you explain? I'm new to Mirth and I cannot find the Reference Tab you have mentioned. The createSegmentAfter function is the only function of yours I have not been able to find the code for. I see many references to this function, but not the actual coded function. If you could help, I would greatly appreciate it.
thanks
Try the link: http://www.mirthcorp.com/community/f...2&postcount=16
Reply With Quote
  #7  
Old 07-21-2017, 08:55 AM
rkMC rkMC is offline
OBX.1 Kenobi
 
Join Date: May 2017
Posts: 48
rkMC is on a distinguished road
Default

I appreciate the link. Only thing is this just has 3 routines, CreateSegmentBefore, InsertSegmentAfter, InsertSegmentBefore. The function I am looking for is not on this link, createSegmentAfter.
Reply With Quote
  #8  
Old 07-24-2017, 12:48 AM
amble amble is offline
OBX.2 Kenobi
 
Join Date: Nov 2015
Posts: 94
amble is on a distinguished road
Default

PHP Code:
[2017-07-24 08:46:19,819]  INFO  (deploy:?): 
function 
createSegmentAfter(namesegment) {
    var 
msgObj segment;
    while (
msgObj.parent() != undefined) {
        
msgObj msgObj.parent();
    }
    
msgObj.insertChildAfter(segment[0], new XML("<" name "></" name ">"));
    return 
msgObj.child(segment[0].childIndex() + 1);

I just put some script in the deploy script of a blank channel:

PHP Code:
var fBody createSegmentAfter.toString();
logger.info(fBody); 

Last edited by amble; 07-24-2017 at 12:55 AM.
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 05:19 PM.


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