Implement support for the %rowIndex environment variable as defined in the SQL on FHIR ViewDefinition spec.
%rowIndex is a built-in environment variable that provides the 0-based index of the current element within the collection being iterated by forEach, forEachOrNull, or repeat. At the top level (no iteration), it evaluates to 0. Each nesting level maintains independent %rowIndex values.
Use cases:
- Preserving ordering — SQL result sets lack inherent ordering, so including the original index allows users to restore the sequence of FHIR data elements
- Disambiguation — when resources contain multiple repeating elements (e.g. multiple patient names), the index distinguishes first, second, etc.
- Surrogate keys — combining resource ID with element index creates unique row identifiers
Implement support for the
%rowIndexenvironment variable as defined in the SQL on FHIR ViewDefinition spec.%rowIndexis a built-in environment variable that provides the 0-based index of the current element within the collection being iterated byforEach,forEachOrNull, orrepeat. At the top level (no iteration), it evaluates to0. Each nesting level maintains independent%rowIndexvalues.Use cases: