' + subdomainCompanyName + '
'; } else { html += 'or
'; html += ''; html += 'We\'ll email you a secure link for a one-time, password-free log in.
'; html += '' + subdomainCopyrightText + '
'; html += 'Can\'t log in?
'; html += ''; html += '
If you don\'t see your reset email...
'; html += 'Be sure to check your spam filter for an email from support@yourhealthmail.com
'; html += 'Never mind, go back to the log in screen
'; html += 'Send Me a Magic Link
'; html += ''; html += '
This is a one-time use link sent to your email that you can click to be automatically logged in!
The link will expire 5 minutes after it was created, so do not use this option if you cannot quickly access your email inbox.
Never mind, go back to the log in screen
'; html += '").replace(/\n/ig,"
") : ''; } /* getTodayDateForDatePicker() usage: var sToday = getTodayDateForDatePicker(); returns "03/18/2016" */ function getTodayDateForDatePicker(options) { if (undefined !== options && options !== null) { return new Date().toLocaleDateString('en-US', options).replace(/\u200e/g, ''); } else { return new Date().toLocaleDateString().replace(/\u200e/g, ''); } } function getTodayDateForServer() { // the server expects the date in the US format, regardless of the user's actual locale let dateobj = new Date(); let month = (dateobj.getMonth() + 1); let date = dateobj.getDate(); let year = dateobj.getFullYear(); return month.toString() + '/' + date.toString() + '/' + year.toString(); } function formatLocalDate(datestr, dateOnly = false) { var d = datestr.replace(/\-/g,"/"); var date = new Date( d + " UTC" ); return date.toLocaleString(); } function formatLocalDateFromTimestamp(timestamp) { timestamp = parseInt(timestamp); const date = new Date(timestamp * 1000); return date.toLocaleString('en-US', {month: '2-digit', day: '2-digit', year: 'numeric'}); } function formatLocalDateTime(timestamp) { let date = new Date(); if (undefined != timestamp && timestamp != null && timestamp > 0) { date = new Date(timestamp * 1000); } return date.toLocaleString('en-US', {month: '2-digit', day: '2-digit', year: 'numeric', hour: 'numeric', minute: 'numeric'}); } function formatLocalTime(timestamp) { let date = new Date(); if (undefined !== timestamp && timestamp != null && timestamp > 0) { date = new Date(timestamp * 1000); } return date.toLocaleString('en-US', { hour12: true, hour: 'numeric', minute: '2-digit' }).toLowerCase(); } function addModal( sModalID, sModalTitle, hModalBody, hModalFooter ) { var sNewModalBodyID = 'modal-body_'+sModalID; var modalhtml = ''; modalhtml += '
' + sModalTitle + '
'; modalhtml += ''; html += '
' + oRecipeObject['meal_display_name']; if (oRecipeObject.hasOwnProperty('replacement_meal') && oRecipeObject.replacement_meal === true) { html += ''; } html += '
'; html += renderRecipeFoodNutrition(iRecipeID, oRecipeObject); html += '' + food['food_name'] + '
' + servingLabel + '
' }); var mealfoodsmodal = 'meal_foods_modal_' + generateUUID(); var mealnutritionmodal = 'meal_nutrition_modal_' + generateUUID(); mealFoods += '
Recipe Ingredients
'; mealFoods += ''; mealFoods += 'Nutrition Info
(per serving)
';
html += 'Recipe Serves ' + numberOfServings + '
';
html += '';
html += 'Calories: | ' + Math.round(calories) + ' |
---|---|
Fat: | ' + getNutrientDisplay(fat) + ' |
Sat fat: | ' + getNutrientDisplay(satfat) + ' |
Cholesterol: | ' + Math.round(cholesterol) + 'mg |
Sodium: | ' + Math.round(sodium) + 'mg |
Carbs: | ' + getNutrientDisplay(carb) + ' |
Fiber: | ' + getNutrientDisplay(fiber) + ' |
Sugar: | ' + getNutrientDisplay(sugar) + ' |
Protein: | ' + getNutrientDisplay(protein) + ' |
Calcium: | ' + Math.round(calcium) + 'mg |
' + oExerciseData['exercise_title'] + '
'; } else if( replacedom === 'plan-edit-day') { html += renderExerciseDescription( oExerciseData, replacedom ); } else { html += '' + oExerciseData['exercise_title'] + '
'; } } if( replacedom !== 'previewmain' ) { html += renderExerciseDescription( oExerciseData, replacedom ); } if(bEditing == true) // exercise in plan day editor { html += ''; } // // check if this exercise is NOT being rendered on a Plan Preview if (undefined !== replacedom && replacedom !== 'program' && replacedom.indexOf("preview") == -1 ) { html += renderExerciseImagesVideo( oExerciseData ); } // return html; } function renderExerciseImagesVideo(oExerciseData) { var html = ''; // exercise images and video html += '
' + oExerciseData['exercise_title'] + '
'; html += '' + obj.name + '
'; html += '' + recommended_product.product.name + '
'; html += '' + recommended_product.product.brand.name + '
'; if (discount !== null && discount > 0) { let patientPrice = (recommended_product.msrp * ((100 - discount) / 100)); html += 'Dosage Instructions:
'; html += '' + lab.name + '
'; lab.tests.forEach(test => { html += '' + test.name + '
'; }); html += '').replace(/\t/g,' '); } function iVeryTop(elems) { var maxIndex = 0; elems = (typeof(elems) !== 'undefined') ? elems : $("*"); $(elems).each(function() { maxIndex = (parseInt(maxIndex) < parseInt($(this).css('z-index'))) ? parseInt($(this).css('z-index')) : maxIndex; iTopZIndex = maxIndex + 1; }); return iTopZIndex; } jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", "5px"); this.css("z-index", 5000); this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px"); return this; } function getUnits(system, metric) { var units = ''; switch (metric.toUpperCase()) { case 'WEIGHT': case 'FAT MASS': case 'MUSCLE MASS': units = (system == 'imperial') ? 'lbs' : 'kgs'; break; case 'HIPS': case 'WAIST': case 'CHEST': case 'ARMS': case 'THIGHS': case 'CALVES': units = (system == 'imperial') ? 'ins' : 'cm'; break; case 'BODY FAT %': units = '%'; break; case 'RESTING HEART RATE': units = 'BPM'; break; case 'BLOOD PRESSURE': units = 'mmHg'; break; case 'BLOOD SUGAR (MG/DL)': units = 'mg/dL'; break; default: units = ''; } return units; } function debounce(func, wait, immediate) { var timeout; return function() { var context = this; args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; }; function renderNotificationTable(aNotificationSettings, iUserID) { var html = ''; var email = {name: 'method', value: 'email'}; var sms = {name: 'method', value: 'sms'}; var userID = {name: 'user_id', value: iUserID}; html += ''; // table headers html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; // table body html += ''; for (let i in aNotificationSettings) { let type = i; let settings = aNotificationSettings[type]; let emailCheckboxID = type+'-email-cb'; let emailChecked = (settings['email_status'] !== 'W') ? 'checked' : ''; let smsCheckboxID = type+'-sms-cb'; let smsChecked = (settings['sms_status']) ? 'checked' : ''; let pushCheckboxID = type+'-push-cb'; let pushChecked = (settings['push_status']) ? 'checked' : ''; html += ''; // LABEL html += ''; // EMAIL SETTINGS html += ''; // SMS SETTINGS html += ''; // PUSH NOTIFICATION SETTINGS html += ''; // text-center html += ''; } html += ''; html += '
Notification Type | SMS | Push Notifications | |
---|---|---|---|
'+settings['label']+' | '; if (settings.allow_email) { const jEmailSettingParams = [ { name: 'notification_type', value: type }, { name: 'user_id', value: userID }, { name: 'checked', is_checked: emailCheckboxID }, { name: 'method', value: 'email' } ]; html += ''; } html += ' | '; if (settings.allow_sms) { const jSMSSettingParams = [ { name: 'notification_type', value: type }, { name: 'user_id', value: userID }, { name: 'checked', is_checked: smsCheckboxID }, { name: 'method', value: 'sms' } ]; html += ''; } html += ' | '; if (settings.allow_push) { const jPushSettingParams = [ { name: 'notification_type', value: type }, { name: 'user_id', value: userID }, { name: 'checked', is_checked: pushCheckboxID }, { name: 'method', value: 'push' } ]; html += ''; } html += ' |
';
html += sPageTitle;
if (undefined !== sEndpoint) {
html += ']*>/gi;
let output = input.replace(regex, "\n");
return output;
}
function activateTab(tab) {
const bsTab = new bootstrap.Tab(tab);
bsTab.show();
}
function goToNavItem(endpoint) {
const navItem = $("#mainnavul a[data-endpoint='/" + endpoint + "/']");
const bsNavItem = new bootstrap.Tab(navItem);
bsNavItem.show();
objectClick(navItem);
}
function closeModal() {
return '';
}
function formatPhoneNumber(phoneNumberString) {
let cleaned = ('' + phoneNumberString).replace(/\D/g, '');
let match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/);
if (match) {
let intlCode = (match[1] ? '+1 ' : '');
return [intlCode, '(', match[2], ') ', match[3], '-', match[4]].join('');
}
return '';
}
function strCompare(strA, strB) {
// do both strings begin with numbers
let numPatt = /^\d+/;
if (numPatt.test(strA) && numPatt.test(strB)) {
// compare the numbers
let numA = numPatt.exec(strA);
numA = parseInt(numA[0]);
let numB = numPatt.exec(strB);
numB = parseInt(numB[0]);
if (numA < numB) {
return -1;
} else if (numA > numB) {
return 1;
} else {
return 0;
}
} else {
// just compare the strings
if (strA.toUpperCase() < strB.toUpperCase()) {
return -1;
} else if (strA.toUpperCase() > strB.toUpperCase()) {
return 1;
} else {
return 0;
}
}
}
jQuery.fn.initWistiaUploader = function() {
let uploader_id = $(this).attr('id');
$.ajax({
url: AJAXURI + '/get_wistia_project_id/',
method: 'POST',
dataType: 'JSON',
headers: {
'X-CSRF-Token': Math.random().toString(20).substr(2, 20)
},
success: function(json) {
if (json.status == 1) {
window._wapiq = window._wapiq || [];
_wapiq.push(function (W) {
window.wistiaUploader = new W.Uploader({
accessToken: json.data.wistia_access_token,
projectId: json.data.wistia_project_id,
dropIn: uploader_id
});
wistiaUploader.on('uploadstart', function(file) {
let html = '';
html += 'Your video is uploading! Don\'t navigate away from this page until it finishes.';
$(html).insertAfter('#' + uploader_id);
});
wistiaUploader.on('uploadsuccess', function(file, media) {
// add the video to the user's library via ajax
let params = {};
params['params'] = {};
params['params']['video_source_ref_id'] = media.id;
params['params']['video_thumbnail_href'] = media.thumbnail.url;
params['params']['video_description'] = media.name;
ajaxCall('/add_uploaded_video_to_library/', params, function(json) {
let html = '';
if (json.status == 1) {
$('#add-video-modal').find('button.close').addClass('abtn').attr('data-endpoint', '/video_library/').attr('data-replace-dom', 'videos');
let jChangeNameParams = [];
jChangeNameParams.push({ name: 'video_name', value_of: 'change-uploaded-video-name' });
jChangeNameParams.push({ name: 'video_ref_id', value: media.id });
html += '';
html += 'Your video has been successfully uploaded and added to your library!
';
html += '';
html += '';
html += ``;
html += ``;
html += ''; // input-group
html += ''; // alert
} else {
html += '';
html += 'Oops! There was a problem adding this video to your library';
html += ''; // alert
}
$('#' + uploader_id + '_message').html(html);
});
});
});
resolve();
} else {
console.log(json.message);
reject();
}
},
error: function(xhr) {
console.log(xhr);
reject();
}
})
window._wapiq = window._wapiq || [];
_wapiq.push(function (W) {
window.wistiaUploader = new W.Uploader({
accessToken: WISTIA_ACCESS_TOKEN,
dropIn: uploader_id,
beforeUpload: function() {
return {
then: function(resolve, reject) {
setTimeout(function() {
// create a project to upload to
$.ajax({
url: AJAXURI + '/get_wistia_project_id/',
method: 'POST',
dataType: 'JSON',
headers: {
'X-CSRF-Token': Math.random().toString(20).substr(2, 20)
},
success: function(json) {
if (json.status == 1) {
wistiaUploader.setProjectId(json.data.wistia_project_id);
wistiaUploader.set
resolve();
} else {
console.log(json.message);
reject();
}
},
error: function(xhr) {
console.log(xhr);
reject();
}
})
}, 1000);
}
}
}
});
wistiaUploader.on('uploadstart', function(file) {
let html = '';
html += 'Your video is uploading! Don\'t navigate away from this page until it finishes.';
$(html).insertAfter('#' + uploader_id);
});
wistiaUploader.on('uploadsuccess', function(file, media) {
// add the video to the user's library via ajax
let params = {};
params['params'] = {};
params['params']['video_source_ref_id'] = media.id;
params['params']['video_thumbnail_href'] = media.thumbnail.url;
params['params']['video_description'] = media.name;
ajaxCall('/add_uploaded_video_to_library/', params, function(json) {
let html = '';
if (json.status == 1) {
$('#add-video-modal').find('button.close').addClass('abtn').attr('data-endpoint', '/video_library/').attr('data-replace-dom', 'videos');
let jChangeNameParams = [];
jChangeNameParams.push({ name: 'video_name', value_of: 'change-uploaded-video-name' });
jChangeNameParams.push({ name: 'video_ref_id', value: media.id });
html += '';
html += 'Your video has been successfully uploaded and added to your library!
';
html += '';
html += '';
html += ``;
html += ``;
html += ''; // input-group
html += ''; // alert
} else {
html += '';
html += 'Oops! There was a problem adding this video to your library';
html += ''; // alert
}
$('#' + uploader_id + '_message').html(html);
});
});
});
};
function parseDate(str) {
var mdy = str.split('/');
return new Date(mdy[2], mdy[0]-1, mdy[1]);
}
function datediff(first, second) {
// Take the difference between the dates and divide by milliseconds per day.
// Round to nearest whole number to deal with DST.
return Math.round((parseDate(second)-parseDate(first))/(1000*60*60*24));
}
function getSelectedRadioVal(btnObjects) {
let ret = '';
btnObjects.each(function() {
let btn = $(this);
if (btn.prop('checked') === true) {
ret = btn.val();
}
});
return ret;
}
function handleTableSearch(table_id) {
let oTable = $("#" + table_id).DataTable();
let timerName = generateUUID() + '_timer';
window[timerName] = null;
$('#' + table_id + '_filter input').off().on('keyup', function() {
if (window[timerName] != null) {
clearTimeout(window[timerName]);
}
let searchVal = $(this).val();
// we don't want to hit the database with the user's answer every single time they press a key
// so wait 1 second and then trigger event that will save the answer
window[timerName] = setTimeout(function() {
oTable.search(searchVal).draw();
}, 750);
});
}
function makeTaskNameStr(task, viewing) {
let name = '';
viewing = (undefined !== viewing) ? viewing : false;
if (task.action != undefined) {
switch (task.action) {
case "/save_new_body_log/":
if (task.hasOwnProperty('action_params') && task.action_params.hasOwnProperty('metric_name')) {
name = 'Track ' + task.action_params.metric_name.toLowerCase();
} else {
name = 'Track a body metric';
console.log('Task ' + task.task_id + ' missing metric name');
}
break;
case "/save_body_goal/":
if (task.hasOwnProperty('action_params') && task.action_params.hasOwnProperty('metric_name')) {
name = 'Set a ' + task.action_params.metric_name.toLowerCase() + ' goal';
} else {
name = 'Set a body metric goal';
console.log('Task ' + task.task_id + ' missing metric name');
}
break;
case "/save_activity/":
case "/track_custom_activity/":
if (task.hasOwnProperty('action_params') && task.action_params.hasOwnProperty('activity_title')) {
name = 'Track ' + task.action_params.activity_title.toLowerCase();
} else {
name = 'Track an activity';
console.log('Task ' + task.task_id + ' missing activity title');
}
break;
case "custom":
if (task.hasOwnProperty('action_params') && task.action_params.hasOwnProperty('prompt')) {
name = task.action_params.prompt;
if (!viewing) {
if (task.action_params.completion === 'checkbox') {
name += '';
} else if (task.action_params.completion === 'feedback') {
name += '';
}
}
} else {
name = 'Custom Task';
console.log('Task ' + task.task_id + ' missing prompt');
}
break;
case "/track_sleep/":
name = 'Track sleep';
break;
case "/track_steps/":
name = 'Track steps';
break;
case "/track_water/":
name = 'Track water intake';
break;
default:
let selAction = ACTION_CHOICES.filter(function (choice) {
return choice.endpoint === task.action;
});
if (selAction.length === 1) {
name = selAction[0].action;
}
break;
}
} else {
switch (task.plan_object_type) {
case 'NOTE':
name = 'Read program content';
break;
case 'EXERCISE':
name = 'Did an exercise';
break;
case 'YOUTUBE':
case 'VIMEO':
case 'WISTIA':
name = 'Watched a video';
break;
default:
break;
}
}
return name;
}
function toBool(str) {
return str.toLowerCase() === 'true';
}
function loadScript(sFileName, fnCallback) {
if (undefined === fnCallback) {
fnCallback = function() { void(0); };
}
if (!window.scripts_loaded.includes(sFileName)) {
$.ajax({
url: scriptbase + sFileName,
dataType: 'script',
success: fnCallback,
async: true,
complete: function (xhr, status) {
window.scripts_loaded.push(sFileName);
},
error: function(xhr, status, error) {
console.log(error);
}
});
} else {
fnCallback.call(null);
}
initOutput();
}
function makePOSTParams(params) {
return encodeURIComponent(JSON.stringify(params));
}
function formatMacroTotal(val) {
return (val < 1 && val > 0) ? '< 1' : Math.round(val);
}
function renderBAAForSignature(json) {
let html = '';
$.getScript('https://cdncf.esignatures.io/assets/iframeResizer.4.2.10.min.js');
html += '';
html += '';
html += '';
html += '';
html += 'Let\'s handle HIPAA before you log in . . .
';
html += ''; // modal-header
html += '';
html += 'Please sign our updated Business Associate Agreement (BAA) and then click Go to My Dashboard to proceed. A BAA protects the privacy of your patients and is required in accordance with HIPAA.
';
html += '';
html += ''; // modal-body
html += '';
html += '';
html += ''
html += ''; // modal-footer
html += ''; // modal-content
html += ''; // modal-dialog
html += ''; // modal
$('body').append(html);
$('#sign-baa-modal').modal({
backdrop: 'static',
keyboard: false
}).modal('show');
let modalBodyElement = document.querySelector('#sign-baa-modal .modal-body');
modalBodyElement.onscroll = function(event) {
const bufferStart = (modalBodyElement.scrollHeight - modalBodyElement.offsetHeight) * .95;
if ((modalBodyElement.scrollTop) >= bufferStart) {
// we're at the bottom, enable the button
$('#done-signing-baa-button').prop('disabled', false).removeClass('disabled');
}
};
}
function checkContractSignedCallback(json, replacedom) {
if (json.status === 1) {
$('#' + replacedom).modal('hide').removeModal(true);
if (json.data.contract_status === 'WITHDRAWN') {
let html = '';
html += '';
html += '';
html += '';
html += '';
html += 'Oops!
';
html += ''; // modal-header
html += '';
html += 'Oops! You withdrew from signing a Business Associate Agreement (BAA). In order to access your account immediately, please click on the button below to temporarily access your account without a BAA. We\'ll follow up with you shortly to make sure you have a BAA if you need one or to confirm your opt out status.
';
html += '';
html += ''; // modal-body
html += ''; // modal-content
html += ''; // modal-dialog
html += ''; // modal
$('body').append(html);
$('#user-withdrawn-opt-out').modal({
backdrop: 'static',
keyboard: false
}).modal('show');
}
}
}
function renderBBABlockerModalForNonDomainAdmin(json) {
let html = '';
let domainAdminUser = json.data.domain_admin_info;
html += '';
html += '';
html += '';
html += '';
html += 'Hold on a minute...
';
html += ''; // modal-header
html += '';
html += 'Hey! We updated our BAA recently and we need ' + domainAdminUser.user_display_name + ' to log in and sign it before you can proceed. We already sent them an email reminder at ' + domainAdminUser.user_email + '. If you have any questions you can call us at (561) 247-3839.
';
html += ''; // modal-body
html += '';
html += '';
html += '';
html += ''; // modal-footer
html += ''; // modal-content
html += ''; // modal-dialog
html += ''; // modal
$('body').append(html);
$('#needs-baa-signed-modal').modal({
backdrop: 'static',
keyboard: false,
}).modal('show');
}
function optOutOfBAACallback(json) {
if (json.status === 1) {
$('#sign-baa-modal').modal('hide').removeModal(true);
}
}
function timePassed(timestamp, start) {
start = (undefined !== start) ? start : Math.round(new Date().getTime()/1000);
let difference = start - timestamp;
let seconds = difference;
let minutes = Math.floor(difference / 60);
seconds = (seconds - (minutes * 60));
let hours = Math.floor(minutes / 60);
minutes = (minutes - (hours * 60));
if (seconds < 10) {
seconds = '0' + seconds;
}
if (minutes < 10) {
minutes = '0' + minutes;
}
if (hours < 10) {
hours = '0' + hours;
}
return hours + ':' + minutes + ':' + seconds;
}
function renderStaffPermissionsOptions(userID, currentPermissions, parentDiv, domainMessagingEnabled) {
let tmpHtml = '';
tmpHtml += '';
// PATIENT MANAGEMENT
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += ''; // form-group
tmpHtml += '';
if (domainMessagingEnabled) {
// MESSAGING
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += ''; // form-group
tmpHtml += '';
}
// PATIENT ENROLLMENT
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += ''; // form-group
tmpHtml += '';
// CONTENT MANAGEMENT
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += ''; // form-group
tmpHtml += '';
// FULL ADMIN
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += '';
tmpHtml += ''; // form-group
tmpHtml += '';
tmpHtml += ''; // row
$('#' + parentDiv).html(tmpHtml);
$('.ui.checkbox').checkbox();
$('.team-member-permissions-checkbox').on('change', function() {
const userID = $(this).attr('data-team-member-user-id');
let selectedPermissions = [];
const checkedPermissionsBoxes = $('.team-member-permissions-checkbox[data-team-member-user-id="' + userID + '"]:checked');
if (checkedPermissionsBoxes.length > 0) {
checkedPermissionsBoxes.each(function () {
selectedPermissions.push($(this).attr('data-permission'));
});
} else {
selectedPermissions.push('NONE');
}
let params = {};
let endpoint = '/provider_update_staff_permissions/';
params.endpoint = endpoint;
params.params = {};
params.params.team_member_user_id = userID;
params.params.permissions = selectedPermissions;
ajaxCall(endpoint, params);
});
}
function officeDiscussionTimeAgo(utc_timestamp) {
const nowTimestamp = (new Date().getTime()) / 1000;
const diff = nowTimestamp - utc_timestamp;
if (diff >= 86400 /* # of seconds in a day */) {
const timestampDate = new Date(utc_timestamp * 1000);
return timestampDate.toLocaleString('en-US', {month: '2-digit', day: '2-digit', year: 'numeric', hour: 'numeric', minute: 'numeric'});
} else {
return timeAgo(utc_timestamp);
}
}
function removeTinyMCEEditor(editorID) {
if ($('#' + editorID).length > 0) {
const editor = tinyMCE.get(editorID);
if (editor != null && editor.initialized) {
editor.remove();
}
}
}
function renderInvoiceStatusBadge(status, collectionMethod) {
let statusBadgeClass = '';
switch (status) {
case 'open':
statusBadgeClass = 'badge-primary';
break;
case 'draft':
case 'uncollectible':
statusBadgeClass = 'badge-secondary';
break;
case 'paid':
statusBadgeClass = 'badge-success';
break;
case 'void':
statusBadgeClass = 'badge-danger';
break;
}
status = (status === 'open' && collectionMethod === 'charge_automatically') ? 'charge pending' : status;
return '' + ucwords(status) + '';
}
function renderSubscriptionStatusBadge(status) {
let html = '';
switch (status) {
case 'pending':
html = 'Pending';
break;
case 'active':
html = 'Active';
break;
case 'past due':
html = 'Past Due';
break;
case 'cancelled':
html = 'Cancelled';
break;
default:
break;
}
return html;
}
function getSubscriptionStatus(subscription) {
let status = '';
if (subscription.stripe_subscription_id == null) {
status = 'pending';
} else if (subscription.hasOwnProperty('stripe_subscription_data') &&
subscription.stripe_subscription_data != null &&
subscription.stripe_subscription_data.status === 'active') {
status = 'active';
} else if (subscription.hasOwnProperty('stripe_subscription_data') &&
subscription.stripe_subscription_data != null &&
subscription.stripe_subscription_data.status === 'past_due') {
status = 'past due';
} else {
status = 'cancelled';
}
return status;
}
function renderSubscriptionTableRow(subscription, patientUserID, includePatientCol, tableID, userStatus) {
let html = '';
let jSubParams = [];
jSubParams.push({name: 'subscription_id', value: subscription.id});
jSubParams.push({name: 'patient_id', value: patientUserID});
let subscriptionStr = '';
let status = getSubscriptionStatus(subscription);
let statusBadge = renderSubscriptionStatusBadge(status);
if (subscription.type === 'PLATFORM') {
subscriptionStr = subdomainCompanyName + ' Platform Access';
} else {
subscriptionStr = subscription.plan_title;
}
html += '';
html += '';
html += '';
html += '';
html += '';
if (status === 'pending') {
if (userStatus === USER_STATUS_ACTIVATED) {
// GET CHECKOUT LINK
html += ` Go to Checkout Page`;
}
// SEND ACTIVATION EMAIL
html += ` Send Activation Email`;
// DELETE PENDING SUBSCRIPTION
html += ` Delete Subscription`;
} else if (status === 'active') {
// CHANGE SUBSCRIPTION PRICE
html += ` Change Subscription Price`;
// CANCEL SUBSCRIPTION
html += ` Cancel Subscription`;
} else if (status === 'cancelled') {
// RESTART SUBSCRIPTION
html += ` Restart Subscription`;
} else if (status === 'past due') {
// CANCEL SUBSCRIPTION
html += ` Cancel Subscription`;
}
html += ''; // dropdown-menu
html += ''; // dropdown
html += '';
if (includePatientCol) {
html += '' + subscription.user_display_name + '';
}
html += '' + subscriptionStr + ''
html += '$' + formatDecimal(subscription.subscription_price, 2) + '';
html += '' + statusBadge + '';
html += '' + formatLocalDateFromTimestamp(subscription.created_timestamp) + '';
html += '' + (status === 'cancelled' ? (subscription.stripe_subscription_data != null) ? subscription.stripe_subscription_data.canceled_at : '-' : '
'; html += ''; html += '
'; html += ''; html += '
Let\'s handle HIPAA before you log in . . .
'; html += 'Please sign our updated Business Associate Agreement (BAA) and then click Go to My Dashboard to proceed. A BAA protects the privacy of your patients and is required in accordance with HIPAA.
'; html += ''; html += 'Oops!
'; html += 'Oops! You withdrew from signing a Business Associate Agreement (BAA). In order to access your account immediately, please click on the button below to temporarily access your account without a BAA. We\'ll follow up with you shortly to make sure you have a BAA if you need one or to confirm your opt out status.
'; html += ''; html += 'Hold on a minute...
'; html += 'Hey! We updated our BAA recently and we need ' + domainAdminUser.user_display_name + ' to log in and sign it before you can proceed. We already sent them an email reminder at ' + domainAdminUser.user_email + '. If you have any questions you can call us at (561) 247-3839.
'; html += 'N/A
') + ''; html += ''; return html; } function copyURLToClipboard(urlToCopy, element) { if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(urlToCopy) .then(() => { if (element) { element.attr('data-bs-original-title', 'Copied!').tooltip('show'); setTimeout(() => { element.attr('data-bs-original-title', 'Copy to clipboard').tooltip('show'); }, 1000); } }) .catch(err => { console.error("Error copying link to clipboard: " + err); if (element) { element.attr('data-bs-original-title', 'Error copying text').tooltip('show'); } }); } else { console.info('Clipboard API not supported, using fallback method'); $(body).append(''); $('#hidden-copy-input').select(); try { let success = document.execCommand('copy'); if (element) { const msg = success ? 'Copied!' : 'Error copying text'; element.attr('data-bs-original-title', msg).tooltip('show'); } } catch (exc) { // something went wrong console.error('Error copying text to clipboard: ' + exc); } if (element) { element.attr('data-bs-original-title', 'Copy to clipboard'); } $('#hidden-copy-input').remove(); } }