TCL script

  • Creator
    Topic
  • #55613
    Albert Sinha
    Participant

    I am trying to change the MSH-4 to the value in the value 555011749

    I created the following script it is not working.  Help

    # Fix HEADER Albert

    proc tpsFixQuantros { 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

               #get the current message

               set msg [msgget $mh]

               set msg [replaceHL7Field $msg “MSH” “3” “555011749”]  

               msgset $mh $msg

               

               # Continue the message

               lappend dispList “CONTINUE $mh”   ;#continue the message

           

           }

           time {

               # Timer-based processing

               # N.B.: there may or may not be a MSGID key in args

           }

           shutdown {

               # Doing some clean-up work

           }

           default {

               error “Unknown mode ‘$mode’ in tpsFixQuantros”

           }

       }

       return $dispList

    }

Viewing 4 reply threads
  • Author
    Replies
    • #85892
      Jason Puskar
      Participant

      Hi,

         Quick question, why not do this in an xlate?  Seems straight forward enough to do it there no?

      Jay

    • #85893
      Albert Sinha
      Participant

      Everything else is in script in the facility, so I did not want to break the norm and create a xlate.

    • #85894
      Michael Hertel
      Participant

      This proc looks good to me.

      I don’t use replaceHL7Field so I don’t know if there is a syntax issue there.

      One thing you could try though is getting rid of the comments on the same line as commands in your run statement. Put them on their own line.

      There was an issue with this in the past.

      i.e., change:

      lappend dispList “CONTINUE $mh”

    • #85895
      Steve Williams
      Participant

      Hi Albert,

      I’ve never liked the genericHL7 tcl procs script as they contain bad coding practices that can give wrong results, just not work, or even more fun, toss errors. To use those procs, you really need to open them up and read them to understand their weaknesses.

      For example, your code works just fine when I tested it with an A07 message using the Vertical Pipe (|) as the field separator.

      Code:


      Output:
      MSH|^~{|EPIC|555011749|CLVR|CLVR|20170906123049|507|ADT^A07|108075|T|2.4
      EVN|A07|20170906123049||ADT_EVENT
      .
      .
      .


      When I ran it with another message using a different character for field separation, then script generates the following error:

      Code:


      [0:TEST] Tcl error:
      msgId = message0
      proc = ‘tpsFixQuantros’
      args = ”
      result = ‘list doesn’t contain element 3’
      errorInfo: ‘
      list doesn’t contain element 3
         while executing
      “lreplace $fieldList $fieldID $fieldID $data”
         (procedure “replaceHL7Field” line 8)
         invoked from within
      “replaceHL7Field $msg “MSH” “3” “555011749””
         (procedure “tpsFixQuantros” line 18)
         invoked from within
      “tpsFixQuantros {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}”‘

      Feel free to PM me if you want to dig deeper into this issue.

    • #85896
      Albert Sinha
      Participant

      I will try that

      Thanks again

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

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,293
Replies
34,435
Topic Tags
286
Empty Topic Tags
10