tcl proc for comparing drug orders in same message

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf tcl proc for comparing drug orders in same message

  • Creator
    Topic
  • #55087
    Kaley Grimes
    Participant

    Good Morning,

    I’m still a tcl newbie so let me first say I am thankful for any assistance that is provided. I have been working on a tcl script for RDE messages. It appears Pharmacy performs tasks which ultimately puts two drug orders in one RDE message. The receiving application wants me to write a script to look at the orders and if the orders are for the same drug, they want the doses to be added together and send as one order.

    The problem I’m having is setting a variable for the multiple instances of the order so that I can write an if statement to compare the fields.

    The field I’m looking at for the comparison is RXE 2.1 – drug name.

    This is where I currently am at with my script:

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

    #####################################################

    ###############SETTING PRELIMINARY VALUES############

    #####################################################

     

      set msg [msgget $mh]

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

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

      set sssub_sep [csubstr $msg 7 1]       ;# HL7 SUB-subfield separator          

        set fieldList [split $msg $field_sep] ;# Split the message into fields

        set msg_type [lindex $fieldList 8] ;# HL7 Message Type

          set subfieldList [split $msg_type $sub_sep] ;# Split the field into subflds

        set msg_type_1 [lindex $subfieldList 0] ;# HL7 Message Type part 1

      set msg_type_2 [lindex $subfieldList 1] ;# HL7 Message Type part 2

    set outbuf {}

    set segments [split $msg r] ;# Get a list of HL7 segments, split message on CR

    if {[cequal $msg_type_1 “RDE”]} {

    foreach seg $segments {

       set segtype [csubstr $seg 0 3] ;# segment type

    if [cequal $segtype MSH] {

    append outbuf ${seg}r    

    #msgset $mh $outbuf

    }

    if [cequal $segtype PID] {

    append outbuf ${seg}r

    #msgset $mh $outbuf

    }

    if {[cequal $segtype RXE]} {

    set fieldList [split $seg $field_sep]

    set rxe2 [lindex $fieldList 2]

    set rxe2_1 [split $rxe2 $sub_sep]

    set rxe2_1_1 [lindex $rxe2_1 1]

    set rxeVal1 “”

    set rxeVal2 “”

    set rxeVal “^RXE\|”

    set segList $segments

    set findrxe [lsearch -all -inline -regexp $segList $rxeVal]

    foreach drugName $rxe2_1_1 {

Viewing 10 reply threads
  • Author
    Replies
    • #84035
      Jim Kosloskey
      Participant

      Is there some reason you don’t want to do this in an Xlate?

      Based on the information provided I think this can be accomplished in an Xlate.

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

    • #84036
      Kaley Grimes
      Participant

      I originally started with an xlate but kept having an issue with getting the iterate to work.

    • #84037
      Kaley Grimes
      Participant

      Okay, this is strange. I just pulled up the xlate again to take another look. I ran it from the last time it was saved, and it does work. It didn’t work previously.

      Let’s see if I can work this out through an xlate.

    • #84038
      Jim Kosloskey
      Participant

      email me if you want to ruminate.

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

    • #84039
      Kaley Grimes
      Participant

      Thanks Jim! I’m going to try a few ideas for the IF.

      If I have any issues, I’ll email ya. Thanks so much.

    • #84040
      Tom Rioux
      Participant

      I could be way off base here but red flags went up when I read what they are asking you to do.   Is there a reason that the source system cannot correct the issue?  

      The red flag went off because they are relying on the interface engine to send the correct dose.   The interface engine can translate data but I feel it should never be used to change data.   All it takes is one patient receiving the incorrect dose and the fingers are going to be pointed at the interface engine.

      Am I the only one sensing a patient safety issue here or as I stated before “way off base”?

      Thanks…

      Tom Rioux

    • #84041
      Suzy Hoffman
      Participant

      I’m with you, Tom.  I saw the same red flags and would not agree to do this kind of manipulation in an engine.  Scary stuff.

    • #84042
      Kaley Grimes
      Participant

      Hey Tom and Suzy,

      Ha! Actually, I completely agree. I addressed my concerns to the Pharmacy manager who is working with the receiving system vendor. She agreed with me and then later changed her mind, and said they needed this change to be made. The receiving system is primarily used for creating utilization reports and alerts based on Pharmacy workflows. I asked if this change could affect patient care and was told Yes but only if Pharmacy incorporates the information from the data they received in to their workflow processes. So, this change could inadvertently affect patient care. I have had several conversations with management and my co-workers, but no one else seems to feel the same way. I’m sure they would if I was requested to make this change for messages being sent between our Pharmacy app and our EHR. Prior to implementing the change, I am going to get all key players on the phone so we can discuss this one more time.

      So, in the end Jim was able to assist me in figuring out what I needed to do in the xlate. I can say this was a challenging task for me as I have not had the opportunity to put this kind of logic in an xlate before.

      Thanks Jim!

    • #84043
      Tom Rioux
      Participant

      Hi Kaley,

      I would draw up some sort of sign-off document.   I would put in there what changes are being requested and who is doing the requesting.   Then I would get your manager, plus representatives from both the sending and receiving systems to sign off on the change.  I would make sure to note the patient safety concerns.

      Without the signoff, I wouldn’t do it.    The signoff ensures you are not fall guy should incorrect information cross the interface.

      Thanks…

      Tom Rioux

    • #84044
      Kaley Grimes
      Participant

      Thanks Tom! That’s a great idea. We do have a formal change control process here but that doesn’t really prevent me from being held accountable if there are issues with the data.

    • #84045
      Gordon Koch
      Participant

      Hello Kaley,

           I have a similar issue if wanting to compare two fields in separate iterations of the same segment type (but I need to suppress one of them), and I was wondering how you structured your Xlate. Can you please share this?

      Thank you.

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10