continued bug fixes (#1876)
[openemr.git] / interface / billing / ub04_helpers.php
blobd902a4c9c36065a0487c47f5442b24b14209a7c3
1 <?php
2 /**
3 * Helper for UB04 form.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Jerry Padgett <sjpadgett@gmail.com>
8 * @copyright Copyright (c) 2017 Jerry Padgett <sjpadgett@gmail.com>
9 * @license https://www.gnu.org/licenses/agpl-3.0.en.html GNU Affero General Public License 3
11 require_once("../globals.php");
12 require_once("ub04_codes.inc.php");
14 $lookup = isset($_GET["code_group"]) ? filter_input(INPUT_GET, 'code_group') : "";
15 $term = isset($_GET["term"]) ? filter_input(INPUT_GET, 'term') : '';
16 if ($lookup != "") {
17 lookup_codes($lookup, $term);
18 exit();
21 // Falling through for user dialog.
22 $users = sqlStatementNoLog("SELECT id,fname,lname,npi,taxonomy FROM users WHERE authorized=? AND active=?", array(1,1));
24 <html>
25 <head>
26 <script>
27 function sendSelection(value)
29 var parentId = <?php echo json_encode($_GET['formid']); ?>;
30 //window.opener.updateValue(parentId, value);
31 //window.close();
32 updateProvider(parentId, value);
33 eModal.close();
35 </script>
36 </head>
37 <body>
38 <table class="table table-striped">
39 <thead>
40 <tr>
41 <th><?php echo xlt('Provider')?></th>
42 <th><?php echo xlt('User Id') ?></th>
43 <th><?php echo xlt('NPI') ?></th>
44 <th><?php echo xlt('Taxonomy') ?></th>
45 </tr>
46 </thead>
47 <tbody>
48 <?php
49 while ($row = sqlFetchArray($users)) {
50 $data = json_encode($row);
52 <tr>
53 <td><button onclick='sendSelection(<?php echo $data;?>)'><?php echo text($row['fname'] . ' ' . $row['lname'])?></button></td>
54 <td><?php echo text($row['id']) ?></td>
55 <td><?php echo text($row['npi']) ?></td>
56 <td><?php echo text($row['taxonomy']) ?></td>
57 </tr>
58 <?php } ?>
59 </tbody>
60 </table>
61 </body>
62 </html>
63 <?php
64 function lookup_codes($group, $term)
66 global $ub04_codes;
67 $gotem = array();
69 foreach ($ub04_codes as $k => $v) {
70 if ($v['code_group'] != $group) {
71 continue;
73 $s = "/" . $term . "/i";
74 $label = $v['code'] . " : " . $v['desc'] . ($v['desc1'] ? (" :: " . $v['desc1']) : "");
75 if (preg_match($s, $label)) {
76 $gotem[] = array(
77 'label' => attr($label),
78 'value' => $v['code']
82 echo json_encode($gotem);
84 /**
85 * Lookup lists
86 * @param lookup group string $group
87 * @param search string $term
89 function get_codes_list($group, $term)
91 $term = "%" . $term . "%";
92 $response = sqlStatement("SELECT CONCAT_WS(': ', isc.code, isc.primary_desc, isc.desc1) as label, isc.code as value, isc.code_group as cg FROM inst_support_codes as isc
93 HAVING label LIKE ? And cg = ? ORDER BY code ASC", array($term, $group ));
95 while ($row = sqlFetchArray($response)) {
96 $resultpd[] = $row;
99 echo json_encode($resultpd);