Question
· Jun 10, 2022

How to Copy NTE and append segments HL7 ensemble

Hi ,

We have inbound HL7 message we want to transform. Is it possible to copy inbound NTE segments at ORC level to PID group level in the transformed messages? I see functions  for insert / append / set etc but they appear to be related to specific properties / fields of segments as iodised to the entire segment.

thanks

Product version: Ensemble 2017.1
Discussion (6)0
Log in or sign up to continue

Hi Ciaran,

Might be your best bet to construct a message from scratch and start appending segments in the order you wish, for example, loop through the PIDgrp appending the segments you want to your newly constructed message and then loop through ORCgrp NTE's and append each segment.

You can loop through and append by using code such as:

If ORMIn.GetValueAt("ORCgrp(1).NTE(1)")'=""
{
        Set NTECount=ORMIn.GetValueAt("ORCgrp(1).NTE(*)")
        For i=1:1:NTECount
        {
                Set tSC=ORMOut.AppendSegment(ORMIn.GetSegmentAt("ORCgrp(1).NTE("_i_")"))
         }
}

Additional info:

I've added the following DTL and managed to append the ORC NTE segments from inbound message to outbound translated message PID NTE, issue is when I have multiple  ORC NTEs to append to PID NTE they overwrite as opposed  to appending as multiple NTE segments:

for each source.{PIDgrpgrp().ORCgrp().NTE()}

append target.{PIDgrpgrp().PIDgrp.NTE(k1)} source.{PIDgrpgrp().ORCgrp().NTE(k1)}

endeach

test- you can see only the one NTE is copied over:

Hey Ciaran.

To overcome the issue of multiple ORCs overwriting your PIDgrp NTE in your copy, you will likely need to maintain a separate count of what is being copied over.

So you could look to do something similar to: (pay specific attention to actions 2, 9, and 10) 

Which would then give the following result:

You could then take it a step further by setting the value of your PIDgrp NTE to your count value before incrementing it:

Which would then give you:

As a warning, I did find that the DTL building went a bit weird when it comes to the auto-applying of the key counts. So I was adding a For Each on a repeating field and it assigned a key of say k1, then when adding the sets within the for each loop, it would randomly use k2 or k3 in the field. it might just be a limitation of how I was building things up, but it's one to keep an eye out for as it'll give you unexpected results if it happens to you. Good luck :)

Thanks Julian,

I did something similar and set a counter and it works as expected.

One more query, I am also trying to iterate the OBXGrp().NTE's but the IF statement  is returning false, can you see anything wrong with the syntax?

 
For each: source.{PIDgrpgrp(1).ORCgrp(1).OBXgrp(1).NTE()}
                ..Contains(source.{PIDgrpgrp(1).ORCgrp(1).OBXgrp(k2).NTE(k2):Comment()},"192MT")
                        CODE:   S INAB = 1
 
 
 
I’m testing against this message so it should be picking up the OBX NTE with ‘192M’: