Skip to content

Commit

Permalink
Weno changes from documentation critique (openemr#7453)
Browse files Browse the repository at this point in the history
* Weno cahnge from documentation critique
- missed calc age bug
- nomenclature changes replace all weno provider with weno user

* -rename user to prescriber for user setting

* - move facility location setup above user id in module settings
- show authorization for widget based on weno user id and premissions
- change how weno user id is saved

* PSR from prior commits
  • Loading branch information
sjpadgett committed May 26, 2024
1 parent c06a6ae commit 5c52818
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 46 deletions.
10 changes: 5 additions & 5 deletions interface/modules/custom_modules/oe-module-weno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- **Important to note that The Primary Admin Section** will require using the Validate and Save button after completing this section. All other sections will auto save when values are changed.
## Setup Summary
- There are three sections. After entering the required Admin credentials, Weno User ID for all prescribers and the Weno Location ID for the appropriate facility, all of which was received when a Weno account was created, click the **Enable** button to enable the module allowing the start of initial pharmacies download. You may then go to the User Settings page to enter the provider/prescribers credentials. For yourself in this case.
- There are three sections. After entering the required Admin credentials, Weno User ID for all prescribers and the Weno Location ID for the appropriate facility, all of which was received when a Weno account was created, click the **Enable** button to enable the module allowing the start of initial pharmacies download. You may then go to the User Settings page to enter the prescribers credentials. For yourself in this case.
All providers that will be prescribing using Weno eRx must also have their credentials set otherwise the Weno eRx widget will not display.
- After a log out and in or by clicking the **Restart OpenEMR** button in config panel the Weno menu items of **Admin->Other->Weno Management** and **Reports->Clients->Prescription Log** will be enabled.
## Weno Required and Ancillary Setup for OpenEMR
Expand All @@ -24,12 +24,12 @@ There are three sections within the Weno eRx Service Admin Setup that allow the
- If the encryption key is deemed invalid an alert will show and a new Encryption Reset button enabled. First try re-entering the key but if that doesn't work clicking the Reset button will create a new key. This change will also be reflected in the Admins main Weno account and no other actions are needed by the user. You may look on the key as an API token which may be a more familiar term to the reader.
### The Map Weno User Id`s (Required) Section.
- This section presents a table of all authorised users showing their default facility if assigned and an input field to enter their Weno user id Uxxxx. This value is important in order to form a relationship between Weno and the OpenEMR user for tracking prescriptions.
- All values are automatically saved for the user whenever the Weno Provider ID is entered or changed.
- As a convenience, an edit button is supplied to present a dialog containing the Users settings in edit mode. From here user may edit any setting such as assigning a default facility. This would be the same as accessing Users from top menu Admin->Users selected provider.
- All values are automatically saved for the user whenever the Weno User ID is entered or changed.
- As a convenience, an edit button is supplied to present a dialog containing the Users settings in edit mode. From here user may edit any setting such as assigning a default facility. This would be the same as accessing Users from top menu Admin->Users selected Weno Prescriber.
### The Map Weno Facility Id`s (Required) Section.
- This section is pretty self explanatory with perhaps noting this same data may be accessed from top menu Admin->Other->Weno Management as explained below.
- This section also auto saves for convenience.
### Other methods for various set up items accessed from top menu.
- Open **Admin->Users** and select the user associated with the weno user id Uxxx and enter and save the weno user id in the **Weno Provider ID** field.
- Open **Admin->Users** and select the user associated with the weno user id Uxxx and enter and save the weno user id in the **Weno User ID** field.
- Next open **Admin->Other->Weno Management** and enter the assigned Location Id Lxxxxx for the locations facilities.
- Lastly from the top patient bar user icon click **Settings**. Scroll down or find the Weno button and click. Enter your username(email) and password in the **Weno Provider Email and Weno Provider Password** fields and **Save**. **Note** If these credentials are absent or wrong, you will not be able to prescribe prescriptions.
- Lastly from the top patient bar user icon click **Settings**. Scroll down or find the Weno button and click. Enter your username(email) and password in the **Weno User Email and Weno User Password** fields and **Save**. **Note** If these credentials are absent or wrong, you will not be able to prescribe prescriptions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getUserIdByWenoId($external_provider_id)
return $provider['id'];
} else {
// logged in user is auth weno user so let's ensure a user is set.
return "REQED:{users}" . xlt("Weno Provider Id missing. Select Admin then Users and edit the user to add Weno Provider Id");
return "REQED:{users}" . xlt("Weno User Id missing. Select Admin then Users and edit the user to add Weno User Id");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ public function getProviderEmail(): string|array
if (!empty($provider_info['email'])) {
return $provider_info;
} else {
$error = xlt("Provider email address is missing. Go to User settings Email to add provider's weno registered email address");
$error = xlt("Weno Prescriber email address is missing. Go to User settings Email to add Weno Prescriber's weno registered email address");
error_log(errorLogEscape($error));
TransmitProperties::echoError($error);
}
} elseif ($GLOBALS['weno_admin_username'] ?? false) {
$provider_info["email"] = $GLOBALS['weno_admin_username'];
return $provider_info;
} else {
$error = xlt("Provider email address is missing. Go to User settings Weno tab to add provider's weno registered email address");
$error = xlt("Weno Prescriber email address is missing. Go to User settings Weno tab to add Weno Prescriber's weno registered email address");
error_log($error);
echo TransmitProperties::styleErrors($error);
exit;
Expand All @@ -238,7 +238,7 @@ public function getProviderPassword(): mixed
if (!empty($GLOBALS['weno_admin_password'])) {
return $this->cryptoGen->decryptStandard($GLOBALS['weno_admin_password']);
} else {
echo xlt('Provider Password is missing');
echo xlt('Weno Prescriber Password is missing');
die;
}
} elseif ($GLOBALS['weno_admin_password']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static function getAge($dob, $as_of = ''): string
}
$a1 = explode('-', substr($dob, 0, 10));
$a2 = explode('-', substr($as_of, 0, 10));
$age = $a2[0] - $a1[0];
$age = (int)$a2[0] - (int)$a1[0];
if ($a2[1] < $a1[1] || ($a2[1] == $a1[1] && $a2[2] < $a1[2])) {
--$age;
}
Expand Down Expand Up @@ -294,7 +294,7 @@ public function getProviderEmail(): array|string
{
$provider_info = ['email' => ($GLOBALS['weno_provider_email'] ?? '')];
if (empty($provider_info['email'])) {
return "REQED:{user_settings}" . (xlt('Provider Email is missing. Go to User Settings Weno Tab and enter your Weno Provider Email'));
return "REQED:{user_settings}" . (xlt('Weno Prescriber Email is missing. Go to User Settings Weno Tab and enter your Weno User Email'));
} else {
return $provider_info;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ public function getFacilityInfo(): array|null|false
}
if (empty($default_facility['weno_id'])) {
// still no joy so let user know and get it set!
$default_facility['error'] = "REQED:{weno_manage}" . xlt('Facility ID is missing. From Admin select Weno eRx Tools then Weno eRx Service Setup. Enter the Weno ID of your facility');
$default_facility['error'] = "REQED:{weno_manage}" . xlt('Facility ID is missing. From Admin select Weno eRx Tools then Weno eRx Service Setup. Enter the Weno Location ID of your facility');
}
return $default_facility;
}
Expand Down Expand Up @@ -429,11 +429,11 @@ public function getProviderPassword(): mixed
if (!empty($GLOBALS['weno_provider_password'])) {
$ret = $this->cryptoGen->decryptStandard($GLOBALS['weno_provider_password']);
if (!$ret) {
return ("REQED:{user_settings}" . xlt('Your Provider Password fails decryption. Go to User Settings Weno Tab and reenter your Weno Provider Password'));
return ("REQED:{user_settings}" . xlt('Your Weno Prescriber Password fails decryption. Go to User Settings Weno Tab and reenter your Weno User Password'));
}
return $ret;
} else {
return "REQED:{user_settings}" . xlt('Your Provider Password is missing. Go to User Settings Weno Tab and enter your Weno Provider Password');
return "REQED:{user_settings}" . xlt('Your Weno Prescriber Password is missing. Go to User Settings Weno Tab and enter your Weno User Password');
}
}

