Announcement

Collapse
No announcement yet.

How to exclude one msg type from transformer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to exclude one msg type from transformer

    Hi all,

    We are on Mirth 3.4.0.800. I have a java transformer that adds a ROL segment. On one message type, indicated by both/either MSH.9= A17 OR MSH.8= SWAPADMIN, there are multiple PID, PV1 & PV2 segments so I want to ignore the addition of the ROL on these. I wasn't sure where to add this w/o messing up the existing code.


    var rolAlreadyCreated = false;

    if(msg.DRG.length() > 0 && rolAlreadyCreated == false)
    {
    var rol = createSegmentAfter('ROL', msg.DRG);

    rol['ROL.3.1'] = 'PP';
    rol['ROL.4.1']['4.1.1'] = existingPV1['PV1.51']['PV1.51.1'];
    rol['ROL.4.1']['4.1.2'] = existingPV1['PV1.51']['PV1.51.2'];
    rol['ROL.4.1']['4.1.3'] = existingPV1['PV1.51']['PV1.51.3'];
    rol['ROL.4.1']['4.1.4'] = existingPV1['PV1.51']['PV1.51.4'];

    rolAlreadyCreated = true;
    }

    if(msg.GT1.length() > 0 && rolAlreadyCreated == false)
    {
    var rol = createSegmentBefore('ROL', msg.GT1);

    rol['ROL.3.1'] = 'PP';
    rol['ROL.4.1']['4.1.1'] = existingPV1['PV1.51']['PV1.51.1'];
    rol['ROL.4.1']['4.1.2'] = existingPV1['PV1.51']['PV1.51.2'];
    rol['ROL.4.1']['4.1.3'] = existingPV1['PV1.51']['PV1.51.3'];
    rol['ROL.4.1']['4.1.4'] = existingPV1['PV1.51']['PV1.51.4'];

    rolAlreadyCreated = true;
    }
    if(msg.OBX.length() > 0 && rolAlreadyCreated == false)
    {
    var rol = createSegmentAfter('ROL', msg.OBX);

    rol['ROL.3.1'] = 'PP';
    rol['ROL.4.1']['4.1.1'] = existingPV1['PV1.51']['PV1.51.1'];
    rol['ROL.4.1']['4.1.2'] = existingPV1['PV1.51']['PV1.51.2'];
    rol['ROL.4.1']['4.1.3'] = existingPV1['PV1.51']['PV1.51.3'];
    rol['ROL.4.1']['4.1.4'] = existingPV1['PV1.51']['PV1.51.4'];

    rolAlreadyCreated = true;
    }

    // only update when consult provider is present,
    if (existingPV1['PV1.9'].length() > 0 && existingPV1['PV1.9']['PV1.9.1'].length() > 0) {
    var newROL = createSegmentAfter('ROL', msg.ROL);
    newROL['ROL.3.1'] = 'CP';
    newROL['ROL.4.1']['4.1.1'] = existingPV1['PV1.9']['PV1.9.1'];
    newROL['ROL.4.1']['4.1.2'] = existingPV1['PV1.9']['PV1.9.2'];
    newROL['ROL.4.1']['4.1.3'] = existingPV1['PV1.9']['PV1.9.3'];
    newROL['ROL.4.1']['4.1.4'] = existingPV1['PV1.9']['PV1.9.4'];
    }

    Basically I am looking for
    If MSH.8 is equal to 'SWAPADMIN' skip all the ROL code that follows, else proceed.

    Any help would be appreciated.
    Thanks,
    Patti

  • #2
    Handling A17 /multiple PID, PV1 & PV2 segments

    Not elegant but found a way to handle this message type w/o having errors from PV1 & PV2 transformers (or having them combined).
    1. Created new transformer to handle all of the changes to the A17 message type:
    if(msg['MSH']['MSH.9']['MSH.9.2'].toString() == 'A17')
    {
    delete msg['MSH']['MSH.8']['MSH.8.1'];
    delete msg['MSH']['MSH.10']['MSH.10.1'];
    delete msg['MSH']['MSH.11']['MSH.11.1'];
    delete msg['MSH']['MSH.15']['MSH.15.1'];
    delete msg['MSH']['MSH.16']['MSH.16.1'];
    delete msg['MSH']['MSH.17']['MSH.17.1'];
    delete msg['EVN']['EVN.2']['EVN.2.1'];
    delete msg['EVN']['EVN.5'].toString();
    delete msg['EVN']['EVN.6']['EVN.6.1'];
    }

    if(msg['MSH']['MSH.9']['MSH.9.2'].toString() == 'A17')
    {
    for each(pid in msg.PID)
    {
    delete pid['PID.1']['PID.1.1'];
    delete pid['PID.4']['PID.4.1'];
    delete pid['PID.5']['PID.5.4'];
    delete pid['PID.5']['PID.5.5'];
    delete pid['PID.5']['PID.5.6'];
    delete pid['PID.5']['PID.5.7'];
    delete pid['PID.6']['PID.6.1'];
    delete pid['PID.9']['PID.9.1'];
    delete pid['PID.11']['PID.11.6'];
    delete pid['PID.11']['PID.11.7'];
    delete pid['PID.11']['PID.11.8'];
    delete pid['PID.11']['PID.11.9'];
    delete pid['PID.13']['PID.13.2'];
    delete pid['PID.13']['PID.13.3'];
    delete pid['PID.13']['PID.13.4'];
    delete pid['PID.20']['PID.20.1'];
    pid['PID.23']['PID.23.1'] = '';
    }
    (continued with very long PV1 & PV2 lists, both preceded with a for each statement)

    2. Added this
    if(msg['MSH']['MSH.9']['MSH.9.2'].toString() != 'A17')
    to my PV1 & PV2 transformers.

    Seems to work. Will move to Prod on Monday to find out for certain.
    ~Pmcnally

    Comment

    Working...
    X