label missing from Justify button due to missing parameter
[openemr.git] / interface / patient_file / encounter / diagnosis.php
blob0c409c5c02d108b516c2b198271e7ca6e589ef4b
1 <?php
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 ($payment_method == "insurance") {
8 $payment_method = "insurance: ".$insurance_company;
10 if (isset($mode)) {
11 if ($mode == "add") {
12 if (strtolower($type) == "copay") {
13 addBilling($encounter, $type, sprintf("%01.2f", $code), $payment_method, $pid, $userauthorized,$_SESSION['authUserID'],$modifier,$units,sprintf("%01.2f", 0 - $code));
15 elseif (strtolower($type) == "other") {
16 addBilling($encounter, $type, $code, $text, $pid, $userauthorized,$_SESSION['authUserID'],$modifier,$units,sprintf("%01.2f", $fee));
18 else {
19 addBilling($encounter, $type, $code, $text, $pid, $userauthorized,$_SESSION['authUserID'],$modifier,$units,$fee);
22 elseif ($mode == "justify") {
23 $diags = $_POST['code']['diag'];
24 $procs = $_POST['code']['proc'];
25 $sql = array();
26 if (!empty($procs) && !empty($diags)) {
27 $sql = array();
28 foreach ($procs as $proc) {
29 $justify_string = "";
30 foreach ($diags as $diag) {
31 $justify_string .= $diag . ":";
33 $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) . "'";
37 if (!empty($sql)) {
38 foreach ($sql as $q) {
39 $results = sqlQ($q);
46 <html>
47 <head>
48 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
49 </head>
51 <body <?php echo $bottom_bg_line;?> topmargin=0 rightmargin=0 leftmargin=4 bottommargin=0 marginheight=0>
53 <?php
54 $thisauth = acl_check('encounters', 'coding_a');
55 if (!$thisauth) {
56 $erow = sqlQuery("SELECT user FROM forms WHERE " .
57 "encounter = '$encounter' AND formdir = 'newpatient' LIMIT 1");
58 if ($erow['user'] == $_SESSION['authUser'])
59 $thisauth = acl_check('encounters', 'coding');
61 if ($thisauth) {
62 $tmp = getPatientData($pid, "squad");
63 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
64 $thisauth = 0;
66 if (!$thisauth) {
67 echo "<p>(".xl('Coding not authorized').")</p>\n";
68 echo "</body>\n</html>\n";
69 exit();
73 <form name="diagnosis" method="post" action="diagnosis.php?mode=justify">
75 <table border=0 cellspacing=0 cellpadding=0 height=100%>
76 <tr>
78 <!--
79 <td background="<?echo $linepic;?>" width=7 height=100%>
80 &nbsp;
81 </td>
82 -->
84 <td valign=top>
86 <dl>
87 <dt><a href="diagnosis_full.php" target="Main"><span class=title><?php echo ($GLOBALS['phone_country_code'] == '1') ? 'Billing' : 'Coding'; ?></span><font class=more><?php echo $tmore;?></font></a>
88 <?php
89 if( !empty( $_GET["back"] ) || !empty( $_POST["back"] ) ){
90 print "&nbsp;<a href=\"superbill_codes.php\" target=\"Main\"><font class=more>$tback</font></a>";
91 print "<input type=\"hidden\" name=\"back\" value=\"1\">";
94 <?php if (!$GLOBALS['weight_loss_clinic']) { ?>
95 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="justify" value="<?php xl('Justify','e');?>">
96 <?php } ?>
97 </dt>
98 </dl>
100 <a href="cash_receipt.php?" class='link_submit' target='new'>
101 [<?php xl('Receipt','e'); ?>]
102 </a>
103 <table border="0">
104 <?php
105 if ($result = getBillingByEncounter($pid,$encounter,"*") ) {
106 $billing_html = array();
107 $total = 0.0;
108 foreach ($result as $iter) {
109 if ($iter["code_type"] == "ICD9") {
110 $html = "<tr>";
112 $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";
113 $billing_html[$iter["code_type"]] .= $html;
114 $counter++;
116 elseif ($iter["code_type"] == "COPAY") {
117 $billing_html[$iter["code_type"]]
118 .= "<tr><td></td><td><a target=Main class=small href='diagnosis_full.php'><b>"
119 .$iter{"code"}."</b> "
120 .ucwords(strtolower($iter{"code_text"}))
121 .' payment entered on '
122 .$iter{"date"}."</a></td></tr>\n";
124 else {
125 $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"})) . ' ' . $iter['fee'] . "</a><span class=\"small\">";
126 $total += $iter['fee'];
127 $js = split(":",$iter['justify']);
128 $counter = 0;
129 foreach ($js as $j) {
130 if(!empty($j)) {
131 if ($counter == 0) {
132 $billing_html[$iter["code_type"]] .= " (<b>$j</b>)";
134 else {
135 $billing_html[$iter["code_type"]] .= " ($j)";
137 $counter++;
142 $billing_html[$iter["code_type"]] .= "</span></td></tr>\n";
147 $billing_html["CPT4"] .= "<tr><td>total:</td><td>" . sprintf("%01.2f",$total) . "</td></tr>\n";
148 foreach ($billing_html as $key => $val) {
149 print "<tr><td>$key</td><td><table>$val</table><td></tr><tr><td height=\"5\"></td></tr>\n";
153 </tr></table>
154 </td>
155 </tr>
156 <input type="hidden" name="encounter_id" value="<?= $encounter?>">
157 <input type="hidden" name="patient_id" value="<?= $pid?>">
158 </form>
159 </table>
161 </body>
162 </html>