Question
· Jul 31, 2019

Remove a segment from the HL7 Message

Hi,

I have a ORU message, which has a EVN segment that I want to remove and send the message across.

I tried to clone the request as below:

s newreq = request.constructClone

s changreq = newreq.RemoveSegmentAt("EVN")

Set request  = changereq

but it fails. Is there a way that I can safely remove a segment and pass it on?

Would appreciate your help in this

Regards,

Eric

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

the message coming in is an ORU_R01 message, and contains an EVN segment, however in the schema 2.4 there is no EVN segment in the ORU message structure. so how can I remove the segment, is there a way to do that? Sorry for the hassle.  

I want to pass this message to the third party system having the EVN segment removed. Will keep trying but if you have any ideas would apprecaite.

Thank you

Ah, now it makes sense. The Document type you'd specified for the inbound message did not match the structure of the message itself, so the RemoveSegmentAt() method didn't know how to "find" the EVN segment ... it didn't exist in that schema.

The recommended approach would be to use a schema/document type (custom if necessary) that matches the structure of your inbound message, making the segment to be removed optional in the definition. With that in place, the RemoveSegmentAt() method would have worked as expected.

Hello @ED Coder,

you can also use a "low-code" approach using the DTL language with the REMOVE action :

Class utils.HL7.transfo.removeSegment Extends Ens.DataTransformDTL [ DependsOn = EnsLib.HL7.Message ]

{
Parameter IGNOREMISSINGSOURCE = 0;
Parameter REPORTERRORS = 1;
Parameter TREATEMPTYREPEATINGFIELDASNULL = 0;
XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='EnsLib.HL7.Message' targetClass='EnsLib.HL7.Message' sourceDocType='2.6:ADT_A01' targetDocType='2.6:ADT_A01' create='copy' language='objectscript' >
<assign value='' property='target.{EVN}' action='remove' />
<assign value='' property='target.{DG1()}' action='remove' />
</transform>
}
}