tcl script to sort dumped recovery db messages by timestamp?

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf tcl script to sort dumped recovery db messages by timestamp?

  • Creator
    Topic
  • #52988
    Jennifer Hardesty
    Participant

    I am coming in on the tail end of a production issue that needs resolution.

    We have a file full of several days-worth of lab results bound for a particular vendor.  The file was created via dump of the recovery database following a server crash and prior to a db init.  Unfortunately, the messages are in order of however which way the db chose to stick them in there rather than based on timestamp.

    I’ve spoken to the vendor and they’ve indicated that the messages absolutely need to be sent the right date/time order.  In other words, they will start erroring out if they do a zigzag through the four days the file covers — and, let’s just say that massive errors from them leads to no where good. 😉

    I’ve been looking around for some sort of tool to sort the messages in the file and haven’t seen one, though I was sure I couldn’t be the first one who’d come across this problem.  If anyone can share either some advise or some code, I’d appreciate it.  

    Meanwhile, I’ll be working on simulating a tcl array of messages and trying to remember my best sorting algorythm. 😛

    Thanks in advance!

Viewing 2 reply threads
  • Author
    Replies
    • #76181
      William Rowley
      Participant

      Here is what I would do –

      Write a tcl script to read from the file, parse out the message date/timestamp and sequence number, format that info into a sort-friendly stub (like yyyymmddhhmmssxxxxx), and write out the message into a new file with the sort-friendly stub prepended.

      Use the sort command to get that file into the desired order.

      Write a tcl script to read from the sorted file, strip off the sort-friendly stub, and write out the message. This last file is then ready to re-send.

      Kind of a brute force approach (and I’m sure that others already have conceived a single-line perl/awk/sed command to do all of the above) but workable.

      Good luck!

    • #76182
      James Cobane
      Participant

      Well, if these are HL7 messages in a newline terminated file and the transaction date/time in MSH:7 is valid to use as the actual date/time, you could potentially use the standard ‘sort’ command (in AIX):

      sort -t”|” +6 myinfile -o myoutfile

      the -t parameter with the pipe in quotes says to use the pipe | as the field separator; the +6 says to ignore the first six fields as sort criteria; the -o says to put the output to the file named myoutfile.

      Hope this helps.

      Jim Cobane

      Henry Ford Health

    • #76183
      Jennifer Hardesty
      Participant

      Oh, I love/hate when it’s something as simple as that.  

      I’ve been beating my head trying to figure out the simplest way to do this.   🙄

      Jim, you are my BFF today!  ðŸ˜€

      Thank you, thank you!

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

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10