Codelist

Codelist Ordering

Users can define how items in a codelist should be ordered through a flexible annotation-based approach.

The behavior depends on the annotation specified at the codelist level:

  1. Codelist-Level Annotation

To enable ordering, an annotation must be added at the codelist level with the following properties:

Type: ORDER_BY

ID: @SXS

Text value: one of:

ORDER: Items will be sorted based on custom order values.

ALPHA: Items will be sorted alphabetically.

NONE: No specific ordering will be applied.

  1. Item-Level Annotation (only required for ORDER)

If the ORDER_BY value is set to ORDER, then an additional step is required:

Only items that need to be positioned explicitly require an annotation specifying their order value; other items that do not include an annotation will be placed according to default logic.

Type: ORDER

Text: A numeric value representing the item's order value.

Example:

For a codelist named CODELIST1, here’s how the items might be annotated:

{ "id": "item1", "annotations": [ { "type": "ORDER", "text": "2" } ] }
{ "id": "item2", "annotations": [ { "type": "ORDER", "text": "1" } ] }
{ "id": "item3", "annotations": [ { "type": "ORDER", "text": "4" } ] }
{ "id": "item4", "annotations": [ { "type": "ORDER", "text": "3" } ] }

This configuration results in the following order: item2, item1, item4, item3

🔹 Note: When ALPHA or NONE is used, no item-level annotation is required. The sorting is automatically applied based on the selected strategy.