How to fetch last viewed patients via RESTful API?

Hi

I want to fetch last viewed patients from the server, like when we go to Find Patient Record in the demo server web client here: https://demo.openmrs.org/openmrs/coreapps/findpatient/findPatient.page?app=coreapps.findPatient

REST documentation is not mentioning this but the project I am working with uses this: https://demo.openmrs.org/openmrs/ws/rest/v1/patient?lastviewed

However, it just returns an empty list. Is there another query parameter other than lastviewed ?

EDIT: I’ve submitted a ticket for this:

https://issues.openmrs.org/browse/EA-172

@abertnamanya Any ideas?

Here is the logic which was used to query the last viewed patients in the coreapps, openmrs-module-emrapi/GeneralUtils.java at df9979bb44293738a1ce4fb08f1426edee7fb0cf · openmrs/openmrs-module-emrapi · GitHub . Went through the Rest Module I can’t see the same logic to query the last viewed.

If it’s not implemented and there is no alternative we could have it as one of patient’s query parameters.

CC: @dkayiwa Please advise

Regards,

1 Like

@abertnamanya you are correct. We do not have a REST API for the last viewed patients.

1 Like

So, in the core app, last viewed patients are retrieved from a user object, do we save these patients locally as there is no API for this ? If you can refer me to User class I’d appreciate it :pray:

It’s a yes and No, newly interacted patients go to user_property table, this enables one to easily view the recent patient he/she has registered into the system even before search through the database.

Best solution is to get heads up for the creation of the ticket to handle this in the patient rest-end point

1 Like

Got it. Thanks @abertnamanya

@salahoamro would it be enough for you to just do something like this? https://demo.openmrs.org/openmrs/ws/rest/v1/user/45ce6c2e-dd5a-11e6-9d9c-0242ac150002?v=custom:(userProperties)

@dkayiwa Yes, but with UUIDs of patients because Android Client has its own ids for patients, and only uses UUIDs for communicating with the server.

The ticket concerning this issue:

https://issues.openmrs.org/browse/EA-172