Is it possible to retrieve updated or newly created resources separately?
I have 3 claim resources. Of which, two resources are updated, so their versionId = 2. Now, is it possible to get these updated claim resources alone?
Azure Health Data Services
-
navba-MSFT 17,575 Reputation points • Microsoft Employee
2023-07-13T10:51:57.44+00:00 @P, Pioline (Cognizant) Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
- Could you please provide more information about your ask?
- Which Azure resource are you referring to ?
- Please explain your use case and requirement.
This will help us to assist you better.
-
P, Pioline (Cognizant) 195 Reputation points
2023-07-13T11:01:06.4166667+00:00 Hi Sure I will provide the info.
The resources I have are Claim resources. These resources are already pushed into Azure Health Data Services - FHIR service.
My requirement is: I want to make a GET request to retrieve only updated resources, and not the newly created resources. (not the latest claim resource, but any claim resource that got updated)
What I explored so far:
When we update a Claim resource, versionID param under meta gets updated. So using this versionId can we retrieve the updated Claim resources alone. -
navba-MSFT 17,575 Reputation points • Microsoft Employee
2023-07-13T13:02:03.4333333+00:00 @P, Pioline (Cognizant) Thanks for clarifying your ask. Your understanding is correct, when a Claim resource is updated, the
versionId
parameter under themeta
element is updated to a new value.You can use the
versionId
search parameter to retrieve a specific version of a Claim resource.However, if you want to retrieve all updated Claim resources, you would need to keep track of the version IDs of the Claim resources that have been updated since the last time you made a request. This can be difficult to manage, especially if there are many Claim resources being updated frequently.
Using the
_lastUpdated
search parameter is a simpler and more efficient way to retrieve all updated Claim resources. The_lastUpdated
parameter allows you to retrieve all resources that have been updated since a specified date and time, without having to keep track of individual version IDs.GET [base]/Claim?_lastUpdated=ge2023-04-01T00:00:00Z
This will return all Claim resources that have been updated since April 1st, 2023.
If a user updates an existing resource and only meta.versionId or meta.lastUpdated have changed then we return OK with existing resource information without updating VersionId and lastUpdated. For more information, see #2519.
Hope this helps.
Sharing some useful articles:
https://learn.microsoft.com/en-us/azure/healthcare-apis/azure-api-for-fhir/overview-of-search#common-search-parameters
https://learn.microsoft.com/en-us/answers/questions/1187873/azure-fhir-apis-support-for-since-and-lastupdated
https://learn.microsoft.com/en-us/azure/healthcare-apis/fhir/fhir-versioning-policy-and-history-management**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.
-
P, Pioline (Cognizant) 195 Reputation points
2023-07-17T04:38:05.1233333+00:00 But the above GET request retrieves both updated as well as new Claim resources. I wish to get only the updated resources alone
-
navba-MSFT 17,575 Reputation points • Microsoft Employee
2023-07-17T14:13:53.9966667+00:00 @P, Pioline (Cognizant) Thanks for getting back. To retrieve only the updated Claim resources and exclude the newly created resources, you can modify the GET request by specifying the
_has
parameter with the versionId qualifier.GET [base]/Claim?_has:Claim:versionId:gte=[last_version_id]
Replace [base] with the base URL of your FHIR service, and [last_version_id] with the versionId of the last Claim resource you retrieved.
This modified GET request using the _has parameter with the versionId qualifier will retrieve all Claim resources that have a versionId greater than or equal to the specified last_version_id. This will exclude any newly created Claim resources but include those that have been updated since the last retrieval.
By tracking the versionId of the last Claim resource you retrieved, you can ensure that you only fetch the updated resources in subsequent requests.
Note that you need to retrieve the versionId of the last Claim resource you fetched and use it in the subsequent requests to retrieve only the updated resources.
-
P, Pioline (Cognizant) 195 Reputation points
2023-07-17T14:44:45.9466667+00:00 Thanks.
When I give make this request:
GET [base]/Claim?**_**has:Claim:versionId:gte=[last_version_id]I am getting 400 response - bad request. Id must be a combination of upper or lower case ASCII letters.
-
navba-MSFT 17,575 Reputation points • Microsoft Employee
2023-07-18T05:39:01.63+00:00 @P, Pioline (Cognizant) Thanks for your reply. Could you please confirm if you have used the asterisk ? It shouldn't be used. Please try it without the asterisk and test again.
Alternatively, you can use the
_filter
parameter instead of the_has
parameter to retrieve only the updated Claim resources and exclude the newly created resources.Here is an example of how to use the _filter parameter to retrieve the updated Claim resources:
GET [base]/Claim?_filter=versionId>=last_version_id
Replace [base] with the base URL of your FHIR service, and [last_version_id] with the versionId of the last Claim resource you retrieved.
https://learn.microsoft.com/en-us/azure/healthcare-apis/fhir/search-samplesThis modified GET request using the _filter parameter with the versionId qualifier will retrieve all Claim resources that have a versionId greater than or equal to the specified last_version_id. This will exclude any newly created Claim resources but include those that have been updated since the last retrieval.
By tracking the versionId of the last Claim resource you retrieved, you can ensure that you only fetch the updated resources in subsequent requests.
Note that the _filter parameter is a more powerful and flexible search parameter than the _has parameter, but it requires more knowledge of the FHIR search syntax.
-
P, Pioline (Cognizant) 195 Reputation points
2023-07-18T05:57:27.7866667+00:00 Thanks.
Earlier, I gave the asterisk, hence the error. Now, I made the GET request with the following:
GET [base]/Claim?_has:Claim:versionId:gte=[last_version_id]I am getting this response: "The search parameter '_has:Claim:versionId:gte' is not supported for the resource type 'Claim'. "
**
_filter operation** is not working in FHIR service. I saw in documentation that _filter is not supported yet. I test also, there was no error, but response was incorrect. It retrieved all the resources. -
navba-MSFT 17,575 Reputation points • Microsoft Employee
2023-07-18T06:57:04.6866667+00:00 @P, Pioline (Cognizant) Thanks for getting back. Since, the
_lastUpdated
search parameter retrieves both updated and new Claim resources. To retrieve only updated Claim resources, you can use the_summary
search parameter to retrieve only the meta element of the Claim resources. The meta element contains information about the version ID and last updated timestamp of the resource.GET [base]/Claim?_lastUpdated=gt[timestamp]&_summary=meta&_sort=-meta.versionId&_count=1
The example you provided is correct. It will retrieve the meta element of the most recently updated Claim resource. The
_sort
parameter is used to sort the results by themeta.versionId
field in descending order. The_count
parameter is used to limit the number of results to 1.Here is an explanation of the query parameters in the example:
-
_lastUpdated=gt[timestamp]
- This parameter specifies that the results should be limited to Claim resources that were last updated after the specified timestamp. -
_summary=meta
- This parameter specifies that only the meta element of the Claim resources should be returned. -
_sort=-meta.versionId
- This parameter specifies that the results should be sorted by themeta.versionId
field in descending order. -
_count=1
- This parameter specifies that the number of results should be limited to 1.
-
-
P, Pioline (Cognizant) 195 Reputation points
2023-07-18T07:21:48.2566667+00:00 I tried this as you mentioned:
GET [base]/Claim?_lastUpdated=gt[timestamp]&_summary=meta&_sort=-meta.versionId&_count=1Response is 400 Bad request. The requested summary paramter 'meta' is invalid. Allowed values are 'True,Text,Data,Count,False'
-
navba-MSFT 17,575 Reputation points • Microsoft Employee
2023-07-27T04:06:43.73+00:00 @P, Pioline (Cognizant) Apologies for the late reply. Thanks for getting back. Could you please provide me some more context here about your actual and complete Use case ? Why do you want just the updated resource ? Awaiting your reply.
Sign in to comment