• Home
  • /HL7 Code
  • /How can I remove RXA-12, not just delete the value, but remove it?

How can I remove RXA-12, not just delete the value, but remove it?

Question: How can I remove RXA-12, not just delete the value, but remove it so that RXA-13 becomes the new RXA-12?

To do this you can use the simple function below. They way it works is to go through all RXA segments and calls the RemoveAt(12) on the segment fields. This will remove the field causing all fields after RXA-12 to be offset by one.

public override void Run()
{
   HL7Message message = GetParsedMessage();
   foreach(HL7Segment segment in message.GetSegments("RXA"))
   {
     segment.Fields.RemoveAt(12);
   }
    
   this.SaveMessage(message,"RXA-12 Removed");
}