Hi all,
We need to have some sort of pagination (or batch loading) of the encounters on the patient dashboard. When there are too many encounters to display, this page could take up to minutes to load, while at the same time just paralysing the backend for every other logged in user.
Culprit here in VisitDetailsFragmentController.java:
for (Encounter encounter : visitWrapper.getSortedEncounters()) {
encounters.add(parseEncounterToJson.createEncounterJSON(authenticatedUser, encounter));
}
createEncounterJSON(..)
when called many times hits some serious performance issues.
I would like to load the encounters by batches whose size would be set through a GP. And, for instance, add a ‘load more’ button that would trigger the loading of the next batch of encounters. That’s easy enough to do for the first batch, but it’s the JavaScript here in visitDetailsTemplate.gsp that bothers me:
[[ _.each(encounters, function(encounter) { ]]
[[= encounterTemplates.displayEncounter(encounter, patient) ]]
[[ }); ]]
Admittedly I don’t know much about Underscore.js and those templates patterns.
(Q.) I guess my question is: how can I resend an updated encounters
array to the client (array that is the previous one + a new batch of encounters) and have this above JS loop to be re-evaluated so that the display is updated accordingly?
Or otherwise, according to you, what would be the least costly way to achieve this basic pagination system?
Any ideas/suggestions would be really welcome!
Cc: @darius, @mogoodrich, @dkayiwa