Jeff Harris · Jul 27, 2020

Ensemble - Using an indexed array in DTL - Can't pull information from an Array in the transformation

I want to write the values that are stored in an array into the OBX 5 field.  The text in MyArray(1) will go in the the first OBX 5 field.  Then the text in MyArray(2) will populate the next OBX 5 field. 

My question is how do you format the Set > Action Tab > Value entry so that it pulls the data from MyArray(source.{PIDgrpgrp().ORCgrp().OBXgrp().OBX:SetIDOBX})

I know the array is ok, because when I hard code MyArray(2) in the Set > Action Tab > Value, then the OBX lines contain the correct element in MyArray(2).  When I drop source.{PIDgrpgrp().ORCgrp().OBXgrp().OBX:SetIDOBX} into Set > Action Tab > Value, then I see the number steadily increase.  

Maybe I'm just missing quotation marks or brackets, but I just don't know how to format MyArray(source.{PIDgrpgrp().ORCgrp().OBXgrp().OBX:SetIDOBX}) so that it doesn't error.

Any tips?

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

Hi Jeff,

You need to traverse the array using the foreach action. The key of you array wil be the key of the OBXgrp. for the others group I'll assume that are fix with the key "1". Bellow a simple example. 

<transform sourceClass='br.cjs.test.ArrayMessage' targetClass='EnsLib.HL7.Message' targetDocType='2.3.1:ORU_R01' create='new' language='objectscript' >
<foreach property='source.ArrayData()' key='k1' >
<assign value='source.ArrayData.(k1)' property='target.{PIDgrpgrp(1).ORCgrp(1).OBXgrp(k1).OBX:SetIDOBX}' action='set' />