web stats
Insert new obx 1.1 line - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2016, 05:33 AM
kab7715 kab7715 is offline
OBX.1 Kenobi
 
Join Date: Aug 2015
Posts: 47
kab7715 is on a distinguished road
Default Insert new obx 1.1 line

SO if certain condition is met I am trying to create a new lead line in OBX and shift allt the existing OBX down 1, but this only happens from the 2nd OBR and on.

So i find an OBR|2| or OBR|3| and etc, etc. any OBX that proceeds that OBR as long as "if(msg['OBR'][i]['OBR.26']['OBR.26.2'].toString() != '')" i need to add the following new line at OBX|1|.....

PHP Code:
  obx1['OBX.1']['OBX.1.1'] = '1';
                    
obx1['OBX.2']['OBX.2.1'] = 'TX';
                    
obx1['OBX.3']['OBX.3.1'] = 'ORG';
                    
obx1['OBX.3']['OBX.3.2'] = 'ORGANISM';
                    
obx1['OBX.5']['OBX.5.1'] = vOBX3_5.toString() + ' ' vOBX4_1.toString();
                    
obx1['OBX.11']['OBX.11.1'] = 'F'
and shift the existing OBX|1| down to being OBX|2| and so on and so on........

so ive tried the following and get different unexpected results....

