2 /********************************************************************************\
3 * Copyright (C) ViCarePlus, Visolve (vicareplus_engg@visolve.com) *
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. *
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. *
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");
24 $codetype = $_REQUEST['codetype'];
25 $form_code_type = $_POST['form_code_type'];
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'>
34 td
{ font
-size
:10pt
; }
37 <script language
="JavaScript">
38 //pass value selected to the parent window
39 function window_submit(chk
)
43 if (len
==undefined
&& chk
.checked
==1)
52 for (pr
= 0; pr
< chk
.length
; pr++
)
54 if(chk
[pr
].checked
== 1)
59 str
= str+
"#"+chk
[pr
].value
;
64 alert('<?php echo xl("Select Diagnosis");?>');
65 if (opener
.closed ||
! opener
.set_related
)
66 alert("<?php echo xl('The destination form was closed');?>");
68 opener
.set_related(str
,"diagnosis");
74 function window_close(chk
)
79 function chkbox_select_none(chk
)
82 if (len
==undefined
) {chk
.checked
=false;}
85 for (pr
= 0; pr
< chk
.length
; pr++
)
87 chk
[pr
].checked
=false;
92 function chkbox_select_all(chk
)
95 if (len
==undefined
) {chk
.checked
=true;}
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");?>');
113 top
.restoreSession();
119 <body
class="body_top">
120 <form method
='post' name
='theform' action
='find_code_popup.php' onsubmit
="return check_search_str();">
122 <input type
="hidden" name
="search_status" id
="search_status" value
=1;>
123 <table border
='0' cellpadding
='5' cellspacing
='0'>
133 echo "<input type='text' name='form_code_type' value='$codetype' size='5' readonly>\n";
135 echo " <select name='form_code_type'";
137 foreach ($code_types as $key => $value) {
138 echo " <option value='$key'";
139 if ($codetype == $key ||
$form_code_type == $key) {
143 echo ">$key</option>\n";
146 echo " <option value='PROD'";
147 if ($codetype == 'PROD' ||
$form_code_type == 'PROD') {
151 echo ">Product</option>\n";
152 echo " </select> \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
'); ?>' />
159 <input type
='submit' name
='bn_search' id
='bn_search' value
='<?php xl('Search
', 'e
'); ?>' />
170 <form method
='post' name
='select_diagonsis'>
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);
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>";
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');
205 echo xl('Please enter new search string');?>");
206 document
.theform
.search_term
.value
=" ";
207 document
.theform
.search_term
.focus();
212 $query = "SELECT code_type, code, modifier, code_text FROM codes " .
213 "WHERE (code_text LIKE '%$search_term%' OR " .
214 "code LIKE '%$search_term%') " .
216 // echo "\n<!-- $query -->\n"; // debugging
217 $res = sqlStatement($query);
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>";
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();"/>