Announcement

Collapse

Mirth Connect 4.3.0 Released!

Mirth Connect 4.3.0 is now available as an appliance update and on our GitHub page.

This is a major release containing new features like adding new functionality to the Mirth Connect Setup Wizard, adding the ability for resource and channel-specific classloaders to load child-first or parent-first, and added a default implementation of the getObjectsForSwaggerExamples() method in the ServicePlugin class. This release also contains enhancements for the Mirth Connect Administrator Launcher, the Mirth Connect Docker images, and several bug fixes and security improvements.

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