|
@@ -40,27 +40,85 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 2024-05-30: optimization round #1
|
|
|
+ // Handler for response from /api/visit/updateSegmentHtmlMultiple [uid, uid, ..]
|
|
|
+ window.updateAllSegmentsInResponseMultiple = function(_response, _updateListeners = true, _updateOnlySummary = false) {
|
|
|
+ if(!hasResponseError(_response)) {
|
|
|
+
|
|
|
+ // _response.data is an array
|
|
|
+ for(let i=0; i<_response.data.length; i++) {
|
|
|
+
|
|
|
+ let item = _response.data[i];
|
|
|
+
|
|
|
+ // refresh primary segment (where uid is _response.data.uid)
|
|
|
+ if(item && item.uid) {
|
|
|
+ updateSegmentByUid(item.uid, item.summaryHtml, item.editHtml, _updateOnlySummary);
|
|
|
+ }
|
|
|
+
|
|
|
+ // refresh listening segments
|
|
|
+ // TODO: batch it
|
|
|
+ if(_updateListeners) {
|
|
|
+ if(item && item.listenerSegmentUids && item.listenerSegmentUids.length) {
|
|
|
+ for (let i=0; i<item.listenerSegmentUids.length; i++) {
|
|
|
+ let listenerSegment = $('.note-section[data-segment-uid="' + item.listenerSegmentUids[i] + '"]');
|
|
|
+ let listenerSegmentTemplateName = listenerSegment.attr('data-segment-template-name');
|
|
|
+ if(listenerSegment && listenerSegment.length) {
|
|
|
+ $.post('/api/visit/updateSegmentHtml', {
|
|
|
+ segmentUid: item.listenerSegmentUids[i]
|
|
|
+ }, _data => {
|
|
|
+ updateAllSegmentsInResponse(_data, false, _updateOnlySummary);
|
|
|
+
|
|
|
+ // ugly hack!
|
|
|
+ if(listenerSegmentTemplateName === 'medrisk_vigilence') {
|
|
|
+ $('.mrv-trigger')
|
|
|
+ .empty()
|
|
|
+ .append('<div class="text-info font-weight-bold text-center font-size-11">MRV</div>')
|
|
|
+ .append(_data.data.summaryHtml);
|
|
|
+ }
|
|
|
+
|
|
|
+ }, 'json');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // refresh rhs-sidebar
|
|
|
+ window.refreshRHSSidebar();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
window.refreshRHSSidebar = function() {
|
|
|
+ // this function no longer refreshes the rhs sidebar
|
|
|
+ // kept here only so that callers don't err out
|
|
|
+ };
|
|
|
+
|
|
|
+ window.refreshRHSSidebarActual = function() {
|
|
|
let noteRHSSidebar = $('#note-rhs-sidebar');
|
|
|
if(noteRHSSidebar.length) {
|
|
|
let lastUpdatedAt = noteRHSSidebar.attr('last-updated-at');
|
|
|
if(lastUpdatedAt) {
|
|
|
lastUpdatedAt = +lastUpdatedAt;
|
|
|
- if(new Date().getTime() - lastUpdatedAt < 500) { // dont refresh if refreshed less than a second ago
|
|
|
+ // don't refresh if refreshed less than a second ago
|
|
|
+ if(new Date().getTime() - lastUpdatedAt < 1000) {
|
|
|
console.log('Skipping rhs sidebar refresh');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
- noteRHSSidebar.attr('last-updated-at', new Date().getTime());
|
|
|
$.get('/note-rhs-sidebar/{{$patient->uid}}/{{$note->uid}}', _data => {
|
|
|
noteRHSSidebar
|
|
|
.empty()
|
|
|
.html($(_data).html());
|
|
|
+ noteRHSSidebar.attr('last-updated-at', new Date().getTime());
|
|
|
$(window).trigger('scroll');
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ addMCHook('refreshRHSSidebar', refreshRHSSidebarActual);
|
|
|
+
|
|
|
window.updateSegmentByUid = function(_uid, _summaryHtml, _editHtml, _updateOnlySummary) {
|
|
|
let segment = $('.note-section[data-segment-uid="' + _uid + '"]');
|
|
|
if(segment && segment.length) {
|