feat: expose suffix and valedictory in user admin and esign (#6814)
[openemr.git] / interface / de_identification_forms / find_code_popup.php
blobb1d4483325e784c61b4dbc725b6456c29649095c
1 <?php
3 /**
4 * find_code_popup.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Visolve <vicareplus_engg@visolve.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2010 ViCarePlus, Visolve <vicareplus_engg@visolve.com>
11 * @copyright Copyright (c) 2018-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("$srcdir/patient.inc.php");
17 require_once("../../custom/code_types.inc.php");
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Core\Header;
22 $info_msg = "";
23 $codetype = $_REQUEST['codetype'];
24 $form_code_type = $_POST['form_code_type'];
26 <html>
27 <head>
28 <title><?php echo xlt('Code Finder'); ?></title>
30 <?php Header::setupHeader(); ?>
32 <style>
33 td {
34 font-size: 0.8125rem;
36 </style>
38 <script>
39 //pass value selected to the parent window
40 function window_submit(chk)
42 var str;
43 var len=chk.length;
44 if (len==undefined && chk.checked==1)
46 if(!str)
47 str = chk.value;
48 else
49 str = "#"+chk.value;
51 else
53 for (pr = 0; pr < chk.length; pr++)
55 if(chk[pr].checked == 1)
57 if(!str)
58 str = chk[pr].value;
59 else
60 str = str+"#"+chk[pr].value;
64 if(!str)
65 alert(<?php echo xlj("Select Diagnosis"); ?>);
66 if (opener.closed || ! opener.set_related)
67 alert(<?php echo xlj('The destination form was closed'); ?>);
68 else
69 opener.set_related(str,"diagnosis");
71 window.close();
75 function window_close(chk)
77 window.close();
80 function chkbox_select_none(chk)
82 var len=chk.length;
83 if (len==undefined) {chk.checked=false;}
84 else
86 for (pr = 0; pr < chk.length; pr++)
88 chk[pr].checked=false;
93 function chkbox_select_all(chk)
95 var len=chk.length;
96 if (len==undefined) {chk.checked=true;}
97 else
99 for (pr = 0; pr < chk.length; pr++)
101 chk[pr].checked=true;
106 function check_search_str()
108 var search_str = document.getElementById('search_term').value;
109 if(search_str.length < 3)
111 alert(<?php echo xlj("Search string should have at least three characters");?>);
112 return false;
114 top.restoreSession();
115 return true;
118 </script>
119 </head>
120 <body class="body_top">
121 <form method='post' name='theform' action='find_code_popup.php' onsubmit="return check_search_str();">
122 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
123 <center>
124 <input type="hidden" name="search_status" id="search_status" value=1;>
125 <table class="border-0" cellpadding='5' cellspacing='0'>
126 <tr>
127 <td height="1">
128 </td>
129 </tr>
130 <tr>
131 <td>
133 <?php
134 if ($codetype) {
135 echo "<input type='text' name='form_code_type' value='" . attr($codetype) . "' size='5' readonly>\n";
136 } else {
137 echo " <select name='form_code_type'";
138 echo ">\n";
139 foreach ($code_types as $key => $value) {
140 echo " <option value='" . attr($key) . "'";
141 if ($codetype == $key || $form_code_type == $key) {
142 echo " selected";
145 echo ">" . text($key) . "</option>\n";
148 echo " <option value='PROD'";
149 if ($codetype == 'PROD' || $form_code_type == 'PROD') {
150 echo " selected";
153 echo ">Product</option>\n";
154 echo " </select>&nbsp;&nbsp;\n";
157 <?php echo xlt('Search for'); ?>
158 <input type='text' name='search_term' id='search_term' size='12' value='<?php echo attr($_REQUEST['search_term']); ?>'
159 title='<?php xla('Any part of the desired code or its description'); ?>' />
160 &nbsp;
161 <input type='submit' name='bn_search' id='bn_search' value='<?php echo xla('Search'); ?>' />
162 </b>
163 </td>
164 </tr>
165 <tr>
166 <td height="1">
167 </td>
168 </tr>
169 </table>
170 </center>
171 </form>
172 <form method='post' name='select_diagonsis'>
173 <table class='border-0'>
174 <tr>
175 <td colspan="4">
176 <?php if ($_REQUEST['bn_search']) {
177 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
178 CsrfUtils::csrfNotVerified();
181 $search_term = $_REQUEST['search_term'];
182 if ($form_code_type == 'PROD') {
183 $query = "SELECT dt.drug_id, dt.selector, d.name " .
184 "FROM drug_templates AS dt, drugs AS d WHERE " .
185 "( d.name LIKE ? OR " .
186 "dt.selector LIKE ? ) " .
187 "AND d.drug_id = dt.drug_id " .
188 "ORDER BY d.name, dt.selector, dt.drug_id";
189 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
190 $row_count = 0;
191 while ($row = sqlFetchArray($res)) {
192 $row_count = $row_count + 1;
193 $drug_id = $row['drug_id'];
194 $selector = $row['selector'];
195 $desc = $row['name'];
197 <input type="checkbox" name="diagnosis[row_count]" value="<?php echo attr($desc); ?>" > <?php echo text($drug_id) . " " . text($selector) . " " . text($desc) . "<br />";
199 } else {
200 $query = "SELECT count(*) as count FROM codes " .
201 "WHERE (code_text LIKE ? OR " .
202 "code LIKE ?) " ;
203 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
204 if ($row = sqlFetchArray($res)) {
205 $no_of_items = $row['count'];
206 if ($no_of_items < 1) {
208 <script>
209 alert(<?php echo xlj('Search string does not match with list in database'); ?> + '\n' + <?php echo xlj('Please enter new search string');?>);
210 document.theform.search_term.value=" ";
211 document.theform.search_term.focus();
212 </script>
213 <?php
216 $query = "SELECT code_type, code, modifier, code_text FROM codes " .
217 "WHERE (code_text LIKE ? OR " .
218 "code LIKE ?) " .
219 "ORDER BY code";
220 // echo "\n<!-- $query -->\n"; // debugging
221 $res = sqlStatement($query, array('%' . $search_term . '%', '%' . $search_term . '%'));
222 $row_count = 0;
223 while ($row = sqlFetchArray($res)) {
224 $row_count = $row_count + 1;
225 $itercode = $row['code'];
226 $itertext = ucfirst(strtolower(trim($row['code_text'])));
228 <input type="checkbox" id="chkbox" value= "<?php echo attr($form_code_type) . ":" . attr($itercode) . "-" . attr($itertext); ?>" > <?php echo text($itercode) . " " . text($itertext) . "<br />";
233 </td>
234 </tr>
235 </table>
236 <center>
237 <br />
238 <div class="btn-group">
239 <input type='button' class="btn btn-primary" id='select_all' value='<?php echo xla('Select All'); ?>' onclick="chkbox_select_all(document.select_diagonsis.chkbox);"/>
241 <input type='button' class="btn btn-primary" id='unselect_all' value='<?php echo xla('Unselect All'); ?>' onclick="chkbox_select_none(document.select_diagonsis.chkbox);"/>
243 <input type='button' class="btn btn-primary" id='submit' value='<?php echo xla('Submit'); ?>' onclick="window_submit(document.select_diagonsis.chkbox);"/>
245 <input type='button' class="btn btn-primary" id='cancel' value='<?php echo xla('Cancel'); ?>' onclick="window_close();"/>
246 </div>
247 </center>
248 <?php } ?>
249 </form>
250 </body>
251 </html>