How to Update lastUpdated in Meta whenever a resource is updated, even if the resource updated is the same.

332 views
Skip to first unread message

pvnmur...@gmail.com

unread,
Aug 31, 2021, 12:11:13 AM8/31/21
to HAPI FHIR
Hi,

I want to update the lastUpdated in meta field whenever a resource is updated in Fhir repo. By default, the lastUpdated value is not changed if the same object is PUT multiple times. But I want to have a different lastUpdated  value set to current datetime value , even when the PUT resource is the same.

I tried the following but it is not updating the lastUpdated field in meta object:

@SuppressWarnings("unchecked")
@Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED)
public void incomingStoragePreStorageResourceUpdated(IBaseResource oldResource,IBaseResource newResource ,ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,ca.uhn.fhir.rest.server.servlet.ServletRequestDetails servletRequestDetails,
ca.uhn.fhir.rest.api.server.storage.TransactionDetails transactionDetails){

org.hl7.fhir.r4.model.Patient pat= (org.hl7.fhir.r4.model.Patient)newResource;
Meta meta = pat.getMeta().setLastUpdated(new Date());//setting lastUpdated to current date time
pat.setMeta(meta);
}

Any help would be appreciated. Please let me know, if you need more details.

thanks,
Narasimha
Reply all
Reply to author
Forward
0 new messages