Email within TCL proc

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Email within TCL proc

  • Creator
    Topic
  • #54616
    Laurie Heineman
    Participant

      We have created a tcl proc which will notify our users the number of charges that have been processed for the day.  We created the proc using an argument so we can list several email addresses.  

         keylget args ARGS.TO to

         keylget args ARGS.CC cc

         keylget args ARGS.DEPT dept

         keylget args ARGS.FROM from

         keylget args ARGS.TITLE title

      {TO testhisout@uchc.edu} {CC testccout@uchc.edu} {DEPT pharm_TEST} {FROM ITCloverpharmCharge@uchc.edu} {TITLE 2}

      The email is working but it seems we can only use one email address for to and cc.  We have tried to use quotes, and acutally set variable to “testthisout@uchc.edu;testccout@uchc.edu” which only sends the email to the second email address.  What are we missing?

      Thanks,

      Laurie

    Viewing 5 reply threads
    • Author
      Replies
      • #82231
        David Barr
        Participant

          Without seeing how the proc is sending the email I couldn’t say. You’ve shown how the parameters are passed into your proc, but you’re not showing how the parameters are sent to the commands that send the email.

        • #82232
          Laurie Heineman
          Participant

            Hi David,

            Here is part of the code. I hope this is what you need.

            Thanks, Laurie

            set body “$body”

                                     

                                     echo nEMAIL MESSAGE: $bodyn

                                           #Sending the email

                                            set cmd “exec cmd /C C:/blat/blat.exe -body $body -to $to -cc $cc -f $from -subject $subject -server $server”

                              echo “++++++++++++++++++++++++++++++++++++++++++++Counter File Email ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”

                                           

                           

            if {[catch $cmd result]} {

                              echo “ERROR: An error occurred running “$cmd”.”

                                 echo ”     Result was: $result”

                              }

                                         

                                 echo “~~~~~~~~~~~~~~~~~~~~~~~ Done sending the counts to Radiology ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~”

          • #82233
            David Barr
            Participant

              Here’s the syntax for Blat: http://www.blat.net/syntax/syntax.html

              The “-to” parameter is supposed to be comma separated, so you could try that.

            • #82234
              Russ Ross
              Participant

                We use sendmail instead of blat but do send to multiple email address using a comma separator between each email address without any white space, unless you double quote them.

                for example:

                Code:

                7134049833@archwireless.net,rross@mdanderson.org

                or

                Code:

                “7134049833@archwireless.net, rross@mdanderson.org”

                the underscored email address is superimposed formatting beyond my control that obviously doesn’t exist in what I typed.

                Russ Ross
                RussRoss318@gmail.com

              • #82235
                Brandon Grudt
                Participant

                  As others have indicated, the addresses should be comma separated.  That SHOULD work.  

                  Here are our ARGS –

                  Quote:

                  {SEGNAME PID} {FIELDNUM 18} {SUBFIELDNUM 0} {RECIPIENTS {brandon.grudt@memorialhosp.org,other.user@memorialhosp.org}} {VALUE ENCOUNTER} {ACTION CONTINUE}

                  Here is a working email proc that we have in place –

                  Code:

                  ######################################################################
                  # Name:     gbl_email_blank_subfield.tcl
                  #
                  # Purpose:  EMAIL recipients if a subfield is blank
                  #
                  # Author: Brandon Grudt
                  # Memorial Hospital of Union County
                  # brandon.grudt@memorialhosp.org
                  #
                  # Args: SEGNAME – Name of segment
                  # FIELDNUM – Number of field
                  # SUBFIELDNUM – Number of subfield
                  # RECIPIENTS – Comma separated list of emails
                  # VALUE – Value of the blank subfield (ie. MRN, Encounter, etc.)
                  # ACTION – Either KILL or CONTINUE
                  #
                  # File History:
                  #
                  # 1.0 4/26/2014 Brandon Grudt Initial release
                  # 1.1 1/28/15 Brandon Grudt Added KILL or CONTINUE switch
                  #
                  ######################################################################
                  proc gbl_email_blank_subfield { args } {
                     keylget args MODE mode                      ;# Fetch mode
                     global HciConnName
                     set dispList {}                            
                     switch -exact — $mode {
                         start {
                         }
                        run {
                        catch {
                            keylget args MSGID mh
                            set msg [msgget $mh]
                  ######################################################################
                  # Set vars and create required folders
                  ######################################################################
                  set date [clock format [clock seconds] -format {%Y%m%d}]
                  set thread UNKNOWN
                  set thread $HciConnName
                  set segname {}
                            keylget args ARGS.SEGNAME segname
                          set fieldnum {}
                            keylget args ARGS.FIELDNUM fieldnum
                  if { $segname eq {MSH} } {
                  incr fieldnum -1
                  }
                            set subfieldnum {}
                            keylget args ARGS.SUBFIELDNUM subfieldnum
                            set recipients {}
                            keylget args ARGS.RECIPIENTS recipients
                            set value {}
                            keylget args ARGS.VALUE value
                  set action {}
                            keylget args ARGS.ACTION action
                            set sep [csubstr $msg 3 1]
                          set sub [csubstr $msg 4 1]
                            set rep [csubstr $msg 5 1]
                  set segments [split $msg r]
                  set system {}
                  set disp CONTINUE
                  ######################################################################
                  # Start of auditing
                  ######################################################################
                  set var [lindex [split [lindex [split [lsearch -inline -all -regexp $segments ^$segname] $sep] $fieldnum] $sub] $subfieldnum]
                  set mrn [lindex [split [lindex [split [lsearch -inline -all -regexp $segments ^PID] $sep] 3] $sub] 0]
                  set system [lindex [split [lindex [split [lsearch -inline -all -regexp $segments ^MSH] $sep] 3] $sub] 0]
                  set encounter [lindex [split [lindex [split [lsearch -inline -all -regexp $segments ^PID] $sep] 18] $sub] 0]
                  ######################################################################
                  # Email
                  ######################################################################
                  if { [string length $var] < 1 } {
                  set disp $action
                  package require smtp
                          package require mime
                            set token [mime::initialize -canonical text/plain -string "PWIM has detected that a message has been submitted that is missing a required element – $value.rrSYSTEM:t$systemrMRN:tt$mrnrVISIT:tt$encounter"]
                          mime::setheader $token Subject "$value VALUE MISSING"
                            smtp::sendmessage $token
                                    -originator "PWIM_ALERT@memorialhosp.org" -recipients "$recipients" -servers MHUC177v
                            mime::finalize $token
                  }
                        }
                  return "{$disp $mh}"
                        }
                      }
                  }

                  [/quote]

                • #82236
                  Laurie Heineman
                  Participant

                    Thanks for your help, it works with the comma seperator.

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