Announcement

Collapse
No announcement yet.

mapping help, convert HL7 datetime to SOAP dateTime

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

  • mapping help, convert HL7 datetime to SOAP dateTime

    I am setting up Mirth to catch scheduling messages and update an ancilliary system with a SOAP call. It gets the HL7 message, picks out what I need and makes the SOAP call just fine. The problem is that I need to covert the HL7 date to the SOAP date format.

    HL7 is YYYYMMDDHHMMSS

    SOAP is [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]

    My current mapping code is:
    Code:
    var startdate = msg['SCH']['SCH.11']['TQ.4']['TS.1'].toString()
    var outdate = '';
    //4 year
    
    outdate += startdate.substr(0,3) + '-';
    //2 month
    
    outdate += startdate.substr(4,5) + '-';
    //2 day
    
    outdate += startdate.substr(6,7) + 'T';
    //2 hour
    
    outdate += startdate.substr(8,9) + ':';
    //2 minute
    
    outdate += startdate.substr(10,11) + ':';
    //2 second
    
    outdate += startdate.substr(12,13);
    
    //[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]
    localMap.put('start', outdate);
    I know I'm close, but I suspect I'm missing something basic about how Mirth expects the Mapping to be formed and how it actually gets data out of that. I get errors at the server from the javascript parser.
    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.

  • #2
    Re: mapping help, convert HL7 datetime to SOAP dateTime

    The problem most likely is that you are using .substr() like .substring(). With .substring() the parameters are first index and end index (not including end index). With .substr() the parameters are first index and then the end index. It seems to me you may want to try substring().

    Comment


    • #3
      Re: mapping help, convert HL7 datetime to SOAP dateTime

      Thanks, I haven't used much JavaScript.

      Is the localMap.put() the correct way to expose the data so that Mirth can map it?
      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


      • #4
        Re: mapping help, convert HL7 datetime to SOAP dateTime

        ooh. It was barfing on the JScript because I forgot a semicolon on line 1.

        I would still like to know what the correct use/API of localMap is. If someone could clarify that I'll tidy up the response and toss it into the Wiki.
        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


        • #5
          Re: mapping help, convert HL7 datetime to SOAP dateTime

          Jon -

          Your usage of the localMap is correct (.put(key, value) or .get(key)).

          As far as date formatting, you can use any JAVA class in your Javascript. This is how we internally format dates

          Code:
          var rawdate = msg['SCH']['SCH.11']['TQ.4']['TS.1'];
          
          var formatter = java.text.SimpleDateFormat("yyyyMMddhhmm");
          var date = formatter.parse(rawdate);
          
          formatter = java.text.SimpleDateFormat("h:mm aaa");
          var pretty_time = formatter.format(date);
          localMap.put('pretty_time',pretty_time);
          The first simpleDateFormat takes a string that defines the incoming format of the date from HL7 and creates a JAVA date object. The next formatter defines the output format we want.

          Your method works well though and prevents the overhead of Java classloading.

          -Chris
          Chris Lang

          Comment

          Working...
          X