android-fhir
android-fhir copied to clipboard
Ensure consistent search results across different timezones in date search
The DateTimeType
supplied above to patient
has time zone but not here. Will running the query in different time zones produce consistent results?
Can we add tests for that case or create an issue to add them later?
Originally posted by @deepankarb in https://github.com/google/android-fhir/pull/419#discussion_r655493322
The spec does say
Where possible, the system should correct for time zones when performing queries. Dates do not have time zones, and time zones should not be considered. Where both search parameters and resource element date times do not have time zones, the servers local time zone should be assumed.
ref : https://www.hl7.org/fhir/search.html#date
I think we can use the devices local timezone for and indexing search parameters (unless specified). I think it would also be pretty consistent although I can think of a one case where it may cause issues.
For example if a resource is indexed in IST (GMT +05:30) and then a search query is performed in UK standard time (GMT +01:00) it may produce some unexpected results (because while indexing we would assume IST and index the corresponding epoch value however while searching ,since we don't save the timezone info there is no way to know whether that epoch value is in IST or UK standard time). So if we search for June 21, 2021 1:06:25 PM
in UK standard time it would actually fetch results corresponding to June 21, 2021 5:36:25 PM
( as this is the corresponding time in IST)
I am not sure how often this would be an issue. However if we operate under the assumption that both the query and indexing take place in the same timezone then I don't think this would be too much of an issue. I think it's easier for servers to handle this since servers usually don't change timezones :P.