We have a requirement to paginate list data in the OHRI widgets / tables that display it. We are experimenting an implementation approach but this requires that we know the total count/number of records before hand in order to paginate.
Looked around the FHIR documentation but can’t seem to see any endpoint that returns the total count of say the Encounter Resource given certain filter criteria.
Do we have any such endpoint? Secondly, any ideas on implementation approaches to paginate list data in the micro-frontends?
Is it fair to assume filter criteria are simple and are indexed in the database. Returning a total count for arbitrary criteria, complex filters, or criteria that include data that aren’t indexed would not perform well in existing systems that have hundreds of thousands or millions of encounters.
As a general principle, we haven’t documented things where we’re just conforming to the FHIR spec. As @corneliouzbett pointed out, there is a total element in all search bundles. While not strictly required by the spec, it is returned for all searches for OpenMRS. If you want to know just the total, you can run the query with ?_summary=count as noted in the FHIR search document.
By default, the FHIR2 API returns 10 results (this can be changed via the fhir2.paging.default). You can request more resources by using the _count=... search parameter (also documented in the FHIR search documentation) up to the value of the fhir2.paging.maximum global property (which defaults to 100).
This is a very important consideration and the FHIR2 search API can easily be abused to create a pathological query.
Strictly speaking, most frontend widgets are unaware that they are only using paged results and don’t properly handle things .