Some change to prior PR#7429 (#7447)
[openemr.git] / interface / patient_file / encounter / superbill_codes.php
blob8212f7e5f134c2d7623b9a2209b7783aa2905d92
1 <?php
3 /**
4 * superbill_codes.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../../globals.php");
14 require_once("../../../custom/code_types.inc.php");
16 use OpenEMR\Billing\BillingUtilities;
17 use OpenEMR\Common\Csrf\CsrfUtils;
18 use OpenEMR\Core\Header;
20 //the number of rows to display before resetting and starting a new column:
21 $N = 10;
23 $mode = $_GET['mode'];
24 $type = $_GET['type'];
25 $modifier = $_GET['modifier'];
26 $units = $_GET['units'];
27 $fee = $_GET['fee'];
28 $code = $_GET['code'];
29 $text = $_GET['text'];
31 if (isset($mode)) {
32 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
33 CsrfUtils::csrfNotVerified();
36 if ($mode == "add") {
37 if (strtolower($type) == "copay") {
38 BillingUtilities::addBilling($encounter, $type, sprintf("%01.2f", $code), $text, $pid, $userauthorized, $_SESSION['authUserID'], $modifier, $units, sprintf("%01.2f", 0 - $code));
39 } elseif (strtolower($type) == "other") {
40 BillingUtilities::addBilling($encounter, $type, $code, $text, $pid, $userauthorized, $_SESSION['authUserID'], $modifier, $units, sprintf("%01.2f", $fee));
41 } else {
42 BillingUtilities::addBilling($encounter, $type, $code, $text, $pid, $userauthorized, $_SESSION['authUserID'], $modifier, $units, $fee);
47 <html>
48 <head>
49 <?php Header::setupHeader(); ?>
50 </head>
51 <body class="body_bottom">
53 <table class="table-borderless" cellspacing="0" cellpadding="0">
54 <tr>
55 <td class="align-top">
57 <dl>
59 <dt>
61 <a href="superbill_custom_full.php" onclick="top.restoreSession()">
62 <span class='title'><?php echo xlt('Superbill'); ?></span>
63 <span class='more'><?php echo text($tmore); ?></span></a>
65 <a href="encounter_bottom.php" onclick="top.restoreSession()"><span class='more'><?php echo text($tback); ?></span></a>
67 </dt>
68 </td></tr>
69 </table>
71 <table class='w-100 table-borderless' cellpadding='0' cellspacing='1'>
72 <?php
73 $res = sqlStatement("select * from codes where superbill = 1 order by code_type, code, code_text");
75 $codes = array();
76 echo " <tr>\n";
77 foreach ($code_types as $key => $value) {
78 $codes[$key] = array();
79 echo " <th class='text-left'>" . text($key) . " Codes</th>\n";
82 echo " </tr>\n";
84 for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
85 foreach ($code_types as $key => $value) {
86 if ($value['id'] == $row['code_type']) {
87 $codes[$key][] = $row;
88 break;
93 $index = 0;
95 $numlines = 0;
96 foreach ($codes as $value) {
97 $numlines = max($numlines, count($value));
100 while ($index < $numlines) {
101 echo " <tr>\n";
102 foreach ($codes as $key => $value) {
103 echo " <td class='align-top'>\n";
104 if (!empty($value[$index])) {
105 $code = $value[$index];
106 echo " <dd><a class='text' ";
107 echo "href='superbill_codes.php?back=1&mode=add" .
108 "&type=" . attr_url($key) .
109 "&modifier=" . attr_url($code["modifier"]) .
110 "&units=" . attr_url($code["units"]) .
111 "&fee=" . attr_url($code["fee"]) .
112 "&code=" . attr_url($code["code"]) .
113 "&text=" . attr_url($code["code_text"]) .
114 "&csrf_token_form=" . attr_url(CsrfUtils::collectCsrfToken()) .
115 "' onclick='top.restoreSession()'>";
116 echo "<b>" . text($code['code']) . "</b>" . "&nbsp;" . text($code['modifier']) . "&nbsp;" . text($code['code_text']);
117 echo "</a></dd>\n";
120 echo " </td>\n";
123 echo " </tr>\n";
124 ++$index;
129 </table>
131 </dl>
133 </body>
134 </html>