HL7 Data Analysis Utility

Clovertech Forums Read Only Archives Cloverleaf General HL7 Data Analysis Utility

  • Creator
    Topic
  • #48897
    Jay Yeiser
    Participant

      I need a breakdown for ADT messages of patient types by message type in a data file.  For example, I want to know how any A03 messages were of patient type

    Viewing 2 reply threads
    • Author
      Replies
      • #60035
        Mike Grieger
        Participant

          You could just use the SMAT tool to achieve this.  Load the file, then Add to View messages that include ADT^A03, and of these, remove from view all messages that do not include |OPM|   (or, instead of the two steps, just Add to View messages that include  ADT^A03.*|OPM|

        • #60036
          Ryan Spires
          Participant

            Usage…

            saved it as countMsgPatType.tcl  (binary) in /home/hci

            takes the filename as a parameter.

            Quick and dirty… may be a better way to do it…  but here it is.

            #!/qdx/qdx5.3/integrator/bin/hcitcl

            #

            set fileName [lindex $argv 0]

            #  open file specified

            if [catch { open $fileName r} inFile] {

               puts stderr “Cannot open $fileName: $inFile”

            } else {

              # grab contents of file

              set contents [split [read $inFile] n]

              close $inFile

            }

            lappend reportData {“msgType” “count”}

            #loop through the contents for each message.

            foreach message $contents {

              #initialize for each message

              set evn_1 “”

              set pv1_18 “”

             

              set segments [split $message r]

              foreach seg $segments {

                  set segId [string range $seg 0 2]

                  switch -exact — $segId {

                      MSH {

                          set fieldDelim [string range $seg 3 3]

                          set compDelim [string range $seg 4 4]

                      }

                     

                      EVN {

                          set evn_1 [lindex [split $seg $fieldDelim] 1]

                      }

                     

                      PV1 {

                          set pv1_18 [lindex [split $seg $fieldDelim] 18]

                      }

                      default {}

                  }      

               }

               

               set msgTypePatType “$evn_1_$pv1_18”

               if {[lsearch [keylkeys reportData] $msgTypePatType] > 0} {

                   set counts [keylget reportData $msgTypePatType]

                   incr counts

                   keylset reportData $msgTypePatType $counts

               } else {

                   if { $msgTypePatType != “_” } {

                       keylset reportData $msgTypePatType 1

                   }

               }

            }

            set keyList [keylkeys reportData]

            foreach key $keyList {

               echo “$key: [keylget reportData $key]”    

            }

          • #60037
            Russ Ross
            Participant

              For the AIX user, understanding how to use these commands

              grep

              perl

              cut

              wc

              sort & sort -u

              can be very useful for this sort of thing without having to resort to writing a program.

              The “cut” command is especially useful since it can parse out a single field easily.

              Here are the simple AIX commands to do what you want.

              grep ‘|ADT^A03|’ newline_file | perl -pi -e ‘s/r/rn/g’ >f1

              grep “^PV1″ f1 | cut -d”|” -f 19 | grep OPM | wc -l

              There are other ways to do the same thing but I wanted to illustrate using the cut command to parse out the contents of an individual field.

              Russ Ross
              RussRoss318@gmail.com

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