diff --git a/interface/modules/custom_modules/oe-module-claimrev-connect/ModuleManagerListener.php b/interface/modules/custom_modules/oe-module-claimrev-connect/ModuleManagerListener.php new file mode 100644 index 00000000000..4b2d663f4ed --- /dev/null +++ b/interface/modules/custom_modules/oe-module-claimrev-connect/ModuleManagerListener.php @@ -0,0 +1,143 @@ + + * @copyright Copyright (c) 2024 Jerry Padgett + * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 + */ + +/* + * Do not declare a namespace + * If you want Laminas manager to set namespace set it in getModuleNamespace + * otherwise uncomment below and set path. + * + * */ + +/* + $classLoader = new \OpenEMR\Core\ModulesClassLoader($GLOBALS['fileroot']); + $classLoader->registerNamespaceIfNotExists("OpenEMR\\Modules\\ClaimRevConnector\\", __DIR__ . DIRECTORY_SEPARATOR . 'src'); +*/ + +use OpenEMR\Core\AbstractModuleActionListener; + +/* Allows maintenance of background tasks depending on Module Manager action. */ + +class ModuleManagerListener extends AbstractModuleActionListener +{ + public function __construct() + { + parent::__construct(); + } + + /** + * @param $methodName + * @param $modId + * @param string $currentActionStatus + * @return string On method success a $currentAction status should be returned or error string. + */ + public function moduleManagerAction($methodName, $modId, string $currentActionStatus = 'Success'): string + { + if (method_exists(self::class, $methodName)) { + return self::$methodName($modId, $currentActionStatus); + } else { + // no reason to report, action method is missing. + return $currentActionStatus; + } + } + + /** + * Required method to return namespace + * If namespace isn't provided return empty string + * and register namespace at top of this script.. + * + * @return string + */ + public static function getModuleNamespace(): string + { + // Module Manager will register this namespace. + return 'OpenEMR\\Modules\\ClaimRevConnector\\'; + } + + /** + * Required method to return this class object + * so it will be instantiated in Laminas Manager. + * + * @return ModuleManagerListener + */ + public static function initListenerSelf(): ModuleManagerListener + { + return new self(); + } + + /** + * @param $modId + * @param $currentActionStatus + * @return mixed + */ + private function help_requested($modId, $currentActionStatus): mixed + { + // must call a script that implements a dialog to show help. + // I can't find a way to override the Lamina's UI except using a dialog. + if (file_exists(__DIR__ . '/show_help.php')) { + include __DIR__ . '/show_help.php'; + } + return $currentActionStatus; + } + + /** + * @param $modId + * @param $currentActionStatus + * @return mixed + */ + private function enable($modId, $currentActionStatus): mixed + { + $logMessage = 'Claimrev Background tasks have been enabled'; + // Register background services + $sql = "UPDATE `background_services` SET `active` = '1' WHERE `name` = ? OR `name` = ? OR `name` = ?"; + $status = sqlQuery($sql, array('ClaimRev_Send', 'ClaimRev_Receive', 'ClaimRev_Elig_Send_Receive')); + error_log($logMessage . ' ' . text($status)); + // Return the current action status from Module Manager in case of error from its action. + return $currentActionStatus; + } + + /** + * @param $modId + * @param $currentActionStatus + * @return mixed + */ + private function disable($modId, $currentActionStatus): mixed + { + $logMessage = 'Claimrev Background tasks have been disabled'; + // Unregister background services + $sql = "UPDATE `background_services` SET `active` = '0' WHERE `name` = ? OR `name` = ? OR `name` = ?"; + $status = sqlQuery($sql, array('ClaimRev_Send', 'ClaimRev_Receive', 'ClaimRev_Elig_Send_Receive')); + error_log($logMessage . ' ' . text($status)); + return $currentActionStatus; + } + + /** + * @param $modId + * @param $currentActionStatus + * @return mixed + */ + private function unregister($modId, $currentActionStatus) + { + $logMessage = 'Claimrev Background tasks have been removed'; // Initialize an empty string to store log messages + $sql = "DELETE FROM `background_services` WHERE `name` = ? OR `name` = ? OR `name` = ?"; + $status = sqlQuery($sql, array('ClaimRev_Send', 'ClaimRev_Receive', 'ClaimRev_Elig_Send_Receive')); + error_log($logMessage . ' ' . text($status)); + return $currentActionStatus; + } +} diff --git a/interface/modules/custom_modules/oe-module-claimrev-connect/cleanup.sql b/interface/modules/custom_modules/oe-module-claimrev-connect/cleanup.sql new file mode 100644 index 00000000000..e69de29bb2d diff --git a/interface/modules/custom_modules/oe-module-claimrev-connect/moduleConfig.php b/interface/modules/custom_modules/oe-module-claimrev-connect/moduleConfig.php new file mode 100644 index 00000000000..787f23a6314 --- /dev/null +++ b/interface/modules/custom_modules/oe-module-claimrev-connect/moduleConfig.php @@ -0,0 +1,25 @@ + + * @copyright Copyright (c) 2023-24 Jerry Padgett + * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 + */ + +use OpenEMR\Core\ModulesClassLoader; + +require_once dirname(__FILE__, 4) . '/globals.php'; + +/* required for config before install */ +$classLoader = new ModulesClassLoader($GLOBALS['fileroot']); +$classLoader->registerNamespaceIfNotExists("OpenEMR\\Modules\\ClaimRevConnector\\", __DIR__ . DIRECTORY_SEPARATOR . 'src'); + +$module_config = 1; + +exit; diff --git a/interface/modules/custom_modules/oe-module-claimrev-connect/openemr.bootstrap.php b/interface/modules/custom_modules/oe-module-claimrev-connect/openemr.bootstrap.php index d7b22424969..9575f9b5540 100644 --- a/interface/modules/custom_modules/oe-module-claimrev-connect/openemr.bootstrap.php +++ b/interface/modules/custom_modules/oe-module-claimrev-connect/openemr.bootstrap.php @@ -12,10 +12,14 @@ namespace OpenEMR\Modules\ClaimRevConnector; +/** + * @global OpenEMR\Core\ModulesClassLoader $classLoader + */ + $classLoader->registerNamespaceIfNotExists('OpenEMR\\Modules\\ClaimRevConnector\\', __DIR__ . DIRECTORY_SEPARATOR . 'src'); /** * @global EventDispatcher $eventDispatcher Injected by the OpenEMR module loader; */ -$bootstrap = new Bootstrap($eventDispatcher, $GLOBALS['kernel']); +$bootstrap = new Bootstrap($eventDispatcher); $bootstrap->subscribeToEvents(); diff --git a/interface/modules/custom_modules/oe-module-claimrev-connect/version.php b/interface/modules/custom_modules/oe-module-claimrev-connect/version.php new file mode 100644 index 00000000000..a32b7caa45d --- /dev/null +++ b/interface/modules/custom_modules/oe-module-claimrev-connect/version.php @@ -0,0 +1,14 @@ + + * Copyright (c) 2024. Sherwin Gaddis + */ + +$v_major = '1'; +$v_minor = '0'; +$v_patch = '0'; +$v_tag = ''; +$v_database = 0;