Patient save or update data entry source

Hi all,

I am working on modifying Bahmni atomfeed module for one of our project where we need to get notified of updates into OpenMRS system (Bahmni's Atom Feed module in the OpenMRS module repo?). Our system also keeps pushing data to OpenMRS via REST which offcourse we dont want to get back again.

The module have a Spring Advice on “savePatient” method of PatientService. This method is called whenever a patient record is inserted or updated.

We want this method to skip creating atomfeed incases when patient is created from a our own system. This works fine for new data as for those we send a particular patient identifier, but for updates we are unable to find where does update request come from!

A hacky solution could be to skip atomfeeds for patient data updates done form a specific user role (daemon service user) but then patient`s ‘ChangedBy’ doesnot get updated everytime. For example incase of updating address it does not set ‘ChangedBy’ but savePatient method is called. This is also true for updates to patient_identifier.

Is there any property that would be consistent for all objects and can be used to seggregate “data entered by user”? Or w should move advice to any level (Hibernate or REST)

If OpenMRS is the system of record for the data, then I would countersuggest that you probably do want to update your other system with OpenMRS’s view of the data, even if you just posted it to OpenMRS, so you ensure that the other system has a copy of the latest data-of-record.

However, assuming you’ve thought this approach through and have good reasons to approach it this way…

Can’t you just check Context.getAuthenticatedUser(), and check whether it’s the user that represents your external system?