Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Javascript Help!

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

  • Javascript Help!

    I'm trying to accomplish padding PID3 with zeros when PID3 is less than 8 digits in length. Ultimately the MRN field should always be 8char

    Here's the code that I'm struggling with. When ran the variable "val" is not recognized.

    //Pad with 0's
    function padleft(val, ch, num) {
    var re = new RegExp(".{" + 8 + "}$");
    var pad = "";
    var val = msg['PID']['PID.3']['PID.3.1'].toString();
    }
    if (val.length < 8)
    do {
    pad += 0;
    }while(pad.length < 8);

    return re.exec(pad + val);

    SAMPLE MSG:
    MSH|^~\&|ONLINE_ORDERS|WMH|||20080104171437||ORM^O 01|1|P|2.3|||NE|NE
    PID|||909-2||TEST^JACK|||||B|123 B STREET^^INDIANAPOLIS^IN^46202||()||||||999-99-9999
    PV1||I|4N^^W4112A|||MED1^^W4112A
    ORC|NW|D527-1^GPHI|||||||20080104171437|10083-4||10083-4^WARVEL^JACK^^^^^^^^4^^DN
    OBR|002|D527-1^GPHI||12236^CALCIUM^STAR||20080104171256|||||||| ||10083-4^WARVEL^JACK^^^^^^^^4^^DN||||||||T|||QAM|||||1008 3-4
    NTE|003||QAM

    Thanks,
    D

  • #2
    Re:Javascript Help!

    Try:

    Code:
    var padleft=function(val, ch, num) {
       var re = new RegExp(".{" + 8 + "}$"«»);
       var pad = "";
       var val = msg['PID']['PID.3']['PID.3.1'].toString();
       if (val.length < 8)
       do {
         pad += 0;
       }while(pad.length < 8);
       return re.exec(pad + val);
    }

    Comment


    • #3
      Re:Javascript Help!

      How would you return this padded value to a variable?

      Comment

      Working...
      X