(function () { var widgetHTML = "\n\n
" var practiceID = 503; var widgetDiv = document.getElementById('nextpatient-widget'); if (widgetDiv == null) widgetDiv = document.getElementById('nextpatient_widget'); if (widgetDiv) {widgetDiv.innerHTML = widgetHTML} var apptDiv = document.getElementById('nextpatient-appts'); var reasonSelect = document.getElementById('nextpatient-reason-id'); var entitySelect = document.getElementById('nextpatient-entity-id'); function refreshAppts() { if (apptDiv) { data = {} if (reasonSelect) data.reason_id = reasonSelect.value; if (entitySelect) data.entity_id = entitySelect.value; var url = 'https://nextpatient.co/p/' + practiceID + '/schedule-widget-compact-appointments.html' if (data) { var urlPars = []; for(var key in data) urlPars.push(encodeURIComponent(key) + "=" + encodeURIComponent(data[key])); url = url + '?' + urlPars.join('&'); } var request = new XMLHttpRequest(); request.open('GET', url, true); request.onload = function() { if (request.status == 200) { apptDiv.innerHTML = request.responseText; } } request.send(); } } if (reasonSelect) reasonSelect.onchange = function(){ refreshAppts(); } if (entitySelect) entitySelect.onchange = function(){ refreshAppts(); } })();