Question
· Jul 7, 2022

Delete first part of HL7 field up to first "(" character

I am doing a HL7 data transformation with object script but need to only write a substring from the first "(" of the NTE-3 field to the end.

example

Input: NTE|1|||Some text (HI) (321)|ABC

Desired Output: NTE|1|||(HI) (321)|ABC

Basically I'd like to delete "Some text  ".

If I were writing a shell script I would use sed 's/^.*(/(/' with perhaps a modification to get only the first.

I use the function wizard but can't seem to get the right code.

Discussion (9)2
Log in or sign up to continue

What version are you running where $EXTRACT is not available? Not sure I’ve heard of such a situation.  
 

edit: noted you referenced ..ReplaceStr which is an Interoperability function. There are semi-equivalents of $EXTRACT and $FIND in there as well - $EXTRACT is ..SubString. But note if you use the solution I or David presented, don’t use .. in front of $EXTRACT, $FIND or $PIECE as these aren't interoperability functions but pure ObjectScript functions. 
 

my suggestion, that I know works as we do something similar, is as follows:

“(“_$PIECE(input,”(“,2)

Have to re-add the opening paren since we’re using that as our splitter, but some find it easier than chaining multiple functions together. David’s solution is certainly valid too.

https://docs.intersystems.com/iris20221/csp/docbook/Doc.View.cls?KEY=RCO...