How to truncate OBX 5 values that are being evaluated by BPL
I have a BPL that checks if at least one of the incoming OBX 5 values exists in TestTable. If the value exists it gets passed to Operation A and if it doesn't exist it gets passed to Operation B. The lookup table has keys that range between 10 to 70 characters. However, the incoming message sometimes has OBX 5 values that are greater than 510 characters which causes the BPL to terminate and the message does not get sent to any operation. So, my question is, how do I truncate the incoming OBX 5 values before they get passed to the BPL so that what is passed to the BPL is always between 10 and 300 characters?
Edited to add:
Interface is designed not to use any rules, only BPL so any suggestions should please take that into account.
You can create a previous Business Rule to apply a transform before to the redirection to BPL.
https://docs.intersystems.com/iris20232/csp/docbook/DocBook.UI.Page.cls?...
In the transformation your can apply $EXTRACT function to the OBX.5 bigger than 510 and replace that OBX.5
Thanks for your response @Luis Angel Pérez Ramos. I should have included in my post that this interface is designed not to have any rules. Only 1 BPL and DTLs. Any way I can use $EXTRACT within the BPL?
You can call the transformation from the BPL as the first step.
I like the idea BUT I still want the original OBX 5 values to be received as is downstream without being truncated and my fear is that by truncating the OBX 5 values greater than 510 characters before passing on to subsequent DTLs I will pass on incomplete fields. Hope that makes sense
You can configure a transform creating a new message and defining another context variable with the same type than the original message as output, then you keep your original message in the request and the transformed message in the new variable.
Thank you @Luis Angel Pérez Ramos I used your suggestion and it worked. Thank you @Jeffrey Drumm for showing me how to set the EXTRACT function. I used $EXTRACT(context.ObxTrunc,1,470) where context.OBxTrunc is the context variable holding the original message.
In the BPL, I passed the message through the newly created DTL that was looking if the OBX 5 characters(bytes) were greater than 400, if so, I took the substring of the first 470. (I tried taking 480/ 490/ 500 but that would cause the message to error) then following Luis's suggestion, I defined another context variable with the same type than the original message as output.
Can you share the error message generated by the BPL when it terminates?
You should be able to assign the return value of $EXTRACT(request.{OBX:5},1,510)}* to a context variable and use it in place of the original OBX:5 path in the lookup function. However, if the OBX:5 is longer than the maximum string size in IRIS (i.e. it's a stream), you may need to include logic to check for that, then read just the first 510 bytes.
* The path to the OBX segment is likely different than what's in my example ... you'll need to supply the correct path.
@Jeffrey Drumm please see below.
Error 1:
ERROR <Ens>ErrException: <SUBSCRIPT>zExists+1^Ens.Util.FunctionSet.1 ^Ens.LookupTable("TestTable","The patient came in accompanied by their daughter.. Time-out was -- logged as '-' number - @''
Error 2:
ERROR <Ens>ErrBPTerminated: Terminating BP TestRsltRouter # due to error: ERROR <Ens>ErrException: <SUBSCRIPT>zExists+1^Ens.Util.FunctionSet.1 ^Ens.LookupTable("TestTable","The patient came in accompanied by their daughter.. Time-out was -- logged as '-' number - @''
> ERROR <Ens>ErrException: <SUBSCRIPT>zExists+1^Ens.Util.FunctionSet.1 ^Ens.LookupTable("TestTable","The patient came in accompanied by their daughter.. Time-out was -- logged as '-' number - @''
Global subscripts have a limit of 511 characters, and Exists() doesn't like anything larger. You'll need to $EXTRACT() the first 510 characters from the field to a context variable as suggested in my previous comment and pass that as the string argument in the Exists() method.