web stats
Some help to improve code - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2017, 07:07 AM
amble amble is offline
OBX.2 Kenobi
 
Join Date: Nov 2015
Posts: 95
amble is on a distinguished road
Default Some help to improve code

Hi,

A system of ours requires questions and answers in OBX moving to the OBR 13 field. An order can have multiple ORC, an OBR following an ORC and then x amount of OBX per ORC group. All OBX must be deleted as the last step.

I'm using this code currently:

PHP Code:
var 0;
var 
0;

for 
each(orc in msg.ORC
    {
        var 
obxGroup getSegmentsAfter(msgmsg.OBR[i], 'OBX'false);
        for 
each(obx in obxGroup)
            {
                
msg['OBR'][i]['OBR.13']['OBR.13.2'] += msg['OBX'][k]['OBX.3']['OBX.3.2'].toString() +": " +msg['OBX'][k]['OBX.5']['OBX.5.1'].toString() +"::";
                
k++;
            }
    
    
// 
        
i++;
    }

var 
obxLength msg['OBX'].length();
while (
obxLength--)
{
    if (
obxLength >= 0)
    {
        
delete msg['OBX'][obxLength];
    }


Example input 1
PHP Code:
MSH|^~\&|||||||||||||||||||
PID|1||111111^^^PAT^PID||SIMPSON^BART^^^MR^^P||20060101|1||||||||||||||||||||||||
PD1||||
PV1|1|I|||||||||||||||||||||||||||||||||||||||||||
ORC|NW|ORDER-NUM01||||||||||^||
OBR|1|ORDER-NUM01|||||||||||ORDER COMMENT||||||||||||||
OBX|0|ST|^Q1|""|A1||||||
OBX|1|ST|^Q2|""|A2||||||
OBX|2|ST|^Q3|""|A3||||||
OBX|3|ST|^Q4|""|A4||||||
OBX|4|ST|^Q5|""|A5|||||| 

Example input 2
PHP Code:
MSH|^~\&|||||||||||||||||||
PID|1||111111^^^PAT^PID||SIMPSON^BART^^^MR^^P||20060101|1||||||||||||||||||||||||
PD1||||
PV1|1|I|||||||||||||||||||||||||||||||||||||||||||
ORC|NW|ORDER-NUM01||||||||||^||
OBR|1|ORDER-NUM01|||||||||||ORDER COMMENT||||||||||||||
OBX|0|ST|^Q1|""|A1||||||
OBX|1|ST|^Q2|""|A2||||||
OBX|2|ST|^Q3|""|A3||||||
OBX|3|ST|^Q4|""|A4||||||
OBX|4|ST|^Q5|""|A5||||||
ORC|NW|ORDER-NUM02||||||||||^||
OBR|1|ORDER-NUM02|||||||||||ORDER COMMENT 2||||||||||||||
OBX|0|ST|^Q2|""|A2||||||
OBX|0|ST|^Q3|""|A3||||||
OBX|0|ST|^Q4|""|A4|||||| 
At the moment they are delimited by colons. However, it is possible to map a question per field in OBR 13 (to a maximum of 5). So I'm trying to get from what I have in ORDER-NUM01 to what is displayed in ORDER-NUM02 (instead of delimited by colon, put in seperate fields.

PHP Code:
MSH|^~\&|||||||||||||||||||
PID|1||111111^^^PAT^PID||SIMPSON^BART^^^MR^^P||20060101|1||||||||||||||||||||||||
PD1||||
PV1|1|I|||||||||||||||||||||||||||||||||||||||||||
ORC|NW|ORDER-NUM01||||||||||^||
OBR|1|ORDER-NUM01|||||||||||ORDER COMMENT^Q1A1::Q2A2::Q3A3::Q4A4::Q5A5::||||||||||||||
ORC|NW|ORDER-NUM02||||||||||^||
OBR|1|ORDER-NUM02|||||||||||ORDER COMMENT 2^Q2A2^Q3A3^Q4A4|||||||||||||| 

Any thoughts/ideas? Took me a while to get here and I need a bit of a lift for the alternative
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 01:38 PM.


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