Good morning,
The Patients GET Simple returns results sorted by PatNum (ascending). You are quite correct that if the API were to return unsorted results it would be difficult to get datasets complete/in sync. We call this "drift" in our documentation. Nearly all of our API GET endpoints sort by the Primary Key of their table. A notable exception is Appointments GET, which sorts by AptDateTime
then AptNum, due to how appointments are used.
1. Fetching in DateTStamp Order:
Is there a search parameter or any other way to fetch patient records in an ordered manner by `DateTStamp`?
No. All API methods will return sorted by default and do not allow for custom sorting.
2. ... When using the `DateTStamp` parameter to fetch records updated or inserted ... will this ensure that all records are returned in chronological order of `DateTStamp`
No. Using an optional parameter does not change the default sorting in any way, including to sort by the parameter(s).
From your description, it sounds as though you are leveraging the DateTStamp parameter correctly. By using this parameter, you can only return records that have changed since the last time your application polled for the data. These results will be sorted by Primary Key, so while they they aren't ordered by date, they are ordered so that you can page/collect all the data in the set.
That process will work great for keeping your application's cache up-to-date, but the initial data grab would be a lengthy process. If this is something you are sure your application needs to do (eg Open Dental does not cache the patient table) then I would recommend using our
Queries POST endpoint. This would allow you to query for the specific data you want, ORDER BY whichever parameters you want, and eliminate paging altogether.
Another strategy to keep an up-to-date list of patient data is to leverage Api Events. These are essentially identical to your application running using Patients GET Simple with the DateTStamp parameter, but Open Dental itself performs this logic automatically, and sends it to a webhook site you host. More information on ApiEvents can be found in our
API Guide – Subscriptions and Events.
Happy to help if you have further questions.