Announcement

Collapse
No announcement yet.

Multiple OBX to NTE segments

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

  • Multiple OBX to NTE segments

    I am trying to create a transformer that will move contents in OBX 5.1 to a new NTE segment and place 'See Results Below' in OBX 5.1. I've successfully created this if there is one OBX segment, but having multiple OBX segments creates problems. In the transformer I am also replacing /E/ with a page break.

    The problem I'm having is that the first OBX segment will be placed into two new NTE segments and the second OBX 5.1 segment is removed completely. I've tried a for each loop and I get the error:

    Assignment to lists with more than one item is not supported.

    I've attached the transformer I'm using

    ORIGINAL MESSAGE

    MSH|^~\&|TEST|TEST|TEST|TEST|20110901014240|TEST|O RU^R01|0000000|P|2.3
    PID|||930039^^^CHM||TEST^TEST^TEST||19980126|F|||1 01 TEST AVE^^TEST^TI^10125^US^^^TEST|TEST|^^^^^513^5461266 ||ENGLISH|^^||||||NON-HISPANIC||||||||N
    PD1||||00473^TESTS^TEST^^^^^TEST
    PV1||E|CCM EMERGENCY MED^B5^B5^10|Emergency|||03409^TEST^TEST^E.^^^^||7 0269^TEST^TEST^E.^^^^CHM~71604^TEST^TEST^^^^^|Emer gency Medicine||||EMERGENCY ROOM|||||512013881|||||||||||||||||HOME OR SELF CARE||||||||20110830100700|20110830121700
    OBR|1|512013881|512013881^TRANSCRIPTION|TRANSCRIPT ION^EDPCP|||20110901014200||||||||||||||||||F||^^^ 20110830000000|1134192057^TEST^TEST^W.^^^^NPI
    OBX|1|FT|160007802^ASAP PCP F/U VISIT RPT|1|TEST\E\.br\E\TEST||||||F
    OBX|2|FT|160007802^ASAP PCP F/U VISIT RPT|1|ANOTHERTEST\E\.br\E\ANOTHERTEST||||||F

    DESIRED RESULT


    MSH|^~\&|TEST|TEST|TEST|TEST|20110901014240|TEST|O RU^R01|0000000|P|2.3
    PID|||930039^^^CHM||TEST^TEST^TEST||19980126|F|||1 01 TEST AVE^^TEST^TI^10125^US^^^TEST|TEST|^^^^^513^5461266 ||ENGLISH|^^||||||NON-HISPANIC||||||||N
    PD1||||00473^TESTS^TEST^^^^^TEST
    PV1||E|CCM EMERGENCY MED^B5^B5^10|Emergency|||03409^TEST^TEST^E.^^^^||7 0269^TEST^TEST^E.^^^^CHM~71604^TEST^TEST^^^^^|Emer gency Medicine||||EMERGENCY ROOM|||||512013881|||||||||||||||||HOME OR SELF CARE||||||||20110830100700|20110830121700
    OBR|1|512013881|512013881^TRANSCRIPTION|TRANSCRIPT ION^EDPCP|||20110901014200||||||||||||||||||F||^^^ 20110830000000|1134192057^TEST^TEST^W.^^^^NPI
    OBX|1|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    OBX|2|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    NTE|||TEST\.br\TEST
    NTE|||ANOTHERTEST\.br\ANOTHERTEST


    What I'm Getting Now:

    MSH|^~\&|TEST|TEST|TEST|TEST|20110901014240|TEST|O RU^R01|0000000|P|2.3
    PID|||930039^^^CHM||TEST^TEST^TEST||19980126|F|||1 01 TEST AVE^^TEST^TI^10125^US^^^TEST|TEST|^^^^^513^5461266 ||ENGLISH|^^||||||NON-HISPANIC||||||||N
    PD1||||00473^TESTS^TEST^^^^^TEST
    PV1||E|CCM EMERGENCY MED^B5^B5^10|Emergency|||03409^TEST^TEST^E.^^^^||7 0269^TEST^TEST^E.^^^^CHM~71604^TEST^TEST^^^^^|Emer gency Medicine||||EMERGENCY ROOM|||||512013881|||||||||||||||||HOME OR SELF CARE||||||||20110830100700|20110830121700
    OBR|1|512013881|512013881^TRANSCRIPTION|TRANSCRIPT ION^EDPCP|||20110901014200||||||||||||||||||F||^^^ 20110830000000|1134192057^TEST^TEST^W.^^^^NPI
    OBX|1|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    OBX|2|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    NTE|||TEST\.br\TEST
    NTE|||TEST\.br\TEST

    TRANSFORMER:

    var newNTE = createSegment('NTE');


    if (msg['OBX']['OBX.5']['OBX.5.1'].toString().length > 2000)
    {
    for (i = 0; i < msg['OBX']['OBX.5'].length(); i++)
    {
    // msg['OBX'][i]['OBX.5']['OBX.5.1']= msg['OBX'][i]['OBX.5']['OBX.5.1'].toString().replace(/__________________________________________________ _________________________/g,'\\.br\\');
    msg['OBX'][i]['OBX.5']['OBX.5.1']= msg['OBX'][i]['OBX.5']['OBX.5.1'].toString().replace(/\\E\\.br\\E\\/g,'\\.br\\');
    //msg['OBX'][i]['OBX.5']['OBX.5.1']= msg['OBX'][i]['OBX.5']['OBX.5.1'].toString().replace(/\\E\\.br\\E\\/g,"");
    newNTE['NTE.3'] += msg['OBX'][i]['OBX.5']['OBX.5.1'].toString();
    msg['OBX'][i]['OBX.5']['OBX.5.1'] ='See Results Below';
    msg['OBX'] +=newNTE;

    }
    }

    Thanks.
    Last edited by tlonneman; 01-26-2012, 06:12 AM.

  • #2
    Getting closer. This is what I'm getting now. From the original message above, this is the transformed message:

    NEW MESSAGE

    MSH|^~\&|TEST|TEST|TEST|TEST|20110901014240|TEST|O RU^R01|0000000|P|2.3
    PID|||930039^^^CHM||TEST^TEST^TEST||19980126|F|||1 01 TEST AVE^^TEST^TI^10125^US^^^TEST|TEST|^^^^^513^5461266 ||ENGLISH|^^||||||NON-HISPANIC||||||||N
    PD1||||00473^TESTS^TEST^^^^^TEST
    PV1||E|CCM EMERGENCY MED^B5^B5^10|Emergency|||03409^TEST^TEST^E.^^^^||7 0269^TEST^TEST^E.^^^^CHM~71604^TEST^TEST^^^^^|Emer gency Medicine||||EMERGENCY ROOM|||||512013881|||||||||||||||||HOME OR SELF CARE||||||||20110830100700|20110830121700
    OBR|1|512013881|512013881^TRANSCRIPTION|TRANSCRIPT ION^EDPCP|||20110901014200||||||||||||||||||F||^^^ 20110830000000|1134192057^TEST^TEST^W.^^^^NPI
    OBX|1|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    NTE|||TEST\.br\TEST
    OBX|2|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    NTE|||ANOTHERTEST\.br\ANOTHERTEST

    I've tried to get both NTE segments to be placed below both OBX segments and can't figure it out. I want this to be the message:
    DESIRED RESULT

    MSH|^~\&|TEST|TEST|TEST|TEST|20110901014240|TEST|O RU^R01|0000000|P|2.3
    PID|||930039^^^CHM||TEST^TEST^TEST||19980126|F|||1 01 TEST AVE^^TEST^TI^10125^US^^^TEST|TEST|^^^^^513^5461266 ||ENGLISH|^^||||||NON-HISPANIC||||||||N
    PD1||||00473^TESTS^TEST^^^^^TEST
    PV1||E|CCM EMERGENCY MED^B5^B5^10|Emergency|||03409^TEST^TEST^E.^^^^||7 0269^TEST^TEST^E.^^^^CHM~71604^TEST^TEST^^^^^|Emer gency Medicine||||EMERGENCY ROOM|||||512013881|||||||||||||||||HOME OR SELF CARE||||||||20110830100700|20110830121700
    OBR|1|512013881|512013881^TRANSCRIPTION|TRANSCRIPT ION^EDPCP|||20110901014200||||||||||||||||||F||^^^ 20110830000000|1134192057^TEST^TEST^W.^^^^NPI
    OBX|1|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    OBX|2|FT|160007802^ASAP PCP F/U VISIT RPT|1|See Results Below||||||F
    NTE|||TEST\.br\TEST
    NTE|||ANOTHERTEST\.br\ANOTHERTEST


    This is the code I'm using which I grabbed from the forums here:

    for (var i = 0; i <= msg.elements('OBX').length()-1; i++)
    {
    var NTE = <NTE/>;
    msg['OBX'][i]['OBX.5']['OBX.5.1']= msg['OBX'][i]['OBX.5']['OBX.5.1'].toString().replace(/\\E\\.br\\E\\/g,'\\.br\\');
    NTE['NTE.3']['NTE.3.1'] = msg['OBX'][i]['OBX.5']['OBX.5.1'].toString();
    msg['OBX'][i]['OBX.5']['OBX.5.1'] ='See Results Below';
    msg['OBX'][i] += NTE ;
    }

    Comment


    • #3
      Try this:

      Code:
      for each (obx in msg.OBX) {
      	var nte = <NTE/>;
      	nte['NTE.3']['NTE.3.1'] = obx['OBX.5']['OBX.5.1'].toString().replace(/\\E\\\.br\\E\\/,'\\.br\\');
      	delete obx['OBX.5']['OBX.5.1'];
      	msg.appendChild(nte);
      }
      Feel free to add onto it for the NTE.1 set IDs, etc. Also, I noticed that you were missing a backslash in your replace method; it still technically worked though, because a period represents any single character. Anyway, hope that helps!
      Last edited by narupley; 01-26-2012, 08:19 AM.
      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.

      Comment


      • #4
        The given code works but how do i rewrite it in-case if i want a NTE segment in place of OBX segment deleted.
        Just need to retain the first occurrence of OBX segment in a message.

        Comment


        • #5
          Originally posted by satishs View Post
          The given code works but how do i rewrite it in-case if i want a NTE segment in place of OBX segment deleted.
          Just need to retain the first occurrence of OBX segment in a message.
          See here...
          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.

          Comment

          Working...
          X