* @copyright Copyright (c) 2018 Brady Miller * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once("../../globals.php"); use OpenEMR\Common\Csrf\CsrfUtils; use OpenEMR\Common\Database\QueryUtils; use OpenEMR\Common\Logging\EventAuditLogger; use OpenEMR\Common\Session\SessionWrapperFactory; use OpenEMR\Core\Header; use OpenEMR\Core\OEGlobalsBag; $session = SessionWrapperFactory::getInstance()->getActiveSession(); $globals = OEGlobalsBag::getInstance(); $groupname = $globals->get('groupname', ''); $tback = $globals->getString('tback'); $authorize = []; $result = []; $result2 = []; $result3 = []; $result4 = []; $emptyRow = ['billing' => '', 'transaction' => '', 'pnotes' => '', 'forms' => '']; // Match the sibling authorizations.php gate — session must be flagged // userauthorized or have users.see_auth > 2 to run the mode=authorize action. $atemp = QueryUtils::querySingleRow("SELECT see_auth FROM users WHERE username = ?", [$session->get('authUser')]); $see_auth = is_array($atemp) ? ($atemp['see_auth'] ?? 0) : 0; $imauthorized = $session->get('userauthorized') || $see_auth > 2; if (isset($_GET["mode"]) && $_GET["mode"] == "authorize" && $imauthorized) { CsrfUtils::checkCsrfInput(INPUT_GET, dieOnFail: true); EventAuditLogger::getInstance()->newEvent("authorize", $session->get('authUser'), $session->get('authProvider'), 1, '', $_GET["pid"]); sqlStatement("update billing set authorized=1 where pid=?", [$_GET["pid"]]); sqlStatement("update forms set authorized=1 where pid=?", [$_GET["pid"]]); sqlStatement("update pnotes set authorized=1 where pid=?", [$_GET["pid"]]); sqlStatement("update transactions set authorized=1 where pid=?", [$_GET["pid"]]); } ?> " . text($iter["user"]) . ": " . text($iter["code_text"] . " " . date("n/j/Y", strtotime((string) $iter["date"]))) . "
\n"; } } //fetch transaction information: if ($res = sqlStatement("select * from transactions where authorized=0 and groupname=?", [$groupname])) { for ($iter = 0; $row = sqlFetchArray($res); $iter++) { $result2[$iter] = $row; } foreach ($result2 as $iter) { $pid = (int) $iter["pid"]; $authorize[$pid] ??= $emptyRow; $authorize[$pid]["transaction"] .= "" . text($iter["user"]) . ": " . text($iter["title"] . ": " . strterm((string) $iter["body"], 25) . " " . date("n/j/Y", strtotime((string) $iter["date"]))) . "
\n"; } } if (!OEGlobalsBag::getInstance()->getBoolean('ignore_pnotes_authorization')) { //fetch pnotes information, exclude ALL deleted notes if ($res = sqlStatement("select * from pnotes where authorized=0 and deleted!=1 and groupname=?", [$groupname])) { for ($iter = 0; $row = sqlFetchArray($res); $iter++) { $result3[$iter] = $row; } foreach ($result3 as $iter) { $pid = (int) $iter["pid"]; $authorize[$pid] ??= $emptyRow; $authorize[$pid]["pnotes"] .= "" . text($iter["user"]) . ": " . text(strterm((string) $iter["body"], 25) . " " . date("n/j/Y", strtotime((string) $iter["date"]))) . "
\n"; } } } //fetch forms information: if ($res = sqlStatement("select * from forms where authorized=0 and groupname=?", [$groupname])) { for ($iter = 0; $row = sqlFetchArray($res); $iter++) { $result4[$iter] = $row; } foreach ($result4 as $iter) { $pid = (int) $iter["pid"]; $authorize[$pid] ??= $emptyRow; $authorize[$pid]["forms"] .= "" . text($iter["user"]) . ": " . text($iter["form_name"] . " " . date("n/j/Y", strtotime((string) $iter["date"]))) . "
\n"; } } ?> \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } ?>
$patient) { $name = getPatientData($ppid); echo "
" . text($name["fname"] . " " . $name["lname"]) . "
" . xlt('Authorize') . "
" . xlt('Billing') . ":
" . $patient["billing"] . "
" . xlt('Transactions') . ":
" . $patient["transaction"] . "
" . xlt('Patient Notes') . ":
" . $patient["pnotes"] . "
" . xlt('Encounter Forms') . ":
" . $patient["forms"] . "