Sending Message to Email

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Sending Message to Email

  • Creator
    Topic
  • #50623
    Jared Miller
    Participant

      We are having an issue where sometimes our patient access registrars improperly register an account, and when that happens a MRN does not get generated.  Cerner does not accept messages without a MRN so when this happens the connection gets dropped, and can not be restarted until the faulty message is skipped.

      As a solution I am working on creating tcl code to check each message to insure that a MRN is present in PID-3.1, and if there is not a MRN then I want to kill the message.  However, before killing the message I would like to receive an email with the HL7 message in there so that I can notify the appropriate people that a patient isn’t being registered correctly.

      This is what I have right now:

      if {[cequal $pid_3_1 “”]} {

      system “echo “Subject: No MRN is Message\n.” | sendmail sample@tmcmed.org

      lappend dispList “KILL $mh”

      return $dispList

      } else {

      lappend dispList “CONTINUE $mh”

      return $dispList

      }

      I am able to get an email generated, but I am having trouble getting the HL7 message in the email so I am just looking for some help with that portion of the code.  Thanks in advance!

    Viewing 2 reply threads
    • Author
      Replies
      • #66814

        Jared, do a search for email on the forum. There’s a bunch of good stuff related to email out there.

        -- Max Drown (Infor)

      • #66815
        Jim Kosloskey
        Participant

          Jared,

          What would happen if you NAK’d the nmessage at the inbound thread?

          How would the sending system respond? Is it set up to intelligently handle NAKs?

          If the Sending system can do a decent job handling NAKs (including notification of the error), why not NAK the mesage upon receipt and populate the MSA fields so that there is both an error reason code and a corresponding text?

          Then the folks who are using the system to create the mesage might be able to get notified right on that system an error occurred.

          Of course, the best solution would be to have the sending system edit Patient information for required data and stop the transaction at the data entry point.

          As Max said, there is a lot of good information on the forum for emailing.

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

        • #66816
          Jared Miller
          Participant

            Thanks for suggesting the search…I had done a search a few weeks ago and didn’t find anything I was able to get to work for me, however, today I find something I was able to adapt into a working solution.

               # Here we retrieve the data from our original message

               set msg [msgget $mh]

               

               #Variable to set what is sent in the body of the email

               set EmailMsg “$msg”

               #Variable to set what is sent as the email subject

               set EmailSub “Invalid Registration – NO MRN”

               #Variable to set what email addresses to send to

               set Emails “sample@tmcmed.org”

               # Now we need to determine our field and subcomponent seperatoprs

               set field_sep [csubstr $msg 3 1] ;# HL7 field separator    

               set sub_sep [csubstr $msg 4 1] ;# HL7 subfield separator    

               # Here we spilt the original message into a list of the segments contained within

               set segmentList [split $msg r]

               # Now we iterate over each segment in our list.

               foreach segment $segmentList {

            if {[cequal [crange $segment 0 2] PID]} {

            set fieldList [split $segment $field_sep]

            set pid_3 [lindex $fieldList 3]

                               # split PID-3 on the sub-seperator

                                    set pid_3_list [split $pid_3 $sub_sep]

                               #  get the first element in PID-3

                                  set pid_3_1 [lindex $pid_3_list 0]

                     

               if {[cequal $pid_3_1 “”]} {

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

            lappend dispList “KILL $mh”

            return $dispList

            } else {

            lappend dispList “CONTINUE $mh”

            return $dispList

            }

               }

            }

               }

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