Emailing HL7 message

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Emailing HL7 message

  • Creator
    Topic
  • #49658
    Gary Atkinson
    Participant

    Hello-

    I writing a tps proc to a kill a message base on a field OBR4:1 and then email the HL7 message.  I have been successful in both cases, but I have an issue with how the hl7 message looks in the email body.  We are on version 5.5 rev1 and operation system is AIX 5.3.  Here is my proc:

    Code:


    proc tpsRAD_invalid_alias { 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 msg [ msgget $mh ]
               set segmentList [ split $msg r ]
               set newmsg [ join $segmentList n ]
               puts “Message joined by newline: $newmsg”
               set segment [lindex [ lregexp $segmentList ^OBR ] 0 ]
               set fieldsep [ string index $msg 3 ]
               set fieldList [ split $segment $fieldsep ]
               puts $fieldList
               set OBR4 [ lindex $fieldList 4 ]
               puts “This is OBR4: $OBR4”
               set OBR4_1 [ string range $OBR4 0 1 ]
               puts “This is first two characters of OBR4: $OBR4_1”
               set email_subject “Invalid Cerner Radiology Order Alias Received”
               if { [ string equal $OBR4_1 “CD” ] } {
                   set msgdisp “KILL $mh”
                   system echo “$newmsg” | mailx -s “$email_subject” gatkinson@bwmc.umms.org
               } else {
                   set msgdisp “CONTINUE $mh”
               }
               
             
               

               lappend dispList $msgdisp
           }

           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
    }


    I tried sending message with segments join as (r) and also as (n), but both cases I always get this in the email body:

    Code:


    MSH|^~&|HNAM|ARUNDEL|CHARGES|STAR|20071128093049||ORM^O01|Q24865496T168
    MSH|94335||2.3
    PID|1|1028681^^^^^STAR|1028681^^^^^STAR||CONTROL^TEMPORARY^LAKOF||192304
    PID|1|21|F|CONTROL^TEMPORARY^LAKOF|1|6 SUNRISE CT^^GLEN
    PID|1|BURNIE^MD^21060^US^^^02|02|(410)236-4577|NONE|E|W||730600009^^^^^S
    PID|1|TAR|5467896|||||||||Not of Span/Hispanic||N
    PV1|1|Inpatient|CCU^CCU^06^BWMC^^^NAH|Direct|||1058^Badro,
    PV1|1|Inpatient|M.D.^Bassim~1058^Badro, M.D.^Bassim|||CAR||||*Phy
    PV1|1|Inpatient|Ref/Home|||1058^Badro, M.D.^Bassim~1058^Badro,
    PV1|1|Inpatient|M.D.^Bassim|IPA||1|||||||||||||||||||BWMC|||||2007110215
    PV1|1|Inpatient|1400
    PV2||C||||||||0|||CD:28952855||||||||||^^589723
    ZVI||||CHEST PAIN NOS|||||2
    ORC|NW|IR-07-0000085|||Ordered||||20071128093000|^Costanzo^Jennifer||105
    ORC|NW|IR-07-0000085|||Ordered||||20071128093000|8^Badro,
    ORC|NW|IR-07-0000085|||Ordered||||20071128093000|M.D.^Bassim~1058^Badro,
    ORC|NW|IR-07-0000085|||Ordered||||20071128093000|M.D.^Bassim|NAH
    ORC|NW|IR-07-0000085|||Ordered||||20071128093000|Pharmacy||2007112809304
    ORC|NW|IR-07-0000085|||Ordered||||20071128093000|5|||Written^Written|^Co
    ORC|NW|IR-07-0000085|||Ordered||||20071128093000|stanzo^Jennifer
    OBR|1|IR-07-0000085||CD:28989428^IR Needle Bx/Special
    OBR|1|IR-07-0000085||Procedure||||||||CD:312689^Standard
    OBR|1|IR-07-0000085||Precautions|||Rad Type&Rad Type|1058^Badro,
    OBR|1|IR-07-0000085||M.D.^Bassim~1058^Badro,
    OBR|1|IR-07-0000085||M.D.^Bassim||||19781737|CD:28799302|20071128093046|
    OBR|1|IR-07-0000085|||CD:28907525|||1^^0^20071128093000^^R|||CD:319451|^
    OBR|1|IR-07-0000085||Tumor

    What have others done to email HL7 messages as they come into the engine?  And does anyone have any ideas why segment names repeat?

    Thanks for you time!

    Gary

