infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Read Only Archives
Cloverleaf
Tcl Library
Add OBX segment AFTER last DG1 segment found -multiple times
Lawrence Nelson
I have a vendor that sends me HL7 ORM messages in the following format
Find more posts tagged with
Clovertech
Comments
Jim Kosloskey
First - I don't think you will need Tcl for this.
Second - is the layout you show actually what is in your variant(s)?
If so I don't think they are correct.
email me if you would like me to help you and I will work with you off-line.
Lawrence Nelson
The variant - has the OBX in it -
The message never does.
The inbound message has an NTE that has to be parsed up into
a MANY - OBX's outbound
I've only been successful with getting my Xlate to work by creating a message with a single benign OBX.
end_prologue
MSH
PID
[ PV1 ]
[ PD1 ]
{
{
[{ IN1 } ]
[ IN2 ]
[ IN3 ]
}
[ GT1 ]
}
{
[{ ORC } ]
[{ NTE } ]
{
[{ OBR } ]
[{ NTE } ]
[{ DG1 } ]
[{ OBX } ]
}
}
Charlie Bursell
[{ ORC } ] should be just ORC. It should be required but will not affect your problem.
"I need a single OBX tacked on AFTER every LAST DG1 per ORC"
The DG1 is optional. What if not there?
Listen to Jim as how to do without Tcl. If you then really want it done in Tcl, let me know and I will help.
Charlie Bursell
Changed my mind. Decided to post code - nothing else going on
Jim will tell you how to do without Tcl and you can decide which way to go
Did not test a lot as I don't have your messages
==============================================
# Set canned OBX segnent to whatever
set OBX OBX|1||||||.|
# Split message into segments
set Segments [split $msg r]
# Get location of all OBR segments
set obrLoc [lsearch -all -regexp $Segments {^OBR}]
# Traverse in reverse order so as not to change OBR locations
foreach loc [lsort -integer -decreasing $obrLoc] {
# Assume no DG1
set dg1Loc -1
# List of all DG1 segments each time
foreach dg1Loc [lsearch -all -regexp $Segments {^DG1}] {
# We need DG1 *AFTER* the OBR
if {$dg1Loc < $loc} {continue}
# Got one after OBR - bail out
break
}
# No DG1 found - No mod to this OBR loop
if {$dg1Loc < 0} {continue}
# Get last one
# See if multiple DG1 and hget location of last one for the loop
while {[regexp {^DG1} [lindex $Segments [expr $dg1Loc + 1]]]} {
incr dg1Loc
}
# Incr location so we insert *AFTER* DG1
incr dg1Loc
set Segments [linsert $Segments $dg1Loc $OBX]
}
msgset $mh [join $segments r]
return "{CONTINUE $mh}"
Lawrence Nelson
Thanks Charlie - this is very helpful for the next case I run into something of this nature.
Jim and I worked through my xlate OBX issues yesterday - and we were able to do away with the TCL preproc in this case. Thanks again to Jim K!