Search code examples
azuresortinghl7-fhir

What is the default sort when searching for resources in Azure API for FHIR?


Granted that _sort is not yet supported in Azure API for FHIR as documented here and discussed in this question, I'd like to know what the default sort is (assuming there is one).

For example, if I search for locations by making the following request:

GET [base]/Location?_count=10

The response contains 10 location resource entries as expected. The question is: in what order are these resources?

After doing some manual comparisons, the default sort does not appear to be on the following properties:

  • id
  • name
  • lastUpdated

Is the default sort on some other field(s)? If so, which field(s)? Or is it that, in the absence of a _sort parameter, resources are returned in random or arbitrary order at the discretion of the server?


Solution

  • Currently only _lastUpdated is a supported sort param, and it's also the default sort for queries.

    GET [base]/Location?_count=10&sort=_lastUpdated (well actually &sort=_lastUpdated is redundant because it's the default)

    Or

    GET [base]/Location?_count=10&sort=-_lastUpdated to sort descending.