Hi Charlie, et al.–
What I was trying to create was a RegEx that would evaluate the list of segments found (variable foundSegList) in an order message and then report back if any required segments are missing or out of sequence or any optional or conditional segments are out of order (based on my RegEx stored in segOrderRegEx). This works just fine in a standalone Tcl Proc (Tclx package required).
The expression I used is in the manual Tcl proc after capturing the values is:
if { [regexp $segOrderRegEx $foundSegList] }
So, I was trying to do the same ORM message validation in a TPS Inbound Pre-Proc to evaluate and validate incoming ORM messages. During testing in the Cloverleaf Testing Tool for some reason the variable holding the list of found segments was adding a space at the end of the list and the RegEx was failing (return 0) no matter what segments/order was included, so to get beyond that I added the space to the the RegEx figuring I could tackle that issue later; in the Testing Tool it was then successfully evaluating messages and catching both passing sequences (return 1) and failing sequences (return 0), but I knew I’d have to return to the extra space later… I put the TPS Proc into a test thread and it began core dumping.
The RegEx is captured through a KEYS file that I open and pull the contents into (to faciliate updating a KEYS (keyed list file) file rather than the code itself) which is why the entire RegEx is quoted with curly braces which are then removed leaving me with what I need. Looks something like this in the file now (a few extraneous items removed):
****************
{SEGREGEX {^((MSH PID){1}( NTE){0,10}( NK1){0,1}( PV1){0,1}( ZCC){0,1}( IN1){0,2}(( GT1){0,1}( DG1){0,120})( ZCI){0,1}(((( ORC OBR)( OBX){0,}( NTE){0,}){1,40})))$}}
…
keylget segKeys SEGREGEX segOrderRegEx
****************
I have removed all the uneccessary question marks and the space, so now I have something like this:
^((MSH PID){1}( NTE){0,10}( NK1){0,1}( PV1){0,1}( ZCC){0,1}( IN1){0,2}(( GT1){0,1}( DG1){0,120})( ZCI){0,1}(((( ORC OBR)( OBX){0,}( NTE){0,}){1,40})))$
Is there a better way to get a list of segments in a message and then iterate through that list to validate the sequence is proper and incorporates all required and optional segments? Additionally, I’d like to then store the offending segments and return them in a message I email out (I already have that piece in place if I can stop the core dumps).
Thanks very much for your time!
Dave Young
David Young, AKA, TeflonSuper
Just because one can do a thing does not mean one should do a thing.