Continuing my research over AZURE FHIR (Sql Version), I found that the lastUpdated search parameter somehow is corelated to the ResourceSurrogateId field (in the Resource table).
Moreover, I believe both are the same but in different formats. However, I did not find any source explaining how the lastupdated (a date-time value) is transformed into the ResourceSurrogateId (numeric Value).
Can somebody explain me how can I get a ResourceSurrogateId based on its original date-time value?
Test: I run the followig FHIR REST API:
https://XXXXXXXXXXX/DeviceComponent?_lastUpdated=gt2019-07-01
and the actual query on the database was:
FROM dbo.Resource r
WHERE ResourceTypeId = @p1
AND ResourceSurrogateId >= @p2
AND IsHistory = 0
AND IsDeleted = 0
ORDER BY r.ResourceSurrogateId ASC
OPTION(RECOMPILE)',N'@p0 int,@p1 smallint,@p2 bigint',@p0=11,@p1=32,@p2=5095809792000000000```
The resource surrogate ID encodes the datetime of insert to millisecond precision along with a "uniquifier" that comes from a cycling sequence on the database. The code that converts from a surrogate ID to datetime and back is here.
You will not be able to get the surrogate ID from the datetime, but you will be able to get lower and upper bounds on it.