Article
· Jul 25, 2016 1m read

Tips & Tricks - How to remove a group of HL7 segments

EnsLib.HL7.Message.cls provides many API methods for manipulating an HL7 message.  RemoveSegmentAt(), for example, can be used to remove a segment by path or index, but only one segment at a time.   There may be times that you'll need to remove all segments within a group or even many groups of segments from the HL7 message.  Surely you can iterate through each segment in each group and remove them one by one, but there's a much easier way. 

 

With just one command, like below, you can remove all OBX segments in an ORU_R01 message (msg):

Set tSC = msg.SetValueAt(,"PIDgrpgrp(1).ORCgrp(1).OBXgrp()","remove")

 

Or, with just the following command, you can easily remove all PR1 and ROL segments within a specific group in an ADT_A01 message (msg):

Set tSC = msg.SetValueAt(,"PR1grp(1)","remove")

 

I hope you'll find this article helpful. Let me know if you have any question or concern. Cheers!

Discussion (1)0
Log in or sign up to continue