How to Generate a Message control ID

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf How to Generate a Message control ID

  • Creator
    Topic
  • #49742
    Hongle Sun
    Participant

      Is there any ways to generate a Message Control ID in MSH10 while inbound message hits the interface eninge, the reason is the inbound system doesnot have a msg control id in it? Thanks

    Viewing 7 reply threads
    • Author
      Replies
      • #63362

        Hongle Sun wrote:

        Is there any ways to generate a Message Control ID in MSH10 while inbound message hits the interface eninge, the reason is the inbound system doesnot have a msg control id in it? Thanks

        Here is one way …

        Code:


        … code …

        # Get the message ID
        set midList [msgmetaget $mh MID]
        keylget midList NUM mid

        set msgId $timeStamp$mid

        … code …

        -- Max Drown (Infor)

      • #63363
        Hongle Sun
        Participant

          Thank but how can i incoprate into my xlate? Please explain. thanks gain

        • #63364

          Good question. I’m not sure how to get the mh/mid from an xlt fragment; however, you could set it in a pre or post proc using the code above.

          -- Max Drown (Infor)

        • #63365

          Here is an example post-proc you could try. You’ll need to add the code that actually changes the field in the hl7 message.

          Code:


          ######################################################################
          # Name: tps_setMsgId
          # Purpose:
          # UPoC type: tps
          # Args: tps keyedlist containing the following keys:
          #       MODE    run mode (”start”, “run” or “time”)
          #       MSGID   message handle
          #       ARGS    user-supplied arguments:
          #              
          #
          # Returns: tps disposition list:
          #          

          #

          proc tps_setMsgId { args } {
             keylget args MODE mode               ;# Fetch mode

             set dispList {} ;# Nothing to return

             switch -exact — $mode {
                 start {
                     # Perform special init functions
                     # N.B.: there may or may not be a MSGID key in args
                 }

                 run {
                     # ‘run’ mode always has a MSGID; fetch and process it
                     keylget args MSGID mh

                     set messageTs [clock format [clock seconds] -format %Y%m%d%H%M%S]

                     # Get the Cloverleaf message ID (mid)
                     set midList [msgmetaget $mh MID]
                     keylget midList NUM mid

                     puts “MSH.10: $mid$messageTs”

                     lappend dispList “CONTINUE $mh”
                 }

                 time {
                     # Timer-based processing
                     # N.B.: there may or may not be a MSGID key in args
                 }
                 
                 shutdown {
                     # Doing some clean-up work
          }
             }

             return $dispList
          }

          -- Max Drown (Infor)

        • #63366
          Charlie Bursell
          Participant

            Max:

            To get MID in Xlate:

            set klst [msgmetaget $xlateId MID]

            set MID [keylget klst NUM]

            But I would use a counter to build a Message Control ID

          • #63367
            Steve Pringle
            Participant

              Charlie,

              Why use a counter instead of the approach Max proposed?

              The engine uses some sort of internal counter for the NUM component of the msgMid, no?

              Plus, using a counter implies you have now performed a read/write disk io.  

              Or maybe you’re thinking of a tcl variable that gets incremented as needed?

              Seem more efficient to use Max’s approach.

              Curious minds…

              thanks,

              Steve

            • #63368
              James Cobane
              Participant

                Depending on the receiving system, they may expect a sequential Control ID, or you may want to have a unique counter related to the specific interface.  Lots of reasons to do it either way, but the right way is whichever best meets the need… 🙂

                Jim Cobane

                Henry Ford Health

              • #63369
                Highland Dave
                Participant

                  I could not get this to work as

                  set klst [msgmetaget $xlateId MID]

                  set MID [keylget klst NUM]

                  received the following error

                  [xlt :xlat:ERR /0:initiate_xlate:08/04/2010 15:14:08] [0.0.1083320] Xlate ‘InitiateA30ToCe.xlt’ failed: Tcl callout error

                  erroCode: NONE

                  errorInfo:

                  bad msgId “xpm0”

                     while executing

                  “msgmetaget $xlateId MID”

                  I changed the xlate to use:

                  set klst [xpmmetaget $xlateId MID]

                  set MID [keylget klst NUM]

                  no errors and a display shows:

                  +++DEBUG  the metadata MID value is 1083391

                  +++DEBUG  the metadata MID value is 1083393

                  +++DEBUG  the metadata MID value is 1083395

                  +++DEBUG  the metadata MID value is 1083397

                  +++DEBUG  the metadata MID value is 1083399

                  +++DEBUG  the metadata MID value is 1083401

                  +++DEBUG  the metadata MID value is 1083403

                  I do not need a sequential value, I just need a unique ID when sending the merge message to GE Centricity Enterprise.   So, it’s like the previous post, what works best for the situation and done in the GUI.

              Viewing 7 reply threads
              • The forum ‘Cloverleaf’ is closed to new topics and replies.