phpgacl implementation updates
[openemr.git] / interface / patient_file / encounter / diagnosis.php
blob29aee885fbcfc68ffd14c271ebc03476edfd6b8e
1 <?
2 include_once("../../globals.php");
3 include_once("$srcdir/billing.inc");
4 include_once("$srcdir/sql.inc");
5 include_once("$srcdir/acl.inc");
7 if (isset($mode)) {
8 if ($mode == "add") {
9 if (strtolower($type) == "copay") {
10 addBilling($encounter, $type, sprintf("%01.2f", $code), $text, $pid, $userauthorized,$_SESSION['authUserID'],$modifier,$units,sprintf("%01.2f", 0 - $code));
12 elseif (strtolower($type) == "other") {
13 addBilling($encounter, $type, $code, $text, $pid, $userauthorized,$_SESSION['authUserID'],$modifier,$units,sprintf("%01.2f", $fee));
15 else {
16 addBilling($encounter, $type, $code, $text, $pid, $userauthorized,$_SESSION['authUserID'],$modifier,$units,$fee);
19 elseif ($mode == "justify") {
20 $diags = $_POST['code']['diag'];
21 $procs = $_POST['code']['proc'];
22 $sql = array();
23 if (!empty($procs) && !empty($diags)) {
24 $sql = array();
25 foreach ($procs as $proc) {
26 $justify_string = "";
27 foreach ($diags as $diag) {
28 $justify_string .= $diag . ":";
30 $sql[] = "UPDATE billing set justify = concat(justify,'" . mysql_real_escape_string($justify_string) ."') where encounter = '" . mysql_real_escape_string($_POST['encounter_id']) . "' and pid = '" . mysql_real_escape_string($_POST['patient_id']) . "' and code = '" . mysql_real_escape_string($proc) . "'";
34 if (!empty($sql)) {
35 foreach ($sql as $q) {
36 $results = sqlQ($q);
43 <html>
44 <head>
45 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
46 </head>
48 <body <?echo $bottom_bg_line;?> topmargin=0 rightmargin=0 leftmargin=4 bottommargin=0 marginheight=0>
51 $thisauth = acl_check('encounters', 'coding_a');
52 if (!$thisauth) {
53 $erow = sqlQuery("SELECT user FROM forms WHERE " .
54 "encounter = '$encounter' AND formdir = 'newpatient' LIMIT 1");
55 if ($erow['user'] == $_SESSION['authUser'])
56 $thisauth = acl_check('encounters', 'coding');
58 if (!$thisauth) {
59 echo "<p>(Coding not authorized)</p>\n";
60 echo "</body>\n</html>\n";
61 exit();
65 <form name="diagnosis" method="post" action="diagnosis.php?mode=justify">
67 <table border=0 cellspacing=0 cellpadding=0 height=100%>
68 <tr>
69 <td background="<?echo $linepic;?>" width=7 height=100%>
70 &nbsp;
71 </td>
72 <td valign=top>
74 <dl>
75 <dt><a href="diagnosis_full.php" target="Main"><span class=title><? echo ($GLOBALS['phone_country_code'] == '1') ? 'Billing' : 'Coding' ?></span><font class=more><?echo $tmore;?></font></a>
77 if( !empty( $_GET["back"] ) || !empty( $_POST["back"] ) ){
78 print "&nbsp;<a href=\"superbill_codes.php\" target=\"Main\"><font class=more>$tback</font></a>";
79 print "<input type=\"hidden\" name=\"back\" value=\"1\">";
82 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="justify" value="Justify"></dt>
83 </dl>
85 <table border="0">
87 if ($result = getBillingByEncounter($pid,$encounter,"*") ) {
88 $billing_html = array();
89 foreach ($result as $iter) {
90 if ($iter["code_type"] == "ICD9") {
91 $html = "<tr>";
93 $html .= "<td valign=\"middle\">" . '<input style="width: 11px;height: 11px;" name="code[diag]['. $iter["code"]. ']" type="checkbox" value="' .$iter[code] . '">' . "</td><td><div><a target=Main class=small href='diagnosis_full.php'><b>".$iter{"code"}."</b> " . ucwords(strtolower($iter{"code_text"})) . "</a></div></td></tr>\n";
94 $billing_html[$iter["code_type"]] .= $html;
95 $counter++;
97 elseif ($iter["code_type"] == "COPAY") {
98 $billing_html[$iter["code_type"]] .= "<tr><td></td><td><a target=Main class=small href='diagnosis_full.php'><b>".$iter{"code"}."</b> " . ucwords(strtolower($iter{"code_text"})) . "</a></td></tr>\n";
100 else {
101 $billing_html[$iter["code_type"]] .= "<tr><td>" . '<input style="width: 11px;height: 11px;" name="code[proc]['. $iter["code"]. ']" type="checkbox" value="'. $iter[code] .'">' . "</td><td><a target=Main class=small href='diagnosis_full.php'><b>".$iter{"code"}. ' ' . $iter['modifier'] . "</b> " . ucwords(strtolower($iter{"code_text"})) . "</a><span class=\"small\">";
102 $js = split(":",$iter['justify']);
103 $counter = 0;
104 foreach ($js as $j) {
105 if(!empty($j)) {
106 if ($counter == 0) {
107 $billing_html[$iter["code_type"]] .= " (<b>$j</b>)";
109 else {
110 $billing_html[$iter["code_type"]] .= " ($j)";
112 $counter++;
117 $billing_html[$iter["code_type"]] .= "</span></td></tr>\n";
122 foreach ($billing_html as $key => $val) {
123 print "<tr><td>$key</td><td><table>$val</table><td></tr><tr><td height=\"5\"></td></tr>\n";
133 </tr></table>
134 </td>
135 </tr>
136 <input type="hidden" name="encounter_id" value="<?=$encounter?>">
137 <input type="hidden" name="patient_id" value="<?=$pid?>">
138 </form>
139 </table>
144 </body>
145 </html>