Ensemble - How do I change the order in which addenda segments appear in the OBX?

Primary tabs

Ensemble

While I am not new to HL7, I am very new to Ensemble.   

We have a request to change the order in which the Addenda segments are sent to the client.  Right now, the global setting of the Lab system is to send the newest addenda at the top of the report, then the next oldest, and so on until we get to the final report:

OBX|1|||*****Addendum 3****
OBX|2|||text 3
OBX|3|||*****Addendum 2****
OBX|4|||text 2 
OBX|5|||*****Addendum 1****
OBX|6|||text 1
OBX|7|||*****Final****
OBX|8|||final text

 

One particular doctor's group wishes to have its reports with the oldest addenda sent first, then the second addenda next, and so on until the final text:

OBX|1|||*****Addendum 1****
OBX|2|||text 1
OBX|3|||*****Addendum 2****
OBX|4|||text 2 
OBX|5|||*****Addendum 3****
OBX|6|||text 3
OBX|7|||*****Final****
OBX|8|||final text
 

The addenda are clearly marked in the ORU, and the asterisks make it easy to see where a new Addenda begins and ends, and it also very happily creates a numbered index for me.  Clearly being new to DTL,  is it possible to feed the content from OBX|1| and OBX|2| into a variable like "BlobAddenda1", and then OBX|3| and OBX|4| into "BlobAddenda2", and then write them in the opposite order in the outgoing message?

Any help or direction would be greatly appreciated.

 

 

Replies

Hey Jeff,

I wrote up a quick sample that doesn't get quite what you wanted, but I think it's close enough that you'll be able to take it from there. If not, feel free to ask further.

My sample reverses the first FT1grps and leaves the last one in the final slot.

First I used * to get the count: Counting Fields

If you wanted to implement some more complex logic you could potentially do it here. Alternatively, you might want to write a custom utility function to perform the chunking and reversal. This keeps your code more compartmentalized and keeps too much from sitting in the DTL itself.

Defining Custom Utility Functions