Skip to content

Implement %rowIndex environment variable #2560

@johngrimes

Description

@johngrimes

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

Metadata

Metadata

Assignees

Labels

fhirpathRelated to fhirpath reference implementationsqlonfhirChanges that relate to SQL on FHIR functionality

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions