Announcement

Collapse

Mirth Connect 4.0.1 Released!

Mirth Connect 4.0.1 is now available as an appliance update and on our GitHub page. Mirth Connect 4.0.1 is a patch release containing a bug fix which includes fixing a Jetty keystore regression that caused Connect servers using a PKCS12 keystore containing a wildcard certificate and/or a certificate with a SAN to throw an exception on startup. 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

837s

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

  • 837s

    Trying to yank the data off the HI segment. Specifically, I'm trying to get the DRG right now, but I'm gonna have to pull the rest of the HI coding as my next step.

    The line is HI*DR:189~.

    How do you pull the 189 value from this using javascript?

    Is there something different about pulling the values after the colon? I originally tried segment['HI.02']['HI.02.1'] but that's not right.

    Suggestions?

    Thanks.

    Mike

  • #2
    You want to upload the channel and a sample message?

    Comment


    • #3
      Here's an extract from the data.

      HI*ABK:U071:::::::Y~
      HI*ABJ:R0603~
      HI*DR:177~
      HI*ABF:J1289:::::::Y*ABF:E039:::::::Y*ABF:M353:::: :::Y*ABF569:::::::Y*ABF:A499:::::::Y*ABF:E559::::: ::Y~

      Here's my current code, which is wrong...

      function HI(segment)
      {
      if (segment['HI.01']['HI.01.1'].toString() == 'DR')
      {
      m_DRG = segment['HI.02']['HI.02.1'].toString();
      m_CurrentLoop = '2300';
      }
      return true;
      }

      There must be some string manipulation that gets done in order to pull out the values after the colon (. Not sure how I'm supposed to access that data?

      Thanks.

      Mike

      Comment


      • #4
        Not sure how I'm supposed to access that data?
        That's why it would help if you could upload the message and export/upload the channel. There's several ways to access it using JavaScript but what data types are you working with and does the source message validate against the configured data types. If you're treating the whole message as RAW data, hence a string, then you could theoretically find the colons and grab the data that follows but I wouldn't recommend it. .indexOf() and .substr() / substring() methods can be used to traverse strings and grab data but it's not very efficient to try to process the whole data structure using those methods. If you want to upload the channel and a sample message, I'm happy to take a look at it.

        Comment


        • #5
          Something like this might work:

          Code:
          for each (seg in msg.children())
          { // using Iterate Over All Segment
                logger.error('outer = ' + seg.name().toString());
          if (seg.name().toString() == "HI")
          { // <--- using Iterate Over Segment
               var sample_value = seg['HI.01.1'].toString();
               logger.error('sample value = ' + sample_value); } }

          Comment


          • #6
            Thanks - wasn't moving down the segment correctly.

            Used your example and made this to loop through the HI segment - let me see where the values were sitting.

            for each (seg in segment.children())
            {
            logger.info("HI:" + seg.name() + " " + seg.toString() + "\r\n");
            }

            Then the DRG was here:

            m_DRG = segment['HI.01']['HI.01.2'].toString();

            Thanks again for the help.

            Mike

            Comment


            • #7
              mwellington42 Did you try putting a sample message in the inbound template of your transformer? That should allow you see the xml layout in the message tree and generate the correct code to access a given element if you drag and drop it from the tree.

              Comment

              Working...
              X