Add new modules loaded event (#7463)
[openemr.git] / interface / billing / ub04_helpers.php
blob9dac76988d24ae27825d664b9676573e56f2f554
1 <?php
3 /**
4 * Helper for UB04 form.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Jerry Padgett <sjpadgett@gmail.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2017-2019 Jerry Padgett <sjpadgett@gmail.com>
11 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("ub04_codes.inc.php");
18 $lookup = isset($_GET["code_group"]) ? filter_input(INPUT_GET, 'code_group') : "";
19 $term = isset($_GET["term"]) ? filter_input(INPUT_GET, 'term') : '';
20 if ($lookup != "") {
21 lookup_codes($lookup, $term);
22 exit();
25 // Falling through for user dialog.
26 $users = sqlStatementNoLog("SELECT id,fname,lname,npi,taxonomy FROM users WHERE authorized=? AND active=?", array(1,1));
28 <html>
29 <head>
30 <script>
31 function sendSelection(value)
33 let parentId = <?php echo js_escape($_GET['formid']); ?>;
35 updateProvider(parentId, value);
36 dialog.closeAjax();
38 </script>
39 </head>
40 <body>
41 <table class="table table-sm table-striped">
42 <thead>
43 <tr>
44 <th><?php echo xlt('Provider')?></th>
45 <th><?php echo xlt('User Id') ?></th>
46 <th><?php echo xlt('NPI') ?></th>
47 <th><?php echo xlt('Taxonomy') ?></th>
48 </tr>
49 </thead>
50 <tbody>
51 <?php
52 while ($row = sqlFetchArray($users)) {
53 $data = json_encode($row);
55 <tr>
56 <td><button btn btn-secondary btn-sm onclick='sendSelection(<?php echo $data;?>)'><?php echo text($row['fname'] . ' ' . $row['lname'])?></button></td>
57 <td><?php echo text($row['id']) ?></td>
58 <td><?php echo text($row['npi']) ?></td>
59 <td><?php echo text($row['taxonomy']) ?></td>
60 </tr>
61 <?php } ?>
62 </tbody>
63 </table>
64 </body>
65 </html>
66 <?php
67 function lookup_codes($group, $term)
69 global $ub04_codes;
70 $gotem = array();
72 foreach ($ub04_codes as $k => $v) {
73 if ($v['code_group'] != $group) {
74 continue;
76 $s = "/" . $term . "/i";
77 $label = $v['code'] . " : " . $v['desc'] . ($v['desc1'] ? (" :: " . $v['desc1']) : "");
78 if (preg_match($s, $label)) {
79 $gotem[] = array(
80 'label' => attr($label),
81 'value' => $v['code']
85 echo json_encode($gotem);
87 /**
88 * Lookup lists
89 * @param lookup group string $group
90 * @param search string $term
92 function get_codes_list($group, $term)
94 $term = "%" . $term . "%";
95 $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
96 HAVING label LIKE ? And cg = ? ORDER BY code ASC", array($term, $group ));
98 while ($row = sqlFetchArray($response)) {
99 $resultpd[] = $row;
102 echo json_encode($resultpd);