Skip to content

Commit

Permalink
Adding module manager
Browse files Browse the repository at this point in the history
  • Loading branch information
juggernautsei committed Jun 19, 2024
1 parent e873bb6 commit fbb7b05
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php

/**
* Class to be called from Laminas Module Manager for reporting management actions.
* Example is if the module is enabled, disabled or unregistered ect.
*
* The class is in the Laminas "Installer\Controller" namespace.
* Currently, register isn't supported of which support should be a part of install.
* If an error needs to be reported to user, return description of error.
* However, whatever action trapped here has already occurred in Manager.
* Catch any exceptions because chances are they will be overlooked in Laminas module.
* Report them in the return value.
*
* @package OpenEMR Modules
* @link https://www.open-emr.org
* @author Jerry Padgett <[email protected]>
* @copyright Copyright (c) 2024 Jerry Padgett <[email protected]>
* @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 'Juggernaut\\OpenEMR\\Modules\\PriorAuthModule\\';
}

/**
* 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
{
// 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
{
return $currentActionStatus;
}

/**
* @param $modId
* @param $currentActionStatus
* @return mixed
*/
private function unregister($modId, $currentActionStatus)
{
$logMessage = 'Prior Auth table have been removed if empty else manually remove'; // Initialize an empty string to store log messages
$records = sqlQuery("SELECT * FROM `module_prior_authorizations` ORDER BY id DESC LIMIT 1"); // Query the database for all records in the module_prior_authorizations table
if (empty($records)) { // Check if the records array is empty
$sql = "DROP TABLE `module_prior_authorizations`"; // Drop the module_prior_authorizations table if it is empty
$status = sqlStatement($sql); // Execute the SQL statement
error_log($logMessage . ' ' . text($status)); // Log the status of the SQL statement
}
return $currentActionStatus;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ function refreshme() {
<input type="hidden" id="id" name="id" value="">
<div class="form-row">
<div class="col">
<input class="form-control" id="authorization" name="authorization" value="" placeholder="
<?php echo xla('Authorization Number') ?>">
<input class="form-control" id="authorization" name="authorization" value="" placeholder="<?php echo xla('Authorization Number') ?>">
</div>
<div class="col">
<input class="form-control" id="units" name="units" value="" placeholder="<?php echo xla('Units') ?>">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/*
* package OpenEMR
* link https://open-emr.org
* author Sherwin Gaddis <[email protected]>
* Copyright (c) 2024. Sherwin Gaddis <[email protected]>
*/

$v_major = '1';
$v_minor = '0';
$v_patch = '0';
$v_tag = '';
$v_database = 0;

0 comments on commit fbb7b05

Please sign in to comment.