Skip to content

Commit

Permalink
Weno follow up (openemr#7196)
Browse files Browse the repository at this point in the history
* Weno follow up
- correct interval for WenoExchange
- add after actions to enable, disable and delete background tasks.

* - review escaping and some performance refactors
- find and populate user id to prescription table.
- remove encounter dependency to render weno prescription frame.
- add docblocks
- restore README module install instruction.

* - a version v6.0.0 background task requierement left for legacy
- remove encounter requirement my call
- fix user specific password get
- remove weno from custom menu.

* - remove all references for old weno drugs feature.
- remove tasking call for old background tasks.
  • Loading branch information
sjpadgett authored Jan 29, 2024
1 parent d893b1f commit 501cfa7
Show file tree
Hide file tree
Showing 20 changed files with 283 additions and 107,240 deletions.
85,860 changes: 0 additions & 85,860 deletions contrib/weno/WenoPharmacyDirectory2020-12-13.csv

This file was deleted.

21,208 changes: 0 additions & 21,208 deletions contrib/weno/erx_weno_drugs.sql

This file was deleted.

1 change: 1 addition & 0 deletions interface/modules/custom_modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Custom Modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?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\\WenoModule\\", __DIR__ . DIRECTORY_SEPARATOR . 'src');
*/

use OpenEMR\Core\AbstractModuleActionListener;

/* Allows maintenance of background tasks depending on Module Manager action. */

class ModuleManagerAfterActionListener 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 {
return "Module cleanup method $methodName does not exist.";
}
}

/**
* Required method to return namespace
* If namespace isn't provided return empty
* and register namespace at top of this script..
*
* @return string
*/
public static function getModuleNamespace(): string
{
// Module Manager will register this namespace.
return 'OpenEMR\\Modules\\WenoModule\\';
}

/**
* Required method to return this class object,
* so it is instantiated in Laminas Manager.
*
* @return ModuleManagerAfterActionListener
*/
public static function initListenerSelf(): ModuleManagerAfterActionListener
{
return new self();
}

/**
* @param $modId
* @param $currentActionStatus
* @return mixed
*/
private function install($modId, $currentActionStatus): mixed
{
return $currentActionStatus;
}

/**
* @param $modId
* @param $currentActionStatus
* @return mixed
*/
private function enable($modId, $currentActionStatus): mixed
{
$rtn = $this->setTaskState('1');
return $currentActionStatus;
}

/**
* @param $modId
* @param $currentActionStatus
* @return mixed
*/
private function disable($modId, $currentActionStatus): mixed
{
$rtn = $this->setTaskState('0');
return $currentActionStatus;
}

/**
* @param $modId
* @param $currentActionStatus
* @return mixed
*/
private function unregister($modId, $currentActionStatus): mixed
{
$sql = "DELETE FROM `background_services` WHERE `name` = ? OR `name` = ?";
sqlQuery($sql, array('WenoExchange', 'WenoExchangePharmacies'));
return $currentActionStatus;
}

/**
* @param $modId
* @param $currentActionStatus
* @return mixed
*/
private function install_sql($modId, $currentActionStatus): mixed
{
return $currentActionStatus;
}

/**
* @param $modId
* @param $currentActionStatus
* @return mixed
*/
private function upgrade_sql($modId, $currentActionStatus): mixed
{
return $currentActionStatus;
}

/**
* Grab all Module setup or columns values.
*
* @param $modId
* @param string $col
* @return array
*/
function getModuleRegistry($modId, $col = '*'): array
{
$registry = [];
$sql = "SELECT $col FROM modules WHERE mod_id = ?";
$results = sqlQuery($sql, array($modId));
foreach ($results as $k => $v) {
$registry[$k] = trim((preg_replace('/\R/', '', $v)));
}

return $registry;
}

/**
* @param $flag
* @return mixed
*/
private function setTaskState($flag): mixed
{
$sql_next = "UPDATE `background_services` SET `active` = ? WHERE `name` = ? OR `name` = ?";
return sqlQuery($sql_next, array($flag, 'WenoExchange', 'WenoExchangePharmacies'));
}
}
1 change: 1 addition & 0 deletions interface/modules/custom_modules/oe-module-weno/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Custom Modules
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
use OpenEMR\Modules\WenoModule\Services\LogProperties;
use OpenEMR\Modules\WenoModule\Services\WenoPharmaciesJson;

if (isset($_GET['key']) && !empty(isset($_GET['key']))) {
start_weno();
}
function start_weno()
{
$logsync = new LogProperties();
$logsync->logSync();
}

function downloadWenoPharmacy()
{
$cryptoGen = new CryptoGen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@
$term = filter_input(INPUT_GET, "term");
$val = '%' . $term . '%';

array_push($params, $val);
$params[] = $val;

$sql = "SELECT city, id FROM weno_pharmacy WHERE city LIKE ? LIMIT 10";
$res = sqlStatement($sql, $params);
while ($row = sqlFetchArray($res)) {
$return_arr[] = $row['city'];
}

echo json_encode($return_arr);
echo text(json_encode($return_arr));
}

