simplify decrypt to return blank value when a empty value is sent (#2115)
[openemr.git] / interface / de_identification_forms / find_drug_popup.php
blob941277822d16c5d2fa43c36cdb0afaa994d6307b
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 \********************************************************************************/
20 require_once("../globals.php");
21 require_once("$srcdir/patient.inc");
22 require_once("../../custom/code_types.inc.php");
24 $info_msg = "";
25 $codetype = $_REQUEST['codetype'];
26 $form_code_type = $_POST['form_code_type'];
28 <html>
29 <head>
30 <?php html_header_show(); ?>
31 <title><?php echo xlt('Drug Finder'); ?></title>
32 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
34 <style>
35 td { font-size:10pt; }
36 </style>
38 <script language="JavaScript">
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 xls("Select Drug");?>');
66 if (opener.closed || ! opener.set_related)
67 alert("<?php echo xls('The destination form was closed')?>");
68 else
69 opener.set_related(str,"drugs");
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 xls("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_drug_popup.php' onsubmit="return check_search_str();">
122 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
123 <center>
124 <input type="hidden" name="search_status" id="search_status" value=1;>
125 <table border='0' cellpadding='5' cellspacing='0'>
126 <tr>
127 <td height="1">
128 </td>
129 </tr>
130 <tr>
131 <td>
133 <?php echo xlt('Search for'); ?>
134 <input type='text' name='search_term' id='search_term' size='12' value='<?php echo attr($_REQUEST['search_term']); ?>'
135 title='<?php echo xla('Any part of the drug id or drug name'); ?>' />
136 &nbsp;
137 <input type='submit' name='bn_search' id='bn_search' value='<?php echo xla('Search'); ?>' />
138 </b>
139 </td>
140 </tr>
141 <tr>
142 <td height="1">
143 </td>
144 </tr>
145 </table>
146 </center>
147 </form>
148 <form method='post' name='select_drug'>
149 <table>
150 <tr>
151 <td colspan="4">
152 <?php if ($_REQUEST['bn_search']) {
153 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
154 csrfNotVerified();
157 $search_term = $_REQUEST['search_term'];
159 $query = "SELECT count(*) as count FROM drugs " .
160 "WHERE (drug_id LIKE ? OR " .
161 "name LIKE ?) ";
162 $res = sqlStatement($query, array('%'.$search_term.'%', '%'.$search_term.'%'));
163 if ($row = sqlFetchArray($res)) {
164 $no_of_items = $row['count'];
165 if ($no_of_items < 1) {
167 <script language='JavaScript'>
168 alert("<?php echo xls('Search string does not match with list in database');
169 echo '\n';
170 echo xls('Please enter new search string');?>");
171 document.theform.search_term.value=" ";
172 document.theform.search_term.focus();
173 </script>
174 <?php
177 $query = "SELECT drug_id, name FROM drugs " .
178 "WHERE (drug_id LIKE ? OR " .
179 "name LIKE ?) " .
180 "ORDER BY drug_id";
181 $res = sqlStatement($query, array('%'.$search_term.'%', '%'.$search_term.'%'));
182 $row_count = 0;
183 while ($row = sqlFetchArray($res)) {
184 $row_count = $row_count + 1;
185 $itercode = $row['drug_id'];
186 $itertext = ucfirst(strtolower(trim($row['name'])));
188 <input type="checkbox" id="chkbox" name ="chkbox" value= "<?php echo attr($itercode) . "-" . attr($itertext); ?>" > <?php echo text($itercode) . " " . text($itertext) . "</br>";
194 </td>
195 </tr>
196 </table>
197 <center>
198 <input type='button' name='select_all' value='<?php echo xla('Select All'); ?>' onclick="chkbox_select_all(document.select_drug.chkbox);"/>
200 <input type='button' name='unselect_all' value='<?php echo xla('Unselect All'); ?>' onclick="chkbox_select_none(document.select_drug.chkbox);"/>
202 <input type='button' name='submit' value='<?php echo xla('Submit'); ?>' onclick="window_submit(document.select_drug.chkbox);"/>
204 <input type='button' name='cancel' value='<?php echo xla('Cancel'); ?>' onclick="window_close();"/>
205 </center>
206 <?php } ?>
207 </form>
208 </body>
209 </html>