quick tcl help

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf quick tcl help

  • Creator
    Topic
  • #48591
    Gene Salay
    Participant

      I’m trying to send only ED messages to my ScriptRx server.  

      here’s my current tcl filter:

                 keylget args MSGID mh

                 set msg [msgget $mh]

                 set segments [split $msg r]

                 set pv1_loc [lsearch -regexp $segments “^PV1”]

                 set pv1_seg [lindex $segments $pv1_loc]

                 set pv1_fld10 [lindex [split $pv1_seg |] 10]

                 set pv1_fld44 [lindex [split $pv1_seg |] 44]

                 if {[regexp {ED} $pv1_fld10]} {

                   lappend dispList “CONTINUE $mh”

       } else {

             lappend dispList “KILL $mh”

                 }  

      I’m told it let the following message through:

      MSH|^~&|REG|SACH||SACH|20060615112149||ADT^A08|20607|D|2.3|

      EVN|A08|20060615112149|||SHW

      PID|||070580||TEST^SRX2^^^^||19810101|F||W|525 PARK PL^^HACKENSACK^NJ^

       07601^^|||||||3931755|555-01-0181|||O|||||||||

      PV1||I|2ND^210^1|3|||415^PATEL^SAMIR^^^|||MED||||1|||415^PATEL^SAMIR^^

       ^|MED|541|BCHMO|||||||||N||||||||||||A|||20060615070000||||||

      PV2||S||||||||||||||||||||||A|||||||||||||

      DG1|000||401.0^MALIGNANT HYPERTENSION^I9|||A|||||||||||

      ZOR||||

      Is it seeing the ED in MED and letting it go because of that?   How can I specify exactly ED?

      Thanks much!!

    Viewing 3 reply threads
    • Author
      Replies
      • #59087
        Steve Carter
        Participant

          Changing your regexp to {^ED$} should force it to only match ED.  This will anchor the pattern to the beginning and end of the pattern.

          Hope this helps.

          Steve

        • #59088
          Robert Kersemakers
          Participant

            Or use

             [string equal $pv1_fld10 “ED”]

            instead of the regexp. Makes it more readable in my opinion.

            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

          • #59089
            Gene Salay
            Participant

              Thank you both.   Much appreciated!

            • #59090
              Anonymous
              Participant

                I would also recommend using the string.  However, if you want to use the regexp, then changing it to {^ED$} is not what you want to do.  Instead, change the regexp to {[ED]+}.  That will match “ED” no matter where it is in the variable.  It will match ED, MED, EDIT, MEDICAL and so on.  Using it as Steve specified returns a “0”  or false statement.  The “+” at the end will match one or more instances of the previous pattern within the variable specified.

                Hope this helps.

                Thomas G. Rioux

                The Methodist Hospital

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