if (isset($_GET['searchFor']) && $_GET['searchFor'] == 'weno_pharmacy') {
$term = filter_input(INPUT_GET, "term");
$val = '%' . $term . '%';

array_push($params, $val);
$params[] = $val;

$sql = "SELECT Business_Name, state, ncpdp, city, address_line_1 " .
"FROM weno_pharmacy WHERE Business_Name LIKE ?";
Expand All @@ -63,31 +63,31 @@

if (!empty($weno_coverage)) {
$sql .= " AND state_wide_mail_order = ?";
array_push($params, $weno_coverage);
$params[] = $weno_coverage;
}
if (!empty($weno_state)) {
$sql .= " AND state = ?";
array_push($params, $weno_state);
$params[] = $weno_state;
}
if (!empty($weno_city)) {
$sql .= " AND city = ?";
array_push($params, $weno_city);
$params[] = $weno_city;
}
if (!empty($weno_only)) {
$sql .= " AND on_weno = ?";
array_push($params, $weno_only);
$params[] = $weno_only;
}
if (!empty($full_day)) {
$sql .= " AND 24HR = ?";
array_push($params, $full_day);
$params[] = $full_day;
}
if (!empty($weno_zipcode)) {
$sql .= " AND ZipCode = ?";
array_push($params, $weno_zipcode);
$params[] = $weno_zipcode;
}
if (!empty($weno_test_pharmacies)) {
$sql .= " AND test_pharmacy = ?";
array_push($params, $weno_test_pharmacies);
$params[] = $weno_test_pharmacies;
}

$sql .= " ORDER BY Business_Name ASC";
Expand All @@ -99,13 +99,13 @@
"ncpdp" => $row['ncpdp']
);
}
echo json_encode($return_arr);
echo text(json_encode($return_arr));
}

if (isset($_GET['searchFor']) && $_GET['searchFor'] == 'weno_drop') {
$term = filter_input(INPUT_GET, "term");
$val = '%' . $term . '%';
array_push($params, $val);
$params[] = $val;

$sql = "SELECT Business_Name, state, ncpdp, city, address_line_1 " .
"FROM weno_pharmacy WHERE";
Expand All @@ -115,41 +115,42 @@
$weno_city = $_GET['weno_city'] ? $_GET['weno_city'] : '';
$full_day = $_GET['full_day'] ? 'Yes' : '';
$weno_zipcode = $_GET['weno_zipcode'] ? $_GET['weno_zipcode'] : '';
$weno_test_pharmacies = $_GET['test_pharmacy'] ? 'True' : '';
$weno_test_pharmacies = $_GET['test_pharmacy'] ? 'True' : '';

if (!empty($weno_state)) {
$sql .= " state = ?";
array_push($params, $weno_state);
$params[] = $weno_state;
}
if (!empty($weno_coverage)) {
$sql .= " AND state_wide_mail_order = ?";
array_push($params, $weno_coverage);
$params[] = $weno_coverage;
}
if (!empty($weno_city)) {
$sql .= " AND city = ?";
array_push($params, $weno_city);
$params[] = $weno_city;
}
if (!empty($full_day)) {
$sql .= " AND 24HR = ?";
array_push($params, $full_day);
$params[] = $full_day;
}
if (!empty($weno_zipcode)) {
$sql .= " AND ZipCode = ?";
array_push($params, $weno_zipcode);
$params[] = $weno_zipcode;
}
if (!empty($weno_test_pharmacies)) {
$sql .= " AND test_pharmacy = ?";
array_push($params, $weno_test_pharmacies);
$params[] = $weno_test_pharmacies;
}

$sql .= " ORDER BY Business_Name ASC";

$res = sqlStatement($sql, $params);
$return_arr = [];
while ($row = sqlFetchArray($res)) {
$return_arr[] = array(
"name" => $row['Business_Name'] . "/ " . $row['address_line_1'] . " / " . $row['city'],
"ncpdp" => $row['ncpdp']
);
}
echo json_encode($return_arr);
echo text(json_encode($return_arr));
}
12 changes: 6 additions & 6 deletions interface/modules/custom_modules/oe-module-weno/sql/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ CREATE TABLE `weno_download_log` (
) ENGINE=InnoDB;
#EndIf

-- For early adopters of weno, incase they need to upgrade to the next/latest release of openEMR
#IfRow background_services name WenoExchange
UPDATE `background_services` SET title="Weno Log Sync", `function`="downloadWenoPrescriptionLog", `require_once`="/interface/modules/custom_modules/oe-module-weno/scripts/weno_log_sync.php" WHERE `name`="WenoExchange";
#EndIf

#IfNotRow background_services name WenoExchangePharmacies
INSERT INTO `background_services` (`name`, `title`, `active`, `running`, `next_run`, `execute_interval`, `function`, `require_once`, `sort_order`)
VALUES ('WenoExchangePharmacies', 'Weno Exchange Pharmacy', '0', '0', current_timestamp(), '1440', 'downloadWenoPharmacy', '/interface/modules/custom_modules/oe-module-weno/scripts/weno_log_sync.php', '100');
#EndIf

#IfNotRow background_services name WenoExchange
INSERT INTO `background_services` (`name`, `title`, `active`, `running`, `next_run`, `execute_interval`, `function`, `require_once`, `sort_order`)
VALUES ('WenoExchange', 'Weno Log Sync', '0', '0', current_timestamp(), '1440', 'downloadWenoPrescriptionLog', '/interface/modules/custom_modules/oe-module-weno/scripts/weno_log_sync.php', '100');
#EndIf

-- For early adopters of weno, incase they need to upgrade to the next/latest release of openEMR
#IfRow background_services name WenoExchange
UPDATE `background_services` SET title="Weno Log Sync", `function`="downloadWenoPrescriptionLog", `require_once`="/interface/modules/custom_modules/oe-module-weno/scripts/weno_log_sync.php" WHERE `name`="WenoExchange";
VALUES ('WenoExchange', 'Weno Log Sync', '0', '0', current_timestamp(), '30', 'downloadWenoPrescriptionLog', '/interface/modules/custom_modules/oe-module-weno/scripts/weno_log_sync.php', '100');
#EndIf

#IfRow globals gl_name weno_provider_password
Expand Down
Loading

0 comments on commit 501cfa7

Please sign in to comment.