Merge pull request #1420 from priya-anand/patch-7
[openemr.git] / interface / de_identification_forms / find_code_popup.php
blob3088b8e1129dad38a8f5a843624e7c82b49ae5b6
1 <?php
2 /********************************************************************************\
3 * Copyright (C) ViCarePlus, Visolve (vicareplus_engg@visolve.com) *
4 * *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 \********************************************************************************/
19 require_once("../globals.php");
20 require_once("$srcdir/patient.inc");
21 require_once("../../custom/code_types.inc.php");
23 $info_msg = "";
24 $codetype = $_REQUEST['codetype'];
25 $form_code_type = $_POST['form_code_type'];
27 <html>
28 <head>
29 <?php html_header_show(); ?>
30 <title><?php xl('Code Finder', 'e'); ?></title>
31 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
33 <style>
34 td { font-size:10pt; }
35 </style>
37 <script language="JavaScript">
38 //pass value selected to the parent window
39 function window_submit(chk)
41 var str;
42 var len=chk.length;
43 if (len==undefined && chk.checked==1)
45 if(!str)
46 str = chk.value;
47 else
48 str = "#"+chk.value;
50 else
52 for (pr = 0; pr < chk.length; pr++)
54 if(chk[pr].checked == 1)
56 if(!str)
57 str = chk[pr].value;
58 else
59 str = str+"#"+chk[pr].value;
63 if(!str)
64 alert('<?php echo xl("Select Diagnosis");?>');
65 if (opener.closed || ! opener.set_related)
66 alert("<?php echo xl('The destination form was closed');?>");
67 else
68 opener.set_related(str,"diagnosis");
70 window.close();
74 function window_close(chk)
76 window.close();
79 function chkbox_select_none(chk)
81 var len=chk.length;
82 if (len==undefined) {chk.checked=false;}
83 else
85 for (pr = 0; pr < chk.length; pr++)
87 chk[pr].checked=false;
92 function chkbox_select_all(chk)
94 var len=chk.length;
95 if (len==undefined) {chk.checked=true;}
96 else
98 for (pr = 0; pr < chk.length; pr++)
100 chk[pr].checked=true;
105 function check_search_str()
107 var search_str = document.getElementById('search_term').value;
108 if(search_str.length < 3)
110 alert('<?php echo xl("Search string should have at least three characters");?>');
111 return false;
113 top.restoreSession();
114 return true;
117 </script>
118 </head>
119 <body class="body_top">
120 <form method='post' name='theform' action='find_code_popup.php' onsubmit="return check_search_str();">
121 <center>
122 <input type="hidden" name="search_status" id="search_status" value=1;>
123 <table border='0' cellpadding='5' cellspacing='0'>
124 <tr>
125 <td height="1">
126 </td>
127 </tr>
128 <tr>
129 <td>
131 <?php
132 if ($codetype) {
133 echo "<input type='text' name='form_code_type' value='$codetype' size='5' readonly>\n";
134 } else {
135 echo " <select name='form_code_type'";
136 echo ">\n";
137 foreach ($code_types as $key => $value) {
138 echo " <option value='$key'";
139 if ($codetype == $key || $form_code_type == $key) {
140 echo " selected";
143 echo ">$key</option>\n";
146 echo " <option value='PROD'";
147 if ($codetype == 'PROD' || $form_code_type == 'PROD') {
148 echo " selected";
151 echo ">Product</option>\n";
152 echo " </select>&nbsp;&nbsp;\n";
155 <?php xl('Search for', 'e'); ?>
156 <input type='text' name='search_term' id='search_term' size='12' value='<?php echo $_REQUEST['search_term']; ?>'
157 title='<?php xl('Any part of the desired code or its description', 'e'); ?>' />
158 &nbsp;
159 <input type='submit' name='bn_search' id='bn_search' value='<?php xl('Search', 'e'); ?>' />
160 </b>
161 </td>
162 </tr>
163 <tr>
164 <td height="1">
165 </td>
166 </tr>
167 </table>
168 </center>
169 </form>
170 <form method='post' name='select_diagonsis'>
171 <table border='0'>
172 <tr>
173 <td colspan="4">
174 <?php if ($_REQUEST['bn_search']) {
175 $search_term = $_REQUEST['search_term'];
176 if ($form_code_type == 'PROD') {
177 $query = "SELECT dt.drug_id, dt.selector, d.name " .
178 "FROM drug_templates AS dt, drugs AS d WHERE " .
179 "( d.name LIKE '%$search_term%' OR " .
180 "dt.selector LIKE '%$search_term%' ) " .
181 "AND d.drug_id = dt.drug_id " .
182 "ORDER BY d.name, dt.selector, dt.drug_id";
183 $res = sqlStatement($query);
184 $row_count = 0;
185 while ($row = sqlFetchArray($res)) {
186 $row_count = $row_count + 1;
187 $drug_id = addslashes($row['drug_id']);
188 $selector = addslashes($row['selector']);
189 $desc = addslashes($row['name']);
191 <input type="checkbox" name="diagnosis[row_count]" value= "<?php echo $desc; ?>" > <?php echo $drug_id." ".$selector." ".$desc."</br>";
193 } else {
194 $query = "SELECT count(*) as count FROM codes " .
195 "WHERE (code_text LIKE '%$search_term%' OR " .
196 "code LIKE '%$search_term%') " ;
197 $res = sqlStatement($query);
198 if ($row = sqlFetchArray($res)) {
199 $no_of_items = addslashes($row['count']);
200 if ($no_of_items < 1) {
202 <script language='JavaScript'>
203 alert("<?php echo xl('Search string does not match with list in database');
204 echo '\n';
205 echo xl('Please enter new search string');?>");
206 document.theform.search_term.value=" ";
207 document.theform.search_term.focus();
208 </script>
209 <?php
212 $query = "SELECT code_type, code, modifier, code_text FROM codes " .
213 "WHERE (code_text LIKE '%$search_term%' OR " .
214 "code LIKE '%$search_term%') " .
215 "ORDER BY code";
216 // echo "\n<!-- $query -->\n"; // debugging
217 $res = sqlStatement($query);
218 $row_count = 0;
219 while ($row = sqlFetchArray($res)) {
220 $row_count = $row_count + 1;
221 $itercode = addslashes($row['code']);
222 $itertext = addslashes(ucfirst(strtolower(trim($row['code_text']))));
224 <input type="checkbox" id="chkbox" value= "<?php echo $form_code_type.":".$itercode."-".$itertext; ?>" > <?php echo $itercode." ".$itertext."</br>";
229 </td>
230 </tr>
231 </table>
232 <center>
233 </br>
234 <input type='button' id='select_all' value='<?php xl('Select All', 'e'); ?>' onclick="chkbox_select_all(document.select_diagonsis.chkbox);"/>
236 <input type='button' id='unselect_all' value='<?php xl('Unselect All', 'e'); ?>' onclick="chkbox_select_none(document.select_diagonsis.chkbox);"/>
238 <input type='button' id='submit' value='<?php xl('Submit', 'e'); ?>' onclick="window_submit(document.select_diagonsis.chkbox);"/>
240 <input type='button' id='cancel' value='<?php xl('Cancel', 'e'); ?>' onclick="window_close();"/>
242 </center>
243 <?php } ?>
244 </form>
245 </body>
246 </html>