Speeding up Clinician Facing Dashboard - Dashboard Widgets

I am wondering if there is any suggestion on speeding up the loading of the dashboard widgets, since the core is now moving to REST calls. There are about 40 AJAX calls to load the data for the different widgets

Do we tweak Tomcat? The database tweaks are innodb_buffer_pool_size which is already at 40% RAM for a Windows server so the database fits in memory.

This page takes about 20 seconds to load, which becomes an issue for clinicians using it. Any suggestions for further profiling to find the bottle necks?

My first thought, if this page requires 40 ajax calls, is that it must be making multiple calls per widget, and these should be combined. In other words introduce a new rest resource for each widget that currently makes multiple calls. The new resource may make multiple Java API calls, but combines into a single rest response.

(You could think of this as the back ends for front ends pattern, in other words it’s appropriate for the ref app to provide these rest controllers in the core apps module. there might also be an argument for doing this directly in the rest module, but I’m not certain about that.)

Or maybe some of these widgets could query the reporting module.

How long does the same page take to load when you remove all the custom dashboard widgets?

So we need to restructure all the components which are connected to this Dashboard to make this combined REST calls.

Or else, Can we direct all the REST calls from this widgets through a intermediate communicator (may be JS based communicator), and store the responses in a short memory storage(unique for the patients or calls). Then the communicator should return the stored response data to the caller if the requested REST calls is points to exiting one. Using this way, We need to implement a intermediate communicator for this widgets and no more major chances for the widgets or REST resources. Is it possible to make it?

Cc : @darius, @dkayiwa, @ssmusoke

It is much faster - the timelag is with the REST

Unfortunately you cannot cache the calls, as these are to data that can change at any time. It will be too much work to have to invalidate caches.

This is an excellent idea, which will certainly speed up the calls e.g., latestobsforconceptlist makes a REST call for the latest obs for each concept specified in the list. If this is mapped to a single REST interface then a single call is made irrespective of the number of concepts specified.

Created [RA-1520] - OpenMRS Issues

For this specific example (get latest obs for multiple concepts for a patient), this seems worth adding to our core REST module. But it would require some extra design there, so you should probably do the quick-fix in the coreapps module first.

@dkayiwa a followup on this requirement, my thoughts for the first custom proof of concept endpoint:

  1. Url - latestconceptvalue
  2. Parameters
    • conceptlist (required) - Comma delimited list of Concept numeric id, uuid, or mapping
    • maxAge (optional) - Numeric integer with a suffix for example, 1d – 1 day, 2w – 2 weeks, 4m – 4 months from the current date
  3. Returns - similar to the concept endpoint (no changes)

latestconcept or latestobs?

@dkayiwa you are right latestobs

Can you give a sample call and details that you are currently making multiple times? Or just point me to where that is?

“LATEST OBSERVATIONS” widget on demo.openmrs.org

@dkayiwa ping

@dkayiwa the code for the widget is https://github.com/openmrs/openmrs-module-coreapps/blob/1057a14c0330eba85e00f6431521de79726b9aff/omod/src/main/resources/apps/dashboardWidgets_app.json#L2-L25

The Javascript files are https://github.com/openmrs/openmrs-module-coreapps/tree/1057a14c0330eba85e00f6431521de79726b9aff/omod/src/main/web/dashboardwidgets/latestobsforconceptlist