Filtering Base Resources by Date
Utilizing the lastUpdated Parameter with the SearchDate Class in the b.well SDK
lastUpdated Parameter with the SearchDate Class in the b.well SDKThe lastUpdated parameter, combined with the SearchDate class, offers a powerful tool for fetching base health data resources based on their modification dates. This feature allows for fine-grained control over the data retrieval process, ensuring you access the most recent and relevant information.
Defining Search Criteria with SearchDate
SearchDateThe SearchDate class encapsulates search criteria based on dates, utilizing operations like equals, not equals, greater than, and less than. This flexibility enables SDK users to precisely target the retrieval of health data updates.
Specific operations are utilized to refine search queries by date, each with unique characteristics and combinability rules:
equals: Finds records exactly matching a specified date. Cannot be combined with other operations.notEquals: Excludes records matching a specified date. Cannot be combined with other operations.greaterThan: Selects records updated after the specified date. Cannot be combined withgreaterThanOrEqualTo,equals,notEquals, orapproximately. Exception thrown iflessThanorlessThanOrEqualToset a date that occurs before thegreaterThandate.greaterThanOrEqualTo: Similar to "Greater Than" but includes the exact date. Cannot be combined withgreaterThan,equals,notEquals, orapproximately. Exception thrown iflessThanorlessThanOrEqualToset a date that occurs before thegreaterThandate.lessThan: Retrieves records updated before the specified date. Cannot be combined withlessThanOrEqualsTo,equals,notEquals, orapproximately. Exception thrown ifgreaterThanorgreaterThanOrEqualsToset a date that occurs after thelessThandate.lessThanOrEqualTo: Similar to "Less Than" but includes the exact date. Cannot be combined withlessThan,equals,notEquals, orapproximately. Exception thrown ifgreaterThanorgreaterThanOrEqualsToset a date that occurs after thelessThanOrEqualsTodate.approximately: Searches for records around a specified date and returns results within a 10% margin. Cannot be combined with other operations.
Building a SearchDate Instance
SearchDate InstanceTo use the lastUpdated parameter effectively, you construct a SearchDate instance with the desired search criteria using its builder pattern. Here’s how you can specify different date conditions:
val lastUpdateSearchDate = SearchDate.Builder()
.greaterThanOrEqualTo(SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2024-01-12 22:00:00"))
.build()Applying SearchDate to Data Retrieval Requests
SearchDate to Data Retrieval RequestsWith the SearchDate object ready, you can include it in your data retrieval requests. For example, when fetching immunizations updated after a specific date, your request might look like this:
val request = ImmunizationRequest.Builder()
.lastUpdated(lastUpdateSearchDate)
.build()Updated about 2 months ago
