Emailing errors

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Emailing errors

  • Creator
    Topic
  • #51988
    Kevin Crist
    Participant

      We are on CL 5.4.1. Does anyone do anything with emailing errors to certain people straight from the engine, not necassirly alerts though. We have an app that we are going to kill updates to charge codes. But the person wants the message so they can change one field. Is there a way to do that? Kill a messages based on criteria and send it straight in an email with tcl?

    Viewing 11 reply threads
    • Author
      Replies
      • #72598
        Jim Kosloskey
        Participant

          Yes, the email method you use depends on your system.

          We do not do that with KILLing messages, but we do it with our ODBC when we have a connection problem or a problem reported back by the Stored Procedure we invoke.

          However, there is no reason that cannot be done when filtering messages in Tcl (pre-route for example) or even inside the Xlate if you wanted to.

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #72599
          James Cobane
          Participant

            We do this for several of our interfaces; when we receive a NAK for a message, we’ll send an e-mail for the NAK’d message with the specifics from the message to a designated recipient.

            Jim Cobane

            Henry Ford Health

          • #72600
            Kevin Crist
            Participant

              interesting. Thank guys. Is there a special tcl code to use for emailing that you put in a proc?

            • #72601
              Russ Ross
              Participant

                There might be some TCL curl stuff for email but we have been using the UNIX/AIX sendmail command and calling it from TCL using either exec or system.

                Here is an example using the TCL exec command:

                Code:

                      if {[catch [exec —  echo “Subject: $email_subject\n.” | sendmail $email_addresses] cerr]} {
                        # put error messages into the process standard log
                          echo “$module ERROR: *****************************************************”
                          echo “$module ERROR: email/Page attempt of:”
                          echo “$module ERROR:   >$email_subject$email_addresses$email_subject$email_addresses<"
                          puts stderr "$module ERROR: failed!"
                          flush stderr
                          return $msgval
                      }

                Here is an example using the TCL system command:

                Code:

                system “echo “Subject: $email_subject\n.” | sendmail $email_addresses”

                I also did a little clovertech search and found this URL to get you started on the path

                    <span style="color: red]https://usspvlclovertch2.infor.com/viewtopic.php?t=3251&highlight=sendmail%5B/url%5D%5B/color%5D

                This URL also has an example of using the tclMail pakage that I think is part of TCL curl I was referring to earlier.

                Russ Ross
                RussRoss318@gmail.com

              • #72602
                Kevin Crist
                Participant

                  Sweet. Thanks for your time and pointing me in the right direction. Let the fun begin.

                • #72603
                  David Barr
                  Participant

                    Here’s another way to send e-mail from TCL.  This will let you add file attachments.  We’re also using Ghostscript to change a Postscript attachment to PDF before we send it.

                    Code:

                    proc penrad_cmax_mail { psmsg body } {
                       package require mime
                       package require smtp

                       set fp [open report.ps w]
                       puts -nonewline $fp $psmsg
                       close $fp
                       exec ksh -c “unset SHLIB_PATH; gs -sDEVICE=pdfwrite -sOutputFile=report.pdf report.ps < /dev/null"
                       set psmsg [read_file report.pdf]

                       # create an image and text
                       set psT [mime::initialize -canonical
                                    "application/pdf; name="report.pdf"" -string $psmsg]
                       set textT [mime::initialize -canonical text/plain -string $body]

                       # create a multipart containing both, and a timestamp
                       set multiT [mime::initialize -canonical multipart/mixed
                                       -parts [list $psT $textT]]

                       # call Sendmail to deliver the message
                       set rcpt [list "zzzzz@valleymed.org" "xxxxx@valleymed.org" "david_barr@valleymed.org"]
                       set rcpt2 [join $rcpt " "]
                       set fp [open "|/usr/sbin/sendmail $rcpt2" w]
                       puts $fp "To: [join $rcpt ,]"
                       puts $fp "From: "VMC.QDX Integrator production mode." ”
                       puts $fp “Subject: error processing report from Penrad”
                       #Date: Wed, 02 Mar 2008 16:34:00 -0700
                       puts $fp [::mime::buildmessage $multiT]
                       close $fp

                    # The following code works from a standalone script, but not from
                    # within a cloverleaf process.  In the future, I’d like to try to get
                    # this working.
                    #
                    #     smtp::sendmessage $multiT
                    #       -header [list To “David_Barr@valleymed.org”]
                    #       -header [list Subject “error processing report from Penrad”]
                    #       -servers { borderware.valleymed.net }
                       #    -header [list From “David_Barr@valleymed.org”]

                    }

                  • #72604
                    Kevin Crist
                    Participant

                      Thanks all. I actually got this working, pretty cool. But i have one more question…since these are charge codes that come from our patient accts, at the end of year they send out lots of changes, maybe in the thousands, will this cause any performance issues sending out many emails like this? This only happens at year end and the rest of the time they just trickle down.

                    • #72605
                      Scott Folley
                      Participant

                        Kevin Crist wrote:

                        Thanks all. I actually got this working, pretty cool. But i have one more question…since these are charge codes that come from our patient accts, at the end of year they send out lots of changes, maybe in the thousands, will this cause any performance issues sending out many emails like this? This only happens at year end and the rest of the time they just trickle down.

                        You are likely, at those times, to experience a myriad of issues.  First your email server is likely to trash those messages thinking that they are spam.  Second, you ARE going to experience a significant increase in overhead on your system.  Cloverleaf will likely handle this just fine because it is handing it off to the mail system but you are going to be sending out messages so fast that you may well run out of ephemeral ports.  On most systems the number of ephemeral ports available is roughly 32,768.  Sending mail is basically equivalent to opening up a telnet session so for each message you are going to use an ephemeral port to connect to the mail server.  When you disconnect, those ports are going to sit in a “TIME_WAIT” state until the proper network ACK’ing and NAK’ing takes place to permanently close the connection.  This happens pretty fast but could become the weak link in your chain.  There are a lot of planets that would have to line up just right for this to be a major problem but, that said, there are a lot of planets involved in this scenario and it is my belief that you WILL experience a problem.  Either you will reach the limit of the number of subprocesses that you can spawn or you will negatively impact your production system.

                        Just my 0.02

                      • #72606
                        Kevin Crist
                        Participant

                          Sorry to rehash this older thread but it serves as relevance.

                          Below is what i ended up using for emailing from the engine and it works great on unix. Anyone know what it should be for Linux? Our new version is on RHLinux and having issues with it.

                          catch [exec << $EmailMsg mailx -s $EmailSub $Emails]

                          thanks.

                        • #72607
                          Terry Kellum
                          Participant

                            Just did a quick tclsh.

                            exec mailx -s $EmailSub $Emails << $EmailMsg

                          • #72608
                            Jeff Dinsmore
                            Participant

                              David,

                              Here’s how I send with Tcl’s mime/smtp tools…

                              After you’ve built your message:

                              Code:


                              set recipientList [list bob@fred.com jeff@fred.com]

                              set smtpSnd cloverleaf@fred.com

                              set smtpServ emailServer.fred.com

                              # write header stuff
                              mime::setheader $multiT From “$smtpSnd”
                              mime::setheader $multiT To [join $recipientList ,]
                              mime::setheader $multiT  Subject “Your Subject Here”

                              # send the message – I use catch to protect from any unhandled errors
                              catch {smtp::sendmessage $multiT -recipients [join $recipientList ,] -servers $smtpServ -atleastone 1}

                              # destroy the message  
                              catch {mime::finalize $multiT}

                              Jeff Dinsmore
                              Chesapeake Regional Healthcare

                            • #72609
                              Robert Kersemakers
                              Participant

                                Hi Terry,

                                We are currently migrating towards CL6.0 and also swapping platforms: from HP-UX to RHEL. We use mailx as well to send out email; this is what we call from within an xlate:

                                Code:

                                exec mailx -r zorgdomein_no_reply@orbisconcern.nl -s “${subject}” ${email} < ${filename}

                                I haven’t been able to test mailx/this xlate, as the connection to our Exchange server hasn’t been made yet. As soon as I can test this, I will let you know. But according to the man pages, it should work.

                                Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

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