|
@@ -67,7 +67,12 @@ var findEventHandlers = function (eventType, jqSelector) {
|
|
|
|
|
|
window.top.addEventListener('popstate', function (event) {
|
|
window.top.addEventListener('popstate', function (event) {
|
|
window.setTimeout(function () {
|
|
window.setTimeout(function () {
|
|
- if (!event) return;
|
|
|
|
|
|
+ hideMask();
|
|
|
|
+ hideMoeFormMask();
|
|
|
|
+ if (!event || (!event.state && event.state !== '')) {
|
|
|
|
+ console.error('ALIX No state!', event, event.state);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
var state = event.state;
|
|
var state = event.state;
|
|
if (state === '') state = '/';
|
|
if (state === '') state = '/';
|
|
if (state[0] !== '/') state = '/' + state;
|
|
if (state[0] !== '/') state = '/' + state;
|
|
@@ -75,8 +80,9 @@ window.top.addEventListener('popstate', function (event) {
|
|
}, 0);
|
|
}, 0);
|
|
});
|
|
});
|
|
$(document).ready(function () {
|
|
$(document).ready(function () {
|
|
- if(window.location.href === window.top.location.href) {
|
|
|
|
- window.location.href = '/mc' + window.location.pathname;
|
|
|
|
|
|
+
|
|
|
|
+ if(window.location.pathname === window.top.location.pathname) {
|
|
|
|
+ window.top.location.href = '/mc' + window.location.pathname;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// window.top.ensureRHS();
|
|
// window.top.ensureRHS();
|
|
@@ -94,8 +100,10 @@ $(document).ready(function () {
|
|
if (body.is('.stag_rhs_collapsed')) {
|
|
if (body.is('.stag_rhs_collapsed')) {
|
|
icon.removeClass().addClass('fa fa-arrow-left');
|
|
icon.removeClass().addClass('fa fa-arrow-left');
|
|
}
|
|
}
|
|
- initPrimaryForm();
|
|
|
|
|
|
+ initCreateNote();
|
|
|
|
+ initQuillEdit();
|
|
initFastLoad();
|
|
initFastLoad();
|
|
|
|
+ initPrimaryForm();
|
|
if(typeof initializeCalendar !== 'undefined') {
|
|
if(typeof initializeCalendar !== 'undefined') {
|
|
initializeCalendar();
|
|
initializeCalendar();
|
|
}
|
|
}
|
|
@@ -103,12 +111,13 @@ $(document).ready(function () {
|
|
initIntakeEvents();
|
|
initIntakeEvents();
|
|
}
|
|
}
|
|
|
|
|
|
- // replace history on fresh load
|
|
|
|
|
|
+ // populate history on fresh load
|
|
var target = window.top.location.pathname;
|
|
var target = window.top.location.pathname;
|
|
if (target.indexOf('/mc') === 0) {
|
|
if (target.indexOf('/mc') === 0) {
|
|
target = target.split('/mc')[1];
|
|
target = target.split('/mc')[1];
|
|
}
|
|
}
|
|
- window.top.history.pushState(target, null, '/mc' + target);
|
|
|
|
|
|
+ fastLoad(target, true, false, true);
|
|
|
|
+
|
|
});
|
|
});
|
|
function enableTimeSpecificFields(_checked, _valueClass, _rangeClass) {
|
|
function enableTimeSpecificFields(_checked, _valueClass, _rangeClass) {
|
|
if(_valueClass) $('.' + _valueClass).prop('disabled', _checked);
|
|
if(_valueClass) $('.' + _valueClass).prop('disabled', _checked);
|
|
@@ -173,7 +182,6 @@ function initFastLoad(_parent = false) {
|
|
$(_a)
|
|
$(_a)
|
|
.off('click.fast-load')
|
|
.off('click.fast-load')
|
|
.on('click.fast-load', function () {
|
|
.on('click.fast-load', function () {
|
|
- showMask();
|
|
|
|
fastLoad(this.href, true, true);
|
|
fastLoad(this.href, true, true);
|
|
$('.dropdown-menu[aria-labelledby="practice-management"]')
|
|
$('.dropdown-menu[aria-labelledby="practice-management"]')
|
|
.removeClass('show')
|
|
.removeClass('show')
|
|
@@ -203,8 +211,10 @@ function onFastLoaded(_data, _href, _history) {
|
|
content += '<script src="/js/yemi.js?_=4"></script>';
|
|
content += '<script src="/js/yemi.js?_=4"></script>';
|
|
targetParent.html(content);
|
|
targetParent.html(content);
|
|
window.setTimeout(function() {
|
|
window.setTimeout(function() {
|
|
- initPrimaryForm();
|
|
|
|
|
|
+ initCreateNote();
|
|
|
|
+ initQuillEdit();
|
|
initFastLoad(targetParent);
|
|
initFastLoad(targetParent);
|
|
|
|
+ initPrimaryForm();
|
|
}, 50);
|
|
}, 50);
|
|
if(typeof initializeCalendar !== 'undefined') {
|
|
if(typeof initializeCalendar !== 'undefined') {
|
|
initializeCalendar();
|
|
initializeCalendar();
|
|
@@ -212,38 +222,66 @@ function onFastLoaded(_data, _href, _history) {
|
|
if(typeof initIntakeEvents !== 'undefined') {
|
|
if(typeof initIntakeEvents !== 'undefined') {
|
|
initIntakeEvents();
|
|
initIntakeEvents();
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ // fallback
|
|
|
|
+ console.warn('MC: Target page failed: ' + _href);
|
|
|
|
+ targetParent.html('<p class="text-danger p-3 small">Target page not found or returned error: <b>' + _href + '</b></p>');
|
|
|
|
+ }
|
|
|
|
+ hideMask();
|
|
|
|
+}
|
|
|
|
+function fastLoad(_href, _history = true, _useCache = true, _replaceState = false) {
|
|
|
|
|
|
- // push state
|
|
|
|
- if (_history) {
|
|
|
|
- var target = _href;
|
|
|
|
- if (target.indexOf('//') !== -1) {
|
|
|
|
- target = target.split('//')[1];
|
|
|
|
- if (target.indexOf('/') !== -1) {
|
|
|
|
- target = target.substr(target.indexOf('/') + 1);
|
|
|
|
- }
|
|
|
|
|
|
+ showMask();
|
|
|
|
+
|
|
|
|
+ if(_href === '') _href = '/';
|
|
|
|
+
|
|
|
|
+ // push state
|
|
|
|
+ if (_history) {
|
|
|
|
+ var target = _href;
|
|
|
|
+ if (target.indexOf('//') !== -1) {
|
|
|
|
+ target = target.split('//')[1];
|
|
|
|
+ if (target.indexOf('/') !== -1) {
|
|
|
|
+ target = target.substr(target.indexOf('/') + 1);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ if(target[0] === '/') target = target.substr(1);
|
|
|
|
+ if(_replaceState) {
|
|
|
|
+ window.top.history.replaceState(target, null, '/mc/' + target);
|
|
|
|
+ console.log('ALIX replaceState: [' + target + ']');
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
window.top.history.pushState(target, null, '/mc/' + target);
|
|
window.top.history.pushState(target, null, '/mc/' + target);
|
|
|
|
+ console.log('ALIX pushState: [' + target + ']');
|
|
}
|
|
}
|
|
-
|
|
|
|
- } else {
|
|
|
|
- console.warn('Target page not found: ' + _href);
|
|
|
|
- window.location.href = _href; // fallback
|
|
|
|
}
|
|
}
|
|
- // hideMask();
|
|
|
|
-}
|
|
|
|
-function fastLoad(_href, _history = true, _useCache = true) {
|
|
|
|
|
|
+
|
|
if (_useCache && !!fastCache[_href]) {
|
|
if (_useCache && !!fastCache[_href]) {
|
|
onFastLoaded(fastCache[_href], _href, _history);
|
|
onFastLoaded(fastCache[_href], _href, _history);
|
|
} else {
|
|
} else {
|
|
$.get(_href, function(_data) {
|
|
$.get(_href, function(_data) {
|
|
onFastLoaded(_data, _href, _history);
|
|
onFastLoaded(_data, _href, _history);
|
|
|
|
+ }).fail(function() {
|
|
|
|
+ onFastLoaded('error', _href, _history);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-function initPrimaryForm() {
|
|
|
|
- if($('.primary-form:visible').length) {
|
|
|
|
- $('.primary-form:visible').first().find('input, textarea, select').first().focus().select();
|
|
|
|
|
|
+function initPrimaryForm(_form = false) {
|
|
|
|
+ var primaryForm = _form ? _form : $('.primary-form:visible');
|
|
|
|
+ if (primaryForm.length) {
|
|
|
|
+ primaryForm = primaryForm.first();
|
|
|
|
+ var rte = primaryForm.find('[contenteditable="true"]').first();
|
|
|
|
+ if(rte.length) {
|
|
|
|
+ rte.focus().select();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if(primaryForm.find('[autofocus]:visible').length) {
|
|
|
|
+ primaryForm.find('[autofocus]:visible').first().focus().select();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ primaryForm.find('input:not([type="hidden"]):visible, textarea:visible, select:visible').first().focus().select();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -254,3 +292,65 @@ function openInRHS(_url) {
|
|
window.top.openInRHS(_url);
|
|
window.top.openInRHS(_url);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+function initCreateNote() {
|
|
|
|
+ $(document)
|
|
|
|
+ .off('click.create-note', '.create-auto-note-trigger')
|
|
|
|
+ .on('click.create-note', '.create-auto-note-trigger', function() {
|
|
|
|
+ showMask();
|
|
|
|
+ var clientUid = $(this).attr('data-patient-uid');
|
|
|
|
+ $.post('/api/note/createUsingFreeTextHtml', {
|
|
|
|
+ clientUid: clientUid,
|
|
|
|
+ hcpProUid: $(this).attr('data-hcp-uid'),
|
|
|
|
+ effectiveDateEST: $(this).attr('data-effective-date'),
|
|
|
|
+ }, function(_data) {
|
|
|
|
+ hideMask();
|
|
|
|
+ if (!_data.success) {
|
|
|
|
+ toastr.error(_data.message);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ fastLoad('/patients/view/' + clientUid + '/notes/view/' + _data.data, true, false);
|
|
|
|
+ }
|
|
|
|
+ }, 'json');
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function initQuillEdit(_selector = '.note-content[auto-edit]') {
|
|
|
|
+
|
|
|
|
+ $(document)
|
|
|
|
+ .off('click.enable-edit', '.note-content:not([auto-edit]):not(.readonly)')
|
|
|
|
+ .on('click.enable-edit', '.note-content:not([auto-edit]):not(.readonly)', function() {
|
|
|
|
+ $(this).attr('auto-edit', 1);
|
|
|
|
+ initQuillEdit();
|
|
|
|
+ initPrimaryForm();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if(!$(_selector).length) return;
|
|
|
|
+ var noteUid = $(_selector).attr('data-note-uid');
|
|
|
|
+ var qe = new Quill(_selector, {
|
|
|
|
+ theme: 'snow'
|
|
|
|
+ });
|
|
|
|
+ var toolbar = $(qe.container).prev('.ql-toolbar');
|
|
|
|
+ var saveButton = $('<button class="btn btn-sm btn-primary w-auto px-3 py-0 text-sm text-white save-note-content">Save</button>');
|
|
|
|
+ toolbar.append(saveButton);
|
|
|
|
+ saveButton.on('click', function() {
|
|
|
|
+ $.post('/api/note/putFreeTextHtml', {
|
|
|
|
+ uid: noteUid,
|
|
|
|
+ freeTextHtml: qe.root.innerHTML,
|
|
|
|
+ }, function(_data) {
|
|
|
|
+ if (!_data.success) {
|
|
|
|
+ toastr.error(_data.message);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ // toastr.success('Note saved');
|
|
|
|
+ // saveButton.prop('disabled', true);
|
|
|
|
+ fastLoad(window.top.location.pathname.substr(3), false, false);
|
|
|
|
+ }
|
|
|
|
+ }, 'json');
|
|
|
|
+ });
|
|
|
|
+ // qe.on('text-change', function() {
|
|
|
|
+ // saveButton.prop('disabled', false);
|
|
|
|
+ // });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|