SMAT File Searches

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf SMAT File Searches

  • Creator
    Topic
  • #52085
    Greg Tataryn
    Participant

      I am hoping someone out there has some pointers on easy SMAT file searches.  It has not been so bad until recently and we have been on Cloverleaf as our interface engine for a little over a year.

      My issue is this, when given an issue to troubleshoot the messages needed likely span multiple procs/threads and possible multiple days.  It gets to be rather tedious to open a smat file, filter the messages, then open another one and filter.  Even if I could find a way to search all SMAT files for a given day based on a certain criteria (such as patient account in PID:18) it would make life so much easier.  Any suggestions are greatly appreciated.

    Viewing 1 reply thread
    • Author
      Replies
      • #73000
        Keith McLeod
        Participant

          In $HCIROOT/contrib, Charlie left a perl Script called perl_grep.  Modify it by commenting out the following line with # as such.

          #$pattern = quotemeta $pattern;

          Also make sure the firest line is correct for your installation. For instance, the one I am looking at has:

          #!/qdx/qdx5.5/integrator/bin/perl

          You can then search for messages using regular expressions.

          Find Exactly MUELLER in Last Name Field

          rPID(?:[^|]*|){5}(MUELLER^)

          Find all messages where PID:18 is Blank

          rPID(?:[^|]*|){18}(|)

          Find All Birthdays where PID:7 begins with 1965

          rPID(?:[^|]*|){7}(1965)

          Run this command in your SMAT file Directory:

          perl_grep -l “rPID(?:[^|]*|){18}(|)” *.msg

          perl_grep -l “rPID(?:[^|]*|){5}(MUELLER^)” *.msg

          to find SMAT files that have a PID:18 that is blank or PID:5 with a last name of MUELLER.  It will return the name of the files containing those message.  You can then use the same expression within SMAT to find the actual messages.

          Also, Max Drown has several useful HL7 scripts that may provide you what you are looking for.

        • #73001
          Kevin Crist
          Participant

            We use this on occasion. It searches back through our archived smats and gives you the date/file that what you are looking for is in. Not sure if it’s exactly whats needed here.

            Code:

            #!/quovadx/qdx5.4.1/integrator/bin/hcitcl
            #
            ##########################################################################################
            ##########################################################################################
            ##########################################################################################
            #
            # A Tcl program to scan the smats in ARCHIVE
            # Prints out info for every segment that matches the criteria input
            #
            # Glob matching works on
            # – File Name
            # – Message Type
            # – Field Value
            #
            # Program Name: FindMsgs
            #
            # Parameterts: None
            #
            # Example Call: FindMsgs
            #
            # Created: John Zalesak 04/21/2009
            #
            #
            ##########################################################################################
            ##########################################################################################
            ##########################################################################################
            #
            #
            proc FindMsgs {argv argc} {

            ##########################################################################################
            # Set up globals and initialize variables
            ##########################################################################################

            global HciRoot

            set linecnt 0
            set maxlines 60

            set FieldVal {}

            set fldSep “” ;# Field Seperator – get from MSH
            set subSep “” ;# SubField Seperator – get from MSH
            set repSep “” ;# Repeating Field Seperator – get from MSH

            set segList [list]
            set fldList [list]
            set subfldList [list]

            #########################################################################################
            # Load in the arguments we need that were passed from the caller
            #########################################################################################

            puts -nonewline “nPlease Enter the Site Name: ”
            gets stdin SiteNa
            puts -nonewline “nPlease Enter the File Name: ”
            gets stdin FileNa
            puts -nonewline “nPlease Enter the Message Type: ”
            gets stdin MsgType
            puts -nonewline “nPlease Enter the Segment Name: ”
            gets stdin SegNa
            puts -nonewline “nPlease Enter the Field Number: ”
            gets stdin FieldNu
            puts -nonewline “nPlease Enter the Field Value: ”
            gets stdin FieldVal
            # puts -nonewline “nPlease Enter the Sub-Field Number: ”
            # gets stdin SubFieldNu

            set linenct 0
            foreach match [lsort [glob -nocomplain -dir $HciRoot/ARCHIVE/$SiteNa — $FileNa.*.idx]] {

            set idxchan [open $match]
            set idxdata [read $idxchan]

            set match [string map {idx msg} $match]
            set msgchan [open $match]

            echo “nFile name: $match”

            foreach idxmsg $idxdata {
            keylget idxmsg OFFSET MsgOffset
            keylget idxmsg LENGTH MsgLength
            # echo $MsgOffset
            # echo $MsgLength

            seek $msgchan $MsgOffset start
            set Msg [read $msgchan $MsgLength]
            # echo raw message $Msg

                 set fldSep [string index $Msg 3] ;# Field Seperator
                 set subSep [string index $Msg 4] ;# Sub-Field Seperator
                 set repSep [string index $Msg 5] ;# Repeating Field Seperator

            set segList [split $Msg n]    ;# Split message into segList
            set type [lindex [split [lindex [split [lindex $segList 0] $fldSep] 8] $subSep] 1]

            if { [string match -nocase $MsgType $type] == 1 } {
            foreach seg $segList {
            if { [string first “MSH” $seg] == 0 } {
            set MsgID [lindex [split [lindex $segList 0] $fldSep] 9]
            }
            if { [string first $SegNa $seg] == 0 } {
            set fldList [split $seg $fldSep]
            if { [string match -nocase $FieldVal [lindex $fldList $FieldNu]] == 1 } {
            echo “ID = $MsgID – Type = $type – Seg = $SegNa – Field = $FieldNu – Value = [lindex $fldList $FieldNu]”
            incr linecnt
            if { $linecnt >= $maxlines } {
            echo “Press Enter to Continue: ”
            gets stdin
            echo “nFile name: $match”
            set linecnt 0
            }
            }
            }
            }
            }

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