Viewing 9 reply threads
  • Author
    Replies
    • #62899
      Robert Milfajt
      Participant

      Yes, we had this problem back in August.  I have the fix for you, but I do not remember why I did this.  Funny, you look at the problem, remember fixing it, find the fix and then say to yourself, what the frell was I thinking.  Here is a snippet of a proc I created called Printable_Msg, that takes a variable containing what is returned by the [msget $mh], and massages it so it prints correctly!  It looks like I converted all hard returns to new-lines, adds a space before each segment and after each new-line, but for the life of me I do not remember why I added the spaces.

      Code:

      proc Printable_Msg { msg } {
             regsub -all r $msg n msg1
             regsub -all {^(…)} $msg1 ” \1″ msg2
             regsub -all {n(…)} $msg2 “n \1” msg1
             return $msg1
      }      

      Hope this helps,

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #62900
      Chris Williams
      Participant

      If the destination mail reader is on a PC, it is expecting to see a CRLF pair (rn) as the line termination. If you are trying to read with Windows Outlook, you need to go to

      Tools / Options / Preferences / E-maiil Options

      and uncheck “Remove extra line breaks in plain text messages”

    • #62901
      Gary Atkinson
      Participant

      Thanks Chris that worked!  ðŸ˜€

      I love microsoft  ðŸ™„

      This what it looks like now in outlook:

      Code:


      MSH|^~&|HNAM|ARUNDEL|CHARGES|STAR|20071128093049||ORM^O01|Q24865496T16894335||2.3
      PID|1|1028681^^^^^STAR|1028681^^^^^STAR||CONTROL^TEMPORARY^LAKOF||19230421|F|CONTROL^TEMPORARY^LAKOF|1|6 SUNRISE CT^^GLEN BURNIE^MD^21060^US^^^02|02|(410)236-4577|NONE|E|W||730600009^^^^^STAR|5467896|||||||||Not of Span/Hispanic||N
      PV1|1|Inpatient|CCU^CCU^06^BWMC^^^NAH|Direct|||1058^Badro, M.D.^Bassim~1058^Badro, M.D.^Bassim|||CAR||||*Phy Ref/Home|||1058^Badro, M.D.^Bassim~1058^Badro, M.D.^Bassim|IPA||1|||||||||||||||||||BWMC|||||20071102151400
      PV2||C||||||||0|||CD:28952855||||||||||^^589723
      ZVI||||CHEST PAIN NOS|||||2
      ORC|NW|IR-07-0000085|||Ordered||||20071128093000|^Costanzo^Jennifer||1058^Badro, M.D.^Bassim~1058^Badro, M.D.^Bassim|NAH Pharmacy||20071128093045|||Written^Written|^Costanzo^Jennifer
      OBR|1|IR-07-0000085||CD:28989428^IR Needle Bx/Special Procedure||||||||CD:312689^Standard Precautions|||Rad Type&Rad Type|1058^Badro, M.D.^Bassim~1058^Badro, M.D.^Bassim||||19781737|CD:28799302|20071128093046||CD:28907525|||1^^0^20071128093000^^R|||CD:319451|^Tumor

    • #62902
      Robert Milfajt
      Participant

      And I wrote code to fix this…   😳

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #62903
      Gary Atkinson
      Participant

      Yes Robert thanks for your suggestion as well 😆

      I’m lazy so I took the outlook suggestion first  ðŸ˜‰

    • #62904
      David Barr
      Participant

      I’m trying to figure out what’s going on from your examples.  In the first instance, a new line starts wherever you have a new segment, but any segments longer than about 72 characters are cut off.  

      It’s hard to tell exactly what is going on in your second message.  It looks like lines are getting wrapped if there is a space in them, but otherwise they are still being truncated.  If you want to avoid all truncations, I’d advise changing this code:

      Code:

      system echo “$newmsg” | mailx -s “$email_subject”

      to this:

      Code:

      system echo “$newmsg” | fold -w 70 | mailx -s “$email_subject”

      This will cause all lines to wrap regardless of whether or not they contain spaces.

    • #62905
      Gary Atkinson
      Participant

      Thanks David for that tip as well!  

      I thought HciConnName returned the name of the thread, but when running this proc in the engine I see its returning the process .  Is their a global variable that contains the name of the thread where the tcl proc is used?

    • #62906
      Charlie Bursell
      Participant

      processname_xlate IS the name of the Xlate thread so HciConnName is giving you exactly what you asked for.  If you want the the name of the thread that is sending to the Xlate thread you can get it from the metadata of the message.

    • #62907
      Gary Atkinson
      Participant

      Thanks Charlie  8)

    • #62908
      Gary Atkinson
      Participant

      I found the thread name in SOURCECONN.   😛

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

Forum Statistics

Registered Users
5,115
Forums
28
Topics
9,290
Replies
34,426
Topic Tags
286
Empty Topic Tags
10