Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › resending smat file (have .msg, but missing .idx)
- This topic has 4 replies, 4 voices, and was last updated 15 years, 8 months ago by Duy Nguyen.
-
CreatorTopic
-
January 26, 2009 at 6:55 pm #50583Duy NguyenParticipant
Hello~ I am trying to resend all the messages for a certain day but for some reason, I am missing the associated .idx file.
-
CreatorTopic
-
AuthorReplies
-
-
January 26, 2009 at 7:26 pm #66685Alice SchmautzParticipant
Settings in UltraEdit-32
Advanced –> Configuration –> General tab:
Auto Detect Unix Files – Checked
Auto Convert Unix Files – Unchecked
Save File as Input Format – Unchecked
1. Open .msg file but do NOT convert to DOS.
2. Search on “!” char in file (Generally NOT found).
3. Assuming no “!” character in file, REPLACE “MSH|” with “!MSH|”
4. Remove the ! at the very beginning of the file (First HL7 message in file)
5. Go into HEX Mode.
6. In HEX Mode, replace Hex 21 (This is the “!” character) with Hex 0A.
7. Go out of HEX Mode.
8. The file is all now in “newline” format, with original Hex 0d characters separating HL7 segment within each message
and Hex 0D 0A at the end of every HL7 message WITH ONE EXCEPTION.
9. Enter Ctrl-Home to go to LAST character in the file. This is a Hex 0D character. Use backspace to delete this character, then press enter.
Pressing enter inserts Hex 0D 0A as the last two characters of the file.
10. Save the file to the Cloverleaf server. It is ready to load to a thread in Newline format.
NOTE #1: If you find a “!” character in the original file, you can replace using TWO or THREE “!” characters in Step 3.
Then, in Step 6, you would replace with HEX 21 21 (or HEX 21 21 21). The point is to have somethine unique for this search/replace action.
NOTE #2: If your “raw” file is already saved in DOS format with CR-LF after each message, you will need to insert a step above between Steps 5 and 6, to replace HEX 0A with null, then continue on to Step 6.
Hope this helps!
-
January 26, 2009 at 7:45 pm #66686Max Drown (Infor)Keymaster
http://clovertech.infor.com/viewtopic.php?t=3097
-- Max Drown (Infor)
-
January 28, 2009 at 7:28 pm #66687Sergey SevastyanovParticipant
Duy,
I had similar problem and I created small script to create SMAT files.
I used it on several occasions and it worked fine (I’m on Cloverleaf 5.4). I was guessing the structure of IDX file and I still don’t know meaning of some of the values, but it worked for opening the files in SMAT and resending nevertheless.
Here is my script (it runs under wish). Feel free to change it to your liking.
Please use on your own risk!
Code:
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl
exec tclsh “$0” ${1+”$@”}# Read messages from a text file and build message files for SMAT
package require Tk
package require Tclx##############################################################################
#
# proc initWindow
#
##############################################################################
proc initWindow {} {
wm title . “Generate SMAT files from a text file”
# wm geometry size behaves differently when it contains text widget – sizes are in some different units
# wm geometry . 13×13+20+20
global fstatus
menu .menu -tearoff 0
set mf .menu.file
menu $mf -tearoff 0 -activebackground DarkBlue -activeforeground White -font {Arial 8 normal}
.menu add cascade -label “File” -menu $mf -underline 0
$mf add command -label “Open message text file…” -command “openFile”
$mf add command -label “Create SMAT files” -command “createSMAT”
$mf add command -label “Exit” -command {exit}
. configure -menu .menu
# set text area to display status of the program
set fstatus .fstatus
frame .fstatus -borderwidth 2 -height 200 -width 200 ; ###-relief sunken
pack .fstatus -side top -fill both -pady 2 -padx 2 -expand yestext $fstatus.text -wrap none -height 20 -width 100
-setgrid true -highlightthickness 0 -pady 1 -padx 1
-font {Courier 10 normal}
-bg white
-xscrollcommand “$fstatus.xscroll set”
-yscrollcommand “$fstatus.yscroll set”
-relief sunken
scrollbar $fstatus.yscroll -command “$fstatus.text yview”
-highlightthickness 0 -orient vertical
scrollbar $fstatus.xscroll -command “$fstatus.text xview”
-highlightthickness 0 -orient horizontalgrid $fstatus.text -in $fstatus -padx 1 -pady 1
-row 0 -column 0 -rowspan 1 -sticky news
grid $fstatus.yscroll -in $fstatus -padx 1 -pady 1
-row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
grid $fstatus.xscroll -in $fstatus -padx 1 -pady 1
-row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
grid rowconfig $fstatus 0 -weight 1 -minsize 0
grid rowconfig $fstatus 1 -weight 0 -minsize 0
grid columnconfig $fstatus 0 -weight 1 -minsize 0
grid columnconfig $fstatus 1 -weight 0 -minsize 0
#define styles
TextStyles $fstatus.text}
proc TextStyles {text} {
$text tag configure arial_12_bold_red -font {arial 12 bold} -foreground red
$text tag configure arial_16_bold_red -font {arial 16 bold} -foreground red
$text tag configure arial_12_bold_italic_red -font {arial 12 bold italic} -foreground red
$text tag configure courier_10_bold -font {courier 10 bold} -foreground black
$text tag configure courier_10_bold_blue -font {courier 10 bold} -foreground blue
$text tag configure default -font {courier 10 } -foreground black
}#============================================================
# openFile
#============================================================
proc openFile {} {
global fileinset MessageFile [tk_getOpenFile -initialdir {C:Test } -title “Open message text file”]
if { $MessageFile eq “” } { return }
set filein [open $MessageFile r]
if {$filein != 0} {
return $filein
}
# read the whole file into $html
while {[gets $filein line] >= 0} {
append html $line “n”
}}
#============================================================
# createSMAT
#============================================================
proc createSMAT {} {
global filein
set msgSMAT [tk_getSaveFile -initialdir {C:Test } -title “Save SMAT message file”]if { $msgSMAT eq “” } { return }
set rootname [file rootname $msgSMAT]
set ext [file extension $msgSMAT]
if {$ext ne “.msg”} {
set ext “.msg”
}
set ext2 “.idx”set msgSMAT “”
set idxSMAT “”
append msgSMAT $rootname $ext
append idxSMAT $rootname $ext2
set outmsg [open $msgSMAT w]
if {$outmsg == 0} {
error “Error during creation of SMAT msg file $msgSMAT”
return
}
# create SMAT idx file
set outidx [open $idxSMAT w]
if {$outidx == 0} {
error “Error during creation of SMAT index file $idxSMAT”
return
}set offset 0
set len 0
# process input message file
while {[gets $filein line] >= 0} {
# display line
#displayLog $line 1
# if MSH segment read create index record for previous message
set seg [string range $line 0 2]
###displayLog “processing segment $seg” 1 arial_12_bold_italic_red
if {($seg eq “MSH”) && ($len > 0)} {
# display MSH line
displayLog $line 1
# create index record
set indrec [createIndexRec $offset $len]
incr offset $len
set len 0
puts $outidx “{”
foreach el $indrec {
puts $outidx t$el
}
puts $outidx “}”
}# write segment to message file
incr len [string length $line]
incr len 1
puts -nonewline $outmsg $linexd}
# create index record for the last message
set indrec [createIndexRec $offset $len]
puts $outidx “{”
foreach el $indrec {
puts $outidx t$el
}
puts $outidx “}”
close $filein
close $outmsg
close $outidxdisplayLog “========================================================” 1
displayLog “All Done” 1}
proc createIndexRec {offset len} {
# set keylists
set domain [list DOMAIN 0]
set hub [list HUB 0]
set num [list NUM 0]
set mid [list MID [list $domain $hub $num]]
set srcmid [list SRCMID [list $domain $hub $num]]
set dest to_test
set orig_dest to_test
set source_conn frm_tets
set orig_source_conn frm_test
keylset midkl MID.DOMAIN 0 MID.HUB 0 MID.NUM 0
keylset srcmidkl SRCMID.DOMAIN 0 SRCMID.HUB 0 SRCMID.NUM 0
keylset typekl TYPE DATA
keylset srcconn SOURCECONN $source_conn
keylset osrcconn ORIGSOURCECONN $orig_source_conn
keylset destconn DESTCONN $dest
keylset origdestconn ORIGDESTCONN $orig_dest
keylset time TIME 0
keylset prty PRIORITY 5120
keylset datfmt DATAFMT “”
keylset savcntx SAVECONTEXT outbound
keylset off OFFSET $offset
keylset lenkl LENGTH $len
set indrec2 [list $midkl $srcmidkl $typekl $srcconn $osrcconn $destconn $origdestconn $time $prty $datfmt $savcntx $off $lenkl]
return $indrec2
}#============================================================
# displayLog – display text in the window
#============================================================
proc displayLog {text newline {style “”} } {
global fstatus
set textstyle default
if {$style ne “”} {
set textstyle $style
}
$fstatus.text insert end $text $textstyle
if {$newline > 0} {
for {set i 1} {$i <= $newline} {incr i} {
$fstatus.text insert end "n"
}
}
# scroll to the end
$fstatus.text see end
update idletasks
}initWindow
Sorry for sloppy style – I just needed a quick tool when I was learning Tcl
Chose your file with messages in “Open message text file” option from File menu.
Then select “Create SMAT files” from file menu and specify name of the new file (you don’t have to specify extensions). The program will create two files with extensions .idx and .msg.
You can change values of the following variables in createIndexRec proc to set proper thread names:
Code:set dest to_test
set orig_dest to_test
set source_conn frm_tets
set orig_source_conn frm_testFrom my experience it doesn’t really matter what names are there.
I would advise you to test it first by sending a few (or all) messages through a test thread first
Good luck
Sergey
-
January 30, 2009 at 3:06 pm #66688Duy NguyenParticipant
Thanks for all the great responses everyone. 🙂
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.