more bug fixes (#1917)
[openemr.git] / interface / main / authorizations / authorizations_full.php
blob1d30ccfe34fb5eba79bd00d827a91f1c58af3ca4
1 <?php
2 /**
3 * Authorizations full script.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../../globals.php");
14 require_once("$srcdir/patient.inc");
16 if (isset($_GET["mode"]) && $_GET["mode"] == "authorize") {
17 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
18 die(xlt('Authentication Error'));
21 newEvent("authorize", $_SESSION["authUser"], $_SESSION["authProvider"], 1, '', $_GET["pid"]);
22 sqlStatement("update billing set authorized=1 where pid=?", array($_GET["pid"]));
23 sqlStatement("update forms set authorized=1 where pid=?", array($_GET["pid"]));
24 sqlStatement("update pnotes set authorized=1 where pid=?", array($_GET["pid"]));
25 sqlStatement("update transactions set authorized=1 where pid=?", array($_GET["pid"]));
28 <html>
29 <head>
30 <?php html_header_show();?>
31 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
32 </head>
33 <body class="body_top">
35 <a href="authorizations.php" onclick='top.restoreSession()'>
36 <font class=title><?php echo xlt('Authorizations'); ?></font>
37 <font class=more><?php echo text($tback); ?></font></a>
39 <?php
40 // billing
41 // forms
42 // pnotes
43 // transactions
45 //fetch billing information:
46 if ($res = sqlStatement("select *, concat(u.fname,' ', u.lname) as user from billing LEFT JOIN users as u on billing.user = u.id where billing.authorized=0 and groupname=?", array ($groupname))) {
47 for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
48 $result[$iter] = $row;
51 if ($result) {
52 foreach ($result as $iter) {
53 $authorize{$iter{"pid"}}{"billing"} .= "<span class=small>" .
54 text($iter{"user"}) . ": </span><span class=text>" .
55 text($iter{"code_text"} . " " . date("n/j/Y", strtotime($iter{"date"}))) .
56 "</span><br>\n";
61 //fetch transaction information:
62 if ($res = sqlStatement("select * from transactions where authorized=0 and groupname=?", array($groupname))) {
63 for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
64 $result2[$iter] = $row;
67 if ($result2) {
68 foreach ($result2 as $iter) {
69 $authorize{$iter{"pid"}}{"transaction"} .= "<span class=small>" .
70 text($iter{"user"}) . ": </span><span class=text>" .
71 text($iter{"title"} . ": " . strterm($iter{"body"}, 25) . " " . date("n/j/Y", strtotime($iter{"date"}))) .
72 "</span><br>\n";
77 if (empty($GLOBALS['ignore_pnotes_authorization'])) {
78 //fetch pnotes information, exclude ALL deleted notes
79 if ($res = sqlStatement("select * from pnotes where authorized=0 and deleted!=1 and groupname=?", array($groupname))) {
80 for ($iter = 0; $row = sqlFetchArray($res);
81 $iter++) {
82 $result3[$iter] = $row;
85 if ($result3) {
86 foreach ($result3 as $iter) {
87 $authorize{$iter{"pid"}}{"pnotes"} .= "<span class=small>" .
88 text($iter{"user"}) . ": </span><span class=text>" .
89 text(strterm($iter{"body"}, 25) . " " . date("n/j/Y", strtotime($iter{"date"}))) .
90 "</span><br>\n";
96 //fetch forms information:
97 if ($res = sqlStatement("select * from forms where authorized=0 and groupname=?", array($groupname))) {
98 for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
99 $result4[$iter] = $row;
102 if ($result4) {
103 foreach ($result4 as $iter) {
104 $authorize{$iter{"pid"}}{"forms"} .= "<span class=small>" .
105 text($iter{"user"}) . ": </span><span class=text>" .
106 text($iter{"form_name"} . " " . date("n/j/Y", strtotime($iter{"date"}))) .
107 "</span><br>\n";
113 <table border=0 cellpadding=0 cellspacing=2 width=100%>
114 <tr>
115 <td valign=top>
117 <?php
118 if ($authorize) {
119 while (list($ppid,$patient) = each($authorize)) {
120 $name = getPatientData($ppid);
122 echo "<tr><td valign=top><span class=bold>". text($name{"fname"} . " " . $name{"lname"}) .
123 "</span><br><a class=link_submit href='authorizations_full.php?mode=authorize&pid=" .
124 attr(urlencode($ppid)) . "&csrf_token_form=" . attr(urlencode(collectCsrfToken())) . "' onclick='top.restoreSession()'>" . xlt('Authorize') . "</a></td>\n";
125 echo "<td valign=top><span class=bold>".xlt('Billing').
126 ":</span><span class=text><br>" . $patient{"billing"} . "</td>\n";
127 echo "<td valign=top><span class=bold>".xlt('Transactions').
128 ":</span><span class=text><br>" . $patient{"transaction"} . "</td>\n";
129 echo "<td valign=top><span class=bold>".xlt('Patient Notes').
130 ":</span><span class=text><br>" . $patient{"pnotes"} . "</td>\n";
131 echo "<td valign=top><span class=bold>".xlt('Encounter Forms').
132 ":</span><span class=text><br>" . $patient{"forms"} . "</td>\n";
133 echo "</tr>\n";
134 $count++;
139 </td>
141 </tr>
142 </table>
144 </body>
145 </html>