Skip to content

Commit

Permalink
More Changes and Fixes Modules (openemr#7755)
Browse files Browse the repository at this point in the history
* More Changes and Fixes Modules
- add update to log sync for erx changes
- rename Weno Provider ID to  Weno User ID in Users

* tune up demographics styling
track sync status

* ensure fetchEncounterQuestionnaireForm form is enabled.

* fix questionnaire assessment to handle actions from document module
ensure clear encounter for save from documents
fix edit list feesheet limit of 40 codes on save
add save alert to lists edit
fix demographics patient documents calling templates directly, activity history and restyle
fix portal patient ledger and restyle

* add delete per row to portal audit table
add password show toggle to portal and core login

* validate repsponsible party
  • Loading branch information
sjpadgett authored Oct 9, 2024
1 parent 402c607 commit 557ec66
Show file tree
Hide file tree
Showing 30 changed files with 1,361 additions and 1,093 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
$questionnaire_form = $_GET['questionnaire_form'] ?? null;
$repository_item = $_POST['select_item'] ?? null;

$isModule = ($_REQUEST['formOrigin'] ?? null) == 2;
$isDashboard = ($_REQUEST['formOrigin'] ?? null) == 1;
if ($isModule) {
$questionnaire_form = $_GET['formname'] ?? null;
}
if ($isPortal) {
$questionnaire_form = $_GET['formname'] ?? null;
}
Expand Down Expand Up @@ -74,10 +79,11 @@
$q_json = '';
$lform = '';
$form_name = '';
// By name is for new form from repository.
if (empty($formid) && !empty($questionnaire_form) && $questionnaire_form != 'New Questionnaire') {
// since we are here then user is authorized for a pre-approved questionnaire form.
$is_authorized = true;
if ($isPortal) {
if ($isPortal || $isModule) {
if (is_numeric($questionnaire_form)) {
$q = $service->fetchQuestionnaireById((int)$questionnaire_form);
} else {
Expand All @@ -90,6 +96,9 @@
$lform = $q['lform'] ?: '';
$mode = 'new_form';
$form_name = $q['name'] ?: '';
if (empty($q_json) && empty($lform)) {
throw (new Exception(xl("Unable to find questionnaire form" . ' ' . $questionnaire_form)));
}
}
// This is for newly selected questionnaire from repository dropdown.
if (!empty($repository_item) && $questionnaire_form == 'New Questionnaire') {
Expand All @@ -99,15 +108,15 @@
$form_name = $q['name'] ?: '';
$mode = 'new_repository_form';
}

if (!$isPortal) {
$do_warning = checkUserSetting('disable_form_disclaimer', '1') === true ? 0 : 1;
}
if ($questionnaire_form == 'New Questionnaire') {
$q_list = $service->getQuestionnaireList(true);
}
} catch (Exception $e) {
die(xlt("Can not continue with reason.") . '<br />' . text($e->getMessage()));
$msg = "<p style='color: red; font-size: 1.25rem;'>" . xlt("Can not continue") . ": " . text($e->getMessage()) . "</p>";
die($msg);
}
/* where to put the LOINC statement , and the statement itself */
$top_note = true; // default to top if not set in configuration
Expand Down Expand Up @@ -153,9 +162,12 @@
$theme = 'dark';
}

$container = 'container-fluid';
if (!empty($GLOBALS['questionnaire_display_fullscreen'] ?? 0)) {
if ($isModule || $isDashboard || $isPortal) {
$container = 'container-fluid';
} elseif (!empty($GLOBALS['questionnaire_display_fullscreen'] ?? 0)) {
$container = 'container';
} else {
$container = 'container-fluid';
}

?>
Expand All @@ -166,6 +178,11 @@
<title id="main_title"><?php echo xlt('Questionnaire'); ?></title>
<?php Header::setupHeader(); ?>
<!-- TODO remove next release -->
<style>
.lhc-form-title {
padding: .25rem !important;
}
</style>
<script>
let isPortal = <?php echo js_escape($isPortal); ?>;
let portalOther = <?php echo js_escape($patientPortalOther); ?>;
Expand Down Expand Up @@ -423,7 +440,7 @@ function initSearchForm() {
</head>
<body class="bg-light" data-theme="<?php echo attr($theme); ?>">
<div class="<?php echo attr($container); ?>">
<?php if (!$isPortal) { ?>
<?php if (!$isPortal && !$isModule && !$isDashboard) { ?>
<div class="title bg-light text-dark">
<h4><?php if ($mode != 'new_form' && $mode != 'update') {
echo xlt("Create Encounter Questionnaires");
Expand Down
4 changes: 4 additions & 0 deletions interface/forms/questionnaire_assessments/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
if ($isPortal && $mode == 'update' && !empty($formid)) {
CoreFormToPortalUtility::confirmFormBootstrapPatient($isPortal, $formid, 'questionnaire_assessments', $_SESSION['pid']);
}
if (($_REQUEST['formOrigin'] ?? null) == 2) {
$encounter = 0;
}

if ($mode !== 'new' && $mode !== 'new_repository_form') {
$service = new QuestionnaireService();
$responseService = new QuestionnaireResponseService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,20 @@
$db_sms_msg['sms_gateway_type'] = "SMS";
$db_sms_msg['message'] = $MESSAGE;
?>
<!DOCTYPE html>
<html lang="eng">
<head>
<title><?php echo xlt("Notifications") ?></title>
<?php Header::setupHeader(); ?>
</head>
<style>
html {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
font-size: 14px;
}
</style>
<body>
<!DOCTYPE html>
<html lang="eng">
<head>
<title><?php echo xlt("Notifications") ?></title>
<?php Header::setupHeader(); ?>
</head>
<style>
html {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
font-size: 14px;
}
</style>
<body>
<div>
<div class="container-fluid">
<div>
<div class="text-center mt-2"><h2><?php echo xlt("Working and may take a few minutes to finish.") ?></h2></div>
</div>
Expand Down Expand Up @@ -253,7 +252,7 @@
?>
</div>
</body>
</html>
</html>

<?php
function isValidPhone($phone): array|bool|string|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function dispatchActions(): void
public function getSession($param = null, $default = null): mixed
{
if ($param) {
return $_SESSION[$param] ?: $default;
return $_SESSION[$param] ?? $default;
}

return $this->_session;
Expand All @@ -112,7 +112,7 @@ public function getSession($param = null, $default = null): mixed
public function getQuery($param = null, $default = null): mixed
{
if ($param) {
return $this->_query[$param] ?: $default;
return $this->_query[$param] ?? $default;
}

return $this->_query;
Expand Down Expand Up @@ -313,7 +313,7 @@ abstract function fetchReminderCount(): string|bool;
public function getPost($param = null, $default = null): mixed
{
if ($param) {
return $this->_post[$param] ?: $default;
return $this->_post[$param] ?? $default;
}

return $this->_post;
Expand Down Expand Up @@ -408,7 +408,7 @@ protected function saveSetup(array $setup = []): string
public function getRequest($param = null, $default = null): mixed
{
if ($param) {
return $this->_request[$param] ?: $default;
return $this->_request[$param] ?? $default;
}

return $this->_request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function __construct()
$this->uriDir = $GLOBALS['OE_SITE_WEBROOT'];
$this->cacheDir = $GLOBALS['OE_SITE_DIR'] . '/documents/logs_and_misc/_cache';
$this->credentials = $this->getCredentials();
$this->portalUrl = $this->credentials['production'] ? "https://service.ringcentral.com/" : "https://service.devtest.ringcentral.com/";
$this->serverUrl = $this->credentials['production'] ? "https://platform.ringcentral.com" : "https://platform.devtest.ringcentral.com";
$this->redirectUrl = $this->credentials['redirect_url'];
$this->portalUrl = $this->credentials['production'] ?? null ? "https://service.ringcentral.com/" : "https://service.devtest.ringcentral.com/";
$this->serverUrl = $this->credentials['production'] ?? null ? "https://platform.ringcentral.com" : "https://platform.devtest.ringcentral.com";
$this->redirectUrl = $this->credentials['redirect_url'] ?? null;
$this->initializeSDK();
parent::__construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,41 @@ public function insertPrescriptions($insertdata)
return $e->getMessage();
}
}

public function updatePrescriptions($updatedata)
{
$sql = "UPDATE prescriptions SET ";
$sql .= "active = ?, ";
$sql .= "date_added = ?, ";
$sql .= "datetime = NOW(), ";
$sql .= "patient_id = ?, ";
$sql .= "provider_id = ?, ";
$sql .= "drug = ?, ";
$sql .= "quantity = ?, ";
$sql .= "refills = ?, ";
$sql .= "substitute = ?, ";
$sql .= "note = ?, ";
$sql .= "rxnorm_drugcode = ?, ";
$sql .= "external_id = ? ";
$sql .= "WHERE indication = ?";

try {
sqlQuery($sql, [
$updatedata['active'],
$updatedata['date_added'],
$updatedata['patient_id'],
$updatedata['user_id'],
$updatedata['drug'],
$updatedata['quantity'],
$updatedata['refills'],
$updatedata['substitute'],
$updatedata['note'],
$updatedata['rxnorm_drugcode'],
$updatedata['provider_id'],
$updatedata['prescriptionguid']
]);
} catch (Exception $e) {
return $e->getMessage();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function checkMessageId()
{
$sql = "select count(*) as count from prescriptions where indication = ?";
$entry = sqlQuery($sql, [$this->messageid]);
return $entry['count'];
return $entry['count'] ?? 0;
}

function convertToUTC($dateString)
Expand All @@ -76,6 +76,7 @@ public function buildPrescriptionInserts(): bool|string
$wenoLog = new WenoLogService();
$l = 0;
$rxCnt = 0;
$updateCnt = 0;
if (file_exists($this->rxsynclog)) {
$records = fopen($this->rxsynclog, "r");

Expand All @@ -92,9 +93,6 @@ public function buildPrescriptionInserts(): bool|string
if (isset($line[4])) {
$this->messageid = $line[4];
$is_saved = $this->checkMessageId();
if ($is_saved > 0) {
continue;
}
}
if (!empty($line)) {
$pr = $line[2] ?? '';
Expand All @@ -119,7 +117,9 @@ public function buildPrescriptionInserts(): bool|string
$insertdata['date_added'] = $ida;
$insertdata['patient_id'] = $pid;
$insertdata['attached_user_id'] = $uid;
$drug = isset($line[11]) ? str_replace('"', '', $line[11]) : xlt("Incomplete");
$insertdata['sync_type'] = trim($line[3] ?? '');
$insertdata['status'] = trim($line[6] ?? '');
$drug = isset($line[11]) ? str_replace('"', '', $line[11]) : ($insertdata['sync_type'] . " " . $insertdata['status'] . " " . xl("Use RxLog"));
$insertdata['drug'] = $drug;
$insertdata['quantity'] = $line[18] ?? '';
$insertdata['refills'] = $refills;
Expand All @@ -132,8 +132,15 @@ public function buildPrescriptionInserts(): bool|string
$insertdata['prescriptionguid'] = $line[4] ?? '';
$insertdata['txDate'] = $ida;
$loginsert = new LogDataInsert();
$loginsert->insertPrescriptions($insertdata);
++$rxCnt;
if ($is_saved > 0) {
$loginsert->updatePrescriptions($insertdata);
if (trim($line[7] ?? '') == 'True') {
++$updateCnt;
}
} else {
$loginsert->insertPrescriptions($insertdata);
++$rxCnt;
}
++$l;
}
}
Expand All @@ -143,10 +150,10 @@ public function buildPrescriptionInserts(): bool|string
return false;
}

if ($rxCnt == 0) {
if ($rxCnt == 0 && $updateCnt == 0) {
$status = xl("No new prescriptions to sync.");
} else {
$status = xl("Synced") . " " . text($rxCnt) . " " . xl("prescriptions.");
$status = xl("Synced") . " " . text($rxCnt) . " new " . text($updateCnt) . " " . xl("updated") . " " . xl("prescriptions.");
}
$wenoLog->insertWenoLog("Sync Report", $status);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ private function getResponsibleParty(): mixed
if (empty($relation)) {
return 'REQED:{demographics}' . xlt("Patient is under 19 years old. A Responsible Party is required. From the Patient Chart select Demographics Primary Insurance or Guardian to add a person.");
}
if (empty($relation['ResponsiblePartyZip']) || empty($relation['ResponsiblePartyAddressLine1']) || empty($relation['ResponsiblePartyCity'])) {
return 'REQED:{demographics}' . xlt("Responsible Party Zip, Street and or City Missing, From the Patient Chart select Demographics Primary Insurance or Guardian to add or edit a person.");
}

return $relation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use OpenEMR\Modules\WenoModule\Services\TransmitProperties;
use OpenEMR\Modules\WenoModule\Services\WenoLogService;

if (!AclMain::aclCheckCore('patients', 'rx', '', 'write')) {
if (!AclMain::aclCheckCore('patients', 'rx')) {
echo xlt("Not Authorized to use this widget.");
return;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ function getProviderByWenoId($external_id, $provider_id = ''): string
}
}

$defaultUserFacility = sqlQuery("SELECT id,username,lname,fname,weno_prov_id,facility,facility_id FROM `users` WHERE active = 1 and authorized = 1 and id = ?", array($_SESSION['authUserID'] ?? 0));
$defaultUserFacility = sqlQuery("SELECT id,username,lname,fname,weno_prov_id,facility,facility_id FROM `users` WHERE active = 1 AND `username` > '' and id = ?", array($_SESSION['authUserID'] ?? 0));
$list = sqlStatement("SELECT id, name, street, city, weno_id FROM facility WHERE inactive != 1 AND weno_id IS NOT NULL ORDER BY name");
$facilities = [];
while ($row = sqlFetchArray($list)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

$wenoLog = new WenoLogService();

$fetch = sqlStatement("SELECT id,username,lname,fname,weno_prov_id,facility,facility_id FROM `users` WHERE active = 1 and authorized = 1");
$fetch = sqlStatement("SELECT id,username,lname,fname,weno_prov_id,facility,facility_id FROM `users` WHERE active = 1 AND `username` > ''");
while ($row = sqlFetchArray($fetch)) {
$usersData[] = $row;
}

$defaultUserFacility = sqlQuery("SELECT id,username,lname,fname,weno_prov_id,facility,facility_id FROM `users` WHERE active = 1 and authorized = 1 and id = ?", array($_SESSION['authUserID'] ?? 0));
$defaultUserFacility = sqlQuery("SELECT id,username,lname,fname,weno_prov_id,facility,facility_id FROM `users` WHERE active = 1 AND `username` > '' and id = ?", array($_SESSION['authUserID'] ?? 0));
$list = sqlStatement("SELECT id, name, street, city, weno_id FROM facility WHERE inactive != 1 AND weno_id IS NOT NULL ORDER BY name");
$facilities = [];
while ($row = sqlFetchArray($list)) {
Expand Down
6 changes: 3 additions & 3 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -1161,14 +1161,14 @@ function filterActiveIssues(array $i): array
$viewArgs['content'] = ob_get_contents();
ob_end_clean();

echo "<div class=\"col\">";
echo "<div class='col m-0 p-0 mx-1'>";
echo $t->render('patient/card/rx.html.twig', $viewArgs); // render core prescription card
echo "</div>";
endif;
?>
</div>
<div class="row">
<div class="col-md-8">
<div class="col-md-8 px-2">
<?php
if ($deceased > 0) :
echo $twig->getTwig()->render('patient/partials/deceased.html.twig', [
Expand Down Expand Up @@ -1412,7 +1412,7 @@ function filterActiveIssues(array $i): array
endwhile; // end while
?>
</div> <!-- end left column div -->
<div class="col-md-4">
<div class="col-md-4 px-2">
<!-- start right column div -->
<?php
$_extAccess = [
Expand Down
Loading

0 comments on commit 557ec66

Please sign in to comment.