Skip to content

Commit

Permalink
- weno module changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpadgett committed Feb 26, 2024
1 parent c36bc15 commit f89380b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public static function initListenerSelf(): ModuleManagerListener
*/
private function install($modId, $currentActionStatus): mixed
{
$modService = new ModuleService();
/* setting the active ui flag here will allow the config button to show
* before enable. This is a good thing because it allows the user to
* configure the module before enabling it. However, if the module is disabled
* this flag is reset by MM.
*/
$modService::setModuleState($modId, '0', '1');
return $currentActionStatus;
}

Expand All @@ -98,12 +105,6 @@ private function install($modId, $currentActionStatus): mixed
*/
private function preenable($modId, $currentActionStatus): mixed
{
$modService = new ModuleService();
if ($modService->isWenoConfigured()) {
$modService::setModuleState($modId, '0', '0');
return $currentActionStatus;
}
$modService::setModuleState($modId, '0', '1');
return $currentActionStatus;
}

Expand All @@ -130,7 +131,8 @@ private function enable($modId, $currentActionStatus): mixed
*/
private function disable($modId, $currentActionStatus): mixed
{
ModuleService::setModuleState($modId, '0', '0');
// allow config button to show before enable.
ModuleService::setModuleState($modId, '0', '1');
return $currentActionStatus;
}

Expand Down
12 changes: 9 additions & 3 deletions interface/modules/custom_modules/oe-module-weno/moduleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
* @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';

$module_config = 1;
?>
/* required for config before install */
$classLoader = new ModulesClassLoader($GLOBALS['fileroot']);
$classLoader->registerNamespaceIfNotExists("OpenEMR\\Modules\\WenoModule\\", __DIR__ . DIRECTORY_SEPARATOR . 'src');

<iframe src="templates/weno_setup.php?module_config=1" style="border:none;height:100vh;width:100%;"></iframe>
$module_config = 1;
/* renders in a Laminas created iframe */
require_once dirname(__FILE__) . '/templates/weno_setup.php';
exit;
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ public function isWenoConfigured(): bool
$config = $this->getVendorGlobals();
$keys = array_keys($config);
foreach ($keys as $key) {
if ($key === 'weno_rx_enable_test') {
if (
$key === 'weno_rx_enable_test'
|| $key === 'weno_secondary_admin_username'
|| $key === 'weno_secondary_admin_password'
|| $key === 'weno_secondary_encryption_key'
) {
continue;
}
$value = $GLOBALS[$key] ?? null;
Expand Down Expand Up @@ -161,7 +166,7 @@ public static function statusPharmacyDownloadReset(): bool
/**
* @param $modId string|int module id or directory name
* @param $flag string|int 1 or 0 to activate or deactivate module.
* @param $flag_ui string|int custom module ui flag to activate or deactivate Manager UI states.
* @param $flag_ui string|int custom flag to activate or deactivate Manager UI button states.
* @return array|bool|null
*/
public static function setModuleState($modId, $flag, $flag_ui): array|bool|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public function getWenoProviderId($id = null): mixed
// get the weno provider id from the user table (weno_prov_id
$provider = sqlQuery("SELECT weno_prov_id FROM users WHERE id = ?", [$id]);
if (!empty(trim($provider['weno_prov_id'] ?? ''))) {
$doIt = $GLOBALS['weno_provider_uid'] != trim($provider['weno_prov_id']);
$doIt = ($GLOBALS['weno_provider_uid'] ?? '') != trim($provider['weno_prov_id']);
if ($doIt) {
$GLOBALS['weno_provider_uid'] = trim($provider['weno_prov_id']);
$sql = "UPDATE `user_settings` SET `setting_value` = ? WHERE `setting_user` = ? AND `setting_label` = 'global:weno_provider_uid'";
Expand Down

0 comments on commit f89380b

Please sign in to comment.