Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › scripts to "downconvert" from hl7 v 2.5 to hl7 v 2
anyone out there have any thoughts or sample code on how to downconvert
Thanks alot for any help
Can you explain a little more?
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
We have done a very very very generic program to handle the ORM data messages that we get in 2.5.1 and convert to 2.3.
Of course you may need to make changes to the logic for your needs.
Code: set segments [split $mtext $cr] foreach segment $segments { set fields [split $segment $fdel] set segId [lindex $fields 0] switch -exact — $segId { MSH { #Format MSH to 2.3 set segment “MSH|^~\&|[lindex $fields 2]|[lindex $fields 3]|[lindex $fields 4]|[lindex $fields 5]|[string range [lindex $fields 6] 0 13]|[lindex $fields 7]|ORM^O01|[lindex $fields 9]|[lindex $fields 10]|2.3|” } PID { set segment “PID|[lindex $fields 1]|[lindex $fields 2]|[lindex [split [lindex $fields 3] ^] 0]|[lindex $fields 4]|[lindex $fields 5]|[lindex $fields 6]|[lindex $fields 7]|[lindex $fields 8]|[lindex $fields 9]|[lindex $fields 10]|[lindex $fields 11]|[lindex $fields 12]|[lindex $fields 13]|[lindex $fields 14]|[lindex $fields 15]|[lindex $fields 16]|[lindex $fields 17]|[lindex $fields 18]|[lindex $fields 19]|[lindex $fields 20]|[lindex $fields 21]|” } OBX – DG1 – NTE – OBR – ORC – GT1 – IN2 – IN1 – TQ1 – PV1 { #Passthrough only allow these segments for 2.3 } default { set segment “” } } if {$segment ne “”} { lappend newsegmentList $segment } } set newmsg [join $newsegmentList $cr] msgset $mh $newmsg lappend dispList “CONTINUE $mh”
set segments [split $mtext $cr] foreach segment $segments { set fields [split $segment $fdel] set segId [lindex $fields 0] switch -exact — $segId { MSH {
#Format MSH to 2.3 set segment “MSH|^~\&|[lindex $fields 2]|[lindex $fields 3]|[lindex $fields 4]|[lindex $fields 5]|[string range [lindex $fields 6] 0 13]|[lindex $fields 7]|ORM^O01|[lindex $fields 9]|[lindex $fields 10]|2.3|” } PID { set segment “PID|[lindex $fields 1]|[lindex $fields 2]|[lindex [split [lindex $fields 3] ^] 0]|[lindex $fields 4]|[lindex $fields 5]|[lindex $fields 6]|[lindex $fields 7]|[lindex $fields 8]|[lindex $fields 9]|[lindex $fields 10]|[lindex $fields 11]|[lindex $fields 12]|[lindex $fields 13]|[lindex $fields 14]|[lindex $fields 15]|[lindex $fields 16]|[lindex $fields 17]|[lindex $fields 18]|[lindex $fields 19]|[lindex $fields 20]|[lindex $fields 21]|” } OBX – DG1 – NTE – OBR – ORC – GT1 – IN2 – IN1 – TQ1 – PV1 { #Passthrough only allow these segments for 2.3 } default { set segment “” } } if {$segment ne “”} { lappend newsegmentList $segment } }
set newmsg [join $newsegmentList $cr] msgset $mh $newmsg
lappend dispList “CONTINUE $mh”