2 * Javascript function for checking the registration of the logged in user and registering them for telehealth if they
3 * are not currently registered.
6 * @link http://www.open-emr.org
7 * @author Stephen Nielson <snielson@discoverandchange.com>
8 * @copyright Copyright (c) 2023 Comlink Inc <https://comlinkinc.com/>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
11 export function RegistrationChecker(scriptLocation)
16 var currentCheckCount = 0;
19 this.checkRegistration = function()
21 if (currentCheckCount++ > maxCheck)
23 console.error("Failed to get a valid telehealth registration for user");
27 let location = scriptLocation + '?action=check_registration';
29 window.top.restoreSession();
30 window.fetch(location)
34 throw new Error("Registration check failed");
38 .then(registrationSettings => {
39 if (registrationSettings && Object.prototype.hasOwnProperty.call(registrationSettings, 'errorCode')) {
40 if (registrationSettings.errorCode == 402) {
41 // user is not enrolled and so we will skip trying to register the user
42 checker.settings = {};
45 checker.settings = registrationSettings;
48 console.error("Failed to execute check_registration action", error);
49 timeoutId = setTimeout(checker.checkRegistration.bind(checker), 2000);