Get API Responses Onto Dashboard From ActorResponseTable

Dear Friends!

cc @pwargulak. i would like to know if i can create an endpoint that will fetch data from messages_actor_response database table by their priorities and render responses as flags or alerts in the patient dashboard .

Thoughts: Create a Rest Resource for ActorResponse that will get all endpoints for fetching responses for patients after a successful call. . Implying that when a patient responds to a call with a diagnosis forexample covid-19, This sysmptom is supposed to come from the messages_actor_response table and appear on patient dashboard as flag for a systems admin.

Doughts: How will the responses from the patient sync with SQL query definition since we can only have flags appear on the dashboard after defining them directly within the server.

Kindly request to clear direction on how to approach this. cc @pwargulak , @dkayiwa @mozzy

Thanks Regards

Hi @sharif you don’t need endpoint for that.

The idea of patient flags is that you define criteria (SQL, groovy script, Java impl) for a patient to be flagged. For example, if you want ‘newly added’ patients to be flagged as “New patient”, you can create a patient flag with SQL query criteria like: select patient_id from patient where date_created > DATE_SUB( current_time(), INTERVAL 7 day). That flag will appear on dashboards of all patients who ware added to system during the past 7 days.

Now, as for your use-case. You need a callflow which saves a response in messages_actor_response table - check registerResponse methods: MessagingService. Once you know what is saved - what is question id or what is question_text, what is answer id or answer_text - you can follow with patient flag.

You need a patient flag with SQL criteria, an SQL would look something like: SELECT patient_id FROM messages_actor_response WHERE question = 123456 AND text_response = 'YES'. And if your tag have all roles assigned, and if your patient dashboard has flags widget, if there is data in messages_actor_response, then you will see the flag.

Best regards, PiotrW

1 Like

Great thanks for your quick response. We are able to get flags in the patient dashboard as you have suggested above, However one challenge we are trying to replicate is,

Is it possible for us to be able to write rest resources that will get Responses from patients after a successful call? The idea is that we want to be able to use those endpoints in a client application to POST and GET data from client app back to the system.

Thanks, I think this is the reason why the Patient Flag module did not support Rest API, Is there a plan of bringing this back, or its not necessary?

This sounds awesome. Meaning that, if am interested in getting endpoints for what is saved in messages_actor_response based on question_id or question_text. We can create Rest API for POST and GET endpoints for them in the messages module Because we are interested in having endpoints for fetching responses from patients. Is this the right approach?

Hello @pwargulak @dkayiwa @mozzy. Here is an architectural diagram that represents the kind of work we are trying to achieve.

Ideally we have a databases called Message_Actor_Response Table where all the data we want to fetch gets stored. Using that same data, we want to be able to POST AND GET them back to HBC APP using REST. Hope this brings it out clearly.

Hi @sharif

I can’t speak for patient flags module, it’s part of an OpenMRS and I’m not OpenMRS guy.

I’ll pass the feature request to add REST endpoints for Message_Actor_Response table to the Connect for Life team.

Thanks @pwargulak , I’ll be glad to help Connect for life team add that feature there in messages Module because its urgently required.

Created A Pull Request Here.