PHP Code:
 for(var 1msg['OBR'].length(); i++)
    {
        if(
msg['OBR'][i]['OBR.26']['OBR.26.2'].toString() != '')
        {
            var 
ExistOBX getSegmentsAfter(msgmsg.OBR[i], 'OBX'false);
            
            for 
each (obx in getSegmentsAfter(msgobr'OBX'true))
            {
                for 
each (var obx1 in ExistOBX)
                {
                    var 
shifter parseFloat(obx1['OBX.1']['OBX.1.1']) + 1;
                    
obx1['OBX.1']['OBX.1.2'] = shifter;
                    
                }
            }
    } 
this was just testing to see what happens...so i process the message and see..

OBX|1^2|
OBX|2^3|

so i say ok i then add the following lines under obx1['OBX.1']['OBX.1.2'] = shifter;...

PHP Code:
 obx1['OBX.1']['OBX.1.1'] = obx1['OBX.1']['OBX.1.2'].toString();
                    
delete obx1['OBX.1']['OBX.1.2'] ; 
expecting to get the 2 to replace the 1 and the 3 to replace the 2 but that not what happens.... i end up getting the lengthy of that OBX segment which is 18 lines long and now..

OBX|1| becomes OBX|19| and OBX|2| becomes OBX|20|

my raw message looks like this...

MSH|^~\
SFT|Med
PID|1|2
NK1|1|A
NK1|2|J
NK1|3|S
PV1|1|O
PV2|||L
ORC|RE|
OBR|1|0
NTE|1|N
TQ1||||
SPM|1|0
OBX|1|S
OBX|2|S
OBX|3|S
FT1|1||
OBR|2|0
OBX|1|S
OBX|2|S
OBX|3|S
OBX|4|S
OBX|5|S
OBX|6|S
OBX|7|S
OBX|8|S
OBX|9|S
OBX|10|
OBX|11|
OBX|12|
OBX|13|
OBX|14|
OBX|15|
OBX|16|
OBX|17|
OBX|18|
FT1|2||
OBR|3|0
OBX|1|S
OBX|2|S
OBX|3|S
OBX|4|S
OBX|5|S
OBX|6|S
OBX|7|S
OBX|8|S
OBX|9|S
OBX|10|
OBX|11|
OBX|12|
OBX|13|
OBX|14|
OBX|15|
OBX|16|
OBX|17|
OBX|18|
FT1|2|||


so my encoded message looks like this

MSH|^~\&
PID|1|20
PV1|1|O|
ORC|RE|P
OBR|1|PR
NTE|1|L|
NTE|2|L|
OBX|1|ST|IM
OBX|2|ST|IM
OBX|3|ST|ES
OBR|2|PRO35
OBX|19|ST|5
OBX|20|ST|2
OBX|21|ST|3
OBX|22|ST|4
OBX|23|ST|7
OBX|24|ST|1
OBX|25|ST|1
OBX|26|ST|6
OBX|27|ST|1
OBX|28|ST|3
OBX|29|ST|G
OBX|30|ST|6
OBX|31|ST|3
OBX|32|ST|4
OBX|33|ST|5
OBX|34|ST|1
OBX|35|ST|2
OBX|36|ST|4
OBR|3|PRO35
OBX|19|ST|5
OBX|20|ST|2
OBX|21|ST|3
OBX|22|ST|4
OBX|23|ST|7
OBX|24|ST|1
OBX|25|ST|1
OBX|26|ST|6
OBX|27|ST|1
OBX|28|ST|3
OBX|29|ST|G
OBX|30|ST|6
OBX|31|ST|3
OBX|32|ST|4
OBX|33|ST|5
OBX|34|ST|1
OBX|35|ST|2
OBX|36|ST|412

Last edited by kab7715; 03-16-2016 at 08:22 AM.
Reply With Quote
  #2  
Old 03-16-2016, 06:31 AM
kab7715 kab7715 is offline
OBX.1 Kenobi
 
Join Date: Aug 2015
Posts: 47
kab7715 is on a distinguished road
Default

Am I using the wrong approach to this?
Reply With Quote
  #3  
Old 03-16-2016, 07:56 AM
mcalKno mcalKno is offline
 
Join Date: Apr 2015
Location: Pennsylvania
Posts: 247
mcalKno is on a distinguished road
Default

I think this might help...

PHP Code:
for each(obr in msg.OBR)
{
    if(
obr['OBR.26']['OBR.26.2'].toString() != '')
    {
        var 
newOBX createSegmentAfter('OBX'obr);
        
newOBX['OBX.1']['OBX.1.1'] = '1';
        
newOBX['OBX.2']['OBX.2.1'] = '';
        
newOBX['OBX.3']['OBX.3.1'] = 'newobxvalue'
    }

    for 
each(obx in msg.OBX)
    {
        var 
obxGroup getSegmentsAfter(msg,obr,'OBX');
        for (var 
0<= obxGroup.length-1o++)
            
msg.children()[obxGroup[o].childIndex()]['OBX.1']['OBX.1.1'] = o+1;
    }


Last edited by mcalKno; 03-16-2016 at 08:29 AM.
Reply With Quote
  #4  
Old 03-16-2016, 08:47 AM
kab7715 kab7715 is offline
OBX.1 Kenobi
 
Join Date: Aug 2015
Posts: 47
kab7715 is on a distinguished road
Default

Quote:
Originally Posted by mcalKno View Post
I think this might help...

PHP Code:
for each(obr in msg.OBR)
{
    if(
obr['OBR.26']['OBR.26.2'].toString() != '')
    {
        var 
newOBX createSegmentAfter('OBX'obr);
        
newOBX['OBX.1']['OBX.1.1'] = '1';
        
newOBX['OBX.2']['OBX.2.1'] = '';
        
newOBX['OBX.3']['OBX.3.1'] = 'newobxvalue'
    }

    for 
each(obx in msg.OBX)
    {
        var 
obxGroup getSegmentsAfter(msg,obr,'OBX');
        for (var 
0<= obxGroup.length-1o++)
            
msg.children()[obxGroup[o].childIndex()]['OBX.1']['OBX.1.1'] = o+1;
    }



i want avoid changing any OBX after the first OBR and only create message changes to OBX after for any other OBR that might show up in message

PHP Code:
for(var 1msg['OBR'].length(); i++)
    {
        if(
msg['OBR'][i]['OBR.26']['OBR.26.2'].toString() != '')
        {
            var 
newOBX createSegmentAfter('OBX'obr); 
                
newOBX['OBX.1']['OBX.1.1'] = '1'
                
newOBX['OBX.2']['OBX.2.1'] = 'TX'
                
newOBX['OBX.3']['OBX.3.1'] = 'ORG'
                
newOBX['OBX.3']['OBX.3.2'] = 'ORGANISM';
                
newOBX['OBX.5']['OBX.5.1'] = vOBX3_5.toString() + ' ' vOBX4_1.toString();
                
newOBX['OBX.11']['OBX.11.1'] = 'F';   

                for 
each(obx in msg.OBX)
                { 
                    var 
obxGroup getSegmentsAfter(msgobr[i],'OBX'); 
                
                    for (var 
0<= obxGroup.length-1o++)
                        
msg.children()[obxGroup[o].childIndex()]['OBX.1']['OBX.1.1'] = o+1
                    
                }
                 }

now im getting the childIndex error

TypeError: Cannot call method "childIndex" of undefined

Last edited by kab7715; 03-16-2016 at 08:51 AM.
Reply With Quote
  #5  
Old 03-16-2016, 08:53 AM
mcalKno mcalKno is offline
 
Join Date: Apr 2015
Location: Pennsylvania
Posts: 247
mcalKno is on a distinguished road
Default

Just add an additional condition to the if statement....

PHP Code:
for each(obr in msg.OBR)
{
    if(
obr['OBR.1']['OBR.1.1'].toString() > && obr['OBR.26']['OBR.26.2'].toString() != '')
    {
        var 
newOBX createSegmentAfter('OBX'obr);
        
newOBX['OBX.1']['OBX.1.1'] = '1';
        
newOBX['OBX.2']['OBX.2.1'] = '';
        
newOBX['OBX.3']['OBX.3.1'] = 'newobxvalue'
    }

    for 
each(obx in msg.OBX)
    {
        var 
obxGroup getSegmentsAfter(msg,obr,'OBX');
        for (var 
0<= obxGroup.length-1o++)
            
msg.children()[obxGroup[o].childIndex()]['OBX.1']['OBX.1.1'] = o+1;
    }

Reply With Quote
  #6  
Old 03-16-2016, 08:58 AM
kab7715 kab7715 is offline
OBX.1 Kenobi
 
Join Date: Aug 2015
Posts: 47
kab7715 is on a distinguished road
Default

THANK YOU mcalKno for your response was extremely helpful..

Looks like i may have it thank to you..

PHP Code:
for(var 1msg['OBR'].length(); i++)
    {
        if(
msg['OBR'][i]['OBR.26']['OBR.26.2'].toString() != '')
        {
            var 
newOBX createSegmentAfter('OBX'msg.OBR[i]);
            
                
newOBX['OBX.1']['OBX.1.1'] = '1'
                
newOBX['OBX.2']['OBX.2.1'] = 'TX'
                
newOBX['OBX.3']['OBX.3.1'] = 'ORG'
                
newOBX['OBX.3']['OBX.3.2'] = 'ORGANISM';
                
newOBX['OBX.5']['OBX.5.1'] = vOBX3_5.toString() + ' ' vOBX4_1.toString();
                
newOBX['OBX.11']['OBX.11.1'] = 'F';   

                for 
each(obx in msg.OBX)
                { 
                    var 
obxGroup getSegmentsAfter(msgmsg.OBR[i],'OBX'); 
                
                    for (var 
0<= obxGroup.length-1o++)
                        
msg.children()[obxGroup[o].childIndex()]['OBX.1']['OBX.1.1'] = o+1
                }         
        }
    } 
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:10 AM.


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