Announcement

Collapse
No announcement yet.

Repeating Field Approach

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

  • Repeating Field Approach

    Hi all,

    I am seeking the best approach to decompose a repeating field,
    in particular PID.13 which could contain the home_phone, cell_phone,
    and pager_number in a string such as this:
    123-4567^^^[email protected]^^^1234567^^FIX~262-9999^^^^^^2629999^^PAG~262-8888^^^^^^2628888^^CEL

    The phone type is specified by the string (FIX, PAG or CEL).
    I have to know the type of the field before I can assign
    it via a transformer to a db field.

    Do I need a filter or something else?

    Cheers,
    Youssef

  • #2
    I have the need to do similar mapping. I was looking for a Javascript solution.
    I am familiar with HL7 and interface engines but new to Mirth and Javascript.

    I am normally getting Home Phone in the first repeat of PID 13. (PID 13.3 = HP) , the email address(PID 13.4), cell phone(PID13.1) or secondary phone(PID13.1) could be in any of the other PID 13 repeats of which there could be onbly 1 or 2 or 3 or maybe even 4 ??
    ( PID 13.3 = 'MO' for Mobile phone and PID 13.3 = 'Internet' for email address, PID 13.3 = 'OP' for Other Phone)

    My thought was to have if, then else logic for each repeat, in PID 13.

    something like logic such as:

    If ['PID']['PID.13'][0]['PID.13.3'] = 'HP' then map ['PID']['PID.13'][0]['PID.13.1'] to HomePhone.
    else map to ""

    if ['PID']['PID.13'][1]['PID.13.3'] = 'MO' then map ['PID']['PID.13'][1]['PID.13.1'] to Cell Number
    else
    if ['PID']['PID.13'][2]['PID.13.3'] = 'MO' then map ['PID']['PID.13'][2]['PID.13.1'] to Cell Number
    else map to ""

    If if ['PID']['PID.13'][1]['PID.13.3'] = 'Internet' then map ['PID']['PID.13'][1]['PID.13.4'] to Email address.
    else
    If ['PID']['PID.13'][2]['PID.13.3'] = 'Internet' then map ['PID']['PID.13'][2]['PID.13.4'] to Email address
    else map to ""


    So basically there could be only 1 phone# in PID 13, but possible to have 2, 3 or possibly even 4 repeats of PID 13.
    with phone #'s in PID 13.1 and email address in PID 13.4 just need to figure out which repeat has what data.

    If the value doesn't exist then map do not map anything.

    So that is why I thought could check PID 13.3 of each repeat and if it finds one of the expected values (HP, MO, Internet or OP) then map the value in 13.1 (or 13.4 for email) to appropriate db field. If not found then do not map anything.

    Hopefully I am on the right track and someone can advise on the Javascript syntax.

    thanks in advance to anyone who can point me in the right direction.

    Here is an example of PID 13 with 3 repeats:

    |(800)555-1212^P^HP^^^800^5551212~^NET^Internet^[email protected] .com~(456)123-7891^P^MO^^^456^1237891|
    Last edited by cactuspete; 09-08-2014, 02:42 PM. Reason: add example field.

    Comment


    • #3
      try something like:

      var arrContact = msg['PID']['PID.13']['PID.13.3'].toString().split('~');

      for each (contact in arrContact) {
      var contactFlds = contact.split('^');
      switch(contactFlds[2]) {
      case "HP":
      //do whatever here
      break;
      case "MO":
      //do whatever here
      break;
      case "Internet":
      //do whatever here
      break;
      default:
      //do this if no matches above
      }
      }

      see the following references:

      http://www.w3schools.com/jsref/jsref_split.asp
      http://www.w3schools.com/js/js_switch.asp

      Hope this helps....

      Comment


      • #4
        Thanks for the response, I will try taking a look at that method and the links.

        I was thinking it isn't or wouldn't be necessary to do a string split on the ~ character as that is the repeat delimiter and with the Message Template properties set to 'parse field repetitions' for this channel.

        Without the 'parse field repetitions' checked then I agree the string split idea makes sense. I was hoping to use or take advantage of the option to parse field repetitions in Mirth.

        Comment


        • #5
          Sorry, misread and thought you wanted to parse that string and for some reason the repeating field didn't register.

          instead of the split, just loop the msg['PID']['PID.13']

          for each (contact in msg['PID']['PID.13']) {

          switch(contact['PID.13.3]) {
          case "HP":
          //do whatever here
          break;
          case "MO":
          //do whatever here
          break;
          case "Internet":
          //do whatever here
          break;
          default:
          //do this if no matches above
          }
          }
          Last edited by Noggin; 09-10-2014, 01:17 PM.

          Comment


          • #6
            Thanks, most appreciated I will give that a try when time permits

            Comment

            Working...
            X