Question
John Nurmi · Nov 5

In Transform Order AIS by AIS 3.1 value

I have a SIU message that has multiple AIS segments in an RGS group. I need to reorder the AIS segments based on the AIS 3.1 value.

What is the most efficient way to do this in a transform?

Product version: HealthShare 2017.2
$ZV: Cache for UNIX (IBM AIX for System Power System-64) 2017.2.2 (Build 867_4_20755U) Thu Apr 8 2021 11:23:20 EDT [HealthShare Modules:Core:15.032.9692 + Linkage Engine:15.032.9692]
00
3 0 1 46
Log in or sign up to continue

Are the values in AIS:3.1 sequential integers ranging from 1 to the number of AIS segments? If yes, it's very easy.

If not ... just a little harder. You'd populate a subscripted variable using the values in AIS:3.1 as the index and the segment repetition number as the array element value. Then $ORDER() through it get the source segment repetition number and assign that segment to the target in AIS:3.1 order. For example:

The variable tAISArr will be subscripted by the values in AIS:3.1. So now we just $ORDER() through tAISArr in a code action:

 set tIdx = 1
 set tKey = $ORDER(tAISArr(""))
 while (tKey '= "")
 {
      // Grab the segment identified by the value of the array subscript
      set AISSeg = source.GetValueAt("RGSgrp(1).AISgrp("_tAISArr(tKey)_").AIS")
      // stuff it into the target segment at the current position of the value of the loop counter tIdx
      do target.SetValueAt(AISSeg,"RGSgrp(1).AISgrp("_tIdx_").AIS")
      // Don't forget to renumber the Set ID
      do target.SetValueAt(tIdx,"RGSgrp(1).AISgrp("_tIdx_").AIS:1")
      set tIdx = tIdx + 1
      set tKey = $ORDER(tAISArr(tKey))
 }

Sample Input:

Sample Output: