Announcement

Collapse
No announcement yet.

Using rememberd matches.

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

  • Using rememberd matches.

    I'm using the following code in a javascript transformer step. I'm trying to parse the date of birth and format it. The problem I'm having is the use of the remembered portions of the match, for some reason they expand to an empty string. The value in dob is correct because I'm temporarily prepending it for debugging and it shows up.

    Code:
    if( msg['PID']['PID.7']['PID.7.1'] != null &&
        msg['PID']['PID.7']['PID.7.1'].toString() != null){
      var dob = msg['PID']['PID.7']['PID.7.1'].toString();
      var junk = dob.match(/(dddd)(dd)(dd)/);
      channelMap.put("usrBirthDateFmt",
    	dob + '/'+RegExp.$2 + '-' + RegExp.$3 + '-' + RegExp.$1 );
    }

  • #2
    Re:Using rememberd matches.

    Found the problem, it was with the pattern used in the matching. It should have been /(/d/d/d/d)(/d/d)(/d/d)/

    Comment


    • #3
      Re:Using rememberd matches.

      Ah, glad it's working!

      Post edited by: chrisl, at: 08/20/2007 13:38
      Chris Lang

      Comment


      • #4
        Re:Using rememberd matches.

        Why don't you just use the Convert Date function from the reference list?
        Brendan Haverlock | Mirth Software Engineer | Mirth Corporation

        Comment


        • #5
          Re:Using rememberd matches.

          wmsTrebor wrote:
          Found the problem, it was with the pattern used in the matching. It should have been /(/d/d/d/d)(/d/d)(/d/d)/
          /(/d{4})(/d{2})(/d{2})/ should work too
          /(/d{4})(/d{2}){2}/ might also work, not sure how that last group will come out though

          brendanh wrote:
          Why don't you just use the Convert Date function from the reference list?
          I'm half-joking here, but how is one supposed to know what to pass in as arguments to this method?
          Code:
          var datestring = DateUtil.convertDate(inpattern, outpattern, date);
          Could the reference functions be updated to look like this:
          Code:
          //Reference: [url]http://mirthproject.com/documents/reference/js/dateutil#convertDate[/url]
          var datestring = DateUtil.convertDate(inpattern, outpattern, date);
          Jon Bartels

          Zen is hiring!!!!
          http://consultzen.com/careers/
          Talented healthcare IT professionals wanted. Engineers to sales to management.
          Good benefits, great working environment, genuinely interesting work.

          Comment


          • #6
            Re:Using rememberd matches.

            That's a good idea. Would you prefer a link or in-line documentation for each function?

            We're working on docs, promise!
            Chris Lang

            Comment


            • #7
              Re:Using rememberd matches.

              chrisl wrote:
              That's a good idea. Would you prefer a link or in-line documentation for each function?

              We're working on docs, promise!
              IMHO a link *to the version of the libraries that Mirth is using* would be best. That way it goes right to the full spec and you won't have to deal with version conflicts.
              Something like: http://mirthproject.org/docs/1.6/js/somemethodname .

              It'll save you some time too, that way you won't have to regenerate docs for outside libraries that Mirth just happens to use.

              Sorry for the hijack!
              Jon Bartels

              Zen is hiring!!!!
              http://consultzen.com/careers/
              Talented healthcare IT professionals wanted. Engineers to sales to management.
              Good benefits, great working environment, genuinely interesting work.

              Comment

              Working...
              X