Expand Down Expand Up @@ -469,7 +469,7 @@ private function getSubscriber(): mixed
$relation = sqlQuery("select subscriber_relationship from insurance_data where pid = ? and type = 'primary'", [$_SESSION['pid']]);
$relation = $relation ?? ['subscriber_relationship' => ''];

return $relation['subscriber_relationship'];
return $relation['subscriber_relationship'] ?? '';
}

/**
Expand Down Expand Up @@ -533,20 +533,22 @@ public function getWenoProviderId($id = null): mixed
if (empty($id)) {
$id = $_SESSION['authUserID'] ?? '';
}
// get the weno provider id from the user table (weno_prov_id)
// get the Weno User id from the user table (weno_prov_id)
$provider = sqlQuery("SELECT weno_prov_id FROM users WHERE id = ?", [$id]);

if ((!empty($GLOBALS['weno_provider_uid'])) && !empty($provider['weno_prov_id'])) {
$doIt = ($GLOBALS['weno_provider_uid']) != trim($provider['weno_prov_id']);
if ($doIt) {
$GLOBALS['weno_provider_uid'] = $provider['weno_prov_id'];
$provider['weno_prov_id'] = $GLOBALS['weno_provider_uid'];
$sql = "INSERT INTO `user_settings` (`setting_value`, `setting_user`, `setting_label`)
VALUES (?, ?, 'global:weno_provider_uid')
ON DUPLICATE KEY UPDATE `setting_value` = ?";
sqlQuery($sql, [$provider['weno_prov_id'], $id, $provider['weno_prov_id']]);
}

$GLOBALS['weno_provider_uid'] = $GLOBALS['weno_prov_id'] = $provider['weno_prov_id']; // update globals
$GLOBALS['weno_provider_uid'] = $GLOBALS['weno_prov_id'] = $provider['weno_prov_id']; // update users
$sql = "INSERT INTO `users` (`weno_prov_id`, `id`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `weno_prov_id` = ?";
sqlQuery($sql, [$GLOBALS['weno_provider_uid'], $id, $GLOBALS['weno_provider_uid']]);
return $provider['weno_prov_id'];
} elseif (!empty($provider['weno_prov_id'] ?? '') && empty($GLOBALS['weno_provider_uid'])) {
$sql = "INSERT INTO `user_settings` (`setting_value`, `setting_user`, `setting_label`)
Expand All @@ -557,14 +559,13 @@ public function getWenoProviderId($id = null): mixed
$GLOBALS['weno_provider_uid'] = $GLOBALS['weno_prov_id'] = $provider['weno_prov_id'];
return $provider['weno_prov_id'];
} elseif (empty($provider['weno_prov_id'] ?? '') && !empty($GLOBALS['weno_provider_uid'])) {
$sql = "INSERT INTO `users` (`weno_prov_id`, `id`) VALUES (?, ?)
ON DUPLICATE KEY UPDATE `weno_prov_id` = ?";
$sql = "INSERT INTO `users` (`weno_prov_id`, `id`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `weno_prov_id` = ?";
sqlQuery($sql, [$GLOBALS['weno_provider_uid'], $id, $GLOBALS['weno_provider_uid']]);

$provider['weno_prov_id'] = $GLOBALS['weno_prov_id'] = $GLOBALS['weno_provider_uid'];
return $provider['weno_prov_id'];
} else {
return "REQED:{users}" . xlt("Weno Provider Id missing. Select Admin then Users and edit the user to add Weno Provider Id");
return "REQED:{users}" . xlt("Weno User Id missing. Select Admin then Users and edit the user to add Weno User Id");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ public function getGlobalSettingSectionConfiguration(): array
, 'user_setting' => false
]*/
self::WENO_PROVIDER_EMAIL => [
'title' => xl('Weno Provider Email')
'title' => xl('Weno Prescriber Email')
, 'description' => xl('')
, 'type' => GlobalSetting::DATA_TYPE_TEXT
, 'default' => ''
, 'user_setting' => true
]
, self::WENO_PROVIDER_PASSWORD => [
'title' => xl('Weno Provider Password')
'title' => xl('Weno Prescriber Password')
, 'description' => xl('')
, 'type' => GlobalSetting::DATA_TYPE_ENCRYPTED
, 'default' => ''
, 'user_setting' => true
]
, self::WENO_PROVIDER_UID => [
'title' => xl('Weno Provider ID')
, 'description' => xl('When a Weno eRx provider, please enter your Weno provider ID here or in your Users setting. If you are not a Weno provider, please leave this field blank.')
'title' => xl('Weno Prescriber ID')
, 'description' => xl('When a Weno eRx Prescriber, please enter your Weno User ID here or in your Users setting. If you are not a Weno Prescriber, please leave this field blank.')
, 'type' => GlobalSetting::DATA_TYPE_TEXT
, 'default' => ''
, 'user_setting' => true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<th><?php print xlt('Facility Name'); ?></th>
<th><?php print xlt('Address'); ?></th>
<th><?php print xlt('City'); ?></th>
<th><?php print xlt('Weno ID'); ?></th>
<th><?php print xlt('Weno Location ID'); ?></th>
</tr>
</thead>
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@

use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Twig\TwigContainer;
use OpenEMR\Modules\WenoModule\Services\TransmitProperties;
use OpenEMR\Modules\WenoModule\Services\WenoLogService;

if (!AclMain::aclCheckCore('patients', 'med')) {
exit;
echo xlt("Not Authorized to use this widget.");
return;
}

$validate = new TransmitProperties(true);
$validate_errors = "";
$cite = '';

if (stripos($validate->getWenoProviderId(), 'Weno User Id missing') !== false) {
echo xlt("Not Authorized! Missing Weno Prescriber Id. See User Settings to configure Weno Prescriber Id.");
return "Fail";
}

$logService = new WenoLogService();
$pharmacyLog = $logService->getLastPharmacyDownloadStatus('Success');

Expand Down Expand Up @@ -52,7 +59,7 @@ function getProviderByWenoId($external_id, $provider_id = ''): string
if ($provider) {
return $provider['fname'] . " " . $provider['mname'] . " " . $provider['lname'];
} else {
return xlt("Weno Provider Id missing.");
return xlt("Weno User Id missing.");
}
}

Expand Down
Loading

0 comments on commit 5c52818

Please sign in to comment.