6 * @link http://www.open-emr.org
7 * @author Visolve <vicareplus_engg@visolve.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) ViCarePlus, Visolve <vicareplus_engg@visolve.com>
10 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
11 * @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");
17 require_once("../../custom/code_types.inc.php");
20 $codetype = $_REQUEST['codetype'];
21 $form_code_type = $_POST['form_code_type'];
25 <?php
html_header_show(); ?
>
26 <title
><?php
echo xlt('Code Finder'); ?
></title
>
27 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
30 td
{ font
-size
:10pt
; }
33 <script language
="JavaScript">
34 //pass value selected to the parent window
35 function window_submit(chk
)
39 if (len
==undefined
&& chk
.checked
==1)
48 for (pr
= 0; pr
< chk
.length
; pr++
)
50 if(chk
[pr
].checked
== 1)
55 str
= str+
"#"+chk
[pr
].value
;
60 alert('<?php echo xls("Select Diagnosis");?>');
61 if (opener
.closed ||
! opener
.set_related
)
62 alert("<?php echo xls('The destination form was closed');?>");
64 opener
.set_related(str
,"diagnosis");
70 function window_close(chk
)
75 function chkbox_select_none(chk
)
78 if (len
==undefined
) {chk
.checked
=false;}
81 for (pr
= 0; pr
< chk
.length
; pr++
)
83 chk
[pr
].checked
=false;
88 function chkbox_select_all(chk
)
91 if (len
==undefined
) {chk
.checked
=true;}
94 for (pr
= 0; pr
< chk
.length
; pr++
)
101 function check_search_str()
103 var search_str
= document
.getElementById('search_term').value
;
104 if(search_str
.length
< 3)
106 alert('<?php echo xls("Search string should have at least three characters");?>');
109 top
.restoreSession();
115 <body
class="body_top">
116 <form method
='post' name
='theform' action
='find_code_popup.php' onsubmit
="return check_search_str();">
117 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
119 <input type
="hidden" name
="search_status" id
="search_status" value
=1;>
120 <table border
='0' cellpadding
='5' cellspacing
='0'>
130 echo "<input type='text' name='form_code_type' value='" . attr($codetype) . "' size='5' readonly>\n";
132 echo " <select name='form_code_type'";
134 foreach ($code_types as $key => $value) {
135 echo " <option value='" . attr($key) . "'";
136 if ($codetype == $key ||
$form_code_type == $key) {
140 echo ">" . text($key) . "</option>\n";
143 echo " <option value='PROD'";
144 if ($codetype == 'PROD' ||
$form_code_type == 'PROD') {
148 echo ">Product</option>\n";
149 echo " </select> \n";
152 <?php
echo xlt('Search for'); ?
>
153 <input type
='text' name
='search_term' id
='search_term' size
='12' value
='<?php echo attr($_REQUEST['search_term
']); ?>'
154 title
='<?php xla('Any part of the desired code
or its description
'); ?>' />
156 <input type
='submit' name
='bn_search' id
='bn_search' value
='<?php echo xla('Search
'); ?>' />
167 <form method
='post' name
='select_diagonsis'>
171 <?php
if ($_REQUEST['bn_search']) {
172 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
176 $search_term = $_REQUEST['search_term'];
177 if ($form_code_type == 'PROD') {
178 $query = "SELECT dt.drug_id, dt.selector, d.name " .
179 "FROM drug_templates AS dt, drugs AS d WHERE " .
180 "( d.name LIKE ? OR " .
181 "dt.selector LIKE ? ) " .
182 "AND d.drug_id = dt.drug_id " .
183 "ORDER BY d.name, dt.selector, dt.drug_id";
184 $res = sqlStatement($query, array('%'.$search_term.'%', '%'.$search_term.'%'));
186 while ($row = sqlFetchArray($res)) {
187 $row_count = $row_count +
1;
188 $drug_id = $row['drug_id'];
189 $selector = $row['selector'];
190 $desc = $row['name'];
192 <input type
="checkbox" name
="diagnosis[row_count]" value
="<?php echo attr($desc); ?>" > <?php
echo text($drug_id) . " " . text($selector) . " " . text($desc) . "</br>";
195 $query = "SELECT count(*) as count FROM codes " .
196 "WHERE (code_text LIKE ? OR " .
198 $res = sqlStatement($query, array('%'.$search_term.'%', '%'.$search_term.'%'));
199 if ($row = sqlFetchArray($res)) {
200 $no_of_items = $row['count'];
201 if ($no_of_items < 1) {
203 <script language
='JavaScript'>
204 alert("<?php echo xls('Search string does not match with list in database');
206 echo xls('Please enter new search string');?>");
207 document
.theform
.search_term
.value
=" ";
208 document
.theform
.search_term
.focus();
213 $query = "SELECT code_type, code, modifier, code_text FROM codes " .
214 "WHERE (code_text LIKE ? OR " .
217 // echo "\n<!-- $query -->\n"; // debugging
218 $res = sqlStatement($query, array('%'.$search_term.'%', '%'.$search_term.'%'));
220 while ($row = sqlFetchArray($res)) {
221 $row_count = $row_count +
1;
222 $itercode = $row['code'];
223 $itertext = ucfirst(strtolower(trim($row['code_text'])));
225 <input type
="checkbox" id
="chkbox" value
= "<?php echo attr($form_code_type) . ":" . attr($itercode) . "-" . attr($itertext); ?>" > <?php
echo text($itercode) . " " . text($itertext) . "</br>";
235 <input type
='button' id
='select_all' value
='<?php echo xla('Select All
'); ?>' onclick
="chkbox_select_all(document.select_diagonsis.chkbox);"/>
237 <input type
='button' id
='unselect_all' value
='<?php echo xla('Unselect All
'); ?>' onclick
="chkbox_select_none(document.select_diagonsis.chkbox);"/>
239 <input type
='button' id
='submit' value
='<?php echo xla('Submit
'); ?>' onclick
="window_submit(document.select_diagonsis.chkbox);"/>
241 <input type
='button' id
='cancel' value
='<?php echo xla('Cancel
'); ?>' onclick
="window_close();"/>